for-any-project-min
for-any-projectをこのURLでbundleしたもの
code:script.js
var kT=Object.defineProperty;var Fo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)r}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Bi=(e,t)=>{for(var r in t)kT(e,r,{get:tr,enumerable:!0})};function _e(e){if(e)return vT(e)}function vT(e){for(var t in _e.prototype)et=_e.prototypet;return e}_e.prototype.on=_e.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};_e.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};_e.prototype.off=_e.prototype.removeListener=_e.prototype.removeAllListeners=_e.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks"$"+e;if(!r)return this;if(arguments.length==1)return delete this._callbacks"$"+e,this;for(var o,n=0;n<r.length;n++)if(o=rn,o===t||o.fn===t){r.splice(n,1);break}return r.length===0&&delete this._callbacks"$"+e,this};_e.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,o=1;o<arguments.length;o++)to-1=argumentso;if(r){r=r.slice(0);for(var o=0,n=r.length;o<n;++o)ro.apply(this,t)}return this};_e.prototype.emitReserved=_e.prototype.emit;_e.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};_e.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Or=Object.create(null);Or.open="0";Or.close="1";Or.ping="2";Or.pong="3";Or.message="4";Or.upgrade="5";Or.noop="6";var qi=Object.create(null);Object.keys(Or).forEach(e=>{qi[Ore]=e});var $l={type:"error",data:"parser error"},id=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",ad=typeof ArrayBuffer=="function",cd=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Gi=({type:e,data:t},r,o)=>id&&t instanceof Blob?r?o(t):od(t,o):ad&&(t instanceof ArrayBuffer||cd(t))?r?o(t):od(new Blob(t),o):o(Ore+(t||"")),od=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")1;t("b"+(o||""))},r.readAsDataURL(e)};function nd(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Dl;function TT(e,t){if(id&&e.data instanceof Blob)return e.data.arrayBuffer().then(nd).then(t);if(ad&&(e.data instanceof ArrayBuffer||cd(e.data)))return t(nd(e.data));Gi(e,!1,r=>{Dl||(Dl=new TextEncoder),t(Dl.encode(r))})}var sd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",_s=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<sd.length;e++)_ssd.charCodeAt(e)=e;var _T=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,a,c;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(o=0;o<r;o+=4)s=_se.charCodeAt(o),i=_se.charCodeAt(o+1),a=_se.charCodeAt(o+2),c=_se.charCodeAt(o+3),un++=s<<2|i>>4,un++=(i&15)<<4|a>>2,un++=(a&3)<<6|c&63;return l},PT=typeof ArrayBuffer=="function",zi=(e,t)=>{if(typeof e!="string")return{type:"message",data:ld(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:OT(e.substring(1),t)}:qir?e.length>1?{type:qir,data:e.substring(1)}:{type:qir}:$l},OT=(e,t)=>{if(PT){let r=_T(e);return ld(r,t)}else return{base64:!0,data:e}},ld=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},pd="",ud=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{Gi(s,!1,a=>{oi=a,++n===r&&t(o.join(pd))})})},md=(e,t)=>{let r=e.split(pd),o=[];for(let n=0;n<r.length;n++){let s=zi(rn,t);if(o.push(s),s.type==="error")break}return o};function fd(){return new TransformStream({transform(e,t){TT(e,r=>{let o=r.length,n;if(o<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,o);else if(o<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,o)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(o))}e.data&&typeof e.data!="string"&&(n0|=128),t.enqueue(n),t.enqueue(r)})}})}var Ul;function Hi(e){return e.reduce((t,r)=>t+r.length,0)}function Wi(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),o=0;for(let n=0;n<t;n++)rn=e0o++,o===e0.length&&(e.shift(),o=0);return e.length&&o<e0.length&&(e0=e0.slice(o)),r}function dd(e,t){Ul||(Ul=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(o===0){if(Hi(r)<1)break;let c=Wi(r,1);s=(c0&128)===128,n=c0&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(Hi(r)<2)break;let c=Wi(r,2);n=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),o=3}else if(o===2){if(Hi(r)<8)break;let c=Wi(r,8),l=new DataView(c.buffer,c.byteOffset,c.length),u=l.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue($l);break}n=u*Math.pow(2,32)+l.getUint32(4),o=3}else{if(Hi(r)<n)break;let c=Wi(r,n);a.enqueue(zi(s?c:Ul.decode(c),t)),o=0}if(n===0||n>e){a.enqueue($l);break}}}})}var jl=4;var Ps=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),or=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),ST="arraybuffer";function gd(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(ro=eo),r),{})}var LT=or.setTimeout,NT=or.clearTimeout;function Os(e,t){t.useNativeTimers?(e.setTimeoutFn=LT.bind(or),e.clearTimeoutFn=NT.bind(or)):(e.setTimeoutFn=or.setTimeout.bind(or),e.clearTimeoutFn=or.clearTimeout.bind(or))}var MT=1.33;function CT(e){return typeof e=="string"?IT(e):Math.ceil((e.byteLength||e.size)*MT)}function IT(e){let t=0,r=0;for(let o=0,n=e.length;o<n;o++)t=e.charCodeAt(o),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(o++,r+=4);return r}function yd(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function AT(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function FT(e){let t={},r=e.split("&");for(let o=0,n=r.length;o<n;o++){let s=ro.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var DT=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Wl=class extends _e{constructor(e){super(),this.writable=!1,Os(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,r){return super.emitReserved("error",new DT(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=zi(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:""+e+""}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=AT(e);return t.length?"?"+t:""}},UT=class extends Wl{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};md(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write({type:"close"})};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,ud(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(tthis.opts.timestampParam=yd()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},xd=!1;try{xd=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var $T=xd;function jT(){}var BT=class extends UT{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",r=location.port;r||(r=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(o,n)=>{this.onError("xhr post error",o,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},_n=class Vi extends _e{constructor(t,r,o){super(),this.createRequest=t,Os(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var t;let r=gd(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&o.setRequestHeader(n,this._opts.extraHeadersn)}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var n;o.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=Vi.requestsCount++,Vi.requeststhis._index=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=jT,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Vi.requeststhis._index,this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};_n.requestsCount=0;_n.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",hd);else if(typeof addEventListener=="function"){let e="onpagehide"in or?"pagehide":"unload";addEventListener(e,hd,!1)}}function hd(){for(let e in _n.requests)_n.requests.hasOwnProperty(e)&&_n.requestse.abort()}var HT=function(){let e=bd({xdomain:!1});return e&&e.responseType!==null}(),ql=class extends BT{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=HT&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new _n(bd,this.uri(),e)}};function bd(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||$T))return new XMLHttpRequest}catch{}if(!t)try{return new or["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Ed=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",WT=class extends Wl{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=Ed?{}:gd(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;Gi(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}o&&Ps(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(tthis.opts.timestampParam=yd()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Bl=or.WebSocket||or.MozWebSocket,Gl=class extends WT{createSocket(e,t,r){return Ed?new Bl(e,t,r):t?new Bl(e,t):new Bl(e)}doWrite(e,t){this.ws.send(t)}},wd=class extends Wl{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptionsthis.name)}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=dd(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),o=fd();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();let n=()=>{r.read().then(({done:i,value:a})=>{i||(this.onPacket(a),n())}).catch(i=>{})};n();let s={type:"open"};this.query.sid&&(s.data={"sid":"${this.query.sid}"}),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;this._writer.write(r).then(()=>{o&&Ps(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},qT={websocket:Gl,webtransport:wd,polling:ql},GT=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,zT="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function Ji(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf(""),o=e.indexOf("");r!=-1&&o!=-1&&(e=e.substring(0,r)+e.substring(r,o).replace(/:/g,";")+e.substring(o,e.length));let n=GT.exec(e||""),s={},i=14;for(;i--;)s[zTi]=ni||"";return r!=-1&&o!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("","").replace("","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=VT(s,s.path),s.queryKey=KT(s,s.query),s}function VT(e,t){let r=/\/{2,9}/g,o=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&o.splice(0,1),t.slice(-1)=="/"&&o.splice(o.length-1,1),o}function KT(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(o,n,s){n&&(rn=s)}),r}var Hl=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ki=[];Hl&&addEventListener("offline",()=>{Ki.forEach(e=>e())},!1);var Yi=class Xi extends _e{constructor(t,r){if(super(),this.binaryType=ST,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){let o=Ji(t);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Ji(r.host).host);Os(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{let n=o.prototype.name;this.transports.push(n),this._transportsByNamen=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=FT(this.opts.query)),Hl&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ki.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=jl,r.transport=t,this.id&&(r.sid=this.id);let o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptionst);return new this._transportsByNamet(o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&Xi.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports0;this.readyState="opening";let r=this.createTransport(t);r.open(),this.setTransport(r)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",Xi.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let r=new Error("server error");r.code=t.data,this._onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let o=this.writeBufferr.data;if(o&&(t+=CT(o)),r>0&&t>this._maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Ps(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,o){return this._sendPacket("message",t,r,o),this}send(t,r,o){return this._sendPacket("message",t,r,o),this}_sendPacket(t,r,o,n){if(typeof r=="function"&&(n=r,r=void 0),typeof o=="function"&&(n=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;let s={type:t,data:r,options:o};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():t()}):this.upgrading?o():t()),this}_onError(t){if(Xi.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Hl&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=Ki.indexOf(this._offlineEventListener);o!==-1&&Ki.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};Yi.protocol=jl;var YT=class extends Yi{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgradese)}_probe(e){let t=this.createTransport(e),r=!1;Yi.priorWebsocketSuccess=!1;let o=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",u=>{if(!r)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Yi.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(l(),this.setTransport(t),t.send({type:"upgrade"}),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function n(){r||(r=!0,l(),t.close(),t=null)}let s=u=>{let p=new Error("probe error: "+u);p.transport=t.name,n(),this.emitReserved("upgradeError",p)};function i(){s("transport closed")}function a(){s("socket closed")}function c(u){t&&u.name!==t.name&&n()}let l=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",o),t.once("error",s),t.once("close",i),this.once("close",a),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(er)&&t.push(er);return t}},zl=class extends YT{constructor(e,t={}){let r=typeof e=="object"?e:t;(!r.transports||r.transports&&typeof r.transports0=="string")&&(r.transports=(r.transports||"polling","websocket","webtransport").map(o=>qTo).filter(o=>!!o)),super(e,r)}};var GD=zl.protocol;var Xl={};Bi(Xl,{Decoder:()=>n0,Encoder:()=>o0,PacketType:()=>ce,protocol:()=>vd});var XT=typeof ArrayBuffer=="function",JT=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,kd=Object.prototype.toString,QT=typeof Blob=="function"||typeof Blob<"u"&&kd.call(Blob)==="object BlobConstructor",ZT=typeof File=="function"||typeof File<"u"&&kd.call(File)==="object FileConstructor";function Yl(e){return XT&&(e instanceof ArrayBuffer||JT(e))||QT&&e instanceof Blob||ZT&&e instanceof File}function Qi(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if(Qi(er))return!0;return!1}if(Yl(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Qi(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&Qi(er))return!0;return!1}function e0(e){let t=[],r=e.data,o=e;return o.data=Vl(r,t),o.attachments=t.length,{packet:o,buffers:t}}function Vl(e,t){if(!e)return e;if(Yl(e)){let r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){let r=new Array(e.length);for(let o=0;o<e.length;o++)ro=Vl(eo,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(ro=Vl(eo,t));return r}return e}function t0(e,t){return e.data=Kl(e.data,t),delete e.attachments,e}function Kl(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return te.num;throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)er=Kl(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=Kl(er,t));return e}var r0="connect","connect_error","disconnect","disconnecting","newListener","removeListener",vd=5,ce;(function(e){ee.CONNECT=0="CONNECT",ee.DISCONNECT=1="DISCONNECT",ee.EVENT=2="EVENT",ee.ACK=3="ACK",ee.CONNECT_ERROR=4="CONNECT_ERROR",ee.BINARY_EVENT=5="BINARY_EVENT",ee.BINARY_ACK=6="BINARY_ACK"})(ce||(ce={}));var o0=class{constructor(e){this.replacer=e}encode(e){return(e.type===ce.EVENT||e.type===ce.ACK)&&Qi(e)?this.encodeAsBinary({type:e.type===ce.EVENT?ce.BINARY_EVENT:ce.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===ce.BINARY_EVENT||e.type===ce.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=e0(e),r=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(r),o}};function Rd(e){return Object.prototype.toString.call(e)==="object Object"}var n0=class Td extends _e{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);let o=r.type===ce.BINARY_EVENT;o||r.type===ce.BINARY_ACK?(r.type=o?ce.EVENT:ce.ACK,this.reconstructor=new s0(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Yl(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0,o={type:Number(t.charAt(0))};if(ceo.type===void 0)throw new Error("unknown packet type "+o.type);if(o.type===ce.BINARY_EVENT||o.type===ce.BINARY_ACK){let s=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);let i=t.substring(s,r);if(i!=Number(i)||t.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););o.nsp=t.substring(s,r)}else o.nsp="/";let n=t.charAt(r+1);if(n!==""&&Number(n)==n){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}o.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(Td.isPayloadValid(o.type,s))o.data=s;else throw new Error("invalid payload")}return o}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case ce.CONNECT:return Rd(r);case ce.DISCONNECT:return r===void 0;case ce.CONNECT_ERROR:return typeof r=="string"||Rd(r);case ce.EVENT:case ce.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&r0.indexOf(r0)===-1);case ce.ACK:case ce.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},s0=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=t0(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function i0(e,t="",r){let o=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),o=Ji(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";let n=o.host.indexOf(":")!==-1?""+o.host+"":o.host;return o.id=o.protocol+"://"+n+":"+o.port+t,o.href=o.protocol+"://"+n+(r&&r.port===o.port?"":":"+o.port),o}function gr(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var a0=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),_d=class extends _e{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=gr(e,"open",this.onopen.bind(this)),gr(e,"packet",this.onpacket.bind(this)),gr(e,"error",this.onerror.bind(this)),gr(e,"close",this.onclose.bind(this))}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var r,o,n;if(a0.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let s={type:ce.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof tt.length-1=="function"){let c=this.ids++,l=t.pop();this._registerAckCallback(c,l),s.id=c}let i=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!i||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var r;let o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.ackse=t;return}let n=this.io.setTimeoutFn(()=>{delete this.ackse;for(let i=0;i<this.sendBuffer.length;i++)this.sendBufferi.id===e&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},o),s=(...i)=>{this.io.clearTimeoutFn(n),t.apply(this,i)};s.withError=!0,this.ackse=s}emitWithAck(e,...t){return new Promise((r,o)=>{let n=(s,i)=>s?o(s):r(i);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof ee.length-1=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...n)=>r!==this._queue0?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue0;t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ce.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.ackse;delete this.ackse,t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ce.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ce.EVENT:case ce.BINARY_EVENT:this.onevent(e);break;case ce.ACK:case ce.BINARY_ACK:this.onack(e);break;case ce.DISCONNECT:this.ondisconnect();break;case ce.CONNECT_ERROR:this.destroy();let t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof ee.length-1=="string"&&(this._lastOffset=ee.length-1)}ack(e){let t=this,r=!1;return function(...o){r||(r=!0,t.packet({type:ce.ACK,id:e,data:o}))}}onack(e){let t=this.ackse.id;typeof t=="function"&&(delete this.ackse.id,t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ce.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===tr)return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===tr)return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function On(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}On.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};On.prototype.reset=function(){this.attempts=0};On.prototype.setMin=function(e){this.ms=e};On.prototype.setMax=function(e){this.max=e};On.prototype.setJitter=function(e){this.jitter=e};var Jl=class extends _e{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Os(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new On({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let o=t.parser||Xl;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new zl(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=gr(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=gr(t,"error",n);if(this._timeout!==!1){let i=this._timeout,a=this.setTimeoutFn(()=>{o(),n(new Error("timeout")),t.close()},i);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(o),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(gr(e,"ping",this.onping.bind(this)),gr(e,"data",this.ondata.bind(this)),gr(e,"error",this.onerror.bind(this)),gr(e,"close",this.onclose.bind(this)),gr(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Ps(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nspse;return r?this._autoConnect&&!r.active&&r.connect():(r=new _d(this,e,t),this.nspse=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nspsr.active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(tr,e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}},Ss={};function Pn(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=i0(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=Ssn&&s in Ssn.nsps,a=t.forceNew||t"force new connection"||t.multiplex===!1||i,c;return a?c=new Jl(o,t):(Ssn||(Ssn=new Jl(o,t)),c=Ssn),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Pn,{Manager:Jl,Socket:_d,io:Pn,connect:Pn});var Pd=" must not return ",c0="transformer",l0="recoverer",p0="defaultValue",Sn=c0+Pd,Wr="called with ",Ln=p0+" must not be ",Nn=l0+Pd;var u0="Ok",Od="Err",Sd=Wr+Od,Ld=Wr+u0,Nd="Carrying E in "+Od+" instead of throwing it directly. See .cause",Ql="an instance of Error of the current realm.",MU="The thrown value is not "+Ql,CU="The contained E should be "+Ql,Md="This .cause is not "+Ql;function K(e){return e.ok}function L(e){return{ok:!0,val:e,err:null}}function O(e){return!e.ok}function M(e){return{ok:!1,val:null,err:e}}function S(e){return Zl(e,Sd)}function Z(e){return ep(e,Ld)}function Zl(e,t){if(O(e))throw new TypeError(t);return e.val}function ep(e,t){if(K(e))throw new TypeError(t);return e.err}function fe(e){return e.val}function xe(e){return e.err}function Ls(e,t){if(O(e))return e;let r=fe(e);return t(r)}async function Ns(e,t){if(O(e))return e;let r=fe(e);return await t(r)}function m0(e){return e}function tp(e){return Ls(e,m0)}function rp(e){let t=e.status;switch(t){case"fulfilled":{let r=e.value;return L(r)}case"rejected":{let r=e.reason;return M(r)}default:{let r=\`PromiseSettledResult.status=${String(t)}\` is not supported;throw new TypeError(r)}}}function op(e,t){if(K(e)){let r=fe(e);t(r)}return e}function np(e,t){if(O(e)){let r=xe(e);t(r)}return e}function sp(e,t,r){if(K(e)){let o=fe(e);t(o)}else{let o=xe(e);r(o)}return e}function Zi(e,t){if(K(e))return!1;let r=xe(e);return t(r)}function ip(e,t){return Zi(e,t)}function ea(e,t){if(O(e))return!1;let r=fe(e);return t(r)}function ap(e,t){return ea(e,t)}function qr(e,t){if(O(e))return e;let r=fe(e),o=t(r);return L(o)}async function ie(e,t){if(O(e))return e;let r=fe(e),o=await t(r);return L(o)}function cp(e,t){if(K(e))return e;let r=xe(e),o=t(r);return M(o)}async function Ae(e,t){if(K(e))return e;let r=xe(e),o=await t(r);return M(o)}function lp(e,t,r){if(K(e)){let o=fe(e);return r(o)}return t}async function pp(e,t,r){if(O(e))return t;let o=fe(e);return await r(o)}function Ms(e,t,r){if(K(e)){let n=fe(e);return r(n)}let o=xe(e);return t(o)}async function up(e,t,r){if(K(e)){let n=fe(e);return await r(n)}let o=xe(e);return await t(o)}function mp(e,t){if(K(e))return e;let r=xe(e);return t(r)}async function ta(e,t){if(K(e))return e;let r=xe(e);return await t(r)}function ra(e,t){return K(e)?t:xe(e)}function Do(e,t){return K(e)?fe(e):t}function fp(e){return Do(e,null)}function dp(e){return ra(e,null)}function hp(e){return Do(e,void 0)}function gp(e){return ra(e,void 0)}var oa="null",nr=Sn+oa,f0=Wr+oa,Mn=Ln+oa,po=Nn+oa;function je(e){return e!==null}function tt(e){return e===null}function rt(e,t){if(je(e))return e;throw new TypeError(t)}var na="undefined",sr=Sn+na,d0=Wr+na,Cn=Ln+na,uo=Nn+na;function ot(e){return e!==void 0}function nt(e){return e===void 0}function st(e,t){if(ot(e))return e;throw new TypeError(t)}function yp(e){if(O(e))return e;let t=fe(e);return tt(t)?null:L(t)}function xp(e){if(O(e))return e;let t=fe(e);if(!nt(t))return L(t)}function Cd(e){return e instanceof Error}var h0="UnknownCausalError",g0=class extends Error{constructor(e){super(Md,{cause:e}),this.name=h0}};function sa(e){return Cd(e)?e:new g0(e)}function ia(e){try{let t=e();return L(t)}catch(t){return M(t)}}function bp(e){let t=ia(e);if(K(t))return t;let r=xe(t),o=sa(r);return M(o)}async function aa(e){let t;try{t=await e()}catch(r){return M(r)}return L(t)}async function Ep(e){let t=await aa(e);if(K(t))return t;let r=xe(t),o=sa(r);return M(o)}function wp(e,t){if(K(e))return fe(e);let r=xe(e);return t(r)}async function Rp(e,t){if(K(e))return fe(e);let r=xe(e);return await t(r)}var y0="CausalCarrierError",x0=class extends Error{constructor(e){super(Nd,{cause:e}),this.name=y0}};function kp(e){if(K(e))return fe(e);let t=xe(e);throw new x0(t)}var Be=e=>e.ok?L(e):M({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Id=async(e,t)=>{let r=new Request(e,t);try{return L(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return M({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return M({name:"NetworkError",message:o.message,request:r});throw o}};var we=e=>{let{fetch:t=Id,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var Ad=e=>{let{sid:t,hostName:r}=we(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:Re(t)}}:void 0)},Fd=e=>ie(Be(e),async t=>await t.json()),ca=(()=>{let e=async t=>{let{fetch:r,...o}=we(t??{}),n=await r(Ad(o));return O(n)?n:Fd(S(n))};return e.toRequest=Ad,e.fromResponse=Fd,e})();var Re=e=>connect.sid=${e},In=async e=>{let t=e?.csrf??globalThis._csrf;return t?L(t):qr(await ca(e),r=>r.csrfToken)};var Mt=(e,t)=>{if(e?.connected)return Promise.resolve(L(e));e??=Pn("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"],...t?{rejectUnauthorized:!1,extraHeaders:{Cookie:Re(t),Host:"scrapbox.io",Referer:"https://scrapbox.io/"}}:{}});let r=new Promise(o=>{let n=s=>o(M(s));e.once("connect",()=>{e.off("disconnect",n),o(L(e))}),e.once("disconnect",n)});return e.connect(),r},Ct=e=>{if(e.disconnected)return Promise.resolve(L(void 0));let t=new Promise(r=>{let o=n=>{if(n!=="io client disconnect"){r(M(n));return}r(L(void 0)),e.off("disconnect",o)};e.on("disconnect",o)});return e.disconnect(),t};var Dd=e=>b0.includes(e.name),b0="SocketIOError","DuplicateTitleError","NotFastForwardError";var Ud=(e,t,r,o)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(L(void 0));let{resolve:n,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(u)},c=f=>{if(f==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(f==="io server disconnect"){a(),n(M({name:"SocketIOError"}));return}};e.on("disconnect",c);let l=o?.timeout??9e4,u=setTimeout(()=>{a(),n(M({name:"TimeoutError",message:exceeded ${l} (ms)}))},l),p=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",p,f=>{if(a(),"error"in f){n(M(Dd(f.error)?f.error:{name:"UnexpectedRequestError",...f}));return}n(L(f.data))}),s};function la(e,t={}){if(e===null)return"null";if(Array.isArray(e))return E0(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:w0(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function E0(e,t){let{threshold:r=20}=t,o=e.map(i=>la(i,t)),n=o.join(", ");if(n.length<=r)return[${n}];let s=o.join(`,
);return[
${$d(2,s)}
]}function w0(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${la(ei,t)}),n=o.join(", ");if(n.length<=r)return{${n}};let s=o.join(,
);return{
${$d(2,s)}
}}function $d(e,t){let r=" ".repeat(e);return t.split(
).map(o=>${r}${o}).join(
)}function ut(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${t}(${r.map(n=>la(n)).join(", ")}),o)}})}function yr(e){return Array.isArray(e)}function Cs(e){return ut(t=>yr(t)&&t.every(r=>e(r)),"isArrayOf",e)}function Uo(e){let t=new Set(e);return ut(r=>t.has(r),"isLiteralOneOf",e)}function mo(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function ke(e){return typeof e=="string"}var mt=async(e,t)=>{let r=e.response.clone(),o=Uo(t);try{let n=await r.json();if(!mo(n))return;if(r.status===422){if(!ke(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!ke(n.message)?void 0:n.name==="NotLoggedInError"?!mo(n.detals)||!ke(n.detals.project)||!Cs(R0)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},R0=Uo(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var ae=e=>e.replaceAll(" ","_").toLowerCase();var ne=e=>[...e].map((t,r)=>t===" "?"_":!k0.includes(t)||r===e.length-1&&v0.includes(t)?encodeURIComponent(t):t).join(""),k0='@$&+=:;",',v0=':;",';var pa="null or undefined",ir=Sn+pa,T0=Wr+pa,An=Ln+pa,fo=Nn+pa;function Ve(e){return e!=null}function Ke(e){return e==null}function Ye(e,t){if(Ve(e))return e;throw new TypeError(t)}function vp(e,t){return Ke(e)?e:t(e)}async function Tp(e,t){return Ke(e)?e:await t(e)}function _p(e,t){return Ve(e)&&t(e),e}function Pp(e,t){if(Ke(e))return e;let r=t(e);return Ye(r,ir)}async function Op(e,t){if(Ke(e))return e;let r=await t(e);return Ye(r,ir)}function Sp(e,t,r){let o,n="";return e!=null?(o=r(e),n=ir):(o=t,n=An),Ye(o,n)}async function Lp(e,t,r){if(Ke(e))return Ye(t,An);let o=await r(e);return Ye(o,ir)}function Np(e,t,r){let o,n="";return e!=null?(o=r(e),n=ir):(o=t(),n=fo),Ye(o,n)}async function Mp(e,t,r){let o,n="";return Ve(e)?(o=await r(e),n=ir):(o=await t(),n=fo),Ye(o,n)}function Cp(e,t){return Ve(e)?L(e):M(t)}function Is(e,t){if(Ve(e))return L(e);let r=t();return M(r)}async function Ip(e,t){if(Ve(e))return L(e);let r=await t();return M(r)}function Ap(e,t){return e??t()}async function Fp(e,t){return Ve(e)?e:await t()}function Dp(e){return Ke(e)?null:e}function ua(e){return Ke(e)?M(void 0):L(e)}function Up(e){return Ke(e)?L(void 0):M(e)}function $p(e){if(!Ke(e))return e}function As(e,t){return Ve(e)?e:Ye(t,An)}function jp(e,t){if(Ve(e))return e;let r=t();return Ye(r,fo)}async function Bp(e,t){if(Ve(e))return e;let r=await t();return Ye(r,fo)}var jd=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:i}=we(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(https://${n}/api/pages/${e}/${ne(t)}?${a},o?{headers:{Cookie:Re(o)}}:void 0)},Bd=async e=>Ae(await ie(Be(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:As(await mt(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),ar=(()=>{let e=async(t,r,o)=>Ns(await we(o??{}).fetch(jd(t,r,o)),n=>Bd(n));return e.toRequest=jd,e.fromResponse=Bd,e})();var Hd=(e,t)=>{let{sid:r,hostName:o}=we(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:Re(r)}}:void 0)},Wd=async e=>ie(await Ae(Be(e),async t=>await mt(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),$o=(()=>{let e=async(t,r)=>{let{fetch:o}=we(r??{}),n=Hd(t,r),s=await o(n);return O(s)?s:Wd(S(s))};return e.toRequest=Hd,e.fromResponse=Wd,e})(),qd=(e,t)=>{let{sid:r,hostName:o}=we(t??{}),n=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${o}/api/projects?${n},r?{headers:{Cookie:Re(r)}}:void 0)},Gd=async e=>ie(await Ae(Be(e),async t=>await mt(t,["NotLoggedInError"])??t),t=>t.json()),ma=(()=>{let e=async(t,r)=>{let{fetch:o}=we(r??{}),n=await o(qd(t,r));return O(n)?n:Gd(S(n))};return e.toRequest=qd,e.fromResponse=Gd,e})();var Wp=async(e,t,r)=>{let[o,n,s]=await Promise.all([ar(e,t,r),P0(r),O0(e,r)]);return O(o)?o:O(n)?n:O(s)?s:L({...S(o),projectId:S(s),userId:S(n)})},Hp,P0=async e=>{if(Hp)return L(Hp);let t=await ca(e);if(O(t))return t;let r=S(t);return"id"in r?(Hp=r.id,L(r.id)):M({name:"NotLoggedInError",message:"This script cannot be used without login"})},zd=new Map,O0=async(e,t)=>{let r=zd.get(e);return r?L(r):qr(await $o(e,t),({id:o})=>(zd.set(e,o),o))};function Fe(e,t={}){let{signal:r,persistent:o=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((n,s)=>{let i=()=>{clearTimeout(+c),s(r?.reason)},c=S0(()=>{r?.removeEventListener("abort",i),n()},e);if(r?.addEventListener("abort",i,{once:!0}),o===!1)try{Deno.unrefTimer(+c)}catch(l){if(!(l instanceof ReferenceError))throw clearTimeout(+c),l;console.error("persistent option is only available in Deno")}})}var Vd=2**31-1;function S0(e,t){let r=t=Math.trunc(Math.max(t,0)||0),o=Date.now(),n,s=()=>{r=t-(Date.now()-o),n=r>Vd?Number(setTimeout(s,Vd)):Number(setTimeout(e,r))};return s(),{valueOf:()=>n}}var jo=async(e,t,r,o)=>{let n=await Mt(o?.socket,o?.sid);if(O(n))return M({name:"UnexpectedRequestError",error:Z(n)});let s=S(n),i=await Wp(e,t,o);if(O(i))return i;let a=S(i);try{let c=0,l=[],u;for(;o?.maxAttempts===void 0||c<o.maxAttempts;){let p=r(a,c,l,u);if(l=p instanceof Promise?await p:p,c++,l.length===0)return L(a.commitId);let f={kind:"page",projectId:a.projectId,pageId:a.id,parentId:a.commitId,userId:a.userId,changes:l,cursor:null,freeze:!0};for(;;){let m=await Ud(s,"commit",f);if(K(m))return a.commitId=S(m).commitId,L(a.commitId);let h=Z(m),g=h.name;if(g==="SocketIOServerDisconnectError"||g==="UnexpectedRequestError")return M(h);if(g==="TimeoutError"||g==="SocketIOError"){await Fe(3e3);continue}if(g==="NotFastForwardError"){await Fe(1e3);let y=await Wp(e,t,o);if(O(y))return y;a=S(y)}u=g;break}}return M({name:"RetryError",attempts:c,message:Retrying exceeded the maxAttempts (${c}).})}finally{o?.socket||await Ct(s)}};var qp=(e,t)=>{let r=e.length>t.length,o=r?t:e,n=r?e:t,s=o.length+1,i=o.length+n.length+3,a=new Array(i);a.fill(-1);let c=[];function l(g,y,x){let w=Math.max(y,x),k=w-g;for(;k<o.length&&w<n.length&&o[k]===n[w];)++k,++w;return a[g+s]=c.length,c.push([{x:k,y:w},a[g+(y>x?-1:1)+s]]),w}let u=new Array(i);u.fill(-1);let p=-1,f=n.length-o.length;do{++p;for(let g=-p;g<=f-1;++g)u[g+s]=l(g,u[g-1+s]+1,u[g+1+s]);for(let g=f+p;g>=f+1;--g)u[g+s]=l(g,u[g-1+s]+1,u[g+1+s]);u[f+s]=l(f,u[f-1+s]+1,u[f+1+s])}while(u[f+s]!==n.length);let m=[],h=a[f+s];for(;h!==-1;)m.push(c[h][0]),h=c[h][1];return{from:e,to:t,editDistance:f+p*2,buildSES:function*(){let g=0,y=0;for(let{x,y:w}of L0(m))for(;g<x||y<w;)w-x>y-g?(yield{value:n[y],type:r?"deleted":"added"},++y):w-x<y-g?(yield{value:o[g],type:r?"added":"deleted"},++g):(yield{value:o[g],type:"common"},++g,++y)}}};function*Gp(e){let t=[],r=[];function*o(){if(t.length>r.length){for(let n=0;n<r.length;n++)yield Kd(t[n],r[n]);for(let n=r.length;n<t.length;n++)yield t[n]}else{for(let n=0;n<t.length;n++)yield Kd(t[n],r[n]);for(let n=t.length;n<r.length;n++)yield r[n]}t=[],r=[]}for(let n of e)switch(n.type){case"added":t.push(n);break;case"deleted":r.push(n);break;case"common":yield*o(),yield n;break}yield*o()}var Kd=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*L0(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var Yd=e=>e.padStart(8,"0"),zp=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${Yd(t).slice(-8)}${e.slice(-6)}0000${Yd(r)}};function*Vp(e,t,{userId:r}){let{buildSES:o}=qp(e.map(({text:i})=>i),t),n=0,s=e[0].id;for(let i of Gp(o())){switch(i.type){case"added":yield{_insert:s,lines:{id:zp(r),text:i.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:i.value}};break}n++,s=e[n]?.id??"_end"}}var Xd=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(i=>i.text.substring(o+1)).join(
)}};var le=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let a of o){let c=a.exec(n);if(c===null)continue;let l=n.substring(0,c.index),u=n.substring(c.index+(c[0]?.length??0)),p=e(c[0]??"",s);return[...jt(l,s),...p,...jt(u,s)]}return i?.()??[]};var de=e=>[{type:"plain",raw:e,text:e}],Jd=le(de,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var N0=/\[\s+\]/,M0=(e,t)=>t.context==="table"?de(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],Qd=le(M0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[N0]});var C0=/.*?/,I0=(e,t)=>t.context==="table"?de(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],Zd=le(I0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[C0]});var A0=/^[$%] .+$/,F0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},eh=le(F0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[A0]});var D0=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,U0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let i=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(i,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:jt(n,{...t,nested:!0})}]},th=le(U0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[D0]});var $0=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,j0=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,B0=/\[https?:\/\/[^\s\]]+\]/,H0=/https?:\/\/[^\s]+/,W0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},rh=le(W0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[$0,j0,B0,H0]});var q0=/\[\$ .+? \]/,G0=/\[\$ [^\]]+\]/,z0=(e,t)=>t.context==="table"?de(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],oh=le(z0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[q0,G0]});var nh=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,sh=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,V0=e=>{let[t="",r="",o=""]=e.split(","),n=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(o)?Number.parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:i}},K0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.match(nh)??e.match(sh);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,n="",s=""]=o?r:[r[0],r[2],r[1]],{latitude:i,longitude:a,zoom:c}=V0(n),l=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${i},${a},${c}z:https://www.google.com/maps/@${i},${a},${c}z;return[{type:"googleMap",raw:e,latitude:i,longitude:a,zoom:c,place:s,url:l}]},ih=le(K0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[nh,sh]});var Y0=/(?:^|\s)#\S+/,X0=(e,t)=>{if(t.context==="table")return de(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...de(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},ah=le(X0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Y0]});var J0=/^\? .+$/,Q0=(e,t)=>t.context==="table"?de(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],ch=le(Q0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[J0]});var Z0=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,e_=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),o=t.substring(0,r),n=o.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),i=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:o,pathType:n,type:"icon",raw:e}))},lh=le(e_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Z0]});var t_=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,r_=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,o_=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,n_=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,s_=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||i_(e),i_=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),a_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,i]=s_(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:i}]},ph=le(a_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[t_,r_,o_,n_]});var c_=/\[\/?[^[\]]+\]/,l_=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},uh=le(l_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[c_]});var p_=/^[0-9]+\. .*$/,u_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=Number.parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:jt(s,{...t,nested:!1})}]},mh=le(u_,{parseOnNested:!1,parseOnQuoted:!1,patterns:[p_]});var m_=/^>.*$/,f_=(e,t)=>t.context==="table"?de(e,t):[{type:"quote",raw:e,nodes:jt(e.substring(1),{...t,quoted:!0})}],fh=le(f_,{parseOnNested:!1,parseOnQuoted:!1,patterns:[m_]});var d_=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,h_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.substring(2,e.length-2),o=r.lastIndexOf(".icon"),n=r.substring(0,o),s=n.startsWith("/")?"root":"relative",i=r.substring(o+5,r.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},dh=le(h_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[d_]});var g_=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,y_=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,x_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?${r}/thumb/1000:r}]},hh=le(x_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[g_,y_]});var b_=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,E_=(e,t)=>t.context==="table"?de(e,t):[{type:"strong",raw:e,nodes:jt(e.substring(2,e.length-2),{...t,nested:!0})}],gh=le(E_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[b_]});var w_=(e,t,r)=>e===""?[]:r?.()??[],R_=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>Jd(t,r))(),jt=R_(w_,fh,ch,mh,Zd,eh,Qd,th,oh,hh,dh,gh,ph,rh,lh,ih,uh,ah);var yh=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:jt(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var xh=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(i=>i.text.substring(o+1)).map(i=>i.split(" ").map(a=>jt(a,{nested:!1,quoted:!1,context:"table"})))}};var bh=e=>({type:"title",text:e.rows[0].text});var Eh=e=>{switch(e.type){case"title":return bh(e);case"codeBlock":return Xd(e);case"table":return xh(e);case"line":return yh(e)}};var k_=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),wh=(e,t)=>{let r=e[e.length-1];return r!==void 0&&k_(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)},Rh=(e,t)=>{if(t.hasTitle??!0){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(wh,[])]}return e.reduce(wh,[])};var kh=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var it=(e,t)=>{let r=kh(e);return Rh(r,{hasTitle:t?.hasTitle??!0}).map(Eh)},vh=e=>/^\s*\S.*$/m.exec(e)?.[0]?.trim()??"Untitled";var v_=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,T_=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,__=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,P_=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,fa=e=>{if(v_.test(e)){let t=new URL(e).searchParams,r=t.get("v");if(r)return{pathType:"com",videoId:r,params:t}}{let t=e.match(T_);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(__);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(P_);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Ph=e=>{let t=it(e,{hasTitle:!0}),r="",o=new Map,n=[],s=new Set,i=[],a=new Set,c=[],l=null,u=[],p=new Set,f=new Set,m=new RegExp(${globalThis.location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),h=x=>{switch(x.type){case"hashTag":if(o.has(ae(x.href)))return;o.set(ae(x.href),!1),n.push(x.href);return;case"link":switch(x.pathType){case"relative":{let w=_h(x.href);if(o.get(ae(w)))return;o.set(ae(w),!0),n.push(w);return}case"root":{let w=_h(x.href);if(/^\/[\w\d-]+\/?$/.test(w)||s.has(ae(w)))return;s.add(ae(w)),i.push(w);return}case"absolute":{if(x.content)return;let w=fa(x.href);if(w&&w.pathType!=="list"){l??=https://i.ytimg.com/vi/${w.videoId}/mqdefault.jpg;return}let k=x.href.match(m)?.[1];k&&p.add(k);return}default:return}case"icon":case"strongIcon":{if(x.pathType==="root"||a.has(ae(x.path)))return;a.add(ae(x.path)),c.push(x.path);return}case"image":case"strongImage":{l??=x.src.endsWith("/thumb/1000")?x.src.replace(/\/thumb\/1000$/,"/raw"):x.src;{let w=x.src.match(m)?.[1];w&&p.add(w)}if(x.type==="image"){let w=x.link.match(m)?.[1];w&&p.add(w)}return}case"helpfeel":f.add(x.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let w of x.nodes)h(w);return}default:return}},g=[];for(let x of t)switch(x.type){case"title":{r=x.text;continue}case"line":u.length<5&&x.nodes.length>0&&u.push(x.nodes[0].type==="helpfeel"||x.nodes[0].type==="commandLine"?Th(x.nodes[0].raw):x.nodes.map(w=>w.raw).join("").trim().slice(0,200));for(let w of x.nodes)h(w);continue;case"codeBlock":u.length<5&&u.push(Th(x.content));continue;case"table":{for(let w of x.cells)for(let k of w)for(let b of k)h(b);if(!["infobox","cosense"].includes(x.fileName))continue;g.push(...x.cells.map(w=>w.map(k=>k.map(b=>b.raw).join("")).join(" ").trim()));continue}}let y=e.split(
);return[r,n,i,c,l,u,[...p],[...f],g,y.length,y.reduce((x,w)=>x+[...w].length,0)]},Th=e=>\${e.trim().replaceAll("","\\").slice(0,198)}\`,_h=e=>e.replace(/#a-f\d{24,32}$/,"");var ho=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));var Oh=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?t.trimStart().slice(2):[]);function*Sh(e,t,r){let o=t.flatMap(g=>(ke(g)?g:g.text).split(`
));for(let g of Vp(e.lines,o,{userId:r}))yield g;let[n,s,i,a,c,l,u,p,f,m,h]=Ph(o.join(
));(e.title!==n||!e.persistent)&&(yield{title:n}),ho(e.links,s)||(yield{links:s}),ho(e.projectLinks,i)||(yield{projectLinks:i}),ho(e.icons,a)||(yield{icons:a}),e.image!==c&&(yield{image:c}),ho(e.descriptions,l)||(yield{descriptions:l}),ho(e.files,u)||(yield{files:u}),ho(Oh(e.lines),p)||(yield{helpfeels:p}),ho(e.infoboxDefinition,f)||(yield{infoboxDefinition:f}),yield{linesCount:m},yield{charsCount:h}}var Lh=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,o=t?.[2]?parseInt(t[2])+1:2;return${r}_${o}};var Nh=()=>Number.MAX_SAFE_INTEGER-Math.floor(Date.now()/1e3);var Le=(e,t,r,o)=>jo(e,t,async(n,s,i,a)=>{if(a==="DuplicateTitleError"){let m=Lh(t);return i.map(h=>("title"in h&&(h.title=m),h))}let c=r(n.lines,{...n,attempts:s}),l=c instanceof Promise?await c:c;if(l===void 0)return[];let[u,p]=Array.isArray(l)?[l,void 0]:[l.lines,l.pin];if(u.length===0)return[{deleted:!0}];let f=n.lines===u?[]:[...Sh(n,u,n.userId)];return p!==void 0&&(p&&n.pin===0||!p&&n.pin>0)&&f.push({pin:p?Nh():0}),f},o);var Mh=(e,t,r)=>jo(e,t,o=>o.persistent?[{deleted:!0}]:[],r);var da=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i}=we(o??{}),a=await In(o);if(O(a))return a;let c=new Request(https://${s}/api/pages/${e}/replace/links,{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":S(a),...n?{Cookie:Re(n)}:{}},body:JSON.stringify({from:t,to:r})}),l=await i(c);return O(l)?l:ie(await Ae(Be(S(l)),async u=>await mt(u,["NotFoundError","NotLoggedInError","NotMemberError"])??u),async u=>{let{message:p}=await u.json();return parseInt(p.match(/\d+/)?.[0]??"0")})};var Ch=(e,t)=>{let{sid:r,hostName:o,followingId:n}=we(t??{});return new Request(https://${o}/api/pages/${e}/search/titles${n??followingId=${n}:""},r?{headers:{Cookie:Re(r)}}:void 0)},Ih=async e=>ie(await Ae(Be(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await mt(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),L_=(()=>{let e=async(t,r)=>{let o=await we(r??{}).fetch(Ch(t,r));return O(o)?o:Ih(S(o))};return e.toRequest=Ch,e.fromResponse=Ih,e})();async function*Ah(e,t){let r;do{let o=await L_(e,{followingId:r,...t});if(O(o)){yield o;return}let n=S(o);yield L(n.pages),r=n.followingId}while(r)}var Fh=async(e,t,r)=>{let{sid:o,hostName:n,fetch:s}=we(r??{}),i=new Request(https://${n}/api/pages/${t}/search/query?q=${encodeURIComponent(e)},o?{headers:{Cookie:Re(o)}}:void 0),a=await s(i);return O(a)?a:ie(await Ae(Be(S(a)),async c=>await mt(c,["NotFoundError","NotLoggedInError","NotMemberError","NoQueryError"])??c),c=>c.json())};var Dh=(e,t,r,o)=>{let{sid:n,hostName:s}=we(o??{});return new Request(https://${s}/api/code/${e}/${ne(t)}/${ne(r)},n?{headers:{Cookie:Re(n)}}:void 0)},Uh=async e=>ie(await Ae(Be(e),async t=>t.response.status===404&&t.response.headers.get("Content-Type")?.includes?.("text/plain")?{name:"NotFoundError",message:"Code block is not found"}:await mt(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),ha=(()=>{let e=async(t,r,o,n)=>{let s=Dh(t,r,o,n),i=await we(n??{}).fetch(s);return O(i)?i:Uh(S(i))};return e.toRequest=Dh,e.fromResponse=Uh,e})();var Yp=e=>{let t=typeof e=="string"?new TextEncoder().encode(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=[1732584193,4023233417,2562383102,271733878],o=new Uint8Array(Kp),n=0,s=0,i=0;[r,o,n,s,i]=jh(r,o,n,s,i,t);let a=Kp-n;a<9&&(a+=Kp);let c=new Uint8Array(a);c[0]=128,[s,i]=[s<<3,i<<3|s>>>29],c[c.length-8]=s&255,c[c.length-7]=s>>>8&255,c[c.length-6]=s>>>16&255,c[c.length-5]=s>>>24&255,c[c.length-4]=i&255,c[c.length-3]=i>>>8&255,c[c.length-2]=i>>>16&255,c[c.length-1]=i>>>24&255,[r,o,n,s,i]=jh(r,o,n,s,i,new Uint8Array(c.buffer));let l=new ArrayBuffer(16),u=new DataView(l);return u.setUint32(0,r[0],!0),u.setUint32(4,r[1],!0),u.setUint32(8,r[2],!0),u.setUint32(12,r[3],!0),l},Kp=64,z=(e,t)=>e<<t|e>>>32-t,It=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,$h=(e,t)=>{let[r,o,n,s]=e,i=It(t,0),a=It(t,4),c=It(t,8),l=It(t,12),u=It(t,16),p=It(t,20),f=It(t,24),m=It(t,28),h=It(t,32),g=It(t,36),y=It(t,40),x=It(t,44),w=It(t,48),k=It(t,52),b=It(t,56),T=It(t,60);return r=o+z(((n^s)&o^s)+r+i+3614090360,7),s=r+z(((o^n)&r^n)+s+a+3905402710,12),n=s+z(((r^o)&s^o)+n+c+606105819,17),o=n+z(((s^r)&n^r)+o+l+3250441966,22),r=o+z(((n^s)&o^s)+r+u+4118548399,7),s=r+z(((o^n)&r^n)+s+p+1200080426,12),n=s+z(((r^o)&s^o)+n+f+2821735955,17),o=n+z(((s^r)&n^r)+o+m+4249261313,22),r=o+z(((n^s)&o^s)+r+h+1770035416,7),s=r+z(((o^n)&r^n)+s+g+2336552879,12),n=s+z(((r^o)&s^o)+n+y+4294925233,17),o=n+z(((s^r)&n^r)+o+x+2304563134,22),r=o+z(((n^s)&o^s)+r+w+1804603682,7),s=r+z(((o^n)&r^n)+s+k+4254626195,12),n=s+z(((r^o)&s^o)+n+b+2792965006,17),o=n+z(((s^r)&n^r)+o+T+1236535329,22),r=o+z(((o^n)&s^n)+r+a+4129170786,5),s=r+z(((r^o)&n^o)+s+f+3225465664,9),n=s+z(((s^r)&o^r)+n+x+643717713,14),o=n+z(((n^s)&r^s)+o+i+3921069994,20),r=o+z(((o^n)&s^n)+r+p+3593408605,5),s=r+z(((r^o)&n^o)+s+y+38016083,9),n=s+z(((s^r)&o^r)+n+T+3634488961,14),o=n+z(((n^s)&r^s)+o+u+3889429448,20),r=o+z(((o^n)&s^n)+r+g+568446438,5),s=r+z(((r^o)&n^o)+s+b+3275163606,9),n=s+z(((s^r)&o^r)+n+l+4107603335,14),o=n+z(((n^s)&r^s)+o+h+1163531501,20),r=o+z(((o^n)&s^n)+r+k+2850285829,5),s=r+z(((r^o)&n^o)+s+c+4243563512,9),n=s+z(((s^r)&o^r)+n+m+1735328473,14),o=n+z(((n^s)&r^s)+o+w+2368359562,20),r=o+z((o^n^s)+r+p+4294588738,4),s=r+z((r^o^n)+s+h+2272392833,11),n=s+z((s^r^o)+n+x+1839030562,16),o=n+z((n^s^r)+o+b+4259657740,23),r=o+z((o^n^s)+r+a+2763975236,4),s=r+z((r^o^n)+s+u+1272893353,11),n=s+z((s^r^o)+n+m+4139469664,16),o=n+z((n^s^r)+o+y+3200236656,23),r=o+z((o^n^s)+r+k+681279174,4),s=r+z((r^o^n)+s+i+3936430074,11),n=s+z((s^r^o)+n+l+3572445317,16),o=n+z((n^s^r)+o+f+76029189,23),r=o+z((o^n^s)+r+g+3654602809,4),s=r+z((r^o^n)+s+w+3873151461,11),n=s+z((s^r^o)+n+T+530742520,16),o=n+z((n^s^r)+o+c+3299628645,23),r=o+z((n^(o|~s))+r+i+4096336452,6),s=r+z((o^(r|~n))+s+m+1126891415,10),n=s+z((r^(s|~o))+n+b+2878612391,15),o=n+z((s^(n|~r))+o+p+4237533241,21),r=o+z((n^(o|~s))+r+w+1700485571,6),s=r+z((o^(r|~n))+s+l+2399980690,10),n=s+z((r^(s|~o))+n+y+4293915773,15),o=n+z((s^(n|~r))+o+a+2240044497,21),r=o+z((n^(o|~s))+r+h+1873313359,6),s=r+z((o^(r|~n))+s+T+4264355552,10),n=s+z((r^(s|~o))+n+f+2734768916,15),o=n+z((s^(n|~r))+o+k+1309151649,21),r=o+z((n^(o|~s))+r+u+4149444226,6),s=r+z((o^(r|~n))+s+x+3174756917,10),n=s+z((r^(s|~o))+n+c+718787259,15),o=n+z((s^(n|~r))+o+g+3951481745,21),[e[0]+r>>>0,e[1]+o>>>0,e[2]+n>>>0,e[3]+s>>>0]},jh=(e,t,r,o,n,s)=>{let i=64-r;if(s.length<i)t.set(s,r),r+=s.length;else{t.set(s.slice(0,i),r),e=$h(e,t);let a=i;for(;a+64<=s.length;)e=$h(e,s.slice(a,a+64)),a+=64;t.fill(0).set(s.slice(a),0),r=s.length-a}return[o,n]=N_(o,n,s.length),[e,t,r,o,n]},N_=(e,t,r)=>(e+=r,e>4294967295&&(t+=1),[e>>>0,t]);var M_=new TextEncoder().encode("0123456789abcdef"),Bh=new Uint8Array(128).fill(16);M_.forEach((e,t)=>Bh[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Bh[e]=t+10);function Hh(e){return e*2}function Wh(e,t,r,o){for(;t<e.length;++t){let n=e[t];e[r++]=o[n>>4],e[r++]=o[n&15]}return r}function qh(e,t){let r=e.length;if(e.byteOffset){let o=new Uint8Array(e.buffer);o.set(e),e=o.subarray(0,r)}return e=new Uint8Array(e.buffer.transfer(t)),e.set(e.subarray(0,r),t-r),[e,t-r]}var Gh=new TextEncoder().encode("0123456789abcdef"),zh=new Uint8Array(128).fill(16);Gh.forEach((e,t)=>zh[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>zh[e]=t+10);function Xp(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,r]=qh(e,Hh(e.length));return Wh(t,r,0,Gh),new TextDecoder().decode(t)}var Vh=async e=>{let t=e.title??".watchlistrc",r="projectsLastAccessed.json",o=await ha(e.project,t,r),n=O(o)?{}:JSON.parse(S(o)||"{}"),s=JSON.parse(localStorage.getItem("projectsLastAccessed")??"{}"),i=new Set([...Object.keys(n),...Object.keys(s)]),a=Object.fromEntries([...i].map(l=>[l,Math.max(n[l]??0,s[l]??0)]).sort((l,u)=>u[1]-l[1])),c=JSON.stringify(a);localStorage.setItem("projectsLastAccessed",c),await Le(e.project,t,()=>[t,"This page is automatically generated. DO NOT EDIT ANYTHING, WHITCH WILL BE OVERWRITTEN.","",code:${r}, ${c},""])};var Qt=!1,ga=e=>{Qt=typeof e=="boolean"?e:new Set(e)},Fn=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},Jp,...o)];case"log":case"info":case"debug":return[t,(...o)=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(%c${e},Jp,...o)}];case"assert":return[t,(o,...n)=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(o,%c${e},Jp,...n)}];case"time":case"timeEnd":return[t,o=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(Qt!==!0&&(!Qt||!Qt.has(e))))return r(...o)}]}})),Jp="color: gray";var Gr=globalThis.scrapbox;var Fs=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}};var Kh=e=>{let{accessToken:t,fetch:r,page:o,per:n}=Fs(e??{}),i=https://api.gyazo.com/api/images?${new URLSearchParams({access_token:t,...n!==void 0?{per_page:${Math.max(1,Math.min(100,Math.round(n)))}}:{},...o!==void 0?{page:${o}}:{}})};return r(i)};var Yh=(e,t)=>{let{title:r,description:o,metadataIsPublic:n,collectionId:s,refererURL:i,accessToken:a,created:c,app:l,fetch:u}=Fs(t),p=new FormData;return p.append("imagedata",e),p.append("access_token",a),i&&p.append("referer_url",i.toString()),l!==void 0&&p.append("app",l),r!==void 0&&p.append("title",r),o!=null&&p.append("desc",o),s&&p.append("collection_id",s),n&&p.append("metadata_is_public","true"),c!==void 0&&p.append("created_at",${c}),u("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:p})};var Dn="Gyazo Viewer",Xh=e=>{let t=Promise.resolve(),r=globalThis.GM_fetch;Gr.PageMenu.addMenu({title:r?Dn:"Open Gyazo",icon:"kamon kamon-gyazo",onClick:r?()=>{t=t.then(()=>C_({per:e.maxCount??10,accessToken:e.accessToken,fetch:r,onClick:e.onClick}))}:()=>globalThis.open("https://gyazo.com/captures")})},C_=async e=>{let t;try{let r=Kh({page:0,...e});t=setTimeout(()=>{Gr.PageMenu(Dn).addItem({title:"Loading...",icon:"fas fa-spinner",onClick:()=>{}})},100);let o=await r;if(!o.ok)throw new Error(${o.status} ${o.statusText});let n=await o.json();clearTimeout(t),Gr.PageMenu(Dn).removeAllItems();for(let s of n)s.image_id&&Gr.PageMenu(Dn).addItem({title:s.metadata?.title||"Untitled",image:s.url,onClick:i=>e.onClick?.(s,i)??navigator?.clipboard?.writeText?.(s.permalink_url)?.catch?.(a=>{alert(${a}),console.error(a)})})}catch(r){clearTimeout(t),Gr.PageMenu(Dn).removeAllItems(),Gr.PageMenu(Dn).addItem({title:"Failed to load the image list.",icon:"fas fa-exclamation-triangle",onClick:()=>{}}),console.error("Failed to load the image list",r)}};import{GYAZO_ACCESS_TOKEN as PD}from"https://scrapbox.io/api/code/takker-memex/GYAZO_ACCESS_TOKEN/auth.js";var Ea,re,eg,I_,Bo,Jh,tg,rg,og,ru,Qp,Zp,ng,Ds={},sg=[],A_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Us=Array.isArray;function zr(e,t){for(var r in t)e[r]=t[r];return e}function ou(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Vr(e,t,r){var o,n,s,i={};for(s in t)s=="key"?o=t[s]:s=="ref"?n=t[s]:i[s]=t[s];if(arguments.length>2&&(i.children=arguments.length>3?Ea.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)i[s]===void 0&&(i[s]=e.defaultProps[s]);return xa(e,i,o,n,null)}function xa(e,t,r,o,n){var s={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:n??++eg,__i:-1,__u:0};return n==null&&re.vnode!=null&&re.vnode(s),s}function ee(e){return e.children}function xr(e,t){this.props=e,this.context=t}function Un(e,t){if(t==null)return e.__?Un(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?Un(e):null}function ig(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return ig(e)}}function eu(e){(!e.__d&&(e.__d=!0)&&Bo.push(e)&&!ba.__r++||Jh!=re.debounceRendering)&&((Jh=re.debounceRendering)||tg)(ba)}function ba(){for(var e,t,r,o,n,s,i,a=1;Bo.length;)Bo.length>a&&Bo.sort(rg),e=Bo.shift(),a=Bo.length,e.__d&&(r=void 0,o=void 0,n=(o=(t=e).__v).__e,s=[],i=[],t.__P&&((r=zr({},o)).__v=o.__v+1,re.vnode&&re.vnode(r),nu(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?[n]:null,s,n??Un(o),!!(32&o.__u),i),r.__v=o.__v,r.__.__k[r.__i]=r,lg(s,r,i),o.__e=o.__=null,r.__e!=n&&ig(r)));ba.__r=0}function ag(e,t,r,o,n,s,i,a,c,l,u){var p,f,m,h,g,y,x,w=o&&o.__k||sg,k=t.length;for(c=F_(r,t,w,c,k),p=0;p<k;p++)(m=r.__k[p])!=null&&(f=m.__i==-1?Ds:w[m.__i]||Ds,m.__i=p,y=nu(e,m,f,n,s,i,a,c,l,u),h=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&su(f.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(x=!!(4&m.__u))||f.__k===m.__k?c=cg(m,c,e,x):typeof m.type=="function"&&y!==void 0?c=y:h&&(c=h.nextSibling),m.__u&=-7);return r.__e=g,c}function F_(e,t,r,o,n){var s,i,a,c,l,u=r.length,p=u,f=0;for(e.__k=new Array(n),s=0;s<n;s++)(i=t[s])!=null&&typeof i!="boolean"&&typeof i!="function"?(c=s+f,(i=e.__k[s]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?xa(null,i,null,null,null):Us(i)?xa(ee,{children:i},null,null,null):i.constructor==null&&i.__b>0?xa(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,a=null,(l=i.__i=D_(i,r,c,p))!=-1&&(p--,(a=r[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(n>u?f--:n<u&&f++),typeof i.type!="function"&&(i.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,i.__u|=4))):e.__k[s]=null;if(p)for(s=0;s<u;s++)(a=r[s])!=null&&!(2&a.__u)&&(a.__e==o&&(o=Un(a)),ug(a,a));return o}function cg(e,t,r,o){var n,s;if(typeof e.type=="function"){for(n=e.__k,s=0;n&&s<n.length;s++)n[s]&&(n[s].__=e,t=cg(n[s],t,r,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=Un(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function go(e,t){return t=t||[],e==null||typeof e=="boolean"||(Us(e)?e.some(function(r){go(r,t)}):t.push(e)),t}function D_(e,t,r,o){var n,s,i,a=e.key,c=e.type,l=t[r],u=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||u&&a==l.key&&c==l.type)return r;if(o>(u?1:0)){for(n=r-1,s=r+1;n>=0||s<t.length;)if((l=t[i=n>=0?n--:s++])!=null&&!(2&l.__u)&&a==l.key&&c==l.type)return i}return-1}function Qh(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||A_.test(t)?r:r+"px"}function ya(e,t,r,o,n){var s,i;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||Qh(e.style,t,"");if(r)for(t in r)o&&r[t]==o[t]||Qh(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(og,"$1")),i=t.toLowerCase(),t=i in e||t=="onFocusOut"||t=="onFocusIn"?i.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?o?r.u=o.u:(r.u=ru,e.addEventListener(t,s?Zp:Qp,s)):e.removeEventListener(t,s?Zp:Qp,s);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function Zh(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=ru++;else if(t.t<r.u)return;return r(re.event?re.event(t):t)}}}function nu(e,t,r,o,n,s,i,a,c,l){var u,p,f,m,h,g,y,x,w,k,b,T,v,A,F,D,N,_=t.type;if(t.constructor!=null)return null;128&r.__u&&(c=!!(32&r.__u),s=[a=t.__e=r.__e]),(u=re.__b)&&u(t);e:if(typeof _=="function")try{if(x=t.props,w="prototype"in _&&_.prototype.render,k=(u=_.contextType)&&o[u.__c],b=u?k?k.props.value:u.__:o,r.__c?y=(p=t.__c=r.__c).__=p.__E:(w?t.__c=p=new _(x,b):(t.__c=p=new xr(x,b),p.constructor=_,p.render=$_),k&&k.sub(p),p.props=x,p.state||(p.state={}),p.context=b,p.__n=o,f=p.__d=!0,p.__h=[],p._sb=[]),w&&p.__s==null&&(p.__s=p.state),w&&_.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=zr({},p.__s)),zr(p.__s,_.getDerivedStateFromProps(x,p.__s))),m=p.props,h=p.state,p.__v=t,f)w&&_.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),w&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(w&&_.getDerivedStateFromProps==null&&x!==m&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(x,b),!p.__e&&p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(x,p.__s,b)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(p.props=x,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(P){P&&(P.__=t)}),T=0;T<p._sb.length;T++)p.__h.push(p._sb[T]);p._sb=[],p.__h.length&&i.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(x,p.__s,b),w&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}if(p.context=b,p.props=x,p.__P=e,p.__e=!1,v=re.__r,A=0,w){for(p.state=p.__s,p.__d=!1,v&&v(t),u=p.render(p.props,p.state,p.context),F=0;F<p._sb.length;F++)p.__h.push(p._sb[F]);p._sb=[]}else do p.__d=!1,v&&v(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++A<25);p.state=p.__s,p.getChildContext!=null&&(o=zr(zr({},o),p.getChildContext())),w&&!f&&p.getSnapshotBeforeUpdate!=null&&(g=p.getSnapshotBeforeUpdate(m,h)),D=u,u!=null&&u.type===ee&&u.key==null&&(D=pg(u.props.children)),a=ag(e,Us(D)?D:[D],t,r,o,n,s,i,a,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&i.push(p),y&&(p.__E=p.__=null)}catch(P){if(t.__v=null,c||s!=null)if(P.then){for(t.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else{for(N=s.length;N--;)ou(s[N]);tu(t)}else t.__e=r.__e,t.__k=r.__k,P.then||tu(t);re.__e(P,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=U_(r.__e,t,r,o,n,s,i,c,l);return(u=re.diffed)&&u(t),128&t.__u?void 0:a}function tu(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(tu)}function lg(e,t,r){for(var o=0;o<r.length;o++)su(r[o],r[++o],r[++o]);re.__c&&re.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(s){s.call(n)})}catch(s){re.__e(s,n.__v)}})}function pg(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:Us(e)?e.map(pg):zr({},e)}function U_(e,t,r,o,n,s,i,a,c){var l,u,p,f,m,h,g,y=r.props,x=t.props,w=t.type;if(w=="svg"?n="http://www.w3.org/2000/svg":w=="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((m=s[l])&&"setAttribute"in m==!!w&&(w?m.localName==w:m.nodeType==3)){e=m,s[l]=null;break}}if(e==null){if(w==null)return document.createTextNode(x);e=document.createElementNS(n,w,x.is&&x),a&&(re.__m&&re.__m(t,s),a=!1),s=null}if(w==null)y===x||a&&e.data==x||(e.data=x);else{if(s=s&&Ea.call(e.childNodes),y=r.props||Ds,!a&&s!=null)for(y={},l=0;l<e.attributes.length;l++)y[(m=e.attributes[l]).name]=m.value;for(l in y)if(m=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")p=m;else if(!(l in x)){if(l=="value"&&"defaultValue"in x||l=="checked"&&"defaultChecked"in x)continue;ya(e,l,null,m,n)}}for(l in x)m=x[l],l=="children"?f=m:l=="dangerouslySetInnerHTML"?u=m:l=="value"?h=m:l=="checked"?g=m:a&&typeof m!="function"||y[l]===m||ya(e,l,m,y[l],n);if(u)a||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=""),ag(t.type=="template"?e.content:e,Us(f)?f:[f],t,r,o,w=="foreignObject"?"http://www.w3.org/1999/xhtml":n,s,i,s?s[0]:r.__k&&Un(r,0),a,c),s!=null)for(l=s.length;l--;)ou(s[l]);a||(l="value",w=="progress"&&h==null?e.removeAttribute("value"):h!=null&&(h!==e[l]||w=="progress"&&!h||w=="option"&&h!=y[l])&&ya(e,l,h,y[l],n),l="checked",g!=null&&g!=e[l]&&ya(e,l,g,y[l],n))}return e}function su(e,t,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(n){re.__e(n,r)}}function ug(e,t,r){var o,n;if(re.unmount&&re.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||su(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){re.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)o[n]&&ug(o[n],t,r||typeof e.type!="function");r||ou(e.__e),e.__c=e.__=e.__e=void 0}function $_(e,t,r){return this.constructor(e,r)}function Rt(e,t,r){var o,n,s,i;t==document&&(t=document.documentElement),re.__&&re.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],i=[],nu(t,e=(!o&&r||t).__k=Vr(ee,null,[e]),n||Ds,Ds,t.namespaceURI,!o&&r?[r]:n?null:t.firstChild?Ea.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o,i),lg(s,e,i)}function $s(e){function t(r){var o,n;return this.getChildContext||(o=new Set,(n={})[t.__c]=this,this.getChildContext=function(){return n},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(i){i.__e=!0,eu(i)})},this.sub=function(s){o.add(s);var i=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),i&&i.call(s)}}),r.children}return t.__c="__cC"+ng++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,o){return r.children(o)}).contextType=t,t}Ea=sg.slice,re={__e:function(e,t,r,o){for(var n,s,i;t=t.__;)if((n=t.__c)&&!n.__)try{if((s=n.constructor)&&s.getDerivedStateFromError!=null&&(n.setState(s.getDerivedStateFromError(e)),i=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,o||{}),i=n.__d),i)return n.__E=n}catch(a){e=a}throw e}},eg=0,I_=function(e){return e!=null&&e.constructor==null},xr.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=zr({},this.state),typeof e=="function"&&(e=e(zr({},r),this.props)),e&&zr(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),eu(this))},xr.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),eu(this))},xr.prototype.render=ee,Bo=[],tg=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,rg=function(e,t){return e.__v.__b-t.__v.__b},ba.__r=0,og=/(PointerCapture)$|Capture$/i,ru=0,Qp=Zh(!1),Zp=Zh(!0),ng=0;var Ho,Me,iu,mg,js=0,Eg=[],Xe=re,fg=Xe.__b,dg=Xe.__r,hg=Xe.diffed,gg=Xe.__c,yg=Xe.unmount,xg=Xe.__;function Bs(e,t){Xe.__h&&Xe.__h(Me,e,js||t),js=0;var r=Me.__H||(Me.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Q(e){return js=1,yo(wg,e)}function yo(e,t,r){var o=Bs(Ho++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):wg(void 0,t),function(a){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,a);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=Me,!Me.__f)){var n=function(a,c,l){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!s||s.call(this,a,c,l);var p=o.__c.props!==a;return u.forEach(function(f){if(f.__N){var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(p=!0)}}),s&&s.call(this,a,c,l)||p};Me.__f=!0;var s=Me.shouldComponentUpdate,i=Me.componentWillUpdate;Me.componentWillUpdate=function(a,c,l){if(this.__e){var u=s;s=void 0,n(a,c,l),s=u}i&&i.call(this,a,c,l)},Me.shouldComponentUpdate=n}return o.__N||o.__}function te(e,t){var r=Bs(Ho++,3);!Xe.__s&&cu(r.__H,t)&&(r.__=e,r.u=t,Me.__H.__h.push(r))}function Ra(e,t){var r=Bs(Ho++,4);!Xe.__s&&cu(r.__H,t)&&(r.__=e,r.u=t,Me.__h.push(r))}function ft(e){return js=5,H(function(){return{current:e}},[])}function H(e,t){var r=Bs(Ho++,7);return cu(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function U(e,t){return js=8,H(function(){return e},t)}function Kr(e){var t=Me.context[e.__c],r=Bs(Ho++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(Me)),t.props.value):e.__}function j_(){for(var e;e=Eg.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(wa),e.__H.__h.forEach(au),e.__H.__h=[]}catch(t){e.__H.__h=[],Xe.__e(t,e.__v)}}Xe.__b=function(e){Me=null,fg&&fg(e)},Xe.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),xg&&xg(e,t)},Xe.__r=function(e){dg&&dg(e),Ho=0;var t=(Me=e.__c).__H;t&&(iu===Me?(t.__h=[],Me.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(wa),t.__h.forEach(au),t.__h=[],Ho=0)),iu=Me},Xe.diffed=function(e){hg&&hg(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Eg.push(t)!==1&&mg===Xe.requestAnimationFrame||((mg=Xe.requestAnimationFrame)||B_)(j_)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),iu=Me=null},Xe.__c=function(e,t){t.some(function(r){try{r.__h.forEach(wa),r.__h=r.__h.filter(function(o){return!o.__||au(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],Xe.__e(o,r.__v)}}),gg&&gg(e,t)},Xe.unmount=function(e){yg&&yg(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{wa(o)}catch(n){t=n}}),r.__H=void 0,t&&Xe.__e(t,r.__v))};var bg=typeof requestAnimationFrame=="function";function B_(e){var t,r=function(){clearTimeout(o),bg&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,35);bg&&(t=requestAnimationFrame(r))}function wa(e){var t=Me,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),Me=t}function au(e){var t=Me;e.__c=e.__(),Me=t}function cu(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==e[o]})}function wg(e,t){return typeof t=="function"?t(e):t}function Je(e){return typeof e=="number"}var H_=(e,t,r)=>{let o=t.name||"anonymous predicate",n=typeof e,s=JSON.stringify(e,null,2);returnExpected ${r??"a value"} that satisfies the predicate ${o}, got ${n}: ${s}},W_=H_,lu=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name=this.constructor.name}};function Rg(e,t,r={}){if(!t(e))throw new lu(r.message??W_(e,t,r.name))}function pu(e,t,r={}){return Rg(e,t,r),e}function qt(e){return typeof e>"u"}var ka=!1,kg=null,vg=()=>{scrapbox.addListener("lines:changed",()=>ka=!1),scrapbox.addListener("layout:changed",()=>ka=!1),vg=void 0},Tg=()=>(vg?.(),ka||(kg=scrapbox.Page.lines,ka=!0),kg);var _g=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Pg=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Og=()=>va(document.getElementById("editor"),"div#editor"),Hs=()=>va(document.getElementsByClassName("lines").item(0),"div.lines");var dt=()=>{let e=document.getElementById("text-input");if(e)return Pg(e,"textarea#text-input"),e};var Sg=()=>va(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Lg=()=>va(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),va=(e,t)=>{if(e)return _g(e,t),e};var At=()=>{let e=Hs();if(!e)throw Error("div.lines is not found.");let 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 e[t].return.stateNode.props.lines};var Zt=e=>e.match(/^(\s*)/)?.[1]?.length??0,Wo=(e,t)=>{let r=Zt(Ng(e,t)),o=0;for(;e+o+1<t.length&&Zt(Ng(e+o+1,t))>r;)o++;return o},Ng=(e,t)=>{let r=t[e];return ke(r)?r:r.text};var uu=e=>{if(qt(e))return;if(Je(e))return Ta(e)?.id;if(ke(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)},Mg=e=>{if(qt(e))return;if(Je(e))return e;let t=uu(e);return t?At().findIndex(r=>r.id===t):-1};var Ta=e=>{if(qt(e))return;if(Je(e))return At()[e];let t=uu(e);return t?At().find(r=>r.id===t):void 0},Yr=e=>{if(Cg(e))return e;let t=uu(e);if(qt(t))return t;let r=document.getElementById(L${t});if(!qt(r))return r},Cg=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var xo=()=>pu(Tg(),yr),kt=e=>{if(qt(e))return;if(Je(e)||ke(e))return Ta(e)?.text;if(!(e instanceof HTMLElement))return;if(Cg(e))return Ta(e)?.text;if(e.classList.contains("char-index"))return e.textContent??void 0;if(e.classList.contains("line")||e.getElementsByClassName("lines")?.[0])return At().map(({text:o})=>o).join(
);let t=[],r=Ta(e);if(!qt(r)){for(let o of G_(e))t.push(z_(o));return r.text.slice(Math.min(...t),Math.max(...t)+1)}};var Ig=()=>{let e=Hs()?.firstElementChild;if(!qt(e))return e},Ag=()=>{let e=Hs()?.lastElementChild;if(!qt(e))return e};var mu=e=>{let t=Mg(e);if(!qt(t))return Wo(t,xo())};function*G_(e){let t=e.getElementsByClassName("char-index");for(let r=0;r<t.length;r++)yield t[0]}var fu=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index"),z_=e=>{if(!fu(e))throw Error("A char DOM is required.");let t=e.className.match(/c-(\d+)/)?.[1];if(qt(t))throw Error('.char-index must have ".c-{\\d}"');return parseInt(t)},Fg=e=>{let t=e?.getElementsByClassName?.("c-0")?.[0];return fu(t)?t:void 0};var Ws=(e,t)=>{let r=Yr(e)?.getElementsByClassName?.(c-${t})?.[0];return fu(r)?r:void 0};var vt=(e,t)=>{let{noModifiedKeys:r=!1,...o}=t??{},n={bubbles:!0,cancelable:!0,keyCode:V_[e],...r?{}:{...o}},s=dt();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",n)),s.dispatchEvent(new KeyboardEvent("keyup",n))},V_={Backspace:8,Tab:9,Enter:13,Delete:46,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,a:65,A:65,b:66,B:66,c:67,C:67,d:68,D:68,e:69,E:69,f:70,F:70,g:71,G:71,h:72,H:72,i:73,I:73,j:74,J:74,k:75,K:75,l:76,L:76,m:77,M:77,n:78,N:78,o:79,O:79,p:80,P:80,q:81,Q:81,r:82,R:82,s:83,S:83,t:84,T:84,u:85,U:85,v:86,V:86,w:87,W:87,x:88,X:88,y:89,Y:89,z:90,Z:90,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,F1:113,F2:114,F3:115,F4:116,F5:117,F6:118,F7:119,F8:120,F9:121,F10:122,F11:123,F12:124,":":186,"*":186,";":187,"+":187,"-":189,"=":189,".":190,">":190,"/":191,"?":191,"@":192,"":192,"":219,"{":219,"\\":220,"|":220,"":221,"}":221,"^":222,"~":222,_:226};var du=async(e,t)=>{let r={button:t.button??0,clientX:t.X,clientY:t.Y,bubbles:!0,cancelable:!0,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,view:window};e.dispatchEvent(new MouseEvent("mousedown",r)),e.dispatchEvent(new MouseEvent("mouseup",r)),e.dispatchEvent(new MouseEvent("click",r)),await Fe(10)};var ht=()=>{let e=dt();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.cursor must has the property whose name starts with "__reactFiber"');return et.return.return.stateNode.props};var hu=e=>{let{top:t,bottom:r}=e.getBoundingClientRect();return t>=0&&r<=globalThis.innerHeight};function Ft(e,t,r){if(r??=e>t?-1:1,!Number.isFinite(e))throw new RangeError(start must be finite, but got ${e}.);if(!Number.isFinite(r))throw new RangeError(step must be finite, but got ${r}.);if(r===0)throw new RangeError("step must not be 0.");if(!Number.isFinite(t))throw new RangeError(stop must be finite, but got ${t}.);if(r>0&&e>t)throw new RangeError("start must be less than stop for positive step.");if(r<0&&e<t)throw new RangeError("start must be greater than stop for negative step.");return function*(){if(r>=0)for(let o=e;o<=t;o+=r)yield o;else for(let o=e;o>=t;o+=r)yield o}()}var Dg=()=>{vt("Home"),vt("Home")};var Ug=async()=>{let e=Ig();if(!e)throw Error(".line:first-of-type can't be found.");hu(e)||e.scrollIntoView({block:"center"});let t=Fg(e);if(!t)throw Error(".line:first-of-type .c-0 can't be found.");let{left:r,top:o}=t.getBoundingClientRect();await du(e,{X:r,Y:o})},$g=async()=>{await Bg(Ag())},jg=async e=>{await Bg(Yr(e))},Bg=async e=>{if(!e)throw Error("The target line DOM is failed to find.");hu(e)||e.scrollIntoView({block:"center"});let{right:t,top:r,height:o}=e.getElementsByClassName("text")0.getBoundingClientRect();await du(e,{X:t+1,Y:r+o/2})};var Hg=(e=1)=>{for(let t of Ft(1,e))vt("z",{ctrlKey:!0})},Wg=(e=1)=>{for(let t of Ft(1,e))vt("z",{shiftKey:!0,ctrlKey:!0})};var qg=async(e,t,r)=>{await jg(e),Dg();for(let o of Ft(e,t))vt("ArrowDown",{shiftKey:!0});vt("End",{shiftKey:!0}),await at(r)};var _a=(e=1)=>{for(let t of Ft(1,e))vt("ArrowRight",{ctrlKey:!0})},Pa=(e=1)=>{for(let t of Ft(1,e))vt("ArrowLeft",{ctrlKey:!0})};var Oa=(e=1)=>{for(let t of Ft(1,e))vt("ArrowUp",{ctrlKey:!0})},Sa=(e=1)=>{for(let t of Ft(1,e))vt("ArrowDown",{ctrlKey:!0})},La=(e=1)=>{for(let t of Ft(1,e))vt("ArrowRight",{altKey:!0})},Na=(e=1)=>{for(let t of Ft(1,e))vt("ArrowLeft",{altKey:!0})};var Ma=(e=1)=>{for(let t of Ft(1,e))vt("ArrowUp",{altKey:!0})},Ca=(e=1)=>{for(let t of Ft(1,e))vt("ArrowDown",{altKey:!0})},at=e=>{let t=dt();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});return t.dispatchEvent(r),scrapbox.Page.waitForSave()};var De=()=>{let e=Lg();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=Gg(...r);o&&t.append(o)},dispose:()=>t.remove(),Symbol.dispose:()=>t.remove()}},Gg=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":returnY_();case"check-circle":returnX_();case"exclamation-triangle":returnJ_();case"text":returnIa(o.text);case"group":{let n=Gg(...o.items);return n?n:[]}}});if(t.length===0)return;if(t.length===1)return t0;let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},Ia=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Y_=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Ia(e)},X_=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Ia(e)},J_=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Ia(e)};var $n=e=>{let t=JSON.parse(localStorage.getItem("pageTransitionContext")??""),r=e.type==="page"?e.from.project===e.to.project?e.from.title===e.to.title?{titleHint:e.to.title}:{linkFrom:e.from.title}:{linkFrom:/${e.from.project}/${e.from.title}}:{searchQuery:e.query};t[page_${ae(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var Q_=(e,t,r)=>{let o=new URL(/${e}/${ne(t)},location.href);if(r?.body&&(o.search=?body=${encodeURIComponent(r.body)}),r?.id&&(o.hash=#${r.id}),r?.context&&$n({...r?.context,to:{project:e,title:t}}),r?.newTab!==!1&&(r?.newTab===!0||e!==scrapbox.Project.name)){globalThis.open(o);return}if(r?.reload!==!1&&(r?.reload===!0||e!==scrapbox.Project.name)){globalThis.open(o,"_self");return}let n=document.createElement("a");n.href=o.toString(),document.body.append(n),n.click(),n.remove()},gu=(e,t,r)=>Q_(e,t,{newTab:!1,reload:!1,body:r});var bo=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}},Aa=async(e,t)=>{let r=t.clone();return await(await caches.open(Z_(new Date))).put(e,r)},Z_=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var Bt=()=>{let e=dt();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 r=et.return.return.stateNode._stores,o=r.find(s=>s.constructor.name==="Cursor");if(!o)throw Error('#text-input must has a "Cursor" store.');let n=r.find(s=>s.constructor.name==="Selection");if(!n)throw Error('#text-input must has a "Selection" store.');return{cursor:o,selection:n}};var Eo=()=>Bt().cursor;var Fa=()=>Bt().selection;var qs=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),zg=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 Da=new Map,yu=new Map,xu=()=>{scrapbox.on("layout:changed",()=>{let e=dt();if(e)for(lett,rof Da)for(leto,nof r)for(let s of n)e.addEventListener(t,o,zg(s))}),xu=void 0},Vg=(e,t,r)=>{xu?.();let o=Da.get(e)??new Map,n=o.get(t)??new Set;if(n.has(qs(r)))return;if(n.add(qs(r)),o.set(t,n),Da.set(e,o),typeof r=="object"&&r?.once){let i=yu.get(t)??new Map,a=qs(r),c=function(u){return bu(e,t,r),i.delete(a),t.call(this,u)};i.set(a,c),yu.set(t,i);let l=dt();if(!l)return;l.addEventListener(e,c,r)}let s=dt();s&&s.addEventListener(e,t,r)},bu=(e,t,r)=>{xu?.();let o=Da.get(e);if(!o)return;let n=o.get(t);if(!n)return;let s=qs(r);if(n.delete(s),typeof r=="object"&&r?.once){let a=yu.get(t);if(!a)return;let c=a.get(s);if(!c)return;let l=dt();if(!l)return;l.removeEventListener(e,c,r),a.delete(s);return}let i=dt();i&&i.removeEventListener(e,t,r)};var Kg={"&":"\\x26","!":"\\x21","#":"\\x23",$:"\\$","%":"\\x25","*":"\\*","+":"\\+",",":"\\x2c",".":"\\.",":":"\\x3a",";":"\\x3b","<":"\\x3c","=":"\\x3d",">":"\\x3e","?":"\\?","@":"\\x40","^":"\\^","":"\\x60","~":"\\x7e","(":"\\(",")":"\\)","[":"\\[","]":"\\]","{":"\\{","}":"\\}","/":"\\/","-":"\\x2d","\\":"\\\\","|":"\\|"},eP=new RegExp(${Object.values(Kg).join("")},"gu");function Yg(e){return e.replaceAll(eP,t=>Kg[t]).replace(/^[0-9a-zA-Z]/,t=>\\x${t.codePointAt(0).toString(16)})}var tP=0,T8=Array.isArray;function d(e,t,r,o,n,s){t||(t={});var i,a,c=t;if("ref"in c)for(a in c={},t)a=="ref"?i=t[a]:c[a]=t[a];var l={type:e,props:c,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--tP,__i:-1,__u:0,__source:n,__self:s};if(typeof e=="function"&&(i=e.defaultProps))for(a in i)c[a]===void 0&&(c[a]=i[a]);return re.vnode&&re.vnode(l),l}var Xg=({project:e,title:t,words:r,lines:o,query:n,close:s})=>{let i=U(c=>{$n({type:"search",query:n,to:{project:e,title:t}}),!(c.metaKey||c.ctrlKey||c.altKey||c.shiftKey)&&s()},[e,t,n,s]),a=H(()=>{let c=new RegExp((${r.map(l=>Yg(l)).join("|")}),"i");return o.flatMap(l=>{let u=l.split(c);return d("span",{children:u.map((p,f)=>f%2===0?p:d("strong",{children:p}))})})},[o,r]);return d("a",{href:/${e}/${ne(t)},target:${e===scrapbox.Project.name?"":"_blank"},rel:${e===scrapbox.Project.name?"route":"noopener noreferrer"},onClick:i,children:[t,d("div",{className:"description",children:a})]})};var Jg=e=>{let[t,r]=Q(e),o=U(()=>r(!0),[]),n=U(()=>r(!1),[]),s=U(()=>r(i=>!i),[]);return[t,{open:o,close:n,toggle:s}]};var Qg=(e,t)=>{let[r,o]=Q(),[n,s]=Q(!1),i=ft(Promise.resolve());return te(()=>{if(t===""){o(void 0);return}let a=!1;return i.current=(async()=>{if(await i.current,!a){s(!0);try{let c=await Fh(t,e);if(a)return;o(K(c)?S(c):void 0)}finally{s(!1)}}})(),()=>a=!0},[t,e]),{loading:n,result:r}};var Zg=()=>d("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;
gap: 0.2em;
flex-direction: column;
}
input {
border-radius: 5px;
padding: 0 10px;
height: 32px;
border: transparent;
box-shadow: none;
color: var(--search-form-text-color, rgba(255, 255, 255, 0.35));
background-color: var(--search-form-bg, rgba(255, 255, 255, 0.15))
}
.result {
flex-direction: column;
width: 100%;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
font-weight: normal;
line-height: 28px;
text-align: left;
border: 1px solid rgba(0,0,0,0.15);
border-radius: 4px;
background-clip: padding-box;
white-space: nowrap;
overflow-x: hidden;
overflow-y: auto;
}
a {
display: block;
padding: 3px 20px;
clear: both;
align-items: center;
user-select: none;
text-decoration: none;
overflow: hidden;
text-overflow: ellipsis;
color: inherit;
}
.description {
margin-top: 0.5em;
color: var(--incremental-fulltext-search-description-text-color, #c4c4c4);
font-size: 12px;
line-height: 14px;
max-height: 28px;
overflow: hidden;
text-overflow: ellipsis;
}
.description strong {
background-color: #ff0;
color: #666;
}
.spinner::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: 1;
content: "\f110";
font-family: "Font Awesome 5 Free";
font-weight: 900;
margin: 0;
padding: 0;
box-sizing: border-box;
animation: fa-spin 2s linear infinite;
}});var rP=()=>d("i",{className:"spinner"}),ey=({exportOps:e})=>{let[t,r]=Q(""),o=scrapbox.Project.name,{loading:n,result:s}=Qg(o,t),i=U(m=>{r(m.currentTarget.value)},[]),[a,{open:c,close:l,toggle:u}]=Jg(!1),p=ft({open:c,close:l,toggle:u});te(()=>{Object.assign(p.current,{open:c,close:l,toggle:u})},[]),te(()=>e(p.current),[e]);let f=U(m=>{m.target instanceof HTMLElement&&m.target.id==="background"&&l()},[]);return d(ee,{children:[d(Zg,{}),d("div",{id:"background",className:modal${a?"":" closed"},onClick:f,children:[d("div",{className:"controller",children:[d("input",{type:"text",value:t,onInput:i}),d("div",{className:"info",children:[n&&d(rP,{}),${s?.pages?.length??0} pages]})]}),s?.pages&&s.pages.length>0&&d("ul",{className:"result",children:s.pages.map(m=>d("li",{children:d(Xg,{...m,project:o,query:t,close:l})},m.title))})]})]})};var ty=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});return document.body.append(e),new Promise(r=>{Rt(d(ey,{exportOps:r}),t)})};var Ua=(e,t)=>Object.hasOwn(e,t),ry={left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",bs:"Backspace",menu:"ContextMenu",apps:"ContextMenu",del:"Delete",return:"Enter",cr:"Enter",esc:"Escape",pgup:"PageUp",pgdn:"PageDown",lt:"<",less:"<",lesser:"<",gt:">",greater:">"},iy=e=>{let t=e.toLowerCase();return Ua(ry,t)?ry[t]:e},oy={Backquote:["","~"],Digit1:"1","!",Digit2:"2","@",Digit3:"3","#",Digit4:"4","$",Digit5:"5","%",Digit6:"6","^",Digit7:"7","&",Digit8:"8","*",Digit9:"9","(",Digit0:"0",")",Minus:"-","_",Equal:"=","+",Backslash:"\\","|",BracketLeft:["","{",BracketRight:"","}"],Semicolon:";",":",Quote:"'",'"',Comma:",","<",Period:".",">",Slash:"/","?"},oP=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return Ua(oy,e)?oyet?1:0:e},ny={"<":"lt",">":"gt"},nP=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,Eu=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=oP(e.code||"",t):(r=iy(r),r===" "&&(r="Space")),nP.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let o="";return e.altKey&&(o+="a-"),e.ctrlKey&&(o+="c-"),e.metaKey&&(o+="m-"),t&&(o+="s-"),Ua(ny,r)&&(r=nyr),o||r.length>1?<${o}${r}>:r},sy={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},sP=e=>{if(e.length===1)return/\s/.test(e)?{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}}:{ok:!0,value:{key:e}};let t=e.match(/^<((?:a-z-)*)(a-z\d+|^<>\s)>$/i);if(!t)return{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}};let,r,o=t,n={key:iy(o)};for(let s of r.split("-").slice(0,-1)){let i=s.toLowerCase();if(!Ua(sy,i))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let a=syi;if(na!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(na=!0,n.key.length===1&&n.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:n}},ay=e=>{let t=sP(e);return t.ok?{ok:!0,value:Eu(t.value)}:t},cy=e=>e.match(/<^<>\s+>|\s\S|^$/g);var cr=!1;var ly=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,r;switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{cr!==!0&&(!cr||!cr.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{cr!==!0&&(!cr||!cr.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{cr!==!0&&(!cr||!cr.has(e))||r(${e} ${o})}];default:returnt,(...o)=>{if(!(cr!==!0&&(!cr||!cr.has(e))))return r(...o)}}}));var qo=ly("ScrapBindings:mod.ts"),$a=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let o=new Map,n=[];for(lets,iof t instanceof Map?t.entries():typeof t=="string"?t,r:Object.entries(t)){let a=py(s);if(!a.ok){for(let l of a.value)qo.error(${s}: ${l.message});o.set(s,a.value);continue}let c=a.value;this.bindings.set(c,i),c.startsWith(this.currentSequence)&&this.filtered.add(c),n.push(c)}return qo.debug("Binded the following commands:",n),this.emitChange(),o}unbind(...t){for(let r of t){let o=py(r);if(!o.ok)continue;let n=o.value;this.bindings.delete(n),this.filtered.delete(n)}this.emitChange()}reset(){this.bindings.clear(),this.emitChange()}bindings=new Map;onSequenceUpdate;flushInterval;_sequence="";set currentSequence(t){let r=this._sequence!==t;this._sequence=t,r&&this.onSequenceUpdate?.(t)}get currentSequence(){return this._sequence}prevBestMatchCommand;filtered=new Set;timer;backToInitial=()=>{clearTimeout(this.timer),this.currentSequence="",this.prevBestMatchCommand=void 0,this.filtered=new Set(this.bindings.keys()),qo.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=Eu(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,qo.debug("sequence",this.currentSequence);let o;for(let s of this.filtered){if(s.startsWith(this.currentSequence)||this.filtered.delete(s),this.currentSequence!==s)continue;let i=this.bindings.get(s);if(!i){this.filtered.delete(s);continue}o=()=>{qo.debug(run ${s});try{i(t)}catch(a){qo.error(a)}finally{this.backToInitial()}}}let n=this.filtered.size;if(qo.debug(${n} candidates: ${[...this.filtered.keys()].join(", ")}),n>0&&(this.prevBestMatchCommand=o),this.prevBestMatchCommand&&n<2){if(this.prevBestMatchCommand(),n===0){this.handleKeydown(t);return}return}if(n===0){this.backToInitial();return}t.preventDefault(),t.stopPropagation(),this.timer=setTimeout(this.prevBestMatchCommand??this.backToInitial,this.flushInterval)};emitChange=()=>{if(this.bindings.size===0){this.backToInitial(),this.target.removeEventListener("keydown",this.handleKeydown);return}this.target.addEventListener("keydown",this.handleKeydown)}},iP={name:"InvalidSequenceError",message:"cannot parse the sequence"},py=e=>{let t=cy(e);if(!t)return{ok:!1,value:iP};let r="",o=[];for(let n of t){let s=ay(n);if(!s.ok){o.push(s.value);continue}r+=s.value}return o.length>0?{ok:!1,value:o}:{ok:!0,value:r}};var uy=()=>{if(scrapbox.Layout!=="page")return{selectionRange:{start:{line:0,char:0},end:{line:0,char:0}},selectedText:""};let{selectionRange:e,selectedText:t,position:r}=ht();if(!t){let u=mu(r.line)??0,p={start:{line:r.line,char:0},end:{line:r.line+u,char:kt(r.line+u)?.length??0}};return{selectionRange:p,selectedText:scrapbox.Page.lines.slice(p.start.line,p.end.line+1).map(f=>f.text).join(`
)}}let{start:o,end:n}=e,s=o.line>n.line,i=s?n.line:o.line,a=s?n.char:o.char,c=s?o.line:n.line,l=s?o.char:n.char;return{selectedText:t,selectionRange:{start:{line:i,char:a},end:{line:c,char:l}}}};var wu=(e,{title:t,projectTo:r,mode:o})=>{let[n,...s]=e.split(
),i=n.replaceAll("[","").replaceAll("]","").trim(),a=Math.min(...[n,...s].map(l=>Zt(l))),c=[from ${t},n.slice(a),...s.map(l=>l.slice(a))];return{text:${i},pages:[{project:r,title:i,lines:c,mode:o}]}};wu.hookName="default-hook";var Xr=e=>{let{project:t=scrapbox.Project.name,mode:r="newtab"}=e??{},o=[...e?.hooks??[],wu],{selectionRange:{start:n,end:s},selectedText:i}=uy();if(!i||scrapbox.Layout!=="page")return;let a=(()=>{for(let p of o){let f=p(i,{title:scrapbox.Page.title,projectFrom:scrapbox.Project.name,projectTo:t,lines:At().slice(n.line,s.line+1),mode:r});if(f)return[p.hookName,f]}})();if(!a)return;let[c,l]=a,u=async()=>{let p=l instanceof Promise?await l:l;if(p.pages.length===0&&p.text===i)return;let f,{render:m,dispose:h}=De();try{if(p.pages.length>0){let y=p.pages.length;m({type:"spinner"},{type:"text",text:Create new ${y} pages...});let x=await Mt(e?.socket);if(O(x))throw Z(x);f=S(x);let w=0;await Promise.all(p.pages.map(async k=>{let b=Array.isArray(k.lines)?T=>[...T.map(v=>v.text),...k.lines]:k.lines;await Le(k.project,k.title,b,{socket:f}),m({type:"spinner"},{type:"text",text:Create ${y-++w} pages...})}))}m({type:"spinner"},{type:"text",text:${p.pages.length>0?"Created. ":""}Removing cut text...});let g=p.text;if(i===g)return;await Le(scrapbox.Project.name,scrapbox.Page.title,y=>{let x=y.map(w=>w.text);return[...x.slice(0,n.line),...${xn.line.slice(0,n.char)}${g}${x.slice(s.line).join(`
).slice(s.char)}.split(`
)]}),m({type:"check-circle"},{type:"text",text:"Removed."});for(let y of p.pages)switch(y.mode){case"self":y.project===scrapbox.Project.name?gu(y.project,y.title):globalThis.open(https://scrapbox.io/${y.project}/${ne(y.title)},"_self");break;case"newtab":globalThis.open(https://scrapbox.io/${y.project}/${ne(y.title)});break}}catch(g){m({type:"exclamation-triangle"},{type:"text",text:"Failed to create new pages (see console)."}),console.error(g)}finally{let g=Fe(1e3);f&&await Ct(f),await g,h()}};return u.hookName=c,u};var aP=Math.pow(10,8)*24*60*60*1e3,r5=-aP,Go=6048e5,Ru=864e5,Sr=6e4,wo=36e5,ja=1e3;var Ba=3600;var ku=Ba*24,cP=ku*7,my=ku*365.2425,fy=my/12,lP=fy*3,vu=Symbol.for("constructDateFrom");function C(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&vu in e?e[vu](t):e instanceof Date?new e.constructor(t):new Date(t)}function E(e,t){return C(t||e,e)}var pP={};function br(){return pP}function Ne(e,t){let r=br(),o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,n=E(e,t?.in),s=n.getDay(),i=(s<o?7:0)+s-o;return n.setDate(n.getDate()-i),n.setHours(0,0,0,0),n}function Er(e,t){let r=E(e,t?.in);return r.setHours(0,0,0,0),r}function ct(e,...t){let r=C.bind(null,e||t.find(o=>typeof o=="object"));return t.map(r)}function Ro(e,t){let[r,o]=ct(e,t.start,t.end);return{start:r,end:o}}function Gs(e,t){let{start:r,end:o}=Ro(t?.in,e),n=+r>+o,s=n?+r:+o,i=n?o:r;i.setHours(0,0,0,0);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,n=!n);let c=[];for(;+i<=s;)c.push(C(r,i)),i.setDate(i.getDate()+a),i.setHours(0,0,0,0);return n?c.reverse():c}function gt(e,t,r){let[o,n]=ct(r?.in,e,t);return+Er(o)==+Er(n)}function wr(e,t){let r=e<0?"-":"",o=Math.abs(e).toString().padStart(t,"0");return r+o}var Tu={y(e,t){let r=e.getFullYear(),o=r>0?r:1-r;return wr(t==="yy"?o%100:o,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):wr(r+1,2)},d(e,t){return wr(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 r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return wr(e.getHours()%12||12,t.length)},H(e,t){return wr(e.getHours(),t.length)},m(e,t){return wr(e.getMinutes(),t.length)},s(e,t){return wr(e.getSeconds(),t.length)},S(e,t){let r=t.length,o=e.getMilliseconds(),n=Math.trunc(o*Math.pow(10,r-3));return wr(n,t.length)}};function dy(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Gt(e){return!(!dy(e)&&typeof e!="number"||isNaN(+E(e)))}var uP=/(\w)\1*|''|'(''|[^'])+('|$)|./g,mP=/^'([^]*?)'?$/,fP=/''/g,dP=/[a-zA-Z]/;function pe(e,t){let r=E(e);if(!Gt(r))throw new RangeError("Invalid time value");let o=t.match(uP);return o?o.map(n=>{if(n==="''")return"'";let s=n[0];if(s==="'")return hP(n);let i=Tu[s];if(i)return i(r,n);if(s.match(dP))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return n}).join(""):""}function hP(e){let t=e.match(mP);return t?t[1].replace(fP,"'"):e}function ve(e,t,r){let o=E(e,r?.in);return isNaN(t)?C(r?.in||e,NaN):(t&&o.setDate(o.getDate()+t),o)}function zt(e,t,r){return ve(e,-t,r)}function zs(e,t,r){return C(r?.in||e,+E(e)+t)}function Vs(e,t,r){return zs(e,t*1e3,r)}function zo(e,t,r){return ve(e,t*7,r)}function Ks(e,t){return E(e,t?.in).getDate()}function Vo(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=br(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=C(t?.in||e,0);i.setFullYear(o+1,0,s),i.setHours(0,0,0,0);let a=Ne(i,t),c=C(t?.in||e,0);c.setFullYear(o,0,s),c.setHours(0,0,0,0);let l=Ne(c,t);return+r>=+a?o+1:+r>=+l?o:o-1}var gP={};function yP(){return gP}function _u(e,t){let r=yP(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,n=Vo(e,t),s=C(t?.in||e,0);return s.setFullYear(n,0,o),s.setHours(0,0,0,0),Ne(s,t)}function ko(e,t){let r=E(e,t?.in),o=+Ne(r,t)-+_u(r,t);return Math.round(o/Go)+1}function gy(e,t){return E(e,t?.in).getMonth()}function Ko(e,t){return E(e,t?.in).getFullYear()}var yy=e=>{let t=new Map;for(let r of e){let o=${Ko(r)}-${gy(r)}-${Ks(r)},n=t.get(o);n&&n.getTime()>r.getTime()||t.set(o,r)}return[...t.values()]};function Ys(e,t,r){let o=E(e,r?.in);if(isNaN(t))return C(r?.in||e,NaN);if(!t)return o;let n=o.getDate(),s=C(r?.in||e,o.getTime());s.setMonth(o.getMonth()+t+1,0);let i=s.getDate();return n>=i?s:(o.setFullYear(s.getFullYear(),s.getMonth(),n),o)}function Pu(e,t,r){let{years:o=0,months:n=0,weeks:s=0,days:i=0,hours:a=0,minutes:c=0,seconds:l=0}=t,u=E(e,r?.in),p=n||o?Ys(u,n+o*12):u,f=i||s?ve(p,i+s*7):p,m=c+a*60,h=(l+m*60)*1e3;return C(r?.in||e,+f+h)}function xy(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=r.getMonth(),s=C(r,0);return s.setFullYear(o,n+1,0),s.setHours(0,0,0,0),s.getDate()}function Ou(e,t,r){let o=E(e,r?.in),n=o.getFullYear(),s=o.getDate(),i=C(r?.in||e,0);i.setFullYear(n,t,15),i.setHours(0,0,0,0);let a=xy(i);return o.setMonth(t,Math.min(s,a)),o}function by(e,t,r){let o=E(e,r?.in);return isNaN(+o)?C(r?.in||e,NaN):(t.year!=null&&o.setFullYear(t.year),t.month!=null&&(o=Ou(o,t.month)),t.date!=null&&o.setDate(t.date),t.hours!=null&&o.setHours(t.hours),t.minutes!=null&&o.setMinutes(t.minutes),t.seconds!=null&&o.setSeconds(t.seconds),t.milliseconds!=null&&o.setMilliseconds(t.milliseconds),o)}function Ey(e,t){return E(e,t?.in).getMinutes()}function Lr(e,t,r){let o=E(e,r?.in);return o.setTime(o.getTime()+t*Sr),o}function Yo(e){return t=>{let r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Ha(e,t){return+E(e)-+E(t)}function vo(e,t,r){let o=Ha(e,t)/Sr;return Yo(r?.roundingMethod)(o)}function wy(e,t){return E(e,t?.in).getHours()}function Su(e,t,r){return zs(e,t*wo,r)}function Wa(e,t){let r=E(e,t?.in);return r.setHours(23,59,59,999),r}function Jr(e){let t=E(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function Qr(e,t,r){let[o,n]=ct(r?.in,e,t),s=Er(o),i=Er(n),a=+s-Jr(s),c=+i-Jr(i);return Math.round((a-c)/Ru)}function Ry(e,t,r){return zo(e,-t,r)}function qa(e,t,r){let o=E(e,r?.in),n=ko(o,r)-t;return o.setDate(o.getDate()-n*7),E(o,r?.in)}function ky(e,t){let{start:r,end:o}=Ro(t?.in,e),n=+r>+o,s=n?Ne(o,t):Ne(r,t),i=n?Ne(r,t):Ne(o,t);s.setHours(15),i.setHours(15);let a=+i.getTime(),c=s,l=t?.step??1;if(!l)return[];l<0&&(l=-l,n=!n);let u=[];for(;+c<=a;)c.setHours(0),u.push(C(r,c)),c=zo(c,l),c.setHours(15);return n?u.reverse():u}function Ga(e,t,r){let[o,n]=ct(r?.in,e,t),s=o.getFullYear()-n.getFullYear(),i=o.getMonth()-n.getMonth();return s*12+i}function Xo(e,t){let r=+E(e)-+E(t);return r<0?-1:r>0?1:r}function Jo(e,t){return+E(e)>+E(t)}var vy=e=>e==null,To=e=>typeof e=="string";async function*Ty(e){let t=[],r,o=i=>{if(!r){t.push(i);return}r(i),r=void 0},n=()=>t.length>0?Promise.resolve(t.pop()):new Promise(i=>r=i),s=0;for(let i of e)i.then(a=>o({state:"fulfilled",value:a})).catch(a=>o({state:"rejected",reason:a})),s++;for(let i=0;i<s;i++)yield await n()}var Tt=e=>{let t=e.match(/^(\d{4})-(\d{2})-(\d{2}) (?: {5}|(\d{2}):(\d{2})) (?: {4}|(\d{4})) (?: {8}|(\d{2}):(\d{2}):(\d{2})) (?: {8}|(\d{2}):(\d{2}):(\d{2}))([^\n]*)$/);if(!t)return;let[,r,o,n,s,i,a,c,l,u,p,f,m,h]=t,g={title:h,base:new Date(parseInt(r),parseInt(o)-1,parseInt(n)),plan:{},record:{}};if(s){let y=new Date(g.base);y.setHours(parseInt(s)),y.setMinutes(parseInt(i)),g.plan.start=y}if(a&&(g.plan.duration=parseInt(a)*60),c){let y=new Date(g.base);y.setHours(parseInt(c)),y.setMinutes(parseInt(l)),y.setSeconds(parseInt(u)),g.record.start=y}if(p){let y=new Date(g.base);y.setHours(parseInt(p)),y.setMinutes(parseInt(f)),y.setSeconds(parseInt(m)),g.record.start&&Jo(g.record.start,y)&&y.setDate(y.getDate()+1),g.record.end=y}return g};var jn=e=>e.record?.start??e.plan?.start??e.base,_y=e=>e.record?.end??(vy(e.plan?.duration)?e.base:Vs(jn(e),e.plan.duration));var Pe=({title:e,base:t,plan:r,record:o})=>["",pe(t,"yyyy-MM-dd")," ",r?.start?pe(r.start,"HH:mm"):" ".repeat(5)," ",r?.duration?${r.duration/60}.padStart(4,"0"):" ".repeat(4)," ",o?.start?pe(o?.start,"HH:mm:ss"):" ".repeat(8)," ",o?.end?pe(o?.end,"HH:mm:ss"):" ".repeat(8),"",e].join("");function*Py(e){for(let t of Qo(e))To(t)||(yield t)}function*Qo(e){for(let t=0;t<e.length;t++){let r=e[t],o=To(r)?r:r.text,n=Wo(t,e),s=Tt(o);if(!s){yield o;continue}yield{...s,lines:e.slice(t+1,t+1+n).map(i=>To(i)?i:i.text)},t+=n}}var xP=5*60,Lu=async()=>{let e=ht().position.line,t=Tt(kt(e)??""),r=t?.base??new Date,o={start:t?.plan?.start?Vs(t.plan.start,xP+(t.plan.duration??0)):void 0,duration:t?.plan?.duration};scrapbox.Page.insertLine(Pe({title:"",base:r,plan:o,record:{}}),e+1),await scrapbox.Page.waitForSave()};var za=async()=>{let e=ht().position.line,t=Tt(kt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;o||(scrapbox.Page.updateLine(Pe({record:{start:r?void 0:new Date},...n}),e),await scrapbox.Page.waitForSave())};var Bn=async()=>{let e=ht().position.line,t=Tt(kt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;r&&(scrapbox.Page.updateLine(Pe({record:{start:r,end:o?void 0:new Date},...n}),e),await scrapbox.Page.waitForSave())};var Nu=async()=>{let e=ht().position.line,t=Tt(kt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;if(r){if(o)return;await Bn();return}if(o)return;let s;for(let{text:a}of xo().slice(0,(e??0)+1).reverse()){let{record:c}=Tt(a)??{};if(c?.end){s=c.end;break}}let i=new Date;scrapbox.Page.updateLine(Pe({record:{start:s??i,end:i},...n}),e),await scrapbox.Page.waitForSave()};var Zo=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:o}=ht();return r===""?[o.line,o.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var Mu=(e,t=7)=>new Date((e+2592e3*((t+1)**1.5-1)/5221.154823442138)*1e3);var Cu=(e,t)=>{let r,o,n,s,i=null;if(i=e.match(/^(.*?)(s|e):([^\s]+)\s+d:(\d+)/))[,o,s,n,r]=i;else if(i=e.match(/^(.*?)d:(\d+)\s+(s|e):([^\s]+)/))[,o,r,s,n]=i;else if(i=e.match(/^(.*?)(s|e):([^\s]+)/))[,o,s,n]=i;else return(i=e.match(/^(.*?)d:(\d+)/))?([,o,r]=i,{name:o.trimEnd(),duration:parseInt(r)*60}):void 0;for(let{test:a,parse:c}of bP){let l=n.match(a);if(!l)continue;let u=c(l),p=u.isDuration?Pu(t,u):by(t,u);return s==="s"?{name:o.trimEnd(),start:p,...r!==void 0?{duration:parseInt(r)*60}:{}}:{name:o.trimEnd(),start:Mu(t.getTime()/1e3,(p.getTime()-t.getTime())/(24*60*60*1e3)),...r!==void 0?{duration:parseInt(r)*60}:{}}}},bP=[{test:/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3]),hours:parseInt(e[4]),minutes:parseInt(e[5])})},{test:/(\d{4})-(\d{2})-(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3]),hours:parseInt(e[4])})},{test:/(\d{4})-(\d{2})-(\d{2})T?$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3])})},{test:/(\d{2})-(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2]),hours:parseInt(e[3]),minutes:parseInt(e[4])})},{test:/(\d{2})-(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2]),hours:parseInt(e[3])})},{test:/(\d{2})-(\d{2})T?$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2])})},{test:/(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,date:parseInt(e[1]),hours:parseInt(e[2]),minutes:parseInt(e[3])})},{test:/(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,date:parseInt(e[1]),hours:parseInt(e[2])})},{test:/T?(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,hours:parseInt(e[1]),minutes:parseInt(e[2])})},{test:/T?(\d{2})$/i,parse:e=>({isDuration:!1,hours:parseInt(e[1])})},{test:/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3]),hours:parseInt(e[4]),minutes:parseInt(e[5])})},{test:/P(\d+)Y(\d+)M(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3]),hours:parseInt(e[4])})},{test:/P(\d+)Y(\d+)M(\d+)D$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3])})},{test:/P(\d+)M(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2]),hours:parseInt(e[3]),minutes:parseInt(e[4])})},{test:/P(\d+)M(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2]),hours:parseInt(e[3])})},{test:/P(\d+)M(\d+)D$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2])})},{test:/P(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,days:parseInt(e[1]),hours:parseInt(e[2]),minutes:parseInt(e[3])})},{test:/P(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,days:parseInt(e[1]),hours:parseInt(e[2])})},{test:/P(\d+)D$/i,parse:e=>({isDuration:!0,days:parseInt(e[1])})},{test:/PT?(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,hours:parseInt(e[1]),minutes:parseInt(e[2])})},{test:/PT?(\d+)H$/i,parse:e=>({isDuration:!0,hours:parseInt(e[1])})},{test:/PT?(\d+)M$/i,parse:e=>({isDuration:!0,minutes:parseInt(e[1])})},{test:/P(\d+)W$/i,parse:e=>({isDuration:!0,weeks:parseInt(e[1])})}];var Xs=async()=>{let e=new Date,[t,r]=Zo(),o=xo().slice(t,r+1).map(s=>s.text),n=o.flatMap(s=>{let i=s.trimEnd();if(i==="")return s;let{name:a,start:c,duration:l}=Cu(i,e)??{};return!a||!c&&!l?s:[Pe({title:a.trim(),base:c??e,plan:{start:c,duration:l},record:{}})]});if(o.join(
)!==n.join(
)){for(let s=t;s<=r;s++)scrapbox.Page.updateLine(n[s-t],s);await scrapbox.Page.waitForSave()}};var Va=async(e,t,r)=>{let o=[];for(let n=e;n<=t;n++){let s=kt(n)??"",i=Tt(s);if(!i){o.push(s);continue}o.push(Pe(r(i,n)))}for(let n=e;n<=t;n++)scrapbox.Page.updateLine(o[n-e],n);await scrapbox.Page.waitForSave()};var Iu=async(e=1)=>{let[t,r]=Zo();await Va(t,r,o=>(o.base=ve(o.base,e),o))};var Au=async()=>{let[e,t]=Zo(),r=new Date;await Va(e,t,o=>(gt(o.base,r)||(o.base=r),o))};var EP="日刊記録sheet",wP=/日刊記録sheet (\d{4})-(\d{2})-(\d{2})/,Js=["[** 00:00 - 03:00] 未明","[** 03:00 - 06:00] 明け方","[** 06:00 - 09:00] 朝","[** 09:00 - 12:00] 昼前","[** 12:00 - 15:00] 昼過ぎ","[** 15:00 - 18:00] 夕方","[** 18:00 - 21:00] 夜のはじめ頃","[** 21:00 - 00:00] 夜遅く"];var Fu=e=>{let t=e.match(wP);if(!t)return;let[,r,o,n]=t,s=new Date(parseInt(r),parseInt(o)-1,parseInt(n));return Gt(s)?s:void 0},Rr=e=>pe(e,'${EP}' yyyy-MM-dd),en=e=>{let t=Fu(e[0]);if(!t)return e;let r=RP(t),o=[],n=[];for(let a of Qo(e.slice(1))){if(typeof a=="string"){if(Js.includes(a)||r!==""&&r===a)continue;n.push(a);continue}o.push(a)}let s=o.sort((a,c)=>Xo(jn(a),jn(c)));if(s.length===0)return[e[0],r,...Js,...n];let i=[0,0,0,0,0,0,0,0];for(let a=1;a<Js.length;a++){let c=Su(new Date(t.getFullYear(),t.getMonth(),t.getDate()),3*a),l=s.findIndex(m=>Jo(jn(m),c));if(l<0){i[a]=-1;continue}if(l===0)continue;let u=s[l-1],p=jn(u),f=_y(u);i[a]=(f.getTime()-p.getTime())/2<c.getTime()-p.getTime()?l:l-1}return[e[0],r,...s.flatMap((a,c)=>[...i.flatMap((l,u)=>l===c?[Js[u]]:[]),Pe(a),...a.lines]),...i.flatMap((a,c)=>a===-1?[Js[c]]:[]),...n]},RP=e=>yesterday: ${Rr(zt(e,1))};var Du=async(e,t)=>{let r=()=>{},o=setTimeout(()=>{let{render:n,dispose:s}=De();r=s,n({type:"spinner"},{type:"text",text:"formatting..."})},500);await Le(e,t,n=>en(n.map(s=>s.text))),clearTimeout(o),r()};async function*Uu(e,t,r){let o=[...t],n=[];for(;o.length>0;){let s=o.shift();if(!s)break;let i=s.base,a=[s];for(let c=0;c<o.length;c++)gt(o[c].base,i)&&(a.push(...o.splice(c,1)),c--);n.push((async()=>(await Le(e,Rr(i),c=>en([...c.map(l=>l.text),...a.flatMap(l=>[Pe(l),...l.lines??[]])]),r),{date:i,size:a.length}))())}yield*Ty(n)}var Qs=async({from:{project:e,title:t},to:r})=>{let o=await ar(e,t);if(O(o))throw Z(o);let n=Fu(t),{lines:s}=S(o),i=[];for(let p of Py(s))n&&gt(p.base,n)||i.push(p);let{render:a,dispose:c}=De();a({type:"spinner"},{type:"text",text:copying ${i.length} tasks...});let l=await Mt();if(O(l))throw Z(l);let u=S(l);try{let p=0,f=!1;for await(let m of Uu(r,i,{socket:u})){if(m.state!=="fulfilled"){console.error(m.reason),f=!0;continue}p+=m.value.size,a({type:"spinner"},{type:"text",text:copying ${i.length-p} tasks...})}if(f){a({type:"exclamation-triangle"},{type:"text",text:"Some tasks failed to be written"});return}a({type:"spinner"},{type:"text",text:Copied. removing ${i.length} original tasks...}),await Le(e,t,m=>{let h=[];for(let g of Qo(m)){if(To(g)){h.push(g);continue}n&&gt(g.base,n)&&h.push(Pe(g),...g.lines)}return h},{socket:u}),a({type:"check-circle"},{type:"text",text:"Moved"})}finally{await Ct(u),await Fe(1e3),c()}};var kr=e=>${e}.padStart(2,"0");var tn=e=>"hours"in e,lr=(e,t)=>e.year!==t.year?e.year<t.year:e.month!==t.month?e.month<t.month:e.date!==t.date?e.date<t.date:"hours"in t?"hours"in e?e.hours*60+e.minutes<t.hours*60+t.minutes:0<t.hours*60+t.minutes:!1,Nr=e=>${${e.year}.padStart(4,"0")}-${kr(e.month)}-${kr(e.date)}${"hours"in e?T${kr(e.hours)}:${kr(e.minutes)}:""},ge=e=>{let t=Nr(e);return new Date(t.includes("T")?t:${t}T00:00)},Ht=e=>({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),hours:e.getHours(),minutes:e.getMinutes()});var Sy=e=>{switch(e.toLowerCase()){case"y":return"yearly";case"m":return"monthly";case"w":return"weekly";case"d":return"daily";default:return}};var Ly=e=>{switch(e){case"+":return"todo";case"-":return"note";case"!":return"deadline";case".":return"done";case"~":return"up-down";default:return}},Ny=e=>{switch(e){case"todo":return"+";case"note":return"-";case"deadline":return"!";case"done":return".";case"up-down":return"~"}};var Mr=e=>{let t=e.match(/(?:([\+\-!~.])(\d+)?)?@(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?(?:\/(\d{2}):(\d{2})|\/(?:(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)|D(\d+))?(?:R([YMWD])?(\d+))?(?:@(?:(\d{2}):(\d{2})|(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)?(?:\/(\d{2}):(\d{2})|\/(?:(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)|D(\d+))?)?/i);if(!t)return;let[r,o,n,s,i,a,c,l,u,p,f,m,h,g,y,x,w,k,b,T,v,A,F,D,N,_,P,I,$,j,q,B,Y]=t,G=${e.slice(0,t.index).trim()}${e.slice((t.index??0)+r.length).trim()},X=My(s,i,a,c,l);if(!Gt(ge(X)))return M({name:"InvalidDateError",message:The reference point of the task "${Nr(X)}" is an invalid date.});let J=Cy(X,f,m,h,u||g,p||y,x);if(J!==void 0){if(Je(J)&&isNaN(J)||!Je(J)&&!Gt(ge(J)))return M({name:"InvalidDateError",message:The estimated end of the task${Je(J)?"": "${Nr(J)}"} is an invalid date.});if(Je(J)&&J<0||!Je(J)&&lr(J,X))return M({name:"TaskRangeError",message:The reference point of an task cannot be after its estimated end.
reference point:${Nr(X)}
estimated end:${Nr(Je(J)?Ht(Lr(ge(X),J)):J)}})}let ue=/^[\uFE00-\uFE0F]*[✅❌]/.test(e)?"done":Ly(o),oe=ue?{status:ue,refDate:X}:void 0;oe&&n&&(oe.speed=parseInt(n));let wt=My(v||s,A||i,F||a,b||D||c,T||N||l);if(!Gt(ge(wt)))return M({name:"InvalidDateError",message:The start of the task/event "${Nr(wt)}" is an invalid date.});let Se=Cy(wt,I||f,$||m,j||h,_||q||u||g,P||B||p||y,Y||x),W=tn(wt)&&Je(Se)?{start:wt,duration:Se}:void 0;if(W){let Nt={name:G,executed:W,generated:!1,raw:e};return oe&&(Nt.freshness=oe),(w||k)&&(Nt.recurrence={frequency:Sy(w??"D")??"daily",count:k?parseInt(k):1}),L(Nt)}if(!oe)return M({name:"InvalidDateError",message:"Task requires freshness to be spec"});let Ee={name:G,freshness:oe,generated:!1,raw:e};return J&&(Ee.estimated=J),L(W?{...Ee,executed:W}:Ee)},Cr=e=>!("executed"in e),_o=e=>"recurrence"in e,Iy=e=>!("executed"in e||"freshness"in e&&tn(e.freshness.refDate)&&e.estimated&&(Je(e.estimated)||tn(e.estimated))),ei=e=>"executed"in e?e.executed.duration:Je(e.estimated)?e.estimated:void 0,Ir=e=>Cr(e)?e.freshness.refDate:e.executed.start,Ay=e=>{if(!Cr(e)){let r=ge(e.executed.start);return Ht(Lr(r,e.executed.duration))}if(Je(e.estimated)&&tn(e.freshness.refDate)){let r=ge(e.freshness.refDate);return Ht(Lr(r,e.estimated))}let t=ge(Je(e.estimated)?e.freshness.refDate:e.estimated??e.freshness.refDate);return t.setHours(0),t.setMinutes(0),Ht(ve(t,1))},OP=e=>{let t=e.freshness?${Ny(e.freshness.status)}${e.freshness.speed??""}:"",r=${Nr(Ir(e))},o=ei(e);return${t}@${r}${o===void 0?"":D${o}}${e.name}},Ka=(e,t)=>{let r=Ht(t),{recurrence:o,executed:n}=e;switch(o.frequency){case"yearly":{if(Math.abs(r.year-n.start.year)%(o.count??1)!==0||n.start.month!==r.month||n.start.date!==r.date)return;break}case"monthly":{if(Ga(ge(r),ge(n.start))%(o.count??1)!==0)return;break}case"weekly":case"daily":{let a=o.frequency==="weekly"?7:1;if(Qr(ge(r),ge(n.start))%((o.count??1)*a)!==0)return;break}}let s={...n.start};s.year=r.year,s.month=r.month,s.date=r.date;let i={name:e.name,executed:{start:s,duration:n.duration},generated:!0,raw:e.raw};return e.freshness&&(i.freshness=e.freshness),i},Ya=e=>e.freshness?e.generated?OP(e):e.raw:e.generated?void 0:e.raw,My=(e,t,r,o,n)=>{let s=parseInt(e),i=parseInt(t),a=parseInt(r),c=o?parseInt(o):void 0,l=n?parseInt(n):void 0;return c!==void 0&&l!==void 0?{year:s,month:i,date:a,hours:c,minutes:l}:{year:s,month:i,date:a}},Cy=(e,t,r,o,n,s,i)=>{if(!t&&!r&&!o&&!n&&!s&&!i)return;if(i)return parseInt(i);let a=t?parseInt(t):e.year,c=r?parseInt(r):e.month,l=o?parseInt(o):e.date,u=n?parseInt(n):void 0,p=s?parseInt(s):void 0,f=u!==void 0&&p!==void 0?{year:a,month:c,date:l,hours:u,minutes:p}:{year:a,month:c,date:l};return!tn(e)||!tn(f)?f:Math.round((ge(f).getTime()-ge(e).getTime())/(60*1e3))};var ti=(e,t)=>{if(!e.generated&&_o(e)){let s=Ka(e,t);return s?ti(s,t):void 0}let r=ge(Cr(e)?e.freshness.refDate:e.executed.start),o=ei(e),n=Ya(e);return{title:n!==void 0?${n}:e.name,base:r,plan:{start:Iy(e)?void 0:r,duration:o!==void 0?o*60:void 0},record:{}}};var $u={あさごはん:"#log-breakfast",ひるごはん:"#log-lunch",よるごはん:"#log-dinner"},rn=(e,{title:t,projectTo:r,mode:o})=>{let[n,...s]=e.split(
),i=Tt(n);if(!i)return;if(s.length===0)return{text:e,pages:[]};let{title:a,base:c,record:l,...u}=i,p=SP(a,c,l),f=Pe({title:${p},base:c,record:l,...u}),m=Math.min(...s.map(g=>Zt(g))),h=[.../[\[\]]/.test(a)&&a!==${p}?[a]:[],...t in $u?[...s.map(g=>g.slice(m)),"",$u[t],"#log-eatenfood"]:[...s.map(g=> ${g.slice(m)}),""]];return{text:f,pages:[{project:r,title:p,lines:Fy(t,h,[l.start??c]),mode:o}]}};rn.hookName="task-hook";var SP=(e,t,r)=>{let o=pe(r.start??t,"yyyy-MM-dd");if(e in $u)return${o} ${e};if(Mr(e.slice(1,-1)))return e.slice(1,-1);let n=e.replace(/[\[\]]/g,"").trim();return${n}${n.endsWith(o)?"": ${o}}},on=(e,{title:t,projectTo:r,mode:o,lines:n})=>{let[s,...i]=e.split(
);if(i.length===0)return;let a=s.replace(/[\[\]]/g,"").trim(),c=Math.min(...i.map(p=>Zt(p))),l=r.startsWith("takker")?yy([new Date,...n.map(({updated:p})=>new Date(p*1e3))]).sort((p,f)=>f.getTime()-p.getTime()):[],u=["",.../[\[\]]/.test(s)?[s.trimStart()]:[],...i.map(p=>p.slice(c))];return{text:${" ".repeat(Zt(s))}${a},pages:[{project:r,title:a,lines:Fy(t,u,l),mode:o}]}};on.hookName="new-page-hook";var nn=(e,{projectTo:t,mode:r})=>{if(e.includes(
)||!/\[[^\]]+\]/.test(e))return;let[o,n]=e.match(/^(\s*)(.*)$/)?.slice?.(1)??["",e],s=[...n.matchAll(/\[([^\]])\]/g)].map(a=>ae(a[1])),i=n.replaceAll("[","").replaceAll("]","");return{text:${o}${i},pages:[{project:t,title:i,lines:(a,{links:c})=>{let l=c.map(u=>ae(u));if(!s.every(u=>l.includes(u)))return[...a.map(u=>u.text),n]},mode:r}]}};nn.hookName="splitted-link-hook";var Fy=(e,t,r)=>(o,{links:n})=>{let s=n.map(p=>ae(p)),i=s.includes(ae(e))?[]:[from ${e}],a=r.flatMap(p=>{let f=pe(p,"yyyy-MM-dd");if(s.includes(f))return[];let m=pe(p,"HH:mm:ss");return[#${f} ${m}]}),c=o.map(p=>p.text),l=c.findIndex(p=>/^#\d{4}-\d{2}-\d{2}/.test(p)),u=l<0?c.length:l;return[...c.slice(0,u),...i,...t,"",...a,...c.slice(u)]};var Dy=e=>e.preventDefault(),Uy=e=>e.stopPropagation(),$y={"<A-a><A-t>":async e=>{Dy(e),Uy(e);let[t,r]=LP(),o=xo().slice(t,r+1).map(n=>{let s=n.text,i=n.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=Mr(i);if(!a||O(a))return s;let c=S(a);if(c.freshness?.status==="done")return s;let l=ti(c,new Date);return l?(l.title=${i},Pe(l)):s}).join(
);await qg(t,r,o),await Xs()},"<A-a><A-m>":e=>{scrapbox.Layout==="page"&&(Dy(e),Uy(e),Qs({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"}))}},LP=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:o}=ht();return r===""?[o.line,o.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var sn=e=>e.preventDefault(),an=e=>e.stopPropagation(),ju={"<A-a><A-a>":e=>{sn(e),an(e),Lu()},"<A-a><A-s>":e=>{sn(e),an(e),za()},"<A-a><A-e>":e=>{sn(e),an(e),Bn()},"<A-a><A-0>":e=>{sn(e),an(e),Nu()},"<A-a><A-1>":e=>{sn(e),an(e),Iu(1)},"<A-a><A-t>":e=>{sn(e),an(e),Au()},"<A-a><A-f>":e=>{scrapbox.Layout==="page"&&(sn(e),an(e),Du(scrapbox.Project.name,scrapbox.Page.title))}};var yt=e=>e.preventDefault(),xt=e=>e.stopPropagation(),cn=(e,t)=>{let r=Sg()?.getElementsByClassName?.("button");if(!r)return;let o=[...r].find(n=>t instanceof RegExp?t.test(n.textContent??""):n.textContent===t);o instanceof HTMLDivElement&&e.target===document.activeElement&&(yt(e),xt(e),o.click())},NP={"-":e=>cn(e,""),"]":e=>cn(e,""),c:e=>cn(e,"Copy plain"),$:e=>cn(e,""),"{":e=>cn(e,/{{c\d+}}/),"}":e=>cn(e,"reset cloze"),n:e=>cn(e,"make note")},MP={"<C-]>":e=>{let{position:{line:t,char:r}}=ht(),o=Ws(t,r)?.closest("a.page-link")??Yr(t)?.querySelector?.("a.page-link");o instanceof HTMLAnchorElement&&(yt(e),xt(e),o.click())},"<C-o>":e=>{yt(e),xt(e),history.back()}},CP={"<C-home>":e=>{yt(e),xt(e),Ug()},"<C-end>":e=>{yt(e),xt(e),$g()}},jy=[rn,on,nn],IP={"<C-X>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(yt(e),xt(e),Xr({project:t,mode:"self",hooks:jy})?.())},"<C-D>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(yt(e),xt(e),Xr({project:t,mode:"noopen",hooks:jy})?.())},"<C-h>":e=>{yt(e),xt(e),Pa()},"<C-j>":e=>{yt(e),xt(e),Sa()},"<C-k>":e=>{yt(e),xt(e),Oa()},"<C-l>":e=>{yt(e),xt(e),_a()},"<A-h>":e=>{yt(e),xt(e),Na()},"<A-j>":e=>{yt(e),xt(e),Ca()},"<A-k>":e=>{yt(e),xt(e),Ma()},"<A-l>":e=>{yt(e),xt(e),La()}};scrapbox.TimeStamp.removeAllFormats();var AP={"<A-t><A-t>":e=>{yt(e),xt(e),at(pe(new Date,"#yyyy-MM-dd HH:mm:ss "))},"<A-t><A-j>":e=>{yt(e),xt(e),at(pe(new Date,"yyyy-MM-dd HH:mm:ss "))},"<A-t><A-k>":e=>{yt(e),xt(e),at(pe(new Date,"HH:mm:ss "))},"<A-t><A-l>":e=>{yt(e),xt(e),at(pe(new Date,"yyyy-MM-dd"))}},By={...NP,...MP,...CP,...IP,...AP,...$y};var{render:FP}=De(),Bu,DP=e=>{Bu!==void 0&&cancelAnimationFrame(Bu),Bu=requestAnimationFrame(()=>FP({type:"text",text:e}))},Hu=new $a({addEventListener:Vg,removeEventListener:bu},{onSequenceUpdate:DP}),Hy=Hu.bind({...By,...scrapbox.Project.name==="takker-memex"?ju:{}});Hy.size>0&&alert([...Hy.entries()].map(([e,t])=>${e}:
${t.map(r=>- ${r}).join(`
)}).join(`
));var UP=/https?:\/\/vimeo\.com\/([0-9]+)/i,Wy=e=>{let t=e.match(UP);if(t)return t[1]};var $P=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,qy=e=>{let t=e.match($P);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var jP=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Gy=e=>{let t=e.match(jP);if(!t)return;let[,r]=t;return r};var zy=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let i=fa(n);if(i)return{type:"youtube",href:n,...i,...s};let a=Wy(n);if(a)return{type:"vimeo",videoId:a,href:n,...s};let c=qy(n);if(c)return{type:"spotify",href:n,...c,...s};let l=Gy(n);if(l)return{type:"anchor-fm",videoId:l,href:n,...s};if(HP(n))return{type:"video",href:n,...s}}return BP(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},BP=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),HP=e=>/\.(?:mp4|webm)$/.test(e);var WP=Object.defineProperty,qP=(e,t)=>{for(var r in t)WP(e,r,{get:t[r],enumerable:!0})},GP={};qP(GP,{andThen:()=>Ls,andThenAsync:()=>Ns,flatten:()=>tp,fromPromiseSettledResult:()=>rp,inspectBoth:()=>sp,inspectErr:()=>np,inspectOk:()=>op,isErrAnd:()=>Zi,isErrAndWithEnsureType:()=>ip,isOkAnd:()=>ea,isOkAndWithEnsureType:()=>ap,map:()=>qr,mapAsync:()=>ie,mapErr:()=>cp,mapErrAsync:()=>Ae,mapOr:()=>lp,mapOrAsync:()=>pp,mapOrElse:()=>Ms,mapOrElseAsync:()=>up,orElse:()=>mp,orElseAsync:()=>ta,toNullableFromErr:()=>dp,toNullableFromOk:()=>fp,toUndefinableFromErr:()=>gp,toUndefinableFromOk:()=>hp,transposeToNullable:()=>yp,transposeToUndefinable:()=>xp,tryCatchInto:()=>ia,tryCatchIntoAsync:()=>aa,tryCatchIntoWithEnsureError:()=>bp,tryCatchIntoWithEnsureErrorAsync:()=>Ep,unwrapOr:()=>Do,unwrapOrElse:()=>wp,unwrapOrElseAsync:()=>Rp,unwrapOrThrow:()=>kp});var Vy=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,i])=>i-s).map(([s])=>s),o=await ma([]);if(O(o))return r;let n=S(o).projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var zP;(e=>{})(zP||={});var Xa="0.16.9",Wu,qu,Ky=e=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(qu)throw qu;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,Wu=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>{qu=s,n(s)},document.head.append(r)})}return Wu||new Promise(r=>{let o=setInterval(()=>{window.katex&&(clearInterval(o),r(window.katex))},500)})};var Ja=(e,t)=>{let[r,o]=Q("");return{ref:U(s=>{s&&Ky(Xa).then(i=>{try{i.render(e,s,t),o("")}catch(a){if(a instanceof Error&&a.name==="ParseError")o(a.message.slice(19));else throw a}})},[e,...Object.values(t??{})]),error:r}};var Yy=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let i=s[0]().finally(()=>o(i)).then(a=>s[1](a)).catch(a=>s[2](a));r.add(i)};return n=>{if(r.size<e){let s=n().finally(()=>o(s));return r.add(s),s}return new Promise((s,i)=>{t.push([n,s,i])})}};var VP="0.6.5",Qy=ScrapBubble-${VP},Xy=await globalThis.caches.open(Qy);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Qy&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var Jy=Yy(3);async function*Qa(e,t){let r=((t?.saveFailedResponse?Xy.match(e):void 0)??bo(e,t)).then(i=>["cache",i]);{let i=Fe(1e3).then(()=>"timeout"),a=await Promise.race([r,i]);if(a!=="timeout"){a[1]&&(yield["cache",a[1]]);let c=await Jy(()=>fetch(e));!c.ok&&t?.saveFailedResponse&&await Xy.put(e,c.clone()),yield["network",c]}}let o=Jy(()=>fetch(e)).then(i=>["network",i]),[n,s]=await Promise.race([r,o]);if(n==="network"){yield[n,s];return}s&&(yield[n,s]),yield await o}var Zy=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var Za=()=>{let e=new Map;return{dispatch:(t,r)=>{let o=e.get(t);if(o)for(let n of o)n(r)},on:(t,r)=>{let o=e.get(t)??new Set;o.add(r),e.set(t,o)},off:(t,r)=>{let o=e.get(t);o&&o.delete(r)}}};var er=!1,ex=e=>{er=typeof e=="boolean"?e:new Set(e)},Po=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{er!==!0&&(!er||!er.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{er!==!0&&(!er||!er.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{er!==!0&&(!er||!er.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(er!==!0&&(!er||!er.has(e))))return r(...o)}]}}));var Gu=Za(),ec=new Map,KP=Po("ScrapBubble:useProject.ts"),tx=e=>{let[t,r]=Q();return te(()=>{Gu.on(e,r);let o=ec.get(e);return o?r(o.loading?void 0:o.value):(ec.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=$o.toRequest(e);for await(let[,s]of Qa(n)){let i=await $o.fromResponse(s);ec.set(e,{loading:!1,value:i}),Gu.dispatch(e,i);break}}catch(n){KP.error(n),ec.delete(e)}})()),()=>Gu.off(e,r)},[e]),t};var YP=["default-light","default-dark","default-minimal"],XP=["paper-light","paper-dark-dark","paper-dark"],rx=["blue","purple","green","orange","red"],JP=["hacker1","hacker2"],ox=["winter","spring","summer","automn"],nx=["tropical"],sx=["kyoto","newyork","paris"],ix=["mred","lgreen"],Oce=["default-light","default-minimal","paper-light",...rx,...ox,...nx,...sx,...ix];var QP=[...YP,...XP,...rx,...JP,...ox,...nx,...sx,...ix];function ax(e){return QP.includes(e)}var cx="default-light",ln=e=>{let t=tx(e);return H(()=>{if(!t||O(t))return cx;let r=S(t).theme;return ax(r)?r:cx},[t])};var Hn=(e,t)=>new Promise(r=>{let o=!1,n=()=>{o=!0,r(!1)};e.addEventListener("click",n),e.addEventListener("pointerleave",n),setTimeout(()=>{o||r(!0),e.removeEventListener("click",n),e.removeEventListener("pointerleave",n),r(!1)},t)});var Wn=e=>{let{top:t,right:r,left:o,bottom:n}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),i=(o-s.left)/s.width>.5;return{top:Math.round(n-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...i?{right:Math.round(s.right-r)}:{left:Math.round(o-s.left)},maxWidth:i?r-10:document.documentElement.clientWidth-o-10}};var lx=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:i,prefetch:a})=>{let c=H(()=>o?[]:it(r.join(
),{hasTitle:!1}),[o,r]),l=ln(e),u=U(async({currentTarget:f})=>{a(e,t),await Hn(f,i)&&s({project:e,title:t,linkTo:n,type:"link",position:Wn(f)})},[e,t,i,n?.project,n?.titleLc]),p=H(()=>n?()=>{$n({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return d("a",{className:"related-page-card page-link",type:"link","data-theme":l,href:/${e}/${ne(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:u,onClick:p,children:[d("div",{class:"hover"}),d("div",{class:"content",children:[d("div",{class:"header",children:d("div",{class:"title",children:t})}),o?d("div",{class:"thumbnail",children:d("img",{src:o})}):d("div",{class:"description",children:c.flatMap((f,m)=>f.type==="line"?[d("p",{children:f.nodes.map(h=>d(px,{node:h,project:e}))},m)]:[])})]})]})},px=({node:e,project:t})=>{switch(e.type){case"code":return d("code",{children:e.text});case"formula":return d(ZP,{node:e});case"commandLine":return d("code",{children:[e.symbol," $",e.text]});case"helpfeel":return d("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return d(ee,{children:e.nodes.map(r=>d(px,{node:r,project:t}))});case"icon":case"strongIcon":return d(eO,{node:e,project:t});case"hashTag":return d(tO,{node:e});case"link":return d(rO,{node:e});case"plain":case"blank":return d(ee,{children:e.text});default:return}},ZP=({node:{formula:e}})=>{let{ref:t,error:r}=Ja(e);return d("span",{className:formula ${r?" error":""},children:r?d("code",{children:e}):d("span",{className:"katex-display",ref:t})})},eO=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return d("img",{class:"icon",src:/api/pages/${o}/${ne(n)}/icon})},tO=({node:{href:e}})=>d("span",{class:"page-link",children:["#",e]}),rO=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?d("span",{class:"page-link",children:t}):d("span",{class:"link",children:r||t});var be=(e,t)=>/${e.toLowerCase()}/${ae(t)},tc=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var gx=Symbol.for("immer-nothing"),ux=Symbol.for("immer-draftable"),ye=Symbol.for("immer-state");function pr(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var qn=Object.getPrototypeOf;function Gn(e){return!!e&&!!e[ye]}function eo(e){return e?yx(e)||Array.isArray(e)||!!e[ux]||!!e.constructor?.[ux]||ii(e)||ac(e):!1}var oO=Object.prototype.constructor.toString();function yx(e){if(!e||typeof e!="object")return!1;let t=qn(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)===oO}function ri(e,t){ic(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,o)=>t(o,r,e))}function ic(e){let t=e[ye];return t?t.type_:Array.isArray(e)?1:ii(e)?2:ac(e)?3:0}function Ku(e,t){return ic(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function xx(e,t,r){let o=ic(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function nO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ii(e){return e instanceof Map}function ac(e){return e instanceof Set}function _t(e){return e.copy_||e.base_}function Yu(e,t){if(ii(e))return new Map(e);if(ac(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=yx(e);if(t===!0||t==="class_only"&&!r){let o=Object.getOwnPropertyDescriptors(e);delete o[ye];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){let i=n[s],a=o[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(o[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(qn(e),o)}else{let o=qn(e);if(o!==null&&r)return{...e};let n=Object.create(o);return Object.assign(n,e)}}function Zu(e,t=!1){return cc(e)||Gn(e)||!eo(e)||(ic(e)>1&&Object.defineProperties(e,{set:{value:rc},add:{value:rc},clear:{value:rc},delete:{value:rc}}),Object.freeze(e),t&&Object.values(e).forEach(r=>Zu(r,!0))),e}function rc(){pr(2)}function cc(e){return Object.isFrozen(e)}var Xu={};function pn(e){let t=Xu[e];return t||pr(0,e),t}function sO(e,t){Xu[e]||(Xu[e]=t)}var oi;function oc(){return oi}function iO(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function mx(e,t){t&&(pn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ju(e){Qu(e),e.drafts_.forEach(aO),e.drafts_=null}function Qu(e){e===oi&&(oi=e.parent_)}function fx(e){return oi=iO(oi,e)}function aO(e){let t=e[ye];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function dx(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[ye].modified_&&(Ju(t),pr(4)),eo(e)&&(e=nc(t,e),t.parent_||sc(t,e)),t.patches_&&pn("Patches").generateReplacementPatches_(r[ye].base_,e,t.patches_,t.inversePatches_)):e=nc(t,r,[]),Ju(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==gx?e:void 0}function nc(e,t,r){if(cc(t))return t;let o=t[ye];if(!o)return ri(t,(n,s)=>hx(e,o,t,n,s,r)),t;if(o.scope_!==e)return t;if(!o.modified_)return sc(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let n=o.copy_,s=n,i=!1;o.type_===3&&(s=new Set(n),n.clear(),i=!0),ri(s,(a,c)=>hx(e,o,n,a,c,r,i)),sc(e,n,!1),r&&e.patches_&&pn("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function hx(e,t,r,o,n,s,i){if(Gn(n)){let a=s&&t&&t.type_!==3&&!Ku(t.assigned_,o)?s.concat(o):void 0,c=nc(e,n,a);if(xx(r,o,c),Gn(c))e.canAutoFreeze_=!1;else return}else i&&r.add(n);if(eo(n)&&!cc(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;nc(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&(ii(r)?r.has(o):Object.prototype.propertyIsEnumerable.call(r,o))&&sc(e,n)}}function sc(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Zu(t,r)}function cO(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:oc(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=em;r&&(n=[o],s=ni);let{revoke:i,proxy:a}=Proxy.revocable(n,s);return o.draft_=a,o.revoke_=i,a}var em={get(e,t){if(t===ye)return e;let r=_t(e);if(!Ku(r,t))return lO(e,r,t);let o=r[t];return e.finalized_||!eo(o)?o:o===zu(e.base_,t)?(Vu(e),e.copy_[t]=si(o,e)):o},has(e,t){return t in _t(e)},ownKeys(e){return Reflect.ownKeys(_t(e))},set(e,t,r){let o=bx(_t(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=zu(_t(e),t),s=n?.[ye];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(nO(r,n)&&(r!==void 0||Ku(e.base_,t)))return!0;Vu(e),Zr(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 zu(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Vu(e),Zr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=_t(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){pr(11)},getPrototypeOf(e){return qn(e.base_)},setPrototypeOf(){pr(12)}},ni={};ri(em,(e,t)=>{ni[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ni.deleteProperty=function(e,t){return ni.set.call(this,e,t,void 0)};ni.set=function(e,t,r){return em.set.call(this,e[0],t,r,e[0])};function zu(e,t){let r=e[ye];return(r?_t(r):e)[t]}function lO(e,t,r){let o=bx(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function bx(e,t){if(!(t in e))return;let r=qn(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=qn(r)}}function Zr(e){e.modified_||(e.modified_=!0,e.parent_&&Zr(e.parent_))}function Vu(e){e.copy_||(e.copy_=Yu(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var pO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,o)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(a=s,...c){return i.produce(a,l=>r.call(this,l,...c))}}typeof r!="function"&&pr(6),o!==void 0&&typeof o!="function"&&pr(7);let n;if(eo(t)){let s=fx(this),i=si(t,void 0),a=!0;try{n=r(i),a=!1}finally{a?Ju(s):Qu(s)}return mx(s,o),dx(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===gx&&(n=void 0),this.autoFreeze_&&Zu(n,!0),o){let s=[],i=[];pn("Patches").generateReplacementPatches_(t,n,s,i),o(s,i)}return n}else pr(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,a=>t(a,...i));let o,n;return[this.produce(t,r,(s,i)=>{o=s,n=i}),o,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){eo(e)||pr(8),Gn(e)&&(e=uO(e));let t=fx(this),r=si(e,void 0);return r[ye].isManual_=!0,Qu(t),r}finishDraft(e,t){let r=e&&e[ye];(!r||!r.isManual_)&&pr(9);let{scope_:o}=r;return mx(o,t),dx(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let o=pn("Patches").applyPatches_;return Gn(e)?o(e,t):this.produce(e,n=>o(n,t))}};function si(e,t){let r=ii(e)?pn("MapSet").proxyMap_(e,t):ac(e)?pn("MapSet").proxySet_(e,t):cO(e,t);return(t?t.scope_:oc()).drafts_.push(r),r}function uO(e){return Gn(e)||pr(10,e),Ex(e)}function Ex(e){if(!eo(e)||cc(e))return e;let t=e[ye],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Yu(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Yu(e,!0);return ri(r,(o,n)=>{xx(r,o,Ex(n))}),t&&(t.finalized_=!1),r}function wx(){class e extends Map{constructor(c,l){super(),this[ye]={type_:2,parent_:l,scope_:l?l.scope_:oc(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:c,draft_:this,isManual_:!1,revoked_:!1}}get size(){return _t(this[ye]).size}has(c){return _t(this[ye]).has(c)}set(c,l){let u=this[ye];return i(u),(!_t(u).has(c)||_t(u).get(c)!==l)&&(r(u),Zr(u),u.assigned_.set(c,!0),u.copy_.set(c,l),u.assigned_.set(c,!0)),this}delete(c){if(!this.has(c))return!1;let l=this[ye];return i(l),r(l),Zr(l),l.base_.has(c)?l.assigned_.set(c,!1):l.assigned_.delete(c),l.copy_.delete(c),!0}clear(){let c=this[ye];i(c),_t(c).size&&(r(c),Zr(c),c.assigned_=new Map,ri(c.base_,l=>{c.assigned_.set(l,!1)}),c.copy_.clear())}forEach(c,l){let u=this[ye];_t(u).forEach((p,f,m)=>{c.call(l,this.get(f),f,this)})}get(c){let l=this[ye];i(l);let u=_t(l).get(c);if(l.finalized_||!eo(u)||u!==l.base_.get(c))return u;let p=si(u,l);return r(l),l.copy_.set(c,p),p}keys(){return _t(this[ye]).keys()}values(){let c=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let l=c.next();return l.done?l:{done:!1,value:this.get(l.value)}}}}entries(){let c=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let l=c.next();if(l.done)return l;let u=this.get(l.value);return{done:!1,value:[l.value,u]}}}}[Symbol.iterator](){return this.entries()}}function t(a,c){return new e(a,c)}function r(a){a.copy_||(a.assigned_=new Map,a.copy_=new Map(a.base_))}class o extends Set{constructor(c,l){super(),this[ye]={type_:3,parent_:l,scope_:l?l.scope_:oc(),modified_:!1,finalized_:!1,copy_:void 0,base_:c,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return _t(this[ye]).size}has(c){let l=this[ye];return i(l),l.copy_?!!(l.copy_.has(c)||l.drafts_.has(c)&&l.copy_.has(l.drafts_.get(c))):l.base_.has(c)}add(c){let l=this[ye];return i(l),this.has(c)||(s(l),Zr(l),l.copy_.add(c)),this}delete(c){if(!this.has(c))return!1;let l=this[ye];return i(l),s(l),Zr(l),l.copy_.delete(c)||(l.drafts_.has(c)?l.copy_.delete(l.drafts_.get(c)):!1)}clear(){let c=this[ye];i(c),_t(c).size&&(s(c),Zr(c),c.copy_.clear())}values(){let c=this[ye];return i(c),s(c),c.copy_.values()}entries(){let c=this[ye];return i(c),s(c),c.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(c,l){let u=this.values(),p=u.next();for(;!p.done;)c.call(l,p.value,p.value,this),p=u.next()}}function n(a,c){return new o(a,c)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(c=>{if(eo(c)){let l=si(c,a);a.drafts_.set(c,l),a.copy_.add(l)}else a.copy_.add(c)}))}function i(a){a.revoked_&&pr(3,JSON.stringify(_t(a)))}sO("MapSet",{proxyMap_:t,proxySet_:n})}var tr=new pO,lc=tr.produce,Yce=tr.produceWithPatches.bind(tr),Xce=tr.setAutoFreeze.bind(tr),Jce=tr.setUseStrictShallowCopy.bind(tr),Qce=tr.applyPatches.bind(tr),Zce=tr.createDraft.bind(tr),ele=tr.finishDraft.bind(tr);wx();var Rx=e=>{let t=0;for(let r of e)if(r&&(r.exists||(t+=(r.linked?.length??0)+(r.projectLinked?.length??0),t>1)))return!1;return t<2},kx=(e,t)=>lc(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...i}=t;Object.assign(r,i),tm(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}tm(r)&&!tm(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)}),tm=e=>e.lines[0].id==="dummy";var vx=(e,t)=>{let r=new Map,o=ae(t.title);for(let c of t.links){let l=rm(e,c);l.linked=[o],r.set(be(e,c),l)}let n=be(e,o),s=t.projectLinks.map(c=>{let l=tc(c);return be(l.project,l.titleLc)}),i={...pc(e,t),linked:[],projectLinked:[]};r.set(n,i);let a=t.links.map(c=>ae(c));for(let c of t.relatedPages.links1hop){c.linksLc.includes(o)&&i.linked.push(c.titleLc);for(let f of c.linksLc.filter(m=>a.includes(m))){let m=be(e,f),h=r.get(m)??rm(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=be(e,c.titleLc),u=pc(e,c),p=r.get(l)?.linked;p&&(u.linked=p),r.set(l,u)}for(let c of t.relatedPages.projectLinks1hop){let l=be(c.projectName,c.titleLc);s.includes(l)||i.projectLinked.push(l);let u=pc(c.projectName,c),p=r.get(l)?.projectLinked;p&&(u.projectLinked=p),r.set(l,u)}i.isLinkedCorrect=!0;for(let c of t.relatedPages.links2hop){for(let f of c.linksLc){let m=be(e,f),h=r.get(m)??rm(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=be(e,c.titleLc),u=pc(e,c),p=r.get(l)?.linked;p&&(u.linked=p),r.set(l,u)}return r},pc=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:ae(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:"descriptions"in t?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}),rm=(e,t)=>({project:e,titleLc:ae(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var uc=Po("ScrapBubble:bubble.ts"),om=new Map,mc=new Set,nm=Za();function*_x(e){for(let t of e)yield om.get(t)}var Px=(e,t)=>nm.on(e,t),Ox=(e,t)=>nm.off(e,t),Sx=async(e,t,r,o)=>{let n=[];for(let s of[...t].reverse()){let i=be(s,e);mc.has(i)||n.push(mO(s,e,r,o))}await Promise.all(n)},Tx=0,mO=async(e,t,r,o)=>{let n=be(e,t);if(mc.has(n))return;mc.add(n);let s=Tx++,i=${s} Check update ${n};uc.time(i);try{let a=ar.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[c,l]of Qa(a,{ignoreSearch:!0,saveFailedResponse:!0})){uc.debug(${s}${c} ${n});let u=await ar.fromResponse(l);if(K(u)){let p=vx(e,S(u));for(let[f,m]of p){let h=om.get(f),g=kx(h,m);g&&h!==g&&(om.set(f,g),nm.dispatch(f,m))}}if(o?.ignoreFetch===!0||c==="cache"&&!Zy(l,o?.maxAge??60))break}}catch(a){uc.error(a)}finally{mc.delete(n),uc.timeEnd(i),Tx--}};var Lx=Po("ScrapBubble:useBubbleData.ts"),zn=e=>{let[t,r]=Q(sm(e));return te(()=>{r(sm(e));let o,n=()=>{clearTimeout(o),o=setTimeout(()=>{Lx.debug(Update ${e.length} pages),r(sm(e))},10)};return e.forEach(s=>Px(s,n)),()=>e.forEach(s=>Ox(s,n))},e),t},sm=e=>{let t=[..._x(e)].flatMap(r=>r?[r]:[]);return Lx.debug(Required: ${e.length} pages, ${t.length} found,t),t};var Nx=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=H(()=>[...t.keys(),...r.keys()],[t,r]),i=zn(s),a=H(()=>[...o],[o]),c=H(()=>{let u=(p,f)=>{let m=a.indexOf(p.project),h=a.indexOf(f.project);return m===h?f.updated-p.updated:m<0?1:h<0?-1:m-h};return[...i].sort(u)},[i,a]),l=H(()=>({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:n.onClick,children:c.map(({project:u,titleLc:p,lines:[{text:f}],descriptions:m,image:h})=>{let g=be(u,p),y=t.get(g)??r.get(g);return d("li",{children:d(lx,{project:u,title:f,linkTo:y,descriptions:m,thumbnail:h??"",...n})},g)})})};var Vn=e=>{e:if(e.pathType==="root"){let[,r="",o=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(r==="")break e;let[,n]=o?.match?.(/#([a-f\d]{24,32})$/)??["",""];return o===""?{project:r}:n===""?{project:r,title:o}:{project:r,title:o.slice(0,-1-n.length),hash:n}}let[,t]=e.href.match(/#([a-f\d]{24,32})$/)??["",""];return t===""?{title:e.href}:{title:e.href.slice(0,-1-t.length),hash:t}};var im=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&ae(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=Vn({pathType:r.pathType,href:r.href});return o?!n&&ae(s)===e.titleLc:n===e.project&&ae(s)===e.titleLc}case"quote":case"strong":case"decoration":return im(e,r.nodes)}});var Oo=$s({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Cx=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:i,...a})=>{let c=H(()=>e.flatMap(m=>typeof m=="string"?[]:[m.id]),[e]),l=H(()=>{let m=0;return it(e.map(h=>typeof h=="string"?h:h.text).join(
),{hasTitle:!0}).map(h=>{switch(h.type){case"title":case"line":return{...h,id:c[m++]};case"codeBlock":{let g=m;return m+=h.content.split(
).length+1,{...h,ids:c.slice(g,m)}}case"table":{let g=m;return m+=h.cells.length+1,{...h,ids:c.slice(g,m)}}}})},[e,c]),u=H(()=>{if(s&&c.includes(s))return s;if(i)return l.find(m=>m.type!=="line"?!1:im(i,m.nodes))?.id},[l,c,s,i?.project,i?.titleLc]),p=ft(null);te(()=>{if(!u)return;let m=p.current?.querySelector(data-id="${u}"),h=globalThis.scrollY;m?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,h)},[u]);let f=ln(t);return d("div",{className:"lines","data-theme":f,ref:p,children:d(Oo.Provider,{value:{project:t,title:r,whiteList:o,...a},children:l.map(m=>{switch(m.type){case"title":return d(ee,{children:[d(Yn,{index:m.id,indent:0,noIndent:n,permalink:m.id===u,children:d("a",{className:"page-link",type:"link",href:/${t}/${ne(m.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:m.text})},m.id),d("hr",{})]});case"codeBlock":return d(fO,{block:m,noIndent:n,ids:m.ids,scrollId:u},m.ids[0]);case"table":return d(dO,{block:m,noIndent:n,ids:m.ids,scrollId:u},m.ids[0]);case"line":return d(Yn,{index:m.id,indent:m.indent,noIndent:n,permalink:m.id===u,children:m.nodes.length>0?m.nodes.map(h=>d(Kn,{node:h},h.raw)):d("br",{})},m.id)}})})})},Yn=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>d("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:o}),fO=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:i}=Kr(Oo),[a,c]=Q(""),l=U(async u=>{u.preventDefault(),u.stopPropagation();try{await navigator.clipboard.writeText(t),c("Copied"),await Fe(1e3),c("")}catch(p){alert(Failed to copy the code block
Error: ${p})}},[t]);return d(ee,{children:[d(Yn,{index:o[0],indent:r,permalink:o[0]===n,children:d("span",{className:"code-block",children:[d("span",{className:"code-block-start",children:d("a",{href:/api/code/${s}/${ne(i)}/${e},target:"_blank",children:e})}),d("span",{className:"copy",title:"Copy",onClick:l,children:a})]})}),d(ee,{children:t.split(
).map((u,p)=>d(Yn,{index:o[p+1],indent:r,permalink:o[p+1]===n,children:d("code",{className:"code-block",children:u})}))})]})},dO=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:i}=Kr(Oo);return d(ee,{children:[d(Yn,{index:o[0],indent:r,permalink:o[0]===n,children:d("span",{className:"table-block",children:d("span",{className:"table-block-start",children:d("a",{href:/api/table/${s}/${ne(i)}/${e}.csv,target:"_blank",children:e})})})}),d(ee,{children:t.map((a,c)=>d(Yn,{index:o[c+1],indent:r,permalink:o[c+1]===n,children:d("span",{className:"table-block table-block-row",children:a.map((l,u)=>d("span",{className:cell col-${u},children:l.map(p=>d(Kn,{node:p},p.raw))}))})}))})]})},Kn=({node:e})=>{switch(e.type){case"code":return d("code",{className:"code",children:e.text});case"formula":return d(hO,{node:e});case"commandLine":return d(yO,{node:e});case"helpfeel":return d("code",{className:"helpfeel",children:[d("span",{className:"prefix",children:"?"})," ",d("span",{className:"entry",children:e.text})]});case"quote":return d("blockquote",{className:"quote",children:e.nodes.map(t=>d(Kn,{node:t},t.raw))});case"strong":return d("strong",{children:e.nodes.map(t=>d(Kn,{node:t},t.raw))});case"decoration":return d(gO,{node:e});case"plain":case"blank":return d(ee,{children:e.text});case"hashTag":return d(EO,{node:e});case"link":return d(wO,{node:e});case"googleMap":return d(xO,{node:e});case"icon":return d(Mx,{node:e});case"strongIcon":return d(Mx,{node:e,strong:!0});case"image":return d(bO,{node:e});case"strongImage":return d("img",{className:"image strong-image",src:e.src});case"numberList":return d(ee,{children:[${e.number}. ,e.nodes.map(t=>d(Kn,{node:t},t.raw))]})}},hO=({node:{formula:e}})=>{let{ref:t,error:r}=Ja(e);return d("span",{className:formula ${r?" error":""},children:r?d("code",{children:e}):d("span",{className:"katex-display",ref:t})})},gO=({node:{decos:e,nodes:t}})=>d("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>d(Kn,{node:r},r.raw))}),yO=({node:e})=>{let[t,r]=Q(""),o=U(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await Fe(1e3),r("")}catch(s){alert(Failed to copy the code block
Error: ${s})}},[e.text]);return d(ee,{children:[d("code",{className:"cli",children:[d("span",{className:"prefix",children:e.symbol})," ",d("span",{className:"command",children:e.text})]}),d("span",{className:"tool-buttons",children:d("span",{title:"Copy",className:"copy",onClick:o,children:t})})]})},xO=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>d("span",{className:"pointing-device-map",children:d("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank",children:d("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${globalThis._csrf}})})}),Mx=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=Kr(Oo),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],i=ne(s);return d("a",{href:/${n}/${i},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",children:d("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${i}/icon})})},bO=({node:{link:e,src:t}})=>{let 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",children:d("img",{className:"image",src:t})})},EO=({node:{href:e}})=>{let{project:t}=Kr(Oo),r=Ix(t,e),o=Ax(t,e,"hashtag");return d("a",{href:/${t}/${ne(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:o,children:["#",e]})},wO=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return d(RO,{pathType:e,href:t.href});case"absolute":{let r=zy({pathType:e,...t});switch(r.type){case"youtube":return d(kO,{...r});case"vimeo":return d(vO,{...r});case"spotify":return d(TO,{...r});case"anchor-fm":return d(_O,{...r});case"audio":return d(PO,{...r});case"video":return d(SO,{...r});case"absoluteLink":return d("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},RO=({pathType:e,href:t})=>{let{project:r}=Kr(Oo),{project:o=r,title:n,hash:s=""}=Vn({pathType:e,href:t}),i=Ax(o,n,"link",s),a=Ix(o,n??"");return d("a",{className:page-link${n!==void 0&&a?" empty-page-link":""},type:"link",href:/${o}${n===void 0?"":/${ne(n)}${s===""?"":#${s}}},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:i,children:t})},kO=e=>{e.params.append("autoplay","0");let t=e.pathType==="list"?https://www.youtube.com/embed/?${e.params.toString()}&list=${e.listId}:https://www.youtube.com/embed/${e.videoId}?${e.params.toString()};return d("div",{className:"iframe-video-player",children:d("iframe",{src:t,allowFullScreen:!0})})},vO=({videoId:e})=>d("div",{className:"iframe-video-player",children:d("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0})}),TO=e=>d("div",{className:"iframe-video-player",children:d("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0})}),_O=e=>d("div",{className:"iframe-video-player",children:d("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0})}),PO=e=>e.content===""?d("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):d(OO,{...e}),OO=({href:e,content:t})=>{let r=ft(null),o=U(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return d("span",{className:"audio-link",children:[d("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),d("span",{className:"play",onClick:o,children:"♬"}),d("audio",{preload:"none",src:e,ref:r})]})},SO=({href:e})=>d("div",{className:"video-player",children:d("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),Ix=(e,t)=>{let{whiteList:r}=Kr(Oo),o=H(()=>(r.has(e)?[...r]:[e,...r]).map(s=>be(s,t)),[r,e]),n=zn(o);return H(()=>Rx(n),n)},Ax=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:i}=Kr(Oo);return U(async({currentTarget:a})=>{t&&(i(e,t),await Hn(a,n)&&s({project:e,title:t,hash:o,type:r,position:Wn(a)}))},[e,t,o,r,n,i,s])};var Fx=({pages:e,onClick:t,source:r,whiteList:o,...n})=>{let[s,i]=Q(be(e[0].project,e[0].titleLc)),a=H(()=>({top:${r.position.top}px,maxWidth:${r.position.maxWidth}px,..."left"in r.position?{left:${r.position.left}px}:{right:${r.position.right}px}}),[r.position]);return d("div",{className:"text-bubble",style:a,onClick:t,children:[e.length>1&&d("div",{role:"tablist",children:e.map(c=>d(LO,{project:c.project,titleLc:c.titleLc,selected:s===be(c.project,c.titleLc),tabSelector:i},be(c.project,c.titleLc)))}),e.map(c=>d(NO,{selected:s===be(c.project,c.titleLc),...c,title:c.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:o,...n},be(c.project,c.titleLc)))]})},LO=({project:e,titleLc:t,tabSelector:r,selected:o})=>{let n=U(()=>r(be(e,t)),[e,t]),s=ln(e);return d("button",{type:"button",role:"tab","aria-selected":o,"data-theme":s,tabIndex:-1,onClick:n,children:e})},NO=({selected:e,...t})=>{let r=ln(t.project);return d("div",{role:"tabpanel","data-theme":r,hidden:!e,children:d(Cx,{...t})})};var Dx=Po("ScrapBubble:Bubble.tsx"),Ux=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=H(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,i,a]=CO(e,n,r,t);return d(ee,{children:[MO(a)&&d(Fx,{pages:a,source:e,whiteList:r,onClick:o.hide,...o}),d(Nx,{linked:s,externalLinked:i,onClick:o.hide,source:e,projectsForSort:n,...o})]})},MO=e=>e.length>0,CO=(e,t,r,o)=>{let[[n,s,i],a]=Q([new Map,new Map,[]]),c=H(()=>{let p=[...t].map(f=>be(f,e.title));return Dx.debug("projects",p),p},[t,e.title]),l=zn(c),u=H(()=>o.map(p=>ae(p)),[o]);return Ra(()=>{let p=new Map,f=new Map,m=[];for(let h of l){let g={project:h.project,titleLc:h.titleLc};for(let x of h.projectLinked??[]){let{project:w,titleLc:k}=tc(x);u.includes(k)&&r.has(w)||f.has(x)||f.set(x,g)}if(!r.has(h.project))continue;let y={titleLc:h.titleLc};for(let x of h.linked??[]){if(u.includes(x))continue;let w=be(h.project,x);p.has(w)||p.set(w,y)}u.includes(h.titleLc)||h.exists&&m.push(h)}a(lc(h=>{Dx.debug(depth: ${u.length}, bubbled from ${be(e.project,e.title)}, bubbles,,l,"before",h[0],"internal cards,",p,"external cards",f);for(let g of h[0].keys())p.has(g)||h[0].delete(g);for(let[g,y]of p)h[0].set(g,y);for(let g of h[1].keys())f.has(g)||h[1].delete(g);for(let[g,y]of f)h[1].set(g,y);h[2]=m}))},[l,r,u]),[n,s,i]};var $x=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(o){if(!(o instanceof TypeError))throw o;return e}}};var jx=e=>{let t=H(()=>$x(e.style,import.meta.url),[e.style]);return d(ee,{children:t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",{children:t}))})};var Bx=String.raw*{box-sizing:border-box}a{background-color:transparent;text-decoration:none;cursor:pointer}img{display:inline-block;max-width:100%;max-height:100px}code{font-family:var(--code-text-font, Menlo, Monaco, Consolas, "Courier New", monospace);font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}blockquote{background-color:var(--quote-bg-color, rgba(0,0,0,.05));display:block;border-left:solid 4px #a0a0a0;padding-left:4px;margin:0}strong{font-weight:700}iframe{display:inline-block;margin:3px 0;vertical-align:middle;max-width:100%;width:640px;height:360px;border:0}audio{display:inline-block;vertical-align:middle;white-space:initial;max-width:100%}.formula{margin:auto 6px}.formula.error code{color:#fd7373}.katex-display{display:inline-block!important;margin:0!important;text-align:inherit!important}.error .katex-display{display:none}.cli{border-radius:4px}.cli .prefix{color:#9c6248}.helpfeel{background-color:#fbebdd;border-radius:4px;padding:3px!important}.helpfeel .prefix{color:#f17c00}.helpfeel .entry{color:#cc5020}.code-block{display:block;line-height:1.7em;background-color:var(--code-bg, rgba(0,0,0,.04))}.code-block-start{font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#342d9c;background-color:#ffcfc6;font-size:.9em;padding:1px 2px}.code-block-start a{color:#342d9c;text-decoration:underline}code.code-block,.table-block.table-block-row{padding-left:1em}.copy{font-family:"Font Awesome 5 Free";cursor:pointer}.table-block{white-space:nowrap}.table-block-start{padding:1px 2px;font-size:.9em;background-color:#ffcfc6}.table-block-start a{color:#342d9c;text-decoration:underline}.cell{margin:0;padding:0 2px 0 8px;box-sizing:content-box;display:inline-block;white-space:pre}.cell:nth-child(odd){background-color:#0000000a}.cell:nth-child(2n){background-color:#0000000f}.strong-image{max-height:100%}.icon{height:11px;vertical-align:middle}.strong-icon{height:13.2px}.tool-button{margin-left:1em;cursor:pointer;font-size:.9em}.deco-\/{font-style:italic}.deco-\*-1{font-weight:700}.deco-\*-2{font-weight:700;font-size:1.2em}.deco-\*-3{font-weight:700;font-size:1.44em}.deco-\*-4{font-weight:700;font-size:1.73em}.deco-\*-5{font-weight:700;font-size:2.07em}.deco-\*-6{font-weight:700;font-size:2.49em}.deco-\*-7{font-weight:700;font-size:3em}.deco-\*-8{font-weight:700;font-size:3.58em}.deco-\*-9{font-weight:700;font-size:4.3em}.deco-\*-10{font-weight:700;font-size:5.16em}.deco--{text-decoration:line-through}.deco-_{text-decoration:underline}.page-link{color:var(--page-link-color, #5e8af7)}a.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}a.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}a.link:hover{color:var(--page-link-color-hover-color, #2d67f5)}.link img{padding-bottom:3px;border-style:none none solid;border-width:1.5px;border-color:#8fadf9}.permalink{background-color:var(--line-permalink-color, rgba(234,218,74,.75))}.status-bar{display:inline-block;position:absolute;background-color:var(--page-bg, #fefefe);cursor:default}.status-bar>*{border:1px solid var(--status-bar-border-color, #a9aaaf)}.status-bar.top-left{top:0;left:0}.status-bar.top-left>*{border-top:none;border-left:none}.status-bar.top-left :last-of-type{border-bottom-right-radius:3px}.status-bar.top-right{top:0;right:0}.status-bar.top-right>*{border-top:none;border-right:none}.status-bar.top-right :last-of-type{border-bottom-left-radius:3px}.status-bar.bottom-right{bottom:0;right:0}.status-bar.bottom-right>*{border-bottom:none;border-right:none}.status-bar.bottom-right :last-of-type{border-top-left-radius:3px}.status-bar.bottom-left{bottom:0;left:0}.status-bar.bottom-left>*{border-bottom:none;border-left:none}.status-bar.bottom-left :last-of-type{border-top-right-radius:3px}.text-bubble{font-size:11px;line-height:1.42857;user-select:text;position:absolute;color:var(--page-text-color, #4a4a4a);box-shadow:0 6px 12px #0000002d;display:flex;flex-direction:column;z-index:9000;&.no-scroll{overflow-y:hidden}data-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}data-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}data-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}data-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}data-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}data-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}data-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}data-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}data-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}data-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}data-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}data-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}role=tabpanel{padding:5px 0 5px 5px;border-radius:4px;background-color:var(--page-bg, #fefefe);max-height:80vh;overflow-y:auto}role=tabpanel,button{border:1px solid var(--text-bubble-border-color, hsl(221, 15%, 25%))}button{cursor:default;color:inherit;font-size:inherit;line-height:inherit;background-color:var(--page-bg, #fefefe);border-radius:4px 4px 0 0}buttonaria-selected=true{background-color:var(--text-bubble-border-color, hsl(221, 15%, 25%))}}.project-badge{text-decoration:none;color:var(--tool-text-color, #363c49)}.related-page-carddata-theme=default-dark{--card-title-bg: hsl(0, 0%, 39%)}.related-page-carddata-theme=default-minimal{--card-title-bg: hsl(0, 0%, 89%)}.related-page-carddata-theme=paper-light{--card-title-bg: hsl(53, 8%, 58%)}.related-page-carddata-theme=paper-dark-dark{--card-title-bg: hsl(203, 42%, 17%)}.related-page-carddata-theme=blue{--card-title-bg: hsl(227, 68%, 62%)}.related-page-carddata-theme=purple{--card-title-bg: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--card-title-bg: hsl(136, 29%, 50%)}.related-page-carddata-theme=orange{--card-title-bg: hsl(43, 71%, 51%)}.related-page-carddata-theme=red{--card-title-bg: hsl(4, 58%, 56%)}.related-page-carddata-theme=spring{--card-title-bg: hsl(72, 64%, 57%)}.related-page-carddata-theme=kyoto{--card-title-bg: hsl(331, 21%, 26%)}.related-page-carddata-theme=newyork{--card-title-bg: hsl(176, 29%, 67%)}.related-page-card{display:block;position:relative;height:inherit;width:inherit;overflow:hidden;text-overflow:ellipsis;font-family:Roboto,Helvetica,Arial,Hiragino Sans,sans-serif;background-color:var(--card-bg, #fff);color:var(--card-title-color, #555);word-break:break-word;text-decoration:none}.related-page-card:hover{box-shadow:var(--card-box-hover-shadow, 0 2px 0 rgba(0,0,0,.23))}.related-page-card:focus{outline:0;box-shadow:0 0 0 3px #66afe999;border-color:#66afe9;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.related-page-card.hover{opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;background-color:var(--card-hover-bg, rgba(0,0,0,.05));mix-blend-mode:multiply;z-index:1;transition:background-color .1s}.related-page-card:hover .hover{opacity:1}.related-page-card:active .hover{opacity:1;background-color:var(--card-active-bg, rgba(0,0,0,.1))}.related-page-card .content{height:calc(100% - 5px);width:inherit;display:flex;flex-direction:column;overflow:hidden}.related-page-card .content .header{width:100%;color:#396bdd;text-overflow:ellipsis;border-top:var(--card-title-bg, #f2f2f3) solid 10px;padding:8px 10px}.related-page-card .content .header .title{font-size:11px;line-height:16px;font-weight:700;max-height:48px;color:var(--card-title-color, #363c49);margin:0;overflow:hidden;display:block;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-overflow:ellipsis}.related-page-card .content .description{line-height:16px;padding:8px 10px 0;font-size:10px;white-space:pre-line;column-count:1;column-gap:2em;column-width:10em;height:inherit;color:var(--card-description-color, gray);flex-shrink:16;overflow:hidden}.related-page-card .content .thumbnail{display:block;width:100%;margin:0 auto;padding:0 5px}.related-page-card .content .description p{margin:0;display:block}.related-page-card .content .description code{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}.related-page-card .content .description .icon{height:9px;vertical-align:middle}.related-page-card .content .description .page-link{background-color:transparent;text-decoration:none;cursor:pointer;color:var(--page-link-color, #5e8af7)}.card-bubble{background-color:var(--page-bg, #FFF);box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;position:absolute;max-width:80vw;box-sizing:content-box;z-index:9000;font-size:11px;line-height:1.42857;display:flex;padding:0;margin:0;list-style:none;overflow-x:auto;overflow-y:visible}.card-bubble li{display:block;position:relative;float:none;margin:5px;box-sizing:border-box;box-shadow:var(--card-box-shadow, 0 2px 0 rgba(0,0,0,.12));border-radius:2px;width:120px;height:120px}
;var Hx=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),fc=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var Wx=()=>{let[e,t]=Q([{bubble:o=>r(0,o),hide:()=>r(0)}]),r=U((o,n)=>{t(([s,...i])=>[s,...n?[...i.slice(0,o),n===i.at(o)?.source?i.at(o):{source:n,parentTitles:[scrapbox.Page.title??"",...i.slice(0,o).map(a=>a.source.title)],bubble:a=>r(o+1,a),hide:()=>r(o+1)}]:[...i.slice(0,o)]])},[]);return e};var am=(e,t,r,o,n)=>{te(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var cm="scrap-bubble",qx=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...i]=Wx(),a=U((c,l)=>Sx(l,t.has(c)?t:new Set([c]),r),[t,r]);return am(document,"pointerenter",async c=>{let l=c.target;if(!fc(l)&&!Hx(l))return;let{project:u=scrapbox.Project.name,title:p,hash:f=""}=fc(l)?Vn({pathType:"root",href:${new URL(l.href).pathname}${new URL(l.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(u==="")return;let m=decodeURIComponent(p??"");a(u,m),await Hn(l,e)&&n({project:u,title:m,hash:f,position:Wn(l),type:IO(l)})},{capture:!0},[e,t,r]),am(document,"click",c=>{c.target.dataset.userscriptName!==cm&&s()},{capture:!0},[s]),te(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),d(ee,{children:[d("link",{rel:"stylesheet",href:https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${Xa}/katex.min.css}),d("style",{children:Bx}),d(jx,{style:o}),i.map(c=>d(Ux,{...c,whiteList:t,delay:e,prefetch:a},be(c.source.project,c.source.title)))]})},IO=e=>fc(e)?e.type==="link"?"link":"hashtag":"title";var Gx=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await Vy()).slice(0,100),style:n="",debug:s=!1}=e??{};ex(s);let i=document.createElement("div");i.dataset.userscriptName=cm,document.body.append(i);let a=i.attachShadow({mode:"open"});Rt(d(qx,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(o),style:n}),a)};var AO=["takker-memex","takker-private","takker","takker-books","villagepump"],un=[];switch(scrapbox.Project.name){case"hub":case"villagepump":case"verbalizing-community":un.push("villagepump","hub","verbalizing-community");break;case"programming-notes":case"customize":case"scrapboxlab":un.push("programming-notes","customize","scrapboxlab");break;case"sta":un.push("sta-taskmanagement");break;case"sta-taskmanagement":case"taskmanagement":un.push("sta-taskmanagement","taskmanagement");break;case"plurality-japanese":un.push("nishio","tkgshn");case"takker-books":un.push("work4ai");break}Gx({delay:/mobile/i.test(navigator.userAgent)?300:500,whiteList:[...AO,...un],style:@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";
@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";});var zx=e=>{{let r=e.match(/^([^(]+)\(([^)]+)\)$/);if(r)return{fileName:r[1],lang:r[2]}}let t=e.split(".").pop();return t===void 0?{fileName:e,lang:e}:{fileName:e,lang:t}};var dc={};Bi(dc,{getTitle:()=>vh,parse:()=>it});var Vx=(e,t,r)=>{if(r.length===0)return[];let o=r.map(a=>a.text).join(
),n=it(o,{hasTitle:!0}),s=new Map,i=0;for(let a of n)switch(a.type){case"title":case"line":{i++;break}case"table":i+=a.cells.length+1;break;case"codeBlock":{let{fileName:c,lang:l}=zx(a.fileName),u=s.get(c);s.set(c,{path:u?.path??https://scrapbox.io/api/code/${e}/${ne(t)}/${ne(c)},lang:u?.lang??l,startIds:[...u?.startIds??[],r[i].id]}),i+=a.content.split(
).length+1;break}}return s.values()};function pm(e){let t=o=>{if(o===null)r.write8(0);else if(typeof o=="boolean")r.write8(1),r.write8(+o);else if(typeof o=="number")r.write8(2),r.write32(o|0);else if(typeof o=="string")r.write8(3),r.write(vr(o));else if(o instanceof Uint8Array)r.write8(4),r.write(o);else if(o instanceof Array){r.write8(5),r.write32(o.length);for(let n of o)t(n)}else{let n=Object.keys(o);r.write8(6),r.write32(n.length);for(let s of n)r.write(vr(s)),t(o[s])}},r=new hc;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),lm(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Kx(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return Xn(r.read());case 4:return r.read();case 5:{let i=r.read32(),a=[];for(let c=0;c<i;c++)a.push(t());return a}case 6:{let i=r.read32(),a={};for(let c=0;c<i;c++)a[Xn(r.read())]=t();return a}default:throw new Error("Invalid packet")}},r=new hc(e),o=r.read32(),n=(o&1)===0;o>>>=1;let s=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:n,value:s}}var hc=class{constructor(t=new Uint8Array(1024)){this.buf=t}len=0;ptr=0;_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);lm(this.buf,t,r)}write(t){let r=this._write(4+t.length);lm(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return um(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),o=this._read(r.length);return r.set(this.buf.subarray(o,o+t)),r}},vr,Xn,Yx;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;vr=r=>e.encode(r),Xn=r=>t.decode(r),Yx='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(vr("")instanceof Uint8Array))throw new Error(Invariant violation: "${Yx} instanceof Uint8Array" is incorrectly false
This indicates that your JavaScript environment is broken. You cannot use
esbuild in this environment because esbuild relies on this invariant. This
is not a problem with esbuild. You need to fix your environment instead.
);function um(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function lm(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var ai="0.24.0";var lt=JSON.stringify,Xx="warning",Jx="silent";function Qx(e){if(Pt(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var xc=()=>null,Ue=e=>typeof e=="boolean"?null:"a boolean",V=e=>typeof e=="string"?null:"a string",bc=e=>e instanceof RegExp?null:"a RegExp object",fn=e=>typeof e=="number"&&e===(e|0)?null:"an integer",tb=e=>typeof e=="function"?null:"a function",He=e=>Array.isArray(e)?null:"an array",ur=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",DO=e=>typeof e=="object"&&e!==null?null:"an array or an object";var Zx=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",rb=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",UO=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",$O=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ob=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function R(e,t,r,o){let n=e[r];if(t[r+""]=!0,n===void 0)return;let s=o(n);if(s!==null)throw new Error(${lt(r)} must be ${s});return n}function bt(e,t,r){for(let o in e)if(!(o in t))throw new Error(Invalid option ${r}: ${lt(o)})}function nb(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let o=e[r];if(typeof o=="string"||o===!1)t[r]=o;else throw new Error(Expected ${lt(r)} in mangle cache to map to either a string or false)}}return t}function Ec(e,t,r,o,n){let s=R(t,r,"color",Ue),i=R(t,r,"logLevel",V),a=R(t,r,"logLimit",fn);s!==void 0?e.push(--color=${s}):o&&e.push("--color=true"),e.push(--log-level=${i||n}),e.push(--log-limit=${a||0})}function Pt(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+lt(r):""} to be a string, got ${typeof e} instead);return e}function sb(e,t,r){let o=R(t,r,"legalComments",V),n=R(t,r,"sourceRoot",V),s=R(t,r,"sourcesContent",Ue),i=R(t,r,"target",$O),a=R(t,r,"format",V),c=R(t,r,"globalName",V),l=R(t,r,"mangleProps",bc),u=R(t,r,"reserveProps",bc),p=R(t,r,"mangleQuoted",Ue),f=R(t,r,"minify",Ue),m=R(t,r,"minifySyntax",Ue),h=R(t,r,"minifyWhitespace",Ue),g=R(t,r,"minifyIdentifiers",Ue),y=R(t,r,"lineLimit",fn),x=R(t,r,"drop",He),w=R(t,r,"dropLabels",He),k=R(t,r,"charset",V),b=R(t,r,"treeShaking",Ue),T=R(t,r,"ignoreAnnotations",Ue),v=R(t,r,"jsx",V),A=R(t,r,"jsxFactory",V),F=R(t,r,"jsxFragment",V),D=R(t,r,"jsxImportSource",V),N=R(t,r,"jsxDev",Ue),_=R(t,r,"jsxSideEffects",Ue),P=R(t,r,"define",ur),I=R(t,r,"logOverride",ur),$=R(t,r,"supported",ur),j=R(t,r,"pure",He),q=R(t,r,"keepNames",Ue),B=R(t,r,"platform",V),Y=R(t,r,"tsconfigRaw",UO);if(o&&e.push(--legal-comments=${o}),n!==void 0&&e.push(--source-root=${n}),s!==void 0&&e.push(--sources-content=${s}),i&&(Array.isArray(i)?e.push(--target=${Array.from(i).map(Qx).join(",")}):e.push(--target=${Qx(i)})),a&&e.push(--format=${a}),c&&e.push(--global-name=${c}),B&&e.push(--platform=${B}),Y&&e.push(--tsconfig-raw=${typeof Y=="string"?Y:JSON.stringify(Y)}),f&&e.push("--minify"),m&&e.push("--minify-syntax"),h&&e.push("--minify-whitespace"),g&&e.push("--minify-identifiers"),y&&e.push(--line-limit=${y}),k&&e.push(--charset=${k}),b!==void 0&&e.push(--tree-shaking=${b}),T&&e.push("--ignore-annotations"),x)for(let G of x)e.push(--drop:${Pt(G,"drop")});if(w&&e.push(--drop-labels=${Array.from(w).map(G=>Pt(G,"dropLabels")).join(",")}),l&&e.push(--mangle-props=${l.source}),u&&e.push(--reserve-props=${u.source}),p!==void 0&&e.push(--mangle-quoted=${p}),v&&e.push(--jsx=${v}),A&&e.push(--jsx-factory=${A}),F&&e.push(--jsx-fragment=${F}),D&&e.push(--jsx-import-source=${D}),N&&e.push("--jsx-dev"),_&&e.push("--jsx-side-effects"),P)for(let G in P){if(G.indexOf("=")>=0)throw new Error(Invalid define: ${G});e.push(--define:${G}=${Pt(PG,"define",G)})}if(I)for(let G in I){if(G.indexOf("=")>=0)throw new Error(Invalid log override: ${G});e.push(--log-override:${G}=${Pt(IG,"log override",G)})}if($)for(let G in $){if(G.indexOf("=")>=0)throw new Error(Invalid supported: ${G});let X=$[G];if(typeof X!="boolean")throw new Error(Expected value for supported ${lt(G)} to be a boolean, got ${typeof X} instead);e.push(--supported:${G}=${X})}if(j)for(let G of j)e.push(--pure:${Pt(G,"pure")});q&&e.push("--keep-names")}function jO(e,t,r,o,n){let s=[],i=[],a=Object.create(null),c=null,l=null;Ec(s,t,a,r,o),sb(s,t,a);let u=R(t,a,"sourcemap",rb),p=R(t,a,"bundle",Ue),f=R(t,a,"splitting",Ue),m=R(t,a,"preserveSymlinks",Ue),h=R(t,a,"metafile",Ue),g=R(t,a,"outfile",V),y=R(t,a,"outdir",V),x=R(t,a,"outbase",V),w=R(t,a,"tsconfig",V),k=R(t,a,"resolveExtensions",He),b=R(t,a,"nodePaths",He),T=R(t,a,"mainFields",He),v=R(t,a,"conditions",He),A=R(t,a,"external",He),F=R(t,a,"packages",V),D=R(t,a,"alias",ur),N=R(t,a,"loader",ur),_=R(t,a,"outExtension",ur),P=R(t,a,"publicPath",V),I=R(t,a,"entryNames",V),$=R(t,a,"chunkNames",V),j=R(t,a,"assetNames",V),q=R(t,a,"inject",He),B=R(t,a,"banner",ur),Y=R(t,a,"footer",ur),G=R(t,a,"entryPoints",DO),X=R(t,a,"absWorkingDir",V),J=R(t,a,"stdin",ur),ue=R(t,a,"write",Ue)??n,oe=R(t,a,"allowOverwrite",Ue),wt=R(t,a,"mangleCache",ur);if(a.plugins=!0,bt(t,a,in ${e}() call),u&&s.push(--sourcemap${u===!0?"":=${u}}),p&&s.push("--bundle"),oe&&s.push("--allow-overwrite"),f&&s.push("--splitting"),m&&s.push("--preserve-symlinks"),h&&s.push("--metafile"),g&&s.push(--outfile=${g}),y&&s.push(--outdir=${y}),x&&s.push(--outbase=${x}),w&&s.push(--tsconfig=${w}),F&&s.push(--packages=${F}),k){let W=[];for(let Ee of k){if(Pt(Ee,"resolve extension"),Ee.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${Ee});W.push(Ee)}s.push(--resolve-extensions=${W.join(",")})}if(P&&s.push(--public-path=${P}),I&&s.push(--entry-names=${I}),$&&s.push(--chunk-names=${$}),j&&s.push(--asset-names=${j}),T){let W=[];for(let Ee of T){if(Pt(Ee,"main field"),Ee.indexOf(",")>=0)throw new Error(Invalid main field: ${Ee});W.push(Ee)}s.push(--main-fields=${W.join(",")})}if(v){let W=[];for(let Ee of v){if(Pt(Ee,"condition"),Ee.indexOf(",")>=0)throw new Error(Invalid condition: ${Ee});W.push(Ee)}s.push(--conditions=${W.join(",")})}if(A)for(let W of A)s.push(--external:${Pt(W,"external")});if(D)for(let W in D){if(W.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${W});s.push(--alias:${W}=${Pt(DW,"alias",W)})}if(B)for(let W in B){if(W.indexOf("=")>=0)throw new Error(Invalid banner file type: ${W});s.push(--banner:${W}=${Pt(BW,"banner",W)})}if(Y)for(let W in Y){if(W.indexOf("=")>=0)throw new Error(Invalid footer file type: ${W});s.push(--footer:${W}=${Pt(YW,"footer",W)})}if(q)for(let W of q)s.push(--inject:${Pt(W,"inject")});if(N)for(let W in N){if(W.indexOf("=")>=0)throw new Error(Invalid loader extension: ${W});s.push(--loader:${W}=${Pt(NW,"loader",W)})}if(_)for(let W in _){if(W.indexOf("=")>=0)throw new Error(Invalid out extension: ${W});s.push(--out-extension:${W}=${Pt(_W,"out extension",W)})}if(G)if(Array.isArray(G))for(let W=0,Ee=G.length;W<Ee;W++){let Nt=G[W];if(typeof Nt=="object"&&Nt!==null){let Br=Object.create(null),Hr=R(Nt,Br,"in",V),Pr=R(Nt,Br,"out",V);if(bt(Nt,Br,"in entry point at index "+W),Hr===void 0)throw new Error('Missing property "in" for entry point at index '+W);if(Pr===void 0)throw new Error('Missing property "out" for entry point at index '+W);i.push([Pr,Hr])}else i.push(["",Pt(Nt,"entry point at index "+W)])}else for(let W in G)i.push([W,Pt(G[W],"entry point",W)]);if(J){let W=Object.create(null),Ee=R(J,W,"contents",ob),Nt=R(J,W,"resolveDir",V),Br=R(J,W,"sourcefile",V),Hr=R(J,W,"loader",V);bt(J,W,'in "stdin" object'),Br&&s.push(--sourcefile=${Br}),Hr&&s.push(--loader=${Hr}),Nt&&(l=Nt),typeof Ee=="string"?c=vr(Ee):Ee instanceof Uint8Array&&(c=Ee)}let Se=[];if(b)for(let W of b)W+="",Se.push(W);return{entries:i,flags:s,write:ue,stdinContents:c,stdinResolveDir:l,absWorkingDir:X,nodePaths:Se,mangleCache:nb(wt)}}function BO(e,t,r,o){let n=[],s=Object.create(null);Ec(n,t,s,r,o),sb(n,t,s);let i=R(t,s,"sourcemap",rb),a=R(t,s,"sourcefile",V),c=R(t,s,"loader",V),l=R(t,s,"banner",V),u=R(t,s,"footer",V),p=R(t,s,"mangleCache",ur);return bt(t,s,in ${e}() call),i&&n.push(--sourcemap=${i===!0?"external":i}),a&&n.push(--sourcefile=${a}),c&&n.push(--loader=${c}),l&&n.push(--banner=${l}),u&&n.push(--footer=${u}),{flags:n,mangleCache:nb(p)}}function ib(e){let t={},r={didClose:!1,reason:""},o={},n=0,s=0,i=new Uint8Array(16*1024),a=0,c=k=>{let b=a+k.length;if(b>i.length){let v=new Uint8Array(b*2);v.set(i),i=v}i.set(k,a),a+=k.length;let T=0;for(;T+4<=a;){let v=um(i,T);if(T+4+v>a)break;T+=4,h(i.subarray(T,T+v)),T+=v}T>0&&(i.copyWithin(0,T,a),a-=T)},l=k=>{r.didClose=!0,k&&(r.reason=": "+(k.message||k));let b="The service was stopped"+r.reason;for(let T in o)o[T](b,null);o={}},u=(k,b,T)=>{if(r.didClose)return T("The service is no longer running"+r.reason,null);let v=n++;o[v]=(A,F)=>{try{T(A,F)}finally{k&&k.unref()}},k&&k.ref(),e.writeToStdin(pm({id:v,isRequest:!0,value:b}))},p=(k,b)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(pm({id:k,isRequest:!1,value:b}))},f=async(k,b)=>{try{if(b.command==="ping"){p(k,{});return}if(typeof b.key=="number"){let T=t[b.key];if(!T)return;let v=T[b.command];if(v){await v(k,b);return}}throw new Error("Invalid command: "+b.command)}catch(T){let v=[mn(T,e,null,void 0,"")];try{p(k,{errors:v})}catch{}}},m=!0,h=k=>{if(m){m=!1;let T=String.fromCharCode(...k);if(T!==ai)throw new Error(Cannot start service: Host version "${ai}" does not match binary version ${lt(T)});return}let b=Kx(k);if(b.isRequest)f(b.id,b.value);else{let T=o[b.id];delete o[b.id],b.value.error?T(b.value.error,{}):T(null,b.value)}};return{readFromStdout:c,afterClose:l,service:{buildOrContext:({callName:k,refs:b,options:T,isTTY:v,defaultWD:A,callback:F})=>{let D=0,N=s++,_={},P={ref(){++D===1&&b&&b.ref()},unref(){--D===0&&(delete t[N],b&&b.unref())}};t[N]=_,P.ref(),HO(k,N,u,p,P,e,_,T,v,A,(I,$)=>{try{F(I,$)}finally{P.unref()}})},transform:({callName:k,refs:b,input:T,options:v,isTTY:A,fs:F,callback:D})=>{let N=ab(),_=P=>{try{if(typeof T!="string"&&!(T instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:I,mangleCache:$}=BO(k,v,A,Jx),j={command:"transform",flags:I,inputFS:P!==null,input:P!==null?vr(P):typeof T=="string"?vr(T):T};$&&(j.mangleCache=$),u(b,j,(q,B)=>{if(q)return D(new Error(q),null);let Y=Jn(B.errors,N),G=Jn(B.warnings,N),X=1,J=()=>{if(--X===0){let ue={warnings:G,code:B.code,map:B.map,mangleCache:void 0,legalComments:void 0};"legalComments"in B&&(ue.legalComments=B?.legalComments),B.mangleCache&&(ue.mangleCache=B?.mangleCache),D(null,ue)}};if(Y.length>0)return D(ci("Transform failed",Y,G),null);B.codeFS&&(X++,F.readFile(B.code,(ue,oe)=>{ue!==null?D(ue,null):(B.code=oe,J())})),B.mapFS&&(X++,F.readFile(B.map,(ue,oe)=>{ue!==null?D(ue,null):(B.map=oe,J())})),J()})}catch(I){let $=[];try{Ec($,v,{},A,Jx)}catch{}let j=mn(I,e,N,void 0,"");u(b,{command:"error",flags:$,error:j},()=>{j.detail=N.load(j.detail),D(ci("Transform failed",[j],[]),null)})}};if((typeof T=="string"||T instanceof Uint8Array)&&T.length>1024*1024){let P=_;_=()=>F.writeFile(T,P)}_(null)},formatMessages:({callName:k,refs:b,messages:T,options:v,callback:A})=>{if(!v)throw new Error(Missing second argument in ${k}() call);let F={},D=R(v,F,"kind",V),N=R(v,F,"color",Ue),_=R(v,F,"terminalWidth",fn);if(bt(v,F,in ${k}() call),D===void 0)throw new Error(Missing "kind" in ${k}() call);if(D!=="error"&&D!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${k}() call);let P={command:"format-msgs",messages:to(T,"messages",null,"",_),isWarning:D==="warning"};N!==void 0&&(P.color=N),_!==void 0&&(P.terminalWidth=_),u(b,P,(I,$)=>{if(I)return A(new Error(I),null);A(null,$.messages)})},analyzeMetafile:({callName:k,refs:b,metafile:T,options:v,callback:A})=>{v===void 0&&(v={});let F={},D=R(v,F,"color",Ue),N=R(v,F,"verbose",Ue);bt(v,F,in ${k}() call);let _={command:"analyze-metafile",metafile:T};D!==void 0&&(_.color=D),N!==void 0&&(_.verbose=N),u(b,_,(P,I)=>{if(P)return A(new Error(P),null);A(null,I.result)})}}}}function HO(e,t,r,o,n,s,i,a,c,l,u){let p=ab(),f=e==="context",m=(y,x)=>{let w=[];try{Ec(w,a,{},c,Xx)}catch{}let k=mn(y,s,p,void 0,x);r(n,{command:"error",flags:w,error:k},()=>{k.detail=p.load(k.detail),u(ci(f?"Context failed":"Build failed",[k],[]),null)})},h;if(typeof a=="object"){let y=a.plugins;if(y!==void 0){if(!Array.isArray(y))return m(new Error('"plugins" must be an array'),"");h=y}}if(h&&h.length>0){if(s.isSync)return m(new Error("Cannot use plugins in synchronous API calls"),"");WO(t,r,o,n,s,i,a,h,p).then(y=>{if(!y.ok)return m(y.error,y.pluginName);try{g(y.requestPlugins,y.runOnEndCallbacks,y.scheduleOnDisposeCallbacks)}catch(x){m(x,"")}},y=>m(y,""));return}try{g(null,(y,x)=>x([],[]),()=>{})}catch(y){m(y,"")}function g(y,x,w){let k=s.hasFS,{entries:b,flags:T,write:v,stdinContents:A,stdinResolveDir:F,absWorkingDir:D,nodePaths:N,mangleCache:_}=jO(e,a,c,Xx,k);if(v&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let P={command:"build",key:t,entries:b,flags:T,write:v,stdinContents:A,stdinResolveDir:F,absWorkingDir:D||l,nodePaths:N,context:f};y&&(P.plugins=y),_&&(P.mangleCache=_);let I=(q,B)=>{let Y={errors:Jn(q.errors,p),warnings:Jn(q.warnings,p),outputFiles:void 0,metafile:void 0,mangleCache:void 0},G=Y.errors.slice(),X=Y.warnings.slice();q.outputFiles&&(Y.outputFiles=q.outputFiles.map(GO)),q.metafile&&(Y.metafile=JSON.parse(q.metafile)),q.mangleCache&&(Y.mangleCache=q.mangleCache),q.writeToStdout!==void 0&&console.log(Xn(q.writeToStdout).replace(/\n$/,"")),x(Y,(J,ue)=>{if(G.length>0||J.length>0){let oe=ci("Build failed",G.concat(J),X.concat(ue));return B(oe,null,J,ue)}B(null,Y,J,ue)})},$,j;f&&(i["on-end"]=(q,B)=>new Promise(Y=>{I(B,(G,X,J,ue)=>{let oe={errors:J,warnings:ue};j&&j(G,X),$=void 0,j=void 0,o(q,oe),Y()})})),r(n,P,(q,B)=>{if(q)return u(new Error(q),null);if(!f)return I(B,(X,J)=>(w(),u(X,J)));if(B.errors.length>0)return u(ci("Context failed",B.errors,B.warnings),null);let Y=!1,G={rebuild:()=>($||($=new Promise((X,J)=>{let ue;j=(wt,Se)=>{ue||(ue=()=>wt?J(wt):X(Se))};let oe=()=>{r(n,{command:"rebuild",key:t},(Se,W)=>{Se?J(new Error(Se)):ue?ue():oe()})};oe()})),$),watch:(X={})=>new Promise((J,ue)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');bt(X,{},"in watch() call"),r(n,{command:"watch",key:t},Se=>{Se?ue(new Error(Se)):J(void 0)})}),serve:(X={})=>new Promise((J,ue)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let oe={},wt=R(X,oe,"port",fn),Se=R(X,oe,"host",V),W=R(X,oe,"servedir",V),Ee=R(X,oe,"keyfile",V),Nt=R(X,oe,"certfile",V),Br=R(X,oe,"fallback",V),Hr=R(X,oe,"onRequest",tb);bt(X,oe,"in serve() call");let Pr={command:"serve",key:t,onRequest:!!Hr};wt!==void 0&&(Pr.port=wt),Se!==void 0&&(Pr.host=Se),W!==void 0&&(Pr.servedir=W),Ee!==void 0&&(Pr.keyfile=Ee),Nt!==void 0&&(Pr.certfile=Nt),Br!==void 0&&(Pr.fallback=Br),r(n,Pr,(rd,ET)=>{if(rd)return ue(new Error(rd));Hr&&(i["serve-request"]=(wT,RT)=>{Hr(RT.args),o(wT,{})}),J(ET)})}),cancel:()=>new Promise(X=>{if(Y)return X();r(n,{command:"cancel",key:t},()=>{X()})}),dispose:()=>new Promise(X=>{if(Y)return X();Y=!0,r(n,{command:"dispose",key:t},()=>{X(),w(),n.unref()})})};n.ref(),u(null,G)})}}var WO=async(e,t,r,o,n,s,i,a,c)=>{let l=[],u=[],p={},f={},m=[],h=0,g=0,y=[],x=!1;a=[...a];for(let b of a){let T={};if(typeof b!="object")throw new Error(Plugin at index ${g} must be an object);let v=R(b,T,"name",V);if(typeof v!="string"||v==="")throw new Error(Plugin at index ${g} is missing a name);try{let A=R(b,T,"setup",tb);if(typeof A!="function")throw new Error("Plugin is missing a setup function");bt(b,T,on plugin ${lt(v)});let F={name:v,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};g++;let N=A({initialOptions:i,resolve:(_,P={})=>{if(!x)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof _!="string")throw new Error("The path to resolve must be a string");let I=Object.create(null),$=R(P,I,"pluginName",V),j=R(P,I,"importer",V),q=R(P,I,"namespace",V),B=R(P,I,"resolveDir",V),Y=R(P,I,"kind",V),G=R(P,I,"pluginData",xc),X=R(P,I,"with",ur);return bt(P,I,"in resolve() call"),new Promise((J,ue)=>{let oe={command:"resolve",path:_,key:e,pluginName:v};if($!=null&&(oe.pluginName=$),j!=null&&(oe.importer=j),q!=null&&(oe.namespace=q),B!=null&&(oe.resolveDir=B),Y!=null)oe.kind=Y;else throw new Error('Must specify "kind" when calling "resolve"');G!=null&&(oe.pluginData=c.store(G)),X!=null&&(oe.with=qO(X,"with")),t(o,oe,(wt,Se)=>{wt!==null?ue(new Error(wt)):J({errors:Jn(Se.errors,c),warnings:Jn(Se.warnings,c),path:Se.path,external:Se.external,sideEffects:Se.sideEffects,namespace:Se.namespace,suffix:Se.suffix,pluginData:c.load(Se.pluginData)})})})},onStart(_){let P='This error came from the "onStart" callback registered here:',I=gc(new Error(P),n,"onStart");l.push({name:v,callback:_,note:I}),F.onStart=!0},onEnd(_){let P='This error came from the "onEnd" callback registered here:',I=gc(new Error(P),n,"onEnd");u.push({name:v,callback:_,note:I}),F.onEnd=!0},onResolve(_,P){let I='This error came from the "onResolve" callback registered here:',$=gc(new Error(I),n,"onResolve"),j={},q=R(_,j,"filter",bc),B=R(_,j,"namespace",V);if(bt(_,j,in onResolve() call for plugin ${lt(v)}),q==null)throw new Error("onResolve() call is missing a filter");let Y=h++;p[Y]={name:v,callback:P,note:$},F.onResolve.push({id:Y,filter:q.source,namespace:B||""})},onLoad(_,P){let I='This error came from the "onLoad" callback registered here:',$=gc(new Error(I),n,"onLoad"),j={},q=R(_,j,"filter",bc),B=R(_,j,"namespace",V);if(bt(_,j,in onLoad() call for plugin ${lt(v)}),q==null)throw new Error("onLoad() call is missing a filter");let Y=h++;f[Y]={name:v,callback:P,note:$},F.onLoad.push({id:Y,filter:q.source,namespace:B||""})},onDispose(_){m.push(_)},esbuild:n.esbuild});N&&await N,y.push(F)}catch(A){return{ok:!1,error:A,pluginName:v}}}s["on-start"]=async(b,T)=>{c.clear();let v={errors:[],warnings:[]};await Promise.all(l.map(async({name:A,callback:F,note:D})=>{try{let N=await F();if(N!=null){if(typeof N!="object")throw new Error(Expected onStart() callback in plugin ${lt(A)} to return an object);let _={},P=R(N,_,"errors",He),I=R(N,_,"warnings",He);bt(N,_,from onStart() callback in plugin ${lt(A)}),P!=null&&v.errors.push(...to(P,"errors",c,A,void 0)),I!=null&&v.warnings.push(...to(I,"warnings",c,A,void 0))}}catch(N){v.errors.push(mn(N,n,c,D&&D(),A))}})),r(b,v)},s["on-resolve"]=async(b,T)=>{let v={},A="",F,D;for(let N of T.ids)try{({name:A,callback:F,note:D}=p[N]);let _=await F({path:T.path,importer:T.importer,namespace:T.namespace,resolveDir:T.resolveDir,kind:T.kind,pluginData:c.load(T.pluginData),with:T.with});if(_!=null){if(typeof _!="object")throw new Error(Expected onResolve() callback in plugin ${lt(A)} to return an object);let P={},I=R(_,P,"pluginName",V),$=R(_,P,"path",V),j=R(_,P,"namespace",V),q=R(_,P,"suffix",V),B=R(_,P,"external",Ue),Y=R(_,P,"sideEffects",Ue),G=R(_,P,"pluginData",xc),X=R(_,P,"errors",He),J=R(_,P,"warnings",He),ue=R(_,P,"watchFiles",He),oe=R(_,P,"watchDirs",He);bt(_,P,from onResolve() callback in plugin ${lt(A)}),v.id=N,I!=null&&(v.pluginName=I),$!=null&&(v.path=$),j!=null&&(v.namespace=j),q!=null&&(v.suffix=q),B!=null&&(v.external=B),Y!=null&&(v.sideEffects=Y),G!=null&&(v.pluginData=c.store(G)),X!=null&&(v.errors=to(X,"errors",c,A,void 0)),J!=null&&(v.warnings=to(J,"warnings",c,A,void 0)),ue!=null&&(v.watchFiles=yc(ue,"watchFiles")),oe!=null&&(v.watchDirs=yc(oe,"watchDirs"));break}}catch(_){v={id:N,errors:[mn(_,n,c,D&&D(),A)]};break}r(b,v)},s["on-load"]=async(b,T)=>{let v={},A="",F,D;for(let N of T.ids)try{({name:A,callback:F,note:D}=f[N]);let _=await F({path:T.path,namespace:T.namespace,suffix:T.suffix,pluginData:c.load(T.pluginData),with:T.with});if(_!=null){if(typeof _!="object")throw new Error(Expected onLoad() callback in plugin ${lt(A)} to return an object);let P={},I=R(_,P,"pluginName",V),$=R(_,P,"contents",ob),j=R(_,P,"resolveDir",V),q=R(_,P,"pluginData",xc),B=R(_,P,"loader",V),Y=R(_,P,"errors",He),G=R(_,P,"warnings",He),X=R(_,P,"watchFiles",He),J=R(_,P,"watchDirs",He);bt(_,P,from onLoad() callback in plugin ${lt(A)}),v.id=N,I!=null&&(v.pluginName=I),$ instanceof Uint8Array?v.contents=$:$!=null&&(v.contents=vr($)),j!=null&&(v.resolveDir=j),q!=null&&(v.pluginData=c.store(q)),B!=null&&(v.loader=B),Y!=null&&(v.errors=to(Y,"errors",c,A,void 0)),G!=null&&(v.warnings=to(G,"warnings",c,A,void 0)),X!=null&&(v.watchFiles=yc(X,"watchFiles")),J!=null&&(v.watchDirs=yc(J,"watchDirs"));break}}catch(_){v={id:N,errors:[mn(_,n,c,D&&D(),A)]};break}r(b,v)};let w=(b,T)=>T([],[]);u.length>0&&(w=(b,T)=>{(async()=>{let v=[],A=[];for(let{name:F,callback:D,note:N}of u){let _,P;try{let I=await D(b);if(I!=null){if(typeof I!="object")throw new Error(Expected onEnd() callback in plugin ${lt(F)} to return an object);let $={},j=R(I,$,"errors",He),q=R(I,$,"warnings",He);bt(I,$,from onEnd() callback in plugin ${lt(F)}),j!=null&&(_=to(j,"errors",c,F,void 0)),q!=null&&(P=to(q,"warnings",c,F,void 0))}}catch(I){_=[mn(I,n,c,N&&N(),F)]}if(_){v.push(..._);try{b.errors.push(..._)}catch{}}if(P){A.push(...P);try{b.warnings.push(...P)}catch{}}}T(v,A)})()});let k=()=>{for(let b of m)setTimeout(()=>b(),0)};return x=!0,{ok:!0,requestPlugins:y,runOnEndCallbacks:w,scheduleOnDisposeCallbacks:k}};function ab(){let e=new Map,t=0;return{clear(){e.clear()},load(r){return e.get(r)},store(r){if(r===void 0)return-1;let o=t++;return e.set(o,r),o}}}function gc(e,t,r){let o,n=!1;return()=>{if(n)return o;n=!0;try{let s=(e.stack+"").split(
);s.splice(1,1);let i=cb(t,s,r);if(i)return o={text:e.message,location:i},o}catch{}}}function mn(e,t,r,o,n){let s="Internal error",i=null;try{s=(e&&e.message||e)+""}catch{}try{i=cb(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:n,text:s,location:i,notes:o?[o]:[],detail:r?r.store(e):-1}}function cb(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let n=1;n<t.length;n++){let s=t[n];if(s.startsWith(o))for(s=s.slice(o.length);;){let i=/^(?:new |async )?\S+ \((.*)\)$/.exec(s);if(i){s=i[1];continue}if(i=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(s),i){s=i[1];continue}if(i=/^(\S+):(\d+):(\d+)$/.exec(s),i){let a;try{a=e.readFileSync(i[1],"utf8")}catch{break}let c=a.split(/\r\n|\r|\n|\u2028|\u2029/)[+i[2]-1]||"",l=+i[3]-1,u=c.slice(l,l+r.length)===r?r.length:0;return{file:i[1],namespace:"file",line:+i[2],column:vr(c.slice(0,l)).length,length:vr(c.slice(l,l+u)).length,lineText:c+
+t.slice(1).join(
),suggestion:""}}break}}return null}function ci(e,t,r){let o=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,o+1).map((s,i)=>{if(i===o)return
...;if(!s.location)return
error: ${s.text};let{file:a,line:c,column:l}=s.location,u=s.pluginName?plugin: ${s.pluginName} :"";return
${a}:${c}:${l}: ERROR: ${u}${s.text}}).join("");let n=new Error(e);for(let[s,i]of[["errors",t],["warnings",r]])Object.defineProperty(n,s,{configurable:!0,enumerable:!0,get:()=>i,set:a=>Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:a})});return n}function Jn(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function eb(e,t,r){if(e==null)return null;let o={},n=R(e,o,"file",V),s=R(e,o,"namespace",V),i=R(e,o,"line",fn),a=R(e,o,"column",fn),c=R(e,o,"length",fn),l=R(e,o,"lineText",V),u=R(e,o,"suggestion",V);if(bt(e,o,t),l){let p=l.slice(0,(a&&a>0?a:0)+(c&&c>0?c:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(p)&&!/\n/.test(l)&&(l=p)}return{file:n||"",namespace:s||"",line:i||0,column:a||0,length:c||0,lineText:l||"",suggestion:u||""}}function to(e,t,r,o,n){let s=[],i=0;for(let a of e){let c={},l=R(a,c,"id",V),u=R(a,c,"pluginName",V),p=R(a,c,"text",V),f=R(a,c,"location",Zx),m=R(a,c,"notes",He),h=R(a,c,"detail",xc),g=in element ${i} of "${t}";bt(a,c,g);let y=[];if(m)for(let x of m){let w={},k=R(x,w,"text",V),b=R(x,w,"location",Zx);bt(x,w,g),y.push({text:k||"",location:eb(b,g,n)})}s.push({id:l||"",pluginName:u||o,text:p||"",location:eb(f,g,n),notes:y,detail:r?r.store(h):-1}),i++}return s}function yc(e,t){let r=[];for(let o of e){if(typeof o!="string")throw new Error(${lt(t)} must be an array of strings);r.push(o)}return r}function qO(e,t){let r=Object.create(null);for(let o in e){let n=e[o];if(typeof n!="string")throw new Error(key ${lt(o)} in object ${lt(t)} must be a string);r[o]=n}return r}function GO({path:e,contents:t,hash:r}){let o=null;return{path:e,contents:t,hash:r,get text(){let n=this.contents;return(o===null||n!==t)&&(t=n,o=Xn(n)),o}}}var pb=ai,Rc=e=>kc().build(e),ub=(e,t)=>kc().transform(e,t),mb=(e,t)=>kc().formatMessages(e,t),fb=(e,t)=>kc().analyzeMetafile(e,t);var dn,lb,wc,kc=()=>{if(wc)return wc;throw dn?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},vc=e=>{let t=e.wasm,r=e.worker;if(dn)throw new Error('Cannot call "initialize" more than once');return dn=zO(t,r),dn.catch(()=>{dn=void 0}),dn},zO=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),o,n,s=new Promise((c,l)=>{o=c,n=l});r.onmessage=({data:c})=>{r.onmessage=({data:l})=>i(l),c?n(c):o()},r.postMessage(e);let{readFromStdout:i,service:a}=ib({writeToStdin(c){r.postMessage(c)},isSync:!1,hasFS:!1,esbuild:{build:Rc,transform:ub,formatMessages:mb,analyzeMetafile:fb,version:pb,initialize:vc}});await s,lb=()=>{r.terminate(),dn=void 0,lb=void 0,wc=void 0},wc={build:c=>new Promise((l,u)=>a.buildOrContext({callName:"build",refs:null,options:c,isTTY:!1,defaultWD:"/",callback:(p,f)=>p?u(p):l(f)})),transform:(c,l)=>new Promise((u,p)=>a.transform({callName:"transform",refs:null,input:c,options:l||{},isTTY:!1,fs:{readFile(f,m){m(new Error("Internal error"),null)},writeFile(f,m){m(null)}},callback:(f,m)=>f?p(f):u(m)})),formatMessages:(c,l)=>new Promise((u,p)=>a.formatMessages({callName:"formatMessages",refs:null,messages:c,options:l,callback:(f,m)=>f?p(f):u(m)})),analyzeMetafile:(c,l)=>new Promise((u,p)=>a.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof c=="string"?c:JSON.stringify(c),options:l,callback:(f,m)=>f?p(f):u(m)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function db(){let e=globalThis,t=e.Deno?.build?.os;return typeof t=="string"?t==="windows":e.navigator?.platform?.startsWith("Win")??e.process?.platform?.startsWith("win")??!1}var pt=db();function Ot(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function mm(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let o=t.length-1;o>=0;--o)if(e.charCodeAt(r+o)!==t.charCodeAt(o))return e;return e.slice(0,-t.length)}function fm(e,t,r=0){let o=!1,n=e.length;for(let s=e.length-1;s>=r;--s)if(t(e.charCodeAt(s))){if(o){r=s+1;break}}else o||(o=!0,n=s+1);return e.slice(r,n)}function dm(e,t){if(Ot(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function Tc(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError(URL must be a file URL: received "${e.protocol}");return e}function ro(e){return e=Tc(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Qn(e,t){if(e.length<=1)return e;let r=e.length;for(let o=e.length-1;o>0&&t(e.charCodeAt(o));o--)r=o;return e.slice(0,r)}function mr(e){return e===47}function hm(e,t=""){e instanceof URL&&(e=ro(e)),dm(e,t);let r=fm(e,mr),o=Qn(r,mr);return t?mm(o,t):o}function Ar(e){return e===47||e===92}function oo(e){return e>=97&&e<=122||e>=65&&e<=90}function hn(e){e=Tc(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}var li=pt?"\\":"/";function ym(e){e instanceof URL&&(e=ro(e)),Ot(e);let t=-1,r=0,o=-1,n=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(mr(a)){if(!n){r=i+1;break}continue}o===-1&&(n=!1,o=i+1),a===46?t===-1?t=i:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||o===-1||s===0||s===1&&t===o-1&&t===r+1?"":e.slice(t,o)}function es(e){return pt?hn(e):ro(e)}function xm(e){return Ot(e),e.length>0&&mr(e.charCodeAt(0))}function bm(e){Ot(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return Ar(r)?!0:!!(oo(r)&&t>2&&e.charCodeAt(1)===58&&Ar(e.charCodeAt(2)))}var sS={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Pc(e){return e.replaceAll(/[\s]/g,t=>sS[t]??t)}function xb(e){if(!xm(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=Pc(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function bb(e){if(!bm(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),o=new URL("file:///");if(o.pathname=Pc(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(o.hostname=t,!o.hostname))throw new TypeError(Invalid hostname: "${o.hostname}");return o}function gn(e){return pt?bb(e):xb(e)}function Oc(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Sc(e){let t={},r=Object.keys(e).sort((o,n)=>n.length-o.length);for(let o of r)t[o]=e[o];return t}function Eb(e){return Oc(e)&&(e.imports!==void 0?wm(e.imports):!0)&&(e.scopes!==void 0?Rm(e.scopes):!0)}function wm(e){return Oc(e)}function Rm(e){return Oc(e)&&Object.values(e).every(t=>km(t))}function km(e){return Oc(e)}function Lc(e){try{return new URL(e),!0}catch{return!1}}function Rb(e,t){let r={};for(let[o,n]of Object.entries(e)){let s=pS(o,t);if(s===null)continue;if(typeof n!="string"){console.warn("addresses need to be strings."),r[s]=null;continue}let i=vm(n,t);if(i===null){console.warn("the address was invalid."),r[s]=null;continue}if(o.endsWith("/")&&!Fr(i).endsWith("/")){console.warn("an invalid address was given for the specifier key specifierKey; since specifierKey ended in a slash, the address needs to as well."),r[s]=null;continue}r[s]=Fr(i)}return Sc(r)}function Fr(e){return e.href}function lS(e,t){let r={};for(let[n,s]of Object.entries(e)){if(!km(s))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let i;try{i=new URL(n,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let a=Fr(i);r[a]=Rb(s,t)}let o={};for(let n of Object.keys(r))o[n]=Sc(r[n]);return Sc(o)}function pS(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=vm(e,t);return r!==null?Fr(r):e}function vm(e,t){if(t&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")))try{return new URL(e,t)}catch{return null}try{return new URL(e)}catch{return null}}var uS=["ftp","file","http","https","ws","wss"];function mS(e){return uS.some(t=>Fr(e).startsWith(t))}function wb(e,t,r){for(let[o,n]of Object.entries(r))if(o===e){if(n===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Lc(n))throw new TypeError("resolutionResult must be an URL.");return n}else if(o.endsWith("/")&&e.startsWith(o)&&(t===null||mS(t))){if(n===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Lc(n))throw new TypeError("resolutionResult must be an URL.");let s=e.slice(o.length);if(!n.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let i=new URL(s,n);if(!Lc(i))throw new TypeError("url must be an URL.");if(!Fr(i).startsWith(n))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return Fr(i)}catch{throw new TypeError("resolution of normalizedSpecifier was blocked since the afterPrefix portion could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.")}}return null}function Tm(e,t){let r={};if(!Eb(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:o,scopes:n}=e;if(o!==void 0){if(!wm(o))throw new TypeError('"imports" top-level key needs to be an object.');r=Rb(o,t)}let s={};if(n!==void 0){if(!Rm(n))throw new TypeError('"scopes" top-level key needs to be an object.');s=lS(n,t)}return Object.keys(e).find(i=>i!=="imports"&&i!=="scopes")&&console.warn("an invalid top-level key was present in the import map."),{imports:r,scopes:s}}function kb(e,{imports:t={},scopes:r={}},o){let n=Fr(o),s=vm(e,o),i=s!==null?Fr(s):e;for(let[c,l]of Object.entries(r))if(c===n||c.endsWith("/")&&n.startsWith(c)){let u=wb(i,s,l);if(u!==null)return u}let a=wb(i,s,t);if(a!==null)return a;if(s!==null)return Fr(s);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}var Nc=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function _m(e,t=""){if(!e)throw new Nc(t)}function Tb(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new Pm(e,{allowTrailingComma:t}).parse()}var vb=globalThis.JSON.parse,Pm=class{#o=new Set( \r
);#r=new Set([..."[]{}:,/",...this.#o]);#t;#e;#i;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#i=this.#m(),this.#a=r}parse(){let t=this.#s(),r=this.#p(t),{done:o,value:n}=this.#i.next();if(!o)throw new SyntaxError(Lo(n));return r}#s(){let{done:t,value:r}=this.#i.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#m(){for(let t=0;t<this.#e;t++)if(!this.#o.has(this.#t[t])){if(this.#t[t]==="/"&&this.#t[t+1]==="*"){t+=2;let r=!1;for(;t<this.#e;t++)if(this.#t[t]==="*"&&this.#t[t+1]==="/"){r=!0;break}if(!r)throw new SyntaxError("Unexpected end of JSONC input");t++;continue}if(this.#t[t]==="/"&&this.#t[t+1]==="/"){for(t+=2;t<this.#e&&!(this.#t[t]===
||this.#t[t]==="\r");t++);continue}switch(this.#t[t]){case"{":yield{type:"BeginObject",position:t};break;case"}":yield{type:"EndObject",position:t};break;case"[":yield{type:"BeginArray",position:t};break;case"]":yield{type:"EndArray",position:t};break;case":":yield{type:"NameSeparator",position:t};break;case",":yield{type:"ValueSeparator",position:t};break;case'"':{let r=t,o=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!o);t++)o=this.#t[t]==="\\"&&!o;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#r.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#p(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#n();case"NullOrTrueOrFalseOrNumber":return this.#g(t);case"String":return this.#h(t);default:throw new SyntaxError(Lo(t))}}#f(){let t={};for(let r=!0;;r=!1){let o=this.#s();if((r||this.#a.allowTrailingComma)&&o.type==="EndObject")return t;if(o.type!=="String")throw new SyntaxError(Lo(o));let n=this.#h(o),s=this.#s();if(s.type!=="NameSeparator")throw new SyntaxError(Lo(s));let i=this.#s();Object.defineProperty(t,n,{value:this.#p(i),writable:!0,enumerable:!0,configurable:!0});let a=this.#s();if(a.type==="EndObject")return t;if(a.type!=="ValueSeparator")throw new SyntaxError(Lo(a))}}#n(){let t=[];for(let r=!0;;r=!1){let o=this.#s();if((r||this.#a.allowTrailingComma)&&o.type==="EndArray")return t;t.push(this.#p(o));let n=this.#s();if(n.type==="EndArray")return t;if(n.type!=="ValueSeparator")throw new SyntaxError(Lo(n))}}#h(t){let r;try{r=vb(t.sourceText)}catch{throw new SyntaxError(Lo(t))}return _m(typeof r=="string"),r}#g(t){if(t.sourceText==="null")return null;if(t.sourceText==="true")return!0;if(t.sourceText==="false")return!1;let r;try{r=vb(t.sourceText)}catch{throw new SyntaxError(Lo(t))}return _m(typeof r=="number"),r}};function Lo({type:e,sourceText:t,position:r}){let o="";switch(e){case"BeginObject":o="{";break;case"EndObject":o="}";break;case"BeginArray":o="[";break;case"EndArray":o="]";break;case"NameSeparator":o=":";break;case"ValueSeparator":o=",";break;case"NullOrTrueOrFalseOrNumber":case"String":o=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${o} in JSONC at position ${r}}function Cc(e){if(e.protocol==="file:")return{path:es(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function Om(e){let t=await Deno.readTextFile(e),r=Tb(t);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(Deno config at ${e} must be an object);if("imports"in r&&(typeof r.imports!="object"||r.imports===null||Array.isArray(r.imports)))throw new Error(Deno config at ${e} has invalid "imports" key);if("scopes"in r&&(typeof r.scopes!="object"||r.scopes===null||Array.isArray(r.scopes)))throw new Error(Deno config at ${e} has invalid "scopes" key);if("lock"in r&&typeof r.lock!="boolean"&&typeof r.lock!="string")throw new Error(Deno config at ${e} has invalid "lock" key);if("importMap"in r&&typeof r.importMap!="string")throw new Error(Deno config at ${e} has invalid "importMap" key);return r}function _b(e){if(e.imports!==void 0){let t=[];for(let[r,o]of Object.entries(e.imports))if(t.push([r,o]),!r.endsWith("/")&&o&&(o.startsWith("jsr:")||o.startsWith("npm:"))&&!e.imports[r+"/"]){let n=r+"/",s=o.slice(0,4)+"/"+o.slice(o[4]==="/"?5:4)+"/";t.push([n,s])}e.imports=Object.fromEntries(t)}}var dS=${li}node_modules${li},hS=${li}node_modules;function Mc(e){return e.includes(dS)||e.endsWith(hS)}function Sm(e){return(e.namespace===""||e.namespace==="file")&&(Mc(e.resolveDir)||Mc(e.path)||Mc(e.importer))}function Lm(e={}){return{name:"deno-resolver",setup(t){let r=null,o=(t.initialOptions.external??[]).map(n=>new RegExp("^"+n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let s;if(e.importMapURL===void 0&&e.configPath!==void 0){let i=await Om(e.configPath);if(i.imports!==void 0||i.scopes!==void 0){let a={imports:i.imports,scopes:i.scopes};_b(a),r=Tm(a,gn(e.configPath))}else i.importMap!==void 0&&(s=new URL(i.importMap,gn(e.configPath)).href)}else e.importMapURL!==void 0&&(s=e.importMapURL);if(s){let i=await fetch(s),a=await i.json();r=Tm(a,new URL(i.url))}}),t.onResolve({filter:/.*/},async function(s){if(Sm(s))return;let i;if(s.importer!==""){if(s.namespace==="")throw new Error("[assert] namespace is empty");i=new URL(${s.namespace}:${s.importer})}else if(s.resolveDir!=="")i=new URL(${gn(s.resolveDir).href}/);else return;let a;if(r!==null){let p=kb(s.path,r,new URL(i));a=new URL(p)}else a=new URL(s.path,i);for(let p of o)if(p.test(a.href))return{path:a.href,external:!0};let{path:c,namespace:l}=Cc(a);return await t.resolve(c,{namespace:l,kind:s.kind})})}}}var _ge=new TextEncoder;var gS=[],yS=[],Nm="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=Nm.length;e<t;++e)gS[e]=Nm[e],yS[Nm.charCodeAt(e)]=e;var Vge=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var TS=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var Pb=Lm;var Ob=e=>!!(_S.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),_S=["i.gyazo.com","t.gyazo.com","scrapbox.io","api.openai.com","*.openai.azure.com","maps.googleapis.com","upload.gyazo.com","storage.googleapis.com","sentry.io"];var Sb=e=>{if(e.protocol==="file:")return{path:es(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},Mm=e=>e.namespace==="file"?gn(e.path):new URL(${e.namespace}:${e.path});var Lb=(e,t)=>{let r=Is(PS(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(O(r))return r;let{url:o,start:n,end:s}=S(r);return URL.canParse(o,t)?L({url:new URL(o,t),start:n,end:s}):M({name:"InvalidURLError",message:Invalid URL: ${o}})},PS=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,o=e.length,n=r;for(;n<o&&e.charCodeAt(n)>32;)n++;if(n!==r&&(t[1]==="/"||e.indexOf("*/",n)>0))return{url:e.slice(r,n),start:r,end:n}}};var OS=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],Nb=e=>OS.includes(e),Mb=e=>/^js|^ts|css$/.test(e),Cb=e=>{let t=e.url,r=hm(t);if(Nb(r))return r;if(r==="mjs")return"js";let o=new URL(t);o.search="",o.hash="";let n=ym(o.href).slice(1);if(Nb(n))return n;if(n==="mjs")return"js";let i=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return SS(i)},SS=e=>{let t=e.split("/")[1]??"plain";if(/(?:^plain$|^xml|^svg|^x?html)/.test(t))return"text";if(t.startsWith("json"))return"json";switch(t){case"javascript":return"js";case"typescript":return"ts";case"css":return"css";default:return"text"}};function Ic(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function Fb(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Im(e=[],t=[]){let r=Math.max(e.length,t.length);for(let o=0;o<r;o++){let n=e[o],s=t[o];if(n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(typeof n=="string"&&typeof s=="number")return 1;if(typeof n=="number"&&typeof s=="string"||n<s)return-1;if(n>s)return 1}return 0}var ts="0|[1-9]\\d*",LS="\\d*[a-zA-Z-][a-zA-Z0-9-]*",NS=(?<major>${ts})\\.(?<minor>${ts})\\.(?<patch>${ts}),Ib=(?:${ts}|${LS}),Db=(?:-(?<prerelease>${Ib}(?:\\.${Ib})*)),Ab="[0-9A-Za-z-]+",Ub=(?:\\+(?<buildmetadata>${Ab}(?:\\.${Ab})*)),$b=v?${NS}${Db}?${Ub}?,jb=new RegExp(^${$b}$),Bb="(?:<|>)?=?",MS="x|X|\\*",Cm=${ts}|${MS},Ac=v=\\s*(?<major>${Cm})(?:\\.(?<minor>${Cm})(?:\\.(?<patch>${Cm})${Db}?${Ub}?)?)?,Hb=new RegExp(^(?<operator>~>?|\\^|${Bb})\\s*${Ac}$),Wb=new RegExp(^(?<operator>${Bb})\\s*(${$b})$|^$);function Am(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var Fm=256;var CS=new RegExp(^${ts}$);function Vt(e){return e.split(".").filter(Boolean).map(t=>{if(CS.test(t)){let r=Number(t);if(Am(r))return r}return t})}function Dr(e){return e.split(".").filter(Boolean)}function No(e,t){let r=Number(e);if(!Am(r))throw new TypeError(t);return r}function yn(e){return Number.isNaN(e.major)&&Number.isNaN(e.minor)&&Number.isNaN(e.patch)&&(e.prerelease===void 0||e.prerelease.length===0)&&(e.build===void 0||e.build.length===0)}function fr(e,t){return e===t?0:Ic(e.major,t.major)||Ic(e.minor,t.minor)||Ic(e.patch,t.patch)||Fb(e.prerelease,t.prerelease)||Im(e.prerelease,t.prerelease)}function Dm(e){return e.toFixed(0)}function xn(e){let t=Dm(e.major),r=Dm(e.minor),o=Dm(e.patch),n=e.prerelease?.join(".")??"",s=e.build?.join(".")??"";return[[${t}.${r}.${o},n].filter(c=>c).join("-"),s].filter(c=>c).join("+")}function IS(e,t){if(yn(t))return!0;let r=fr(e,t);switch(t.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function Fc(e,t){for(let r of t)if(!IS(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(yn(r))continue;let{major:o,minor:n,patch:s,prerelease:i}=r;if(i&&i.length>0&&e.major===o&&e.minor===n&&e.patch===s)return!0}return!1}return!0}function Dc(e,t){return t.some(r=>Fc(e,r))}var Uc={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},rs={operator:void 0,...Uc};function qb(e,t){return fr(e,t)>0}function pi(e,t){let r;for(let o of e)Dc(o,t)&&(r=r&&qb(r,o)?r:o);return r}function AS(e){let r=e.match(Wb)?.groups;if(!r)return null;let{operator:o,prerelease:n,buildmetadata:s}=r,i=r.major?{major:No(r.major,Cannot parse comparator ${e}: invalid major version),minor:No(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:No(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:n?Vt(n):[],build:s?Dr(s):[]}:Uc;return{operator:o||void 0,...i}}function Oe(e){return!e||e.toLowerCase()==="x"||e==="*"}function FS(e){if(!Oe(e.major))return Oe(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:Oe(e.patch)?{operator:">=",major:+e.major,minor:+e.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?Vt(e.prerelease):[],build:[]}}function DS(e){if(!Oe(e.major))return Oe(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:Oe(e.patch)?{operator:"<",major:+e.major,minor:+e.minor+1,patch:0,prerelease:[],build:[]}:e.prerelease?{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:Vt(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:[],build:[]}}function US(e){let t=e.match(new RegExp(^${Ac})),r=t?.groups;if(!r)return null;let o=t[0].length,n=e.slice(o).match(/^\s+-\s+/);if(!n)return null;let s=n[0].length,a=e.slice(o+s).match(new RegExp(^${Ac}\\s*$))?.groups;if(!a)return null;let c=FS(r),l=DS(a);return[c,l].filter(Boolean)}function $S(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[rs];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return n===0?[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}]:[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];let a=Vt(e.prerelease??"");return n===0?s===0?[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s,patch:i+1}]:[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s+1,patch:0}]:[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n+1,minor:0,patch:0}]}function jS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[rs];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??"");return[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s+1,patch:0}]}function BS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return o?[{operator:"<",major:n,minor:0,patch:0}]:[{operator:"<",major:n,minor:0,patch:0}];if(o)return[{operator:"<",major:n,minor:s,patch:0}];let a=Vt(e.prerelease??""),c=Dr(e.build??"");return[{operator:"<",major:n,minor:s,patch:i,prerelease:a,build:c}]}function HS(e){let t=Oe(e.minor),r=Oe(e.patch),o=+e.major,n=+e.minor,s=+e.patch;if(t)return r?[{operator:"<",major:o+1,minor:0,patch:0}]:[{operator:"<",major:o,minor:n+1,patch:0}];if(r)return[{operator:"<",major:o,minor:n+1,patch:0}];let i=Vt(e.prerelease??""),a=Dr(e.build??"");return[{operator:"<=",major:o,minor:n,patch:s,prerelease:i,build:a}]}function WS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??""),c=Dr(e.build??"");return[{operator:">",major:n,minor:s,patch:i,prerelease:a,build:c}]}function qS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[rs];if(r)return o?[{operator:">=",major:n,minor:0,patch:0}]:[{operator:">=",major:n,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0}];let a=Vt(e.prerelease??""),c=Dr(e.build??"");return[{operator:">=",major:n,minor:s,patch:i,prerelease:a,build:c}]}function GS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[rs];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??""),c=Dr(e.build??"");return[{operator:void 0,major:n,minor:s,patch:i,prerelease:a,build:c}]}function zS(e){let t=e.match(Hb)?.groups;if(!t)return AS(e);switch(t.operator){case"^":return $S(t);case"~":case"~>":return jS(t);case"<":return BS(t);case"<=":return HS(t);case">":return WS(t);case">=":return qS(t);case"=":case"":return GS(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function VS(e){return e.split(/\s+/).flatMap(zS)}function Gb(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>US(r)||VS(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Um(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>Fm)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${Fm});e=e.trim();let t=e.match(jb)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=No(t.major,Cannot parse version ${e}: invalid major version),o=No(t.minor,Cannot parse version ${e}: invalid minor version),n=No(t.patch,Cannot parse version ${e}: invalid patch version),s=t.prerelease?Vt(t.prerelease):[],i=t.buildmetadata?Dr(t.buildmetadata):[];return{major:r,minor:o,patch:n,prerelease:s,build:i}}function $m(e){try{return Gb(e)}catch{return}}function jm(e){try{return Um(e)}catch{return}}var ui={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var Mo=async e=>{try{let t=await fetch(e);return t.ok?L([t,!1]):M({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return M({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return M({name:"AbortError",message:t.message,request:e});throw t}};var Bm="https://jsr.io",zb=async(e,t)=>{let r=await(t?.fetch??Mo)(new Request(${t?.endpoint??Bm}/${e}/meta.json),t?.cacheFirst);return ie(r,([o])=>o.json())};var Vb=async(e,t,r)=>{let o=await(r?.fetch??Mo)(new Request(${r?.endpoint??Bm}/${e}/${t}_meta.json),r?.cacheFirst);return ie(o,([n])=>n.json())};var Kb=async(e,t)=>{let r=await(t?.fetch??Mo)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return ie(r,([o])=>o.json())};var Jb=(e,t)=>({name:"InvalidPackageVersionError",message:No version of ${e.name} satisfies "${e.tag??"*"}" (available: ${t.slice(0,10).join(", ")}${t.length>10?, ... (${t.length-10} more versions):""}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableVersions:t}),$c=(e,t)=>({name:"InvalidEntryPointError",message:${e.entryPoint} is not a valid entry point for ${e.name}@${e.tag??"*"} (available: ${t.join(", ")}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableEntryPoints:t}),Qb=async(e,t)=>{if(t?.resolvedVersions){let c=new Map(t.resolvedVersions.get(e.name)??[]),l=pi([...c.keys()],e.range);if(l){let u=c.get(l)??mi,p=u[e.entryPoint];return typeof p!="string"&&console.log(p),p?L(Yb(e.name,xn(l),p)):M($c(e,Object.keys(u)))}}let r=await Kb(e.name,t);if(O(r))return r;let o=S(r),n=new Map(Object.entries(o.versions).flatMap(([c,{exports:l}])=>{let u=jm(c);return u?[[u,l??mi]]:[]})),s=pi([...n.keys()],e.range);if(!s)return M(Jb(e,Object.keys(o.versions)));let i={...mi};for(let c of Object.keys(n.get(s)??mi))i[c]=c;let a=i[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[s,i]]),L(Yb(e.name,xn(s),a))):M($c(e,Object.keys(i)))},Yb=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),Zb=async(e,t)=>{if(t?.resolvedVersions){let a=new Map(t.resolvedVersions.get(e.name)??[]),c=pi([...a.keys()],e.range);if(c){let l=a.get(c)??mi,u=l[e.entryPoint];return u?L(Xb(e.name,xn(c),u)):M($c(e,Object.keys(l)))}}let r=await KS(e,t);if(O(r))return r;let o=S(r),n=await Vb(e.name,xn(o),t);if(O(n))return n;let s=S(n).exports,i=s[e.entryPoint];return i?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[o,s]]),L(Xb(e.name,xn(o),i))):M($c(e,Object.keys(S(n).exports)))},Xb=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),KS=async(e,t)=>{let r=await zb(e.name,t);if(O(r))return r;let o=S(r),n=Object.keys(o.versions).flatMap(i=>{let a=jm(i);return a?[a]:[]}),s=pi(n,e.range);return s?L(s):M(Jb(e,Object.keys(o.versions)))},mi={".":"./"};var YS=e=>({name:"OnlyScopeProvidedError",specifier:e}),eE=e=>({name:"PackageNotFoundError",specifier:e}),tE=e=>{if(e.protocol!=="npm:")return M({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,o,n;if(t[r]==="@"){let p=t.indexOf("/",r);if(p===-1)return M(YS(e));o=t.indexOf("/",p+1),n=t.indexOf("@",p+1)}else o=t.indexOf("/",r),n=t.indexOf("@",r);if(o===-1&&(o=t.length),n===-1&&(n=t.length),n=Math.min(n,o),r===n)return M(eE(e));let s=t.slice(r,n),i=decodeURIComponent(t.slice(n+1,o)),a=i?$m(i)??[[ui]]:[[ui]],c=t.slice(o+1),l=c?./${c}:".",u={name:s,range:a,entryPoint:l};return i&&(u.tag=i),L(u)},rE=e=>{if(e.protocol!=="jsr:")return M({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return M({name:"ScopeNotFoundError",specifier:e});let o=t.indexOf("/",r);if(o===-1)return M(eE(e));let n=t.indexOf("/",o+1),s=t.indexOf("@",o+1);n===-1&&(n=t.length),s===-1&&(s=t.length),s=Math.min(s,n);let i=t.slice(r,s),a=decodeURIComponent(t.slice(s+1,n)),c=a?$m(a)??[[ui]]:[[ui]],l=t.slice(n+1),u=l?./${l}:".",p={name:i,range:c,entryPoint:u};return a&&(p.tag=a),L(p)};var oE=e=>new Promise((t,r)=>{let o=new FileReader;o.addEventListener("load",()=>{let n=o.result,s=n.indexOf(";");n.startsWith("; charset=utf-8",s)?t(${n.slice(0,s)}${n.slice(s+15)}):t(n)}),o.addEventListener("error",()=>r(o.error)),o.readAsDataURL(e)});var iE=e=>{let t=new Map,r=async o=>{let n=o.namespace==="npm",s=(n?tE:rE)(Mm(o));if(O(s)){let a=Z(s);return{errors:[{text:a.name,detail:a}]}}let i=await(n?Qb:Zb)(S(s),{resolvedVersions:t,...e});if(O(i)){let a=Z(i);return{errors:[{text:${a.name} ${a.message},detail:a}]}}return Sb(S(i))};return{name:"remote-loader",setup({onLoad:o,onResolve:n,initialOptions:s}){for(let i of[...nE,...sE])n({filter:/.*/,namespace:i.slice(0,-1)},XS);n({filter:/.*/,namespace:"npm"},r),n({filter:/.*/,namespace:"jsr"},r);for(let i of nE)o({filter:/.*/,namespace:i.slice(0,-1)},a=>JS(Mm(a),{...e,sourcemap:s.sourcemap!==!1&&s.sourcemap!==void 0}));for(let i of sE)o({filter:/.*/,namespace:i.slice(0,-1)},()=>{throw new Error(${i} import is not supported yet.)})}}},XS=e=>({path:e.path,namespace:e.namespace}),nE=["http:","https:","data:"],sE=["node:"],JS=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(l=>l.test(e)):!0,o=t.fetch??Mo,n=await o(new Request(e),r);if(O(n))return{errors:[{text:${Z(n).message} Failed to fetch ${e},detail:Z(n)}]};let[s,i]=S(n),a=Cb(s);t.onProgress?.({path:e,done:s.clone().blob().then(l=>({size:l.size,loader:a,isCache:i}))});let c=await s.blob();if(t.sourcemap&&Mb(a)){let l=await c.text(),u=Lb(l,e);if(K(u)){let{url:p,start:f,end:m}=S(u);if(p.protocol!=="data:"){let h=await o(new Request(p),r);if(O(h))return{contents:l,loader:a,warnings:[{text:${Z(h).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${p}},{text:Original URL: ${e}}],detail:Z(h)}]};let g=await S(h)[0].blob().then(oE);return{contents:l.slice(0,f)+g+l.slice(m),loader:a}}}}return{contents:new Uint8Array(await c.arrayBuffer()),loader:a}};var hi=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,o,n,s){this.type=e,this.name=t,this.prefix=r,this.value=o,this.suffix=n,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},QS=/[$_\p{ID_Start}]/u,ZS=/[$_\u200C\u200D\p{ID_Continue}]/u,Wm=".*";function eL(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function lE(e,t=!1){let r=[],o=0;for(;o<e.length;){let n=e[o],s=function(i){if(!t)throw new TypeError(i);r.push({type:"INVALID_CHAR",index:o,value:e[o++]})};if(n==="*"){r.push({type:"ASTERISK",index:o,value:e[o++]});continue}if(n==="+"||n==="?"){r.push({type:"OTHER_MODIFIER",index:o,value:e[o++]});continue}if(n==="\\"){r.push({type:"ESCAPED_CHAR",index:o++,value:e[o++]});continue}if(n==="{"){r.push({type:"OPEN",index:o,value:e[o++]});continue}if(n==="}"){r.push({type:"CLOSE",index:o,value:e[o++]});continue}if(n===":"){let i="",a=o+1;for(;a<e.length;){let c=e.substr(a,1);if(a===o+1&&QS.test(c)||a!==o+1&&ZS.test(c)){i+=e[a++];continue}break}if(!i){s(Missing parameter name at ${o});continue}r.push({type:"NAME",index:o,value:i}),o=a;continue}if(n==="("){let i=1,a="",c=o+1,l=!1;if(e[c]==="?"){s(Pattern cannot start with "?" at ${c});continue}for(;c<e.length;){if(!eL(e[c],!1)){s(Invalid character '${ec}' at ${c}.),l=!0;break}if(e[c]==="\\"){a+=e[c++]+e[c++];continue}if(e[c]===")"){if(i--,i===0){c++;break}}else if(e[c]==="("&&(i++,e[c+1]!=="?")){s(Capturing groups are not allowed at ${c}),l=!0;break}a+=e[c++]}if(l)continue;if(i){s(Unbalanced pattern at ${o});continue}if(!a){s(Missing pattern at ${o});continue}r.push({type:"REGEX",index:o,value:a}),o=c;continue}r.push({type:"CHAR",index:o,value:e[o++]})}return r.push({type:"END",index:o,value:""}),r}function pE(e,t={}){let r=lE(e);t.delimiter??="/#?",t.prefixes??="./";let o=^${dr(t.delimiter)}+?,n=[],s=0,i=0,a="",c=new Set,l=k=>{if(i<r.length&&r[i].type===k)return r[i++].value},u=()=>l("OTHER_MODIFIER")??l("ASTERISK"),p=k=>{let b=l(k);if(b!==void 0)return b;let{type:T,index:v}=r[i];throw new TypeError(Unexpected ${T} at ${v}, expected ${k})},f=()=>{let k="",b;for(;b=l("CHAR")??l("ESCAPED_CHAR");)k+=b;return k},m=k=>k,h=t.encodePart||m,g="",y=k=>{g+=k},x=()=>{g.length&&(n.push(new hi(3,"","",h(g),"",3)),g="")},w=(k,b,T,v,A)=>{let F=3;switch(A){case"?":F=1;break;case"*":F=0;break;case"+":F=2;break}if(!b&&!T&&F===3){y(k);return}if(x(),!b&&!T){if(!k)return;n.push(new hi(3,"","",h(k),"",F));return}let D;T?T==="*"?D=Wm:D=T:D=o;let N=2;D===o?(N=1,D=""):D===Wm&&(N=0,D="");let _;if(b?_=b:T&&(_=s++),c.has(_))throw new TypeError(Duplicate name '${_}'.);c.add(_),n.push(new hi(N,_,h(k),D,h(v),F))};for(;i<r.length;){let k=l("CHAR"),b=l("NAME"),T=l("REGEX");if(!b&&!T&&(T=l("ASTERISK")),b||T){let A=k??"";t.prefixes.indexOf(A)===-1&&(y(A),A=""),x();let F=u();w(A,b,T,"",F);continue}let v=k??l("ESCAPED_CHAR");if(v){y(v);continue}if(l("OPEN")){let A=f(),F=l("NAME"),D=l("REGEX");!F&&!D&&(D=l("ASTERISK"));let N=f();p("CLOSE");let _=u();w(A,F,D,N,_);continue}x(),p("END")}return n}function dr(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function aE(e){return e&&e.ignoreCase?"ui":"u"}function tL(e,t,r){return uE(pE(e,r),t,r)}function os(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function uE(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let o=r.start?"^":"";for(let a of e){if(a.type===3){a.modifier===3?o+=dr(a.value):o+=(?:${dr(a.value)})${os(a.modifier)};continue}t&&t.push(a.name);let c=^${dr(r.delimiter)}+?,l=a.value;if(a.type===1?l=c:a.type===0&&(l=Wm),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?o+=(${l})${os(a.modifier)}:o+=((?:${l})${os(a.modifier)});continue}if(a.modifier===3||a.modifier===1){o+=(?:${dr(a.prefix)}(${l})${dr(a.suffix)}),o+=os(a.modifier);continue}o+=(?:${dr(a.prefix)},o+=((?:${l})(?:,o+=dr(a.suffix),o+=dr(a.prefix),o+=(?:${l}))*)${dr(a.suffix)}),a.modifier===0&&(o+="?")}let n=${dr(r.endsWith)}|$,s=${dr(r.delimiter)};if(r.end)return r.strict||(o+=${s}?),r.endsWith.length?o+=(?=${n}):o+="$",new RegExp(o,aE(r));r.strict||(o+=(?:${s}(?=${n}))?);let i=!1;if(e.length){let a=e[e.length-1];a.type===3&&a.modifier===3&&(i=r.delimiter.indexOf(a)>-1)}return i||(o+=(?=${s}|${n})),new RegExp(o,aE(r))}var Io={delimiter:"",prefixes:"",sensitive:!0,strict:!0},rL={delimiter:".",prefixes:"",sensitive:!0,strict:!0},oL={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function nL(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function mE(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function sL(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function fE(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var dE=["ftp","file","http","https","ws","wss"];function hE(e){if(!e)return!0;for(let t of dE)if(e.test(t))return!0;return!1}function iL(e,t){if(e=mE(e,"#"),t||e==="")return e;let r=new URL("https://example.com");return r.hash=e,r.hash?r.hash.substring(1,r.hash.length):""}function aL(e,t){if(e=mE(e,"?"),t||e==="")return e;let r=new URL("https://example.com");return r.search=e,r.search?r.search.substring(1,r.search.length):""}function cL(e,t){return t||e===""?e:fE(e)?xE(e):yE(e)}function lL(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function pL(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function uL(e,t,r){if(r||e==="")return e;if(t&&!dE.includes(t))return new URL(${t}:${e}).pathname;let o=e[0]=="/";return e=new URL(o?e:"/-"+e,"https://example.com").pathname,o||(e=e.substring(2,e.length)),e}function mL(e,t,r){return gE(t)===e&&(e=""),r||e===""?e:bE(e)}function fL(e,t){return e=sL(e,":"),t||e===""?e:qm(e)}function gE(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function qm(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function dL(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function hL(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function yE(e){if(e==="")return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw new TypeError(Invalid hostname '${e}');let t=new URL("https://example.com");return t.hostname=e,t.hostname}function xE(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function bE(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function gL(e){if(e==="")return e;let t=new URL("https://example.com");return t.pathname=e[0]!=="/"?"/-"+e:e,e[0]!=="/"?t.pathname.substring(2,t.pathname.length):t.pathname}function yL(e){return e===""?e:new URL(data:${e}).pathname}function xL(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function bL(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var EL=class{#o;#r=[];#t={};#e=0;#i=1;#a=0;#s=0;#m=0;#p=0;#f=!1;constructor(e){this.#o=e}get result(){return this.#t}parse(){for(this.#r=lE(this.#o,!0);this.#e<this.#r.length;this.#e+=this.#i){if(this.#i=1,this.#r[this.#e].type==="END"){if(this.#s===0){this.#g(),this.#u()?this.#n(9,1):this.#d()?this.#n(8,1):this.#n(7,0);continue}else if(this.#s===2){this.#y(5);continue}this.#n(10,0);break}if(this.#m>0)if(this.#_())this.#m-=1;else continue;if(this.#T()){this.#m+=1;continue}switch(this.#s){case 0:this.#w()&&this.#y(1);break;case 1:if(this.#w()){this.#S();let e=7,t=1;this.#R()?(e=2,t=3):this.#f&&(e=2),this.#n(e,t)}break;case 2:this.#b()?this.#y(3):(this.#E()||this.#d()||this.#u())&&this.#y(5);break;case 3:this.#k()?this.#n(4,1):this.#b()&&this.#n(5,1);break;case 4:this.#b()&&this.#n(5,1);break;case 5:this.#P()?this.#p+=1:this.#O()&&(this.#p-=1),this.#v()&&!this.#p?this.#n(6,1):this.#E()?this.#n(7,0):this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 6:this.#E()?this.#n(7,0):this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 7:this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 8:this.#u()&&this.#n(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#n(e,t){switch(this.#s){case 0:break;case 1:this.#t.protocol=this.#l();break;case 2:break;case 3:this.#t.username=this.#l();break;case 4:this.#t.password=this.#l();break;case 5:this.#t.hostname=this.#l();break;case 6:this.#t.port=this.#l();break;case 7:this.#t.pathname=this.#l();break;case 8:this.#t.search=this.#l();break;case 9:this.#t.hash=this.#l();break;case 10:break}this.#s!==0&&e!==10&&([1,2,3,4].includes(this.#s)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#s)&&[8,9].includes(e)&&(this.#t.pathname??=this.#f?"/":""),[1,2,3,4,5,6,7].includes(this.#s)&&e===9&&(this.#t.search??="")),this.#h(e,t)}#h(e,t){this.#s=e,this.#a=this.#e+t,this.#e+=t,this.#i=0}#g(){this.#e=this.#a,this.#i=0}#y(e){this.#g(),this.#s=e}#x(e){return e<0&&(e=this.#r.length-e),e<this.#r.length?this.#r[e]:this.#r[this.#r.length-1]}#c(e,t){let r=this.#x(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#w(){return this.#c(this.#e,":")}#R(){return this.#c(this.#e+1,"/")&&this.#c(this.#e+2,"/")}#b(){return this.#c(this.#e,"@")}#k(){return this.#c(this.#e,":")}#v(){return this.#c(this.#e,":")}#E(){return this.#c(this.#e,"/")}#d(){if(this.#c(this.#e,"?"))return!0;if(this.#r[this.#e].value!=="?")return!1;let e=this.#x(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#u(){return this.#c(this.#e,"#")}#T(){return this.#r[this.#e].type=="OPEN"}#_(){return this.#r[this.#e].type=="CLOSE"}#P(){return this.#c(this.#e,"[")}#O(){return this.#c(this.#e,"]")}#l(){let e=this.#r[this.#e],t=this.#x(this.#a).index;return this.#o.substring(t,e.index)}#S(){let e={};Object.assign(e,Io),e.encodePart=qm;let t=tL(this.#l(),void 0,e);this.#f=hE(t)}},Hm=["protocol","username","password","hostname","port","pathname","search","hash"],Co="*";function cE(e,t){if(typeof e!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(e,t);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function no(e,t){return t?di(e):e}function fi(e,t,r){let o;if(typeof t.baseURL=="string")try{o=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=no(o.protocol.substring(0,o.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=no(o.username,r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=no(o.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=no(o.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=no(o.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=no(o.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=no(o.search.substring(1,o.search.length),r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=no(o.hash.substring(1,o.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=fL(t.protocol,r)),typeof t.username=="string"&&(e.username=pL(t.username,r)),typeof t.password=="string"&&(e.password=lL(t.password,r)),typeof t.hostname=="string"&&(e.hostname=cL(t.hostname,r)),typeof t.port=="string"&&(e.port=mL(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,o&&!nL(e.pathname,r)){let n=o.pathname.lastIndexOf("/");n>=0&&(e.pathname=no(o.pathname.substring(0,n+1),r)+e.pathname)}e.pathname=uL(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=aL(t.search,r)),typeof t.hash=="string"&&(e.hash=iL(t.hash,r)),e}function di(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function wL(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function RL(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",o=^${wL(t.delimiter)}+?,n=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let i=0;i<e.length;++i){let a=e[i];if(a.type===3){if(a.modifier===3){s+=di(a.value);continue}s+={${di(a.value)}}${os(a.modifier)};continue}let c=a.hasCustomName(),l=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!t.prefixes.includes(a.prefix)),u=i>0?e[i-1]:null,p=i<e.length-1?e[i+1]:null;if(!l&&c&&a.type===1&&a.modifier===3&&p&&!p.prefix.length&&!p.suffix.length)if(p.type===3){let f=p.value.length>0?p.value[0]:"";l=n.test(f)}else l=!p.hasCustomName();if(!l&&!a.prefix.length&&u&&u.type===3){let f=u.value[u.value.length-1];l=t.prefixes.includes(f)}l&&(s+="{"),s+=di(a.prefix),c&&(s+=:${a.name}),a.type===2?s+=(${a.value}):a.type===1?c||(s+=(${o})):a.type===0&&(!c&&(!u||u.type===3||u.modifier!==3||l||a.prefix!=="")?s+="*":s+=(${r})),a.type===1&&c&&a.suffix.length&&n.test(a.suffix[0])&&(s+="\\"),s+=di(a.suffix),l&&(s+="}"),a.modifier!==3&&(s+=os(a.modifier))}return s}var EE=class{#o;#r={};#t={};#e={};#i={};#a=!1;constructor(e={},t,r){try{let o;if(typeof t=="string"?o=t:r=t,typeof e=="string"){let a=new EL(e);if(a.parse(),e=a.result,o===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=o}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(o)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let n={ignoreCase:r.ignoreCase===!0},s={pathname:Co,protocol:Co,username:Co,password:Co,hostname:Co,port:Co,search:Co,hash:Co};this.#o=fi(s,e,!0),gE(this.#o.protocol)===this.#o.port&&(this.#o.port="");let i;for(i of Hm){if(!(i in this.#o))continue;let a={},c=this.#o[i];switch(this.#t[i]=[],i){case"protocol":Object.assign(a,Io),a.encodePart=qm;break;case"username":Object.assign(a,Io),a.encodePart=dL;break;case"password":Object.assign(a,Io),a.encodePart=hL;break;case"hostname":Object.assign(a,rL),fE(c)?a.encodePart=xE:a.encodePart=yE;break;case"port":Object.assign(a,Io),a.encodePart=bE;break;case"pathname":hE(this.#r.protocol)?(Object.assign(a,oL,n),a.encodePart=gL):(Object.assign(a,Io,n),a.encodePart=yL);break;case"search":Object.assign(a,Io,n),a.encodePart=xL;break;case"hash":Object.assign(a,Io,n),a.encodePart=bL;break}try{this.#i[i]=pE(c,a),this.#r[i]=uE(this.#i[i],this.#t[i],a),this.#e[i]=RL(this.#i[i],a),this.#a=this.#a||this.#i[i].some(l=>l.type===2)}catch{throw new TypeError(invalid ${i} pattern '${this.#oi}'.)}}}catch(o){throw new TypeError(Failed to construct 'URLPattern': ${o.message})}}test(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return!1;try{typeof e=="object"?r=fi(r,e,!1):r=fi(r,cE(e,t),!1)}catch{return!1}let o;for(o of Hm)if(!this.#r[o].exec(r[o]))return!1;return!0}exec(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return;try{typeof e=="object"?r=fi(r,e,!1):r=fi(r,cE(e,t),!1)}catch{return null}let o={};t?o.inputs=[e,t]:o.inputs=[e];let n;for(n of Hm){let s=this.#r[n].exec(r[n]);if(!s)return null;let i={};for(let[a,c]of this.#t[n].entries())if(typeof c=="string"||typeof c=="number"){let l=s[a+1];i[c]=l}o[n]={input:r[n]??"",groups:i}}return o}static compareComponent(e,t,r){let o=(a,c)=>{for(let l of["type","modifier","prefix","value","suffix"]){if(a[l]<c[l])return-1;if(a[l]!==c[l])return 1}return 0},n=new hi(3,"","","","",3),s=new hi(0,"","","","",3),i=(a,c)=>{let l=0;for(;l<Math.min(a.length,c.length);++l){let u=o(a[l],c[l]);if(u)return u}return a.length===c.length?0:o(a[l]??n,c[l]??n)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?i(t.#i[e],[s]):!t.#e[e]&&r.#e[e]?i([s],r.#i[e]):i(t.#i[e],r.#i[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#a}};globalThis.URLPattern||(globalThis.URLPattern=EE);var wE,RE=async(e,t)=>(wE??=vc({wasm:e,worker:t}),await wE,async r=>{let{outputFiles:o}=await Rc({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[Pb(),iE({fetch:kL,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:o[0].text}}),kL=async(e,t)=>{let r=Ob(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let o=await Gm(e);if(o)return o}try{let o=await r(e);return o.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await Aa(e,o),L([o,!1])):await Gm(e)??M({name:"HTTPError",message:${o.status} ${o.statusText},response:o})}catch(o){let n=await Gm(e);if(n)return n;if(o instanceof TypeError)return M({name:"NetworkError",message:o.message,request:e});if(o instanceof DOMException)return M({name:"AbortError",message:o.message,request:e});throw o}},Gm=async e=>{if(e.url.startsWith("data:"))return;let t=await bo(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),L([t,!0])};var kE=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var vE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},TE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},_E=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},PE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var OE=()=>{let e;return{show:(o,{x:n,y:s})=>{e=vL(),e.append(TL(o)),e.style.visibility="hidden",document.body.append(e);let{height:i}=e.getBoundingClientRect();e.style.top=${s-i}px,e.style.left=${n}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(o=>setTimeout(o,150)),e?.remove?.()}}},vL=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},TL=e=>{let t=document.createElement("pre");return t.classList.add("tooltip-inner"),t.style.textAlign="unset",t.style.maxWidth="70vw",t.style.margin="unset",t.innerText=e,t};var SE=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:o}=OE();return{component:e,setStatus:async(s,i)=>{switch(e.textContent="",await o(),s){case"loading":e.append(_E());break;case"pass":e.append(vE());break;case"fail":e.append(TE());break;case"none":break}i!==void 0&&s!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await o();else{let{top:a,left:c}=e.getBoundingClientRect();r(i,{y:a+globalThis.scrollY,x:c})}t=!t}):e.style.pointerEvents="none"}}};var LE=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(PE()),t.addEventListener("click",e),t};var NE=e=>{let{component:t,setStatus:r}=SE(),o=document.createElement("div");return o.style.position="absolute",o.style.left="-2em",o.style.zIndex="1",o.style.display="flex",o.style.flexFlow="column",o.append(LE(e),t),{menu:o,setStatus:r}};function ME(e){return new Promise(t=>setTimeout(t,e))}function CE(e,t){let{trailing:r=!1,interval:o=0}=t??{},n,s=!1,i=l=>{n?.resolve?.({executed:!1}),n=l},a=()=>{let{...l}=n;return n=void 0,l},c=async()=>{if(s||!n)return;s=!0,o>0&&await ME(o);let{parameters:l,resolve:u,reject:p}=a();try{let f=await e(...l);s=!1,u({result:f,executed:!0})}catch(f){s=!1,p(f)}finally{r?await c():(i(),await Promise.resolve())}};return(...l)=>new Promise((u,p)=>{i({parameters:l,resolve:u,reject:p}),c()})}var IE,AE=async(e,t)=>{let r=[],n=CE(async()=>{r.forEach(({menu:i,setStatus:a})=>{a("none"),i.remove()});let s=Vx(scrapbox.Project.name,scrapbox.Page.title??"",At());for(let i of s){let a=i.lang.toLowerCase();if(kE(a))for(let c of i.startIds){let l=document.getElementById(L${c}),{menu:u,setStatus:p}=NE(async()=>{await p("loading");try{IE??=await RE(e,t);let{contents:f}=await IE(i.path);console.debug("execute:",f),await Function(return (async()=>{${f}})())(),await p("pass")}catch(f){console.error(f),await p("fail",${f})}});r.push({menu:u,setStatus:p}),l?.insertBefore?.(u,l?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await n(),scrapbox.addListener("lines:changed",n),()=>{scrapbox.removeListener("lines:changed",n),r.forEach(({menu:s,setStatus:i})=>{i("none"),s.remove()})}};function PL(e,t){for(var r in t)e[r]=t[r];return e}function FE(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Bc(e,t){var r=t(),o=Q({t:{__:r,u:t}}),n=o[0].t,s=o[1];return Ra(function(){n.__=r,n.u=t,zm(n)&&s({t:n})},[e,r,t]),te(function(){return zm(n)&&s({t:n}),e(function(){zm(n)&&s({t:n})})},[e]),r}function zm(e){var t,r,o=e.u,n=e.__;try{var s=o();return!((t=n)===(r=s)&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}}function DE(e,t){this.props=e,this.context=t}(DE.prototype=new xr).isPureReactComponent=!0,DE.prototype.shouldComponentUpdate=function(e,t){return FE(this.props,e)||FE(this.state,t)};var UE=re.__b;re.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),UE&&UE(e)};var Owe=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var OL=re.__e;re.__e=function(e,t,r,o){if(e.then){for(var n,s=t;s=s.__;)if((n=s.__c)&&n.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),n.__c(e,t)}OL(e,t,r,o)};var $E=re.unmount;function GE(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=PL({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return GE(o,t,r)})),e}function zE(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return zE(o,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function Vm(){this.__u=0,this.o=null,this.__b=null}function VE(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function jc(){this.i=null,this.l=null}re.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),$E&&$E(e)},(Vm.prototype=new xr).__c=function(e,t){var r=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(r);var n=VE(o.__v),s=!1,i=function(){s||(s=!0,r.__R=null,n?n(a):a())};r.__R=i;var a=function(){if(!--o.__u){if(o.state.__a){var c=o.state.__a;o.__v.__k[0]=zE(c,c.__c.__P,c.__c.__O)}var l;for(o.setState({__a:o.__b=null});l=o.o.pop();)l.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},Vm.prototype.componentWillUnmount=function(){this.o=[]},Vm.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=GE(this.__b,r,o.__O=o.__P)}this.__b=null}var n=t.__a&&Vr(ee,null,e.fallback);return n&&(n.__u&=-33),[Vr(ee,null,t.__a?null:e.children),n]};var jE=function(e,t,r){if(++r[1]===r[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(r=e.i;r;){for(;r.length>3;)r.pop()();if(r[1]<r[0])break;e.i=r=r[2]}};(jc.prototype=new xr).__a=function(e){var t=this,r=VE(t.__v),o=t.l.get(e);return o[0]++,function(n){var s=function(){t.props.revealOrder?(o.push(n),jE(t,e,o)):n()};r?r(s):s()}},jc.prototype.render=function(e){this.i=null,this.l=new Map;var t=go(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var r=t.length;r--;)this.l.set(t[r],this.i=[1,0,this.i]);return e.children},jc.prototype.componentDidUpdate=jc.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){jE(e,r,t)})};var SL=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,LL=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,NL=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,ML=/[A-Z0-9]/g,CL=typeof document<"u",IL=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};xr.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(xr.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var BE=re.event;function AL(){}function FL(){return this.cancelBubble}function DL(){return this.defaultPrevented}re.event=function(e){return BE&&(e=BE(e)),e.persist=AL,e.isPropagationStopped=FL,e.isDefaultPrevented=DL,e.nativeEvent=e};var KE,UL={enumerable:!1,configurable:!0,get:function(){return this.class}},HE=re.vnode;re.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,o=t.type,n={},s=o.indexOf("-")===-1;for(var i in r){var a=r[i];if(!(i==="value"&&"defaultValue"in r&&a==null||CL&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var c=i.toLowerCase();i==="defaultValue"&&"value"in r&&r.value==null?i="value":i==="download"&&a===!0?a="":c==="translate"&&a==="no"?a=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?i="ondblclick":c!=="onchange"||o!=="input"&&o!=="textarea"||IL(r.type)?c==="onfocus"?i="onfocusin":c==="onblur"?i="onfocusout":NL.test(i)&&(i=c):c=i="oninput":s&&LL.test(i)?i=i.replace(ML,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&n[i=c]&&(i="oninputCapture"),n[i]=a}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=go(r.children).forEach(function(l){l.props.selected=n.value.indexOf(l.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=go(r.children).forEach(function(l){l.props.selected=n.multiple?n.defaultValue.indexOf(l.props.value)!=-1:n.defaultValue==l.props.value})),r.class&&!r.className?(n.class=r.class,Object.defineProperty(n,"className",UL)):(r.className&&!r.class||r.class&&r.className)&&(n.class=n.className=r.className),t.props=n}(e),e.$$typeof=SL,HE&&HE(e)};var WE=re.__r;re.__r=function(e){WE&&WE(e),KE=e.__c};var qE=re.diffed;re.diffed=function(e){qE&&qE(e);var t=e.props,r=e.__e;r!=null&&e.type==="textarea"&&"value"in t&&t.value!==r.value&&(r.value=t.value==null?"":t.value),KE=null};var YE=({title:e,projects:t,selected:r,confirm:o})=>d("div",{className:candidate${r?" selected":""},children:[d($L,{title:e,confirm:o}),t.map(n=>d(jL,{project:n.name,title:e,mark:n.mark,confirm:n.confirm}))]}),$L=({title:e,confirm:t})=>d("a",{className:"button",tabIndex:0,role:"menuitem",href:./${ne(e)},onClick:XE(t),children:e}),jL=({project:e,title:t,mark:r,confirm:o})=>{let n=XE(o);return r===""?null:d("a",{className:"mark",tabIndex:0,href:../${e}/${ne(t)},onClick:n,title:/${e}/${ne(t)},children:r instanceof URL?d("img",{src:r.href}):${r}})},XE=e=>U(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},[e]);var JE=(e,t)=>{let[r,o]=Q(null),n=U(c=>o(l=>{if(e.length===0)return null;if(l===null)return t(e[0]);let u=e.findIndex(p=>t(p)===l);return t(c?.cyclic?e[(u+1)%e.length]:e.at(u+1)??e[0])}),[e,t]),s=U(c=>o(l=>{if(e.length===0)return null;if(l===null)return t(e[e.length-1]);let u=e.findIndex(p=>t(p)===l);return u<0?t(e[e.length-1]):t(c?.cyclic?e[(u-1+e.length)%e.length]:e.at(u-1)??e[e.length-1])}),[e,t]),i=U(()=>o(e.length===0?null:t(e[0])),[e,t]),a=U(()=>o(e.length===0?null:t(e[e.length-1])),[e,t]);return{selectedId:r,next:n,prev:s,selectFirst:i,selectLast:a}};var QE=e=>{let[t,r]=Q(null),o=H(()=>{let n=t?.getBoundingClientRect?.(),i=Ws(e.line,e.char)?.getBoundingClientRect?.();return!i||!n?{}:{top:${i.bottom-n.top}px,left:${i?.left??0-n.left}px,right:${n.right-(i?.left??0)}px}},[t,e.line,e.char]);return{updateStandardElement:r,...o}};var Ym="enableProjectsOnSuggestion",ZE=(e,t)=>{let[r,o]=Q(Hc([...e],t)),n=U((s,i)=>{BL(s,i,e,t),o(Hc([...e],t))},[e,t.enableSelfProjectOnStart]);return te(()=>{let s=i=>{i.key===Ym&&o(Hc([...e],t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},[e,t.enableSelfProjectOnStart]),{projects:r,set:n}},Km=!0,Hc=(e,t)=>{try{let r=localStorage.getItem(Ym);if(r===null)return Wc(e),e;let o=JSON.parse(r);return Array.isArray(o)&&o.every(n=>typeof n=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?o:o.includes(scrapbox.Project.name)?Km?o:o.filter(n=>n!==scrapbox.Project.name):Km?[...o,scrapbox.Project.name]:o:(Wc(e),e)}catch(r){if(!(r instanceof TypeError))throw r;return Wc(e),e}},BL=(e,t,r,o)=>{let n=Hc([...r],o);o.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(Km=t),Wc(t?[...n,e]:n.filter(s=>s!==e))},Wc=e=>localStorage.setItem(Ym,JSON.stringify(e));var ew=()=>H(()=>document.documentElement.dataset.os??"",[]);var gi=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(o){if(!(o instanceof TypeError))throw o;return e}}};var tw=({progress:e})=>d("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 ow=({position:e,start:t,enableSelfProjectOnStart:r,projects:o,...n})=>{let{projects:s,set:i}=ZE(o,{enableSelfProjectOnStart:r}),{updateStandardElement:a,top:c,left:l,right:u}=QE({line:e.line,char:t}),p=ew();return d(ee,{children:[d(WL,{itemCount:n.items.length,enableProjects:s,projects:o,top:c,right:u,set:i,os:p,...n}),d(HL,{updateStandardElement:a,start:t,enableProjects:s,projects:o,top:c,left:l,os:p,...n})]})},HL=({start:e,updateStandardElement:t,confirmAfter:r,cancel:o,query:n,enableProjects:s,projects:i,items:a,top:c,left:l,progress:u,callback:p,limit:f,mark:m,os:h})=>{let g=U((N,_,P)=>{let I=[${_?/${_}/${N}:N}${P?.icon?".icon":""}];r(($,{line:j})=>[${...$.slice(0,e).join("")}${I}${...$.slice(e+...n.length).join("")},{line:j,char:e+[...I].length}])},[e,n]),y=H(()=>i.size>1||!i.has(scrapbox.Project.name),[i]),x=H(()=>{let N=[];for(let _ of a){if(N.length===f)break;_.projects.some(P=>s.includes(P))&&N.push({title:_.title,projects:_.projects.flatMap(P=>s.includes(P)?[{name:P,mark:y?gi(m[P]??"",import.meta.url)||P[0]:"",confirm:I=>g(_.title,P,I)}]:[]),confirm:P=>g(_.title,void 0,P)})}return N},[s,y,a,f,m,g]),{selectedId:w,next:k,prev:b,selectLast:T,selectFirst:v}=JE(x,rw),A=U(N=>w===null?!1:(x.find(_=>rw(_)===w)?.confirm?.(N),!0),[w,x]);te(()=>p(x.length===0?void 0:{selectNext:N=>(k(N),!0),selectPrev:N=>(b(N),!0),selectFirst:()=>(v(),!0),selectLast:()=>(T(),!0),confirm:A,cancel:()=>(o(),!0)}),[p,x.length,k,b,v,T,A]);let F=H(()=>x.length>0&&c!=null&&l!=null?{top:c,left:l}:{display:"none"},[x.length,c,l]),D=U(N=>{if(!N){t(N);return}let _=N.parentNode;if(!(_ instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(_.host.parentElement)},[t]);return d("div",{ref:D,className:"container candidates","data-os":h,style:F,children:[x.map(N=>d(YE,{...N,selected:w===N.title},N.title)),a.length>f&&d("div",{className:"counter",children:${a.length-f} more links}),d(tw,{progress:u})]})},WL=({enableProjects:e,projects:t,projectScore:r,mark:o,itemCount:n,top:s,right:i,set:a,os:c,freezeUntil:l})=>{let u=H(()=>[...t].sort((f,m)=>(r.get(m)??0)-(r.get(f)??0)).flatMap(f=>r.has(f)?[{name:f,enable:e.includes(f),mark:gi(o[f]??"",import.meta.url)||f[0],score:r.get(f),onClick:()=>l(()=>{a(f,!e.includes(f)),dt().focus()})}]:[]),[t,r,e,o]),p=H(()=>n>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},[s,i,n,t.size]);return d("div",{className:"container projects","data-os":c,style:p,children:u.map(f=>d(qL,{...f},f.name))})},qL=e=>d("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name,children:e.mark instanceof URL?d("img",{src:e.mark.href}):${e.mark}}),rw=e=>e.title;var nw=e=>{let t=H(()=>gi(e.style,import.meta.url),[e.style]);return d(ee,{children:t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",{children:t}))})};var sw=()=>d("style",{children:.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;
}
.candidates:not(data-os*="android"):not(data-os*="ios") {
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
.projects:is(data-os*="android", data-os*="ios") > * {
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;
}
.progressstyle {
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
}});function*iw(e){if(!("nodes"in e))return;let t=0;function*r(o){for(let n of Array.isArray(o)?o:[o]){if(typeof n=="string"){t+=[...n].length;continue}switch(n.type){case"link":yield{whole:n.unit.whole,start:t},t+=[...n.unit.whole].length;break;case"indent":case"quote":t+=[...n.unit.tag].length,yield*r(n.children);break;case"deco":t+=[...n.unit.deco].length+2,yield*r(n.children),t++;break;case"strong":t+=2,yield*r(n.children),t+=2;break;default:t+=[...n.unit.whole].length;break}}}yield*r(e.nodes)}var aw=(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 r=Math.min(t.range.start.char,t.range.end.char),o=Math.max(t.range.start.char,t.range.end.char),n=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(r,o).join(""):"";if(zL(t.lines[t.position.line],n)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:n,start:r,position:t.position};if(n!=="")return e.type==="completion"?{type:"ready"}:e;let s=GL(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"}},GL=(e,t)=>{for(let{whole:r,start:o}of iw(e))if(!(t<=o||o+[...r].length<=t))return{whole:r,start:o}},zL=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var cw=()=>{let e=ft(scrapbox.Page.lines),t=ft(!1);return te(()=>{let r=()=>{t.current=!0};return scrapbox.addListener("lines:changed",r),scrapbox.addListener("layout:changed",r),()=>{scrapbox.removeListener("lines:changed",r),scrapbox.removeListener("layout:changed",r)}},[]),U(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var VL=Fn("scrapbox-select-suggestion:useLifecycle.ts"),lw=()=>{let[e,t]=yo(aw,{type:"ready"}),r=cw(),o=H(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:c,selection:l}=Bt();t({type:a,lines:r(),range:l.getRange({normalizeOrder:!0}),position:c.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);te(()=>{let i=()=>{o("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{o("selection:changed")},c=Fa();return c.addChangeListener(a),()=>{scrapbox.removeListener("lines:changed",i),scrapbox.removeListener("layout:changed",i),c.removeChangeListener(a)}},[]),te(()=>{if(e.context!=="input")return;let i=()=>{o("cursor:changed")},a=Eo();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[n,s]=Q(e);return n!==e&&(s(e),VL.debug("Detect changes",e)),{state:e,setEnable:U(i=>t({type:i?"enable":"disable"}),[]),cancel:U(()=>t({type:"cancel"}),[]),freezeUntil:U(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:U(async i=>{let a=r();if(!a)return;t({type:"lock"});let{cursor:c,selection:l}=Bt(),u=c.getPosition().line,p=a[u].text,[f,m]=i(p,c.getPosition());l.setRange({start:{line:u,char:0},end:{line:u,char:[...p].length}}),await at(f),c.setPosition(m),c.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var pw=(e,t)=>{let r=e.dist-t.dist;if(r!==0)return r;let o=e.matches.map(([i])=>i).sort(),n=t.matches.map(([i])=>i).sort();for(let i=0;i<o.length;i++){let a=o[i]-(n[i]??n.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var mw=Symbol("Comlink.proxy"),KL=Symbol("Comlink.endpoint"),Qm=Symbol("Comlink.releaseProxy"),Xm=Symbol("Comlink.finalizer"),Gc=Symbol("Comlink.thrown"),fw=e=>typeof e=="object"&&e!==null||typeof e=="function",YL={canHandle:e=>fw(e)&&e[mw],serialize(e){let{port1:t,port2:r}=new MessageChannel;return hw(e,t),[r,[r]]},deserialize(e){return e.start(),Zm(e)}},XL={canHandle:e=>fw(e)&&Gc in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},dw=new Map([["proxy",YL],["throw",XL]]);function JL(e,t){for(let r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function hw(e,t=globalThis,r=["*"]){t.addEventListener("message",function o(n){if(!n||!n.data)return;if(!JL(r,n.origin)){console.warn(Invalid origin '${n.origin}' for comlink proxy);return}let{id:s,type:i,path:a}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(bn),l;try{let u=a.slice(0,-1).reduce((f,m)=>f[m],e),p=a.reduce((f,m)=>f[m],e);switch(i){case"GET":l=p;break;case"SET":u[a.slice(-1)[0]]=bn(n.data.value),l=!0;break;case"APPLY":l=p.apply(u,c);break;case"CONSTRUCT":{let f=new p(...c);l=ef(f)}break;case"ENDPOINT":{let{port1:f,port2:m}=new MessageChannel;hw(e,m),l=rN(f,[f])}break;case"RELEASE":l=void 0;break;default:return}}catch(u){l={value:u,[Gc]:0}}Promise.resolve(l).catch(u=>({value:u,[Gc]:0})).then(u=>{let[p,f]=Kc(u);t.postMessage(Object.assign(Object.assign({},p),{id:s}),f),i==="RELEASE"&&(t.removeEventListener("message",o),gw(t),Xm in e&&typeof e[Xm]=="function"&&e[Xm]())}).catch(u=>{let[p,f]=Kc({value:new TypeError("Unserializable return value"),[Gc]:0});t.postMessage(Object.assign(Object.assign({},p),{id:s}),f)})}),t.start&&t.start()}function QL(e){return e.constructor.name==="MessagePort"}function gw(e){QL(e)&&e.close()}function Zm(e,t){let r=new Map;return e.addEventListener("message",function(o){let{data:n}=o;if(!n||!n.id)return;let s=r.get(n.id);if(s)try{s(n)}finally{r.delete(n.id)}}),Jm(e,r,[],t)}function qc(e){if(e)throw new Error("Proxy has been released and is not useable")}function yw(e){return ns(e,new Map,{type:"RELEASE"}).then(()=>{gw(e)})}var zc=new WeakMap,Vc="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(zc.get(e)||0)-1;zc.set(e,t),t===0&&yw(e)});function ZL(e,t){let r=(zc.get(t)||0)+1;zc.set(t,r),Vc&&Vc.register(e,t,e)}function eN(e){Vc&&Vc.unregister(e)}function Jm(e,t,r=[],o=function(){}){let n=!1,s=new Proxy(o,{get(i,a){if(qc(n),a===Qm)return()=>{eN(s),yw(e),t.clear(),n=!0};if(a==="then"){if(r.length===0)return{then:()=>s};let c=ns(e,t,{type:"GET",path:r.map(l=>l.toString())}).then(bn);return c.then.bind(c)}return Jm(e,t,[...r,a])},set(i,a,c){qc(n);let[l,u]=Kc(c);return ns(e,t,{type:"SET",path:[...r,a].map(p=>p.toString()),value:l},u).then(bn)},apply(i,a,c){qc(n);let l=r[r.length-1];if(l===KL)return ns(e,t,{type:"ENDPOINT"}).then(bn);if(l==="bind")return Jm(e,t,r.slice(0,-1));let[u,p]=uw(c);return ns(e,t,{type:"APPLY",path:r.map(f=>f.toString()),argumentList:u},p).then(bn)},construct(i,a){qc(n);let[c,l]=uw(a);return ns(e,t,{type:"CONSTRUCT",path:r.map(u=>u.toString()),argumentList:c},l).then(bn)}});return ZL(s,e),s}function tN(e){return Array.prototype.concat.apply([],e)}function uw(e){let t=e.map(Kc);return[t.map(r=>r[0]),tN(t.map(r=>r[1]))]}var xw=new WeakMap;function rN(e,t){return xw.set(e,t),e}function ef(e){return Object.assign(e,{[mw]:!0})}function Kc(e){for(let[t,r]of dw)if(r.canHandle(e)){let[o,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:o},n]}return[{type:"RAW",value:e},xw.get(e)||[]]}function bn(e){switch(e.type){case"HANDLER":return dw.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ns(e,t,r,o){return new Promise(n=>{let s=oN();t.set(s,n),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),o)})}function oN(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ss=Fn("scrapbox-select-suggestion:cancelableSearch.ts"),bw=e=>{let t=Zm(e);return{load:async r=>{ss.debug("start loading source");let o=await t.load([...r]);return ss.debug(loaded ${o} candidates),o},search:(r,o)=>nN(r,o??5e3,t.search),[Symbol.dispose]:()=>{t[Qm](),e instanceof MessagePort?e.close():e.terminate(),ss.debug("shared worker closed.")}}},nN=(e,t,r)=>{if(ss.debug("start searching: ",e),!e.trim())return new ReadableStream({start(s){s.close()}});let o=new Date,n=!1;return new ReadableStream({async start(s){try{await r(e,t,ef((i,a)=>(n||s.enqueue([i,a]),n))),s.close()}catch(i){s.error(i)}finally{n=!0;let a=new Date().getTime()-o.getTime();ss.debug(Comlink search completed for "${e}" in ${a}ms)}},cancel(){n=!0;let i=new Date().getTime()-o.getTime();ss.debug(Comlink search cancelled for "${e}" after ${i}ms)}})};var Yc=(e,t)=>{let r=t?.interval??0,o=t?.maxQueued??1/0,n,s,i=[],a=(...c)=>{if(!n)return n=(async()=>{do{await new Promise(m=>{let h=setTimeout(m,r);s=()=>{for(clearTimeout(h);i.length>0;)i.shift()("discarded");m()}});let f=i.pop();if(!f)break;f("delayed")}while(i.length>0);n=void 0})(),new Promise(f=>f(e.call(a,...c,"immediate")));for(;i.length>Math.max(o,0);)i.shift()("discarded");let{promise:l,resolve:u,reject:p}=Promise.withResolvers();return i.push(f=>{try{u(e.call(a,...c,f))}catch(m){p(m)}}),l};return a.clear=()=>{s?.()},Object.defineProperty(a,"ready",{get:()=>n}),a};var yi=e=>e.query!=="",Ew=e=>(t,r)=>{if("query"in r){if(r.query===t.query)return t;let i=yi(t)?t.job:void 0;if(!r.query)return i?.abort?.(),{query:""};let{run:a,abort:c}=e(r.query),l=i?.abort?.()?.then?.(a)??a();return{query:r.query,job:{done:l,abort:()=>(c(),l)},progress:0,candidates:yi(t)?t.candidates:[]}}if(!yi(t))return t;if(!r.candidates){let{progress:i,...a}=t;return i===r.progress?t:{progress:r.progress,...a}}let{candidates:o,progress:n,...s}=t;return o===r.candidates&&n===r.progress?t:{candidates:r.candidates??o,progress:r.progress,...s}};var xi="SharedWorker"in globalThis;var aN=Fn("scrapbox-select-suggestion:useSearch.ts"),ww=(e,t)=>{let r=H(()=>bw(xi?new SharedWorker(t.workerUrl,{type:"module"}).port:new Worker(t.workerUrl,{type:"module"})),[t.workerUrl]);te(()=>(r.load(t.projects),()=>{using i=r}),[r,t.projects]);let o=U(Ew(i=>{let a=!1;return{run:async()=>{let c=Yc((u,p)=>{p!=="discarded"&&(a||s(u))},{interval:500,maxQueued:0}),l=[];for await(let[u,p]of r.search(i,1e4)){if(a)return;l=[...l,...u],s({progress:p}),u.length!==0&&c({progress:p,candidates:l})}c({progress:1,candidates:l})},abort:()=>a=!0}}),[r]),[n,s]=yo(o,{query:""});return te(()=>s({query:e}),[e]),H(()=>{if(!yi(n))return;let[i,a]=cN(n.candidates);return aN.debug("Detect changes",{progress:n.progress,items:a}),{progress:n.progress,projectScore:i,items:a}},[n])},cN=e=>{let t=new Map,r=[];for(let o of e.sort(pw)){let n=[...o.metadata.keys()];for(let s of n)t.set(s,(t.get(s)??0)+.5**o.dist);r.push({title:o.title,dist:o.dist,projects:n})}return[t,r]};var Rw=(e,t)=>{let r=ft({...t});te(()=>(Object.assign(r.current,t),()=>{for(let o of Object.keys(t))delete r.current[o]}),[...Object.keys(t)].sort().map(o=>t[o])),te(()=>{e(r.current)},[e])};var lN={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},kw=e=>{let{state:t,setEnable:r,...o}=lw(),n=ww(t.type==="completion"?t.context==="input"?t.query.slice(1,-1):t.query:"",e),[s,i]=Q(),{callback:a,style:c,...l}=e;return Rw(a,{enable:U(()=>r(!0),[]),disable:U(()=>r(!1),[]),...t.type!=="completion"||!s?lN:s}),d(ee,{children:[d(sw,{}),d(nw,{style:c}),t.type==="completion"&&n&&d(ow,{callback:i,...n,...t,...o,...l})]})};var vw=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let r=t.attachShadow({mode:"open"});document.body.append(t);let{limit:o=5,debug:n=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0,workerUrl:c}=e,l=new Set([...a?[scrapbox.Project.name]:[],...e.projects??[scrapbox.Project.name]]);return ga(n),new Promise(u=>Rt(d(kw,{limit:o,projects:l,mark:s,style:i,callback:u,enableSelfProjectOnStart:a,workerUrl:c}),r))};var rr=e=>e.flatMap(t=>{let r=t.slice(1),o=Math.min(...r.map(n=>n.text.length-n.text.trimStart().length));return r.map(n=>n.text.slice(o))}).join(
).trim();function*Tw(e,t){for(let[r,o]of t.entries()){let n=e.get(r);if(n&&rr(n.blocks)===rr(o)){yield{changed:!1,filename:r};continue}yield{changed:!0,filename:r}}for(let r of e.keys())t.has(r)||(yield{changed:!0,filename:r})}var _w=e=>{let t=new Map;if(e.length===0)return t;let r=it(e.map(n=>n.text).join(
),{hasTitle:!0}),o=0;for(let n of r)switch(n.type){case"title":case"line":o++;break;case"table":o+=n.cells.length+1;break;case"codeBlock":{let s=t.get(n.fileName)??[],i=n.content.split(
).length+1;s.push(e.slice(o,o+i)),t.set(n.fileName,s),o+=i;break}}return t};var Pw=e=>{let t,r,o=async()=>{for(;t;){let[n,s]=t;t=void 0;try{let i=await e(...n);s({type:"resolve",value:i})}catch(i){s({type:"reject",value:i})}}r=void 0};return(...n)=>{let{resolve:s,promise:i}=Promise.withResolvers();return t?.[1]?.({type:"cancel"}),t=[n,s],r??=o(),i}};var Xc=class{constructor(t,r){this._filename=t;this._preview=Pw(async(o,n,s)=>(this._dispose=await r(s?{filename:this.filename,before:o,after:n,render:(...i)=>{s.textContent="",s.append(...i)}}:{filename:this.filename,before:o}),!1))}get filename(){return this._filename}get blocks(){return this._blocks??[]}async update(t){if(await this._dispose?.(),!t||rr(t)===""){let a=await this._preview(this.blocks);if(a.type==="cancel")return a;if(a.type==="reject")throw a.value;return this._area?.remove?.(),this._style?.remove?.(),this._area=void 0,this._style=void 0,this._blocks=void 0,{type:"resolve",value:!0}}let r=this.blocks;this._blocks=t,this.makeStyle();let o=this.makeArea(),n=t.at(0)?.at?.(-1)?.id,s=Yr(n);if(!s)throw new Error("div.lines#L${n}" could not be found.);s.insertAdjacentElement("afterend",o);let i=()=>{let a=s.getElementsByClassName("indent")[0];a instanceof HTMLElement&&(o.style.marginLeft=a.style.marginLeft)};return this._observer?.disconnect?.(),i(),this._observer=new MutationObserver(i),this._observer.observe(s,{childList:!0,subtree:!0}),this._preview(r,t,o)}makeArea(){if(this._area)return this._area;let t=document.createElement("div");return t.classList.add("scrap-run"),t.dataset.filename=this.filename,this._area=t,t}makeStyle(){let t=this.blocks.flatMap(o=>o.slice(1).map(({id:n})=>#L${n})),r=this.blocks.flatMap(o=>o.map(({id:n})=>#L${n}));this._style||(this._style=document.createElement("style"),document.head.append(this._style)),this._style.textContent=.lines:not(:has(:is(${...r.join(",")}).cursor-line)) :is(${...t.join(",")}){display:none}}_blocks;_dispose;_preview;_area;_observer;_style};var Ow=({previewers:e})=>{let t=new Map,r=()=>{let s=_w(At());for(let{changed:i,filename:a}of Tw(t,s)){if(!i)continue;let c=s.get(a),l=t.get(a);if(!l){if(!c)continue;let u=e.find(({when:p})=>p.test(a))?.preview;if(!u)continue;l=new Xc(a,u),t.set(a,l)}l.update(c).then(u=>{switch(u.type){case"resolve":u.value&&t.delete(a);return;case"reject":throw u.value;case"cancel":return}})}},o=()=>{if(scrapbox.Layout!=="page"){scrapbox.off("lines:changed",r);return}r(),scrapbox.on("lines:changed",r)};o(),scrapbox.on("page:changed",o);let n=document.createElement("style");return n.textContent=".scrap-run{display:block;width:95%}",document.head.append(n),()=>{scrapbox.off("page:changed",o),n.remove()}};var bi=e=>{let t=new FileReader,r=new Promise(o=>t.onload=()=>o(t.result));return t.readAsDataURL(e),r};var Sw=async e=>{if(!("after"in e))return;let t=rr(e.after),o=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("parsererror");if(o){let i=document.createElement("pre"),a=document.createElement("code");a.innerText=o.innerHTML,i.append(a),e.render(i);return}let n=await bi(new Blob([t],{type:"image/svg+xml"})),s=document.createElement("img");s.src=n,e.render(s)};var tf={};Bi(tf,{default:()=>Mw});var $N=Object.create,Nw=Object.defineProperty,jN=Object.getOwnPropertyDescriptor,BN=Object.getOwnPropertyNames,HN=Object.getPrototypeOf,WN=Object.prototype.hasOwnProperty,qN=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),GN=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of BN(t))!WN.call(e,n)&&n!==r&&Nw(e,n,{get:()=>t[n],enumerable:!(o=jN(t,n))||o.enumerable});return e},zN=(e,t,r)=>(r=e!=null?$N(HN(e)):{},GN(t||!e||!e.__esModule?Nw(r,"default",{value:e,enumerable:!0}):r,e)),VN=qN((e,t)=>{t.exports=o;var r=Object.prototype.toString;function o(n){if(!n)return!1;var s=r.call(n);return s==="[object Function]"||typeof n=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(n===window.setTimeout||n===window.alert||n===window.confirm||n===window.prompt)}}),Lw=zN(VN()),Mw=Lw.default??Lw;var rf={};Bi(rf,{default:()=>Aw});var KN=Object.create,Iw=Object.defineProperty,YN=Object.getOwnPropertyDescriptor,XN=Object.getOwnPropertyNames,JN=Object.getPrototypeOf,QN=Object.prototype.hasOwnProperty,ZN=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),eM=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of XN(t))!QN.call(e,n)&&n!==r&&Iw(e,n,{get:()=>t[n],enumerable:!(o=YN(t,n))||o.enumerable});return e},tM=(e,t,r)=>(r=e!=null?KN(JN(e)):{},eM(t||!e||!e.__esModule?Iw(r,"default",{value:e,enumerable:!0}):r,e)),rM=ZN((e,t)=>{var r=function(n){return n.replace(/^\s+|\s+$/g,"")},o=function(n){return Object.prototype.toString.call(n)==="[object Array]"};t.exports=function(n){if(!n)return{};for(var s=Object.create(null),i=r(n).split(
),a=0;a<i.length;a++){var c=i[a],l=c.indexOf(":"),u=r(c.slice(0,l)).toLowerCase(),p=r(c.slice(l+1));typeof s[u]>"u"?s[u]=p:o(s[u])?s[u].push(p):s[u]=[s[u],p]}return s}}),Cw=tM(rM()),Aw=Cw.default??Cw;var oM=(()=>{var e=globalThis;return{default:e}})(),nM=(()=>{var e=(...t)=>Object.assign({},...t);return{default:e}})(),is=e=>{let t=o=>typeof o.default<"u"?o.default:o,r=o=>Object.assign({__esModule:!0},o);switch(e){case"npm:global/window":return t(oM);case"is-function":return t(tf);case"parse-headers":return t(rf);case"npm:xtend":return t(nM);default:return console.error('module "'+e+'" not found'),null}},sM=Object.create,Dw=Object.defineProperty,iM=Object.getOwnPropertyDescriptor,aM=Object.getOwnPropertyNames,cM=Object.getPrototypeOf,lM=Object.prototype.hasOwnProperty,Jc=(e=>typeof is<"u"?is:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof is<"u"?is:t)[r]}):e)(function(e){if(typeof is<"u")return is.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),pM=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),uM=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of aM(t))!lM.call(e,n)&&n!==r&&Dw(e,n,{get:()=>t[n],enumerable:!(o=iM(t,n))||o.enumerable});return e},mM=(e,t,r)=>(r=e!=null?sM(cM(e)):{},uM(t||!e||!e.__esModule?Dw(r,"default",{value:e,enumerable:!0}):r,e)),fM=pM((e,t)=>{"use strict";var r=Jc("npm:global/window"),o=Jc("is-function"),n=Jc("parse-headers"),s=Jc("npm:xtend");t.exports=l,t.exports.default=l,l.XMLHttpRequest=r.XMLHttpRequest||f,l.XDomainRequest="withCredentials"in new l.XMLHttpRequest?l.XMLHttpRequest:r.XDomainRequest,i(["get","put","post","patch","head","delete"],function(m){l[m==="delete"?"del":m]=function(h,g,y){return g=c(h,g,y),g.method=m.toUpperCase(),u(g)}});function i(m,h){for(var g=0;g<m.length;g++)h(m[g])}function a(m){for(var h in m)if(m.hasOwnProperty(h))return!1;return!0}function c(m,h,g){var y=m;return o(h)?(g=h,typeof m=="string"&&(y={uri:m})):y=s(h,{uri:m}),y.callback=g,y}function l(m,h,g){return h=c(m,h,g),u(h)}function u(m){if(typeof m.callback>"u")throw new Error("callback argument missing");var h=!1,g=function(j,q,B){h||(h=!0,m.callback(j,q,B))};function y(){b.readyState===4&&setTimeout(k,0)}function x(){var j=void 0;if(b.response?j=b.response:j=b.responseText||p(b),P)try{j=JSON.parse(j)}catch{}return j}function w(j){return clearTimeout(I),j instanceof Error||(j=new Error(""+(j||"Unknown XMLHttpRequest Error"))),j.statusCode=0,g(j,$)}function k(){if(!v){var j;clearTimeout(I),m.useXDR&&b.status===void 0?j=200:j=b.status===1223?204:b.status;var q=$,B=null;return j!==0?(q={body:x(),statusCode:j,method:F,headers:{},url:A,rawRequest:b},b.getAllResponseHeaders&&(q.headers=n(b.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),g(B,q,q.body)}}var b=m.xhr||null;b||(m.cors||m.useXDR?b=new l.XDomainRequest:b=new l.XMLHttpRequest);var T,v,A=b.url=m.uri||m.url,F=b.method=m.method||"GET",D=m.body||m.data,N=b.headers=m.headers||{},_=!!m.sync,P=!1,I,$={body:void 0,headers:{},statusCode:0,method:F,url:A,rawRequest:b};if("json"in m&&m.json!==!1&&(P=!0,N.accept||N.Accept||(N.Accept="application/json"),F!=="GET"&&F!=="HEAD"&&(N["content-type"]||N["Content-Type"]||(N["Content-Type"]="application/json"),D=JSON.stringify(m.json===!0?D:m.json))),b.onreadystatechange=y,b.onload=k,b.onerror=w,b.onprogress=function(){},b.onabort=function(){v=!0},b.ontimeout=w,b.open(F,A,!_,m.username,m.password),_||(b.withCredentials=!!m.withCredentials),!_&&m.timeout>0&&(I=setTimeout(function(){if(!v){v=!0,b.abort("timeout");var j=new Error("XMLHttpRequest timeout");j.code="ETIMEDOUT",w(j)}},m.timeout)),b.setRequestHeader)for(T in N)N.hasOwnProperty(T)&&b.setRequestHeader(T,N[T]);else if(m.headers&&!a(m.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in m&&(b.responseType=m.responseType),"beforeSend"in m&&typeof m.beforeSend=="function"&&m.beforeSend(b),b.send(D||null),b}function p(m){try{if(m.responseType==="document")return m.responseXML;var h=m.responseXML&&m.responseXML.documentElement.nodeName==="parsererror";if(m.responseType===""&&!h)return m.responseXML}catch{}return null}function f(){}}),Fw=mM(fM()),Qc=Fw.default??Fw;var Zc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},YTe=function(){function e(r){this.value=r}function t(r){var o,n;function s(c,l){return new Promise(function(u,p){var f={key:c,arg:l,resolve:u,reject:p,next:null};n?n=n.next=f:(o=n=f,i(c,l))})}function i(c,l){try{var u=r[c](l),p=u.value;p instanceof e?Promise.resolve(p.value).then(function(f){i("next",f)},function(f){i("throw",f)}):a(u.done?"return":"normal",u.value)}catch(f){a("throw",f)}}function a(c,l){switch(c){case"return":o.resolve({value:l,done:!0});break;case"throw":o.reject(l);break;default:o.resolve({value:l,done:!1});break}o=o.next,o?i(o.key,o.arg):n=null}this._invoke=s,typeof r.return!="function"&&(this.return=void 0)}return typeof Symbol=="function"&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(r){return this._invoke("next",r)},t.prototype.throw=function(r){return this._invoke("throw",r)},t.prototype.return=function(r){return this._invoke("return",r)},{wrap:function(r){return function(){return new t(r.apply(this,arguments))}},await:function(r){return new e(r)}}}(),jw=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},Bw=function(){function e(t,r){for(var o=0;o<r.length;o++){var n=r[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),of=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}else return Array.from(e)},Ei="";function dM(e){return
<table style="background-color: #8CE; width: 100%; height: 100%;"><tr>
<td align="center">
<div style="display: table-cell; vertical-align: middle;">
<div style="">+e+</div>
</div>
</td></tr></table>
}var hM=
This page requires a browser that supports WebGL.<br/>
<a href="http://get.webgl.org">Click here to upgrade your browser.</a>
,gM=
It does not appear your computer can support WebGL.<br/>
<a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>
,yM=1,xM=2;function bM(e,t,r){function o(i){var a=e.parentNode;a&&(a.innerHTML=dM(i))}function n(i,a){typeof r=="function"?r(i):o(a)}if(!window.WebGLRenderingContext)return n(yM,hM),null;var s=EM(e,t);return s?s.getExtension("OES_standard_derivatives"):n(xM,gM),s}function EM(e,t){for(var r=["webgl","experimental-webgl"],o=null,n=0;n<r.length;++n)try{o=e.getContext(r[n],t)}catch{if(o)break}return o}function as(e,t,r,o){var n=e.gl,s=n.createShader(r);n.shaderSource(s,t),n.compileShader(s);var i=n.getShaderParameter(s,n.COMPILE_STATUS);return i?s:(Ei=n.getShaderInfoLog(s),console.error("*** Error compiling shader "+s+":"+Ei),e.trigger("error",{shader:s,source:t,type:r,error:Ei,offset:o||0}),n.deleteShader(s),null)}function Uw(e,t,r,o){for(var n=e.gl,s=n.createProgram(),i=0;i<t.length;++i)n.attachShader(s,t[i]);if(r)for(var a=0;a<r.length;++a)n.bindAttribLocation(s,o?o[a]:a,r[a]);n.linkProgram(s);var c=n.getProgramParameter(s,n.LINK_STATUS);return c?s:(Ei=n.getProgramInfoLog(s),console.log("Error in program linking:"+Ei),n.deleteProgram(s),null)}function nf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=[];for(var o in e){var n=e[o],s=void 0;if(t&&(o=t+"."+o),typeof n=="number")r.push({type:"float",method:"1f",name:o,value:n});else if(Array.isArray(n)){if(typeof n[0]=="number")n.length===1?r.push({type:"float",method:"1f",name:o,value:n}):n.length>=2&&n.length<=4?r.push({type:"vec"+n.length,method:n.length+"fv",name:o,value:n}):n.length>4&&r.push({type:"float[]",method:"1fv",name:o+"[0]",value:n});else if(typeof n[0]=="string")r.push({type:"sampler2D",method:"1i",name:o,value:n});else if(Array.isArray(n[0])&&typeof n[0][0]=="number"){if(n[0].length>=2&&n[0].length<=4)for(s=0;s<n.length;s++)r.push({type:"vec"+n[0].length,method:n[s].length+"fv",name:o+"["+s+"]",value:n[s]})}else if(Zc(n[0])==="object")for(s=0;s<n.length;s++)r.push.apply(r,of(nf(n[s],o+"["+s+"]")))}else typeof n=="boolean"?r.push({type:"bool",method:"1i",name:o,value:n}):typeof n=="string"?r.push({type:"sampler2D",method:"1i",name:o,value:n}):(typeof n>"u"?"undefined":Zc(n))==="object"&&r.push.apply(r,of(nf(n,o)))}return r}function wM(e){var t=e.getBoundingClientRect();return t.top+t.height>0&&t.top<(window.innerHeight||document.documentElement.clientHeight)}function $w(e){return(e&e-1)===0}function RM(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function kM(e,t){return e&&t?e.toString()!==t.toString():!1}function vM(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(),t.status==200?t.responseText:""}function Hw(e){var t=new Set;return Object.assign(e,{on:function(r,o){var n={};n[r]=o,t.add(n)},off:function(r,o){if(o){var n={};n[r]=o,t.delete(n)}else{var s=!0,i=!1,a=void 0;try{for(var c=t[Symbol.iterator](),l;!(s=(l=c.next()).done);s=!0){var u=l.value,p=!0,f=!1,m=void 0;try{for(var h=Object.keys(u)[Symbol.iterator](),g;!(p=(g=h.next()).done);p=!0){var y=g.value;if(y===r){t.delete(u);return}}}catch(x){f=!0,m=x}finally{try{!p&&h.return&&h.return()}finally{if(f)throw m}}}}catch(x){i=!0,a=x}finally{try{!s&&c.return&&c.return()}finally{if(i)throw a}}}},listSubscriptions:function(){var r=!0,o=!1,n=void 0;try{for(var s=t[Symbol.iterator](),i;!(r=(i=s.next()).done);r=!0){var a=i.value;console.log(a)}}catch(c){o=!0,n=c}finally{try{!r&&s.return&&s.return()}finally{if(o)throw n}}},subscribe:function(r){t.add(r)},unsubscribe:function(r){t.delete(r)},unsubscribeAll:function(){t.clear()},trigger:function(r){for(var o=arguments.length,n=Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];var i=!0,a=!1,c=void 0;try{for(var l=t[Symbol.iterator](),u;!(i=(u=l.next()).done);i=!0){var p=u.value;typeof p[r]=="function"&&p[r].apply(p,of(n))}}catch(f){a=!0,c=f}finally{try{!i&&l.return&&l.return()}finally{if(a)throw c}}}})}var sf=function(){function e(t,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};jw(this,e),Hw(this),this.gl=t,this.texture=t.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=r,this.source=null,this.sourceType=null,this.loading=null,this.setData(1,1,new Uint8Array([0,0,0,255]),{filtering:"linear"}),this.setFiltering(o.filtering),this.load(o)}return Bw(e,[{key:"destroy",value:function(){this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,delete this.data,this.data=null,this.valid=!1)}},{key:"bind",value:function(t){this.valid&&(typeof t=="number"&&e.activeUnit!==t&&(this.gl.activeTexture(this.gl.TEXTURE0+t),e.activeUnit=t),e.activeTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),e.activeTexture=this.texture))}},{key:"load",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.loading=null,typeof t.url=="string"?(this.url===void 0||t.url!==this.url)&&this.setUrl(t.url,t):t.element?this.setElement(t.element,t):t.data&&t.width&&t.height&&this.setData(t.width,t.height,t.data,t)}},{key:"setUrl",value:function(t){var r=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.valid)return this.url=t,this.source=this.url,this.sourceType="url",this.loading=new Promise(function(n,s){var i=t.split(".").pop().toLowerCase(),a=i==="ogv"||i==="webm"||i==="mp4",c=void 0;a?(c=document.createElement("video"),c.autoplay=!0,c.muted=!0,setTimeout(function(){c.play()},1),o.filtering="nearest"):c=new Image,c.onload=function(){try{r.setElement(c,o)}catch(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,o)}n(r)},c.onerror=function(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,o),n(r)},RM()&&r.source.slice(0,5)==="data:"||(c.crossOrigin="anonymous"),c.src=r.source,a&&r.setElement(c,o)}),this.loading}},{key:"setData",value:function(t,r,o){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.width=t,this.height=r,this.source=o,this.sourceType="data",this.update(n),this.setFiltering(n),this.loading=Promise.resolve(this),this.loading}},{key:"setElement",value:function(t,r){var o=this,n=t;if(typeof t=="string"&&(t=document.querySelector(t)),t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement)this.source=t,this.sourceType="element",t instanceof HTMLVideoElement?(this.width=this.source.videoWidth,this.height=this.source.videoHeight,t.addEventListener("canplaythrough",function(){o.intervalID=setInterval(function(){o.update(r)},15)},!0),t.addEventListener("ended",function(){t.currentTime=0,t.play()},!0)):this.update(r),this.setFiltering(r);else{var s="the 'element' parameter (element: "+JSON.stringify(n)+") must be a CSS ";s+="selector string, or a <canvas>, <image> or <video> object",console.log("Texture '"+this.name+"': "+s,r)}return this.loading=Promise.resolve(this),this.loading}},{key:"update",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.valid&&(this.bind(),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,t.UNPACK_FLIP_Y_WEBGL!==!1),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.sourceType==="element"&&(this.source instanceof HTMLCanvasElement||this.source instanceof HTMLVideoElement||this.source instanceof HTMLImageElement&&this.source.complete)?(this.source instanceof HTMLVideoElement?(this.width=this.source.videoWidth,this.height=this.source.videoHeight):(this.width=this.source.width,this.height=this.source.height),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.source)):this.sourceType==="data"&&this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.width,this.height,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.source),this.trigger("loaded",this))}},{key:"setFiltering",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.valid){this.powerOf2=$w(this.width)&&$w(this.height),this.filtering=t.filtering||"linear";var r=this.gl;this.bind(),this.powerOf2?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t.TEXTURE_WRAP_S||r.REPEAT),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t.TEXTURE_WRAP_T||r.REPEAT),this.filtering==="mipmap"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.generateMipmap(r.TEXTURE_2D)):this.filtering==="linear"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)):this.filtering==="nearest"&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST))):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),this.filtering==="mipmap"&&(this.filtering="linear"),this.filtering==="nearest"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)))}}}]),e}();sf.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)};sf.activeUnit=-1;var Ww=function(){function e(t,r,o){var n=this;jw(this,e),Hw(this),r=r||{},o=o||{},t.hasAttribute("data-fullscreen")&&(t.getAttribute("data-fullscreen")=="1"||t.getAttribute("data-fullscreen")=="true")?(this.width=window.innerWidth,this.height=window.innerHeight,t.width=window.innerWidth,t.height=window.innerHeight):(this.width=t.clientWidth,this.height=t.clientHeight),this.canvas=t,this.gl=void 0,this.deps={},this.program=void 0,this.textures={},this.buffers={},this.uniforms={},this.vbo={},this.isValid=!1,this.animationFrameRequest=void 0,this.BUFFER_COUNT=0,this.vertexString=r.vertexString||
#ifdef GL_ES
precision mediump float;
#endif
attribute vec2 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
void main() {
gl_Position = vec4(a_position, 0.0, 1.0);
v_texcoord = a_texcoord;
}
,this.fragmentString=r.fragmentString||
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
void main(){
gl_FragColor = vec4(0.0);
}
;var s=bM(t,r,o.onError);if(!s)return;if(this.gl=s,this.timeLoad=this.timePrev=performance.now(),this.timeDelta=0,this.forceRender=!0,this.paused=!1,this.realToCSSPixels=window.devicePixelRatio||1,t.style.backgroundColor=r.backgroundColor||"rgba(1,1,1,0)",t.hasAttribute("data-fragment"))this.fragmentString=t.getAttribute("data-fragment");else if(t.hasAttribute("data-fragment-url")){var i=t.getAttribute("data-fragment-url");Qc.get(i,function(g,y,x){n.load(x,n.vertexString)})}if(t.hasAttribute("data-vertex"))this.vertexString=t.getAttribute("data-vertex");else if(t.hasAttribute("data-vertex-url")){var a=t.getAttribute("data-vertex-url");Qc.get(a,function(g,y,x){n.load(n.fragmentString,x)})}if(this.load(),!this.program)return;var c=s.getAttribLocation(this.program,"a_texcoord");this.vbo.texCoords=s.createBuffer(),this.gl.bindBuffer(s.ARRAY_BUFFER,this.vbo.texCoords),this.gl.bufferData(s.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),s.STATIC_DRAW),this.gl.enableVertexAttribArray(c),this.gl.vertexAttribPointer(c,2,s.FLOAT,!1,0,0);var l=s.getAttribLocation(this.program,"a_position");if(this.vbo.vertices=s.createBuffer(),this.gl.bindBuffer(s.ARRAY_BUFFER,this.vbo.vertices),this.gl.bufferData(s.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),s.STATIC_DRAW),this.gl.enableVertexAttribArray(l),this.gl.vertexAttribPointer(l,2,s.FLOAT,!1,0,0),t.hasAttribute("data-textures")){var u=t.getAttribute("data-textures").split(",");for(var p in u)this.setUniform("u_tex"+p,u[p])}var f={x:0,y:0};document.addEventListener("mousemove",function(g){f.x=g.clientX||g.pageX,f.y=g.clientY||g.pageY},!1);var m=this;function h(){m.nMouse>1&&m.setMouse(f),m.resize()&&(m.forceRender=!0),m.render(),m.animationFrameRequest=window.requestAnimationFrame(h)}return this.setMouse({x:0,y:0}),h(),this}return Bw(e,[{key:"destroy",value:function(){cancelAnimationFrame(this.animationFrameRequest),this.animated=!1,this.isValid=!1;for(var t in this.textures)t.destroy&&t.destroy();this.textures={};for(var r in this.attribs)this.gl.deleteBuffer(this.attribs[r]);this.gl.useProgram(null),this.gl.deleteProgram(this.program);for(var o in this.buffers){var n=this.buffers[o];this.gl.deleteProgram(n.program)}this.program=null,this.gl=null}},{key:"load",value:function(t,r){var o=this;r&&(this.vertexString=r),t&&(this.fragmentString=t);var n=this.fragmentString.split(/\r?\n/);this.fragmentString=#define PLATFORM_WEBGL
#line 0
,n.forEach(function(g,y){var x=g.trim();if(x.startsWith('#include "lygia')){var w=x.substring(15).replace(/\'|\"|\;|\s/g,"");if(w.endsWith("glsl")){if(o.deps[w]===void 0){var k="https://lygia.xyz"+w;o.deps[w]=vM(k)}o.fragmentString+=o.deps[w]+
#line +(y+1)+
}}else o.fragmentString+=g+
}),this.animated=!1,this.nDelta=(this.fragmentString.match(/u_delta/g)||[]).length,this.nTime=(this.fragmentString.match(/u_time/g)||[]).length,this.nDate=(this.fragmentString.match(/u_date/g)||[]).length,this.nMouse=(this.fragmentString.match(/u_mouse/g)||[]).length,this.animated=this.nDate>1||this.nTime>1||this.nMouse>1;var s=this.fragmentString.search(/sampler2D/g);if(s)for(var i=this.fragmentString.split(
),a=0;a<i.length;a++){var c=i[a].match(/uniform\s*sampler2D\s*([\w]*);\s*\/\/\s*([\w|\:\/\/|\.|\-|\_]*)/i);if(c){var l=c[2].split(".").pop().toLowerCase();c[1]&&c[2]&&(l==="jpg"||l==="jpeg"||l==="png"||l==="ogv"||l==="webm"||l==="mp4")&&this.setUniform(c[1],c[2])}var u=i[a].match(/\s*void\s*main\s*/g);if(u)break}var p=as(this,this.vertexString,this.gl.VERTEX_SHADER),f=as(this,this.fragmentString,this.gl.FRAGMENT_SHADER);f?this.isValid=!0:(f=as(this,void main(){
gl_FragColor = vec4(1.0);
},this.gl.FRAGMENT_SHADER),this.isValid=!1);var m=Uw(this,[p,f]);this.gl.useProgram(m),this.gl.deleteShader(p),this.gl.deleteShader(f),this.program=m,this.change=!0,this.BUFFER_COUNT=0;var h=this.getBuffers(this.fragmentString);Object.keys(h).length&&this.loadPrograms(h),this.buffers=h,this.texureIndex=this.BUFFER_COUNT,this.trigger("load",{}),this.forceRender=!0,this.render()}},{key:"test",value:function(t,r,o){var n=this.vertexString,s=this.fragmentString,i=this.paused,a=this.gl.getExtension("EXT_disjoint_timer_query"),c=a.createQueryEXT(),l=this.isValid;(r||o)&&(this.load(r,o),l=this.isValid,this.forceRender=!0,this.render()),this.paused=!0,a.beginQueryEXT(a.TIME_ELAPSED_EXT,c),this.forceRender=!0,this.render(),a.endQueryEXT(a.TIME_ELAPSED_EXT);var u=this;function p(){u.paused=i,(r||o)&&u.load(s,n)}function f(){u.forceRender=!0,u.render();var m=a.getQueryObjectEXT(c,a.QUERY_RESULT_AVAILABLE_EXT),h=u.gl.getParameter(a.GPU_DISJOINT_EXT);if(m&&!h){var g={wasValid:l,frag:r||u.fragmentString,vert:o||u.vertexString,timeElapsedMs:a.getQueryObjectEXT(c,a.QUERY_RESULT_EXT)/1e6};p(),t(g)}else window.requestAnimationFrame(f)}f()}},{key:"loadTexture",value:function(t,r,o){var n=this;o||(o={}),typeof r=="string"?o.url=r:(typeof r>"u"?"undefined":Zc(r))==="object"&&r.data&&r.width&&r.height?(o.data=r.data,o.width=r.width,o.height=r.height):(typeof r>"u"?"undefined":Zc(r))==="object"&&(o.element=r),this.textures[t]?this.textures[t]&&(this.textures[t].load(o),this.textures[t].on("loaded",function(s){n.forceRender=!0})):(this.textures[t]=new sf(this.gl,t,o),this.textures[t].on("loaded",function(s){n.forceRender=!0}))}},{key:"refreshUniforms",value:function(){this.uniforms={}}},{key:"setUniform",value:function(t){for(var r={},o=arguments.length,n=Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];r[t]=n,this.setUniforms(r)}},{key:"setUniforms",value:function(t){var r=nf(t);for(var o in r)r[o].type==="sampler2D"?this.loadTexture(r[o].name,r[o].value[0]):this.uniform(r[o].method,r[o].type,r[o].name,r[o].value);this.forceRender=!0}},{key:"setMouse",value:function(t){var r=this.canvas.getBoundingClientRect();if(t&&t.x&&t.x>=r.left&&t.x<=r.right&&t.y&&t.y>=r.top&&t.y<=r.bottom){var o=(t.x-r.left)*this.realToCSSPixels,n=this.canvas.height-(t.y-r.top)*this.realToCSSPixels;this.uniform("2f","vec2","u_mouse",o,n)}}},{key:"uniform",value:function(t,r,o){this.uniforms[o]=this.uniforms[o]||{};for(var n=this.uniforms[o],s=arguments.length,i=Array(s>3?s-3:0),a=3;a<s;a++)i[a-3]=arguments[a];var c=kM(n.value,i);if(c||this.change||!n.location||!n.value){n.name=o,n.type=r,n.value=i,n.method="uniform"+t,this.gl.useProgram(this.program),n.location=this.gl.getUniformLocation(this.program,o),this.gl[n.method].apply(this.gl,[n.location].concat(n.value));for(var l in this.buffers){var u=this.buffers[l];this.gl.useProgram(u.program);var p=this.gl.getUniformLocation(u.program,o);this.gl[n.method].apply(this.gl,[p].concat(n.value))}}}},{key:"uniformTexture",value:function(t,r,o){if(this.textures[t]===void 0)this.loadTexture(t,r,o);else{this.uniform("1i","sampler2D",t,this.texureIndex);for(var n in this.buffers){var s=this.buffers[n];this.gl.useProgram(s.program),this.gl.activeTexture(this.gl.TEXTURE0+this.texureIndex),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textures[t].texture)}this.gl.useProgram(this.program),this.gl.activeTexture(this.gl.TEXTURE0+this.texureIndex),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textures[t].texture),this.uniform("2f","vec2",t+"Resolution",this.textures[t].width,this.textures[t].height)}}},{key:"resize",value:function(){if(this.width!==this.canvas.clientWidth||this.height!==this.canvas.clientHeight){this.realToCSSPixels=window.devicePixelRatio||1;var t=Math.floor(this.gl.canvas.clientWidth*this.realToCSSPixels),r=Math.floor(this.gl.canvas.clientHeight*this.realToCSSPixels);return(this.gl.canvas.width!==t||this.gl.canvas.height!==r)&&(this.gl.canvas.width=t,this.gl.canvas.height=r,this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height)),this.width=this.canvas.clientWidth,this.height=this.canvas.clientHeight,this.resizeSwappableBuffers(),!0}else return!1}},{key:"render",value:function(){if(this.visible=wM(this.canvas),this.forceRender||this.change||this.animated&&this.visible&&!this.paused){var t=new Date,r=performance.now();this.timeDelta=(r-this.timePrev)/1e3,this.timePrev=r,this.nDelta>1&&this.uniform("1f","float","u_delta",this.timeDelta),this.nTime>1&&this.uniform("1f","float","u_time",(r-this.timeLoad)/1e3),this.nDate&&this.uniform("4f","float","u_date",t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()*3600+t.getMinutes()*60+t.getSeconds()+t.getMilliseconds()*.001),this.uniform("2f","vec2","u_resolution",this.canvas.width,this.canvas.height);for(var o in this.buffers){var n=this.buffers[o];this.uniform("1i","sampler2D",n.name,n.bundle.input.index)}this.texureIndex=this.BUFFER_COUNT;for(var s in this.textures)this.uniformTexture(s),this.texureIndex++;this.renderPrograms(),this.trigger("render",{}),this.change=!1,this.forceRender=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"play",value:function(){this.paused=!1}},{key:"renderPrograms",value:function(){var t=this.gl,r=t.canvas.width,o=t.canvas.height;t.viewport(0,0,r,o);for(var n in this.buffers){var s=this.buffers[n];s.bundle.render(r,o,s.program,s.name),t.bindFramebuffer(t.FRAMEBUFFER,null)}t.useProgram(this.program),t.drawArrays(t.TRIANGLES,0,6)}},{key:"getBuffers",value:function(t){var r={};return t&&t.replace(/(?:^\s*)((?:#if|#elif)(?:\s*)(defined\s*\(\s*BUFFER_)(\d+)(?:\s*\))|(?:#ifdef)(?:\s*BUFFER_)(\d+)(?:\s*))/gm,function(){var o=arguments[3]||arguments[4];r["u_buffer"+o]={fragment:"#define BUFFER_"+o+
+t}}),r}},{key:"loadPrograms",value:function(t){var r=this,o=this.gl,n=as(r,r.vertexString,o.VERTEX_SHADER);for(var s in t){var i=t[s],a=as(r,i.fragment,o.FRAGMENT_SHADER,1);a?r.isValid=!0:(a=as(r,void main(){
gl_FragColor = vec4(1.0);
},o.FRAGMENT_SHADER),r.isValid=!1);var c=Uw(r,[n,a]);i.name=s,i.program=c,i.bundle=r.createSwappableBuffer(r.canvas.width,r.canvas.height,c),o.deleteShader(a)}o.deleteShader(n)}},{key:"createSwappableBuffer",value:function(t,r,o){var n=this.createBuffer(t,r,o),s=this.createBuffer(t,r,o),i=this.gl;return{input:n,output:s,swap:function(){var a=n;n=s,s=a,this.input=n,this.output=s},render:function(a,c,l,u){i.useProgram(l),i.viewport(0,0,a,c),i.bindFramebuffer(i.FRAMEBUFFER,this.input.buffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.output.texture,0),i.drawArrays(i.TRIANGLES,0,6),this.swap()},resize:function(a,c,l,u){i.useProgram(l),i.viewport(0,0,a,c),this.input.resize(a,c),this.output.resize(a,c)}}}},{key:"createBuffer",value:function(t,r,o){var n=this.gl,s=this.BUFFER_COUNT;this.BUFFER_COUNT+=2,n.getExtension("OES_texture_float");var i=n.createTexture();n.activeTexture(n.TEXTURE0+s),n.bindTexture(n.TEXTURE_2D,i),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t,r,0,n.RGBA,n.FLOAT,null),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);var a=n.createFramebuffer();return{index:s,texture:i,buffer:a,W:t,H:r,resize:function(c,l){n.bindFramebuffer(n.FRAMEBUFFER,a);var u=Math.min(c,this.W),p=Math.min(l,this.H),f=new Float32Array(u*p*4);n.readPixels(0,0,u,p,n.RGBA,n.FLOAT,f),n.bindFramebuffer(n.FRAMEBUFFER,null);var m=s+1,h=n.createTexture();n.activeTexture(n.TEXTURE0+m),n.bindTexture(n.TEXTURE_2D,h),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,c,l,0,n.RGBA,n.FLOAT,null),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,u,p,n.RGBA,n.FLOAT,f);var g=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(i),n.activeTexture(n.TEXTURE0+s),n.bindTexture(n.TEXTURE_2D,h),s=this.index=s,i=this.texture=h,a=this.buffer=g,this.W=c,this.H=l}}}},{key:"resizeSwappableBuffers",value:function(){var t=this.gl,r=t.canvas.width,o=t.canvas.height;t.viewport(0,0,r,o);for(var n in this.buffers){var s=this.buffers[n];s.bundle.resize(r,o,s.program,s.name)}t.useProgram(this.program)}},{key:"version",value:function(){return"0.1.7"}}]),e}();function TM(){var e=document.getElementsByClassName("glslCanvas");if(e.length>0){window.glslCanvases=[];for(var t=0;t<e.length;t++){var r=new Ww(e[t]);r.isValid&&window.glslCanvases.push(r)}}}window.addEventListener("load",function(){TM()});var el=Ww;var qw=e=>{if(!("after"in e))return Promise.resolve(void 0);let t=document.createElement("canvas");return new el(t).load(rr(e.after)),e.render(t),Promise.resolve(void 0)};var Gw=e=>{let t="";for(let r=0;r<e.length;r+=3)r+2===e.length?t+=af(e[r],e[r+1],0):r+1===e.length?t+=af(e[r],0,0):t+=af(e[r],e[r+1],e[r+2]);return t},tl=e=>e<10?String.fromCharCode(48+e):(e-=10,e<26?String.fromCharCode(65+e):(e-=26,e<26?String.fromCharCode(97+e):(e-=26,e===0?"-":e===1?"_":"?"))),af=(e,t,r)=>{let o=e>>2,n=(e&3)<<4|t>>4,s=(t&15)<<2|r>>6,i=r&63;return tl(o&63)+tl(n&63)+tl(s&63)+tl(i&63)};var zw=async(e,t="svg")=>{let r=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream("deflate")),o=new Uint8Array(await new Response(r).arrayBuffer());returnhttps://www.plantuml.com/plantuml/${t}/~1${Gw(o)}};var Vw=async e=>{if(!("after"in e))return;let t=document.createElement("img"),r=await zw(rr(e.after));t.src=r,e.render(t)};var cf=Promise.resolve({log:new Uint8Array(0)}),rl,Kw=(e,t,r,o)=>(cf=(async()=>{await cf,rl??=await _M(t,r);let n=new Promise(i=>{let a=c=>{if(c.data.type==="stdout"){o(c.data.message);return}c.data.type==="compile"&&(i(c.data),rl.removeEventListener("message",a))};rl.addEventListener("message",a)}),s={type:"compile",input:e};return rl.postMessage(s),n})(),cf),_M=async(e,t)=>{let r=new Worker(e,{type:"module"}),o=new Promise(s=>{let i=a=>{a.data.type==="asset-url"&&(s(),r.removeEventListener("message",i))};r.addEventListener("message",i)}),n={type:"asset-url",url:${t}};return r.postMessage(n),await o,r};var Yw=(e,t)=>async r=>{if(!("after"in r))return;let o=PM(),n="Compile is not started yet. Please wait...",s=l=>{n=[...n.split(
),l].join(
),o.log(n)},i=document.createElement("img"),a=setTimeout(()=>{r.render(o.div),o.log(n)},2e3),{svg:c}=await Kw(rr(r.after),e,t,s);if(clearTimeout(a),!c){r.render(o.div),o.log(n);return}i.src=await bi(new Blob([c],{type:"image/svg+xml"})),r.render(i)},PM=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent='*{box-sizing:border-box;}pre{display:block;padding:9.5px;margin:0 0 10px;border:1px solid #ccc;border-radius:4px;height:20em;overflow:auto;font-size:13px;line-height:1.428571429;}pre code{padding:0;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:inherit;word-break:break-all;word-wrap:break-word;white-space:pre-wrap;color:var(--code-color,#342d9c);background-color: rgba(0,0,0,0);border-radius:0;}',t.append(r);let o=document.createElement("pre"),n=document.createElement("code");return o.append(n),t.append(o),{div:e,log:s=>{n.textContent=s,o.scroll(0,o.scrollHeight)}}};function Kt(e,t){return Ne(e,{...t,weekStartsOn:1})}function En(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=C(r,0);n.setFullYear(o+1,0,4),n.setHours(0,0,0,0);let s=Kt(n),i=C(r,0);i.setFullYear(o,0,4),i.setHours(0,0,0,0);let a=Kt(i);return r.getTime()>=s.getTime()?o+1:r.getTime()>=a.getTime()?o:o-1}function wi(e,t){let r=En(e,t),o=C(t?.in||e,0);return o.setFullYear(r,0,4),o.setHours(0,0,0,0),Kt(o)}function lf(e,t){let r,o=t?.in;return e.forEach(n=>{!o&&typeof n=="object"&&(o=C.bind(null,n));let s=E(n,o);(!r||r<s||isNaN(+s))&&(r=s)}),C(o,r||NaN)}function Ri(e,t,r){let o=Ha(e,t)/1e3;return Yo(r?.roundingMethod)(o)}function ol(e){return(t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}function cs(e){return(t,r)=>{let o=r?.context?String(r.context):"standalone",n;if(o==="formatting"&&e.formattingValues){let i=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):i;n=e.formattingValues[a]||e.formattingValues[i]}else{let i=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;n=e.values[a]||e.values[i]}let s=e.argumentCallback?e.argumentCallback(t):t;return n[s]}}var FM={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},DM={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},UM={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},$M={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},jM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},BM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},HM=(e,t)=>{let r=Number(e),o=r%100;if(o>20||o<10)switch(o%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},WM={ordinalNumber:HM,era:cs({values:FM,defaultWidth:"wide"}),quarter:cs({values:DM,defaultWidth:"wide",argumentCallback:e=>e-1}),month:cs({values:UM,defaultWidth:"wide"}),day:cs({values:$M,defaultWidth:"wide"}),dayPeriod:cs({values:jM,defaultWidth:"wide",formattingValues:BM,defaultFormattingWidth:"wide"})};function ls(e){return(t,r={})=>{let o=r.width,n=o&&e.matchPatterns[o]||e.matchPatterns[e.defaultMatchWidth],s=t.match(n);if(!s)return null;let i=s[0],a=o&&e.parsePatterns[o]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?GM(a,p=>p.test(i)):qM(a,p=>p.test(i)),l;l=e.valueCallback?e.valueCallback(c):c,l=r.valueCallback?r.valueCallback(l):l;let u=t.slice(i.length);return{value:l,rest:u}}}function qM(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function GM(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function Zw(e){return(t,r={})=>{let o=t.match(e.matchPattern);if(!o)return null;let n=o[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=r.valueCallback?r.valueCallback(i):i;let a=t.slice(n.length);return{value:i,rest:a}}}var zM=/^(\d+)(th|st|nd|rd)?/i,VM=/\d+/i,KM={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},YM={any:[/^b/i,/^(a|c)/i]},XM={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},JM={any:[/1/i,/2/i,/3/i,/4/i]},QM={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},ZM={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},e1={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},t1={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},r1={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},o1={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},n1={ordinalNumber:Zw({matchPattern:zM,parsePattern:VM,valueCallback:e=>parseInt(e,10)}),era:ls({matchPatterns:KM,defaultMatchWidth:"wide",parsePatterns:YM,defaultParseWidth:"any"}),quarter:ls({matchPatterns:XM,defaultMatchWidth:"wide",parsePatterns:JM,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ls({matchPatterns:QM,defaultMatchWidth:"wide",parsePatterns:ZM,defaultParseWidth:"any"}),day:ls({matchPatterns:e1,defaultMatchWidth:"wide",parsePatterns:t1,defaultParseWidth:"any"}),dayPeriod:ls({matchPatterns:r1,defaultMatchWidth:"any",parsePatterns:o1,defaultParseWidth:"any"})};var s1={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},i1={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},a1={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},gSe={date:ol({formats:s1,defaultWidth:"full"}),time:ol({formats:i1,defaultWidth:"full"}),dateTime:ol({formats:a1,defaultWidth:"full"})};function pf(e,t){let r=E(e,t?.in),o=+Kt(r)-+wi(r);return Math.round(o/Go)+1}function eR(e,t){let r=E(e,t?.in).getDay();return r===0?7:r}function uf(e){return Math.trunc(+E(e)/1e3)}function rR(e,t,r){let o=E(e,r?.in),n=pf(o,r)-t;return o.setDate(o.getDate()-n*7),o}function us(e,t,r){let o=br(),n=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0,s=E(e,r?.in),i=s.getDay(),a=(t%7+7)%7,c=7-n,l=t<0||t>6?t-(i+c)%7:(a+c)%7-(i+c)%7;return ve(s,l,r)}function oR(e,t,r){let o=E(e,r?.in),n=eR(o,r),s=t-n;return ve(o,s,r)}var y1=class{subPriority=0;validate(e,t){return!0}},x1=class extends y1{constructor(e,t,r,o,n){super(),this.value=e,this.validateValue=t,this.setValue=r,this.priority=o,n&&(this.subPriority=n)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,r){return this.setValue(e,t,this.value,r)}};var he=class{run(e,t,r,o){let n=this.parse(e,t,r,o);return n?{setter:new x1(n.value,this.validate,this.set,this.priority,this.subPriority),rest:n.rest}:null}validate(e,t,r){return!0}},b1=class extends he{priority=140;parse(e,t,r){switch(t){case"G":case"GG":case"GGG":return r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"});case"GGGGG":return r.era(e,{width:"narrow"});case"GGGG":default:return r.era(e,{width:"wide"})||r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"})}}set(e,t,r){return t.era=r,e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]},Qe={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},Ur={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function Ze(e,t){return e&&{value:t(e.value),rest:e.rest}}function $e(e,t){let r=t.match(e);return r?{value:parseInt(r[0],10),rest:t.slice(r[0].length)}:null}function $r(e,t){let r=t.match(e);if(!r)return null;if(r[0]==="Z")return{value:0,rest:t.slice(1)};let o=r[1]==="+"?1:-1,n=r[2]?parseInt(r[2],10):0,s=r[3]?parseInt(r[3],10):0,i=r[5]?parseInt(r[5],10):0;return{value:o*(n*wo+s*Sr+i*ja),rest:t.slice(r[0].length)}}function nR(e){return $e(Qe.anyDigitsSigned,e)}function We(e,t){switch(e){case 1:return $e(Qe.singleDigit,t);case 2:return $e(Qe.twoDigits,t);case 3:return $e(Qe.threeDigits,t);case 4:return $e(Qe.fourDigits,t);default:return $e(new RegExp("^\\d{1,"+e+"}"),t)}}function nl(e,t){switch(e){case 1:return $e(Qe.singleDigitSigned,t);case 2:return $e(Qe.twoDigitsSigned,t);case 3:return $e(Qe.threeDigitsSigned,t);case 4:return $e(Qe.fourDigitsSigned,t);default:return $e(new RegExp("^-?\\d{1,"+e+"}"),t)}}function mf(e){switch(e){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function sR(e,t){let r=t>0,o=r?t:1-t,n;if(o<=50)n=e||100;else{let s=o+50,i=Math.trunc(s/100)*100,a=e>=s%100;n=e+i-(a?100:0)}return r?n:1-n}function iR(e){return e%400===0||e%4===0&&e%100!==0}var E1=class extends he{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){let o=n=>({year:n,isTwoDigitYear:t==="yy"});switch(t){case"y":return Ze(We(4,e),o);case"yo":return Ze(r.ordinalNumber(e,{unit:"year"}),o);default:return Ze(We(t.length,e),o)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){let o=e.getFullYear();if(r.isTwoDigitYear){let s=sR(r.year,o);return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}let n=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}},w1=class extends he{priority=130;parse(e,t,r){let o=n=>({year:n,isTwoDigitYear:t==="YY"});switch(t){case"Y":return Ze(We(4,e),o);case"Yo":return Ze(r.ordinalNumber(e,{unit:"year"}),o);default:return Ze(We(t.length,e),o)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,o){let n=Vo(e,o);if(r.isTwoDigitYear){let i=sR(r.year,n);return e.setFullYear(i,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ne(e,o)}let s=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(s,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ne(e,o)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},R1=class extends he{priority=130;parse(e,t){return nl(t==="R"?4:t.length,e)}set(e,t,r){let o=C(e,0);return o.setFullYear(r,0,4),o.setHours(0,0,0,0),Kt(o)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},k1=class extends he{priority=130;parse(e,t){return nl(t==="u"?4:t.length,e)}set(e,t,r){return e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},v1=class extends he{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return We(t.length,e);case"Qo":return r.ordinalNumber(e,{unit:"quarter"});case"QQQ":return r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(e,{width:"wide",context:"formatting"})||r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},T1=class extends he{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return We(t.length,e);case"qo":return r.ordinalNumber(e,{unit:"quarter"});case"qqq":return r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return r.quarter(e,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(e,{width:"wide",context:"standalone"})||r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},_1=class extends he{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){let o=n=>n-1;switch(t){case"M":return Ze($e(Qe.month,e),o);case"MM":return Ze(We(2,e),o);case"Mo":return Ze(r.ordinalNumber(e,{unit:"month"}),o);case"MMM":return r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return r.month(e,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(e,{width:"wide",context:"formatting"})||r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}},P1=class extends he{priority=110;parse(e,t,r){let o=n=>n-1;switch(t){case"L":return Ze($e(Qe.month,e),o);case"LL":return Ze(We(2,e),o);case"Lo":return Ze(r.ordinalNumber(e,{unit:"month"}),o);case"LLL":return r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return r.month(e,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(e,{width:"wide",context:"standalone"})||r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},O1=class extends he{priority=100;parse(e,t,r){switch(t){case"w":return $e(Qe.week,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return We(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,o){return Ne(qa(e,r,o),o)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},S1=class extends he{priority=100;parse(e,t,r){switch(t){case"I":return $e(Qe.week,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return We(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){return Kt(rR(e,r))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},L1=[31,28,31,30,31,30,31,31,30,31,30,31],N1=[31,29,31,30,31,30,31,31,30,31,30,31],M1=class extends he{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return $e(Qe.date,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return We(t.length,e)}}validate(e,t){let r=e.getFullYear(),o=iR(r),n=e.getMonth();return o?t>=1&&t<=N1[n]:t>=1&&t<=L1[n]}set(e,t,r){return e.setDate(r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},C1=class extends he{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return $e(Qe.dayOfYear,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return We(t.length,e)}}validate(e,t){let r=e.getFullYear();return iR(r)?t>=1&&t<=366:t>=1&&t<=365}set(e,t,r){return e.setMonth(0,r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},I1=class extends he{priority=90;parse(e,t,r){switch(t){case"E":case"EE":case"EEE":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return r.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEE":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=us(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},A1=class extends he{priority=90;parse(e,t,r,o){let n=s=>{let i=Math.floor((s-1)/7)*7;return(s+o.weekStartsOn+6)%7+i};switch(t){case"e":case"ee":return Ze(We(t.length,e),n);case"eo":return Ze(r.ordinalNumber(e,{unit:"day"}),n);case"eee":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeeee":return r.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeee":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=us(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},F1=class extends he{priority=90;parse(e,t,r,o){let n=s=>{let i=Math.floor((s-1)/7)*7;return(s+o.weekStartsOn+6)%7+i};switch(t){case"c":case"cc":return Ze(We(t.length,e),n);case"co":return Ze(r.ordinalNumber(e,{unit:"day"}),n);case"ccc":return r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"ccccc":return r.day(e,{width:"narrow",context:"standalone"});case"cccccc":return r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"cccc":default:return r.day(e,{width:"wide",context:"standalone"})||r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=us(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},D1=class extends he{priority=90;parse(e,t,r){let o=n=>n===0?7:n;switch(t){case"i":case"ii":return We(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return Ze(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o);case"iiiii":return Ze(r.day(e,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Ze(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Ze(r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){return e=oR(e,r),e.setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},U1=class extends he{priority=80;parse(e,t,r){switch(t){case"a":case"aa":case"aaa":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(mf(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},$1=class extends he{priority=80;parse(e,t,r){switch(t){case"b":case"bb":case"bbb":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(mf(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},j1=class extends he{priority=80;parse(e,t,r){switch(t){case"B":case"BB":case"BBB":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(mf(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},B1=class extends he{priority=70;parse(e,t,r){switch(t){case"h":return $e(Qe.hour12h,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return We(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){let o=e.getHours()>=12;return o&&r<12?e.setHours(r+12,0,0,0):!o&&r===12?e.setHours(0,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},H1=class extends he{priority=70;parse(e,t,r){switch(t){case"H":return $e(Qe.hour23h,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return We(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,r){return e.setHours(r,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]},W1=class extends he{priority=70;parse(e,t,r){switch(t){case"K":return $e(Qe.hour11h,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return We(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.getHours()>=12&&r<12?e.setHours(r+12,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]},q1=class extends he{priority=70;parse(e,t,r){switch(t){case"k":return $e(Qe.hour24h,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return We(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){let o=r<=24?r%24:r;return e.setHours(o,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},G1=class extends he{priority=60;parse(e,t,r){switch(t){case"m":return $e(Qe.minute,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return We(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setMinutes(r,0,0),e}incompatibleTokens=["t","T"]},z1=class extends he{priority=50;parse(e,t,r){switch(t){case"s":return $e(Qe.second,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return We(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},V1=class extends he{priority=30;parse(e,t){let r=o=>Math.trunc(o*Math.pow(10,-t.length+3));return Ze(We(t.length,e),r)}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},K1=class extends he{priority=10;parse(e,t){switch(t){case"X":return $r(Ur.basicOptionalMinutes,e);case"XX":return $r(Ur.basic,e);case"XXXX":return $r(Ur.basicOptionalSeconds,e);case"XXXXX":return $r(Ur.extendedOptionalSeconds,e);case"XXX":default:return $r(Ur.extended,e)}}set(e,t,r){return t.timestampIsSet?e:C(e,e.getTime()-Jr(e)-r)}incompatibleTokens=["t","T","x"]},Y1=class extends he{priority=10;parse(e,t){switch(t){case"x":return $r(Ur.basicOptionalMinutes,e);case"xx":return $r(Ur.basic,e);case"xxxx":return $r(Ur.basicOptionalSeconds,e);case"xxxxx":return $r(Ur.extendedOptionalSeconds,e);case"xxx":default:return $r(Ur.extended,e)}}set(e,t,r){return t.timestampIsSet?e:C(e,e.getTime()-Jr(e)-r)}incompatibleTokens=["t","T","X"]},X1=class extends he{priority=40;parse(e){return nR(e)}set(e,t,r){return[C(e,r*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"},J1=class extends he{priority=20;parse(e){return nR(e)}set(e,t,r){return[C(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"},s1e={G:new b1,y:new E1,Y:new w1,R:new R1,u:new k1,Q:new v1,q:new T1,M:new _1,L:new P1,w:new O1,I:new S1,d:new M1,D:new C1,E:new I1,e:new A1,c:new F1,i:new D1,a:new U1,b:new $1,B:new j1,h:new B1,H:new H1,K:new W1,k:new q1,m:new G1,s:new z1,S:new V1,X:new K1,x:new Y1,t:new X1,T:new J1};var aR=(e,t,r=0,o=[])=>{let[n,s]=Q("uninitialized"),[i,a]=Q({ok:!0,value:t}),c=U(e,o);return te(()=>{(async()=>{let l=setTimeout(()=>s("pending"),r);try{let u=await c();if(u===void 0)return;a({ok:!0,value:u})}catch(u){a({ok:!1,value:u})}finally{clearTimeout(l),s("resolved")}})()},[c,r,...o]),i.ok?{result:i.value,state:n}:{result:i.value,state:"rejected"}};var cR=e=>{let t=e.flatMap(({changes:n,created:s,userId:i})=>n.flatMap(a=>{let c=oC(a,i,s);return c?[c]:[]})),r=[...new Set(t.map(({created:n})=>n))].sort();return{history:t.reduce((n,s)=>{if(s.type==="insert"){let a=new Map;a.set(s.created,{text:s.text,type:s.type,userId:s.userId});let c={id:s.id,snapshots:a};if(s.parentId==="_end")return[...n,c];let l=n.findIndex(({id:u})=>u===s.parentId);return l<0?(console.warn("[scrapbox-snapshot@0.1.0] The parent line the snapshot would insert before is not found. change: ",s),[...n,c]):[...n.slice(0,l),c,...n.slice(l)]}let i=n.findIndex(({id:a})=>a===s.id);return i<0?(console.warn("[scrapbox-snapshot@0.1.0] The line data to be append the change is not found. change: ",s),n):(n[i].snapshots.set(s.created,{text:s.type==="update"?s.text:void 0,type:s.type,userId:s.userId}),n)},[]),range:r}},oC=(e,t,r)=>{if("_insert"in e)return{type:"insert",id:e.lines.id,parentId:e._insert,text:e.lines.text,userId:t,created:r};if("_update"in e)return{type:"update",id:e._update,text:e.lines.text,userId:t,created:r};if("_delete"in e)return{type:"delete",id:e._delete,userId:t,created:r}};var Yt=e=>{let{fetch:t=(n,s)=>globalThis.fetch(n,s),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var Xt=e=>connect.sid=${e};var nC=(e,t,r)=>{let{sid:o,baseURL:n,head:s}=Yt(r??{});return new Request(${n}api/commits/${e}/${t}?head=${s??""},o?{headers:{Cookie:Xt(o)}}:void 0)},lR=(e,t,r)=>Yt(r??{}).fetch(nC(e,t,r));var uR=async(e,t)=>{let r=await lR(e,t);if(!r.ok)throw new Error(Failed to fetch commits for ${e}/${t}: ${r.statusText},{cause:r});return cR((await r.json()).commits)};var mR=()=>{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=>Rt(d(aC,{getController:o=>r(o)}),t))},aC=({getController:e})=>{let[t,r]=Q(!0),o=U(()=>r(!1),[]),n=U(()=>r(!0),[]),s=U(()=>r(h=>!h),[]);te(()=>e({open:o,close:n,toggle:s}),[e]);let i=U(h=>{h.target instanceof HTMLElement&&h.target.id==="background"&&n()},[]),{state:a,result:c}=aR(async()=>{if(t||scrapbox.Layout!=="page")return;let h=await uR(scrapbox.Project.name,scrapbox.Page.id);return{range:h.range,getSnapshot:g=>h.history.flatMap(({snapshots:y})=>{let x=y.get(g);if(x)return x.text===void 0?[]:[x.text];let w=Math.max(...[...y.keys()].filter(b=>b<g));if(w===g)return[];let k=y.get(w)?.text;return k===void 0?[]:[k]})}},{range:[],getSnapshot:()=>[]},1e3,[t]),[l,u]=Q(0),[p,f]=Q(0);te(()=>{if(a!=="resolved")return;let h=Math.max(0,c.range.length-1);u(h),f(h)},[c]);let m=U(h=>f(parseInt(h.currentTarget.value)),[]);return d(ee,{children:[d("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}'}),d("div",{id:"background",className:modal${t?" closed":""},onClick:i,children:[d("div",{className:"controller",children:[d("button",{type:"button",className:"close-button",onClick:n,children:"x"}),a==="resolved"&&c.range.length===0&&d("span",{className:"not-found",children:"no history found."}),a!=="rejected"&&c.range.length>0&&d(ee,{children:[d("input",{type:"range",max:l,min:"0",step:"1",value:p,title:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss"),onInput:m}),d("time",{dateTime:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss"),children:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss")})]})]}),a!=="rejected"?d("div",{className:"viewer",children:d("pre",{children:c.getSnapshot(c.range[p]).join(
)})}):d("div",{className:"error viewer",children:Error: ${JSON.stringify(c)}})]})]})};var wn=()=>/mobile/i.test(navigator.userAgent);function fR(e){return Ke(e)?L(e):(K(e),e)}var cC=Object.defineProperty,lC=(e,t)=>{for(var r in t)cC(e,r,{get:t[r],enumerable:!0})},pC={};lC(pC,{andThen:()=>vp,andThenAsync:()=>Tp,inspect:()=>_p,map:()=>Pp,mapAsync:()=>Op,mapOr:()=>Sp,mapOrAsync:()=>Lp,mapOrElse:()=>Np,mapOrElseAsync:()=>Mp,okOr:()=>Cp,okOrElse:()=>Is,okOrElseAsync:()=>Ip,orElse:()=>Ap,orElseAsync:()=>Fp,toNullable:()=>Dp,toResultErr:()=>Up,toResultOk:()=>ua,toUndefinable:()=>$p,transposeToResult:()=>fR,unwrapOr:()=>As,unwrapOrElse:()=>jp,unwrapOrElseAsync:()=>Bp});function dR(e,t){return tt(e)?e:t(e)}async function hR(e,t){return tt(e)?null:await t(e)}function gR(e,t){return je(e)&&t(e),e}function yR(e,t){if(tt(e))return e;let r=t(e);return rt(r,nr)}async function xR(e,t){if(tt(e))return null;let r=await t(e);return rt(r,nr)}function bR(e,t,r){let o,n="";return e!==null?(o=r(e),n=nr):(o=t,n=Mn),rt(o,n)}async function ER(e,t,r){if(tt(e))return rt(t,Mn);let o=await r(e);return rt(o,nr)}function wR(e,t,r){let o,n="";return je(e)?(o=r(e),n=nr):(o=t(),n=po),rt(o,n)}async function RR(e,t,r){let o,n="";return je(e)?(o=await r(e),n=nr):(o=await t(),n=po),rt(o,n)}function kR(e,t){return je(e)?L(e):M(t)}function vR(e,t){if(je(e))return L(e);let r=t();return M(r)}async function TR(e,t){if(je(e))return L(e);let r=await t();return M(r)}function _R(e,t){return e!==null?e:t()}async function PR(e,t){return je(e)?e:await t()}function OR(e){return tt(e)?M(void 0):L(e)}function SR(e){return tt(e)?L(void 0):M(e)}function LR(e){if(!tt(e))return e}function NR(e){return tt(e)?L(null):(K(e),e)}function MR(e,t){return je(e)?e:rt(t,Mn)}function CR(e,t){if(je(e))return e;let r=t();return rt(r,po)}async function IR(e,t){if(je(e))return e;let r=await t();return rt(r,po)}var uC=Object.defineProperty,mC=(e,t)=>{for(var r in t)uC(e,r,{get:t[r],enumerable:!0})},fC={};mC(fC,{andThen:()=>dR,andThenAsync:()=>hR,inspect:()=>gR,map:()=>yR,mapAsync:()=>xR,mapOr:()=>bR,mapOrAsync:()=>ER,mapOrElse:()=>wR,mapOrElseAsync:()=>RR,okOr:()=>kR,okOrElse:()=>vR,okOrElseAsync:()=>TR,orElse:()=>_R,orElseAsync:()=>PR,toResultErr:()=>SR,toResultOk:()=>OR,toUndefinable:()=>LR,transposeToResult:()=>NR,unwrapOr:()=>MR,unwrapOrElse:()=>CR,unwrapOrElseAsync:()=>IR});function AR(e,t){return nt(e)?e:t(e)}async function FR(e,t){return nt(e)?void 0:await t(e)}function DR(e,t){return ot(e)&&t(e),e}function UR(e,t){if(nt(e))return e;let r=t(e);return st(r,sr)}async function $R(e,t){if(nt(e))return;let r=await t(e);return st(r,sr)}function jR(e,t,r){let o,n="";return e!==void 0?(o=r(e),n=sr):(o=t,n=Cn),st(o,n)}async function BR(e,t,r){if(nt(e))return st(t,Cn);let o=await r(e);return st(o,sr)}function HR(e,t,r){let o,n="";return e!==void 0?(o=r(e),n=sr):(o=t(),n=uo),st(o,n)}async function WR(e,t,r){let o,n="";return ot(e)?(o=await r(e),n=sr):(o=await t(),n=uo),st(o,n)}function qR(e,t){return ot(e)?L(e):M(t)}function GR(e,t){if(ot(e))return L(e);let r=t();return M(r)}async function zR(e,t){if(ot(e))return L(e);let r=await t();return M(r)}function VR(e,t){return e!==void 0?e:t()}async function KR(e,t){return ot(e)?e:await t()}function YR(e){return nt(e)?null:e}function XR(e){return nt(e)?M(void 0):L(e)}function JR(e){return nt(e)?L(void 0):M(e)}function QR(e){return nt(e)?L(void 0):(K(e),e)}function ZR(e,t){return ot(e)?e:st(t,Cn)}function ek(e,t){if(ot(e))return e;let r=t();return st(r,uo)}async function tk(e,t){if(ot(e))return e;let r=await t();return st(r,uo)}var dC=Object.defineProperty,hC=(e,t)=>{for(var r in t)dC(e,r,{get:t[r],enumerable:!0})},gC={};hC(gC,{andThen:()=>AR,andThenAsync:()=>FR,inspect:()=>DR,map:()=>UR,mapAsync:()=>$R,mapOr:()=>jR,mapOrAsync:()=>BR,mapOrElse:()=>HR,mapOrElseAsync:()=>WR,okOr:()=>qR,okOrElse:()=>GR,okOrElseAsync:()=>zR,orElse:()=>VR,orElseAsync:()=>KR,toNullable:()=>YR,toResultErr:()=>JR,toResultOk:()=>XR,transposeToResult:()=>QR,unwrapOr:()=>ZR,unwrapOrElse:()=>ek,unwrapOrElseAsync:()=>tk});var sl=class{#o=[];#r;#t;constructor(t){if(t<=0||!Number.isSafeInteger(t))throw new RangeError(size must be a positive safe integer, got ${t});this.#r=t,this.#t=t}get locked(){return this.#r===0}get waiterCount(){return this.#o.length}acquire(){if(this.#r>0)return this.#r-=1,Promise.resolve();{let{promise:t,resolve:r}=Promise.withResolvers();return this.#o.push(r),t}}release(){let t=this.#o.shift();t?t():this.#r<this.#t&&(this.#r+=1)}};var il=class{#o;constructor(t){this.#o=new sl(t)}get locked(){return this.#o.locked}get waiterCount(){return this.#o.waiterCount}async lock(t){await this.#o.acquire();try{return await t()}finally{this.#o.release()}}};async function*rk(e,t){if(e.length===0||e.every(({before:n,after:s})=>n===s))return;let r=S(await Mt()),o=new il(5);try{yield*new ReadableStream({async start(n){let s=[];for(let i of e){if(i.before===i.after){n.enqueue({link:i,projectCount:0,replaced:0,done:!0});continue}let a=0,c=0,l=[];for(let u of new Set(t))l.push(o.lock(async()=>{let p=await yC(i,u,r);if(O(p)){n.error(xC(Z(p)));return}a++,c+=S(p),n.enqueue({link:i,projectCount:a,replaced:c,done:!1})}));s.push(Promise.all(l).then(()=>n.enqueue({link:i,projectCount:a,replaced:c,done:!0})))}await Promise.all(s),n.close()}})}finally{await Ct(r)}}var yC=async(e,t,r)=>{let[o]=await Promise.all([da(t,e.before,e.after),Le(t,e.before,(n,{persistent:s})=>{if(s)return[e.after,...n.map(i=>i.text).slice(1)]},{socket:r})]);return o},so=e=>e.split(
).flatMap(t=>[...t.matchAll(/\[((?:[^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~] |.[^ ]*)[^\[\]]*)\]/g)]).map(([,t])=>t),xC=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var ok=e=>it(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return bC(r);case"table":return EC(r);case"line":return wC(r)}}).map(r=>r).join(
),bC=({fileName:e,content:t,indent:r})=>{let o=" ".repeat(r);return[${o}code:${e},...t.split(
).map(n=>${o} ${n})]},EC=({fileName:e,cells:t,indent:r})=>{let o=" ".repeat(r);return[${o}table:${e},...t.map(n=>${o} ${n.map(s=>s.map(i=>ki(i)).join("")).join(" ")})]},wC=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${ki(r)}).join("")}],ki=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>ki(t)).join("")};case"strong":return${e.nodes.map(t=>ki(t)).join("")};case"decoration":{let t=e.decos.map(r=>{let o=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return o>0?"*".repeat(o):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>ki(r)).join("")}]}case"hashTag":return e.href;case"link":return e.pathType==="absolute"?e.raw:e.href;default:return e.raw}};scrapbox.PopupMenu.addButton({title:e=>so(e).length>0?"":"",onClick:e=>{let t=ok(e);if(e!=t)return t}});var nk=e=>!e.includes(
)&&/\[[^\]]+\]/.test(e);scrapbox.PopupMenu.addButton({title:e=>nk(e)?"[][]":"",onClick:e=>{if(!nk(e))return;let t=e.replaceAll("[","").replaceAll("]","");return(async()=>{let{render:r,dispose:o}=De();try{let n=scrapbox.Project.name;r({type:"spinner"},{type:"text",text:create /${n}/${t}}),await Le(n,t,([{text:s}],{persistent:i})=>{if(!i)return[s,e]}),r({type:"check-circle"},{type:"text",text:create /${n}/${t}})}catch(n){if(console.error(n),!(n instanceof Error))throw n;r({type:"exclamation-triangle"},{type:"text",text:${n.name} ${n.message}})}finally{await Fe(2e3),o()}})(),${t}}});var ik=(e,t)=>{switch(e.type){case"title":return"";case"codeBlock":return[e.fileName,
\\`\`${OC(e.fileName)},e.content,"\n"].join(
);case"table":return RC(e);case"line":return vC(e,t)}},RC=e=>{let t=[e.fileName],r=Math.max(...e.cells.map(o=>o.length));return e.cells.forEach((o,n)=>{t.push(| ${o.map(s=>s.map(i=>ds(i)).join("")).join(" | ")} |),n===0&&t.push(|${" -- |".repeat(r)})}),t.join(
)},kC=" ",vC=(e,t)=>{let r=e.nodes.map(n=>ds(n,{section:e.indent===t})).join("").trim();if(r==="")return"";if(e.indent===t)return r;let o=kC.repeat(e.indent-t-1);return/^\d+\. /.test(r)||(o+="- "),o+r},ds=(e,t)=>{let{section:r=!1}=t??{};switch(e.type){case"quote":return> ${e.nodes.map(o=>ds(o)).join("")};case"helpfeel":return\? ${e.text}\`;case"image":case"strongImage":return![image](${e.src});case"icon":case"strongIcon":return"/icons/hr","/scrapboxlab/hr".includes(e.path)?"---":"";case"strong":return**${e.nodes.map(o=>ds(o)).join("")}**;case"formula":return$${e.formula}$;case"decoration":{let o=e.nodes.map(n=>ds(n)).join("");return e.decos.includes("/")&&(o=*${o}*),r?(e.decos.includes("*-3")&&(o=`# ${o}
),e.decos.includes("*-2")&&(o=## ${o}
),e.decos.includes("*-1")&&(o=### ${o}
)):e.decos.some(n=>/\*-/.test(n[0]))&&(o=**${o}**),e.decos.includes("~")&&(o=~~${o}~~),o}case"code":return\${e.text}\`;case"commandLine":return\`${e.symbol} ${e.text}\`;case"link":switch(e.pathType){case"root":{let,o,...n=e.href.split("/");return[${e.href}](https://scrapbox.io/${o}/${sk(n.join("/"))})}case"relative":return[${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${sk(e.href)});default:return e.content===""? ${e.href} :[${e.content}](${e.href})}case"googleMap":return[${e.place}](${e.url});case"hashTag":return[#${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${e.href});case"numberList":return${e.number}. ${e.nodes.map(o=>ds(o)).join("")};case"blank":case"plain":return e.text}},sk=e=>...e.map((t,r)=>t===" "?"_":!TC.includes(t)||r===e.length-1&&_C.includes(t)?encodeURIComponent(t):t).join(""),TC='@$&+=:;",',_C=':;",',PC=[{extensions:"javascript","js",fileType:"javascript"},{extensions:"typescript","ts",fileType:"typescript"},{extensions:"cpp","hpp",fileType:"cpp"},{extensions:"c","cc","h",fileType:"c"},{extensions:"cs","csharp",fileType:"cs"},{extensions:"markdown","md",fileType:"markdown"},{extensions:"htm","html",fileType:"html"},{extensions:"json",fileType:"json"},{extensions:"xml",fileType:"xml"},{extensions:"yaml","yml",fileType:"yaml"},{extensions:"toml",fileType:"toml"},{extensions:"ini",fileType:"ini"},{extensions:"tex","sty",fileType:"tex"},{extensions:"svg",fileType:"svg"}],OC=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return PC.find(r=>r.extensions.includes(t))?.fileType??""};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{(async()=>{try{let t=dc.parse(e,{hasTitle:!1}),r=Math.min(...t.map(o=>o.indent));await navigator.clipboard.writeText(t.map(o=>ik(o,r)).join(`
))}catch(t){alert(Failed to copy:
${JSON.stringify(t)})}})()}});var ak=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var ck=()=>SC(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),SC=(e,t)=>{if(e)return ak(e,t),e};var lk=()=>{let e=ck();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=pk(...r);o&&t.append(o)},dispose:()=>t.remove(),[Symbol.dispose]:()=>t.remove()}},pk=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":return[IC()];case"check-circle":return[AC()];case"exclamation-triangle":return[FC()];case"text":return[cl(o.text)];case"group":{let n=pk(...o.items);return n?[n]:[]}}});if(t.length===0)return;if(t.length===1)return t[0];let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},cl=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},IC=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),cl(e)},AC=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),cl(e)},FC=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),cl(e)};var df=(e,...t)=>{let r=t.reduce((o,n)=>ke(o)?o:o instanceof Promise?o.then(s=>ke(s)?s:n(s)):n(o),e);return r instanceof Promise?r.then(o=>${o}):${e}};var hs=e=>e.ok?L(e):M({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var uk=e=>window.GM_fetch?.(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x)?.then?.(t=>ie(hs(t),r=>r.json()));function St(e){return e.val}function Ut(e){return e.err}var mk=" must not return ",UC="transformer",$C="recoverer",jC="defaultValue",gs=UC+mk,io="called with ",ys=jC+" must not be ",xs=$C+mk;var BC="Ok",fk="Err",dk=io+fk,HC=io+BC,WC="Carrying E in "+fk+" instead of throwing it directly. See .cause",hf="an instance of Error of the current realm.",D9e="The thrown value is not "+hf,U9e="The contained E should be "+hf,qC="This .cause is not "+hf;function Et(e){return e.ok}function Ce(e){return{ok:!0,val:e,err:null}}function se(e){return!e.ok}function Lt(e){return{ok:!1,val:null,err:e}}function Te(e){return hk(e,dk)}function hk(e,t){if(se(e))throw new TypeError(t);return e.val}function vi(e,t){if(se(e))return e;let r=St(e),o=t(r);return Ce(o)}async function qe(e,t){if(se(e))return e;let r=St(e),o=await t(r);return Ce(o)}async function et(e,t){if(Et(e))return e;let r=Ut(e),o=await t(r);return Lt(o)}async function ll(e,t){if(Et(e))return e;let r=Ut(e);return await t(r)}var pl="null",XXe=gs+pl,VC=io+pl,JXe=ys+pl,QXe=xs+pl;var ul="undefined",o7e=gs+ul,KC=io+ul,n7e=ys+ul,s7e=xs+ul;var Ge=e=>e.ok?Ce(e):Lt({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var yk=async(e,t)=>{let r=new Request(e,t);try{return Ce(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return Lt({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return Lt({name:"NetworkError",message:o.message,request:r});throw o}};var Ie=e=>{let{fetch:t=yk,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var xk=e=>{let{sid:t,hostName:r}=Ie(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:ze(t)}}:void 0)},bk=e=>qe(Ge(e),async t=>await t.json()),Ek=(()=>{let e=async t=>{let{fetch:r,...o}=Ie(t??{}),n=await r(xk(o));return se(n)?n:bk(Te(n))};return e.toRequest=xk,e.fromResponse=bk,e})();var ze=e=>connect.sid=${e},ao=async e=>{let t=e?.csrf??globalThis._csrf;return t?Ce(t):vi(await Ek(e),r=>r.csrfToken)};var $t=async(e,t)=>{let r=e.response.clone(),o=Uo(t);try{let n=await r.json();if(!mo(n))return;if(r.status===422){if(!ke(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!ke(n.message)?void 0:n.name==="NotLoggedInError"?!mo(n.detals)||!ke(n.detals.project)||!Cs(JC)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},JC=Uo(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var ml="null or undefined",bs=gs+ml,QC=io+ml,gf=ys+ml,fl=xs+ml;function jr(e){return e==null}function dl(e){return jr(e)?Lt(void 0):Ce(e)}var wk=(e,t)=>{let{sid:r,hostName:o}=Ie(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:ze(r)}}:void 0)},Rk=async e=>qe(await et(Ge(e),async t=>await $t(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),kk=(()=>{let e=async(t,r)=>{let{fetch:o}=Ie(r??{}),n=wk(t,r),s=await o(n);return se(s)?s:Rk(Te(s))};return e.toRequest=wk,e.fromResponse=Rk,e})();var vk=async(e,t)=>{let{sid:r,hostName:o,fetch:n}=Ie(t??{}),s=await ao(t);if(se(s))return s;let i=new Request(https://${o}/api/embed-text/url?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":Te(s),...r?{Cookie:ze(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await n(i);return se(a)?a:qe(await et(Ge(Te(a)),async c=>await $t(c,["SessionError","BadRequestError","InvalidURLError"])??c),async c=>{let{title:l}=await c.json();return l})};var Tk=async(e,t)=>{let{sid:r,hostName:o,fetch:n}=Ie(t??{}),s=await ao(t);if(se(s))return s;let i=new Request(https://${o}/api/embed-text/twitter?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":Te(s),...r?{Cookie:ze(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await n(i);return se(a)?a:et(await qe(Ge(Te(a)),c=>c.json()),async c=>c.response.status===422?{name:"InvalidURLError",message:(await c.response.json()).message}:await $t(c,["SessionError","BadRequestError"])??c)};var _k=async e=>{let{fetch:t,sid:r,hostName:o,gyazoTeamsName:n}=Ie(e??{}),s=new Request(https://${o}/api/login/gyazo/oauth-upload/token${n??gyazoTeamsName=${n}:""},r?{headers:{Cookie:ze(r)}}:void 0),i=await t(s);return se(i)?i:qe(await et(Ge(Te(i)),async a=>await $t(a,["NotLoggedInError"])??a),a=>a.json().then(c=>c.token))};var Pk=async(e,t,r)=>{let o=${Xp(Yp(await e.arrayBuffer()))},n=await eI(e,t,o,r);if(se(n))return n;let s=Te(n);if("embedUrl"in s)return Ce(s);let i=await tI(s.signedUrl,e,r);return se(i)?i:rI(t,s.fileId,o,r)},eI=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i,csrf:a}=Ie(o??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},l=await ll(dl(a),()=>ao(o));if(se(l))return l;let u=new Request(https://${s}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":Te(l),...n?{Cookie:ze(n)}:{}}}),p=await i(u);return se(p)?p:qe(await et(Ge(Te(p)),async f=>f.response.status===402?{name:"FileCapacityError",message:(await f.response.json()).message}:f),f=>f.json())},tI=async(e,t,r)=>{let{sid:o,fetch:n}=Ie(r??{}),s=await n(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...o?{Cookie:ze(o)}:{}}});return se(s)?s:vi(await et(Ge(Te(s)),async i=>i.response.headers.get("Content-Type")?.includes?.("/xml")?{name:"GCSError",message:await i.response.text()}:i),()=>{})},rI=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i,csrf:a}=Ie(o??{}),c=await ll(dl(a),()=>ao(o));if(se(c))return c;let l=new Request(https://${s}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":Te(c),...n?{Cookie:ze(n)}:{}}}),u=await i(l);return se(u)?u:qe(await et(Ge(Te(u)),async p=>p.response.status===404?{name:"NotFoundError",message:(await p.response.json()).message}:p),p=>p.json())};var Ok=(e,t)=>{let r=new FormData;return r.append("data",e),r.append("metadata",JSON.stringify({app:"Gyazo",title:e.name})),GM_fetch(https://gif.gyazo.com/${t?.teams?"teams":"gif"}/upload,{method:"POST",body:r,credentials:"include",headers:{Origin:"https://gyazo.com","sec-fetch-site":"same-site"},referrer:"https://gyazo.com/"})};var hl="",Sk=!1,gl=new Map,Lk=async(e,t,r,o)=>{let n=gl.get(e.href);if(n)return n;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let l=await GM_fetch(e);if(!l.ok)return;let u=l.headers.get("content-type")?.split?.(";")?.[0]??${e}.endsWith(".mp4")?"video/mp4":"video/webm",p=new File([await l.blob()],o||${t},{type:u});if(u==="video/mp4"){let h=await Ok(p);if(h.ok){let g=new URL(await h.text());return gl.set(e.href,g),g}}let f=await Pk(p,r);if(O(f))throw Error(Z(f).name);let m=new URL(S(f).embedUrl);return gl.set(e.href,m),m}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Sk){if(!hl)return}else{let l=await _k();if(Sk=!0,O(l)){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(hl=S(l)||"",!hl){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let s=await GM_fetch(e);if(!s.ok)return;let i=await Yh(await s.blob(),{accessToken:hl,refererURL:t,description:o});if(!i.ok)throw new Error(Gyazo upload failed: ${i.status} ${i.statusText});let a=await i.json(),c=new URL(a.permalink_url);return gl.set(e.href,c),c};var Ck=[["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#39;"]],oI=Object.fromEntries([...Ck.map(([e,t])=>[t,e]),["&apos;","'"],["&nbsp;"," "]]),nI=new Map(Ck),sot=new RegExp([${...nI.keys().join("")}],"g");var sI={entityList:oI},iI=1114111,aI=/&#([0-9]+);/g,cI=/&#x(\p{AHex}+);/gu,Nk=new WeakMap;function yf(e,t={}){let{entityList:r}={...sI,...t},o=Nk.get(r);return o||(o=new RegExp((${Object.keys(r).sort((n,s)=>s.length-n.length).join("|")}),"g"),Nk.set(r,o)),e.replaceAll(o,n=>r[n]).replaceAll(aI,(n,s)=>Mk(s,10)).replaceAll(cI,(n,s)=>Mk(s,16))}function Mk(e,t){let r=parseInt(e,t);return r>iI?"�":String.fromCodePoint(r)}var yl=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),o=[...e.entities.hashtags.map(i=>({type:"hashtag",...i})),...e.entities.symbols.map(i=>({type:"symbol",...i})),...e.entities.user_mentions.map(i=>({type:"mention",name:i.name,screenName:i.screen_name,indices:i.indices})),...e.entities.urls.map(i=>{let a={type:"url",indices:i.indices,url:new URL(i.expanded_url)};if(e.card&&e.card?.url===i.url){let{description:c,title:l}=e.card.binding_values,u="STRING";c?.type===u&&(a.description=c.string_value),l?.type===u&&(a.title=l.string_value)}return a}),...e.entities.media?.map?.(i=>({type:"media",indices:i.indices,media:e.mediaDetails?.flatMap?.(a=>a.url===i.url?[{type:a.type,url:new URL(a.video_info?.variants?.sort?.((c,l)=>(l.bitrate??0)-(c.bitrate??0))?.[0].url??a.media_url_https)}]:[])??[]}))??[]].sort((i,a)=>i.indices[0]-a.indices[0]),n=[];{let i=0,a=e.text;for(let{indices:c,...l}of o){let u=[...a].slice(0,c[0]-i).join("");n.push({type:"plain",text:yf(u)}),n.push(l),a=[...a].slice(c[1]-i).join(""),i=c[1]}a&&n.push({type:"plain",text:yf(a)})}let s={id:e.id_str,content:n,author:t,posted:r,replyCount:"reply_count"in e?e.reply_count:e.conversation_count};return e.self_thread&&(s.rootId=e.self_thread.id_str),e.in_reply_to_status_id_str&&(s.replyId=e.in_reply_to_status_id_str),e.parent&&(s.replyTo=yl(e.parent)),e.quoted_tweet&&(s.quote=yl(e.quoted_tweet)),s};var lI=["landing","product","enterprise","pricing","try-enterprise","contact","terms","privacy","jp-commercial-act","support","case","features","business","auth","login","logout","oauth2","_","api","app.html","assets","file","files","billing","billings","config","feed","index","io","new","opensearch","project","projects","search","setting","settings","setup-profile","slide","socket.io","stream","user","users"],xl=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,o,n]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!o||lI.includes(o)?r:n?o===e?${decodeURIComponent(n)}:/${o}/${decodeURIComponent(n)}:/${o}};var Ik=(e=pI)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:www\.|mobile\.|m\.|)(?:twitter|x)\.com\/[A-Za-z0-9_]*\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let o=await(uk(r)??Tk(t.href));if(O(o))throw Z(o);let n=S(o);return e("images"in n?{...n,id:r}:n,t)})():t},pI=async e=>{if("images"in e)return Ti(e);let{quote:t,replyTo:r,...o}=yl(e);return[...r?[...(await Ti(r)).split(
).map(n=> > ${n}),...r.quote?(await Ti(r.quote)).split(
).map(n=> > ${n}):[]]:[],...(await Ti(o)).split(
).map(n=>> ${n}),...t?(await Ti(t)).split(
).map(n=>> > ${n}):[]].join(
)},Ti=async e=>{let t=new URL(https://twitter.com/${"author"in e?e.author.screenName:e.screenName}/status/${e.id});if("images"in e)return[> @${bf(e.screenName)} ${t.origin}${t.pathname},...e.description?.split?.(
)?.map?.(n=>> ${bf(n)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(n=>[${n}])}]:[]].join(
);let r=e.content,o=e.author.screenName;return[@${bf(o)} ${t},...(await Promise.all(r.map(async n=>{switch(n.type){case"plain":return n.text;case"hashtag":return #${n.text} ;case"symbol":return #$${n.text} ;case"mention":return@${n.screenName};case"media":{let s=[],i=1;for(;i<n.media.length;i+=2)s.push([${await xf(n.mediai-1,t)}] [${await xf(n.mediai,t)}]);return i===n.media.length&&s.push([${await xf(n.mediai-1,t)}]),
${s.join(`
`)}
}case"url":return${xl()(n.url)} }}))).join("").split(
)].join(
)},bl="",uI=async()=>{if(bl)return bl;let e=await kk(scrapbox.Project.name);if(O(e))throw new Error(Z(e).name);return bl=S(e).id,bl},xf=async(e,t)=>await Lk(e.url,t,await uI(),"")??e.url,bf=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Ak=e=>window.GM_fetch?.(https://t.co/${e})?.then?.(t=>ie(hs(t),async r=>{let o=new DOMParser().parseFromString(await r.text(),"text/html");try{return new URL(o.title)}catch(n){if(n instanceof TypeError)return;throw n}}));var Fk=e=>{let t=window.GM_fetch;if("bit.ly","amzn.to","amzn.asia","goo.gl","s.nikkei.com","apple.co","nico.ms","w.wiki".includes(e.hostname)&&t)return t(e).then(o=>o.ok?new URL(o.url):e);if(e.hostname!=="t.co")return e;let r=Ak(e.pathname.slice(1));return r?r.then(o=>Ms(o,()=>e,n=>n??e)):e};var Dk=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,n=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!n)return e;e.hostname=${n}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",o=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${o}#${r}]:[${t} - Wikipedia ${o}]};var Uk=e=>{if(e.hostname!=="www.wikiwand.com")return e;let,t,r=e.pathname.match(/^\/(^\/+)\/(^\/+)/)??[];return!t||!r||(e.hostname=${t}.wikipedia.org,e.pathname=/wiki/${r},e.hash=e.hash.startsWith("#/")?#${e.hash.slice(2)}:e.hash),e};var Ef=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var $k=/charset=(^;+)/,jk=e=>window.GM_fetch?.(${e})?.then?.(t=>ie(hs(t),async r=>{let o=r.headers.get("content-type")?.match?.($k)?.1??await mI(r.clone());return new TextDecoder(o).decode(await r.arrayBuffer())})),mI=async e=>{let t=new DOMParser().parseFromString(await e.text(),"text/html");return t.querySelector("metacharset")?.getAttribute?.("charset")??t.querySelector('metahttp-equiv="content-type"')?.getAttribute?.("content")?.match?.($k)?.1??"utf-8"};var Bk=(e=fI)=>async t=>e(await dI(t),t),fI=(e,t)=>{let r=(ke(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},dI=async e=>{let t=jk(e);if(!t){let o=await vk(e);if(O(o))throw Z(o);return S(o)}let r=await t;if(O(r))throw Z(r);return new DOMParser().parseFromString(S(r),"text/html")};var Hk=e=>{if(!/^(?:www\.)?amazon(?:\.co|com)?\.(?:au|br|ca|fr|de|in|it|jp|mx|nl|sg|es|tr|ae|uk|cn)$/.test(e.hostname))return e;let,t=e.pathname.match(/\/dp\/(\w\d+)/)??e.pathname.match(/\/gp\/product\/(\w\d+)/)??e.pathname.match(/\/exec\/obidos\/asin\/(\w\d+)/)??e.pathname.match(/\/o\/ASIN\/(\w\d+)/)??[];return t&&(e.hash="",e.search="",e.pathname=/dp/${t}),e};var Wk=e=>{if(!/(?:0-9a-z-\.)?gyazo\.com/.test(e.hostname))return e;let,t=e.pathname.match(/^\/(0-9a-f{32})(?:\/raw)?$/)??[];return t?[https://gyazo.com/${t}]:e};var qk=(e,...t)=>{if(e instanceof URL)return df(new URL(e),...t);let r=0,o=0,n=0,s=!1,i=e.split(/(https?:\/\/\S+)/g).map(u=>{if(!/^https?:\/\/\S+$/.test(u))return u;r++;try{let p=df(new URL(u),...t);return ke(p)?(o++,p):(s=!0,p,u)}catch(p){return console.error(p),n++,u}});if(!s)return i.join("");let{render:a,dispose:c}=lk(),l=()=>a({type:"spinner"},{type:"text",text:URL: ${o}/${r} converted, ${n} failed});return l(),Promise.all(i.map(async u=>{if(ke(u))return u;try{let p=await u0;return o++,p}catch(p){return console.error(p),n++,u1}finally{l()}})).then(u=>(a({type:"check-circle"},{type:"text",text:URL: ${o}/${r} converted, ${n} failed}),u.join(""))).finally(()=>{setTimeout(c,1e3)})};var Gk=e=>{if(!/^(?:\w+\.nicovideo\.jp|nico\.ms)$/.test(e.hostname))return e;let t=e.pathname.match(/(?:sm|nm|so|ca|ax|yo|nl|ig|na|cw|za-e|om|sk|yk|lv)\d{1,14}$/)?.0;return t?[https://nicothumb2img.vercel.app/image/${t}#.png https://nico.ms/${t}]:e};var zk=e=>it(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return hI(r);case"table":return gI(r);case"line":return yI(r)}}).map(r=>r).join(`
),hI=({fileName:e,content:t,indent:r})=>{let o=" ".repeat(r);return[${o}code:${e},...t.split(
).map(n=>${o} ${n})]},gI=({fileName:e,cells:t,indent:r})=>{let o=" ".repeat(r);return[${o}table:${e},...t.map(n=>${o} ${n.map(s=>s.map(i=>i.raw).join("")).join(" ")})]},yI=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${_i(r)}).join("")}],_i=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>_i(t)).join("")};case"helpfeel":return-? ${e.text};case"commandLine":return-${e.symbol} ${e.text};case"icon":case"strongIcon":case"image":case"strongImage":case"formula":case"code":case"googleMap":return e.raw;case"strong":return${e.nodes.map(t=>_i(t)).join("")};case"decoration":{e.decos.includes("-")||e.decos.push("-");let t=e.decos.map(r=>{let o=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return o>0?"*".repeat(o):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>_i(r)).join("")}]}case"link":switch(e.pathType){case"root":case"relative":return${e.href};case"absolute":return[- ${e.content?${e.content} :""}${e.href}]]}case"hashTag":return#${e.href};case"numberList":return${e.number}. ${e.nodes.map(t=>_i(t)).join("")};case"blank":case"plain":return${e.text}}};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=zk(e);if(e!==t)return t}});var wf=e=>{let t=e.indexOf(
);if(t<0)return;let r=e.slice(0,t).split(
).map(s=>{let[i="",a=""]=s.split(" => ",2);return[i,a]});if(r.length===0)return;let o=e.slice(t+2).split(
);if(o.length===0)return;for(let[s,i]of r){let a=s.match(/^\/(.*?)\/([gimy]*)$/);if(a){let c=new RegExp(a[1],a[2]);o=o.map(l=>l.replace(c,i.replaceAll("\\n",
)))}else o=o.map(c=>c.replaceAll(s,i.replaceAll("\\n",
)))}let n=${e.slice(0,t+2)}${o.join(`
)};if(e!==n)return n};scrapbox.PopupMenu.addButton({title:e=>wf(e)?"replace":"",onClick:e=>{let t=wf(e);if(t!==void 0)return t}});var Vk=e=>{let t=document.createElement("div"),r=t.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent="dialog::backdrop{background-color:#000c}dialog{flex-direction:column;align-items:center;row-gap:10px;padding:10px;background:unset;margin-top:unset;margin-bottom:unset;border:unset;height:unset}dialogopen{display:flex}dialog>*{color:var(--page-text-color, #4a4a4a);background-color:var(--dropdown-menu-bg, #fff);border:1px solid rgba(0,0,0,.2);border-radius:6px}@media (min-width: 768px){dialog{padding:30px 0}}.container{display:flex;padding:5px;gap:0.2em;flex-direction:column;width:100%;}.button-container{flex-direction:unset;}.button-container>*{flex:1;}",r.append(o);let n=document.createElement("dialog");n.insertAdjacentHTML("beforeend",`
<div class="container">
Replace Links:
<textarea class="editor"></textarea>
<div class="container button-container">
<button class="cancel">cancel</button>
<button class="replace">replace</button>
</div>
</div>
),r.append(n);let s=n.querySelector(".editor");s.rows=e.length,s.value=e.join(
);let i=()=>{n.style.minWidth=${Math.max(...s.value.split(`
).map(u=>[...u].length))+6}em};i(),s.addEventListener("input",i);let a=n.querySelector(".cancel"),c=n.querySelector(".replace"),l=new Promise(u=>{let p=()=>{u({convert:!1}),t.remove()};n.addEventListener("close",p),n.addEventListener("click",p),a.addEventListener("click",p),c.addEventListener("click",()=>{let f=s.value.split(`
);u({convert:!0,links:e.flatMap((m,h)=>m===f[h]||m===""||!f[h]?[]:[{before:m,after:f[h]??m}])}),t.remove()}),n.querySelector(".container").addEventListener("click",f=>{f.stopPropagation()})});return document.body.append(t),n.showModal(),l};var Kk=async(e,t)=>{let r=so(e),o=await Vk([...new Set(r)]);if(!o.convert||o.links.length===0)return;let n=new Map(o.links.map(s=>[s.before,De()]));for await(let{link:s,projectCount:i,replaced:a,done:c}of rk(o.links,t)){let l=n.get(s.before);if(l){if(c){l.render({type:"check-circle"},{type:"text",text:"${s.after}", ${a}l. ${i}p.}),setTimeout(()=>l.dispose(),1e3);continue}l.render({type:"spinner"},{type:"text",text:"${s.after}", ${a}l. ${i}p.})}}};var Yk=async(e,t)=>{let r=so(e)[0];if(!r)return;let o=window.prompt(Replace "${r}" to this in ${t.map(a=>"/${a}").join(", ")},r)?.replace?.(/[\[\]\n]/g," ")??"";if(o==="")return;let{render:n,dispose:s}=De(),i=S(await Mt());try{n({type:"spinner"},{type:"text",text:Replacing links in ${t.length} projects...});let a=0,l=(await Promise.all(t.map(async u=>{let[p]=await Promise.all([da(u,r,o),Le(u,r,(f,{persistent:m})=>{if(m)return[o,...f.map(h=>h.text).slice(1)]},{socket:i})]);if(O(p))throw n({type:"exclamation-triangle"},{type:"text",text:${Z(p).name} ${Z(p).message}}),xI(Z(p));return a++,n({type:"spinner"},{type:"text",text:Replacing links in ${t.length-a} projects...}),S(p)}))).reduce((u,p)=>u+p,0);n({type:"check-circle"},{type:"text",text:Successfully replaced ${l} links.})}finally{await Ct(i),setTimeout(s,1e3)}},xI=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var Xk=e=>{let t=[scrapbox.Project.name,...e];scrapbox.PopupMenu.addButton({title:r=>{let o=so(r).length;return o>1?"update links":o===1?"update a link":""},onClick:r=>{let o=so(r).length;o>1?Kk(r,t):o===1&&Yk(r,t)}})};scrapbox.PopupMenu.addButton({title:e=>/[\n..。]/.test(e)?"\\n":"",onClick:e=>e.replace(/(\w)\n(\w)/g,"$1 $2").replaceAll(
,"").replaceAll(".",.
).replaceAll(".",.
).replaceAll("。",。
)});scrapbox.PopupMenu.addButton({title:e=>/https:\/\/(?:thumb\.|i\.)?gyazo\.com\/[a-z0-9]+/.test(e)?globalThis.GM_fetch?"copy Gyazo OCR":"open Gyazo":"",onClick:async e=>{let t=e.match(/https:\/\/(?:thumb\.|i\.)?gyazo\.com\/([a-z0-9]+)/)?.[1];if(!t)return;if(!globalThis.GM_fetch){window.open(https://gyazo.com/${t});return}let o=(await(await GM_fetch(https://gyazo.com/${t}.json)).json()).metadata?.ocr?.description;if(o)try{await navigator.clipboard.writeText(o)}catch(n){console.error(n),alert(${n.name} ${n.message})}}});scrapbox.PopupMenu.addButton({title:e=>/https:\/\/gyazo\.com\/[a-z0-9]+/.test(e)?"":"",onClick:e=>{let t=e.match(/https:\/\/gyazo\.com\/([a-z0-9]+)/)?.[1];t&&window.open(https://gyazo.com/${t}/transform)}});var Jk=e=>{let t="",r=0;for(let o of e)if(o.type!=="title"){if(o.indent>r)for(let n=r;n<o.indent;n++)t+=Pi(${n!==r?"\\item":""}\\begin{itemize},n*2)+
;if(o.indent<r)for(let n=r;n>o.indent;n--)t+=Pi("\\end{itemize}",(n-1)*2)+
;r=o.indent,t+=Pi(${r>0?"\\item ":""}${bI(o)},r*2)+
}for(let o=r;o>0;o--)t+=Pi("\\end{itemize}",(o-1)*2)+
;return t},bI=e=>{switch(e.type){case"codeBlock":return EI(e);case"table":return wI(e);case"line":return RI(e)}},EI=e=>\\begin{lstlisting}language=${Jt(vI(e.fileName))},caption=${Jt(e.fileName)},label=lang:${e.fileName},numbers=left
${e.content}
\\end{lstlisting},wI=e=>{let t=\\caption{${Jt(e.fileName)}}\\label{table:${Jt(e.fileName)}},r=Math.max(...e.cells.map(n=>n.length)),o=e.cells.map(n=> ${n.map(s=>s.map(i=>Es(i)).join("")).join(" & ")}\\\\);return\\begin{table}htbp
${t}
\\centering
\\begin{tabular}{${"c".repeat(r)}}
${o.length===0?"":o.length===1?` \\toprule
${o.join(`
`)}
\\bottomrule: \\toprule
${o0}
\\midrule
${o.slice(1).join(`
`)}
\\bottomrule`}
\\end{tabular}
\\end{table}},RI=e=>e.nodes.map(t=>Es(t)).join(""),Es=e=>{switch(e.type){case"quote":return\\begin{quote}
${Pi(e.nodes.map(t=>Es(t)).join(""),2)}
\\end{quote};case"image":case"strongImage":return\\begin{figure}hbtp
iamge:\\url{${e.src}}
\\end{figure};case"icon":case"strongIcon":return\\textit{${Jt(e.path)}};case"strong":return\\textbf{${e.nodes.map(t=>Es(t)).join("")}};case"formula":return$${e.formula}$;case"decoration":{let t=e.nodes.map(r=>Es(r)).join("");return e.decos.includes("/")&&(t=\\textit{${t}}),e.decos.some(r=>/\*-/.test(r[0]))&&(t=\\textbf{${t}}),e.decos.includes("_")&&(t=\\uline{${t}}),e.decos.includes("-")&&(t=\\sout{${t}}),t}case"numberList":return${e.number}. ${e.nodes.map(t=>Es(t)).join("")};case"helpfeel":return\\lstinline!? ${Jt(e.text)}!;case"code":return\\lstinline!${Jt(e.text)}!;case"commandLine":return\\lstinline!${Jt(e.symbol)} ${Jt(e.text)}!;case"link":return e.pathType==="absolute"?e.content===""?\\url{${e.href}}:\\href{${e.href}}{${Jt(e.content)}}:Jt(e.href);case"googleMap":return\\href{${e.url}}{${Jt(e.place)}};case"hashTag":return Jt(#${e.href});case"blank":case"plain":return Jt(e.text)}},kI=[{extensions:["javascript","js"],fileType:"javascript"},{extensions:["typescript","ts"],fileType:"typescript"},{extensions:["cpp","hpp"],fileType:"C++"},{extensions:["c","cc","h"],fileType:"C"},{extensions:["cs","csharp"],fileType:"cs"},{extensions:["markdown","md"],fileType:"markdown"},{extensions:["htm","html"],fileType:"html"},{extensions:["json"],fileType:"json"},{extensions:["xml"],fileType:"xml"},{extensions:["yaml","yml"],fileType:"yaml"},{extensions:["toml"],fileType:"toml"},{extensions:["ini"],fileType:"ini"},{extensions:["tex","sty"],fileType:"tex"},{extensions:["svg"],fileType:"svg"}],vI=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return kI.find(r=>r.extensions.includes(t))?.fileType??""},Jt=e=>e.replaceAll("\\","\\textbackslash ").replaceAll("#","\\#").replaceAll("%","\\%").replaceAll("$","\\$").replaceAll("&","\\&").replaceAll("~","\\textasciitilde ").replaceAll("^","\\textasciicircum ").replaceAll("_","\\_").replaceAll("{","\\{").replaceAll("}","\\}").replaceAll("|","\\textbar ").replaceAll("<","\\textless ").replaceAll(">","\\textgreater "),Pi=(e,t)=>e.split(
).map(r=>${" ".repeat(t)}${r}).join(
);scrapbox.PopupMenu.addButton({title:"TeX",onClick:e=>{navigator.clipboard.writeText(Jk(it(e))).catch(t=>{console.error(t),alert(${t.name} ${t.message}
${t.stack})})}});var El="https://keicho.herokuapp.com/api/";var Qk=async(e,t)=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let r=await window.GM_fetch(${El}web/,{mode:"cors",method:"POST",body:JSON.stringify({user:"nobody",talk:t,text:e}),headers:{"Content-Type":"application/json"}});if(!r.ok)return{ok:!1,value:{name:"ResponseError",res:r}};let o=await r.json();return{ok:!0,value:{text:o.text,buttons:o.buttons,canInput:o.can_input}}};var Zk=()=>{let{popupMenu:e,render:t}=TI();Og()?.append?.(e);let r=Eo(),o=()=>{requestAnimationFrame(()=>{let n=document.getElementsByClassName("cursor")[0];e.style.top=${parseInt(n.style.top)+parseInt(n.style.height)+4}px})};return r.addChangeListener(o),{render:t,visible:()=>!e.hidden,open:()=>e.hidden=!1,close:()=>e.hidden=!0,toggle:()=>e.hidden=!e.hidden,dispose:()=>{e.remove(),r.removeChangeListener(o)}}},TI=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});t.innerHTML=
<style>
:host {
position: absolute;
left: 0px;
width:100%;
z-index:300;
user-select:none;
font-family:"Open Sans",Helvetica,Arial,"Hiragino Sans",sans-serif;
pointer-events:none
}
.button-container {
position: relative;
display:inline-block;
max-width:70vw;
min-width:80px;
text-align:center;
background-color:#111;
padding:0 1px;
border-radius:4px;
pointer-events:auto
}
htmldata-os*='android' .button-container {
max-width:90vw
}
htmldata-os*='ios' .button-container {
max-width:90vw
}
.button {
font-size:11px;
color:#eee;
cursor:pointer;
display:inline-block;
padding:0 5px
}
.button:not(:first-of-type) {
border:0;
border-left:1px solid #eee
}
.button.selected {
background-color:#222;
text-decoration:underline
}
htmldata-os*='android' .button {
font-size:13px;
padding:6px;
min-width:12vw
}
htmldata-os*='ios' .button{
font-size:13px;
padding:6px;
min-width:12vw
}
.button div.icon {
height:2em;
max-width:10em;
display:inline-block;
overflow:hidden;
margin-left:1px;
vertical-align:top
}
.button div.icon img {
max-height:100%;
vertical-align:unset
}
</style>
<div class="button-container"></div>
;let r=t.lastElementChild;return{popupMenu:e,render:(...o)=>{r.textContent="",r.append(...o.map(({text:n,onClick:s})=>{let i=document.createElement("div");return i.classList.add("button"),i.textContent=n,s&&i.addEventListener("click",()=>s()),i}))}}};var ev=async(e="normal")=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let t=await window.GM_fetch(${El}web/create/?mode=${e},{mode:"cors"});return t.ok?{ok:!0,value:await t.text()}:{ok:!1,value:{name:"ResponseError",res:t}}};var tv=e=>https://keicho.netlify.app/#talk=${e};var rv=e=>{let t=e.split(
),r=t[1]??t[0],o=e===t[0]?"":t[0];return o?[o.trim(),r].join(
):r};var wl=async(e,t,r)=>{let o=Eo(),n=o.lines.findIndex(i=>i.id===t.id);n<0&&(n=o.lines.findIndex(i=>i.text===t.text)),n<0&&(n=Math.min(r,Math.max(0,o.lines.length-1)));let s=o.lines[n].text;return Fa().clear(),o.setPosition({line:n,char:[...s].length}),await at(
${e}),o.getPosition().line};var ov=e=>it(e,{hasTitle:!1}).map(t=>{if(t.type==="title")return t.text.trimEnd();let r=" ".repeat(t.indent);switch(t.type){case"codeBlock":return[${r}${t.fileName},...t.content.split(
).map(o=>${r} ${o})].join(
).trimEnd();case"table":return[${r}${t.fileName},...t.cells.map(o=>${r} ${o.flatMap(n=>n.map(s=>Rl(s))).join(" ")})].join(
).trimEnd();case"line":return${r}${t.nodes.map(o=>Rl(o)).join("")}.trimEnd()}}).join(
),Rl=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Rl(t)).join("")};case"helpfeel":case"commandLine":return e.raw;case"strongImage":case"image":case"strongIcon":case"icon":case"googleMap":return"";case"strong":case"decoration":case"numberList":return e.nodes.map(t=>Rl(t)).join("");case"formula":return\\(${e.formula}\\);case"code":return ${e.text} ;case"blank":case"plain":return e.raw;case"hashTag":return e.href;case"link":switch(e.pathType){case"absolute":return e.content? ${e.content} :"";case"root":return e.href.split("/").pop()??"";case"relative":return e.href}}};var ws=e=>/^[((]/.test(e);var sv=async e=>{let t=scrapbox.Page.lines;if(!t)return;let{cursor:r,selection:o}=Bt(),n=e?.entire||o.hasSelectionAll(),s=n?t.map(P=>P.text).join(
):o.getSelectedText(),i=e?.botIcon??"[/nishio/nisbot.icon]",{render:a,visible:c,open:l,close:u,dispose:p}=Zk();u();let f=new Set,m=()=>{p();for(let P of f)P()},h=P=>f.add(P),g={text:"Exit",onClick:m},y=e?.talkId||nv(s)||(n?"":nv(t.slice(0,1+r.getPosition().line).map(P=>P.text).join(
))),x=!y;if(!y){let P=ev(e?.mode),I=setTimeout(()=>{a({text:"Start talking..."}),l();let j=0;I=setInterval(()=>{a({text:Start talking${".".repeat(j%3)}}),j++},1e3)},1e3),$=await P;if(clearTimeout(I),!$.ok){if($.value.name==="GMFetchNotAvailableError"){alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc.");return}if($.value.name==="ResponseError"){a({text:Error: ${$.value.res.status} ${$.value.res.statusText}},g),l(),console.error(Error: ${$.value.res.status} ${$.value.res.statusText},await $.value.res.text());return}return}y=$.value}let w=y,k=o.normalizeOrder(o.getRange()),b=n?t.length-1:k.end.line,T=t[b],v=n?"":" ".repeat(Math.min(...t.slice(k.start.line,k.end.line+1).map(P=>Zt(P.text)))),A=async P=>{let I=await Qk(P,w);if(!I.ok)switch(I.value.name){case"ResponseError":return a({text:Error: ${I.value.res.status} ${I.value.res.statusText}},g),l(),console.error(Error: ${I.value.res.status} ${I.value.res.statusText},await I.value.res.text()),I;case"GMFetchNotAvailableError":return alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc."),I}return I},F="",D=async P=>{let I=ov(P).split(
).map(B=>B.trim()).join(
).trim();I.startsWith(F)&&(I=I.slice(F.length));let $=I.split(
);if($.length===0)return;if($.every(B=>ws(B))&&(F=I),$.filter(B=>!ws(B)).length<2){let B,Y;for(let G of $){if(Y=await A(G),!Y.ok)return Y;ws(G)||(B=Y)}return B??Y}let q=0;{let B;for(;q<$.length&&ws($[q]);q++)if(B=await A($[q]),!B.ok)return B}{let B=await A("まず聞いて");if(!B.ok)return B}for(;q<$.length&&!ws($[q]);q++){let B=await A($[q]);if(!B.ok)return B}return await A("おしまい")},N=async P=>{if(scrapbox.Layout!=="page"||P==="")return;let I=D(P),$=setTimeout(()=>{a({text:"Asking..."}),l();let G=0;$=setInterval(()=>{a({text:Asking${".".repeat(G%3)}}),G++},1e3)},1e3),j=await I;if(clearTimeout($),!j||!j.ok)return;let{text:q,buttons:B}=j.value,Y=rv(q);if(Y.trim()){let G=${v}${i}${Y.includes(`
)?
${Y.split(`
).map(X=> ${v}${X}).join(
)}:Y}
${v};b=await wl(G,T,b),T=t[b]}a({text:"Send",onClick:_},{text:"🙂",onClick:()=>at("🙂")},{text:"🙁",onClick:()=>at("🙁")},...B.map(G=>({text:G,onClick:async()=>{b=await wl(G,T,b),T=t[b],await N(G)}})),g),l()},_=async()=>{if(scrapbox.Layout!=="page")return;let P=scrapbox.Page.lines,I=r.getPosition().line,[$,j,q]=_I(P,I,i);$!==""&&(b=q,T=P[b],v=" ".repeat(Math.min(...P.slice(j,q+1).map(B=>Zt(B.text)))),await N($))};return x&&(b=await wl(tv(w),T,b),T=t[b]),await N(s),{ask:_,open:l,close:u,visible:c,exit:m,onExit:h}},nv=e=>{for(let t of e.split(
).reverse()){let r=t.match(/https?:\/\/keicho\.netlify\.app\/#talk=(\w+)/)?.[1];if(r)return r}},_I=(e,t,r)=>{let o=Math.max(e.findLastIndex((s,i)=>i<t&&s.text.trim().startsWith(r)),1),n=o+Wo(o,e)+1;return[e.slice(n,t+1).map(s=>s.text.trim()).join(
).trim(),n,t]};scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>$ ${e}});var iv=[rn,on,nn];scrapbox.PopupMenu.addButton({title:e=>{let t=Xr({project:scrapbox.Project.name,mode:"noopen",hooks:iv});return!t||t.hookName.includes("default")?"":t.hookName.includes("task")?"":t.hookName.includes("split")?"":""},onClick:()=>{let e=window.prompt("Create a new page at",scrapbox.Project.name);e&&Xr({project:e,mode:"noopen",hooks:iv})?.()}});scrapbox.PopupMenu.addButton({title:e=>/(https?:\/\/[^\s]+)/g.test(e)?"":"",onClick:e=>{let t=e.replace(/(https?:\/\/[^\s]+)/g,"[$1#.jpg]");if(e!==t)return t}});scrapbox.PopupMenu.addButton({title:"S",onClick:e=>{window.open(https://scrapbox.io/${scrapbox.Project.name}/search/page?q=${e})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[(.*)\]/g,"$1")).join(
);window.open(https://www.google.com/search?q=${encodeURIComponent(t)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=o=>[...o].some(n=>n.charCodeAt(0)>255),r=e.split(/\n/).map(o=>o.replace(/\[(.*)\]/g,"$1")).join(
).trim().replace(/\s+/g,"+");t(r)?window.open(https://www.ldoceonline.com/search/japanese-english/direct/?q=${encodeURIComponent(r)}):window.open(https://www.oxfordlearnersdictionaries.com/search/english/?q=${encodeURIComponent(r)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[(.*)\]/g,"$1")).join(
);window.open(https://www.google.com/search?q=${encodeURIComponent(t)}+site:scrapbox.io)}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"🖍",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:e=>/\$([^$]+)\$/.test(e)?"L":"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\$([^$]+)\$/g,"[$ $1]")).join(
);if(e!=t)return t}});var PI=[Ef,Fk,Ef,Uk,Hk,xl(),Wk,Ik(),Dk,e=>{if(e.hostname!=="ekitan.com"||!/^\/transit\/(?:route|first|last)\//.test(e.pathname))return e;let t=e.searchParams.get("dt"),r=e.searchParams.get("tm"),o=e.searchParams.get("sr"),n=new URL(e);return n.search="",t&&n.searchParams.append("dt",t),n.pathname.startsWith("/transit/route/")&&(r&&n.searchParams.append("tm",r),o&&n.searchParams.append("sr",o)),n},e=>{if(e.host!==location.host||!e.pathname.startsWith("/api/code/"))return e;let t=encodeURIComponent(${e.origin}${e.pathname});return${e}.endsWith(".svg")?${e}:${e}.endsWith(".mlt")?${e}:e},e=>{if(e.hostname==="raw.githubusercontent.com")return${e};if(e.hostname!=="github.com")return e;let[t,r,o]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!o)return e;let[,n,s]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${n&&s?L${n}-${s}/:n?L${n}/:""}https://raw.githubusercontent.com/${t}/${r}/${o}#.svg ${e}]},e=>e.hostname==="github.com"?${e}:e,Gk,Bk()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=qk(e,...PI);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return at(r)})}});Xk(["takker","takker-memex","takker-private","takker-books"]);if(!/mobile/i.test(navigator.userAgent)){let e=(t,r)=>{t.trim()!==""&&sv({mode:r}).then(o=>{if(!o)return;let{ask:n,visible:s,onExit:i}=o,a=c=>{!s()||c.key!=="Enter"||!c.ctrlKey||c.altKey||c.shiftKey||(c.preventDefault(),c.stopPropagation(),n())};dt().addEventListener("keydown",a),i(()=>dt().removeEventListener("keydown",a))})};scrapbox.PopupMenu.addButton({title:()=>"🤖",onClick:t=>e(t)})}var Oi=(e,t)=>t.map(r=>r.replace(/@yyyy-MM-dd HH:mm:ss@/g,pe(e,"yyyy-MM-dd HH:mm:ss")).replace(/@yyyy-MM-dd@/g,pe(e,"yyyy-MM-dd")).replace(/@yyyy-MM-dd(?:([+-])(\d+)(w?))?(?:\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))?@/g,(o,n,s,i,a)=>{let c=n?n==="+"?ve(e,parseInt(s)*(i==="w"?7:1)):zt(e,parseInt(s)*(i==="w"?7:1)):e;return pe(a?ve(Ne(c),OI(a)):c,"yyyy-MM-dd")}).replace(/@yyyy-ww@/g,${Ko(e)}-w${${ko(e)}.padStart(2,"0")}).replace(/@yyyy-ww([+-])(\d+)(w?)@/g,(o,n,s,i)=>{let a=n==="+"?ve(e,parseInt(s)*(i==="w"?7:1)):zt(e,parseInt(s)*(i==="w"?7:1));return${Ko(a)}-w${${ko(a)}.padStart(2,"0")}}).replace(/@yyyy@/g,${Ko(e)}).replace(/@yyyy([+-])(\d+)y@/g,(o,n,s)=>{let i=parseInt(s);return${Ko(e)+(n==="+"?i:-i)}})),OI=e=>{switch(e){case"Sun":return 0;case"Mon":return 1;case"Tue":return 2;case"Wed":return 3;case"Thu":return 4;case"Fri":return 5;default:return 6}};var cv=async(e,t,r,o=new Date(2023,1,3))=>{if(scrapbox.Project.name!==e)return()=>{};let n=scrapbox.Project.pages;await new Promise(l=>{let u=setInterval(()=>{if(n.length===0){n=scrapbox.Project.pages;return}clearInterval(u),l()},2e3)});let s=async()=>{let l=new Date,u={start:o,end:ve(l,1)},{render:p,dispose:f}=De(),m;try{let h=await av(t),g=await av(r),y=Gs(u).filter(b=>{let T=Oi(b,h)[0],v=n.find(A=>A.title===T);return!v||!v.exists}),x=ky(u).filter(b=>{let T=Oi(b,g)[0],v=n.find(A=>A.title===T);return!v||!v.exists});if(y.length===0&&x.length===0)return;let w=y.length+x.length;p({type:"spinner"},{type:"text",text:create ${w} review pages...});let k=await Mt();if(O(k))throw Z(k);m=S(k);for(let b of[...y.map(T=>Oi(T,h)),...x.map(T=>Oi(T,g))])await Le(e,b[0],(T,v)=>v.persistent?void 0:b,m?{socket:m}:{}),w--,p({type:"spinner"},{type:"text",text:create ${w} review pages...});p({type:"check-circle"},{type:"text",text:created ${y.length+x.length} review pages.}),o=l}catch(h){p({type:"exclamation-triangle"},{type:"text",text:h instanceof Error?${h.name} ${h.message}:"Unknown error! (see developper console)"}),console.error(h)}finally{m&&await Ct(m),await Fe(1e3),f()}},i=s(),a=new Date,c=setInterval(()=>{let l=new Date;gt(a,l)||(a=l,i.then(()=>i=s()))},1e4);return()=>(clearTimeout(c),i)},av=async e=>{let t=await ha(e[0],e[1],e[2]);if(O(t)){let o=new Error;throw o.name=Z(t).name,o.message=${Z(t).message} at fetching /${e0}/${e1}/${e2},o}let r=S(t).split(
);if(r.length===0)throw new Error(template "/${e0}/${e1}/${e2}" is empty!);return r};var lv=function(){};function Li(e,t={}){lv.prototype.name=e;let r={};return new Proxy(lv,{get(o,n){return n==="caller"?null:n==="__createMock__"?Li:n==="__unenv__"?!0:n in t?t[n]:r[n]=r[n]||Li(${e}.${n.toString()})},apply(o,n,s){return Li(${e}())},construct(o,n,s){return Li(${e})},enumerate(){return[]}})}var Rf=Li("mock");function SI(e){return new Error(unenv ${e} is not implemented yet!)}function me(e){return Object.assign(()=>{throw SI(e)},{__unenv__:!0})}var LI=Object.freeze(Object.create(null,{__unenv__:{get:()=>!0}})),kl=Object.create(null),NI=globalThis.process?.env,Si=e=>NI||globalThis.__env__||(e?kl:globalThis),MI=new Proxy(kl,{get(e,t){return Si()[t]??kl[t]},has(e,t){let r=Si();return t in r||t in kl},set(e,t,r){let o=Si(!0);return o[t]=r,!0},deleteProperty(e,t){let r=Si(!0);return delete r[t],!0},ownKeys(){let e=Si();return Object.keys(e)}}),CI=Object.assign(function(e){let t=Date.now(),r=Math.trunc(t/1e3),o=t%1e3*1e6;if(e){let n=r-e[0],s=o-e[0];return s<0&&(n=n-1,s=1e9+s),[n,s]}return[r,o]},{bigint:function(){return BigInt(Date.now()*1e6)}}),II=globalThis.queueMicrotask?(e,...t)=>{globalThis.queueMicrotask(e.bind(void 0,...t))}:AI();function AI(){let e=[],t=!1,r,o=-1;function n(){!t||!r||(t=!1,r.length>0?e=[...r,...e]:o=-1,e.length>0&&s())}function s(){if(t)return;let i=setTimeout(n);t=!0;let a=e.length;for(;a;){for(r=e,e=[];++o<a;)r&&r[o]();o=-1,a=e.length}r=void 0,t=!1,clearTimeout(i)}return(i,...a)=>{e.push(i.bind(void 0,...a)),e.length===1&&!t&&setTimeout(s)}}var FI="unenv",DI=[],UI="",$I={ares:"",http_parser:"",icu:"",modules:"",node:"",openssl:"",uv:"",v8:"",zlib:""};function Tr(){return kf}var jI=Tr,BI=Tr,HI=Tr,WI=Tr,qI=Tr,GI=Tr,zI=function(e){return e==="message"||e==="multipleResolves"?kf:!1},VI=Tr,KI=Tr,YI=function(e){return[]},XI=()=>0,JI=function(e){throw new Error("[unenv] process.binding is not supported")},pv="/",QI=function(){return pv},ZI=function(e){pv=e},eA=function(){return 0},tA=function(){return 1e3},rA=function(){return 1e3},oA=function(){return 1e3},nA=function(){return 1e3},sA=function(){return[]},iA=e=>{},aA=me("process.abort"),cA=new Set,lA="",pA="",uA=LI,mA=!1,fA=()=>0,dA=()=>0,hA=me("process.cpuUsage"),gA=0,yA=me("process.dlopen"),xA=Tr,bA=Tr,EA=me("process.eventNames"),wA=[],RA="",kA=me("process.exit"),vA=Object.create({inspector:void 0,debug:void 0,uv:void 0,ipv6:void 0,tls_alpn:void 0,tls_sni:void 0,tls_ocsp:void 0,tls:void 0,cached_builtins:void 0}),TA=()=>[],_A=me("process.getMaxListeners"),PA=me("process.kill"),OA=Object.assign(()=>({arrayBuffers:0,rss:0,external:0,heapTotal:0,heapUsed:0}),{rss:()=>0}),SA=1e3,LA="",NA=1e3,MA=me("process.rawListeners"),CA=Object.create({name:"",lts:"",sourceUrl:void 0,headersUrl:void 0}),IA=Object.create({compact:void 0,directory:void 0,filename:void 0,getReport:me("process.report.getReport"),reportOnFatalError:void 0,reportOnSignal:void 0,reportOnUncaughtException:void 0,signal:void 0,writeReport:me("process.report.writeReport")}),AA=me("process.resourceUsage"),FA=me("process.setegid"),DA=me("process.seteuid"),UA=me("process.setgid"),$A=me("process.setgroups"),jA=me("process.setuid"),BA=me("process.setMaxListeners"),HA=me("process.setSourceMapsEnabled"),WA=Rf.__createMock__("process.stdout"),qA=Rf.__createMock__("process.stderr"),GA=Rf.__createMock__("process.stdin"),zA=!1,VA=()=>0,KA=0,YA=me("process.setUncaughtExceptionCaptureCallback"),XA=()=>!1,JA=!1,QA=me("process.loadEnvFile"),ZA=void 0,eF={has:()=>!1},tF={ref(){},unref(){}},rF=!1,oF={register(){},unregister(){},registerBeforeExit(){}},nF=me("process.assert"),sF=me("process.openStdin"),iF=me("process._debugEnd"),aF=me("process._debugProcess"),cF=me("process._fatalException"),lF=me("process._getActiveHandles"),pF=me("process._getActiveRequests"),uF=me("process._kill"),mF=[],fF=me("process._rawDebug"),dF=me("process._startProfilerIdleNotifier"),hF=me("process.__stopProfilerIdleNotifier"),gF=me("process._tickCallback"),Hst=me("process._linkedBinding"),yF=void 0,xF=me("process.initgroups"),bF=[],EF=Tr,wF=!1,RF=[],kF=0,vF=0,kf={_events:RF,_eventsCount:kF,_exiting:wF,_maxListeners:vF,_debugEnd:iF,_debugProcess:aF,_fatalException:cF,_getActiveHandles:lF,_getActiveRequests:pF,_kill:uF,_preload_modules:mF,_rawDebug:fF,_startProfilerIdleNotifier:dF,_stopProfilerIdleNotifier:hF,_tickCallback:gF,domain:yF,initgroups:xF,moduleLoadList:bF,reallyExit:EF,exitCode:KA,abort:aA,addListener:BI,allowedNodeEnvironmentFlags:cA,hasUncaughtExceptionCaptureCallback:XA,setUncaughtExceptionCaptureCallback:YA,loadEnvFile:QA,sourceMapsEnabled:JA,throwDeprecation:rF,mainModule:ZA,permission:eF,channel:tF,arch:lA,argv:DI,argv0:pA,assert:nF,binding:JI,chdir:ZI,config:uA,connected:mA,constrainedMemory:fA,availableMemory:dA,cpuUsage:hA,cwd:QI,debugPort:gA,dlopen:yA,disconnect:xA,emit:zI,emitWarning:bA,env:MI,eventNames:EA,execArgv:wA,execPath:RA,exit:kA,finalization:oF,features:vA,getBuiltinModule:iA,getegid:tA,geteuid:rA,getgid:oA,getgroups:sA,getuid:nA,getActiveResourcesInfo:TA,getMaxListeners:_A,hrtime:CI,kill:PA,listeners:YI,listenerCount:XI,memoryUsage:OA,nextTick:II,on:jI,off:WI,once:HI,openStdin:sF,pid:SA,platform:LA,ppid:NA,prependListener:VI,prependOnceListener:KI,rawListeners:MA,release:CA,removeAllListeners:GI,removeListener:qI,report:IA,resourceUsage:AA,setegid:FA,seteuid:DA,setgid:UA,setgroups:$A,setuid:jA,setMaxListeners:BA,setSourceMapsEnabled:HA,stderr:qA,stdin:GA,stdout:WA,title:FI,traceDeprecation:zA,umask:eA,uptime:VA,version:UI,versions:$I},Ni=kf;var TF=Object.create,gv=Object.defineProperty,_F=Object.getOwnPropertyDescriptor,PF=Object.getOwnPropertyNames,OF=Object.getPrototypeOf,SF=Object.prototype.hasOwnProperty,yv=(e=>typeof Fo<"u"?Fo:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof Fo<"u"?Fo:t)[r]}):e)(function(e){if(typeof Fo<"u")return Fo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),xv=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),LF=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of PF(t))!SF.call(e,n)&&n!==r&&gv(e,n,{get:()=>t[n],enumerable:!(o=_F(t,n))||o.enumerable});return e},bv=(e,t,r)=>(r=e!=null?TF(OF(e)):{},LF(t||!e||!e.__esModule?gv(r,"default",{value:e,enumerable:!0}):r,e)),NF=xv((e,t)=>{var r=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in Ni&&"node"in Ni.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{r=[yv][0](${"node","util".join(":")})}catch{r=null}t.exports=r}),MF=xv((e,t)=>{var r=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in Ni&&"node"in Ni.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{r=[yv][0](${"node","fs".join(":")})}catch{r=null}t.exports=r}),CF={},vl=IF(globalThis,CF);function IF(e,t){return new Proxy(e,{get(r,o,n){return o in t?t[o]:e[o]},set(r,o,n){return o in t&&delete t[o],e[o]=n,!0},deleteProperty(r,o){let n=!1;return o in t&&(delete t[o],n=!0),o in e&&(delete e[o],n=!0),n},ownKeys(r){let o=Reflect.ownKeys(e),n=Reflect.ownKeys(t),s=new Set(n);return[...o.filter(i=>!s.has(i)),...n]},defineProperty(r,o,n){return o in t&&delete t[o],Reflect.defineProperty(e,o,n),!0},getOwnPropertyDescriptor(r,o){return o in t?Reflect.getOwnPropertyDescriptor(t,o):Reflect.getOwnPropertyDescriptor(e,o)},has(r,o){return o in t||o in e}})}var uv=["debug","info","warning","error","fatal"];function mv(e,t){let r=uv.indexOf(e);if(r<0)throw new TypeError(Invalid log level: ${JSON.stringify(e)}.);let o=uv.indexOf(t);if(o<0)throw new TypeError(Invalid log level: ${JSON.stringify(t)}.);return r-o}function Mi(e=[]){return Ev.getLogger(e)}var vf=Symbol.for("logtape.rootLogger"),Ev=class Ao{static getLogger(t=[]){let r=vf in vl?vl[vf]??null:null;return r==null&&(r=new Ao(null,[]),vl[vf]=r),typeof t=="string"?r.getChild(t):t.length===0?r:r.getChild(t)}constructor(t,r){Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"category",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sinks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parentSinks",{enumerable:!0,configurable:!0,writable:!0,value:"inherit"}),Object.defineProperty(this,"filters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lowestLevel",{enumerable:!0,configurable:!0,writable:!0,value:"debug"}),Object.defineProperty(this,"contextLocalStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.parent=t,this.children={},this.category=r,this.sinks=[],this.filters=[]}getChild(t){let r=typeof t=="string"?t:t[0],o=this.children[r],n=o instanceof Ao?o:o?.deref();return n==null&&(n=new Ao(this,[...this.category,r]),this.children[r]="WeakRef"in vl?new WeakRef(n):n),typeof t=="string"||t.length===1?n:n.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks="inherit";this.filters.length>0;)this.filters.shift();this.lowestLevel="debug"}resetDescendants(){for(let t of Object.values(this.children))(t instanceof Ao?t:t.deref())?.resetDescendants();this.reset()}with(t){return new AF(this,{...t})}filter(t){for(let r of this.filters)if(!r(t))return!1;return this.filters.length<1?this.parent?.filter(t)??!0:!0}*getSinks(t){if(!(this.lowestLevel===null||mv(t,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks==="inherit")for(let r of this.parent.getSinks(t))yield r;for(let r of this.sinks)yield r}}emit(t,r){if(!(this.lowestLevel===null||mv(t.level,this.lowestLevel)<0||!this.filter(t))){for(let o of this.getSinks(t.level))if(!r?.has(o))try{o(t)}catch(n){let s=new Set(r);s.add(o),FF.log("fatal","Failed to emit a log record to sink {sink}: {error}",{sink:o,error:n,record:t},s)}}}log(t,r,o,n){let s=Ao.getLogger().contextLocalStorage?.getStore()??{},i,a=typeof o=="function"?{category:this.category,level:t,timestamp:Date.now(),get message(){return fv(r,this.properties)},rawMessage:r,get properties(){return i==null&&(i={...s,...o()}),i}}:{category:this.category,level:t,timestamp:Date.now(),message:fv(r,{...s,...o}),rawMessage:r,properties:{...s,...o}};this.emit(a,n)}logLazily(t,r,o={}){let n=Ao.getLogger().contextLocalStorage?.getStore()??{},s,i;function a(){if((i==null||s==null)&&(i=r((c,...l)=>(s=c,dv(c,l))),s==null))throw new TypeError("No log record was made.");return[i,s]}this.emit({category:this.category,level:t,get message(){return a()[0]},get rawMessage(){return a()[1]},timestamp:Date.now(),properties:{...n,...o}})}logTemplate(t,r,o,n={}){let s=Ao.getLogger().contextLocalStorage?.getStore()??{};this.emit({category:this.category,level:t,message:dv(r,o),rawMessage:r,timestamp:Date.now(),properties:{...s,...n}})}debug(t,...r){typeof t=="string"?this.log("debug",t,r[0]??{}):typeof t=="function"?this.logLazily("debug",t):this.logTemplate("debug",t,r)}info(t,...r){typeof t=="string"?this.log("info",t,r[0]??{}):typeof t=="function"?this.logLazily("info",t):this.logTemplate("info",t,r)}warn(t,...r){typeof t=="string"?this.log("warning",t,r[0]??{}):typeof t=="function"?this.logLazily("warning",t):this.logTemplate("warning",t,r)}error(t,...r){typeof t=="string"?this.log("error",t,r[0]??{}):typeof t=="function"?this.logLazily("error",t):this.logTemplate("error",t,r)}fatal(t,...r){typeof t=="string"?this.log("fatal",t,r[0]??{}):typeof t=="function"?this.logLazily("fatal",t):this.logTemplate("fatal",t,r)}},AF=class wv{constructor(t,r){Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.logger=t,this.properties=r}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(t){return this.logger.getChild(t).with(this.properties)}with(t){return new wv(this.logger,{...this.properties,...t})}log(t,r,o,n){this.logger.log(t,r,typeof o=="function"?()=>({...this.properties,...o()}):{...this.properties,...o},n)}logLazily(t,r){this.logger.logLazily(t,r,this.properties)}logTemplate(t,r,o){this.logger.logTemplate(t,r,o,this.properties)}debug(t,...r){typeof t=="string"?this.log("debug",t,r[0]??{}):typeof t=="function"?this.logLazily("debug",t):this.logTemplate("debug",t,r)}info(t,...r){typeof t=="string"?this.log("info",t,r[0]??{}):typeof t=="function"?this.logLazily("info",t):this.logTemplate("info",t,r)}warn(t,...r){typeof t=="string"?this.log("warning",t,r[0]??{}):typeof t=="function"?this.logLazily("warning",t):this.logTemplate("warning",t,r)}error(t,...r){typeof t=="string"?this.log("error",t,r[0]??{}):typeof t=="function"?this.logLazily("error",t):this.logTemplate("error",t,r)}fatal(t,...r){typeof t=="string"?this.log("fatal",t,r[0]??{}):typeof t=="function"?this.logLazily("fatal",t):this.logTemplate("fatal",t,r)}},FF=Ev.getLogger(["logtape","meta"]);function fv(e,t){let r=[],o="";for(let n=0;n<e.length;n++){let s=e.charAt(n),i=e.charAt(n+1);if(s==="{"&&i==="{")o=o+s,n++;else if(s==="}"&&i==="}")o=o+s,n++;else if(s==="{")r.push(o),o="";else if(s==="}"){let a;o.match(/^\s|\s$/)?a=o in t?t[o]:t[o.trim()]:a=t[o],r.push(a),o=""}else o=o+s}return r.push(o),r}function dv(e,t){let r=[];for(let o=0;o<e.length;o++)r.push(e[o]),o<t.length&&r.push(t[o]);return r}var DF=bv(NF()),Tl=DF.default,hv={debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},Rv="Deno"in globalThis&&"inspect"in globalThis.Deno&&typeof globalThis.Deno.inspect=="function"?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):Tl!=null&&"inspect"in Tl&&typeof Tl.inspect=="function"?(e,t)=>Tl.inspect(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function kv(e={}){let t=e.timestamp==null||e.timestamp==="date-time-timezone"?i=>new Date(i).toISOString().replace("T"," ").replace("Z"," +00:00"):e.timestamp==="date-time-tz"?i=>new Date(i).toISOString().replace("T"," ").replace("Z"," +00"):e.timestamp==="date-time"?i=>new Date(i).toISOString().replace("T"," ").replace("Z",""):e.timestamp==="time-timezone"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z"," +00:00"):e.timestamp==="time-tz"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z"," +00"):e.timestamp==="time"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z",""):e.timestamp==="date"?i=>new Date(i).toISOString().replace(/T.*/,""):e.timestamp==="rfc3339"?i=>new Date(i).toISOString():e.timestamp,r=e.category??"·",o=e.value??Rv,n=e.level==null||e.level==="ABBR"?i=>hv[i]:e.level==="abbr"?i=>hv[i].toLowerCase():e.level==="FULL"?i=>i.toUpperCase():e.level==="full"?i=>i:e.level==="L"?i=>i.charAt(0).toUpperCase():e.level==="l"?i=>i.charAt(0):e.level,s=e.format??(({timestamp:i,level:a,category:c,message:l})=>${i} ${a} ${c}: ${l});return i=>{let a="";for(let p=0;p<i.message.length;p++)p%2===0?a+=i.message[p]:a+=o(i.message[p]);let c=t(i.timestamp),l=n(i.level),u=typeof r=="function"?r(i.category):i.category.join(r);return${s({timestamp:c,level:l,category:u,message:a,record:i})}
}}var Gst=kv(),Tf="\x1B[0m",_f={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},Pf={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},UF={debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};function $F(e={}){let t=e.format,r=typeof e.timestampStyle>"u"?"dim":e.timestampStyle,o=e.timestampColor??null,n=${r==null?"":Pfr}${o==null?"":_fo},s=r==null&&o==null?"":Tf,i=typeof e.levelStyle>"u"?"bold":e.levelStyle,a=e.levelColors??UF,c=typeof e.categoryStyle>"u"?"dim":e.categoryStyle,l=e.categoryColor??null,u=${c==null?"":Pfc}${l==null?"":_fl},p=c==null&&l==null?"":Tf;return kv({timestamp:"date-time-tz",value(f){return Rv(f,{colors:!0})},...e,format({timestamp:f,level:m,category:h,message:g,record:y}){let x=a[y.level];return f=${n}${f}${s},m=${i==null?"":Pfi}${x==null?"":_fx}${m}${i==null&&x==null?"":Tf},t==null?${f} ${m} ${u}${h}:${p} ${g}:t({timestamp:f,level:m,category:${u}${h}${p},message:g,record:y})}})}var zst=$F();var jF=bv(MF()),BF=jF.default;function Rs(){throw new Error("File sink is not available in the browser.")}var HF={openSync:Rs,writeSync:Rs,flushSync:Rs,closeSync:Rs,statSync:Rs,renameSync:Rs},Rn=BF,Vst=Rn==null?HF:{openSync(e){return Rn.openSync(e,"a")},writeSync:Rn.writeSync,flushSync:Rn.fsyncSync,closeSync:Rn.closeSync,statSync:Rn.statSync,renameSync:Rn.renameSync};async function*vv(e){let t=[],r=[],o=new Map,n=[];for(let s of e)s.isValid&&(s.id?s.isMember||t.push(s.id):r.push(s.name),n.push(s.name),o.set(s.name,s.checked));for(let s=0;s<t.length;s+=50){let i=t.slice(s,s+50);if(i.length===0)break;i.length===1&&i.push(i[0]);let a=await ma(i);if(O(a)){r=n;break}for(let c of S(a).projects)o.has(c.name)&&(yield L({...c,checked:o.get(c.name)??0}))}for(let s of r){let i=await $o(s);yield K(i)?L({...S(i),checked:o.get(s)??0}):M({...Z(i),project:s})}}var Lf=(e,t)=>t.some(r=>e instanceof r),Tv,_v;function WF(){return Tv||(Tv=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function qF(){return _v||(_v=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Nf=new WeakMap,Of=new WeakMap,_l=new WeakMap;function GF(e){let t=new Promise((r,o)=>{let n=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(kn(e.result)),n()},i=()=>{o(e.error),n()};e.addEventListener("success",s),e.addEventListener("error",i)});return _l.set(t,e),t}function zF(e){if(Nf.has(e))return;let t=new Promise((r,o)=>{let n=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),n()},i=()=>{o(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});Nf.set(e,t)}var Mf={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Nf.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return kn(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Lv(e){Mf=e(Mf)}function VF(e){return qF().includes(e)?function(...t){return e.apply(Cf(this),t),kn(this.request)}:function(...t){return kn(e.apply(Cf(this),t))}}function KF(e){return typeof e=="function"?VF(e):(e instanceof IDBTransaction&&zF(e),Lf(e,WF())?new Proxy(e,Mf):e)}function kn(e){if(e instanceof IDBRequest)return GF(e);if(Of.has(e))return Of.get(e);let t=KF(e);return t!==e&&(Of.set(e,t),_l.set(t,e)),t}var Cf=e=>_l.get(e);function Nv(e,t,{blocked:r,upgrade:o,blocking:n,terminated:s}={}){let i=indexedDB.open(e,t),a=kn(i);return o&&i.addEventListener("upgradeneeded",c=>{o(kn(i.result),c.oldVersion,c.newVersion,kn(i.transaction),c)}),r&&i.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),n&&c.addEventListener("versionchange",l=>n(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}var YF=["get","getKey","getAll","getAllKeys","count"],XF=["put","add","delete","clear"],Sf=new Map;function Pv(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Sf.get(t))return Sf.get(t);let r=t.replace(/FromIndex$/,""),o=t!==r,n=XF.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(n||YF.includes(r)))return;let s=async function(i,...a){let c=this.transaction(i,n?"readwrite":"readonly"),l=c.store;return o&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),n&&c.done]))[0]};return Sf.set(t,s),s}Lv(e=>({...e,get:(t,r,o)=>Pv(t,r)||e.get(t,r,o),has:(t,r)=>!!Pv(t,r)||e.has(t,r)}));var JF=["continue","continuePrimaryKey","advance"],Ov={},If=new WeakMap,Mv=new WeakMap,QF={get(e,t){if(!JF.includes(t))return e[t];let r=Ov[t];return r||(r=Ov[t]=function(...o){If.set(this,Mv.get(this)[t](...o))}),r}};async function*ZF(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let r=new Proxy(t,QF);for(Mv.set(r,t),_l.set(r,Cf(t));t;)yield r,t=await(If.get(r)||t.continue()),If.delete(r)}function Sv(e,t){return t===Symbol.asyncIterator&&Lf(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Lf(e,[IDBIndex,IDBObjectStore])}Lv(e=>({...e,get(t,r,o){return Sv(t,r)?ZF:e.get(t,r,o)},has(t,r){return Sv(t,r)||e.has(t,r)}}));var Cv,Af=async()=>{let e=Mi(["@takker/cosense-storage","open"]);return Cv??=await Nv("scrapbox-storage",4,{upgrade(t,r,o){e.infostart updating DB: ${r} -> ${o};let n=Date.now();for(let a of t.objectStoreNames)t.deleteObjectStore(a);t.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let i=t.createObjectStore("projects",{keyPath:"id"});i.createIndex("checked","checked"),i.createIndex("name","name"),e.infofinish updating DB: ${Date.now()-n}ms},blocked(t,r){let o=The database "@takker/cosense-storage"(v${r}) is blocked because the older one (v${t}) is opened in other tabs.
Please close the other tabs and reload this page.;e.error(o),alert(o)},blocking(t,r){let o=The database "@takker/cosense-storage"(v${t}) is blocking the newer one (v${r}) opened.
Please close this page.;e.error(o),alert(o)}}),Cv};var Iv=(e,t)=>(Ff||(Ff=new BroadcastChannel(Fv),Ff.addEventListener("message",r=>Av(r.data))),Pl.set(t,new Set(e).union(Pl.get(t)??new Set)),()=>Pl.delete(t)),Df=(e,t)=>{if((t.added?.size??0)+(t.updated?.size??0)+(t.deleted?.size??0)===0)return;let r={type:"links:changed",project:e,diff:t};Av(r);let o=new BroadcastChannel(Fv);o.postMessage(r),o.close()},Av=e=>{for(let[t,r]of Pl)r.has(e.project)&&t(e)},Fv="scrapbox-storage-notify",Ff,Pl=new Map;var Dv=async(e,t)=>{let r=await Af(),o=Mi(["@takker/cosense-storage","check"]),n=new Map;try{{o.debugcheck updates of links...;let i=new Set,a=r.transaction("projects","readwrite"),c=uf(new Date),l=c-600;for await(let f of a.store.index("checked").iterate(IDBKeyRange.lowerBound(l,!0))){let m=f.value;if(m.isValid===!1){i.add(m.id);continue}i.add(m.name);let h=m.checked;if(h+t>c||m?.updating&&h>l)continue;let g=structuredClone(m);g.updating=!0,n.set(m.id,g),f.update(g)}let u=[],p=a.store.index("name");for(let f of e)i.has(f)||u.push(p.get(f).then(m=>{m?.updating&&(m?.checked??0)>l||n.set(f,m??eD(f))}));if(await Promise.all(u),await a.done,n.size===0){o.debugchecked. No project needs upgrade.;return}o.debugchecked. ${n.size} projects maybe need upgrade.}let s=uf(new Date);for await(let i of vv(n.values())){if(O(i)){let{project:h,name:g}=Z(i);switch(g){default:continue;case"NotFoundError":o.warn("${h}" is not found.);break;case"NotMemberError":o.warn(You are not a member of "${h}".);break;case"NotLoggedInError":o.warn(You are not a member of "${h}" or You are not logged in yet.);break}n.set(h,{id:h,name:h,checked:s,updating:!1,isValid:!1,reason:g});continue}let{checked:a,...c}=S(i);if(c.updated<a){o.debugno updates in "${c.name}",n.set(c.name,{...c,isValid:!0,checked:s,updating:!1});continue}o.debugstart downloading and storing links of "${c.name}";let l=new Set(await r.getAllKeysFromIndex("titles","project",c.name)),u=0,p=0;for await(let h of Ah(c.name)){if(O(h)){let{name:w,message:k}=Z(h);o.errorFailed to get links of "${c.name}" with ${w}: ${k};break}let g=S(h),y={},x=r.transaction("titles","readwrite");await Promise.all(g.map(async w=>{let k={...w,project:c.name},b=await x.store.get(w.id);if(!b)return y.added?.set?.(w.id,k)??(y.added=new Map([[w.id,k]])),x.store.add(k);if(l.delete(w.id),!!tD(k,b))return y.updated?.set?.(w.id,[b,k])??(y.updated=new Map([[w.id,[b,k]]])),x.store.put(k)})),await x.done,u+=y.added?.size??0,p+=y.updated?.size??0,o.debugUpdating "/${c.name}": +${u} pages, ~${p} pages,Df(c.name,y)}let f=r.transaction("titles","readwrite"),m=new Map((await Promise.all([...l].map(async h=>{let g=await f.store.get(h);if(!g)return[];let y=[[h,g]];return await f.store.delete(h),y}))).flat());await f.done,o.debugFinish downloading and storing links of "${c.name}",o.debugUpdate "/${c.name}": +${u} pages, ~${p} pages, -${m.size} pages,n.set(c.name,{...c,isValid:!0,checked:s,updating:!1}),Df(c.name,{deleted:m})}}finally{let s=r.transaction("projects","readwrite");await Promise.all([...n].map(([,i])=>(i.updating=!1,s.store.put({...i})))),await s.done}},Ol=async e=>{let t=[...new Set(e)];if(t.length===0)return[];let r=Date.now(),n=(await Af()).transaction("titles","readonly"),s=n.store.index("project"),i=(await Promise.all(t.map(c=>s.getAll(c)))).flat();return await n.done,Mi(["@takker/cosense-storage","load"]).debugRead ${i.length} links from ${t.length} projects in ${Date.now()-r}ms,i},eD=e=>({name:e,displayName:e,id:"",isValid:!0,publicVisible:!0,isMember:!0,loginStrategies:[],theme:"default",gyazoTeamsName:null,translation:!0,infobox:!0,checked:0,updated:0,created:0,updating:!0}),tD=(e,t)=>e.updated>t.updated||e.links.sort().join()!==t.links.sort().join();var Wt=e=>${e.getFullYear()}-${kr(e.getMonth()+1)}-${kr(e.getDate())},Ci=e=>{let[t,r,o]=e.split("-").map(n=>parseInt(n,10));return{year:t,month:r,date:o}},Ii=e=>${Vo(e)}-w${kr(ko(e))},Sl=e=>{let[t,r]=e.split("-w").map(o=>parseInt(o,10));return Ne(qa(new Date(t,0,1),r))};var Uv="takker-memex",$v=async(e=new Date(2023,0,24))=>{if(scrapbox.Project.name!==Uv)return()=>{};let t=scrapbox.Project.pages;await new Promise(i=>{let a=setInterval(()=>{if(t.length===0){t=scrapbox.Project.pages;return}clearInterval(a),i()},2e3)});let r=async()=>{let i=new Date,c=Gs({start:e,end:i}).filter(f=>{let m=Rr(f),h=t.find(g=>g.title===m);return!h||!h.exists});if(c.length===0)return;let{render:l,dispose:u}=De(),p;try{l({type:"spinner"},{type:"text",text:load tasks for ${c.length} diary pages});let f=new Map,m=new Set,h=c.map(x=>Wt(x));for(let{title:x,links:w,project:k}of await Ol(["takker","takker-memex"]))for(let b of[x,...w]){let T=Mr(b);if(!T)continue;if(O(T)){let{name:F,message:D}=Z(T);console.error(/${k}/${b}: ${F} ${D});continue}let v=ae(b);if(m.has(v))continue;m.add(v);let A=S(T);if(A.freshness?.status!=="done")for(let F of c){let D=ti(A,F);if(!D)continue;let N=Wt(D.base);h.includes(N)&&(f.set(N,[...f.get(N)??[],D]),_o(A))}}let g=await Mt();if(O(g))throw Z(g);p=S(g);let y=0;l({type:"spinner"},{type:"text",text:create 0/${c.length} diary pages...});for(let x of c){let w=Rr(x),k=f.get(Wt(x))?.map?.(v=>Pe(v))??[],b=#${pe(x,"yyyy-MM-dd")},T=#${pe(x,"yyyy-MM-dd HH:mm:ss")};await Le(Uv,w,(v,{persistent:A})=>{if(A)return;let F=[...v.map(D=>D.text),...k];return F.some(D=>D.includes(b))?en(F):en([...F,T])},{socket:p}),y++,l({type:"spinner"},{type:"text",text:create ${y}/${c.length} diary pages...})}l({type:"check-circle"},{type:"text",text:created ${c.length} diary pages.}),e=i}catch(f){l({type:"exclamation-triangle"},{type:"text",text:f instanceof Error?${f.name} ${f.message}:"Unknown error! (see developper console)"}),console.error(f)}finally{p&&await Ct(p),await Fe(1e3),u()}},o=r(),n=new Date,s=setInterval(()=>{let i=new Date;gt(n,i)||(n=i,o.then(()=>o=r()))},1e4);return()=>(clearTimeout(s),o)};$v(new Date(2024,11,24));var $f=(...e)=>{let t=e.flatMap(o=>{if(typeof o=="string")return[Ll(o)];if(Array.isArray(o.type))return[jv(o.type)];switch(o.type){case"text":return[Ll(o.text)];case"group":{let n=$f(...o.items);return n?[n]:[]}default:return[jv(o.type)]}});if(t.length===0)return;if(t.length===1)return t[0];let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},Ll=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},jv=e=>{if(Array.isArray(e)){let t=document.createElement("span");t.classList.add("fa-stack");let r=Uf(e[0]);r.classList.add("fa-stack-1x");let o=Uf(e[1]);return o.classList.add("fa-stack-1x"),t.append(r,o),Ll(t)}return Ll(Uf(e))},Uf=e=>{let t=document.createElement("i");switch(e){case"spinner":t.classList.add("fa","fa-spinner");break;case"check-circle":case"gyazo":case"ocr":case"calendar":case"trim":t.classList.add("kamon",kamon-${e});break;case"markdown":case"google":t.classList.add("fab",fa-${e});break;case"copy":case"clipboard":t.classList.add("far",fa-${e});break;default:t.classList.add("fas",fa-${e});break}return t};var{cursor:jf,selection:Bf}=Bt(),Hv=e=>{let{className:t,display:r,onClick:o,context:n="page"}=e,s=document.createElement("div");t&&s.classList.add(t),Bv(n)||(s.style.display="none");let i=(...l)=>{if(l.length===1&&l[0]===""){s.style.display="none";return}s.textContent="";let u=$f(...l);u&&s.append(u)},a=typeof r=="function"?r({cursor:jf,selection:Bf}):r;return i(...Array.isArray(a)?a:[a]),s.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o({cursor:jf,selection:Bf,setDisplay:i})}),{status:s,context:n,update:()=>{if(Bv(n)?s.removeAttribute("style"):s.style.display="none",typeof r=="function"){let l=r({cursor:jf,selection:Bf});i(...Array.isArray(l)?l:[l])}}}},Bv=e=>e!=="stream"?scrapbox.Layout===e:scrapbox.Layout==="list"&&location.pathname.startsWith("/stream");var Wv=()=>{let e=document.createElement("style");e.textContent=.status-bar.left {
position: absolute;
top: 0;
left: 0;
max-width: 80vw;
overflow-x: auto;
overflow-y: hidden;
}
.status-bar.left:empty {
display: none;
}
.status-bar.left > div {
border-left: unset;
}
.status-bar.left > div {
border-right: 1px solid var(--tool-light-color, #a9aaaf);
}
.status-bar.left > div:first-of-type {
border-top-left-radius: unset;
}
.status-bar.left > div:last-of-type {
border-top-right-radius: 3px;
},document.head.append(e);let t=document.createElement("div");return t.classList.add("status-bar","left"),document.getElementsByClassName("footer")[0].append(t),t};var Hf=new Set,{cursor:rD,selection:oD}=Bt(),nD=Wv();var hr=e=>{let t=Hv(e);return Hf.add(t),nD.append(t.status),()=>{t.status.remove(),Hf.delete(t)}},Wf=()=>{for(let{update:e}of Hf)e()};rD.addChangeListener(()=>Wf());oD.addChangeListener(()=>Wf());scrapbox.addListener("layout:changed",Wf);var qv=async(e,t)=>{try{let r=t.getSelectedText()||kt(e.getPosition().line);if(!r)return;await navigator.clipboard.writeText(r)}catch(r){console.error(r),alert(Faild to copy:
${JSON.stringify(r)})}},Gv=async(e,t)=>{try{let r=t.hasSelection(),o=r?t.getRange().start.line:e.getPosition().line,n=r?t.getSelectedText():kt(o);if(!n)return;await navigator.clipboard.writeText(n),r||t.setRange({start:{line:o,char:0},end:{line:o,char:n.length}}),e.focus(),vt("Delete")}catch(r){console.error(r),alert(Faild to cut:
${JSON.stringify(r)})}},zv=async e=>{try{let t=await navigator.clipboard.readText();if(!t)return;e.focus(),await at(t)}catch(t){console.error(t),alert(Faild to paste:
${JSON.stringify(t)})}},Vv=e=>{e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?e.hide():(e.focus(),e.showEditPopupMenu())};globalThis.addEventListener("keydown",e=>{if(e.key!=="i"||e.shiftKey||e.altKey||e.metaKey||!e.ctrlKey||e.isComposing)return;let t=Eo();t.hasFocus||(e.preventDefault(),t.focus())});var qf=class{get editor(){return document.getElementById("editor")}get lines(){return document.getElementsByClassName("lines")?.[0]}get computeLine(){return document.getElementById("compute-line")}get grid(){return document.getElementsByClassName("related-page-list clearfix")?.[0]?.getElementsByClassName("grid")?.[0]}get cursorLine(){return document.getElementsByClassName("cursor-line")?.[0]}get textInput(){return document.getElementById("text-input")}get cursor(){return document.getElementsByClassName("cursor")?.[0]}get selections(){return document.getElementsByClassName("selections")?.[0]}get popupMenu(){return document.getElementsByClassName("popup-menu")?.[0]}get pageMenus(){return document.getElementsByClassName("page-menu")?.[0]}get pageInfoMenu(){return document.getElementById("page-info-menu")}get pageEditMenu(){return document.getElementById("page-edit-menu")}get pageEditButtons(){return this.pageEditMenu.nextElementSibling.getElementsByTagName("a")}get randomJumpButton(){return document.getElementsByClassName("random-jump-button")?.[0]}get pageCustomButtons(){return document.getElementsByClassName("page-menu-extension")}},Kv=new qf;var Yv=e=>new Promise(t=>setTimeout(t,e));async function _r(e,{wait:t=1}={}){let r=Kv.textInput;r.focus(),r.value=e;let o=document.createEvent("UIEvent");o.initEvent("input",!0,!1),r.dispatchEvent(o),await Yv(t)}if(wn()){let e="Timestamp";scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/add-time.png"}),scrapbox.PageMenu(e).addItem({title:"#YYYY-MM-DD HH:mm:ss ",onClick:()=>_r(pe(new Date,"#yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD HH:mm:ss ",onClick:()=>_r(pe(new Date,"yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD",onClick:()=>_r(pe(new Date,"yyyy-MM-dd"))}),scrapbox.PageMenu(e).addItem({title:"HH:mm:ss ",onClick:()=>_r(pe(new Date,"HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"⬜",onClick:()=>_r("⬜")}),scrapbox.PageMenu(e).addItem({title:"🚧",onClick:()=>_r("🚧")}),scrapbox.PageMenu(e).addItem({title:"⌛",onClick:()=>_r("⌛")}),scrapbox.PageMenu(e).addItem({title:"📝",onClick:()=>_r("📝")}),scrapbox.PageMenu(e).addItem({title:"✅",onClick:()=>_r("✅")}),scrapbox.PageMenu(e).addItem({title:"❌",onClick:()=>_r("❌")})}scrapbox.PageMenu.addItem({title:"Open kakeru",image:"https://i.kakeru.app/15c3b1a40b6b3c2ebd68f33f4c86b3f6-opaque.png",onClick:()=>window.open("https://kakeru.app")});var Ai=e=>{let{fetch:t=(n,s)=>globalThis.fetch(n,s),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var sD=(e,t,r)=>{let{sid:o,baseURL:n,followRename:s,projects:i}=Ai(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(${n}api/pages/${e}/${ne(t)}?${a},o?{headers:{Cookie:Re(o)}}:void 0)},Gf=(e,t,r)=>Ai(r??{}).fetch(sD(e,t,r));var zf=e=>{let t=Math.round(e/5),r=Math.floor(t/6),o=Math.floor((t-r*6)/3),n=t-r*6-o*3;return${r>20?🍅x${(e/30).toFixed(1)}:"🍅".repeat(r)}${"🍊".repeat(o)}${"🍓".repeat(n)}};var iD=()=>{let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.textAlign="right",e},ks=new Map,Nl,Vf=()=>{for(let r of ks.values())r.remove();ks.clear();let e=Yc(()=>aD(At()),{interval:1e3,maxQueued:0}),t=()=>{e.clear(),e()};if(scrapbox.Layout!=="page"){if(scrapbox.removeListener("lines:changed",t),!Nl)return;clearInterval(Nl),Nl=void 0;return}t(),scrapbox.addListener("lines:changed",t),Nl=setInterval(t,60*1e3)},aD=e=>{for(let t of e){let r=Tt(t.text);if(!r?.record?.start){ks.get(t.id)?.remove?.(),ks.delete(t.id);continue}let o=ks.get(t.id)??iD();Yr(t.id)?.append?.(o),ks.set(t.id,o),o.textContent=zf(vo(r.record.end??new Date,r.record.start))}};scrapbox.Project.name==="takker-memex"&&(Vf(),scrapbox.addListener("page:changed",Vf),scrapbox.addListener("lines:changed",Vf));var cD=e=>{let[t,r]=e.reduce((o,{text:n})=>{let s=Tt(n);return s?.record?.start?s.record.end?(o[1].push(s.record.end),o):(s.record.start&&o[0].push(s.record.start),o):o},[[],[]]);if(t.length===0&&t.push(...r),t.length!==0)return lf(t)},lD=async(e,t)=>{let[r,o]=await Promise.all([Gf(e,Rr(t),{fetch:Xv}),Gf(e,Rr(zt(t,1)),{fetch:Xv})]),n=r.ok?(await r.json()).lines:[];return o.ok&&n.push(...(await o.json()).lines),n},Xv=async(e,t)=>{let r=await bo(new Request(e,t));return!r||Ri(new Date,new Date(${r.headers.get("Date")}))>=60?globalThis.fetch(e,t):r},{render:pD}=De(),Jv=async()=>{let e=cD(await lD("takker-memex",new Date))??Er(new Date);pD({type:"text",text:zf(vo(new Date,e))})};Jv();setInterval(Jv,60*1e3);async function Qv(e,{from:t,to:r,merge:o}){if(t===r)return{success:!0,dup:!1};let n=await ar(t,e);if(O(n))return{success:!1,at:"from",name:Z(n).name,message:Z(n).message};let s=S(n);if(!s.persistent)return{success:!1,at:"from",name:"EmptyPageError",message:"The request page is empty."};let i=await ar(r,e);if(O(i))return{success:!1,at:"to",name:Z(i).name,message:Z(i).message};let a=S(n);return a.persistent&&!o?{success:!1,at:"to",name:"NoEmptyPageError",message:The same page already exists in "/${r}"}:(await Le(r,e,c=>[...c,...s.lines.slice(1)].map(l=>l.text)),await Mh(t,e),{success:!0,dup:a.persistent})}var Kf=async()=>{let e=scrapbox.Page.title,t=scrapbox.Project.name,r=globalThis.prompt(Take "/${t}/${e}" from "${t}" to:,"takker");if(!r)return;let{render:o,dispose:n}=De();o({type:"spinner"},{type:"text",text:/${t}/${e} → /${r}/${e}});try{let s=await Qv(e,{from:t,to:r,merge:!0});if(!s.success){o({type:"exclamation-triangle"},{type:"text",text:${s.name} ${s.message}});return}return o({type:"check-circle"},{type:"text",text:Moved ${s.dup?"and merged ":""}to "/${r}/${e}".}),https://scrapbox.io/${r}/${ne(e)}}catch(s){o({type:"exclamation-triangle"},{type:"text",text:s instanceof Error?${s.name} ${s.message}:"Unknown error! (see developper console)"}),console.error(s)}finally{setTimeout(()=>n(),1e3)}};scrapbox.PageMenu.addItem({title:"Transport",onClick:async()=>{await Kf()}});scrapbox.PageMenu.addItem({title:"Transport and Open",onClick:async()=>{let e=await Kf();e&&window.open(e)}});var uD="button.";document.getElementById("editor").addEventListener("click",async e=>{let t=e.target;if(t.tagName==="IMG"&&t.classList.contains("icon")&&t.title.endsWith("-button")){e.preventDefault(),e.stopImmediatePropagation();try{let r=../${encodeURIComponent(t.title)}/${uD},{execute:o}=await import(r);o()}catch(r){console.log(r)}}});scrapbox.PageMenu.addItem({title:"Copy link for Markdown",onClick:()=>{let e=scrapbox.Page.title.replaceAll(" ","_").replace(/[/?#\{}^|<>]/g,t=>encodeURIComponent(t));navigator.clipboard.writeText(${scrapbox.Page.title}(https://${location.hostname}/${scrapbox.Project.name}/${e}${location.hash})).catch(t=>alert(${t.name}: ${t.message}))}});Gr.PageMenu.addMenu({image:"https://img.icons8.com/ios/180/FFFFFF/inbox.png",title:"~task",onClick:()=>{let{cursor:e,selection:t}=Bt(),r=e.getPosition().line,o=t.getSelectedText(),n=o||e.lines[r].text,s=n.split(
).map(i=>i.replace(/^\s*(.+)$/g,$1~@${pe(new Date,"yyyy-MM-dd")})).join(
);o||t.setRange({start:{line:r,char:0},end:{line:r,char:n.length}}),at(s)}});var Fi=e=>Bc(...H(()=>{let t={tasks:[],errors:[],load:async()=>{},loading:!1},r=Promise.resolve();return[o=>{t.load=()=>(r=(async()=>{await r,t={...t,loading:!0},o(),await Dv(e,60),t={...t,loading:!1},o()})(),r);let n=()=>{r=(async()=>{await r,t={...t,loading:!0},o();let[s,i]=mD(await Ol(e));t={...t,tasks:s,errors:i,loading:!1},o()})()};return n(),Iv(e,n)},()=>t]},e)),mD=e=>{let t=new Set,r=[],o=[];for(let{title:n,links:s,project:i}of e)for(let a of[n,...s]){let c=ae(a);if(t.has(c))continue;t.add(c);let l=Mr(a);if(l){if(O(l)){o.push({project:i,title:a,...Z(l)});continue}r.push({project:i,title:a,...S(l)})}}return[r,o]};var Ml=()=>{let[e,t]=yo(fD,{isOpen:!1,prevOverflowY:""}),r=ft(null),o=U(()=>{t(i=>{r?.current?.showModal?.();let a=r?.current?.open??!1,c=i.isOpen?i.prevOverflowY:document.documentElement.style.overflowY;return document.documentElement.style.overflowY="hidden",{isOpen:a,prevOverflowY:c}})},[]),n=U(()=>{t(i=>{r?.current?.close?.();let a=r?.current?.open??!1;return a?{isOpen:a,prevOverflowY:i.prevOverflowY}:(i.prevOverflowY?document.documentElement.style.overflowY=i.prevOverflowY:document.documentElement.style.removeProperty("overflow-y"),{isOpen:a})})},[]),s=H(()=>{let i;return a=>{if(!a){i?.(),r.current=null;return}let c=new AbortController;a.addEventListener("cancel",n,{signal:c.signal}),a.addEventListener("click",l=>{if(l.target!==l.currentTarget){l.stopPropagation();return}n()},{signal:c.signal}),i=()=>{c.abort()},r.current=a}},[n]);return{isOpen:e.isOpen,open:o,close:n,ref:s}},fD=(e,t)=>{let r=t(e);return e.isOpen===r.isOpen&&e.prevOverflowY===r.prevOverflowY?e:r.isOpen?r:{isOpen:!1}};var Di=String.raw.fa,.far{font-weight:900;font-family:"Font Awesome 5 Free";-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}.far{font-weight:400}.fa-spinner{animation:spin 2s infinite linear}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(359deg)}}.fa-spinner:before{content:"\f110"}.fa-sync:before{content:"\f021"}.fa-bookmark:before{content:"\f02e"}.fa-fw{text-align:center;width:1.25em}.kamon:before{font-family:AppIcons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;text-transform:none}.kamon-check-circle:before{content:"\e018"}.timeline-wrap{display:flex;flex-direction:column;height:100%;overflow-y:hidden;--timeline-bg: var(--dropdown-menu-bg, #fff);--timeline-text-color: var(--page-text-color, #4a4a4a);--timeline-link-color: var(--page-link-color, #5e8af7);--row-header-width: 40px;--timeline-border-color: #888;--timeline-border: solid 1px var(--timeline-border-color);--timeline-hour-height: 40px;background-color:var(--timeline-bg);color:var(--timeline-text-color);.column-header{flex:none;display:flex;flex-direction:row;.cell{flex:1 1 1px;h2{font-weight:400;margin:0;text-align:center;width:100%}}}.week-container{position:relative;height:100%;overflow-y:auto;scrollbar-width:none;.week{flex:auto;display:flex;width:100%;.borders{.border{height:var(--timeline-hour-height)}.border:after{content:attr(data-time);font-size:10px;text-align:right;border-top:var(--timeline-border);position:absolute;width:100%;margin-top:-1px;pointer-events:none}}.timeline{flex:auto;border-left:var(--timeline-border);position:relative;.indicator{position:absolute;top:calc(var(--start) * 40px - .5px);width:100%;height:1px;background-color:red}.copy{position:absolute;top:1.5em}.event{position:absolute;top:calc(var(--start) * 40px - 1px);height:calc(40px * var(--duration) / 60);outline:none;--event-bg2: var(--timeline-text-color);--event-bg: var(--timeline-bg);--event-bg-ratio: 50%;--event-color-ratio: 0%;--event-border-color-ratio: 0%;background-color:color-mix(in srgb,var(--event-bg) var(--event-bg-ratio),var(--event-bg2));color:color-mix(in srgb,var(--event-bg) var(--event-color-ratio),var(--timeline-text-color));border:var(--timeline-border);border-color:color-mix(in srgb,var(--event-bg) var(--event-border-color-ratio),var(--timeline-border-color));border-radius:4px;overflow:hidden;text-wrap:nowrap;max-width:100%;text-overflow:ellipsis}.eventdata-status=done{--event-bg-ratio: 90%;--event-color-ratio: 50%;--event-border-color-ratio: 50%}.eventdata-status=expired{font-weight:700}a.event{--event-bg2: var(--timeline-link-color);text-decoration:none}}.timeline:first-child{border-right:var(--timeline-border)}}}}.wedget{position:fixed;top:60px;left:10px;max-height:calc(90vh - 60px);max-width:100px;width:calc(100vw / 767 * 100 - 10px);min-width:60px;border:solid 1px #888;border-radius:4px;display:flex;flex-direction:column;background-color:var(--dropdown-menu-bg, #fff);color:var(--page-text-color, #4a4a4a);&:not(.open){display:none}}dialog{flex-direction:column;align-items:center;row-gap:10px;&::backdrop{background-color:#000c}padding:10px;background:unset;margin-top:unset;margin-bottom:unset;border:unset;height:unset;overflow-y:hidden;&open{display:flex}>*{color:var(--page-text-color, #4a4a4a);background-color:var(--dropdown-menu-bg, #fff);border:1px solid rgba(0,0,0,.2);border-radius:6px}}@media (min-width: 768px){dialog{padding:30px 0;--item-width: 600px}}.result{padding:15px;width:calc(var(--item-width, 100%) - 30px);overflow-y:scroll}.controller{padding:5px;width:calc(var(--item-width, 100%) - 10px);display:flex;flex-wrap:wrap;flex:none;gap:.2em}.progress{flex-grow:1;>*{padding:0 2px}}a{text-decoration:none;color:var(--page-link-color, #5e8af7);&:hover{color:var(--page-link-hover-color, #2d67f5)}}button{cursor:pointer;background:unset;color:unset;border:unset}.copy,.close,.today{font-family:"Font Awesome 5 Free"}.navi{font-family:AppIcons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;text-transform:none}.close,.today{font-weight:900}ul{list-style-type:none;word-break:break-all}.task-list li:not(data-freshness^="-"):not(data-freshness="0"){font-weight:700}.scheduler details li{&data-status=done{opacity:.4}&data-status=expired{font-weight:700}}.task-list li{&data-type=deadline .label.type{color:var(--takker-scheduler-label-deadline-color, rgb(255, 75, 0))}&data-type=todo .label.type{color:var(--takker-scheduler-label-todo-color, rgb(246, 170, 0))}&data-type=note .label.type{color:var(--takker-scheduler-label-note-color, rgb(200, 200, 203))}&data-type=up-down .label.type{color:var(--takker-scheduler-label-up-down-color, rgb(77, 196, 255))}}:is(data-page-no=expired,data-page-no=errors) li{opacity:1!important}.scheduler{--takker-scheduler-summary-meter-width: 10em;overflow-y:hidden}.label{display:inline-block;font-size:90%;padding:0 3px}.type{text-align:center;width:2.5em;border:1px solid;border-radius:3px}.freshness{text-align:right;width:2.5em}.start,.duration{text-align:right;width:3em}
;var vs=({text:e,title:t})=>{let[r,o]=Q(""),n=U(async s=>{s.preventDefault(),s.stopPropagation();try{await navigator.clipboard.writeText(e),o("Copied"),await Fe(1e3),o("")}catch(i){alert(Failed to copy the code block
Error:${i instanceof Error?i.message:i}),console.error(i)}},[e]);return d("button",{type:"button",className:"copy",title:t??"Copy",onClick:n,children:r})};var dD=60*60*24*1e3,Zv=(e,t)=>{let r=ge(e.refDate),o=(t.getTime()-r.getTime())/dD;switch(r.setHours(0),r.setMinutes(0),e.status){case"done":return-1/0;case"deadline":return o/(e.speed??1);case"todo":return Math.min(o/(e.speed??1),0);case"note":return t.getTime()<r.getTime()?-1/0:-o/(e.speed??1);case"up-down":{let n=e.speed??30;return n*(-1+Math.cos(Math.PI*2*o/n))}}};var tT=(e,t)=>{if(t.score!==e.score)return t.score-e.score;let r=eT(e.freshness),o=eT(t.freshness);return r!==o?o-r:lr(Ir(e),Ir(t))?-1:1},eT=e=>{switch(e.status){case"todo":return 3;case"note":return 2;case"deadline":return 5;case"up-down":return 1;case"done":return 0}};var Ui=({loading:e,onClick:t})=>e?d("div",{children:d("i",{className:"fa fa-spinner"})}):d("button",{type:"button",className:"navi reload",onClick:t,children:""});var Ts=()=>{let[e,t]=Q(new Date);return te(()=>{let r=setInterval(()=>t(new Date),6e4);return()=>{clearInterval(r)}},[]),e};var rT=e=>{switch(e){case"todo":return"ToDo";case"note":return"覚書";case"deadline":return"締切";case"up-down":return"浮遊";case"done":return"完了"}};var oT=(e,t)=>new URL(/${e.project}/${ne(e.title)},t??location.href);var Cl=({children:e,project:t,title:r,className:o,...n})=>d("a",{...n,className:[o??"","page-link"].join(" "),type:"link",href:oT({project:t,title:r}).pathname,...t===scrapbox.Project.name?{rel:"route"}:{rel:"noopener noreferrer",target:"_blank"},children:e});var nT=({action:e,pActions:t})=>{let r=H(()=>rT(e.freshness.status),[e.freshness.status]),o=H(()=>Nr(Ir(e)).slice(11)||" ",[Ir(e)]),n=H(()=>ei(e),[e]),s=Math.floor(Math.round(e.score)/7),i=Ts(),a=H(()=>e.executed!==void 0&&Jo(Lr(ge(e.executed.start),e.executed.duration),i),[e.executed?.start,e.executed?.duration,i]),c=H(()=>[...t,e].map(l=>${l.raw}).join(
),[t,e]);return d("li",{"data-type":e.freshness.status,"data-freshness":e.score.toFixed(0),"data-level":s,...s<0?{style:{opacity:hD(e).toFixed(2)}}:{},children:[d(vs,{text:c,title:"ここまでコピー"}),d("span",{className:"label type",children:r}),d("i",{className:label far fa-fw${a?" fa-bookmark":""}}),d("span",{className:"label freshness",children:e.score.toFixed(0)}),d("time",{className:"label start",children:o}),d("span",{className:"label duration",children:[n,"m"]}),d(Cl,{project:e.project,title:e.raw,children:e.name})]})},hD=e=>Math.max(.8*Math.exp(Math.log(8/7)/7*e.score),.05);var sT=(e=Wt(new Date))=>{let[t,r]=Q(e),o=U(()=>{r(s=>{switch(s){case"errors":return"expired";case"expired":return Wt(new Date);default:{let i=ge(Ci(s));return i.setDate(i.getDate()+1),Wt(i)}}})},[]),n=U(()=>{r(s=>{let i=Wt(new Date);switch(s){case"errors":return"errors";case"expired":return"errors";case i:return"expired";default:{let a=ge(Ci(s));return a.setDate(a.getDate()-1),Wt(a)}}})},[]);return{pageNo:t,next:o,prev:n}};var Il=(e,t)=>te(()=>(scrapbox.on(e,t),()=>scrapbox.off(e,t)),[]);var $i=(e,t)=>{let r=ft({...t});te(()=>(Object.assign(r.current,t),()=>{for(let o of Object.keys(t))delete r.current[o]}),[...Object.keys(t)].sort().map(o=>t[o])),te(()=>{e(r.current)},[e])};var iT=e=>{let t=document.createElement("div");t.dataset.userscriptName="takker-workflow@0.0.1/next-action-viewer";let r=t.attachShadow({mode:"open"});return document.body.append(t),new Promise(o=>Rt(d(gD,{getController:o,projects:e}),r))},gD=({getController:e,projects:t})=>{let{tasks:r,errors:o,load:n,loading:s}=Fi(t),{pageNo:i,next:a,prev:c}=sT(),l=H(()=>{if(i==="errors")return o.map(g=>({name:${g.title}
name:${g.name}
message:${g.message},raw:g.title,freshness:{refDate:{year:9999,month:1,date:1},status:"todo"},project:g.project,generated:!0,score:0}));if(i==="expired"){let g=new Date;return r.flatMap(y=>!Cr(y)&&lr(Ay(y),Ht(g))&&y.freshness===void 0&&y.recurrence===void 0?[{...y,score:0,freshness:{refDate:y.executed.start,status:"todo"}}]:[]).sort((y,x)=>lr(Ir(y),Ir(x))?-1:0)}let h=ge(Ci(i));return r.flatMap(g=>{if(!g.freshness)return[];if(_o(g))return[];let y=Zv(g.freshness,h);return y>-999?[{...g,score:y}]:[]}).sort(tT)},[r,o,i]),{ref:u,open:p,close:f}=Ml();$i(e,{open:p,close:f});let m=H(()=>[i,...l.map(h=> ${h.raw})].join(
),[l,i]);return Il("page:changed",f),d(ee,{children:[d("style",{children:Di}),d("dialog",{ref:u,children:[d("div",{className:"controller",children:[d(vs,{text:m,title:"Copy All Tasks"}),d("span",{children:i}),d("button",{type:"button",className:"navi left",onClick:c,children:""}),d("button",{type:"button",className:"navi right",onClick:a,children:""}),d(Ui,{loading:s,onClick:n}),d("button",{type:"button",className:"close",onClick:f,children:""})]}),d("ul",{className:"result task-list","data-page-no":i,children:l.map((h,g)=>d(nT,{action:h,pActions:l.slice(0,g)},h.raw))})]})]})};var Fl=(e,t)=>/${e}/${ae(t)},ji=new Map,Yf=new Map,aT=(e,t)=>{ji.set(e,t);for(let r of Yf.get(e)??[])r(t)},Al=()=>{vn!==void 0&&(clearInterval(vn),vn=void 0);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Fl(e,t);if(!ji.has(r))return;let o=At().map(n=>n.text);vn=setInterval(()=>{ae(t)===ae(o[0])&&(aT(r,o),vn!==void 0&&(clearInterval(vn),vn=void 0))},1e3)},vn;scrapbox.on("page:changed",()=>{scrapbox.off("lines:changed",Al);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Fl(e,t);ji.has(r)&&scrapbox.on("lines:changed",Al)});var yD=(e,t)=>{let r=Fl(e,t),o=ji.get(r);return o||(ji.set(r,[]),ar(e,t).then(n=>{if(O(n))return[];let s=S(n).lines.map(i=>i.text);aT(r,s),t===scrapbox.Page.title&&!scrapbox.listeners("lines:changed").includes(Al)&&scrapbox.on("lines:changed",Al)})),o??[]},cT=(e,t)=>{let[r,o]=Q(yD(e,t));return te(()=>{let n=Fl(e,t),s=Yf.get(n)??new Set;return s.add(o),Yf.set(n,s),()=>{s.delete(o)}},[e,t]),r};var Xf=e=>e.duration===void 0?void 0:Ht(Lr(ge(e.start),e.duration)),Jf=(e,t)=>{let r=ge(e.start),o=t.getTime(),n=Math.round((o-r.getTime())/(60*1e3));if(n<=0)return[void 0,e];if(e.duration<=n)return[e,void 0];let s={start:e.start,duration:n};return[s,{start:Xf(s),duration:e.duration-n}]};var Tn=e=>"title"in e,xD=e=>e.record?.duration!==void 0,lT=(e,t)=>Tn(e)&&e.status==="done"?e.status:xD(e)?Tn(e)&&e.executed?lr(Ht(t),e.executed.start)?"moved":"expired":"done":lr(Xf(e.plan),Ht(t))?Tn(e)?"expired":"done":"undone";var pT=(e,t)=>{let r=Mr(e.title.slice(1,-1));if(!e.plan.start)return;let o={name:r&&K(r)?S(r).name:e.title,plan:{start:Ht(e.plan.start),duration:(e.plan.duration??0)/60}};if(e.record.start&&(o.record={start:Ht(e.record.start)},e.record.end&&(o.record.duration=vo(e.record.end,e.record.start))),!r||O(r))return o;let n=S(r),s={...o,title:n.raw,project:t};return n.freshness&&(s.status=n.freshness.status),Cr(n)||(s.executed=n.executed),s},Qf=(e,t)=>{let r=Ya(e);return r!==void 0?{name:e.name,project:t,title:r,executed:e.executed,plan:e.executed,status:e.freshness?.status}:{name:e.name,plan:e.executed}};var uT=(e,t,r)=>{let o=[Zf(e,zt(t,1),r),Zf(e,t,r),Zf(e,ve(t,1),r)],n=H(()=>o.flat(),o);return H(()=>{let s=Er(t),i=Wa(t);return n.flatMap(a=>{let[,c]=Jf(a.plan,s);if(!c)return[];let[l]=Jf(c,i);if(!l)return[];let{plan:u,...p}=a;return[{plan:l,...p}]}).sort((a,c)=>lr(a.plan.start,c.plan.start)?-1:0)},[n,t])},Zf=(e,t,r)=>{let o=cT(e,Rr(t)),n=H(()=>ED(o,e),[o,e]);return H(()=>n.length!==0?n:bD(t,r),[n,t,r])},bD=(e,t)=>t.flatMap(r=>{if(r.freshness?.status==="done")return[];if(Cr(r))return[];if(_o(r)){let n=Ka(r,e);return n?[Qf(n,r.project)]:[]}let o=ge(r.executed.start);return gt(o,e)?[Qf(r,r.project)]:[]}),ED=(e,t)=>{let r=[];for(let o of Qo(e)){if(To(o))continue;let n=pT(o,t);n&&r.push(n)}return r};var mT=({event:e})=>{let t=H(()=>e.plan.start.hours+e.plan.start.minutes/60,[e.plan.start]),r=H(()=>--start: ${t}; --duration: ${e.plan.duration};,[t,e.plan.duration]),o=Ts(),n=H(()=>lT(e,o),[e,o]);return Tn(e)?d(Cl,{className:"event","data-status":n,style:r,title:e.title,project:e.project,children:e.name}):d("div",{className:"event","data-status":n,title:e.name,style:r,children:e.name})};var fT=({project:e,date:t,tasks:r})=>{let o=uT(e,t,r),n=H(()=>o.flatMap(a=>Tn(a)?[${a.title}]:[]).join(
),[o]),s=Ts(),i=H(()=>gt(s,t)&&d("div",{className:"indicator",style:--start: ${wy(s)+Ey(s)/60}}),[s,t]);return d("div",{className:"timeline",role:"gridcell",children:[o.map(a=>d(mT,{event:a},a.name)),i,d(vs,{text:n})]})};var ed=({dateList:e,tasks:t,project:r,hasColumn:o})=>d("div",{className:"timeline-wrap",role:"grid",children:[(o??!0)&&d("div",{className:"column-header",role:"row",children:e.map(n=>d("div",{className:"cell",role:"columnheader",children:d("h2",{children:Ks(n)})},Wt(n)))}),d("div",{className:"week-container",role:"presentation",children:d("div",{className:"week",role:"presentation",children:[d("div",{className:"borders",children:[...Array(24).keys()].map(n=>d("div",{className:"border","data-time":${kr(n)}:00},n))}),e.map(n=>d(fT,{project:r,date:n,tasks:t},Wt(n)))]})})]});var td=(e,t,r)=>{let[o,n]=Q(e),s=U(()=>n(t),[t]),i=U(()=>n(r),[t]),a=U(c=>n(c),[]);return{pageNo:o,next:s,prev:i,jump:a}};var dT=e=>{let t=ft(new Set),[r,o]=Q(e),n=U(()=>{for(let l of t.current)l()},[]),s=U(()=>{o(!0),n()},[]),i=U(()=>o(!1),[]),a=U(()=>o(l=>(l||n(),!l)),[]),c=U(l=>(t.current.add(l),()=>t.current.delete(l)),[]);return{isOpen:r,open:s,close:i,toggle:a,onOpen:c}};var yT=e=>{let t=document.createElement("div");t.dataset.userscriptName="takker-scheduler/weekly-scheduler";let r=t.attachShadow({mode:"open"});return document.body.append(t),new Promise(o=>Rt(d(wD,{getController:o,projects:e,mainProject:e[0]}),r))},xT=(e,t)=>{let r=document.createElement("div");r.dataset.userscriptName="takker-scheduler/timeline-wedget";let o=r.attachShadow({mode:"open"});return document.body.append(r),new Promise(n=>Rt(d(RD,{getController:n,projects:e,mainProject:e[0],open:t}),o))},hT=!1,wD=({getController:e,projects:t,mainProject:r})=>{let{tasks:o,load:n,loading:s}=Fi(t),{pageNo:i,next:a,prev:c,jump:l}=td(Ii(new Date),kD,vD),u=H(()=>{let y=Sl(i);return[0,1,2,3,4,5,6].map(x=>ve(y,x))},[i]),{ref:p,open:f,close:m,isOpen:h}=Ml();hT||=h,$i(e,{open:f,close:m,isOpen:h}),Il("page:changed",m);let g=U(()=>l(Ii(new Date)),[l]);return d(ee,{children:[d("style",{children:Di}),d("dialog",{ref:p,children:[d("div",{className:"controller",children:[d("span",{children:i}),d("button",{type:"button",className:"navi left",onClick:c,children:""}),d("button",{type:"button",className:"navi right",onClick:a,children:""}),d("button",{type:"button",className:"today",onClick:g,children:""}),d(Ui,{loading:s,onClick:n}),d("button",{type:"button",className:"close",onClick:m,children:""})]}),hT&&d("div",{ref:bT,className:"result scheduler","data-page-no":i,children:d(ed,{dateList:u,tasks:o,project:r})})]})]})},gT=!1,RD=({projects:e,mainProject:t,getController:r,open:o})=>{let{tasks:n,load:s,loading:i}=Fi(e),{pageNo:a,next:c,prev:l,jump:u}=td(new Date,TD,_D),p=H(()=>[a],[a]),f=U(()=>u(new Date),[u]),{isOpen:m,open:h,close:g}=dT(o);return gT||=m,$i(r,{open:h,close:g,isOpen:m}),d(ee,{children:[d("style",{children:Di}),gT&&d("div",{className:wedget${m?" open":""},ref:bT,children:[d("div",{className:"controller",children:[d("span",{children:Wt(a)}),d("button",{type:"button",className:"navi left",onClick:l,children:""}),d("button",{type:"button",className:"navi right",onClick:c,children:""}),d("button",{type:"button",className:"today",onClick:f,children:""}),d(Ui,{loading:i,onClick:s})]}),d(ed,{dateList:p,tasks:n,project:t,hasColumn:!1})]})]})},kD=e=>Ii(zo(Sl(e),1)),vD=e=>Ii(Ry(Sl(e),1)),TD=e=>ve(e,1),_D=e=>zt(e,1),bT=e=>{let t=e?.getElementsByClassName?.("indicator")?.[0];if(!t)return;let r=globalThis.scrollY;t.scrollIntoView({block:"center"}),globalThis.scroll(0,r)};Vh({project:"takker-dist"});ga(!0);Xh({maxCount:10,accessToken:PD,onClick:async(e,t)=>{try{if(t.ctrlKey){await navigator.clipboard.writeText(e.permalink_url);return}let r=document.getElementById("text-input");if(!r)throw Error("#text-input is not ditected.");r.focus(),r.value=e.permalink_url;let o=new InputEvent("input",{bubbles:!0});r.dispatchEvent(o),await scrapbox.Page.waitForSave()}catch(r){alert(${r}),console.error(r)}}});ty().then(e=>{scrapbox.PageMenu.addItem({title:"Fulltext Search",onClick:()=>{e.toggle()}})});var OD="https://scrapbox.io/files/67344295032adf96d1e4c276.wasm",SD="/api/code/takker-dist/for-any-project-min/esbuild-worker.js";(async()=>{let e=new Request(OD),t=await bo(e);t||(t=await fetch(e),await Aa(e,t)),await AE(await WebAssembly.compileStreaming(t),SD)})();(async()=>{let e=[scrapbox.Project.name,"takker","takker-memex","takker-books","takker-private","villagepump","hub","arpla","work4ai","unnamedcamp","unnamed-project","nishio","enchi","rashitamemo","motoso","shokai","masui","rakusai","yuiseki","akiroom","c4j","miyamonz","mrsekut-p","masuilab","kidaaam-92022284","nwtgck","juneboku","marshmallow-rm","sushitecture","sno2wman","inteltank","issac-37765679","blu3mo","yosider","Mijinko","Mijinko-other","scrapbox-drinkup","nota-techconf","customize","scrapboxlab","scrasobox","programming-notes","tus-alpine","tus-alpine-private","guiland","evergreens","fab-wiki"],t=await vw({projects:e,mark:{...Object.fromEntries([["takker","takker"],["takker-memex","takker"],["takker-books","takker-books"],["takker-private","takker-private"],["nishio","nishio"],["rashitamemo","rashita"],["enchi","雑談_2022-04-12~"],["rakusai","rakusai"],["masui","概要"],["shokai","shokai"],["yuiseki","yuiseki"],["akiroom","はじめに"],["inteltank","sawachin"],["motoso","もとそのもと"],["villagepump","井戸端"],["hub","scrapbox.io%2Fhub_について"],["masuilab","増井研に入ったらまずやること"],["marshmallow-rm","読書猿マシュマロ全質問回答"],["miyamonz","miyamonz"],["mrsekut-p","mrsekut"],["kidaaam-92022284","kidooom"],["c4j","Code_for_Japan"],["suto3","suto3"],["blu3mo","blu3mo"],["nwtgck","nwtgck"],["juneboku","juneboku"],["jigsaw","jgs"],["sno2wman","SnO2WMaN"],["sushitecture","hashrock"],["unnamedcamp","知を営む"],["unnamed-project","unnamed-project"],["issac-37765679","cFQ2f7LRuLYP"],["blu3mo","blu3mo"],["yosider","yosider"],["Mijinko","Mijinko_SD"],["Mijinko-other","Mijinko_SD"],["customize","みんなのカスタマイズ"],["scrapboxlab","入会手続き"],["scrasobox","Scrapboxとあそぶ"],["programming-notes","参加する"],["guiland","概要と参加方法"],["work4ai","work4ai"],["evergreens","HOME"],["fab-wiki","fab-wikiに参加する"]].map(([n,s])=>[n,https://scrapbox.io/api/pages/${n}/${s}/icon])),"NDLSH-SB":"📚","scrapbox-drinkup":"https://scrapbox.io/assets/img/page-icon/scrapbox_beaver.png","nota-techconf":"https://i.gyazo.com/727f42bbd9e2534d99d70e6ea90705b3.jpg","plurality-japanese":"⿻"},workerUrl:"/api/code/takker-dist/for-any-project-min/select-suggestion-worker.js",enableSelfProjectOnStart:!0}),r=n=>{n.preventDefault(),n.stopPropagation()},o=()=>document.querySelector(".line .popup-menu")!==null;Hu.bind({"<Tab>":n=>{o()||t.selectNext?.({cyclic:!0})&&r(n)},"<S-Tab>":n=>{o()||t.selectPrev?.({cyclic:!0})&&r(n)},"<Enter>":n=>{o()||t.confirm?.()&&r(n)},"<Esc>":n=>{o()||t.cancel?.()&&r(n)}})})();Ow({previewers:[{when:/(?:^|\.)svg$/,preview:Sw},{when:/(?:^|\.)glsl$/,preview:qw},{when:/(?:^|\.)(?:plantuml|puml|pu)$/,preview:Vw},{when:/(?:^|\.)tikz\(tex\)$/,preview:Yw("/api/code/takker-dist/for-any-project-min/tex-worker.js","https://scrapbox.io/files/65d1645c19cd8e002433c3df")}]});(async()=>{let{toggle:e}=await mR();scrapbox.PageMenu.addItem({title:"履歴スライダー",image:"https://1.bp.blogspot.com/-UZtkSEX0wh4/U5l5_dNcEsI/AAAAAAAAhWs/UzJGVzyiX8Y/s800/kaichu_dokei.png",onClick:e})})();cv("takker",["takker","振り返り(takker-workflow@0.0.1)のtemplate","txt"],["takker","1週間の振り返り(takker-workflow@0.0.1)のtemplate","txt"],new Date(2024,11,24));wn()&&(hr({display:{type:"caret-left"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Na():Pa()}}),hr({display:{type:"caret-right"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?La():_a()}}),hr({display:{type:"caret-up"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Ma():Oa()}}),hr({display:{type:"caret-down"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Ca():Sa()}}),hr({display:{type:"copy"},onClick:async({cursor:e,selection:t})=>await qv(e,t)}),hr({display:{type:"cut"},onClick:async({cursor:e,selection:t})=>await Gv(e,t)}),hr({display:{type:"clipboard"},onClick:async({cursor:e})=>await zv(e)}),hr({display:{type:"undo"},onClick:()=>Hg()}),hr({display:{type:"redo"},onClick:()=>Wg()}),hr({display:({cursor:e})=>e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?{type:["i-cursor","slash"]}:{type:"i-cursor"},onClick:({cursor:e})=>Vv(e)}));if(wn()&&scrapbox.Project.name!=="takker-memex"){let e="task";scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/todo-list--v2.png"}),scrapbox.PageMenu(e).addItem({title:"Book starting",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:Xs}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>Qs({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"})})}if(wn()){let e="New Page",t=[rn,on,nn];scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/cut-paper.png"}),scrapbox.PageMenu(e).addItem({title:"New Page",onClick:()=>{let r=window.prompt("Create a new page at",scrapbox.Project.name);r&&Xr({project:r,mode:"noopen",hooks:t})?.()}}),scrapbox.PageMenu(e).addItem({title:"New Page and Open",onClick:()=>{let r=window.prompt("Create a new page at",scrapbox.Project.name);r&&Xr({project:r,mode:"self",hooks:t})?.()}})}(async()=>{let e="next-action",t=head styledata-userscript-name="${e}";document.querySelector(t)?.remove?.();let r=document.createElement("style");r.dataset.userscriptName=e,r.textContent=
button:is(#${e}, #scheduler).tool-btn::before {
position: absolute;
font: 900 20px/46px "Font Awesome 5 Free";
}
button#${e}.tool-btn::before {
content: "\\f0ae";
}
button#scheduler.tool-btn::before {
content: "\\f073";
font-weight: 400;
}
button:is(#${e}, #scheduler).tool-btn img {
opacity: 0;
}`,document.head.append(r);let o="takker-memex","takker",{open:n}=await iT(o);scrapbox.PageMenu.addMenu({title:e,image:"/assets/img/favicon/apple-touch-icon.png",onClick:n});let s=await yT(o);scrapbox.PageMenu.addMenu({title:"scheduler",image:"/assets/img/favicon/apple-touch-icon.png",onClick:s.open});{let i="takker-scheduler/wedget",a=JSON.parse(localStorage.getItem(i)??"{}"),c=scrapbox.Project.name;ac??=!1;let l=await xT(o,ac),u=()=>{ac=!l.isOpen,l.isOpen?l.close():l.open?.(),localStorage.setItem(i,JSON.stringify(a))};wn()?hr({display:{type:"calendar"},onClick:u}):scrapbox.PageMenu.addItem({title:"toggle wedget",onClick:u})}})();export{hr as addButton,at as insertText,Hu as scrapBindings};
/** @license
* esbuild-wasm@v0.24.0
*
* MIT License
*
* Copyright (c) 2020 Evan Wallace
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*! Bundled license information:
comlink/dist/esm/comlink.mjs:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*)
*/
code:takker-memex.js
var ST=Object.defineProperty;var Uo=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)r}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ki=(e,t)=>{for(var r in t)ST(e,r,{get:tr,enumerable:!0})};function Pe(e){if(e)return LT(e)}function LT(e){for(var t in Pe.prototype)et=Pe.prototypet;return e}Pe.prototype.on=Pe.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};Pe.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Pe.prototype.off=Pe.prototype.removeListener=Pe.prototype.removeAllListeners=Pe.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks"$"+e;if(!r)return this;if(arguments.length==1)return delete this._callbacks"$"+e,this;for(var o,n=0;n<r.length;n++)if(o=rn,o===t||o.fn===t){r.splice(n,1);break}return r.length===0&&delete this._callbacks"$"+e,this};Pe.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,o=1;o<arguments.length;o++)to-1=argumentso;if(r){r=r.slice(0);for(var o=0,n=r.length;o<n;++o)ro.apply(this,t)}return this};Pe.prototype.emitReserved=Pe.prototype.emit;Pe.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};Pe.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Sr=Object.create(null);Sr.open="0";Sr.close="1";Sr.ping="2";Sr.pong="3";Sr.message="4";Sr.upgrade="5";Sr.noop="6";var Ji=Object.create(null);Object.keys(Sr).forEach(e=>{Ji[Sre]=e});var Vl={type:"error",data:"parser error"},pd=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",ud=typeof ArrayBuffer=="function",md=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Qi=({type:e,data:t},r,o)=>pd&&t instanceof Blob?r?o(t):ad(t,o):ud&&(t instanceof ArrayBuffer||md(t))?r?o(t):ad(new Blob(t),o):o(Sre+(t||"")),ad=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")1;t("b"+(o||""))},r.readAsDataURL(e)};function cd(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Gl;function NT(e,t){if(pd&&e.data instanceof Blob)return e.data.arrayBuffer().then(cd).then(t);if(ud&&(e.data instanceof ArrayBuffer||md(e.data)))return t(cd(e.data));Qi(e,!1,r=>{Gl||(Gl=new TextEncoder),t(Gl.encode(r))})}var ld="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ns=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<ld.length;e++)Nsld.charCodeAt(e)=e;var MT=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,a,c;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(o=0;o<r;o+=4)s=Nse.charCodeAt(o),i=Nse.charCodeAt(o+1),a=Nse.charCodeAt(o+2),c=Nse.charCodeAt(o+3),un++=s<<2|i>>4,un++=(i&15)<<4|a>>2,un++=(a&3)<<6|c&63;return l},CT=typeof ArrayBuffer=="function",Zi=(e,t)=>{if(typeof e!="string")return{type:"message",data:fd(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:IT(e.substring(1),t)}:Jir?e.length>1?{type:Jir,data:e.substring(1)}:{type:Jir}:Vl},IT=(e,t)=>{if(CT){let r=MT(e);return fd(r,t)}else return{base64:!0,data:e}},fd=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},dd="",hd=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{Qi(s,!1,a=>{oi=a,++n===r&&t(o.join(dd))})})},gd=(e,t)=>{let r=e.split(dd),o=[];for(let n=0;n<r.length;n++){let s=Zi(rn,t);if(o.push(s),s.type==="error")break}return o};function yd(){return new TransformStream({transform(e,t){NT(e,r=>{let o=r.length,n;if(o<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,o);else if(o<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,o)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(o))}e.data&&typeof e.data!="string"&&(n0|=128),t.enqueue(n),t.enqueue(r)})}})}var zl;function Yi(e){return e.reduce((t,r)=>t+r.length,0)}function Xi(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),o=0;for(let n=0;n<t;n++)rn=e0o++,o===e0.length&&(e.shift(),o=0);return e.length&&o<e0.length&&(e0=e0.slice(o)),r}function xd(e,t){zl||(zl=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(o===0){if(Yi(r)<1)break;let c=Xi(r,1);s=(c0&128)===128,n=c0&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(Yi(r)<2)break;let c=Xi(r,2);n=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),o=3}else if(o===2){if(Yi(r)<8)break;let c=Xi(r,8),l=new DataView(c.buffer,c.byteOffset,c.length),u=l.getUint32(0);if(u>Math.pow(2,21)-1){a.enqueue(Vl);break}n=u*Math.pow(2,32)+l.getUint32(4),o=3}else{if(Yi(r)<n)break;let c=Xi(r,n);a.enqueue(Zi(s?c:zl.decode(c),t)),o=0}if(n===0||n>e){a.enqueue(Vl);break}}}})}var Kl=4;var Ms=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),or=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),AT="arraybuffer";function Ed(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(ro=eo),r),{})}var FT=or.setTimeout,DT=or.clearTimeout;function Cs(e,t){t.useNativeTimers?(e.setTimeoutFn=FT.bind(or),e.clearTimeoutFn=DT.bind(or)):(e.setTimeoutFn=or.setTimeout.bind(or),e.clearTimeoutFn=or.clearTimeout.bind(or))}var UT=1.33;function $T(e){return typeof e=="string"?jT(e):Math.ceil((e.byteLength||e.size)*UT)}function jT(e){let t=0,r=0;for(let o=0,n=e.length;o<n;o++)t=e.charCodeAt(o),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(o++,r+=4);return r}function wd(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function BT(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function HT(e){let t={},r=e.split("&");for(let o=0,n=r.length;o<n;o++){let s=ro.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var WT=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Jl=class extends Pe{constructor(e){super(),this.writable=!1,Cs(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,r){return super.emitReserved("error",new WT(e,t,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){let t=Zi(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(":")===-1?e:""+e+""}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){let t=BT(e);return t.length?"?"+t:""}},qT=class extends Jl{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";let t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||t()})),this.writable||(r++,this.once("drain",function(){--r||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){let t=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};gd(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){let e=()=>{this.write({type:"close"})};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,hd(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(tthis.opts.timestampParam=wd()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Rd=!1;try{Rd=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var GT=Rd;function zT(){}var VT=class extends qT{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",r=location.port;r||(r=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(o,n)=>{this.onError("xhr post error",o,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},Nn=class ea extends Pe{constructor(t,r,o){super(),this.createRequest=t,Cs(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var t;let r=Ed(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&o.setRequestHeader(n,this._opts.extraHeadersn)}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var n;o.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=ea.requestsCount++,ea.requeststhis._index=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=zT,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ea.requeststhis._index,this._xhr=null}}_onLoad(){let t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};Nn.requestsCount=0;Nn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",bd);else if(typeof addEventListener=="function"){let e="onpagehide"in or?"pagehide":"unload";addEventListener(e,bd,!1)}}function bd(){for(let e in Nn.requests)Nn.requests.hasOwnProperty(e)&&Nn.requestse.abort()}var KT=function(){let e=kd({xdomain:!1});return e&&e.responseType!==null}(),Ql=class extends VT{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=KT&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Nn(kd,this.uri(),e)}};function kd(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||GT))return new XMLHttpRequest}catch{}if(!t)try{return new or["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var vd=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",YT=class extends Jl{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=vd?{}:Ed(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;Qi(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}o&&Ms(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(tthis.opts.timestampParam=wd()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Yl=or.WebSocket||or.MozWebSocket,Zl=class extends YT{createSocket(e,t,r){return vd?new Yl(e,t,r):t?new Yl(e,t):new Yl(e)}doWrite(e,t){this.ws.send(t)}},Td=class extends Jl{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptionsthis.name)}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=xd(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),o=yd();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();let n=()=>{r.read().then(({done:i,value:a})=>{i||(this.onPacket(a),n())}).catch(i=>{})};n();let s={type:"open"};this.query.sid&&(s.data={"sid":"${this.query.sid}"}),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;this._writer.write(r).then(()=>{o&&Ms(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},XT={websocket:Zl,webtransport:Td,polling:Ql},JT=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,QT="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function na(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf(""),o=e.indexOf("");r!=-1&&o!=-1&&(e=e.substring(0,r)+e.substring(r,o).replace(/:/g,";")+e.substring(o,e.length));let n=JT.exec(e||""),s={},i=14;for(;i--;)s[QTi]=ni||"";return r!=-1&&o!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("","").replace("","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=ZT(s,s.path),s.queryKey=e0(s,s.query),s}function ZT(e,t){let r=/\/{2,9}/g,o=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&o.splice(0,1),t.slice(-1)=="/"&&o.splice(o.length-1,1),o}function e0(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(o,n,s){n&&(rn=s)}),r}var Xl=typeof addEventListener=="function"&&typeof removeEventListener=="function",ta=[];Xl&&addEventListener("offline",()=>{ta.forEach(e=>e())},!1);var ra=class oa extends Pe{constructor(t,r){if(super(),this.binaryType=AT,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){let o=na(t);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=na(r.host).host);Cs(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{let n=o.prototype.name;this.transports.push(n),this._transportsByNamen=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=HT(this.opts.query)),Xl&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ta.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=Kl,r.transport=t,this.id&&(r.sid=this.id);let o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptionst);return new this._transportsByNamet(o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&oa.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports0;this.readyState="opening";let r=this.createTransport(t);r.open(),this.setTransport(r)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",r=>this._onClose("transport close",r))}onOpen(){this.readyState="open",oa.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let r=new Error("server error");r.code=t.data,this._onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let o=this.writeBufferr.data;if(o&&(t+=$T(o)),r>0&&t>this._maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Ms(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,o){return this._sendPacket("message",t,r,o),this}send(t,r,o){return this._sendPacket("message",t,r,o),this}_sendPacket(t,r,o,n){if(typeof r=="function"&&(n=r,r=void 0),typeof o=="function"&&(n=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;let s={type:t,data:r,options:o};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():t()}):this.upgrading?o():t()),this}_onError(t){if(oa.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,r){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Xl&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=ta.indexOf(this._offlineEventListener);o!==-1&&ta.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};ra.protocol=Kl;var t0=class extends ra{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgradese)}_probe(e){let t=this.createTransport(e),r=!1;ra.priorWebsocketSuccess=!1;let o=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",u=>{if(!r)if(u.type==="pong"&&u.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;ra.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(l(),this.setTransport(t),t.send({type:"upgrade"}),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{let p=new Error("probe error");p.transport=t.name,this.emitReserved("upgradeError",p)}}))};function n(){r||(r=!0,l(),t.close(),t=null)}let s=u=>{let p=new Error("probe error: "+u);p.transport=t.name,n(),this.emitReserved("upgradeError",p)};function i(){s("transport closed")}function a(){s("socket closed")}function c(u){t&&u.name!==t.name&&n()}let l=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",o),t.once("error",s),t.once("close",i),this.once("close",a),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&e!=="webtransport"?this.setTimeoutFn(()=>{r||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let r=0;r<e.length;r++)~this.transports.indexOf(er)&&t.push(er);return t}},ep=class extends t0{constructor(e,t={}){let r=typeof e=="object"?e:t;(!r.transports||r.transports&&typeof r.transports0=="string")&&(r.transports=(r.transports||"polling","websocket","webtransport").map(o=>XTo).filter(o=>!!o)),super(e,r)}};var ZD=ep.protocol;var np={};Ki(np,{Decoder:()=>p0,Encoder:()=>l0,PacketType:()=>ce,protocol:()=>Od});var r0=typeof ArrayBuffer=="function",o0=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Pd=Object.prototype.toString,n0=typeof Blob=="function"||typeof Blob<"u"&&Pd.call(Blob)==="object BlobConstructor",s0=typeof File=="function"||typeof File<"u"&&Pd.call(File)==="object FileConstructor";function op(e){return r0&&(e instanceof ArrayBuffer||o0(e))||n0&&e instanceof Blob||s0&&e instanceof File}function sa(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if(sa(er))return!0;return!1}if(op(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return sa(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&sa(er))return!0;return!1}function i0(e){let t=[],r=e.data,o=e;return o.data=tp(r,t),o.attachments=t.length,{packet:o,buffers:t}}function tp(e,t){if(!e)return e;if(op(e)){let r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){let r=new Array(e.length);for(let o=0;o<e.length;o++)ro=tp(eo,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(ro=tp(eo,t));return r}return e}function a0(e,t){return e.data=rp(e.data,t),delete e.attachments,e}function rp(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return te.num;throw new Error("illegal attachments")}else if(Array.isArray(e))for(let r=0;r<e.length;r++)er=rp(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=rp(er,t));return e}var c0="connect","connect_error","disconnect","disconnecting","newListener","removeListener",Od=5,ce;(function(e){ee.CONNECT=0="CONNECT",ee.DISCONNECT=1="DISCONNECT",ee.EVENT=2="EVENT",ee.ACK=3="ACK",ee.CONNECT_ERROR=4="CONNECT_ERROR",ee.BINARY_EVENT=5="BINARY_EVENT",ee.BINARY_ACK=6="BINARY_ACK"})(ce||(ce={}));var l0=class{constructor(e){this.replacer=e}encode(e){return(e.type===ce.EVENT||e.type===ce.ACK)&&sa(e)?this.encodeAsBinary({type:e.type===ce.EVENT?ce.BINARY_EVENT:ce.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===ce.BINARY_EVENT||e.type===ce.BINARY_ACK)&&(t+=e.attachments+"-"),e.nsp&&e.nsp!=="/"&&(t+=e.nsp+","),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=i0(e),r=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(r),o}};function _d(e){return Object.prototype.toString.call(e)==="object Object"}var p0=class Sd extends Pe{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);let o=r.type===ce.BINARY_EVENT;o||r.type===ce.BINARY_ACK?(r.type=o?ce.EVENT:ce.ACK,this.reconstructor=new u0(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(op(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0,o={type:Number(t.charAt(0))};if(ceo.type===void 0)throw new Error("unknown packet type "+o.type);if(o.type===ce.BINARY_EVENT||o.type===ce.BINARY_ACK){let s=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);let i=t.substring(s,r);if(i!=Number(i)||t.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););o.nsp=t.substring(s,r)}else o.nsp="/";let n=t.charAt(r+1);if(n!==""&&Number(n)==n){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}o.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(Sd.isPayloadValid(o.type,s))o.data=s;else throw new Error("invalid payload")}return o}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case ce.CONNECT:return _d(r);case ce.DISCONNECT:return r===void 0;case ce.CONNECT_ERROR:return typeof r=="string"||_d(r);case ce.EVENT:case ce.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&c0.indexOf(r0)===-1);case ce.ACK:case ce.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},u0=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let t=a0(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function m0(e,t="",r){let o=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),o=na(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";let n=o.host.indexOf(":")!==-1?""+o.host+"":o.host;return o.id=o.protocol+"://"+n+":"+o.port+t,o.href=o.protocol+"://"+n+(r&&r.port===o.port?"":":"+o.port),o}function yr(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var f0=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Ld=class extends Pe{constructor(e,t,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=yr(e,"open",this.onopen.bind(this)),yr(e,"packet",this.onpacket.bind(this)),yr(e,"error",this.onerror.bind(this)),yr(e,"close",this.onclose.bind(this))}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var r,o,n;if(f0.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let s={type:ce.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof tt.length-1=="function"){let c=this.ids++,l=t.pop();this._registerAckCallback(c,l),s.id=c}let i=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,a=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!i||(a?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var r;let o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.ackse=t;return}let n=this.io.setTimeoutFn(()=>{delete this.ackse;for(let i=0;i<this.sendBuffer.length;i++)this.sendBufferi.id===e&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},o),s=(...i)=>{this.io.clearTimeoutFn(n),t.apply(this,i)};s.withError=!0,this.ackse=s}emitWithAck(e,...t){return new Promise((r,o)=>{let n=(s,i)=>s?o(s):r(i);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof ee.length-1=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...n)=>r!==this._queue0?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue0;t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:ce.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.ackse;delete this.ackse,t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case ce.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case ce.EVENT:case ce.BINARY_EVENT:this.onevent(e);break;case ce.ACK:case ce.BINARY_ACK:this.onack(e);break;case ce.DISCONNECT:this.ondisconnect();break;case ce.CONNECT_ERROR:this.destroy();let t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof ee.length-1=="string"&&(this._lastOffset=ee.length-1)}ack(e){let t=this,r=!1;return function(...o){r||(r=!0,t.packet({type:ce.ACK,id:e,data:o}))}}onack(e){let t=this.ackse.id;typeof t=="function"&&(delete this.ackse.id,t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:ce.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let r=0;r<t.length;r++)if(e===tr)return t.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let r=0;r<t.length;r++)if(e===tr)return t.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let r of t)r.apply(this,e.data)}}};function Cn(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Cn.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),r=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+r:e-r}return Math.min(e,this.max)|0};Cn.prototype.reset=function(){this.attempts=0};Cn.prototype.setMin=function(e){this.ms=e};Cn.prototype.setMax=function(e){this.max=e};Cn.prototype.setJitter=function(e){this.jitter=e};var sp=class extends Pe{constructor(e,t){var r;super(),this.nsps={},this.subs=[],e&&typeof e=="object"&&(t=e,e=void 0),t=t||{},t.path=t.path||"/socket.io",this.opts=t,Cs(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor((r=t.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new Cn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let o=t.parser||np;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ep(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=yr(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=yr(t,"error",n);if(this._timeout!==!1){let i=this._timeout,a=this.setTimeoutFn(()=>{o(),n(new Error("timeout")),t.close()},i);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(o),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(yr(e,"ping",this.onping.bind(this)),yr(e,"data",this.ondata.bind(this)),yr(e,"error",this.onerror.bind(this)),yr(e,"close",this.onclose.bind(this)),yr(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(t){this.onclose("parse error",t)}}ondecoded(e){Ms(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let r=this.nspse;return r?this._autoConnect&&!r.active&&r.connect():(r=new Ld(this,e,t),this.nspse=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nspsr.active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(tr,e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}},Is={};function Mn(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=m0(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=Isn&&s in Isn.nsps,a=t.forceNew||t"force new connection"||t.multiplex===!1||i,c;return a?c=new sp(o,t):(Isn||(Isn=new sp(o,t)),c=Isn),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Mn,{Manager:sp,Socket:Ld,io:Mn,connect:Mn});var Nd=" must not return ",d0="transformer",h0="recoverer",g0="defaultValue",In=d0+Nd,qr="called with ",An=g0+" must not be ",Fn=h0+Nd;var y0="Ok",Md="Err",Cd=qr+Md,Id=qr+y0,Ad="Carrying E in "+Md+" instead of throwing it directly. See .cause",ip="an instance of Error of the current realm.",jU="The thrown value is not "+ip,BU="The contained E should be "+ip,Fd="This .cause is not "+ip;function K(e){return e.ok}function L(e){return{ok:!0,val:e,err:null}}function O(e){return!e.ok}function M(e){return{ok:!1,val:null,err:e}}function S(e){return ap(e,Cd)}function Z(e){return cp(e,Id)}function ap(e,t){if(O(e))throw new TypeError(t);return e.val}function cp(e,t){if(K(e))throw new TypeError(t);return e.err}function fe(e){return e.val}function xe(e){return e.err}function As(e,t){if(O(e))return e;let r=fe(e);return t(r)}async function Fs(e,t){if(O(e))return e;let r=fe(e);return await t(r)}function x0(e){return e}function lp(e){return As(e,x0)}function pp(e){let t=e.status;switch(t){case"fulfilled":{let r=e.value;return L(r)}case"rejected":{let r=e.reason;return M(r)}default:{let r=\`PromiseSettledResult.status=${String(t)}\` is not supported;throw new TypeError(r)}}}function up(e,t){if(K(e)){let r=fe(e);t(r)}return e}function mp(e,t){if(O(e)){let r=xe(e);t(r)}return e}function fp(e,t,r){if(K(e)){let o=fe(e);t(o)}else{let o=xe(e);r(o)}return e}function ia(e,t){if(K(e))return!1;let r=xe(e);return t(r)}function dp(e,t){return ia(e,t)}function aa(e,t){if(O(e))return!1;let r=fe(e);return t(r)}function hp(e,t){return aa(e,t)}function Gr(e,t){if(O(e))return e;let r=fe(e),o=t(r);return L(o)}async function ie(e,t){if(O(e))return e;let r=fe(e),o=await t(r);return L(o)}function gp(e,t){if(K(e))return e;let r=xe(e),o=t(r);return M(o)}async function Ae(e,t){if(K(e))return e;let r=xe(e),o=await t(r);return M(o)}function yp(e,t,r){if(K(e)){let o=fe(e);return r(o)}return t}async function xp(e,t,r){if(O(e))return t;let o=fe(e);return await r(o)}function Ds(e,t,r){if(K(e)){let n=fe(e);return r(n)}let o=xe(e);return t(o)}async function bp(e,t,r){if(K(e)){let n=fe(e);return await r(n)}let o=xe(e);return await t(o)}function Ep(e,t){if(K(e))return e;let r=xe(e);return t(r)}async function ca(e,t){if(K(e))return e;let r=xe(e);return await t(r)}function la(e,t){return K(e)?t:xe(e)}function $o(e,t){return K(e)?fe(e):t}function wp(e){return $o(e,null)}function Rp(e){return la(e,null)}function kp(e){return $o(e,void 0)}function vp(e){return la(e,void 0)}var pa="null",nr=In+pa,b0=qr+pa,Dn=An+pa,fo=Fn+pa;function je(e){return e!==null}function rt(e){return e===null}function ot(e,t){if(je(e))return e;throw new TypeError(t)}var ua="undefined",sr=In+ua,E0=qr+ua,Un=An+ua,ho=Fn+ua;function nt(e){return e!==void 0}function st(e){return e===void 0}function it(e,t){if(nt(e))return e;throw new TypeError(t)}function Tp(e){if(O(e))return e;let t=fe(e);return rt(t)?null:L(t)}function _p(e){if(O(e))return e;let t=fe(e);if(!st(t))return L(t)}function Dd(e){return e instanceof Error}var w0="UnknownCausalError",R0=class extends Error{constructor(e){super(Fd,{cause:e}),this.name=w0}};function ma(e){return Dd(e)?e:new R0(e)}function fa(e){try{let t=e();return L(t)}catch(t){return M(t)}}function Pp(e){let t=fa(e);if(K(t))return t;let r=xe(t),o=ma(r);return M(o)}async function da(e){let t;try{t=await e()}catch(r){return M(r)}return L(t)}async function Op(e){let t=await da(e);if(K(t))return t;let r=xe(t),o=ma(r);return M(o)}function Sp(e,t){if(K(e))return fe(e);let r=xe(e);return t(r)}async function Lp(e,t){if(K(e))return fe(e);let r=xe(e);return await t(r)}var k0="CausalCarrierError",v0=class extends Error{constructor(e){super(Ad,{cause:e}),this.name=k0}};function Np(e){if(K(e))return fe(e);let t=xe(e);throw new v0(t)}var Be=e=>e.ok?L(e):M({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Ud=async(e,t)=>{let r=new Request(e,t);try{return L(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return M({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return M({name:"NetworkError",message:o.message,request:r});throw o}};var Re=e=>{let{fetch:t=Ud,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var $d=e=>{let{sid:t,hostName:r}=Re(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:ke(t)}}:void 0)},jd=e=>ie(Be(e),async t=>await t.json()),ha=(()=>{let e=async t=>{let{fetch:r,...o}=Re(t??{}),n=await r($d(o));return O(n)?n:jd(S(n))};return e.toRequest=$d,e.fromResponse=jd,e})();var ke=e=>connect.sid=${e},$n=async e=>{let t=e?.csrf??globalThis._csrf;return t?L(t):Gr(await ha(e),r=>r.csrfToken)};var Mt=(e,t)=>{if(e?.connected)return Promise.resolve(L(e));e??=Mn("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"],...t?{rejectUnauthorized:!1,extraHeaders:{Cookie:ke(t),Host:"scrapbox.io",Referer:"https://scrapbox.io/"}}:{}});let r=new Promise(o=>{let n=s=>o(M(s));e.once("connect",()=>{e.off("disconnect",n),o(L(e))}),e.once("disconnect",n)});return e.connect(),r},Ct=e=>{if(e.disconnected)return Promise.resolve(L(void 0));let t=new Promise(r=>{let o=n=>{if(n!=="io client disconnect"){r(M(n));return}r(L(void 0)),e.off("disconnect",o)};e.on("disconnect",o)});return e.disconnect(),t};var Bd=e=>T0.includes(e.name),T0="SocketIOError","DuplicateTitleError","NotFastForwardError";var Hd=(e,t,r,o)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(L(void 0));let{resolve:n,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(u)},c=f=>{if(f==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(f==="io server disconnect"){a(),n(M({name:"SocketIOError"}));return}};e.on("disconnect",c);let l=o?.timeout??9e4,u=setTimeout(()=>{a(),n(M({name:"TimeoutError",message:exceeded ${l} (ms)}))},l),p=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",p,f=>{if(a(),"error"in f){n(M(Bd(f.error)?f.error:{name:"UnexpectedRequestError",...f}));return}n(L(f.data))}),s};function ga(e,t={}){if(e===null)return"null";if(Array.isArray(e))return _0(e,t);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:P0(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function _0(e,t){let{threshold:r=20}=t,o=e.map(i=>ga(i,t)),n=o.join(", ");if(n.length<=r)return[${n}];let s=o.join(`,
);return[
${Wd(2,s)}
]}function P0(e,t){let{threshold:r=20}=t,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${ga(ei,t)}),n=o.join(", ");if(n.length<=r)return{${n}};let s=o.join(,
);return{
${Wd(2,s)}
}}function Wd(e,t){let r=" ".repeat(e);return t.split(
).map(o=>${r}${o}).join(
)}function mt(e,t,...r){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${t}(${r.map(n=>ga(n)).join(", ")}),o)}})}function xr(e){return Array.isArray(e)}function Us(e){return mt(t=>xr(t)&&t.every(r=>e(r)),"isArrayOf",e)}function jo(e){let t=new Set(e);return mt(r=>t.has(r),"isLiteralOneOf",e)}function go(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function ve(e){return typeof e=="string"}var ft=async(e,t)=>{let r=e.response.clone(),o=jo(t);try{let n=await r.json();if(!go(n))return;if(r.status===422){if(!ve(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!ve(n.message)?void 0:n.name==="NotLoggedInError"?!go(n.detals)||!ve(n.detals.project)||!Us(O0)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},O0=jo(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var ae=e=>e.replaceAll(" ","_").toLowerCase();var ne=e=>[...e].map((t,r)=>t===" "?"_":!S0.includes(t)||r===e.length-1&&L0.includes(t)?encodeURIComponent(t):t).join(""),S0='@$&+=:;",',L0=':;",';var ya="null or undefined",ir=In+ya,N0=qr+ya,jn=An+ya,yo=Fn+ya;function Ke(e){return e!=null}function Ye(e){return e==null}function Xe(e,t){if(Ke(e))return e;throw new TypeError(t)}function Mp(e,t){return Ye(e)?e:t(e)}async function Cp(e,t){return Ye(e)?e:await t(e)}function Ip(e,t){return Ke(e)&&t(e),e}function Ap(e,t){if(Ye(e))return e;let r=t(e);return Xe(r,ir)}async function Fp(e,t){if(Ye(e))return e;let r=await t(e);return Xe(r,ir)}function Dp(e,t,r){let o,n="";return e!=null?(o=r(e),n=ir):(o=t,n=jn),Xe(o,n)}async function Up(e,t,r){if(Ye(e))return Xe(t,jn);let o=await r(e);return Xe(o,ir)}function $p(e,t,r){let o,n="";return e!=null?(o=r(e),n=ir):(o=t(),n=yo),Xe(o,n)}async function jp(e,t,r){let o,n="";return Ke(e)?(o=await r(e),n=ir):(o=await t(),n=yo),Xe(o,n)}function Bp(e,t){return Ke(e)?L(e):M(t)}function $s(e,t){if(Ke(e))return L(e);let r=t();return M(r)}async function Hp(e,t){if(Ke(e))return L(e);let r=await t();return M(r)}function Wp(e,t){return e??t()}async function qp(e,t){return Ke(e)?e:await t()}function Gp(e){return Ye(e)?null:e}function xa(e){return Ye(e)?M(void 0):L(e)}function zp(e){return Ye(e)?L(void 0):M(e)}function Vp(e){if(!Ye(e))return e}function js(e,t){return Ke(e)?e:Xe(t,jn)}function Kp(e,t){if(Ke(e))return e;let r=t();return Xe(r,yo)}async function Yp(e,t){if(Ke(e))return e;let r=await t();return Xe(r,yo)}var qd=(e,t,r)=>{let{sid:o,hostName:n,followRename:s,projects:i}=Re(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(https://${n}/api/pages/${e}/${ne(t)}?${a},o?{headers:{Cookie:ke(o)}}:void 0)},Gd=async e=>Ae(await ie(Be(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:js(await ft(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),ar=(()=>{let e=async(t,r,o)=>Fs(await Re(o??{}).fetch(qd(t,r,o)),n=>Gd(n));return e.toRequest=qd,e.fromResponse=Gd,e})();var zd=(e,t)=>{let{sid:r,hostName:o}=Re(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:ke(r)}}:void 0)},Vd=async e=>ie(await Ae(Be(e),async t=>await ft(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),Bo=(()=>{let e=async(t,r)=>{let{fetch:o}=Re(r??{}),n=zd(t,r),s=await o(n);return O(s)?s:Vd(S(s))};return e.toRequest=zd,e.fromResponse=Vd,e})(),Kd=(e,t)=>{let{sid:r,hostName:o}=Re(t??{}),n=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${o}/api/projects?${n},r?{headers:{Cookie:ke(r)}}:void 0)},Yd=async e=>ie(await Ae(Be(e),async t=>await ft(t,["NotLoggedInError"])??t),t=>t.json()),ba=(()=>{let e=async(t,r)=>{let{fetch:o}=Re(r??{}),n=await o(Kd(t,r));return O(n)?n:Yd(S(n))};return e.toRequest=Kd,e.fromResponse=Yd,e})();var Jp=async(e,t,r)=>{let[o,n,s]=await Promise.all([ar(e,t,r),C0(r),I0(e,r)]);return O(o)?o:O(n)?n:O(s)?s:L({...S(o),projectId:S(s),userId:S(n)})},Xp,C0=async e=>{if(Xp)return L(Xp);let t=await ha(e);if(O(t))return t;let r=S(t);return"id"in r?(Xp=r.id,L(r.id)):M({name:"NotLoggedInError",message:"This script cannot be used without login"})},Xd=new Map,I0=async(e,t)=>{let r=Xd.get(e);return r?L(r):Gr(await Bo(e,t),({id:o})=>(Xd.set(e,o),o))};function Fe(e,t={}){let{signal:r,persistent:o=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((n,s)=>{let i=()=>{clearTimeout(+c),s(r?.reason)},c=A0(()=>{r?.removeEventListener("abort",i),n()},e);if(r?.addEventListener("abort",i,{once:!0}),o===!1)try{Deno.unrefTimer(+c)}catch(l){if(!(l instanceof ReferenceError))throw clearTimeout(+c),l;console.error("persistent option is only available in Deno")}})}var Jd=2**31-1;function A0(e,t){let r=t=Math.trunc(Math.max(t,0)||0),o=Date.now(),n,s=()=>{r=t-(Date.now()-o),n=r>Jd?Number(setTimeout(s,Jd)):Number(setTimeout(e,r))};return s(),{valueOf:()=>n}}var Ho=async(e,t,r,o)=>{let n=await Mt(o?.socket,o?.sid);if(O(n))return M({name:"UnexpectedRequestError",error:Z(n)});let s=S(n),i=await Jp(e,t,o);if(O(i))return i;let a=S(i);try{let c=0,l=[],u;for(;o?.maxAttempts===void 0||c<o.maxAttempts;){let p=r(a,c,l,u);if(l=p instanceof Promise?await p:p,c++,l.length===0)return L(a.commitId);let f={kind:"page",projectId:a.projectId,pageId:a.id,parentId:a.commitId,userId:a.userId,changes:l,cursor:null,freeze:!0};for(;;){let m=await Hd(s,"commit",f);if(K(m))return a.commitId=S(m).commitId,L(a.commitId);let h=Z(m),g=h.name;if(g==="SocketIOServerDisconnectError"||g==="UnexpectedRequestError")return M(h);if(g==="TimeoutError"||g==="SocketIOError"){await Fe(3e3);continue}if(g==="NotFastForwardError"){await Fe(1e3);let y=await Jp(e,t,o);if(O(y))return y;a=S(y)}u=g;break}}return M({name:"RetryError",attempts:c,message:Retrying exceeded the maxAttempts (${c}).})}finally{o?.socket||await Ct(s)}};var Qp=(e,t)=>{let r=e.length>t.length,o=r?t:e,n=r?e:t,s=o.length+1,i=o.length+n.length+3,a=new Array(i);a.fill(-1);let c=[];function l(g,y,x){let w=Math.max(y,x),k=w-g;for(;k<o.length&&w<n.length&&o[k]===n[w];)++k,++w;return a[g+s]=c.length,c.push([{x:k,y:w},a[g+(y>x?-1:1)+s]]),w}let u=new Array(i);u.fill(-1);let p=-1,f=n.length-o.length;do{++p;for(let g=-p;g<=f-1;++g)u[g+s]=l(g,u[g-1+s]+1,u[g+1+s]);for(let g=f+p;g>=f+1;--g)u[g+s]=l(g,u[g-1+s]+1,u[g+1+s]);u[f+s]=l(f,u[f-1+s]+1,u[f+1+s])}while(u[f+s]!==n.length);let m=[],h=a[f+s];for(;h!==-1;)m.push(c[h][0]),h=c[h][1];return{from:e,to:t,editDistance:f+p*2,buildSES:function*(){let g=0,y=0;for(let{x,y:w}of F0(m))for(;g<x||y<w;)w-x>y-g?(yield{value:n[y],type:r?"deleted":"added"},++y):w-x<y-g?(yield{value:o[g],type:r?"added":"deleted"},++g):(yield{value:o[g],type:"common"},++g,++y)}}};function*Zp(e){let t=[],r=[];function*o(){if(t.length>r.length){for(let n=0;n<r.length;n++)yield Qd(t[n],r[n]);for(let n=r.length;n<t.length;n++)yield t[n]}else{for(let n=0;n<t.length;n++)yield Qd(t[n],r[n]);for(let n=t.length;n<r.length;n++)yield r[n]}t=[],r=[]}for(let n of e)switch(n.type){case"added":t.push(n);break;case"deleted":r.push(n);break;case"common":yield*o(),yield n;break}yield*o()}var Qd=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*F0(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var Zd=e=>e.padStart(8,"0"),eu=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${Zd(t).slice(-8)}${e.slice(-6)}0000${Zd(r)}};function*tu(e,t,{userId:r}){let{buildSES:o}=Qp(e.map(({text:i})=>i),t),n=0,s=e[0].id;for(let i of Zp(o())){switch(i.type){case"added":yield{_insert:s,lines:{id:eu(r),text:i.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:i.value}};break}n++,s=e[n]?.id??"_end"}}var eh=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*code:/,"");return{indent:o,type:"codeBlock",fileName:s,content:r.map(i=>i.text.substring(o+1)).join(
)}};var le=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let a of o){let c=a.exec(n);if(c===null)continue;let l=n.substring(0,c.index),u=n.substring(c.index+(c[0]?.length??0)),p=e(c[0]??"",s);return[...jt(l,s),...p,...jt(u,s)]}return i?.()??[]};var de=e=>[{type:"plain",raw:e,text:e}],th=le(de,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var D0=/\[\s+\]/,U0=(e,t)=>t.context==="table"?de(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],rh=le(U0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[D0]});var $0=/.*?/,j0=(e,t)=>t.context==="table"?de(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],oh=le(j0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[$0]});var B0=/^[$%] .+$/,H0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e[0]??"",o=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:o}]},nh=le(H0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[B0]});var W0=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,q0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let i=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(i,10)})}return[{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:jt(n,{...t,nested:!0})}]},sh=le(q0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[W0]});var G0=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,z0=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,V0=/\[https?:\/\/[^\s\]]+\]/,K0=/https?:\/\/[^\s]+/,Y0=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,o=/^https?:\/\/[^\s\]]/.test(r),n=(o?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(n?.[0]===void 0)return[];let s=o?r.substring(n[0].length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n[0],content:s.trim()}]},ih=le(Y0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[G0,z0,V0,K0]});var X0=/\[\$ .+? \]/,J0=/\[\$ [^\]]+\]/,Q0=(e,t)=>t.context==="table"?de(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],ah=le(Q0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[X0,J0]});var ch=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,lh=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Z0=e=>{let[t="",r="",o=""]=e.split(","),n=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(o)?Number.parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:i}},e_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.match(ch)??e.match(lh);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),[,n="",s=""]=o?r:[r[0],r[2],r[1]],{latitude:i,longitude:a,zoom:c}=Z0(n),l=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${i},${a},${c}z:https://www.google.com/maps/@${i},${a},${c}z;return[{type:"googleMap",raw:e,latitude:i,longitude:a,zoom:c,place:s,url:l}]},ph=le(e_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[ch,lh]});var t_=/(?:^|\s)#\S+/,r_=(e,t)=>{if(t.context==="table")return de(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),o=e.substring(1);return[...de(r,t),{type:"hashTag",raw:o,href:o.substring(1)}]},uh=le(r_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[t_]});var o_=/^\? .+$/,n_=(e,t)=>t.context==="table"?de(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],mh=le(n_,{parseOnNested:!1,parseOnQuoted:!1,patterns:[o_]});var s_=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,i_=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),o=t.substring(0,r),n=o.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),i=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:o,pathType:n,type:"icon",raw:e}))},fh=le(i_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[s_]});var a_=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,c_=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,l_=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,p_=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,u_=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||m_(e),m_=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),f_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,i]=u_(n)?[n,o]:[o,n];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:i}]},dh=le(f_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[a_,c_,l_,p_]});var d_=/\[\/?[^[\]]+\]/,h_=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},hh=le(h_,{parseOnNested:!0,parseOnQuoted:!0,patterns:[d_]});var g_=/^[0-9]+\. .*$/,y_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=Number.parseInt(o,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:o,number:n,nodes:jt(s,{...t,nested:!1})}]},gh=le(y_,{parseOnNested:!1,parseOnQuoted:!1,patterns:[g_]});var x_=/^>.*$/,b_=(e,t)=>t.context==="table"?de(e,t):[{type:"quote",raw:e,nodes:jt(e.substring(1),{...t,quoted:!0})}],yh=le(b_,{parseOnNested:!1,parseOnQuoted:!1,patterns:[x_]});var E_=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,w_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.substring(2,e.length-2),o=r.lastIndexOf(".icon"),n=r.substring(0,o),s=n.startsWith("/")?"root":"relative",i=r.substring(o+5,r.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},xh=le(w_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[E_]});var R_=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,k_=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,v_=(e,t)=>{if(t.context==="table")return de(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?${r}/thumb/1000:r}]},bh=le(v_,{parseOnNested:!1,parseOnQuoted:!0,patterns:[R_,k_]});var T_=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,__=(e,t)=>t.context==="table"?de(e,t):[{type:"strong",raw:e,nodes:jt(e.substring(2,e.length-2),{...t,nested:!0})}],Eh=le(__,{parseOnNested:!1,parseOnQuoted:!0,patterns:[T_]});var P_=(e,t,r)=>e===""?[]:r?.()??[],O_=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>th(t,r))(),jt=O_(P_,yh,mh,gh,oh,nh,rh,sh,ah,bh,xh,Eh,dh,ih,fh,ph,hh,uh);var wh=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:jt(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Rh=e=>{let{rows:[t,...r]}=e,{indent:o=0,text:n=""}=t??{},s=n.replace(/^\s*table:/,"");return{indent:o,type:"table",fileName:s,cells:r.map(i=>i.text.substring(o+1)).map(i=>i.split(" ").map(a=>jt(a,{nested:!1,quoted:!1,context:"table"})))}};var kh=e=>({type:"title",text:e.rows[0].text});var vh=e=>{switch(e.type){case"title":return kh(e);case"codeBlock":return eh(e);case"table":return Rh(e);case"line":return wh(e)}};var S_=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),Th=(e,t)=>{let r=e[e.length-1];return r!==void 0&&S_(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)},_h=(e,t)=>{if(t.hasTitle??!0){let[r,...o]=e;return r===void 0?[]:[{type:"title",rows:[r]},...o.reduce(Th,[])]}return e.reduce(Th,[])};var Ph=e=>e.split(
).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var at=(e,t)=>{let r=Ph(e);return _h(r,{hasTitle:t?.hasTitle??!0}).map(vh)},Oh=e=>/^\s*\S.*$/m.exec(e)?.[0]?.trim()??"Untitled";var L_=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,N_=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,M_=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,C_=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Ea=e=>{if(L_.test(e)){let t=new URL(e).searchParams,r=t.get("v");if(r)return{pathType:"com",videoId:r,params:t}}{let t=e.match(N_);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"dotbe"}}}{let t=e.match(M_);if(t){let[,r,o]=t;return{videoId:r,params:new URLSearchParams(o),pathType:"short"}}}{let t=e.match(C_);if(t){let[,r,o]=t;return{listId:o,params:new URLSearchParams(r),pathType:"list"}}}};var Nh=e=>{let t=at(e,{hasTitle:!0}),r="",o=new Map,n=[],s=new Set,i=[],a=new Set,c=[],l=null,u=[],p=new Set,f=new Set,m=new RegExp(${globalThis.location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),h=x=>{switch(x.type){case"hashTag":if(o.has(ae(x.href)))return;o.set(ae(x.href),!1),n.push(x.href);return;case"link":switch(x.pathType){case"relative":{let w=Lh(x.href);if(o.get(ae(w)))return;o.set(ae(w),!0),n.push(w);return}case"root":{let w=Lh(x.href);if(/^\/[\w\d-]+\/?$/.test(w)||s.has(ae(w)))return;s.add(ae(w)),i.push(w);return}case"absolute":{if(x.content)return;let w=Ea(x.href);if(w&&w.pathType!=="list"){l??=https://i.ytimg.com/vi/${w.videoId}/mqdefault.jpg;return}let k=x.href.match(m)?.[1];k&&p.add(k);return}default:return}case"icon":case"strongIcon":{if(x.pathType==="root"||a.has(ae(x.path)))return;a.add(ae(x.path)),c.push(x.path);return}case"image":case"strongImage":{l??=x.src.endsWith("/thumb/1000")?x.src.replace(/\/thumb\/1000$/,"/raw"):x.src;{let w=x.src.match(m)?.[1];w&&p.add(w)}if(x.type==="image"){let w=x.link.match(m)?.[1];w&&p.add(w)}return}case"helpfeel":f.add(x.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let w of x.nodes)h(w);return}default:return}},g=[];for(let x of t)switch(x.type){case"title":{r=x.text;continue}case"line":u.length<5&&x.nodes.length>0&&u.push(x.nodes[0].type==="helpfeel"||x.nodes[0].type==="commandLine"?Sh(x.nodes[0].raw):x.nodes.map(w=>w.raw).join("").trim().slice(0,200));for(let w of x.nodes)h(w);continue;case"codeBlock":u.length<5&&u.push(Sh(x.content));continue;case"table":{for(let w of x.cells)for(let k of w)for(let b of k)h(b);if(!["infobox","cosense"].includes(x.fileName))continue;g.push(...x.cells.map(w=>w.map(k=>k.map(b=>b.raw).join("")).join(" ").trim()));continue}}let y=e.split(
);return[r,n,i,c,l,u,[...p],[...f],g,y.length,y.reduce((x,w)=>x+[...w].length,0)]},Sh=e=>\${e.trim().replaceAll("","\\").slice(0,198)}\`,Lh=e=>e.replace(/#a-f\d{24,32}$/,"");var xo=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));var Mh=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?t.trimStart().slice(2):[]);function*Ch(e,t,r){let o=t.flatMap(g=>(ve(g)?g:g.text).split(`
));for(let g of tu(e.lines,o,{userId:r}))yield g;let[n,s,i,a,c,l,u,p,f,m,h]=Nh(o.join(
));(e.title!==n||!e.persistent)&&(yield{title:n}),xo(e.links,s)||(yield{links:s}),xo(e.projectLinks,i)||(yield{projectLinks:i}),xo(e.icons,a)||(yield{icons:a}),e.image!==c&&(yield{image:c}),xo(e.descriptions,l)||(yield{descriptions:l}),xo(e.files,u)||(yield{files:u}),xo(Mh(e.lines),p)||(yield{helpfeels:p}),xo(e.infoboxDefinition,f)||(yield{infoboxDefinition:f}),yield{linesCount:m},yield{charsCount:h}}var Ih=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,o=t?.[2]?parseInt(t[2])+1:2;return${r}_${o}};var Ah=()=>Number.MAX_SAFE_INTEGER-Math.floor(Date.now()/1e3);var Le=(e,t,r,o)=>Ho(e,t,async(n,s,i,a)=>{if(a==="DuplicateTitleError"){let m=Ih(t);return i.map(h=>("title"in h&&(h.title=m),h))}let c=r(n.lines,{...n,attempts:s}),l=c instanceof Promise?await c:c;if(l===void 0)return[];let[u,p]=Array.isArray(l)?[l,void 0]:[l.lines,l.pin];if(u.length===0)return[{deleted:!0}];let f=n.lines===u?[]:[...Ch(n,u,n.userId)];return p!==void 0&&(p&&n.pin===0||!p&&n.pin>0)&&f.push({pin:p?Ah():0}),f},o);var Fh=(e,t,r)=>Ho(e,t,o=>o.persistent?[{deleted:!0}]:[],r);var wa=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i}=Re(o??{}),a=await $n(o);if(O(a))return a;let c=new Request(https://${s}/api/pages/${e}/replace/links,{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":S(a),...n?{Cookie:ke(n)}:{}},body:JSON.stringify({from:t,to:r})}),l=await i(c);return O(l)?l:ie(await Ae(Be(S(l)),async u=>await ft(u,["NotFoundError","NotLoggedInError","NotMemberError"])??u),async u=>{let{message:p}=await u.json();return parseInt(p.match(/\d+/)?.[0]??"0")})};var Dh=(e,t)=>{let{sid:r,hostName:o,followingId:n}=Re(t??{});return new Request(https://${o}/api/pages/${e}/search/titles${n??followingId=${n}:""},r?{headers:{Cookie:ke(r)}}:void 0)},Uh=async e=>ie(await Ae(Be(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await ft(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),F_=(()=>{let e=async(t,r)=>{let o=await Re(r??{}).fetch(Dh(t,r));return O(o)?o:Uh(S(o))};return e.toRequest=Dh,e.fromResponse=Uh,e})();async function*$h(e,t){let r;do{let o=await F_(e,{followingId:r,...t});if(O(o)){yield o;return}let n=S(o);yield L(n.pages),r=n.followingId}while(r)}var jh=async(e,t,r)=>{let{sid:o,hostName:n,fetch:s}=Re(r??{}),i=new Request(https://${n}/api/pages/${t}/search/query?q=${encodeURIComponent(e)},o?{headers:{Cookie:ke(o)}}:void 0),a=await s(i);return O(a)?a:ie(await Ae(Be(S(a)),async c=>await ft(c,["NotFoundError","NotLoggedInError","NotMemberError","NoQueryError"])??c),c=>c.json())};var Bh=(e,t,r,o)=>{let{sid:n,hostName:s}=Re(o??{});return new Request(https://${s}/api/code/${e}/${ne(t)}/${ne(r)},n?{headers:{Cookie:ke(n)}}:void 0)},Hh=async e=>ie(await Ae(Be(e),async t=>t.response.status===404&&t.response.headers.get("Content-Type")?.includes?.("text/plain")?{name:"NotFoundError",message:"Code block is not found"}:await ft(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),Ra=(()=>{let e=async(t,r,o,n)=>{let s=Bh(t,r,o,n),i=await Re(n??{}).fetch(s);return O(i)?i:Hh(S(i))};return e.toRequest=Bh,e.fromResponse=Hh,e})();var ou=e=>{let t=typeof e=="string"?new TextEncoder().encode(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),r=[1732584193,4023233417,2562383102,271733878],o=new Uint8Array(ru),n=0,s=0,i=0;[r,o,n,s,i]=qh(r,o,n,s,i,t);let a=ru-n;a<9&&(a+=ru);let c=new Uint8Array(a);c[0]=128,[s,i]=[s<<3,i<<3|s>>>29],c[c.length-8]=s&255,c[c.length-7]=s>>>8&255,c[c.length-6]=s>>>16&255,c[c.length-5]=s>>>24&255,c[c.length-4]=i&255,c[c.length-3]=i>>>8&255,c[c.length-2]=i>>>16&255,c[c.length-1]=i>>>24&255,[r,o,n,s,i]=qh(r,o,n,s,i,new Uint8Array(c.buffer));let l=new ArrayBuffer(16),u=new DataView(l);return u.setUint32(0,r[0],!0),u.setUint32(4,r[1],!0),u.setUint32(8,r[2],!0),u.setUint32(12,r[3],!0),l},ru=64,z=(e,t)=>e<<t|e>>>32-t,It=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Wh=(e,t)=>{let[r,o,n,s]=e,i=It(t,0),a=It(t,4),c=It(t,8),l=It(t,12),u=It(t,16),p=It(t,20),f=It(t,24),m=It(t,28),h=It(t,32),g=It(t,36),y=It(t,40),x=It(t,44),w=It(t,48),k=It(t,52),b=It(t,56),T=It(t,60);return r=o+z(((n^s)&o^s)+r+i+3614090360,7),s=r+z(((o^n)&r^n)+s+a+3905402710,12),n=s+z(((r^o)&s^o)+n+c+606105819,17),o=n+z(((s^r)&n^r)+o+l+3250441966,22),r=o+z(((n^s)&o^s)+r+u+4118548399,7),s=r+z(((o^n)&r^n)+s+p+1200080426,12),n=s+z(((r^o)&s^o)+n+f+2821735955,17),o=n+z(((s^r)&n^r)+o+m+4249261313,22),r=o+z(((n^s)&o^s)+r+h+1770035416,7),s=r+z(((o^n)&r^n)+s+g+2336552879,12),n=s+z(((r^o)&s^o)+n+y+4294925233,17),o=n+z(((s^r)&n^r)+o+x+2304563134,22),r=o+z(((n^s)&o^s)+r+w+1804603682,7),s=r+z(((o^n)&r^n)+s+k+4254626195,12),n=s+z(((r^o)&s^o)+n+b+2792965006,17),o=n+z(((s^r)&n^r)+o+T+1236535329,22),r=o+z(((o^n)&s^n)+r+a+4129170786,5),s=r+z(((r^o)&n^o)+s+f+3225465664,9),n=s+z(((s^r)&o^r)+n+x+643717713,14),o=n+z(((n^s)&r^s)+o+i+3921069994,20),r=o+z(((o^n)&s^n)+r+p+3593408605,5),s=r+z(((r^o)&n^o)+s+y+38016083,9),n=s+z(((s^r)&o^r)+n+T+3634488961,14),o=n+z(((n^s)&r^s)+o+u+3889429448,20),r=o+z(((o^n)&s^n)+r+g+568446438,5),s=r+z(((r^o)&n^o)+s+b+3275163606,9),n=s+z(((s^r)&o^r)+n+l+4107603335,14),o=n+z(((n^s)&r^s)+o+h+1163531501,20),r=o+z(((o^n)&s^n)+r+k+2850285829,5),s=r+z(((r^o)&n^o)+s+c+4243563512,9),n=s+z(((s^r)&o^r)+n+m+1735328473,14),o=n+z(((n^s)&r^s)+o+w+2368359562,20),r=o+z((o^n^s)+r+p+4294588738,4),s=r+z((r^o^n)+s+h+2272392833,11),n=s+z((s^r^o)+n+x+1839030562,16),o=n+z((n^s^r)+o+b+4259657740,23),r=o+z((o^n^s)+r+a+2763975236,4),s=r+z((r^o^n)+s+u+1272893353,11),n=s+z((s^r^o)+n+m+4139469664,16),o=n+z((n^s^r)+o+y+3200236656,23),r=o+z((o^n^s)+r+k+681279174,4),s=r+z((r^o^n)+s+i+3936430074,11),n=s+z((s^r^o)+n+l+3572445317,16),o=n+z((n^s^r)+o+f+76029189,23),r=o+z((o^n^s)+r+g+3654602809,4),s=r+z((r^o^n)+s+w+3873151461,11),n=s+z((s^r^o)+n+T+530742520,16),o=n+z((n^s^r)+o+c+3299628645,23),r=o+z((n^(o|~s))+r+i+4096336452,6),s=r+z((o^(r|~n))+s+m+1126891415,10),n=s+z((r^(s|~o))+n+b+2878612391,15),o=n+z((s^(n|~r))+o+p+4237533241,21),r=o+z((n^(o|~s))+r+w+1700485571,6),s=r+z((o^(r|~n))+s+l+2399980690,10),n=s+z((r^(s|~o))+n+y+4293915773,15),o=n+z((s^(n|~r))+o+a+2240044497,21),r=o+z((n^(o|~s))+r+h+1873313359,6),s=r+z((o^(r|~n))+s+T+4264355552,10),n=s+z((r^(s|~o))+n+f+2734768916,15),o=n+z((s^(n|~r))+o+k+1309151649,21),r=o+z((n^(o|~s))+r+u+4149444226,6),s=r+z((o^(r|~n))+s+x+3174756917,10),n=s+z((r^(s|~o))+n+c+718787259,15),o=n+z((s^(n|~r))+o+g+3951481745,21),[e[0]+r>>>0,e[1]+o>>>0,e[2]+n>>>0,e[3]+s>>>0]},qh=(e,t,r,o,n,s)=>{let i=64-r;if(s.length<i)t.set(s,r),r+=s.length;else{t.set(s.slice(0,i),r),e=Wh(e,t);let a=i;for(;a+64<=s.length;)e=Wh(e,s.slice(a,a+64)),a+=64;t.fill(0).set(s.slice(a),0),r=s.length-a}return[o,n]=D_(o,n,s.length),[e,t,r,o,n]},D_=(e,t,r)=>(e+=r,e>4294967295&&(t+=1),[e>>>0,t]);var U_=new TextEncoder().encode("0123456789abcdef"),Gh=new Uint8Array(128).fill(16);U_.forEach((e,t)=>Gh[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Gh[e]=t+10);function zh(e){return e*2}function Vh(e,t,r,o){for(;t<e.length;++t){let n=e[t];e[r++]=o[n>>4],e[r++]=o[n&15]}return r}function Kh(e,t){let r=e.length;if(e.byteOffset){let o=new Uint8Array(e.buffer);o.set(e),e=o.subarray(0,r)}return e=new Uint8Array(e.buffer.transfer(t)),e.set(e.subarray(0,r),t-r),[e,t-r]}var Yh=new TextEncoder().encode("0123456789abcdef"),Xh=new Uint8Array(128).fill(16);Yh.forEach((e,t)=>Xh[e]=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Xh[e]=t+10);function nu(e){typeof e=="string"?e=new TextEncoder().encode(e):e instanceof ArrayBuffer?e=new Uint8Array(e).slice():e=e.slice();let[t,r]=Kh(e,zh(e.length));return Vh(t,r,0,Yh),new TextDecoder().decode(t)}var Jh=async e=>{let t=e.title??".watchlistrc",r="projectsLastAccessed.json",o=await Ra(e.project,t,r),n=O(o)?{}:JSON.parse(S(o)||"{}"),s=JSON.parse(localStorage.getItem("projectsLastAccessed")??"{}"),i=new Set([...Object.keys(n),...Object.keys(s)]),a=Object.fromEntries([...i].map(l=>[l,Math.max(n[l]??0,s[l]??0)]).sort((l,u)=>u[1]-l[1])),c=JSON.stringify(a);localStorage.setItem("projectsLastAccessed",c),await Le(e.project,t,()=>[t,"This page is automatically generated. DO NOT EDIT ANYTHING, WHITCH WILL BE OVERWRITTEN.","",code:${r}, ${c},""])};var Qt=!1,ka=e=>{Qt=typeof e=="boolean"?e:new Set(e)},Bn=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},su,...o)];case"log":case"info":case"debug":return[t,(...o)=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(%c${e},su,...o)}];case"assert":return[t,(o,...n)=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(o,%c${e},su,...n)}];case"time":case"timeEnd":return[t,o=>{Qt!==!0&&(!Qt||!Qt.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(Qt!==!0&&(!Qt||!Qt.has(e))))return r(...o)}]}})),su="color: gray";var zr=globalThis.scrapbox;var Bs=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}};var Qh=e=>{let{accessToken:t,fetch:r,page:o,per:n}=Bs(e??{}),i=https://api.gyazo.com/api/images?${new URLSearchParams({access_token:t,...n!==void 0?{per_page:${Math.max(1,Math.min(100,Math.round(n)))}}:{},...o!==void 0?{page:${o}}:{}})};return r(i)};var Zh=(e,t)=>{let{title:r,description:o,metadataIsPublic:n,collectionId:s,refererURL:i,accessToken:a,created:c,app:l,fetch:u}=Bs(t),p=new FormData;return p.append("imagedata",e),p.append("access_token",a),i&&p.append("referer_url",i.toString()),l!==void 0&&p.append("app",l),r!==void 0&&p.append("title",r),o!=null&&p.append("desc",o),s&&p.append("collection_id",s),n&&p.append("metadata_is_public","true"),c!==void 0&&p.append("created_at",${c}),u("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:p})};var Hn="Gyazo Viewer",eg=e=>{let t=Promise.resolve(),r=globalThis.GM_fetch;zr.PageMenu.addMenu({title:r?Hn:"Open Gyazo",icon:"kamon kamon-gyazo",onClick:r?()=>{t=t.then(()=>$_({per:e.maxCount??10,accessToken:e.accessToken,fetch:r,onClick:e.onClick}))}:()=>globalThis.open("https://gyazo.com/captures")})},$_=async e=>{let t;try{let r=Qh({page:0,...e});t=setTimeout(()=>{zr.PageMenu(Hn).addItem({title:"Loading...",icon:"fas fa-spinner",onClick:()=>{}})},100);let o=await r;if(!o.ok)throw new Error(${o.status} ${o.statusText});let n=await o.json();clearTimeout(t),zr.PageMenu(Hn).removeAllItems();for(let s of n)s.image_id&&zr.PageMenu(Hn).addItem({title:s.metadata?.title||"Untitled",image:s.url,onClick:i=>e.onClick?.(s,i)??navigator?.clipboard?.writeText?.(s.permalink_url)?.catch?.(a=>{alert(${a}),console.error(a)})})}catch(r){clearTimeout(t),zr.PageMenu(Hn).removeAllItems(),zr.PageMenu(Hn).addItem({title:"Failed to load the image list.",icon:"fas fa-exclamation-triangle",onClick:()=>{}}),console.error("Failed to load the image list",r)}};import{GYAZO_ACCESS_TOKEN as CD}from"https://scrapbox.io/api/code/takker-memex/GYAZO_ACCESS_TOKEN/auth.js";var Pa,re,ng,j_,Wo,tg,sg,ig,ag,pu,iu,au,cg,Hs={},lg=[],B_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Ws=Array.isArray;function Vr(e,t){for(var r in t)e[r]=t[r];return e}function uu(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Kr(e,t,r){var o,n,s,i={};for(s in t)s=="key"?o=t[s]:s=="ref"?n=t[s]:i[s]=t[s];if(arguments.length>2&&(i.children=arguments.length>3?Pa.call(arguments,2):r),typeof e=="function"&&e.defaultProps!=null)for(s in e.defaultProps)i[s]===void 0&&(i[s]=e.defaultProps[s]);return Ta(e,i,o,n,null)}function Ta(e,t,r,o,n){var s={type:e,props:t,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:n??++ng,__i:-1,__u:0};return n==null&&re.vnode!=null&&re.vnode(s),s}function ee(e){return e.children}function br(e,t){this.props=e,this.context=t}function Wn(e,t){if(t==null)return e.__?Wn(e.__,e.__i+1):null;for(var r;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null)return r.__e;return typeof e.type=="function"?Wn(e):null}function pg(e){var t,r;if((e=e.__)!=null&&e.__c!=null){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if((r=e.__k[t])!=null&&r.__e!=null){e.__e=e.__c.base=r.__e;break}return pg(e)}}function cu(e){(!e.__d&&(e.__d=!0)&&Wo.push(e)&&!_a.__r++||tg!=re.debounceRendering)&&((tg=re.debounceRendering)||sg)(_a)}function _a(){for(var e,t,r,o,n,s,i,a=1;Wo.length;)Wo.length>a&&Wo.sort(ig),e=Wo.shift(),a=Wo.length,e.__d&&(r=void 0,o=void 0,n=(o=(t=e).__v).__e,s=[],i=[],t.__P&&((r=Vr({},o)).__v=o.__v+1,re.vnode&&re.vnode(r),mu(t.__P,r,o,t.__n,t.__P.namespaceURI,32&o.__u?[n]:null,s,n??Wn(o),!!(32&o.__u),i),r.__v=o.__v,r.__.__k[r.__i]=r,fg(s,r,i),o.__e=o.__=null,r.__e!=n&&pg(r)));_a.__r=0}function ug(e,t,r,o,n,s,i,a,c,l,u){var p,f,m,h,g,y,x,w=o&&o.__k||lg,k=t.length;for(c=H_(r,t,w,c,k),p=0;p<k;p++)(m=r.__k[p])!=null&&(f=m.__i==-1?Hs:w[m.__i]||Hs,m.__i=p,y=mu(e,m,f,n,s,i,a,c,l,u),h=m.__e,m.ref&&f.ref!=m.ref&&(f.ref&&fu(f.ref,null,m),u.push(m.ref,m.__c||h,m)),g==null&&h!=null&&(g=h),(x=!!(4&m.__u))||f.__k===m.__k?c=mg(m,c,e,x):typeof m.type=="function"&&y!==void 0?c=y:h&&(c=h.nextSibling),m.__u&=-7);return r.__e=g,c}function H_(e,t,r,o,n){var s,i,a,c,l,u=r.length,p=u,f=0;for(e.__k=new Array(n),s=0;s<n;s++)(i=t[s])!=null&&typeof i!="boolean"&&typeof i!="function"?(c=s+f,(i=e.__k[s]=typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?Ta(null,i,null,null,null):Ws(i)?Ta(ee,{children:i},null,null,null):i.constructor==null&&i.__b>0?Ta(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i).__=e,i.__b=e.__b+1,a=null,(l=i.__i=W_(i,r,c,p))!=-1&&(p--,(a=r[l])&&(a.__u|=2)),a==null||a.__v==null?(l==-1&&(n>u?f--:n<u&&f++),typeof i.type!="function"&&(i.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,i.__u|=4))):e.__k[s]=null;if(p)for(s=0;s<u;s++)(a=r[s])!=null&&!(2&a.__u)&&(a.__e==o&&(o=Wn(a)),hg(a,a));return o}function mg(e,t,r,o){var n,s;if(typeof e.type=="function"){for(n=e.__k,s=0;n&&s<n.length;s++)n[s]&&(n[s].__=e,t=mg(n[s],t,r,o));return t}e.__e!=t&&(o&&(t&&e.type&&!t.parentNode&&(t=Wn(e)),r.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function bo(e,t){return t=t||[],e==null||typeof e=="boolean"||(Ws(e)?e.some(function(r){bo(r,t)}):t.push(e)),t}function W_(e,t,r,o){var n,s,i,a=e.key,c=e.type,l=t[r],u=l!=null&&(2&l.__u)==0;if(l===null&&e.key==null||u&&a==l.key&&c==l.type)return r;if(o>(u?1:0)){for(n=r-1,s=r+1;n>=0||s<t.length;)if((l=t[i=n>=0?n--:s++])!=null&&!(2&l.__u)&&a==l.key&&c==l.type)return i}return-1}function rg(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||B_.test(t)?r:r+"px"}function va(e,t,r,o,n){var s,i;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||rg(e.style,t,"");if(r)for(t in r)o&&r[t]==o[t]||rg(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(ag,"$1")),i=t.toLowerCase(),t=i in e||t=="onFocusOut"||t=="onFocusIn"?i.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?o?r.u=o.u:(r.u=pu,e.addEventListener(t,s?au:iu,s)):e.removeEventListener(t,s?au:iu,s);else{if(n=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&r==1?"":r))}}function og(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=pu++;else if(t.t<r.u)return;return r(re.event?re.event(t):t)}}}function mu(e,t,r,o,n,s,i,a,c,l){var u,p,f,m,h,g,y,x,w,k,b,T,v,A,F,D,N,_=t.type;if(t.constructor!=null)return null;128&r.__u&&(c=!!(32&r.__u),s=[a=t.__e=r.__e]),(u=re.__b)&&u(t);e:if(typeof _=="function")try{if(x=t.props,w="prototype"in _&&_.prototype.render,k=(u=_.contextType)&&o[u.__c],b=u?k?k.props.value:u.__:o,r.__c?y=(p=t.__c=r.__c).__=p.__E:(w?t.__c=p=new _(x,b):(t.__c=p=new br(x,b),p.constructor=_,p.render=G_),k&&k.sub(p),p.props=x,p.state||(p.state={}),p.context=b,p.__n=o,f=p.__d=!0,p.__h=[],p._sb=[]),w&&p.__s==null&&(p.__s=p.state),w&&_.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=Vr({},p.__s)),Vr(p.__s,_.getDerivedStateFromProps(x,p.__s))),m=p.props,h=p.state,p.__v=t,f)w&&_.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),w&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(w&&_.getDerivedStateFromProps==null&&x!==m&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(x,b),!p.__e&&p.shouldComponentUpdate!=null&&p.shouldComponentUpdate(x,p.__s,b)===!1||t.__v==r.__v){for(t.__v!=r.__v&&(p.props=x,p.state=p.__s,p.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(P){P&&(P.__=t)}),T=0;T<p._sb.length;T++)p.__h.push(p._sb[T]);p._sb=[],p.__h.length&&i.push(p);break e}p.componentWillUpdate!=null&&p.componentWillUpdate(x,p.__s,b),w&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(m,h,g)})}if(p.context=b,p.props=x,p.__P=e,p.__e=!1,v=re.__r,A=0,w){for(p.state=p.__s,p.__d=!1,v&&v(t),u=p.render(p.props,p.state,p.context),F=0;F<p._sb.length;F++)p.__h.push(p._sb[F]);p._sb=[]}else do p.__d=!1,v&&v(t),u=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++A<25);p.state=p.__s,p.getChildContext!=null&&(o=Vr(Vr({},o),p.getChildContext())),w&&!f&&p.getSnapshotBeforeUpdate!=null&&(g=p.getSnapshotBeforeUpdate(m,h)),D=u,u!=null&&u.type===ee&&u.key==null&&(D=dg(u.props.children)),a=ug(e,Ws(D)?D:[D],t,r,o,n,s,i,a,c,l),p.base=t.__e,t.__u&=-161,p.__h.length&&i.push(p),y&&(p.__E=p.__=null)}catch(P){if(t.__v=null,c||s!=null)if(P.then){for(t.__u|=c?160:128;a&&a.nodeType==8&&a.nextSibling;)a=a.nextSibling;s[s.indexOf(a)]=null,t.__e=a}else{for(N=s.length;N--;)uu(s[N]);lu(t)}else t.__e=r.__e,t.__k=r.__k,P.then||lu(t);re.__e(P,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=q_(r.__e,t,r,o,n,s,i,c,l);return(u=re.diffed)&&u(t),128&t.__u?void 0:a}function lu(e){e&&e.__c&&(e.__c.__e=!0),e&&e.__k&&e.__k.forEach(lu)}function fg(e,t,r){for(var o=0;o<r.length;o++)fu(r[o],r[++o],r[++o]);re.__c&&re.__c(t,e),e.some(function(n){try{e=n.__h,n.__h=[],e.some(function(s){s.call(n)})}catch(s){re.__e(s,n.__v)}})}function dg(e){return typeof e!="object"||e==null||e.__b&&e.__b>0?e:Ws(e)?e.map(dg):Vr({},e)}function q_(e,t,r,o,n,s,i,a,c){var l,u,p,f,m,h,g,y=r.props,x=t.props,w=t.type;if(w=="svg"?n="http://www.w3.org/2000/svg":w=="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((m=s[l])&&"setAttribute"in m==!!w&&(w?m.localName==w:m.nodeType==3)){e=m,s[l]=null;break}}if(e==null){if(w==null)return document.createTextNode(x);e=document.createElementNS(n,w,x.is&&x),a&&(re.__m&&re.__m(t,s),a=!1),s=null}if(w==null)y===x||a&&e.data==x||(e.data=x);else{if(s=s&&Pa.call(e.childNodes),y=r.props||Hs,!a&&s!=null)for(y={},l=0;l<e.attributes.length;l++)y[(m=e.attributes[l]).name]=m.value;for(l in y)if(m=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")p=m;else if(!(l in x)){if(l=="value"&&"defaultValue"in x||l=="checked"&&"defaultChecked"in x)continue;va(e,l,null,m,n)}}for(l in x)m=x[l],l=="children"?f=m:l=="dangerouslySetInnerHTML"?u=m:l=="value"?h=m:l=="checked"?g=m:a&&typeof m!="function"||y[l]===m||va(e,l,m,y[l],n);if(u)a||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=""),ug(t.type=="template"?e.content:e,Ws(f)?f:[f],t,r,o,w=="foreignObject"?"http://www.w3.org/1999/xhtml":n,s,i,s?s[0]:r.__k&&Wn(r,0),a,c),s!=null)for(l=s.length;l--;)uu(s[l]);a||(l="value",w=="progress"&&h==null?e.removeAttribute("value"):h!=null&&(h!==e[l]||w=="progress"&&!h||w=="option"&&h!=y[l])&&va(e,l,h,y[l],n),l="checked",g!=null&&g!=e[l]&&va(e,l,g,y[l],n))}return e}function fu(e,t,r){try{if(typeof e=="function"){var o=typeof e.__u=="function";o&&e.__u(),o&&t==null||(e.__u=e(t))}else e.current=t}catch(n){re.__e(n,r)}}function hg(e,t,r){var o,n;if(re.unmount&&re.unmount(e),(o=e.ref)&&(o.current&&o.current!=e.__e||fu(o,null,t)),(o=e.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){re.__e(s,t)}o.base=o.__P=null}if(o=e.__k)for(n=0;n<o.length;n++)o[n]&&hg(o[n],t,r||typeof e.type!="function");r||uu(e.__e),e.__c=e.__=e.__e=void 0}function G_(e,t,r){return this.constructor(e,r)}function vt(e,t,r){var o,n,s,i;t==document&&(t=document.documentElement),re.__&&re.__(e,t),n=(o=typeof r=="function")?null:r&&r.__k||t.__k,s=[],i=[],mu(t,e=(!o&&r||t).__k=Kr(ee,null,[e]),n||Hs,Hs,t.namespaceURI,!o&&r?[r]:n?null:t.firstChild?Pa.call(t.childNodes):null,s,!o&&r?r:n?n.__e:t.firstChild,o,i),fg(s,e,i)}function qs(e){function t(r){var o,n;return this.getChildContext||(o=new Set,(n={})[t.__c]=this,this.getChildContext=function(){return n},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(i){i.__e=!0,cu(i)})},this.sub=function(s){o.add(s);var i=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),i&&i.call(s)}}),r.children}return t.__c="__cC"+cg++,t.__=e,t.Provider=t.__l=(t.Consumer=function(r,o){return r.children(o)}).contextType=t,t}Pa=lg.slice,re={__e:function(e,t,r,o){for(var n,s,i;t=t.__;)if((n=t.__c)&&!n.__)try{if((s=n.constructor)&&s.getDerivedStateFromError!=null&&(n.setState(s.getDerivedStateFromError(e)),i=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(e,o||{}),i=n.__d),i)return n.__E=n}catch(a){e=a}throw e}},ng=0,j_=function(e){return e!=null&&e.constructor==null},br.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Vr({},this.state),typeof e=="function"&&(e=e(Vr({},r),this.props)),e&&Vr(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),cu(this))},br.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),cu(this))},br.prototype.render=ee,Wo=[],sg=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,ig=function(e,t){return e.__v.__b-t.__v.__b},_a.__r=0,ag=/(PointerCapture)$|Capture$/i,pu=0,iu=og(!1),au=og(!0),cg=0;var qo,Me,du,gg,Gs=0,vg=[],Je=re,yg=Je.__b,xg=Je.__r,bg=Je.diffed,Eg=Je.__c,wg=Je.unmount,Rg=Je.__;function zs(e,t){Je.__h&&Je.__h(Me,e,Gs||t),Gs=0;var r=Me.__H||(Me.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function Q(e){return Gs=1,Eo(Tg,e)}function Eo(e,t,r){var o=zs(qo++,2);if(o.t=e,!o.__c&&(o.__=[r?r(t):Tg(void 0,t),function(a){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,a);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=Me,!Me.__f)){var n=function(a,c,l){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!s||s.call(this,a,c,l);var p=o.__c.props!==a;return u.forEach(function(f){if(f.__N){var m=f.__[0];f.__=f.__N,f.__N=void 0,m!==f.__[0]&&(p=!0)}}),s&&s.call(this,a,c,l)||p};Me.__f=!0;var s=Me.shouldComponentUpdate,i=Me.componentWillUpdate;Me.componentWillUpdate=function(a,c,l){if(this.__e){var u=s;s=void 0,n(a,c,l),s=u}i&&i.call(this,a,c,l)},Me.shouldComponentUpdate=n}return o.__N||o.__}function te(e,t){var r=zs(qo++,3);!Je.__s&&gu(r.__H,t)&&(r.__=e,r.u=t,Me.__H.__h.push(r))}function Sa(e,t){var r=zs(qo++,4);!Je.__s&&gu(r.__H,t)&&(r.__=e,r.u=t,Me.__h.push(r))}function dt(e){return Gs=5,H(function(){return{current:e}},[])}function H(e,t){var r=zs(qo++,7);return gu(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function U(e,t){return Gs=8,H(function(){return e},t)}function Yr(e){var t=Me.context[e.__c],r=zs(qo++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(Me)),t.props.value):e.__}function z_(){for(var e;e=vg.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Oa),e.__H.__h.forEach(hu),e.__H.__h=[]}catch(t){e.__H.__h=[],Je.__e(t,e.__v)}}Je.__b=function(e){Me=null,yg&&yg(e)},Je.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Rg&&Rg(e,t)},Je.__r=function(e){xg&&xg(e),qo=0;var t=(Me=e.__c).__H;t&&(du===Me?(t.__h=[],Me.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(t.__h.forEach(Oa),t.__h.forEach(hu),t.__h=[],qo=0)),du=Me},Je.diffed=function(e){bg&&bg(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(vg.push(t)!==1&&gg===Je.requestAnimationFrame||((gg=Je.requestAnimationFrame)||V_)(z_)),t.__H.__.forEach(function(r){r.u&&(r.__H=r.u),r.u=void 0})),du=Me=null},Je.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Oa),r.__h=r.__h.filter(function(o){return!o.__||hu(o)})}catch(o){t.some(function(n){n.__h&&(n.__h=[])}),t=[],Je.__e(o,r.__v)}}),Eg&&Eg(e,t)},Je.unmount=function(e){wg&&wg(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(o){try{Oa(o)}catch(n){t=n}}),r.__H=void 0,t&&Je.__e(t,r.__v))};var kg=typeof requestAnimationFrame=="function";function V_(e){var t,r=function(){clearTimeout(o),kg&&cancelAnimationFrame(t),setTimeout(e)},o=setTimeout(r,35);kg&&(t=requestAnimationFrame(r))}function Oa(e){var t=Me,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),Me=t}function hu(e){var t=Me;e.__c=e.__(),Me=t}function gu(e,t){return!e||e.length!==t.length||t.some(function(r,o){return r!==e[o]})}function Tg(e,t){return typeof t=="function"?t(e):t}function Qe(e){return typeof e=="number"}var K_=(e,t,r)=>{let o=t.name||"anonymous predicate",n=typeof e,s=JSON.stringify(e,null,2);returnExpected ${r??"a value"} that satisfies the predicate ${o}, got ${n}: ${s}},Y_=K_,yu=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name=this.constructor.name}};function _g(e,t,r={}){if(!t(e))throw new yu(r.message??Y_(e,t,r.name))}function xu(e,t,r={}){return _g(e,t,r),e}function qt(e){return typeof e>"u"}var La=!1,Pg=null,Og=()=>{scrapbox.addListener("lines:changed",()=>La=!1),scrapbox.addListener("layout:changed",()=>La=!1),Og=void 0},Sg=()=>(Og?.(),La||(Pg=scrapbox.Page.lines,La=!0),Pg);var Lg=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Ng=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Mg=()=>Na(document.getElementById("editor"),"div#editor"),Vs=()=>Na(document.getElementsByClassName("lines").item(0),"div.lines");var ht=()=>{let e=document.getElementById("text-input");if(e)return Ng(e,"textarea#text-input"),e};var Cg=()=>Na(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Ig=()=>Na(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),Na=(e,t)=>{if(e)return Lg(e,t),e};var At=()=>{let e=Vs();if(!e)throw Error("div.lines is not found.");let 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 e[t].return.stateNode.props.lines};var Zt=e=>e.match(/^(\s*)/)?.[1]?.length??0,Go=(e,t)=>{let r=Zt(Ag(e,t)),o=0;for(;e+o+1<t.length&&Zt(Ag(e+o+1,t))>r;)o++;return o},Ag=(e,t)=>{let r=t[e];return ve(r)?r:r.text};var bu=e=>{if(qt(e))return;if(Qe(e))return Ma(e)?.id;if(ve(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)},Fg=e=>{if(qt(e))return;if(Qe(e))return e;let t=bu(e);return t?At().findIndex(r=>r.id===t):-1};var Ma=e=>{if(qt(e))return;if(Qe(e))return At()[e];let t=bu(e);return t?At().find(r=>r.id===t):void 0},Xr=e=>{if(Dg(e))return e;let t=bu(e);if(qt(t))return t;let r=document.getElementById(L${t});if(!qt(r))return r},Dg=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var Lr=()=>xu(Sg(),xr),gt=e=>{if(qt(e))return;if(Qe(e)||ve(e))return Ma(e)?.text;if(!(e instanceof HTMLElement))return;if(Dg(e))return Ma(e)?.text;if(e.classList.contains("char-index"))return e.textContent??void 0;if(e.classList.contains("line")||e.getElementsByClassName("lines")?.[0])return At().map(({text:o})=>o).join(
);let t=[],r=Ma(e);if(!qt(r)){for(let o of J_(e))t.push(Q_(o));return r.text.slice(Math.min(...t),Math.max(...t)+1)}};var Ug=()=>{let e=Vs()?.firstElementChild;if(!qt(e))return e},$g=()=>{let e=Vs()?.lastElementChild;if(!qt(e))return e};var Eu=e=>{let t=Fg(e);if(!qt(t))return Go(t,Lr())};function*J_(e){let t=e.getElementsByClassName("char-index");for(let r=0;r<t.length;r++)yield t[0]}var wu=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index"),Q_=e=>{if(!wu(e))throw Error("A char DOM is required.");let t=e.className.match(/c-(\d+)/)?.[1];if(qt(t))throw Error('.char-index must have ".c-{\\d}"');return parseInt(t)},jg=e=>{let t=e?.getElementsByClassName?.("c-0")?.[0];return wu(t)?t:void 0};var Ks=(e,t)=>{let r=Xr(e)?.getElementsByClassName?.(c-${t})?.[0];return wu(r)?r:void 0};var Tt=(e,t)=>{let{noModifiedKeys:r=!1,...o}=t??{},n={bubbles:!0,cancelable:!0,keyCode:Z_[e],...r?{}:{...o}},s=ht();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",n)),s.dispatchEvent(new KeyboardEvent("keyup",n))},Z_={Backspace:8,Tab:9,Enter:13,Delete:46,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,a:65,A:65,b:66,B:66,c:67,C:67,d:68,D:68,e:69,E:69,f:70,F:70,g:71,G:71,h:72,H:72,i:73,I:73,j:74,J:74,k:75,K:75,l:76,L:76,m:77,M:77,n:78,N:78,o:79,O:79,p:80,P:80,q:81,Q:81,r:82,R:82,s:83,S:83,t:84,T:84,u:85,U:85,v:86,V:86,w:87,W:87,x:88,X:88,y:89,Y:89,z:90,Z:90,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,F1:113,F2:114,F3:115,F4:116,F5:117,F6:118,F7:119,F8:120,F9:121,F10:122,F11:123,F12:124,":":186,"*":186,";":187,"+":187,"-":189,"=":189,".":190,">":190,"/":191,"?":191,"@":192,"":192,"":219,"{":219,"\\":220,"|":220,"":221,"}":221,"^":222,"~":222,_:226};var Ru=async(e,t)=>{let r={button:t.button??0,clientX:t.X,clientY:t.Y,bubbles:!0,cancelable:!0,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,view:window};e.dispatchEvent(new MouseEvent("mousedown",r)),e.dispatchEvent(new MouseEvent("mouseup",r)),e.dispatchEvent(new MouseEvent("click",r)),await Fe(10)};var He=()=>{let e=ht();if(!e)throw Error("#text-input is not found.");let t=Object.keys(e).find(r=>r.startsWith("__reactFiber"));if(!t)throw Error('div.cursor must has the property whose name starts with "__reactFiber"');return et.return.return.stateNode.props};var ku=e=>{let{top:t,bottom:r}=e.getBoundingClientRect();return t>=0&&r<=globalThis.innerHeight};function Ft(e,t,r){if(r??=e>t?-1:1,!Number.isFinite(e))throw new RangeError(start must be finite, but got ${e}.);if(!Number.isFinite(r))throw new RangeError(step must be finite, but got ${r}.);if(r===0)throw new RangeError("step must not be 0.");if(!Number.isFinite(t))throw new RangeError(stop must be finite, but got ${t}.);if(r>0&&e>t)throw new RangeError("start must be less than stop for positive step.");if(r<0&&e<t)throw new RangeError("start must be greater than stop for negative step.");return function*(){if(r>=0)for(let o=e;o<=t;o+=r)yield o;else for(let o=e;o>=t;o+=r)yield o}()}var Bg=()=>{Tt("Home"),Tt("Home")};var Hg=async()=>{let e=Ug();if(!e)throw Error(".line:first-of-type can't be found.");ku(e)||e.scrollIntoView({block:"center"});let t=jg(e);if(!t)throw Error(".line:first-of-type .c-0 can't be found.");let{left:r,top:o}=t.getBoundingClientRect();await Ru(e,{X:r,Y:o})},Wg=async()=>{await Gg($g())},qg=async e=>{await Gg(Xr(e))},Gg=async e=>{if(!e)throw Error("The target line DOM is failed to find.");ku(e)||e.scrollIntoView({block:"center"});let{right:t,top:r,height:o}=e.getElementsByClassName("text")0.getBoundingClientRect();await Ru(e,{X:t+1,Y:r+o/2})};var zg=(e=1)=>{for(let t of Ft(1,e))Tt("z",{ctrlKey:!0})},Vg=(e=1)=>{for(let t of Ft(1,e))Tt("z",{shiftKey:!0,ctrlKey:!0})};var Ca=async(e,t,r)=>{await qg(e),Bg();for(let o of Ft(e,t))Tt("ArrowDown",{shiftKey:!0});Tt("End",{shiftKey:!0}),await ct(r)};var Ia=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowRight",{ctrlKey:!0})},Aa=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowLeft",{ctrlKey:!0})};var Fa=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowUp",{ctrlKey:!0})},Da=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowDown",{ctrlKey:!0})},Ua=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowRight",{altKey:!0})},$a=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowLeft",{altKey:!0})};var ja=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowUp",{altKey:!0})},Ba=(e=1)=>{for(let t of Ft(1,e))Tt("ArrowDown",{altKey:!0})},ct=e=>{let t=ht();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});return t.dispatchEvent(r),scrapbox.Page.waitForSave()};var De=()=>{let e=Ig();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=Kg(...r);o&&t.append(o)},dispose:()=>t.remove(),Symbol.dispose:()=>t.remove()}},Kg=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":returntP();case"check-circle":returnrP();case"exclamation-triangle":returnoP();case"text":returnHa(o.text);case"group":{let n=Kg(...o.items);return n?n:[]}}});if(t.length===0)return;if(t.length===1)return t0;let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},Ha=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},tP=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),Ha(e)},rP=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),Ha(e)},oP=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),Ha(e)};var qn=e=>{let t=JSON.parse(localStorage.getItem("pageTransitionContext")??""),r=e.type==="page"?e.from.project===e.to.project?e.from.title===e.to.title?{titleHint:e.to.title}:{linkFrom:e.from.title}:{linkFrom:/${e.from.project}/${e.from.title}}:{searchQuery:e.query};t[page_${ae(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var nP=(e,t,r)=>{let o=new URL(/${e}/${ne(t)},location.href);if(r?.body&&(o.search=?body=${encodeURIComponent(r.body)}),r?.id&&(o.hash=#${r.id}),r?.context&&qn({...r?.context,to:{project:e,title:t}}),r?.newTab!==!1&&(r?.newTab===!0||e!==scrapbox.Project.name)){globalThis.open(o);return}if(r?.reload!==!1&&(r?.reload===!0||e!==scrapbox.Project.name)){globalThis.open(o,"_self");return}let n=document.createElement("a");n.href=o.toString(),document.body.append(n),n.click(),n.remove()},vu=(e,t,r)=>nP(e,t,{newTab:!1,reload:!1,body:r});var wo=async(e,t)=>{let r=await globalThis.caches.keys();for(let o of r.sort().reverse()){let s=await(await caches.open(o)).match(e,t);if(s)return s}},Wa=async(e,t)=>{let r=t.clone();return await(await caches.open(sP(new Date))).put(e,r)},sP=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var Bt=()=>{let e=ht();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 r=et.return.return.stateNode._stores,o=r.find(s=>s.constructor.name==="Cursor");if(!o)throw Error('#text-input must has a "Cursor" store.');let n=r.find(s=>s.constructor.name==="Selection");if(!n)throw Error('#text-input must has a "Selection" store.');return{cursor:o,selection:n}};var Ro=()=>Bt().cursor;var qa=()=>Bt().selection;var Ys=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),Yg=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 Ga=new Map,Tu=new Map,_u=()=>{scrapbox.on("layout:changed",()=>{let e=ht();if(e)for(lett,rof Ga)for(leto,nof r)for(let s of n)e.addEventListener(t,o,Yg(s))}),_u=void 0},Xg=(e,t,r)=>{_u?.();let o=Ga.get(e)??new Map,n=o.get(t)??new Set;if(n.has(Ys(r)))return;if(n.add(Ys(r)),o.set(t,n),Ga.set(e,o),typeof r=="object"&&r?.once){let i=Tu.get(t)??new Map,a=Ys(r),c=function(u){return Pu(e,t,r),i.delete(a),t.call(this,u)};i.set(a,c),Tu.set(t,i);let l=ht();if(!l)return;l.addEventListener(e,c,r)}let s=ht();s&&s.addEventListener(e,t,r)},Pu=(e,t,r)=>{_u?.();let o=Ga.get(e);if(!o)return;let n=o.get(t);if(!n)return;let s=Ys(r);if(n.delete(s),typeof r=="object"&&r?.once){let a=Tu.get(t);if(!a)return;let c=a.get(s);if(!c)return;let l=ht();if(!l)return;l.removeEventListener(e,c,r),a.delete(s);return}let i=ht();i&&i.removeEventListener(e,t,r)};var Jg={"&":"\\x26","!":"\\x21","#":"\\x23",$:"\\$","%":"\\x25","*":"\\*","+":"\\+",",":"\\x2c",".":"\\.",":":"\\x3a",";":"\\x3b","<":"\\x3c","=":"\\x3d",">":"\\x3e","?":"\\?","@":"\\x40","^":"\\^","":"\\x60","~":"\\x7e","(":"\\(",")":"\\)","[":"\\[","]":"\\]","{":"\\{","}":"\\}","/":"\\/","-":"\\x2d","\\":"\\\\","|":"\\|"},iP=new RegExp(${Object.values(Jg).join("")},"gu");function Qg(e){return e.replaceAll(iP,t=>Jg[t]).replace(/^[0-9a-zA-Z]/,t=>\\x${t.codePointAt(0).toString(16)})}var aP=0,CK=Array.isArray;function d(e,t,r,o,n,s){t||(t={});var i,a,c=t;if("ref"in c)for(a in c={},t)a=="ref"?i=t[a]:c[a]=t[a];var l={type:e,props:c,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--aP,__i:-1,__u:0,__source:n,__self:s};if(typeof e=="function"&&(i=e.defaultProps))for(a in i)c[a]===void 0&&(c[a]=i[a]);return re.vnode&&re.vnode(l),l}var Zg=({project:e,title:t,words:r,lines:o,query:n,close:s})=>{let i=U(c=>{qn({type:"search",query:n,to:{project:e,title:t}}),!(c.metaKey||c.ctrlKey||c.altKey||c.shiftKey)&&s()},[e,t,n,s]),a=H(()=>{let c=new RegExp((${r.map(l=>Qg(l)).join("|")}),"i");return o.flatMap(l=>{let u=l.split(c);return d("span",{children:u.map((p,f)=>f%2===0?p:d("strong",{children:p}))})})},[o,r]);return d("a",{href:/${e}/${ne(t)},target:${e===scrapbox.Project.name?"":"_blank"},rel:${e===scrapbox.Project.name?"route":"noopener noreferrer"},onClick:i,children:[t,d("div",{className:"description",children:a})]})};var ey=e=>{let[t,r]=Q(e),o=U(()=>r(!0),[]),n=U(()=>r(!1),[]),s=U(()=>r(i=>!i),[]);return[t,{open:o,close:n,toggle:s}]};var ty=(e,t)=>{let[r,o]=Q(),[n,s]=Q(!1),i=dt(Promise.resolve());return te(()=>{if(t===""){o(void 0);return}let a=!1;return i.current=(async()=>{if(await i.current,!a){s(!0);try{let c=await jh(t,e);if(a)return;o(K(c)?S(c):void 0)}finally{s(!1)}}})(),()=>a=!0},[t,e]),{loading:n,result:r}};var ry=()=>d("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;
gap: 0.2em;
flex-direction: column;
}
input {
border-radius: 5px;
padding: 0 10px;
height: 32px;
border: transparent;
box-shadow: none;
color: var(--search-form-text-color, rgba(255, 255, 255, 0.35));
background-color: var(--search-form-bg, rgba(255, 255, 255, 0.15))
}
.result {
flex-direction: column;
width: 100%;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
font-weight: normal;
line-height: 28px;
text-align: left;
border: 1px solid rgba(0,0,0,0.15);
border-radius: 4px;
background-clip: padding-box;
white-space: nowrap;
overflow-x: hidden;
overflow-y: auto;
}
a {
display: block;
padding: 3px 20px;
clear: both;
align-items: center;
user-select: none;
text-decoration: none;
overflow: hidden;
text-overflow: ellipsis;
color: inherit;
}
.description {
margin-top: 0.5em;
color: var(--incremental-fulltext-search-description-text-color, #c4c4c4);
font-size: 12px;
line-height: 14px;
max-height: 28px;
overflow: hidden;
text-overflow: ellipsis;
}
.description strong {
background-color: #ff0;
color: #666;
}
.spinner::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
line-height: 1;
content: "\f110";
font-family: "Font Awesome 5 Free";
font-weight: 900;
margin: 0;
padding: 0;
box-sizing: border-box;
animation: fa-spin 2s linear infinite;
}});var cP=()=>d("i",{className:"spinner"}),oy=({exportOps:e})=>{let[t,r]=Q(""),o=scrapbox.Project.name,{loading:n,result:s}=ty(o,t),i=U(m=>{r(m.currentTarget.value)},[]),[a,{open:c,close:l,toggle:u}]=ey(!1),p=dt({open:c,close:l,toggle:u});te(()=>{Object.assign(p.current,{open:c,close:l,toggle:u})},[]),te(()=>e(p.current),[e]);let f=U(m=>{m.target instanceof HTMLElement&&m.target.id==="background"&&l()},[]);return d(ee,{children:[d(ry,{}),d("div",{id:"background",className:modal${a?"":" closed"},onClick:f,children:[d("div",{className:"controller",children:[d("input",{type:"text",value:t,onInput:i}),d("div",{className:"info",children:[n&&d(cP,{}),${s?.pages?.length??0} pages]})]}),s?.pages&&s.pages.length>0&&d("ul",{className:"result",children:s.pages.map(m=>d("li",{children:d(Zg,{...m,project:o,query:t,close:l})},m.title))})]})]})};var ny=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});return document.body.append(e),new Promise(r=>{vt(d(oy,{exportOps:r}),t)})};var za=(e,t)=>Object.hasOwn(e,t),sy={left:"ArrowLeft",right:"ArrowRight",up:"ArrowUp",down:"ArrowDown",bs:"Backspace",menu:"ContextMenu",apps:"ContextMenu",del:"Delete",return:"Enter",cr:"Enter",esc:"Escape",pgup:"PageUp",pgdn:"PageDown",lt:"<",less:"<",lesser:"<",gt:">",greater:">"},ly=e=>{let t=e.toLowerCase();return za(sy,t)?sy[t]:e},iy={Backquote:["","~"],Digit1:"1","!",Digit2:"2","@",Digit3:"3","#",Digit4:"4","$",Digit5:"5","%",Digit6:"6","^",Digit7:"7","&",Digit8:"8","*",Digit9:"9","(",Digit0:"0",")",Minus:"-","_",Equal:"=","+",Backslash:"\\","|",BracketLeft:["","{",BracketRight:"","}"],Semicolon:";",":",Quote:"'",'"',Comma:",","<",Period:".",">",Slash:"/","?"},lP=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return za(iy,e)?iyet?1:0:e},ay={"<":"lt",">":"gt"},pP=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,Ou=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=lP(e.code||"",t):(r=ly(r),r===" "&&(r="Space")),pP.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let o="";return e.altKey&&(o+="a-"),e.ctrlKey&&(o+="c-"),e.metaKey&&(o+="m-"),t&&(o+="s-"),za(ay,r)&&(r=ayr),o||r.length>1?<${o}${r}>:r},cy={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},uP=e=>{if(e.length===1)return/\s/.test(e)?{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}}:{ok:!0,value:{key:e}};let t=e.match(/^<((?:a-z-)*)(a-z\d+|^<>\s)>$/i);if(!t)return{ok:!1,value:{name:"InvalidKeyError",key:e,message:Invalid key: ${e}}};let,r,o=t,n={key:ly(o)};for(let s of r.split("-").slice(0,-1)){let i=s.toLowerCase();if(!za(cy,i))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let a=cyi;if(na!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(na=!0,n.key.length===1&&n.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:n}},py=e=>{let t=uP(e);return t.ok?{ok:!0,value:Ou(t.value)}:t},uy=e=>e.match(/<^<>\s+>|\s\S|^$/g);var cr=!1;var my=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,r;switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{cr!==!0&&(!cr||!cr.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{cr!==!0&&(!cr||!cr.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{cr!==!0&&(!cr||!cr.has(e))||r(${e} ${o})}];default:returnt,(...o)=>{if(!(cr!==!0&&(!cr||!cr.has(e))))return r(...o)}}}));var zo=my("ScrapBindings:mod.ts"),Va=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let o=new Map,n=[];for(lets,iof t instanceof Map?t.entries():typeof t=="string"?t,r:Object.entries(t)){let a=fy(s);if(!a.ok){for(let l of a.value)zo.error(${s}: ${l.message});o.set(s,a.value);continue}let c=a.value;this.bindings.set(c,i),c.startsWith(this.currentSequence)&&this.filtered.add(c),n.push(c)}return zo.debug("Binded the following commands:",n),this.emitChange(),o}unbind(...t){for(let r of t){let o=fy(r);if(!o.ok)continue;let n=o.value;this.bindings.delete(n),this.filtered.delete(n)}this.emitChange()}reset(){this.bindings.clear(),this.emitChange()}bindings=new Map;onSequenceUpdate;flushInterval;_sequence="";set currentSequence(t){let r=this._sequence!==t;this._sequence=t,r&&this.onSequenceUpdate?.(t)}get currentSequence(){return this._sequence}prevBestMatchCommand;filtered=new Set;timer;backToInitial=()=>{clearTimeout(this.timer),this.currentSequence="",this.prevBestMatchCommand=void 0,this.filtered=new Set(this.bindings.keys()),zo.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=Ou(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,zo.debug("sequence",this.currentSequence);let o;for(let s of this.filtered){if(s.startsWith(this.currentSequence)||this.filtered.delete(s),this.currentSequence!==s)continue;let i=this.bindings.get(s);if(!i){this.filtered.delete(s);continue}o=()=>{zo.debug(run ${s});try{i(t)}catch(a){zo.error(a)}finally{this.backToInitial()}}}let n=this.filtered.size;if(zo.debug(${n} candidates: ${[...this.filtered.keys()].join(", ")}),n>0&&(this.prevBestMatchCommand=o),this.prevBestMatchCommand&&n<2){if(this.prevBestMatchCommand(),n===0){this.handleKeydown(t);return}return}if(n===0){this.backToInitial();return}t.preventDefault(),t.stopPropagation(),this.timer=setTimeout(this.prevBestMatchCommand??this.backToInitial,this.flushInterval)};emitChange=()=>{if(this.bindings.size===0){this.backToInitial(),this.target.removeEventListener("keydown",this.handleKeydown);return}this.target.addEventListener("keydown",this.handleKeydown)}},mP={name:"InvalidSequenceError",message:"cannot parse the sequence"},fy=e=>{let t=uy(e);if(!t)return{ok:!1,value:mP};let r="",o=[];for(let n of t){let s=py(n);if(!s.ok){o.push(s.value);continue}r+=s.value}return o.length>0?{ok:!1,value:o}:{ok:!0,value:r}};var dy=()=>{if(scrapbox.Layout!=="page")return{selectionRange:{start:{line:0,char:0},end:{line:0,char:0}},selectedText:""};let{selectionRange:e,selectedText:t,position:r}=He();if(!t){let u=Eu(r.line)??0,p={start:{line:r.line,char:0},end:{line:r.line+u,char:gt(r.line+u)?.length??0}};return{selectionRange:p,selectedText:scrapbox.Page.lines.slice(p.start.line,p.end.line+1).map(f=>f.text).join(`
)}}let{start:o,end:n}=e,s=o.line>n.line,i=s?n.line:o.line,a=s?n.char:o.char,c=s?o.line:n.line,l=s?o.char:n.char;return{selectedText:t,selectionRange:{start:{line:i,char:a},end:{line:c,char:l}}}};var Su=(e,{title:t,projectTo:r,mode:o})=>{let[n,...s]=e.split(
),i=n.replaceAll("[","").replaceAll("]","").trim(),a=Math.min(...[n,...s].map(l=>Zt(l))),c=[from ${t},n.slice(a),...s.map(l=>l.slice(a))];return{text:${i},pages:[{project:r,title:i,lines:c,mode:o}]}};Su.hookName="default-hook";var Jr=e=>{let{project:t=scrapbox.Project.name,mode:r="newtab"}=e??{},o=[...e?.hooks??[],Su],{selectionRange:{start:n,end:s},selectedText:i}=dy();if(!i||scrapbox.Layout!=="page")return;let a=(()=>{for(let p of o){let f=p(i,{title:scrapbox.Page.title,projectFrom:scrapbox.Project.name,projectTo:t,lines:At().slice(n.line,s.line+1),mode:r});if(f)return[p.hookName,f]}})();if(!a)return;let[c,l]=a,u=async()=>{let p=l instanceof Promise?await l:l;if(p.pages.length===0&&p.text===i)return;let f,{render:m,dispose:h}=De();try{if(p.pages.length>0){let y=p.pages.length;m({type:"spinner"},{type:"text",text:Create new ${y} pages...});let x=await Mt(e?.socket);if(O(x))throw Z(x);f=S(x);let w=0;await Promise.all(p.pages.map(async k=>{let b=Array.isArray(k.lines)?T=>[...T.map(v=>v.text),...k.lines]:k.lines;await Le(k.project,k.title,b,{socket:f}),m({type:"spinner"},{type:"text",text:Create ${y-++w} pages...})}))}m({type:"spinner"},{type:"text",text:${p.pages.length>0?"Created. ":""}Removing cut text...});let g=p.text;if(i===g)return;await Le(scrapbox.Project.name,scrapbox.Page.title,y=>{let x=y.map(w=>w.text);return[...x.slice(0,n.line),...${xn.line.slice(0,n.char)}${g}${x.slice(s.line).join(`
).slice(s.char)}.split(`
)]}),m({type:"check-circle"},{type:"text",text:"Removed."});for(let y of p.pages)switch(y.mode){case"self":y.project===scrapbox.Project.name?vu(y.project,y.title):globalThis.open(https://scrapbox.io/${y.project}/${ne(y.title)},"_self");break;case"newtab":globalThis.open(https://scrapbox.io/${y.project}/${ne(y.title)});break}}catch(g){m({type:"exclamation-triangle"},{type:"text",text:"Failed to create new pages (see console)."}),console.error(g)}finally{let g=Fe(1e3);f&&await Ct(f),await g,h()}};return u.hookName=c,u};var fP=Math.pow(10,8)*24*60*60*1e3,p5=-fP,Vo=6048e5,Lu=864e5,Nr=6e4,ko=36e5,Ka=1e3;var Ya=3600;var Nu=Ya*24,dP=Nu*7,hy=Nu*365.2425,gy=hy/12,hP=gy*3,Mu=Symbol.for("constructDateFrom");function C(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Mu in e?e[Mu](t):e instanceof Date?new e.constructor(t):new Date(t)}function E(e,t){return C(t||e,e)}var gP={};function Er(){return gP}function Ne(e,t){let r=Er(),o=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,n=E(e,t?.in),s=n.getDay(),i=(s<o?7:0)+s-o;return n.setDate(n.getDate()-i),n.setHours(0,0,0,0),n}function wr(e,t){let r=E(e,t?.in);return r.setHours(0,0,0,0),r}function lt(e,...t){let r=C.bind(null,e||t.find(o=>typeof o=="object"));return t.map(r)}function vo(e,t){let[r,o]=lt(e,t.start,t.end);return{start:r,end:o}}function Xs(e,t){let{start:r,end:o}=vo(t?.in,e),n=+r>+o,s=n?+r:+o,i=n?o:r;i.setHours(0,0,0,0);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,n=!n);let c=[];for(;+i<=s;)c.push(C(r,i)),i.setDate(i.getDate()+a),i.setHours(0,0,0,0);return n?c.reverse():c}function yt(e,t,r){let[o,n]=lt(r?.in,e,t);return+wr(o)==+wr(n)}function Rr(e,t){let r=e<0?"-":"",o=Math.abs(e).toString().padStart(t,"0");return r+o}var Cu={y(e,t){let r=e.getFullYear(),o=r>0?r:1-r;return Rr(t==="yy"?o%100:o,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):Rr(r+1,2)},d(e,t){return Rr(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 r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return Rr(e.getHours()%12||12,t.length)},H(e,t){return Rr(e.getHours(),t.length)},m(e,t){return Rr(e.getMinutes(),t.length)},s(e,t){return Rr(e.getSeconds(),t.length)},S(e,t){let r=t.length,o=e.getMilliseconds(),n=Math.trunc(o*Math.pow(10,r-3));return Rr(n,t.length)}};function yy(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Gt(e){return!(!yy(e)&&typeof e!="number"||isNaN(+E(e)))}var yP=/(\w)\1*|''|'(''|[^'])+('|$)|./g,xP=/^'([^]*?)'?$/,bP=/''/g,EP=/[a-zA-Z]/;function pe(e,t){let r=E(e);if(!Gt(r))throw new RangeError("Invalid time value");let o=t.match(yP);return o?o.map(n=>{if(n==="''")return"'";let s=n[0];if(s==="'")return wP(n);let i=Cu[s];if(i)return i(r,n);if(s.match(EP))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return n}).join(""):""}function wP(e){let t=e.match(xP);return t?t[1].replace(bP,"'"):e}function Te(e,t,r){let o=E(e,r?.in);return isNaN(t)?C(r?.in||e,NaN):(t&&o.setDate(o.getDate()+t),o)}function zt(e,t,r){return Te(e,-t,r)}function Js(e,t,r){return C(r?.in||e,+E(e)+t)}function Qs(e,t,r){return Js(e,t*1e3,r)}function Ko(e,t,r){return Te(e,t*7,r)}function Zs(e,t){return E(e,t?.in).getDate()}function Yo(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=Er(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=C(t?.in||e,0);i.setFullYear(o+1,0,s),i.setHours(0,0,0,0);let a=Ne(i,t),c=C(t?.in||e,0);c.setFullYear(o,0,s),c.setHours(0,0,0,0);let l=Ne(c,t);return+r>=+a?o+1:+r>=+l?o:o-1}var RP={};function kP(){return RP}function Iu(e,t){let r=kP(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,n=Yo(e,t),s=C(t?.in||e,0);return s.setFullYear(n,0,o),s.setHours(0,0,0,0),Ne(s,t)}function To(e,t){let r=E(e,t?.in),o=+Ne(r,t)-+Iu(r,t);return Math.round(o/Vo)+1}function by(e,t){return E(e,t?.in).getMonth()}function Xo(e,t){return E(e,t?.in).getFullYear()}var Ey=e=>{let t=new Map;for(let r of e){let o=${Xo(r)}-${by(r)}-${Zs(r)},n=t.get(o);n&&n.getTime()>r.getTime()||t.set(o,r)}return[...t.values()]};function ei(e,t,r){let o=E(e,r?.in);if(isNaN(t))return C(r?.in||e,NaN);if(!t)return o;let n=o.getDate(),s=C(r?.in||e,o.getTime());s.setMonth(o.getMonth()+t+1,0);let i=s.getDate();return n>=i?s:(o.setFullYear(s.getFullYear(),s.getMonth(),n),o)}function Au(e,t,r){let{years:o=0,months:n=0,weeks:s=0,days:i=0,hours:a=0,minutes:c=0,seconds:l=0}=t,u=E(e,r?.in),p=n||o?ei(u,n+o*12):u,f=i||s?Te(p,i+s*7):p,m=c+a*60,h=(l+m*60)*1e3;return C(r?.in||e,+f+h)}function wy(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=r.getMonth(),s=C(r,0);return s.setFullYear(o,n+1,0),s.setHours(0,0,0,0),s.getDate()}function Fu(e,t,r){let o=E(e,r?.in),n=o.getFullYear(),s=o.getDate(),i=C(r?.in||e,0);i.setFullYear(n,t,15),i.setHours(0,0,0,0);let a=wy(i);return o.setMonth(t,Math.min(s,a)),o}function Ry(e,t,r){let o=E(e,r?.in);return isNaN(+o)?C(r?.in||e,NaN):(t.year!=null&&o.setFullYear(t.year),t.month!=null&&(o=Fu(o,t.month)),t.date!=null&&o.setDate(t.date),t.hours!=null&&o.setHours(t.hours),t.minutes!=null&&o.setMinutes(t.minutes),t.seconds!=null&&o.setSeconds(t.seconds),t.milliseconds!=null&&o.setMilliseconds(t.milliseconds),o)}function ky(e,t){return E(e,t?.in).getMinutes()}function Mr(e,t,r){let o=E(e,r?.in);return o.setTime(o.getTime()+t*Nr),o}function Jo(e){return t=>{let r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function Xa(e,t){return+E(e)-+E(t)}function _o(e,t,r){let o=Xa(e,t)/Nr;return Jo(r?.roundingMethod)(o)}function vy(e,t){return E(e,t?.in).getHours()}function Du(e,t,r){return Js(e,t*ko,r)}function Ja(e,t){let r=E(e,t?.in);return r.setHours(23,59,59,999),r}function Qr(e){let t=E(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function Zr(e,t,r){let[o,n]=lt(r?.in,e,t),s=wr(o),i=wr(n),a=+s-Qr(s),c=+i-Qr(i);return Math.round((a-c)/Lu)}function Ty(e,t,r){return Ko(e,-t,r)}function Qa(e,t,r){let o=E(e,r?.in),n=To(o,r)-t;return o.setDate(o.getDate()-n*7),E(o,r?.in)}function _y(e,t){let{start:r,end:o}=vo(t?.in,e),n=+r>+o,s=n?Ne(o,t):Ne(r,t),i=n?Ne(r,t):Ne(o,t);s.setHours(15),i.setHours(15);let a=+i.getTime(),c=s,l=t?.step??1;if(!l)return[];l<0&&(l=-l,n=!n);let u=[];for(;+c<=a;)c.setHours(0),u.push(C(r,c)),c=Ko(c,l),c.setHours(15);return n?u.reverse():u}function Za(e,t,r){let[o,n]=lt(r?.in,e,t),s=o.getFullYear()-n.getFullYear(),i=o.getMonth()-n.getMonth();return s*12+i}function Qo(e,t){let r=+E(e)-+E(t);return r<0?-1:r>0?1:r}function Zo(e,t){return+E(e)>+E(t)}var Py=e=>e==null,Po=e=>typeof e=="string";async function*Oy(e){let t=[],r,o=i=>{if(!r){t.push(i);return}r(i),r=void 0},n=()=>t.length>0?Promise.resolve(t.pop()):new Promise(i=>r=i),s=0;for(let i of e)i.then(a=>o({state:"fulfilled",value:a})).catch(a=>o({state:"rejected",reason:a})),s++;for(let i=0;i<s;i++)yield await n()}var xt=e=>{let t=e.match(/^(\d{4})-(\d{2})-(\d{2}) (?: {5}|(\d{2}):(\d{2})) (?: {4}|(\d{4})) (?: {8}|(\d{2}):(\d{2}):(\d{2})) (?: {8}|(\d{2}):(\d{2}):(\d{2}))([^\n]*)$/);if(!t)return;let[,r,o,n,s,i,a,c,l,u,p,f,m,h]=t,g={title:h,base:new Date(parseInt(r),parseInt(o)-1,parseInt(n)),plan:{},record:{}};if(s){let y=new Date(g.base);y.setHours(parseInt(s)),y.setMinutes(parseInt(i)),g.plan.start=y}if(a&&(g.plan.duration=parseInt(a)*60),c){let y=new Date(g.base);y.setHours(parseInt(c)),y.setMinutes(parseInt(l)),y.setSeconds(parseInt(u)),g.record.start=y}if(p){let y=new Date(g.base);y.setHours(parseInt(p)),y.setMinutes(parseInt(f)),y.setSeconds(parseInt(m)),g.record.start&&Zo(g.record.start,y)&&y.setDate(y.getDate()+1),g.record.end=y}return g};var Gn=e=>e.record?.start??e.plan?.start??e.base,Sy=e=>e.record?.end??(Py(e.plan?.duration)?e.base:Qs(Gn(e),e.plan.duration));var be=({title:e,base:t,plan:r,record:o})=>["",pe(t,"yyyy-MM-dd")," ",r?.start?pe(r.start,"HH:mm"):" ".repeat(5)," ",r?.duration?${r.duration/60}.padStart(4,"0"):" ".repeat(4)," ",o?.start?pe(o?.start,"HH:mm:ss"):" ".repeat(8)," ",o?.end?pe(o?.end,"HH:mm:ss"):" ".repeat(8),"",e].join("");function*Ly(e){for(let t of en(e))Po(t)||(yield t)}function*en(e){for(let t=0;t<e.length;t++){let r=e[t],o=Po(r)?r:r.text,n=Go(t,e),s=xt(o);if(!s){yield o;continue}yield{...s,lines:e.slice(t+1,t+1+n).map(i=>Po(i)?i:i.text)},t+=n}}var vP=5*60,ti=async()=>{let e=He().position.line,t=xt(gt(e)??""),r=t?.base??new Date,o={start:t?.plan?.start?Qs(t.plan.start,vP+(t.plan.duration??0)):void 0,duration:t?.plan?.duration};scrapbox.Page.insertLine(be({title:"",base:r,plan:o,record:{}}),e+1),await scrapbox.Page.waitForSave()};var tn=async()=>{let e=He().position.line,t=xt(gt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;o||(scrapbox.Page.updateLine(be({record:{start:r?void 0:new Date},...n}),e),await scrapbox.Page.waitForSave())};var eo=async()=>{let e=He().position.line,t=xt(gt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;r&&(scrapbox.Page.updateLine(be({record:{start:r,end:o?void 0:new Date},...n}),e),await scrapbox.Page.waitForSave())};var Uu=async()=>{let e=He().position.line,t=xt(gt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;if(!r){await tn();return}if(!o){await eo();return}scrapbox.Page.updateLine(be({record:{},...n}),e),await scrapbox.Page.waitForSave()};var ri=async()=>{let e=He().position.line,t=xt(gt(e)??"");if(!t)return;let{record:{start:r,end:o},...n}=t;if(r){if(o)return;await eo();return}if(o)return;let s;for(let{text:a}of Lr().slice(0,(e??0)+1).reverse()){let{record:c}=xt(a)??{};if(c?.end){s=c.end;break}}let i=new Date;scrapbox.Page.updateLine(be({record:{start:s??i,end:i},...n}),e),await scrapbox.Page.waitForSave()};var rn=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:o}=He();return r===""?[o.line,o.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var $u=(e,t=7)=>new Date((e+2592e3*((t+1)**1.5-1)/5221.154823442138)*1e3);var ju=(e,t)=>{let r,o,n,s,i=null;if(i=e.match(/^(.*?)(s|e):([^\s]+)\s+d:(\d+)/))[,o,s,n,r]=i;else if(i=e.match(/^(.*?)d:(\d+)\s+(s|e):([^\s]+)/))[,o,r,s,n]=i;else if(i=e.match(/^(.*?)(s|e):([^\s]+)/))[,o,s,n]=i;else return(i=e.match(/^(.*?)d:(\d+)/))?([,o,r]=i,{name:o.trimEnd(),duration:parseInt(r)*60}):void 0;for(let{test:a,parse:c}of TP){let l=n.match(a);if(!l)continue;let u=c(l),p=u.isDuration?Au(t,u):Ry(t,u);return s==="s"?{name:o.trimEnd(),start:p,...r!==void 0?{duration:parseInt(r)*60}:{}}:{name:o.trimEnd(),start:$u(t.getTime()/1e3,(p.getTime()-t.getTime())/(24*60*60*1e3)),...r!==void 0?{duration:parseInt(r)*60}:{}}}},TP=[{test:/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3]),hours:parseInt(e[4]),minutes:parseInt(e[5])})},{test:/(\d{4})-(\d{2})-(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3]),hours:parseInt(e[4])})},{test:/(\d{4})-(\d{2})-(\d{2})T?$/i,parse:e=>({isDuration:!1,year:parseInt(e[1]),month:parseInt(e[2])-1,date:parseInt(e[3])})},{test:/(\d{2})-(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2]),hours:parseInt(e[3]),minutes:parseInt(e[4])})},{test:/(\d{2})-(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2]),hours:parseInt(e[3])})},{test:/(\d{2})-(\d{2})T?$/i,parse:e=>({isDuration:!1,month:parseInt(e[1])-1,date:parseInt(e[2])})},{test:/(\d{2})T(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,date:parseInt(e[1]),hours:parseInt(e[2]),minutes:parseInt(e[3])})},{test:/(\d{2})T(\d{2})$/i,parse:e=>({isDuration:!1,date:parseInt(e[1]),hours:parseInt(e[2])})},{test:/T?(\d{2}):(\d{2})$/i,parse:e=>({isDuration:!1,hours:parseInt(e[1]),minutes:parseInt(e[2])})},{test:/T?(\d{2})$/i,parse:e=>({isDuration:!1,hours:parseInt(e[1])})},{test:/P(\d+)Y(\d+)M(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3]),hours:parseInt(e[4]),minutes:parseInt(e[5])})},{test:/P(\d+)Y(\d+)M(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3]),hours:parseInt(e[4])})},{test:/P(\d+)Y(\d+)M(\d+)D$/i,parse:e=>({isDuration:!0,year:parseInt(e[1]),month:parseInt(e[2])-1,days:parseInt(e[3])})},{test:/P(\d+)M(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2]),hours:parseInt(e[3]),minutes:parseInt(e[4])})},{test:/P(\d+)M(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2]),hours:parseInt(e[3])})},{test:/P(\d+)M(\d+)D$/i,parse:e=>({isDuration:!0,month:parseInt(e[1])-1,days:parseInt(e[2])})},{test:/P(\d+)DT(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,days:parseInt(e[1]),hours:parseInt(e[2]),minutes:parseInt(e[3])})},{test:/P(\d+)DT(\d+)H$/i,parse:e=>({isDuration:!0,days:parseInt(e[1]),hours:parseInt(e[2])})},{test:/P(\d+)D$/i,parse:e=>({isDuration:!0,days:parseInt(e[1])})},{test:/PT?(\d+)H(\d+)M$/i,parse:e=>({isDuration:!0,hours:parseInt(e[1]),minutes:parseInt(e[2])})},{test:/PT?(\d+)H$/i,parse:e=>({isDuration:!0,hours:parseInt(e[1])})},{test:/PT?(\d+)M$/i,parse:e=>({isDuration:!0,minutes:parseInt(e[1])})},{test:/P(\d+)W$/i,parse:e=>({isDuration:!0,weeks:parseInt(e[1])})}];var on=async()=>{let e=new Date,[t,r]=rn(),o=Lr().slice(t,r+1).map(s=>s.text),n=o.flatMap(s=>{let i=s.trimEnd();if(i==="")return s;let{name:a,start:c,duration:l}=ju(i,e)??{};return!a||!c&&!l?s:[be({title:a.trim(),base:c??e,plan:{start:c,duration:l},record:{}})]});if(o.join(
)!==n.join(
)){for(let s=t;s<=r;s++)scrapbox.Page.updateLine(n[s-t],s);await scrapbox.Page.waitForSave()}};var ec=async(e,t,r)=>{let o=[];for(let n=e;n<=t;n++){let s=gt(n)??"",i=xt(s);if(!i){o.push(s);continue}o.push(be(r(i,n)))}for(let n=e;n<=t;n++)scrapbox.Page.updateLine(o[n-e],n);await scrapbox.Page.waitForSave()};var oi=async(e=1)=>{let[t,r]=rn();await ec(t,r,o=>(o.base=Te(o.base,e),o))};var ni=async()=>{let[e,t]=rn(),r=new Date;await ec(e,t,o=>(yt(o.base,r)||(o.base=r),o))};var _P="日刊記録sheet",PP=/日刊記録sheet (\d{4})-(\d{2})-(\d{2})/,si=["[** 00:00 - 03:00] 未明","[** 03:00 - 06:00] 明け方","[** 06:00 - 09:00] 朝","[** 09:00 - 12:00] 昼前","[** 12:00 - 15:00] 昼過ぎ","[** 15:00 - 18:00] 夕方","[** 18:00 - 21:00] 夜のはじめ頃","[** 21:00 - 00:00] 夜遅く"];var Bu=e=>{let t=e.match(PP);if(!t)return;let[,r,o,n]=t,s=new Date(parseInt(r),parseInt(o)-1,parseInt(n));return Gt(s)?s:void 0},kr=e=>pe(e,'${_P}' yyyy-MM-dd),nn=e=>{let t=Bu(e[0]);if(!t)return e;let r=OP(t),o=[],n=[];for(let a of en(e.slice(1))){if(typeof a=="string"){if(si.includes(a)||r!==""&&r===a)continue;n.push(a);continue}o.push(a)}let s=o.sort((a,c)=>Qo(Gn(a),Gn(c)));if(s.length===0)return[e[0],r,...si,...n];let i=[0,0,0,0,0,0,0,0];for(let a=1;a<si.length;a++){let c=Du(new Date(t.getFullYear(),t.getMonth(),t.getDate()),3*a),l=s.findIndex(m=>Zo(Gn(m),c));if(l<0){i[a]=-1;continue}if(l===0)continue;let u=s[l-1],p=Gn(u),f=Sy(u);i[a]=(f.getTime()-p.getTime())/2<c.getTime()-p.getTime()?l:l-1}return[e[0],r,...s.flatMap((a,c)=>[...i.flatMap((l,u)=>l===c?[si[u]]:[]),be(a),...a.lines]),...i.flatMap((a,c)=>a===-1?[si[c]]:[]),...n]},OP=e=>yesterday: ${kr(zt(e,1))};var ii=async(e,t)=>{let r=()=>{},o=setTimeout(()=>{let{render:n,dispose:s}=De();r=s,n({type:"spinner"},{type:"text",text:"formatting..."})},500);await Le(e,t,n=>nn(n.map(s=>s.text))),clearTimeout(o),r()};async function*Hu(e,t,r){let o=[...t],n=[];for(;o.length>0;){let s=o.shift();if(!s)break;let i=s.base,a=[s];for(let c=0;c<o.length;c++)yt(o[c].base,i)&&(a.push(...o.splice(c,1)),c--);n.push((async()=>(await Le(e,kr(i),c=>nn([...c.map(l=>l.text),...a.flatMap(l=>[be(l),...l.lines??[]])]),r),{date:i,size:a.length}))())}yield*Oy(n)}var sn=async({from:{project:e,title:t},to:r})=>{let o=await ar(e,t);if(O(o))throw Z(o);let n=Bu(t),{lines:s}=S(o),i=[];for(let p of Ly(s))n&&yt(p.base,n)||i.push(p);let{render:a,dispose:c}=De();a({type:"spinner"},{type:"text",text:copying ${i.length} tasks...});let l=await Mt();if(O(l))throw Z(l);let u=S(l);try{let p=0,f=!1;for await(let m of Hu(r,i,{socket:u})){if(m.state!=="fulfilled"){console.error(m.reason),f=!0;continue}p+=m.value.size,a({type:"spinner"},{type:"text",text:copying ${i.length-p} tasks...})}if(f){a({type:"exclamation-triangle"},{type:"text",text:"Some tasks failed to be written"});return}a({type:"spinner"},{type:"text",text:Copied. removing ${i.length} original tasks...}),await Le(e,t,m=>{let h=[];for(let g of en(m)){if(Po(g)){h.push(g);continue}n&&yt(g.base,n)&&h.push(be(g),...g.lines)}return h},{socket:u}),a({type:"check-circle"},{type:"text",text:"Moved"})}finally{await Ct(u),await Fe(1e3),c()}};var vr=e=>${e}.padStart(2,"0");var an=e=>"hours"in e,lr=(e,t)=>e.year!==t.year?e.year<t.year:e.month!==t.month?e.month<t.month:e.date!==t.date?e.date<t.date:"hours"in t?"hours"in e?e.hours*60+e.minutes<t.hours*60+t.minutes:0<t.hours*60+t.minutes:!1,Cr=e=>${${e.year}.padStart(4,"0")}-${vr(e.month)}-${vr(e.date)}${"hours"in e?T${vr(e.hours)}:${vr(e.minutes)}:""},ge=e=>{let t=Cr(e);return new Date(t.includes("T")?t:${t}T00:00)},Ht=e=>({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),hours:e.getHours(),minutes:e.getMinutes()});var My=e=>{switch(e.toLowerCase()){case"y":return"yearly";case"m":return"monthly";case"w":return"weekly";case"d":return"daily";default:return}};var Cy=e=>{switch(e){case"+":return"todo";case"-":return"note";case"!":return"deadline";case".":return"done";case"~":return"up-down";default:return}},Iy=e=>{switch(e){case"todo":return"+";case"note":return"-";case"deadline":return"!";case"done":return".";case"up-down":return"~"}};var pr=e=>{let t=e.match(/(?:([\+\-!~.])(\d+)?)?@(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}))?(?:\/(\d{2}):(\d{2})|\/(?:(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)|D(\d+))?(?:R([YMWD])?(\d+))?(?:@(?:(\d{2}):(\d{2})|(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)?(?:\/(\d{2}):(\d{2})|\/(?:(?:(?:(\d{4})-)?(\d{2})-)?(\d{2})(?:T(\d{2}):(\d{2}))?)|D(\d+))?)?/i);if(!t)return;let[r,o,n,s,i,a,c,l,u,p,f,m,h,g,y,x,w,k,b,T,v,A,F,D,N,_,P,I,$,j,q,B,Y]=t,G=${e.slice(0,t.index).trim()}${e.slice((t.index??0)+r.length).trim()},X=Ay(s,i,a,c,l);if(!Gt(ge(X)))return M({name:"InvalidDateError",message:The reference point of the task "${Cr(X)}" is an invalid date.});let J=Fy(X,f,m,h,u||g,p||y,x);if(J!==void 0){if(Qe(J)&&isNaN(J)||!Qe(J)&&!Gt(ge(J)))return M({name:"InvalidDateError",message:The estimated end of the task${Qe(J)?"": "${Cr(J)}"} is an invalid date.});if(Qe(J)&&J<0||!Qe(J)&&lr(J,X))return M({name:"TaskRangeError",message:The reference point of an task cannot be after its estimated end.
reference point:${Cr(X)}
estimated end:${Cr(Qe(J)?Ht(Mr(ge(X),J)):J)}})}let ue=/^[\uFE00-\uFE0F]*[✅❌]/.test(e)?"done":Cy(o),oe=ue?{status:ue,refDate:X}:void 0;oe&&n&&(oe.speed=parseInt(n));let kt=Ay(v||s,A||i,F||a,b||D||c,T||N||l);if(!Gt(ge(kt)))return M({name:"InvalidDateError",message:The start of the task/event "${Cr(kt)}" is an invalid date.});let Se=Fy(kt,I||f,$||m,j||h,_||q||u||g,P||B||p||y,Y||x),W=an(kt)&&Qe(Se)?{start:kt,duration:Se}:void 0;if(W){let Nt={name:G,executed:W,generated:!1,raw:e};return oe&&(Nt.freshness=oe),(w||k)&&(Nt.recurrence={frequency:My(w??"D")??"daily",count:k?parseInt(k):1}),L(Nt)}if(!oe)return M({name:"InvalidDateError",message:"Task requires freshness to be spec"});let we={name:G,freshness:oe,generated:!1,raw:e};return J&&(we.estimated=J),L(W?{...we,executed:W}:we)},Ir=e=>!("executed"in e),Oo=e=>"recurrence"in e,Dy=e=>!("executed"in e||"freshness"in e&&an(e.freshness.refDate)&&e.estimated&&(Qe(e.estimated)||an(e.estimated))),ci=e=>"executed"in e?e.executed.duration:Qe(e.estimated)?e.estimated:void 0,Ar=e=>Ir(e)?e.freshness.refDate:e.executed.start,Uy=e=>{if(!Ir(e)){let r=ge(e.executed.start);return Ht(Mr(r,e.executed.duration))}if(Qe(e.estimated)&&an(e.freshness.refDate)){let r=ge(e.freshness.refDate);return Ht(Mr(r,e.estimated))}let t=ge(Qe(e.estimated)?e.freshness.refDate:e.estimated??e.freshness.refDate);return t.setHours(0),t.setMinutes(0),Ht(Te(t,1))},IP=e=>{let t=e.freshness?${Iy(e.freshness.status)}${e.freshness.speed??""}:"",r=${Cr(Ar(e))},o=ci(e);return${t}@${r}${o===void 0?"":D${o}}${e.name}},tc=(e,t)=>{let r=Ht(t),{recurrence:o,executed:n}=e;switch(o.frequency){case"yearly":{if(Math.abs(r.year-n.start.year)%(o.count??1)!==0||n.start.month!==r.month||n.start.date!==r.date)return;break}case"monthly":{if(Za(ge(r),ge(n.start))%(o.count??1)!==0)return;break}case"weekly":case"daily":{let a=o.frequency==="weekly"?7:1;if(Zr(ge(r),ge(n.start))%((o.count??1)*a)!==0)return;break}}let s={...n.start};s.year=r.year,s.month=r.month,s.date=r.date;let i={name:e.name,executed:{start:s,duration:n.duration},generated:!0,raw:e.raw};return e.freshness&&(i.freshness=e.freshness),i},rc=e=>e.freshness?e.generated?IP(e):e.raw:e.generated?void 0:e.raw,Ay=(e,t,r,o,n)=>{let s=parseInt(e),i=parseInt(t),a=parseInt(r),c=o?parseInt(o):void 0,l=n?parseInt(n):void 0;return c!==void 0&&l!==void 0?{year:s,month:i,date:a,hours:c,minutes:l}:{year:s,month:i,date:a}},Fy=(e,t,r,o,n,s,i)=>{if(!t&&!r&&!o&&!n&&!s&&!i)return;if(i)return parseInt(i);let a=t?parseInt(t):e.year,c=r?parseInt(r):e.month,l=o?parseInt(o):e.date,u=n?parseInt(n):void 0,p=s?parseInt(s):void 0,f=u!==void 0&&p!==void 0?{year:a,month:c,date:l,hours:u,minutes:p}:{year:a,month:c,date:l};return!an(e)||!an(f)?f:Math.round((ge(f).getTime()-ge(e).getTime())/(60*1e3))};var cn=(e,t)=>{if(!e.generated&&Oo(e)){let s=tc(e,t);return s?cn(s,t):void 0}let r=ge(Ir(e)?e.freshness.refDate:e.executed.start),o=ci(e),n=rc(e);return{title:n!==void 0?${n}:e.name,base:r,plan:{start:Dy(e)?void 0:r,duration:o!==void 0?o*60:void 0},record:{}}};var Wu={あさごはん:"#log-breakfast",ひるごはん:"#log-lunch",よるごはん:"#log-dinner"},ln=(e,{title:t,projectTo:r,mode:o})=>{let[n,...s]=e.split(
),i=xt(n);if(!i)return;if(s.length===0)return{text:e,pages:[]};let{title:a,base:c,record:l,...u}=i,p=AP(a,c,l),f=be({title:${p},base:c,record:l,...u}),m=Math.min(...s.map(g=>Zt(g))),h=[.../[\[\]]/.test(a)&&a!==${p}?[a]:[],...t in Wu?[...s.map(g=>g.slice(m)),"",Wu[t],"#log-eatenfood"]:[...s.map(g=> ${g.slice(m)}),""]];return{text:f,pages:[{project:r,title:p,lines:$y(t,h,[l.start??c]),mode:o}]}};ln.hookName="task-hook";var AP=(e,t,r)=>{let o=pe(r.start??t,"yyyy-MM-dd");if(e in Wu)return${o} ${e};if(pr(e.slice(1,-1)))return e.slice(1,-1);let n=e.replace(/[\[\]]/g,"").trim();return${n}${n.endsWith(o)?"": ${o}}},pn=(e,{title:t,projectTo:r,mode:o,lines:n})=>{let[s,...i]=e.split(
);if(i.length===0)return;let a=s.replace(/[\[\]]/g,"").trim(),c=Math.min(...i.map(p=>Zt(p))),l=r.startsWith("takker")?Ey([new Date,...n.map(({updated:p})=>new Date(p*1e3))]).sort((p,f)=>f.getTime()-p.getTime()):[],u=["",.../[\[\]]/.test(s)?[s.trimStart()]:[],...i.map(p=>p.slice(c))];return{text:${" ".repeat(Zt(s))}${a},pages:[{project:r,title:a,lines:$y(t,u,l),mode:o}]}};pn.hookName="new-page-hook";var un=(e,{projectTo:t,mode:r})=>{if(e.includes(
)||!/\[[^\]]+\]/.test(e))return;let[o,n]=e.match(/^(\s*)(.*)$/)?.slice?.(1)??["",e],s=[...n.matchAll(/\[([^\]])\]/g)].map(a=>ae(a[1])),i=n.replaceAll("[","").replaceAll("]","");return{text:${o}${i},pages:[{project:t,title:i,lines:(a,{links:c})=>{let l=c.map(u=>ae(u));if(!s.every(u=>l.includes(u)))return[...a.map(u=>u.text),n]},mode:r}]}};un.hookName="splitted-link-hook";var $y=(e,t,r)=>(o,{links:n})=>{let s=n.map(p=>ae(p)),i=s.includes(ae(e))?[]:[from ${e}],a=r.flatMap(p=>{let f=pe(p,"yyyy-MM-dd");if(s.includes(f))return[];let m=pe(p,"HH:mm:ss");return[#${f} ${m}]}),c=o.map(p=>p.text),l=c.findIndex(p=>/^#\d{4}-\d{2}-\d{2}/.test(p)),u=l<0?c.length:l;return[...c.slice(0,u),...i,...t,"",...a,...c.slice(u)]};var jy=e=>e.preventDefault(),By=e=>e.stopPropagation(),Hy={"<A-a><A-t>":async e=>{jy(e),By(e);let[t,r]=FP(),o=Lr().slice(t,r+1).map(n=>{let s=n.text,i=n.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=pr(i);if(!a||O(a))return s;let c=S(a);if(c.freshness?.status==="done")return s;let l=cn(c,new Date);return l?(l.title=${i},be(l)):s}).join(
);await Ca(t,r,o),await on()},"<A-a><A-m>":e=>{scrapbox.Layout==="page"&&(jy(e),By(e),sn({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"}))}},FP=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:o}=He();return r===""?[o.line,o.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var mn=e=>e.preventDefault(),fn=e=>e.stopPropagation(),qu={"<A-a><A-a>":e=>{mn(e),fn(e),ti()},"<A-a><A-s>":e=>{mn(e),fn(e),tn()},"<A-a><A-e>":e=>{mn(e),fn(e),eo()},"<A-a><A-0>":e=>{mn(e),fn(e),ri()},"<A-a><A-1>":e=>{mn(e),fn(e),oi(1)},"<A-a><A-t>":e=>{mn(e),fn(e),ni()},"<A-a><A-f>":e=>{scrapbox.Layout==="page"&&(mn(e),fn(e),ii(scrapbox.Project.name,scrapbox.Page.title))}};var bt=e=>e.preventDefault(),Et=e=>e.stopPropagation(),dn=(e,t)=>{let r=Cg()?.getElementsByClassName?.("button");if(!r)return;let o=[...r].find(n=>t instanceof RegExp?t.test(n.textContent??""):n.textContent===t);o instanceof HTMLDivElement&&e.target===document.activeElement&&(bt(e),Et(e),o.click())},DP={"-":e=>dn(e,""),"]":e=>dn(e,""),c:e=>dn(e,"Copy plain"),$:e=>dn(e,""),"{":e=>dn(e,/{{c\d+}}/),"}":e=>dn(e,"reset cloze"),n:e=>dn(e,"make note")},UP={"<C-]>":e=>{let{position:{line:t,char:r}}=He(),o=Ks(t,r)?.closest("a.page-link")??Xr(t)?.querySelector?.("a.page-link");o instanceof HTMLAnchorElement&&(bt(e),Et(e),o.click())},"<C-o>":e=>{bt(e),Et(e),history.back()}},$P={"<C-home>":e=>{bt(e),Et(e),Hg()},"<C-end>":e=>{bt(e),Et(e),Wg()}},Wy=[ln,pn,un],jP={"<C-X>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(bt(e),Et(e),Jr({project:t,mode:"self",hooks:Wy})?.())},"<C-D>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(bt(e),Et(e),Jr({project:t,mode:"noopen",hooks:Wy})?.())},"<C-h>":e=>{bt(e),Et(e),Aa()},"<C-j>":e=>{bt(e),Et(e),Da()},"<C-k>":e=>{bt(e),Et(e),Fa()},"<C-l>":e=>{bt(e),Et(e),Ia()},"<A-h>":e=>{bt(e),Et(e),$a()},"<A-j>":e=>{bt(e),Et(e),Ba()},"<A-k>":e=>{bt(e),Et(e),ja()},"<A-l>":e=>{bt(e),Et(e),Ua()}};scrapbox.TimeStamp.removeAllFormats();var BP={"<A-t><A-t>":e=>{bt(e),Et(e),ct(pe(new Date,"#yyyy-MM-dd HH:mm:ss "))},"<A-t><A-j>":e=>{bt(e),Et(e),ct(pe(new Date,"yyyy-MM-dd HH:mm:ss "))},"<A-t><A-k>":e=>{bt(e),Et(e),ct(pe(new Date,"HH:mm:ss "))},"<A-t><A-l>":e=>{bt(e),Et(e),ct(pe(new Date,"yyyy-MM-dd"))}},qy={...DP,...UP,...$P,...jP,...BP,...Hy};var{render:HP}=De(),Gu,WP=e=>{Gu!==void 0&&cancelAnimationFrame(Gu),Gu=requestAnimationFrame(()=>HP({type:"text",text:e}))},zu=new Va({addEventListener:Xg,removeEventListener:Pu},{onSequenceUpdate:WP}),Gy=zu.bind({...qy,...scrapbox.Project.name==="takker-memex"?qu:{}});Gy.size>0&&alert([...Gy.entries()].map(([e,t])=>${e}:
${t.map(r=>- ${r}).join(`
)}).join(`
));var qP=/https?:\/\/vimeo\.com\/([0-9]+)/i,zy=e=>{let t=e.match(qP);if(t)return t[1]};var GP=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Vy=e=>{let t=e.match(GP);if(!t)return;let[,r,o]=t;return{videoId:o,pathType:r}};var zP=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Ky=e=>{let t=e.match(zP);if(!t)return;let[,r]=t;return r};var Yy=e=>{let{type:t,pathType:r,content:o,href:n,...s}=e;if(o===""){let i=Ea(n);if(i)return{type:"youtube",href:n,...i,...s};let a=zy(n);if(a)return{type:"vimeo",videoId:a,href:n,...s};let c=Vy(n);if(c)return{type:"spotify",href:n,...c,...s};let l=Ky(n);if(l)return{type:"anchor-fm",videoId:l,href:n,...s};if(KP(n))return{type:"video",href:n,...s}}return VP(n)?{type:"audio",content:o,href:n,...s}:{type:"absoluteLink",content:o,href:n,...s}},VP=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),KP=e=>/\.(?:mp4|webm)$/.test(e);var YP=Object.defineProperty,XP=(e,t)=>{for(var r in t)YP(e,r,{get:t[r],enumerable:!0})},JP={};XP(JP,{andThen:()=>As,andThenAsync:()=>Fs,flatten:()=>lp,fromPromiseSettledResult:()=>pp,inspectBoth:()=>fp,inspectErr:()=>mp,inspectOk:()=>up,isErrAnd:()=>ia,isErrAndWithEnsureType:()=>dp,isOkAnd:()=>aa,isOkAndWithEnsureType:()=>hp,map:()=>Gr,mapAsync:()=>ie,mapErr:()=>gp,mapErrAsync:()=>Ae,mapOr:()=>yp,mapOrAsync:()=>xp,mapOrElse:()=>Ds,mapOrElseAsync:()=>bp,orElse:()=>Ep,orElseAsync:()=>ca,toNullableFromErr:()=>Rp,toNullableFromOk:()=>wp,toUndefinableFromErr:()=>vp,toUndefinableFromOk:()=>kp,transposeToNullable:()=>Tp,transposeToUndefinable:()=>_p,tryCatchInto:()=>fa,tryCatchIntoAsync:()=>da,tryCatchIntoWithEnsureError:()=>Pp,tryCatchIntoWithEnsureErrorAsync:()=>Op,unwrapOr:()=>$o,unwrapOrElse:()=>Sp,unwrapOrElseAsync:()=>Lp,unwrapOrThrow:()=>Np});var Xy=async()=>{let e=localStorage.getItem("projectsLastAccessed");if(!e)return[];try{let t=JSON.parse(e),r=Object.entries(t).sort(([,s],[,i])=>i-s).map(([s])=>s),o=await ba([]);if(O(o))return r;let n=S(o).projects.map(s=>s.id);return r.filter(s=>!n.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var QP;(e=>{})(QP||={});var oc="0.16.9",Vu,Ku,Jy=e=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(Ku)throw Ku;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,Vu=new Promise((o,n)=>{r.onload=()=>o(window.katex),r.onerror=s=>{Ku=s,n(s)},document.head.append(r)})}return Vu||new Promise(r=>{let o=setInterval(()=>{window.katex&&(clearInterval(o),r(window.katex))},500)})};var nc=(e,t)=>{let[r,o]=Q("");return{ref:U(s=>{s&&Jy(oc).then(i=>{try{i.render(e,s,t),o("")}catch(a){if(a instanceof Error&&a.name==="ParseError")o(a.message.slice(19));else throw a}})},[e,...Object.values(t??{})]),error:r}};var Qy=e=>{let t=[],r=new Set,o=n=>{r.delete(n);let s=t.pop();if(!s)return;let i=s[0]().finally(()=>o(i)).then(a=>s[1](a)).catch(a=>s[2](a));r.add(i)};return n=>{if(r.size<e){let s=n().finally(()=>o(s));return r.add(s),s}return new Promise((s,i)=>{t.push([n,s,i])})}};var ZP="0.6.5",tx=ScrapBubble-${ZP},Zy=await globalThis.caches.open(tx);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==tx&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var ex=Qy(3);async function*sc(e,t){let r=((t?.saveFailedResponse?Zy.match(e):void 0)??wo(e,t)).then(i=>["cache",i]);{let i=Fe(1e3).then(()=>"timeout"),a=await Promise.race([r,i]);if(a!=="timeout"){a[1]&&(yield["cache",a[1]]);let c=await ex(()=>fetch(e));!c.ok&&t?.saveFailedResponse&&await Zy.put(e,c.clone()),yield["network",c]}}let o=ex(()=>fetch(e)).then(i=>["network",i]),[n,s]=await Promise.race([r,o]);if(n==="network"){yield[n,s];return}s&&(yield[n,s]),yield await o}var rx=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var ic=()=>{let e=new Map;return{dispatch:(t,r)=>{let o=e.get(t);if(o)for(let n of o)n(r)},on:(t,r)=>{let o=e.get(t)??new Set;o.add(r),e.set(t,o)},off:(t,r)=>{let o=e.get(t);o&&o.delete(r)}}};var er=!1,ox=e=>{er=typeof e=="boolean"?e:new Set(e)},So=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...o)=>r(%c${e},"color: gray",...o)];case"log":case"info":case"debug":return[t,(...o)=>{er!==!0&&(!er||!er.has(e))||r(%c${e},"color: gray",...o)}];case"assert":return[t,(o,...n)=>{er!==!0&&(!er||!er.has(e))||r(o,%c${e},"color: gray",...n)}];case"time":case"timeEnd":return[t,o=>{er!==!0&&(!er||!er.has(e))||r(${e} ${o})}];default:return[t,(...o)=>{if(!(er!==!0&&(!er||!er.has(e))))return r(...o)}]}}));var Yu=ic(),ac=new Map,eO=So("ScrapBubble:useProject.ts"),nx=e=>{let[t,r]=Q();return te(()=>{Yu.on(e,r);let o=ac.get(e);return o?r(o.loading?void 0:o.value):(ac.set(e,{loading:!0}),r(void 0),(async()=>{try{let n=Bo.toRequest(e);for await(let[,s]of sc(n)){let i=await Bo.fromResponse(s);ac.set(e,{loading:!1,value:i}),Yu.dispatch(e,i);break}}catch(n){eO.error(n),ac.delete(e)}})()),()=>Yu.off(e,r)},[e]),t};var tO=["default-light","default-dark","default-minimal"],rO=["paper-light","paper-dark-dark","paper-dark"],sx=["blue","purple","green","orange","red"],oO=["hacker1","hacker2"],ix=["winter","spring","summer","automn"],ax=["tropical"],cx=["kyoto","newyork","paris"],lx=["mred","lgreen"],Ace=["default-light","default-minimal","paper-light",...sx,...ix,...ax,...cx,...lx];var nO=[...tO,...rO,...sx,...oO,...ix,...ax,...cx,...lx];function px(e){return nO.includes(e)}var ux="default-light",hn=e=>{let t=nx(e);return H(()=>{if(!t||O(t))return ux;let r=S(t).theme;return px(r)?r:ux},[t])};var zn=(e,t)=>new Promise(r=>{let o=!1,n=()=>{o=!0,r(!1)};e.addEventListener("click",n),e.addEventListener("pointerleave",n),setTimeout(()=>{o||r(!0),e.removeEventListener("click",n),e.removeEventListener("pointerleave",n),r(!1)},t)});var Vn=e=>{let{top:t,right:r,left:o,bottom:n}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),i=(o-s.left)/s.width>.5;return{top:Math.round(n-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...i?{right:Math.round(s.right-r)}:{left:Math.round(o-s.left)},maxWidth:i?r-10:document.documentElement.clientWidth-o-10}};var mx=({project:e,title:t,descriptions:r,thumbnail:o,linkTo:n,bubble:s,delay:i,prefetch:a})=>{let c=H(()=>o?[]:at(r.join(
),{hasTitle:!1}),[o,r]),l=hn(e),u=U(async({currentTarget:f})=>{a(e,t),await zn(f,i)&&s({project:e,title:t,linkTo:n,type:"link",position:Vn(f)})},[e,t,i,n?.project,n?.titleLc]),p=H(()=>n?()=>{qn({type:"page",from:{project:n.project??e,title:n.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,n?.project,n?.titleLc]);return d("a",{className:"related-page-card page-link",type:"link","data-theme":l,href:/${e}/${ne(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:u,onClick:p,children:[d("div",{class:"hover"}),d("div",{class:"content",children:[d("div",{class:"header",children:d("div",{class:"title",children:t})}),o?d("div",{class:"thumbnail",children:d("img",{src:o})}):d("div",{class:"description",children:c.flatMap((f,m)=>f.type==="line"?[d("p",{children:f.nodes.map(h=>d(fx,{node:h,project:e}))},m)]:[])})]})]})},fx=({node:e,project:t})=>{switch(e.type){case"code":return d("code",{children:e.text});case"formula":return d(sO,{node:e});case"commandLine":return d("code",{children:[e.symbol," $",e.text]});case"helpfeel":return d("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return d(ee,{children:e.nodes.map(r=>d(fx,{node:r,project:t}))});case"icon":case"strongIcon":return d(iO,{node:e,project:t});case"hashTag":return d(aO,{node:e});case"link":return d(cO,{node:e});case"plain":case"blank":return d(ee,{children:e.text});default:return}},sO=({node:{formula:e}})=>{let{ref:t,error:r}=nc(e);return d("span",{className:formula ${r?" error":""},children:r?d("code",{children:e}):d("span",{className:"katex-display",ref:t})})},iO=({node:{pathType:e,path:t},project:r})=>{let[o,n]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return d("img",{class:"icon",src:/api/pages/${o}/${ne(n)}/icon})},aO=({node:{href:e}})=>d("span",{class:"page-link",children:["#",e]}),cO=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?d("span",{class:"page-link",children:t}):d("span",{class:"link",children:r||t});var Ee=(e,t)=>/${e.toLowerCase()}/${ae(t)},cc=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var bx=Symbol.for("immer-nothing"),dx=Symbol.for("immer-draftable"),ye=Symbol.for("immer-state");function ur(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var Kn=Object.getPrototypeOf;function Yn(e){return!!e&&!!e[ye]}function ro(e){return e?Ex(e)||Array.isArray(e)||!!e[dx]||!!e.constructor?.[dx]||fi(e)||dc(e):!1}var lO=Object.prototype.constructor.toString();function Ex(e){if(!e||typeof e!="object")return!1;let t=Kn(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)===lO}function li(e,t){fc(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,o)=>t(o,r,e))}function fc(e){let t=e[ye];return t?t.type_:Array.isArray(e)?1:fi(e)?2:dc(e)?3:0}function Qu(e,t){return fc(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function wx(e,t,r){let o=fc(e);o===2?e.set(t,r):o===3?e.add(r):e[t]=r}function pO(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function fi(e){return e instanceof Map}function dc(e){return e instanceof Set}function _t(e){return e.copy_||e.base_}function Zu(e,t){if(fi(e))return new Map(e);if(dc(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Ex(e);if(t===!0||t==="class_only"&&!r){let o=Object.getOwnPropertyDescriptors(e);delete o[ye];let n=Reflect.ownKeys(o);for(let s=0;s<n.length;s++){let i=n[s],a=o[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(o[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Kn(e),o)}else{let o=Kn(e);if(o!==null&&r)return{...e};let n=Object.create(o);return Object.assign(n,e)}}function om(e,t=!1){return hc(e)||Yn(e)||!ro(e)||(fc(e)>1&&Object.defineProperties(e,{set:{value:lc},add:{value:lc},clear:{value:lc},delete:{value:lc}}),Object.freeze(e),t&&Object.values(e).forEach(r=>om(r,!0))),e}function lc(){ur(2)}function hc(e){return Object.isFrozen(e)}var em={};function gn(e){let t=em[e];return t||ur(0,e),t}function uO(e,t){em[e]||(em[e]=t)}var pi;function pc(){return pi}function mO(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hx(e,t){t&&(gn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function tm(e){rm(e),e.drafts_.forEach(fO),e.drafts_=null}function rm(e){e===pi&&(pi=e.parent_)}function gx(e){return pi=mO(pi,e)}function fO(e){let t=e[ye];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function yx(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[ye].modified_&&(tm(t),ur(4)),ro(e)&&(e=uc(t,e),t.parent_||mc(t,e)),t.patches_&&gn("Patches").generateReplacementPatches_(r[ye].base_,e,t.patches_,t.inversePatches_)):e=uc(t,r,[]),tm(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==bx?e:void 0}function uc(e,t,r){if(hc(t))return t;let o=t[ye];if(!o)return li(t,(n,s)=>xx(e,o,t,n,s,r)),t;if(o.scope_!==e)return t;if(!o.modified_)return mc(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let n=o.copy_,s=n,i=!1;o.type_===3&&(s=new Set(n),n.clear(),i=!0),li(s,(a,c)=>xx(e,o,n,a,c,r,i)),mc(e,n,!1),r&&e.patches_&&gn("Patches").generatePatches_(o,r,e.patches_,e.inversePatches_)}return o.copy_}function xx(e,t,r,o,n,s,i){if(Yn(n)){let a=s&&t&&t.type_!==3&&!Qu(t.assigned_,o)?s.concat(o):void 0,c=uc(e,n,a);if(wx(r,o,c),Yn(c))e.canAutoFreeze_=!1;else return}else i&&r.add(n);if(ro(n)&&!hc(n)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;uc(e,n),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&(fi(r)?r.has(o):Object.prototype.propertyIsEnumerable.call(r,o))&&mc(e,n)}}function mc(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&om(t,r)}function dO(e,t){let r=Array.isArray(e),o={type_:r?1:0,scope_:t?t.scope_:pc(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},n=o,s=nm;r&&(n=[o],s=ui);let{revoke:i,proxy:a}=Proxy.revocable(n,s);return o.draft_=a,o.revoke_=i,a}var nm={get(e,t){if(t===ye)return e;let r=_t(e);if(!Qu(r,t))return hO(e,r,t);let o=r[t];return e.finalized_||!ro(o)?o:o===Xu(e.base_,t)?(Ju(e),e.copy_[t]=mi(o,e)):o},has(e,t){return t in _t(e)},ownKeys(e){return Reflect.ownKeys(_t(e))},set(e,t,r){let o=Rx(_t(e),t);if(o?.set)return o.set.call(e.draft_,r),!0;if(!e.modified_){let n=Xu(_t(e),t),s=n?.[ye];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(pO(r,n)&&(r!==void 0||Qu(e.base_,t)))return!0;Ju(e),to(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 Xu(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ju(e),to(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=_t(e),o=Reflect.getOwnPropertyDescriptor(r,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:r[t]}},defineProperty(){ur(11)},getPrototypeOf(e){return Kn(e.base_)},setPrototypeOf(){ur(12)}},ui={};li(nm,(e,t)=>{ui[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ui.deleteProperty=function(e,t){return ui.set.call(this,e,t,void 0)};ui.set=function(e,t,r){return nm.set.call(this,e[0],t,r,e[0])};function Xu(e,t){let r=e[ye];return(r?_t(r):e)[t]}function hO(e,t,r){let o=Rx(t,r);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Rx(e,t){if(!(t in e))return;let r=Kn(e);for(;r;){let o=Object.getOwnPropertyDescriptor(r,t);if(o)return o;r=Kn(r)}}function to(e){e.modified_||(e.modified_=!0,e.parent_&&to(e.parent_))}function Ju(e){e.copy_||(e.copy_=Zu(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var gO=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,o)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(a=s,...c){return i.produce(a,l=>r.call(this,l,...c))}}typeof r!="function"&&ur(6),o!==void 0&&typeof o!="function"&&ur(7);let n;if(ro(t)){let s=gx(this),i=mi(t,void 0),a=!0;try{n=r(i),a=!1}finally{a?tm(s):rm(s)}return hx(s,o),yx(n,s)}else if(!t||typeof t!="object"){if(n=r(t),n===void 0&&(n=t),n===bx&&(n=void 0),this.autoFreeze_&&om(n,!0),o){let s=[],i=[];gn("Patches").generateReplacementPatches_(t,n,s,i),o(s,i)}return n}else ur(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,a=>t(a,...i));let o,n;return[this.produce(t,r,(s,i)=>{o=s,n=i}),o,n]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){ro(e)||ur(8),Yn(e)&&(e=yO(e));let t=gx(this),r=mi(e,void 0);return r[ye].isManual_=!0,rm(t),r}finishDraft(e,t){let r=e&&e[ye];(!r||!r.isManual_)&&ur(9);let{scope_:o}=r;return hx(o,t),yx(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let n=t[r];if(n.path.length===0&&n.op==="replace"){e=n.value;break}}r>-1&&(t=t.slice(r+1));let o=gn("Patches").applyPatches_;return Yn(e)?o(e,t):this.produce(e,n=>o(n,t))}};function mi(e,t){let r=fi(e)?gn("MapSet").proxyMap_(e,t):dc(e)?gn("MapSet").proxySet_(e,t):dO(e,t);return(t?t.scope_:pc()).drafts_.push(r),r}function yO(e){return Yn(e)||ur(10,e),kx(e)}function kx(e){if(!ro(e)||hc(e))return e;let t=e[ye],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=Zu(e,t.scope_.immer_.useStrictShallowCopy_)}else r=Zu(e,!0);return li(r,(o,n)=>{wx(r,o,kx(n))}),t&&(t.finalized_=!1),r}function vx(){class e extends Map{constructor(c,l){super(),this[ye]={type_:2,parent_:l,scope_:l?l.scope_:pc(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:c,draft_:this,isManual_:!1,revoked_:!1}}get size(){return _t(this[ye]).size}has(c){return _t(this[ye]).has(c)}set(c,l){let u=this[ye];return i(u),(!_t(u).has(c)||_t(u).get(c)!==l)&&(r(u),to(u),u.assigned_.set(c,!0),u.copy_.set(c,l),u.assigned_.set(c,!0)),this}delete(c){if(!this.has(c))return!1;let l=this[ye];return i(l),r(l),to(l),l.base_.has(c)?l.assigned_.set(c,!1):l.assigned_.delete(c),l.copy_.delete(c),!0}clear(){let c=this[ye];i(c),_t(c).size&&(r(c),to(c),c.assigned_=new Map,li(c.base_,l=>{c.assigned_.set(l,!1)}),c.copy_.clear())}forEach(c,l){let u=this[ye];_t(u).forEach((p,f,m)=>{c.call(l,this.get(f),f,this)})}get(c){let l=this[ye];i(l);let u=_t(l).get(c);if(l.finalized_||!ro(u)||u!==l.base_.get(c))return u;let p=mi(u,l);return r(l),l.copy_.set(c,p),p}keys(){return _t(this[ye]).keys()}values(){let c=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{let l=c.next();return l.done?l:{done:!1,value:this.get(l.value)}}}}entries(){let c=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{let l=c.next();if(l.done)return l;let u=this.get(l.value);return{done:!1,value:[l.value,u]}}}}[Symbol.iterator](){return this.entries()}}function t(a,c){return new e(a,c)}function r(a){a.copy_||(a.assigned_=new Map,a.copy_=new Map(a.base_))}class o extends Set{constructor(c,l){super(),this[ye]={type_:3,parent_:l,scope_:l?l.scope_:pc(),modified_:!1,finalized_:!1,copy_:void 0,base_:c,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return _t(this[ye]).size}has(c){let l=this[ye];return i(l),l.copy_?!!(l.copy_.has(c)||l.drafts_.has(c)&&l.copy_.has(l.drafts_.get(c))):l.base_.has(c)}add(c){let l=this[ye];return i(l),this.has(c)||(s(l),to(l),l.copy_.add(c)),this}delete(c){if(!this.has(c))return!1;let l=this[ye];return i(l),s(l),to(l),l.copy_.delete(c)||(l.drafts_.has(c)?l.copy_.delete(l.drafts_.get(c)):!1)}clear(){let c=this[ye];i(c),_t(c).size&&(s(c),to(c),c.copy_.clear())}values(){let c=this[ye];return i(c),s(c),c.copy_.values()}entries(){let c=this[ye];return i(c),s(c),c.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(c,l){let u=this.values(),p=u.next();for(;!p.done;)c.call(l,p.value,p.value,this),p=u.next()}}function n(a,c){return new o(a,c)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(c=>{if(ro(c)){let l=mi(c,a);a.drafts_.set(c,l),a.copy_.add(l)}else a.copy_.add(c)}))}function i(a){a.revoked_&&ur(3,JSON.stringify(_t(a)))}uO("MapSet",{proxyMap_:t,proxySet_:n})}var tr=new gO,gc=tr.produce,rle=tr.produceWithPatches.bind(tr),ole=tr.setAutoFreeze.bind(tr),nle=tr.setUseStrictShallowCopy.bind(tr),sle=tr.applyPatches.bind(tr),ile=tr.createDraft.bind(tr),ale=tr.finishDraft.bind(tr);vx();var Tx=e=>{let t=0;for(let r of e)if(r&&(r.exists||(t+=(r.linked?.length??0)+(r.projectLinked?.length??0),t>1)))return!1;return t<2},_x=(e,t)=>gc(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:o,linked:n,projectLinked:s,...i}=t;Object.assign(r,i),sm(t)||(r.lines=o),n&&(r.linked??=n),s&&(r.projectLinked??=s);return}sm(r)&&!sm(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)}),sm=e=>e.lines[0].id==="dummy";var Px=(e,t)=>{let r=new Map,o=ae(t.title);for(let c of t.links){let l=im(e,c);l.linked=[o],r.set(Ee(e,c),l)}let n=Ee(e,o),s=t.projectLinks.map(c=>{let l=cc(c);return Ee(l.project,l.titleLc)}),i={...yc(e,t),linked:[],projectLinked:[]};r.set(n,i);let a=t.links.map(c=>ae(c));for(let c of t.relatedPages.links1hop){c.linksLc.includes(o)&&i.linked.push(c.titleLc);for(let f of c.linksLc.filter(m=>a.includes(m))){let m=Ee(e,f),h=r.get(m)??im(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=Ee(e,c.titleLc),u=yc(e,c),p=r.get(l)?.linked;p&&(u.linked=p),r.set(l,u)}for(let c of t.relatedPages.projectLinks1hop){let l=Ee(c.projectName,c.titleLc);s.includes(l)||i.projectLinked.push(l);let u=yc(c.projectName,c),p=r.get(l)?.projectLinked;p&&(u.projectLinked=p),r.set(l,u)}i.isLinkedCorrect=!0;for(let c of t.relatedPages.links2hop){for(let f of c.linksLc){let m=Ee(e,f),h=r.get(m)??im(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=Ee(e,c.titleLc),u=yc(e,c),p=r.get(l)?.linked;p&&(u.linked=p),r.set(l,u)}return r},yc=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:ae(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:"descriptions"in t?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}),im=(e,t)=>({project:e,titleLc:ae(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var xc=So("ScrapBubble:bubble.ts"),am=new Map,bc=new Set,cm=ic();function*Sx(e){for(let t of e)yield am.get(t)}var Lx=(e,t)=>cm.on(e,t),Nx=(e,t)=>cm.off(e,t),Mx=async(e,t,r,o)=>{let n=[];for(let s of[...t].reverse()){let i=Ee(s,e);bc.has(i)||n.push(xO(s,e,r,o))}await Promise.all(n)},Ox=0,xO=async(e,t,r,o)=>{let n=Ee(e,t);if(bc.has(n))return;bc.add(n);let s=Ox++,i=${s} Check update ${n};xc.time(i);try{let a=ar.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[c,l]of sc(a,{ignoreSearch:!0,saveFailedResponse:!0})){xc.debug(${s}${c} ${n});let u=await ar.fromResponse(l);if(K(u)){let p=Px(e,S(u));for(let[f,m]of p){let h=am.get(f),g=_x(h,m);g&&h!==g&&(am.set(f,g),cm.dispatch(f,m))}}if(o?.ignoreFetch===!0||c==="cache"&&!rx(l,o?.maxAge??60))break}}catch(a){xc.error(a)}finally{bc.delete(n),xc.timeEnd(i),Ox--}};var Cx=So("ScrapBubble:useBubbleData.ts"),Xn=e=>{let[t,r]=Q(lm(e));return te(()=>{r(lm(e));let o,n=()=>{clearTimeout(o),o=setTimeout(()=>{Cx.debug(Update ${e.length} pages),r(lm(e))},10)};return e.forEach(s=>Lx(s,n)),()=>e.forEach(s=>Nx(s,n))},e),t},lm=e=>{let t=[...Sx(e)].flatMap(r=>r?[r]:[]);return Cx.debug(Required: ${e.length} pages, ${t.length} found,t),t};var Ix=({source:e,linked:t,externalLinked:r,projectsForSort:o,...n})=>{let s=H(()=>[...t.keys(),...r.keys()],[t,r]),i=Xn(s),a=H(()=>[...o],[o]),c=H(()=>{let u=(p,f)=>{let m=a.indexOf(p.project),h=a.indexOf(f.project);return m===h?f.updated-p.updated:m<0?1:h<0?-1:m-h};return[...i].sort(u)},[i,a]),l=H(()=>({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:n.onClick,children:c.map(({project:u,titleLc:p,lines:[{text:f}],descriptions:m,image:h})=>{let g=Ee(u,p),y=t.get(g)??r.get(g);return d("li",{children:d(mx,{project:u,title:f,linkTo:y,descriptions:m,thumbnail:h??"",...n})},g)})})};var Jn=e=>{e:if(e.pathType==="root"){let[,r="",o=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(r==="")break e;let[,n]=o?.match?.(/#([a-f\d]{24,32})$/)??["",""];return o===""?{project:r}:n===""?{project:r,title:o}:{project:r,title:o.slice(0,-1-n.length),hash:n}}let[,t]=e.href.match(/#([a-f\d]{24,32})$/)??["",""];return t===""?{title:e.href}:{title:e.href.slice(0,-1-t.length),hash:t}};var pm=(e,t)=>t.some(r=>{let o=!e.project;switch(r.type){case"hashTag":return o&&ae(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==o)return!1;let{project:n,title:s=""}=Jn({pathType:r.pathType,href:r.href});return o?!n&&ae(s)===e.titleLc:n===e.project&&ae(s)===e.titleLc}case"quote":case"strong":case"decoration":return pm(e,r.nodes)}});var Lo=qs({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),Fx=({lines:e,project:t,title:r,whiteList:o,noIndent:n,hash:s,linkTo:i,...a})=>{let c=H(()=>e.flatMap(m=>typeof m=="string"?[]:[m.id]),[e]),l=H(()=>{let m=0;return at(e.map(h=>typeof h=="string"?h:h.text).join(
),{hasTitle:!0}).map(h=>{switch(h.type){case"title":case"line":return{...h,id:c[m++]};case"codeBlock":{let g=m;return m+=h.content.split(
).length+1,{...h,ids:c.slice(g,m)}}case"table":{let g=m;return m+=h.cells.length+1,{...h,ids:c.slice(g,m)}}}})},[e,c]),u=H(()=>{if(s&&c.includes(s))return s;if(i)return l.find(m=>m.type!=="line"?!1:pm(i,m.nodes))?.id},[l,c,s,i?.project,i?.titleLc]),p=dt(null);te(()=>{if(!u)return;let m=p.current?.querySelector(data-id="${u}"),h=globalThis.scrollY;m?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,h)},[u]);let f=hn(t);return d("div",{className:"lines","data-theme":f,ref:p,children:d(Lo.Provider,{value:{project:t,title:r,whiteList:o,...a},children:l.map(m=>{switch(m.type){case"title":return d(ee,{children:[d(Zn,{index:m.id,indent:0,noIndent:n,permalink:m.id===u,children:d("a",{className:"page-link",type:"link",href:/${t}/${ne(m.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:m.text})},m.id),d("hr",{})]});case"codeBlock":return d(bO,{block:m,noIndent:n,ids:m.ids,scrollId:u},m.ids[0]);case"table":return d(EO,{block:m,noIndent:n,ids:m.ids,scrollId:u},m.ids[0]);case"line":return d(Zn,{index:m.id,indent:m.indent,noIndent:n,permalink:m.id===u,children:m.nodes.length>0?m.nodes.map(h=>d(Qn,{node:h},h.raw)):d("br",{})},m.id)}})})})},Zn=({index:e,indent:t,noIndent:r,children:o,permalink:n})=>d("div",{className:line${n?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:o}),bO=({block:{fileName:e,content:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:i}=Yr(Lo),[a,c]=Q(""),l=U(async u=>{u.preventDefault(),u.stopPropagation();try{await navigator.clipboard.writeText(t),c("Copied"),await Fe(1e3),c("")}catch(p){alert(Failed to copy the code block
Error: ${p})}},[t]);return d(ee,{children:[d(Zn,{index:o[0],indent:r,permalink:o[0]===n,children:d("span",{className:"code-block",children:[d("span",{className:"code-block-start",children:d("a",{href:/api/code/${s}/${ne(i)}/${e},target:"_blank",children:e})}),d("span",{className:"copy",title:"Copy",onClick:l,children:a})]})}),d(ee,{children:t.split(
).map((u,p)=>d(Zn,{index:o[p+1],indent:r,permalink:o[p+1]===n,children:d("code",{className:"code-block",children:u})}))})]})},EO=({block:{fileName:e,cells:t,indent:r},ids:o,scrollId:n})=>{let{project:s,title:i}=Yr(Lo);return d(ee,{children:[d(Zn,{index:o[0],indent:r,permalink:o[0]===n,children:d("span",{className:"table-block",children:d("span",{className:"table-block-start",children:d("a",{href:/api/table/${s}/${ne(i)}/${e}.csv,target:"_blank",children:e})})})}),d(ee,{children:t.map((a,c)=>d(Zn,{index:o[c+1],indent:r,permalink:o[c+1]===n,children:d("span",{className:"table-block table-block-row",children:a.map((l,u)=>d("span",{className:cell col-${u},children:l.map(p=>d(Qn,{node:p},p.raw))}))})}))})]})},Qn=({node:e})=>{switch(e.type){case"code":return d("code",{className:"code",children:e.text});case"formula":return d(wO,{node:e});case"commandLine":return d(kO,{node:e});case"helpfeel":return d("code",{className:"helpfeel",children:[d("span",{className:"prefix",children:"?"})," ",d("span",{className:"entry",children:e.text})]});case"quote":return d("blockquote",{className:"quote",children:e.nodes.map(t=>d(Qn,{node:t},t.raw))});case"strong":return d("strong",{children:e.nodes.map(t=>d(Qn,{node:t},t.raw))});case"decoration":return d(RO,{node:e});case"plain":case"blank":return d(ee,{children:e.text});case"hashTag":return d(_O,{node:e});case"link":return d(PO,{node:e});case"googleMap":return d(vO,{node:e});case"icon":return d(Ax,{node:e});case"strongIcon":return d(Ax,{node:e,strong:!0});case"image":return d(TO,{node:e});case"strongImage":return d("img",{className:"image strong-image",src:e.src});case"numberList":return d(ee,{children:[${e.number}. ,e.nodes.map(t=>d(Qn,{node:t},t.raw))]})}},wO=({node:{formula:e}})=>{let{ref:t,error:r}=nc(e);return d("span",{className:formula ${r?" error":""},children:r?d("code",{children:e}):d("span",{className:"katex-display",ref:t})})},RO=({node:{decos:e,nodes:t}})=>d("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>d(Qn,{node:r},r.raw))}),kO=({node:e})=>{let[t,r]=Q(""),o=U(async n=>{n.preventDefault(),n.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await Fe(1e3),r("")}catch(s){alert(Failed to copy the code block
Error: ${s})}},[e.text]);return d(ee,{children:[d("code",{className:"cli",children:[d("span",{className:"prefix",children:e.symbol})," ",d("span",{className:"command",children:e.text})]}),d("span",{className:"tool-buttons",children:d("span",{title:"Copy",className:"copy",onClick:o,children:t})})]})},vO=({node:{place:e,latitude:t,longitude:r,zoom:o}})=>d("span",{className:"pointing-device-map",children:d("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${o}z,rel:"noopner noreferrer",target:"_blank",children:d("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${o}&_csrf=${globalThis._csrf}})})}),Ax=({node:{pathType:e,path:t},strong:r})=>{let{project:o}=Yr(Lo),[n,s]=e==="relative"?[o,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[o,t],i=ne(s);return d("a",{href:/${n}/${i},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",children:d("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${n}/${i}/icon})})},TO=({node:{link:e,src:t}})=>{let 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",children:d("img",{className:"image",src:t})})},_O=({node:{href:e}})=>{let{project:t}=Yr(Lo),r=Dx(t,e),o=Ux(t,e,"hashtag");return d("a",{href:/${t}/${ne(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:o,children:["#",e]})},PO=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return d(OO,{pathType:e,href:t.href});case"absolute":{let r=Yy({pathType:e,...t});switch(r.type){case"youtube":return d(SO,{...r});case"vimeo":return d(LO,{...r});case"spotify":return d(NO,{...r});case"anchor-fm":return d(MO,{...r});case"audio":return d(CO,{...r});case"video":return d(AO,{...r});case"absoluteLink":return d("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},OO=({pathType:e,href:t})=>{let{project:r}=Yr(Lo),{project:o=r,title:n,hash:s=""}=Jn({pathType:e,href:t}),i=Ux(o,n,"link",s),a=Dx(o,n??"");return d("a",{className:page-link${n!==void 0&&a?" empty-page-link":""},type:"link",href:/${o}${n===void 0?"":/${ne(n)}${s===""?"":#${s}}},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",onPointerEnter:i,children:t})},SO=e=>{e.params.append("autoplay","0");let t=e.pathType==="list"?https://www.youtube.com/embed/?${e.params.toString()}&list=${e.listId}:https://www.youtube.com/embed/${e.videoId}?${e.params.toString()};return d("div",{className:"iframe-video-player",children:d("iframe",{src:t,allowFullScreen:!0})})},LO=({videoId:e})=>d("div",{className:"iframe-video-player",children:d("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0})}),NO=e=>d("div",{className:"iframe-video-player",children:d("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0})}),MO=e=>d("div",{className:"iframe-video-player",children:d("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0})}),CO=e=>e.content===""?d("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):d(IO,{...e}),IO=({href:e,content:t})=>{let r=dt(null),o=U(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return d("span",{className:"audio-link",children:[d("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),d("span",{className:"play",onClick:o,children:"♬"}),d("audio",{preload:"none",src:e,ref:r})]})},AO=({href:e})=>d("div",{className:"video-player",children:d("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),Dx=(e,t)=>{let{whiteList:r}=Yr(Lo),o=H(()=>(r.has(e)?[...r]:[e,...r]).map(s=>Ee(s,t)),[r,e]),n=Xn(o);return H(()=>Tx(n),n)},Ux=(e,t,r,o)=>{let{delay:n,bubble:s,prefetch:i}=Yr(Lo);return U(async({currentTarget:a})=>{t&&(i(e,t),await zn(a,n)&&s({project:e,title:t,hash:o,type:r,position:Vn(a)}))},[e,t,o,r,n,i,s])};var $x=({pages:e,onClick:t,source:r,whiteList:o,...n})=>{let[s,i]=Q(Ee(e[0].project,e[0].titleLc)),a=H(()=>({top:${r.position.top}px,maxWidth:${r.position.maxWidth}px,..."left"in r.position?{left:${r.position.left}px}:{right:${r.position.right}px}}),[r.position]);return d("div",{className:"text-bubble",style:a,onClick:t,children:[e.length>1&&d("div",{role:"tablist",children:e.map(c=>d(FO,{project:c.project,titleLc:c.titleLc,selected:s===Ee(c.project,c.titleLc),tabSelector:i},Ee(c.project,c.titleLc)))}),e.map(c=>d(DO,{selected:s===Ee(c.project,c.titleLc),...c,title:c.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:o,...n},Ee(c.project,c.titleLc)))]})},FO=({project:e,titleLc:t,tabSelector:r,selected:o})=>{let n=U(()=>r(Ee(e,t)),[e,t]),s=hn(e);return d("button",{type:"button",role:"tab","aria-selected":o,"data-theme":s,tabIndex:-1,onClick:n,children:e})},DO=({selected:e,...t})=>{let r=hn(t.project);return d("div",{role:"tabpanel","data-theme":r,hidden:!e,children:d(Fx,{...t})})};var jx=So("ScrapBubble:Bubble.tsx"),Bx=({source:e,parentTitles:t,whiteList:r,...o})=>{let n=H(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,i,a]=$O(e,n,r,t);return d(ee,{children:[UO(a)&&d($x,{pages:a,source:e,whiteList:r,onClick:o.hide,...o}),d(Ix,{linked:s,externalLinked:i,onClick:o.hide,source:e,projectsForSort:n,...o})]})},UO=e=>e.length>0,$O=(e,t,r,o)=>{let[[n,s,i],a]=Q([new Map,new Map,[]]),c=H(()=>{let p=[...t].map(f=>Ee(f,e.title));return jx.debug("projects",p),p},[t,e.title]),l=Xn(c),u=H(()=>o.map(p=>ae(p)),[o]);return Sa(()=>{let p=new Map,f=new Map,m=[];for(let h of l){let g={project:h.project,titleLc:h.titleLc};for(let x of h.projectLinked??[]){let{project:w,titleLc:k}=cc(x);u.includes(k)&&r.has(w)||f.has(x)||f.set(x,g)}if(!r.has(h.project))continue;let y={titleLc:h.titleLc};for(let x of h.linked??[]){if(u.includes(x))continue;let w=Ee(h.project,x);p.has(w)||p.set(w,y)}u.includes(h.titleLc)||h.exists&&m.push(h)}a(gc(h=>{jx.debug(depth: ${u.length}, bubbled from ${Ee(e.project,e.title)}, bubbles,,l,"before",h[0],"internal cards,",p,"external cards",f);for(let g of h[0].keys())p.has(g)||h[0].delete(g);for(let[g,y]of p)h[0].set(g,y);for(let g of h[1].keys())f.has(g)||h[1].delete(g);for(let[g,y]of f)h[1].set(g,y);h[2]=m}))},[l,r,u]),[n,s,i]};var Hx=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(o){if(!(o instanceof TypeError))throw o;return e}}};var Wx=e=>{let t=H(()=>Hx(e.style,import.meta.url),[e.style]);return d(ee,{children:t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",{children:t}))})};var qx=String.raw*{box-sizing:border-box}a{background-color:transparent;text-decoration:none;cursor:pointer}img{display:inline-block;max-width:100%;max-height:100px}code{font-family:var(--code-text-font, Menlo, Monaco, Consolas, "Courier New", monospace);font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}blockquote{background-color:var(--quote-bg-color, rgba(0,0,0,.05));display:block;border-left:solid 4px #a0a0a0;padding-left:4px;margin:0}strong{font-weight:700}iframe{display:inline-block;margin:3px 0;vertical-align:middle;max-width:100%;width:640px;height:360px;border:0}audio{display:inline-block;vertical-align:middle;white-space:initial;max-width:100%}.formula{margin:auto 6px}.formula.error code{color:#fd7373}.katex-display{display:inline-block!important;margin:0!important;text-align:inherit!important}.error .katex-display{display:none}.cli{border-radius:4px}.cli .prefix{color:#9c6248}.helpfeel{background-color:#fbebdd;border-radius:4px;padding:3px!important}.helpfeel .prefix{color:#f17c00}.helpfeel .entry{color:#cc5020}.code-block{display:block;line-height:1.7em;background-color:var(--code-bg, rgba(0,0,0,.04))}.code-block-start{font-family:Menlo,Monaco,Consolas,Courier New,monospace;color:#342d9c;background-color:#ffcfc6;font-size:.9em;padding:1px 2px}.code-block-start a{color:#342d9c;text-decoration:underline}code.code-block,.table-block.table-block-row{padding-left:1em}.copy{font-family:"Font Awesome 5 Free";cursor:pointer}.table-block{white-space:nowrap}.table-block-start{padding:1px 2px;font-size:.9em;background-color:#ffcfc6}.table-block-start a{color:#342d9c;text-decoration:underline}.cell{margin:0;padding:0 2px 0 8px;box-sizing:content-box;display:inline-block;white-space:pre}.cell:nth-child(odd){background-color:#0000000a}.cell:nth-child(2n){background-color:#0000000f}.strong-image{max-height:100%}.icon{height:11px;vertical-align:middle}.strong-icon{height:13.2px}.tool-button{margin-left:1em;cursor:pointer;font-size:.9em}.deco-\/{font-style:italic}.deco-\*-1{font-weight:700}.deco-\*-2{font-weight:700;font-size:1.2em}.deco-\*-3{font-weight:700;font-size:1.44em}.deco-\*-4{font-weight:700;font-size:1.73em}.deco-\*-5{font-weight:700;font-size:2.07em}.deco-\*-6{font-weight:700;font-size:2.49em}.deco-\*-7{font-weight:700;font-size:3em}.deco-\*-8{font-weight:700;font-size:3.58em}.deco-\*-9{font-weight:700;font-size:4.3em}.deco-\*-10{font-weight:700;font-size:5.16em}.deco--{text-decoration:line-through}.deco-_{text-decoration:underline}.page-link{color:var(--page-link-color, #5e8af7)}a.page-link:hover{color:var(--page-link-hover-color, #2d67f5)}.empty-page-link{color:var(--empty-page-link-color, #fd7373)}a.empty-page-link:hover{color:var(--empty-page-link-hover-color, #fd7373)}.link{color:var(--page-link-color, #5e8af7);text-decoration:underline}a.link:hover{color:var(--page-link-color-hover-color, #2d67f5)}.link img{padding-bottom:3px;border-style:none none solid;border-width:1.5px;border-color:#8fadf9}.permalink{background-color:var(--line-permalink-color, rgba(234,218,74,.75))}.status-bar{display:inline-block;position:absolute;background-color:var(--page-bg, #fefefe);cursor:default}.status-bar>*{border:1px solid var(--status-bar-border-color, #a9aaaf)}.status-bar.top-left{top:0;left:0}.status-bar.top-left>*{border-top:none;border-left:none}.status-bar.top-left :last-of-type{border-bottom-right-radius:3px}.status-bar.top-right{top:0;right:0}.status-bar.top-right>*{border-top:none;border-right:none}.status-bar.top-right :last-of-type{border-bottom-left-radius:3px}.status-bar.bottom-right{bottom:0;right:0}.status-bar.bottom-right>*{border-bottom:none;border-right:none}.status-bar.bottom-right :last-of-type{border-top-left-radius:3px}.status-bar.bottom-left{bottom:0;left:0}.status-bar.bottom-left>*{border-bottom:none;border-left:none}.status-bar.bottom-left :last-of-type{border-top-right-radius:3px}.text-bubble{font-size:11px;line-height:1.42857;user-select:text;position:absolute;color:var(--page-text-color, #4a4a4a);box-shadow:0 6px 12px #0000002d;display:flex;flex-direction:column;z-index:9000;&.no-scroll{overflow-y:hidden}data-theme=default-dark{--text-bubble-border-color: hsl(0, 0%, 39%)}data-theme=default-minimal{--text-bubble-border-color: hsl(0, 0%, 89%)}data-theme=paper-light{--text-bubble-border-color: hsl(53, 8%, 58%)}data-theme=paper-dark-dark{--text-bubble-border-color: hsl(203, 42%, 17%)}data-theme=blue{--text-bubble-border-color: hsl(227, 68%, 62%)}data-theme=purple{--text-bubble-border-color: hsl(267, 39%, 60%)}data-theme=green{--text-bubble-border-color: hsl(136, 29%, 50%)}data-theme=orange{--text-bubble-border-color: hsl(43, 71%, 51%)}data-theme=red{--text-bubble-border-color: hsl(4, 58%, 56%)}data-theme=spring{--text-bubble-border-color: hsl(72, 64%, 57%)}data-theme=kyoto{--text-bubble-border-color: hsl(331, 21%, 26%)}data-theme=newyork{--text-bubble-border-color: hsl(176, 29%, 67%)}role=tabpanel{padding:5px 0 5px 5px;border-radius:4px;background-color:var(--page-bg, #fefefe);max-height:80vh;overflow-y:auto}role=tabpanel,button{border:1px solid var(--text-bubble-border-color, hsl(221, 15%, 25%))}button{cursor:default;color:inherit;font-size:inherit;line-height:inherit;background-color:var(--page-bg, #fefefe);border-radius:4px 4px 0 0}buttonaria-selected=true{background-color:var(--text-bubble-border-color, hsl(221, 15%, 25%))}}.project-badge{text-decoration:none;color:var(--tool-text-color, #363c49)}.related-page-carddata-theme=default-dark{--card-title-bg: hsl(0, 0%, 39%)}.related-page-carddata-theme=default-minimal{--card-title-bg: hsl(0, 0%, 89%)}.related-page-carddata-theme=paper-light{--card-title-bg: hsl(53, 8%, 58%)}.related-page-carddata-theme=paper-dark-dark{--card-title-bg: hsl(203, 42%, 17%)}.related-page-carddata-theme=blue{--card-title-bg: hsl(227, 68%, 62%)}.related-page-carddata-theme=purple{--card-title-bg: hsl(267, 39%, 60%)}.text-bubbledata-theme=green{--card-title-bg: hsl(136, 29%, 50%)}.related-page-carddata-theme=orange{--card-title-bg: hsl(43, 71%, 51%)}.related-page-carddata-theme=red{--card-title-bg: hsl(4, 58%, 56%)}.related-page-carddata-theme=spring{--card-title-bg: hsl(72, 64%, 57%)}.related-page-carddata-theme=kyoto{--card-title-bg: hsl(331, 21%, 26%)}.related-page-carddata-theme=newyork{--card-title-bg: hsl(176, 29%, 67%)}.related-page-card{display:block;position:relative;height:inherit;width:inherit;overflow:hidden;text-overflow:ellipsis;font-family:Roboto,Helvetica,Arial,Hiragino Sans,sans-serif;background-color:var(--card-bg, #fff);color:var(--card-title-color, #555);word-break:break-word;text-decoration:none}.related-page-card:hover{box-shadow:var(--card-box-hover-shadow, 0 2px 0 rgba(0,0,0,.23))}.related-page-card:focus{outline:0;box-shadow:0 0 0 3px #66afe999;border-color:#66afe9;transition:border-color ease-in-out .15s,box-shadow ease-in-out .15s}.related-page-card.hover{opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;background-color:var(--card-hover-bg, rgba(0,0,0,.05));mix-blend-mode:multiply;z-index:1;transition:background-color .1s}.related-page-card:hover .hover{opacity:1}.related-page-card:active .hover{opacity:1;background-color:var(--card-active-bg, rgba(0,0,0,.1))}.related-page-card .content{height:calc(100% - 5px);width:inherit;display:flex;flex-direction:column;overflow:hidden}.related-page-card .content .header{width:100%;color:#396bdd;text-overflow:ellipsis;border-top:var(--card-title-bg, #f2f2f3) solid 10px;padding:8px 10px}.related-page-card .content .header .title{font-size:11px;line-height:16px;font-weight:700;max-height:48px;color:var(--card-title-color, #363c49);margin:0;overflow:hidden;display:block;-webkit-line-clamp:3;-webkit-box-orient:vertical;text-overflow:ellipsis}.related-page-card .content .description{line-height:16px;padding:8px 10px 0;font-size:10px;white-space:pre-line;column-count:1;column-gap:2em;column-width:10em;height:inherit;color:var(--card-description-color, gray);flex-shrink:16;overflow:hidden}.related-page-card .content .thumbnail{display:block;width:100%;margin:0 auto;padding:0 5px}.related-page-card .content .description p{margin:0;display:block}.related-page-card .content .description code{font-family:Menlo,Monaco,Consolas,Courier New,monospace;font-size:90%;color:var(--code-color, #342d9c);background-color:var(--code-bg, rgba(0,0,0,.04));padding:0;white-space:pre-wrap;word-wrap:break-word}.related-page-card .content .description .icon{height:9px;vertical-align:middle}.related-page-card .content .description .page-link{background-color:transparent;text-decoration:none;cursor:pointer;color:var(--page-link-color, #5e8af7)}.card-bubble{background-color:var(--page-bg, #FFF);box-shadow:0 2px 2px #00000024,0 3px 1px -2px #0003,0 1px 5px #0000001f;position:absolute;max-width:80vw;box-sizing:content-box;z-index:9000;font-size:11px;line-height:1.42857;display:flex;padding:0;margin:0;list-style:none;overflow-x:auto;overflow-y:visible}.card-bubble li{display:block;position:relative;float:none;margin:5px;box-sizing:border-box;box-shadow:var(--card-box-shadow, 0 2px 0 rgba(0,0,0,.12));border-radius:2px;width:120px;height:120px}
;var Gx=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),Ec=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var zx=()=>{let[e,t]=Q([{bubble:o=>r(0,o),hide:()=>r(0)}]),r=U((o,n)=>{t(([s,...i])=>[s,...n?[...i.slice(0,o),n===i.at(o)?.source?i.at(o):{source:n,parentTitles:[scrapbox.Page.title??"",...i.slice(0,o).map(a=>a.source.title)],bubble:a=>r(o+1,a),hide:()=>r(o+1)}]:[...i.slice(0,o)]])},[]);return e};var um=(e,t,r,o,n)=>{te(()=>(e.addEventListener(t,r,o),()=>e.removeEventListener(t,r,o)),[e,t,o,...n??[]])};var mm="scrap-bubble",Vx=({delay:e,whiteList:t,watchList:r,style:o})=>{let[{bubble:n,hide:s},...i]=zx(),a=U((c,l)=>Mx(l,t.has(c)?t:new Set([c]),r),[t,r]);return um(document,"pointerenter",async c=>{let l=c.target;if(!Ec(l)&&!Gx(l))return;let{project:u=scrapbox.Project.name,title:p,hash:f=""}=Ec(l)?Jn({pathType:"root",href:${new URL(l.href).pathname}${new URL(l.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(u==="")return;let m=decodeURIComponent(p??"");a(u,m),await zn(l,e)&&n({project:u,title:m,hash:f,position:Vn(l),type:jO(l)})},{capture:!0},[e,t,r]),um(document,"click",c=>{c.target.dataset.userscriptName!==mm&&s()},{capture:!0},[s]),te(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),d(ee,{children:[d("link",{rel:"stylesheet",href:https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${oc}/katex.min.css}),d("style",{children:qx}),d(Wx,{style:o}),i.map(c=>d(Bx,{...c,whiteList:t,delay:e,prefetch:a},Ee(c.source.project,c.source.title)))]})},jO=e=>Ec(e)?e.type==="link"?"link":"hashtag":"title";var Kx=async e=>{let{delay:t=500,whiteList:r=[],watchList:o=(await Xy()).slice(0,100),style:n="",debug:s=!1}=e??{};ox(s);let i=document.createElement("div");i.dataset.userscriptName=mm,document.body.append(i);let a=i.attachShadow({mode:"open"});vt(d(Vx,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(o),style:n}),a)};var BO=["takker-memex","takker-private","takker","takker-books","villagepump"],yn=[];switch(scrapbox.Project.name){case"hub":case"villagepump":case"verbalizing-community":yn.push("villagepump","hub","verbalizing-community");break;case"programming-notes":case"customize":case"scrapboxlab":yn.push("programming-notes","customize","scrapboxlab");break;case"sta":yn.push("sta-taskmanagement");break;case"sta-taskmanagement":case"taskmanagement":yn.push("sta-taskmanagement","taskmanagement");break;case"plurality-japanese":yn.push("nishio","tkgshn");case"takker-books":yn.push("work4ai");break}Kx({delay:/mobile/i.test(navigator.userAgent)?300:500,whiteList:[...BO,...yn],style:@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";
@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";});var Yx=e=>{{let r=e.match(/^([^(]+)\(([^)]+)\)$/);if(r)return{fileName:r[1],lang:r[2]}}let t=e.split(".").pop();return t===void 0?{fileName:e,lang:e}:{fileName:e,lang:t}};var es={};Ki(es,{getTitle:()=>Oh,parse:()=>at});var Xx=(e,t,r)=>{if(r.length===0)return[];let o=r.map(a=>a.text).join(
),n=at(o,{hasTitle:!0}),s=new Map,i=0;for(let a of n)switch(a.type){case"title":case"line":{i++;break}case"table":i+=a.cells.length+1;break;case"codeBlock":{let{fileName:c,lang:l}=Yx(a.fileName),u=s.get(c);s.set(c,{path:u?.path??https://scrapbox.io/api/code/${e}/${ne(t)}/${ne(c)},lang:u?.lang??l,startIds:[...u?.startIds??[],r[i].id]}),i+=a.content.split(
).length+1;break}}return s.values()};function dm(e){let t=o=>{if(o===null)r.write8(0);else if(typeof o=="boolean")r.write8(1),r.write8(+o);else if(typeof o=="number")r.write8(2),r.write32(o|0);else if(typeof o=="string")r.write8(3),r.write(Tr(o));else if(o instanceof Uint8Array)r.write8(4),r.write(o);else if(o instanceof Array){r.write8(5),r.write32(o.length);for(let n of o)t(n)}else{let n=Object.keys(o);r.write8(6),r.write32(n.length);for(let s of n)r.write(Tr(s)),t(o[s])}},r=new wc;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),fm(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Jx(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ts(r.read());case 4:return r.read();case 5:{let i=r.read32(),a=[];for(let c=0;c<i;c++)a.push(t());return a}case 6:{let i=r.read32(),a={};for(let c=0;c<i;c++)a[ts(r.read())]=t();return a}default:throw new Error("Invalid packet")}},r=new wc(e),o=r.read32(),n=(o&1)===0;o>>>=1;let s=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:n,value:s}}var wc=class{constructor(t=new Uint8Array(1024)){this.buf=t}len=0;ptr=0;_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);fm(this.buf,t,r)}write(t){let r=this._write(4+t.length);fm(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return hm(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),o=this._read(r.length);return r.set(this.buf.subarray(o,o+t)),r}},Tr,ts,Qx;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;Tr=r=>e.encode(r),ts=r=>t.decode(r),Qx='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(Tr("")instanceof Uint8Array))throw new Error(Invariant violation: "${Qx} instanceof Uint8Array" is incorrectly false
This indicates that your JavaScript environment is broken. You cannot use
esbuild in this environment because esbuild relies on this invariant. This
is not a problem with esbuild. You need to fix your environment instead.
);function hm(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function fm(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var di="0.24.0";var pt=JSON.stringify,Zx="warning",eb="silent";function tb(e){if(Pt(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var vc=()=>null,Ue=e=>typeof e=="boolean"?null:"a boolean",V=e=>typeof e=="string"?null:"a string",Tc=e=>e instanceof RegExp?null:"a RegExp object",bn=e=>typeof e=="number"&&e===(e|0)?null:"an integer",nb=e=>typeof e=="function"?null:"a function",We=e=>Array.isArray(e)?null:"an array",mr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",WO=e=>typeof e=="object"&&e!==null?null:"an array or an object";var rb=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",sb=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",qO=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",GO=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ib=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function R(e,t,r,o){let n=e[r];if(t[r+""]=!0,n===void 0)return;let s=o(n);if(s!==null)throw new Error(${pt(r)} must be ${s});return n}function wt(e,t,r){for(let o in e)if(!(o in t))throw new Error(Invalid option ${r}: ${pt(o)})}function ab(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let o=e[r];if(typeof o=="string"||o===!1)t[r]=o;else throw new Error(Expected ${pt(r)} in mangle cache to map to either a string or false)}}return t}function _c(e,t,r,o,n){let s=R(t,r,"color",Ue),i=R(t,r,"logLevel",V),a=R(t,r,"logLimit",bn);s!==void 0?e.push(--color=${s}):o&&e.push("--color=true"),e.push(--log-level=${i||n}),e.push(--log-limit=${a||0})}function Pt(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+pt(r):""} to be a string, got ${typeof e} instead);return e}function cb(e,t,r){let o=R(t,r,"legalComments",V),n=R(t,r,"sourceRoot",V),s=R(t,r,"sourcesContent",Ue),i=R(t,r,"target",GO),a=R(t,r,"format",V),c=R(t,r,"globalName",V),l=R(t,r,"mangleProps",Tc),u=R(t,r,"reserveProps",Tc),p=R(t,r,"mangleQuoted",Ue),f=R(t,r,"minify",Ue),m=R(t,r,"minifySyntax",Ue),h=R(t,r,"minifyWhitespace",Ue),g=R(t,r,"minifyIdentifiers",Ue),y=R(t,r,"lineLimit",bn),x=R(t,r,"drop",We),w=R(t,r,"dropLabels",We),k=R(t,r,"charset",V),b=R(t,r,"treeShaking",Ue),T=R(t,r,"ignoreAnnotations",Ue),v=R(t,r,"jsx",V),A=R(t,r,"jsxFactory",V),F=R(t,r,"jsxFragment",V),D=R(t,r,"jsxImportSource",V),N=R(t,r,"jsxDev",Ue),_=R(t,r,"jsxSideEffects",Ue),P=R(t,r,"define",mr),I=R(t,r,"logOverride",mr),$=R(t,r,"supported",mr),j=R(t,r,"pure",We),q=R(t,r,"keepNames",Ue),B=R(t,r,"platform",V),Y=R(t,r,"tsconfigRaw",qO);if(o&&e.push(--legal-comments=${o}),n!==void 0&&e.push(--source-root=${n}),s!==void 0&&e.push(--sources-content=${s}),i&&(Array.isArray(i)?e.push(--target=${Array.from(i).map(tb).join(",")}):e.push(--target=${tb(i)})),a&&e.push(--format=${a}),c&&e.push(--global-name=${c}),B&&e.push(--platform=${B}),Y&&e.push(--tsconfig-raw=${typeof Y=="string"?Y:JSON.stringify(Y)}),f&&e.push("--minify"),m&&e.push("--minify-syntax"),h&&e.push("--minify-whitespace"),g&&e.push("--minify-identifiers"),y&&e.push(--line-limit=${y}),k&&e.push(--charset=${k}),b!==void 0&&e.push(--tree-shaking=${b}),T&&e.push("--ignore-annotations"),x)for(let G of x)e.push(--drop:${Pt(G,"drop")});if(w&&e.push(--drop-labels=${Array.from(w).map(G=>Pt(G,"dropLabels")).join(",")}),l&&e.push(--mangle-props=${l.source}),u&&e.push(--reserve-props=${u.source}),p!==void 0&&e.push(--mangle-quoted=${p}),v&&e.push(--jsx=${v}),A&&e.push(--jsx-factory=${A}),F&&e.push(--jsx-fragment=${F}),D&&e.push(--jsx-import-source=${D}),N&&e.push("--jsx-dev"),_&&e.push("--jsx-side-effects"),P)for(let G in P){if(G.indexOf("=")>=0)throw new Error(Invalid define: ${G});e.push(--define:${G}=${Pt(PG,"define",G)})}if(I)for(let G in I){if(G.indexOf("=")>=0)throw new Error(Invalid log override: ${G});e.push(--log-override:${G}=${Pt(IG,"log override",G)})}if($)for(let G in $){if(G.indexOf("=")>=0)throw new Error(Invalid supported: ${G});let X=$[G];if(typeof X!="boolean")throw new Error(Expected value for supported ${pt(G)} to be a boolean, got ${typeof X} instead);e.push(--supported:${G}=${X})}if(j)for(let G of j)e.push(--pure:${Pt(G,"pure")});q&&e.push("--keep-names")}function zO(e,t,r,o,n){let s=[],i=[],a=Object.create(null),c=null,l=null;_c(s,t,a,r,o),cb(s,t,a);let u=R(t,a,"sourcemap",sb),p=R(t,a,"bundle",Ue),f=R(t,a,"splitting",Ue),m=R(t,a,"preserveSymlinks",Ue),h=R(t,a,"metafile",Ue),g=R(t,a,"outfile",V),y=R(t,a,"outdir",V),x=R(t,a,"outbase",V),w=R(t,a,"tsconfig",V),k=R(t,a,"resolveExtensions",We),b=R(t,a,"nodePaths",We),T=R(t,a,"mainFields",We),v=R(t,a,"conditions",We),A=R(t,a,"external",We),F=R(t,a,"packages",V),D=R(t,a,"alias",mr),N=R(t,a,"loader",mr),_=R(t,a,"outExtension",mr),P=R(t,a,"publicPath",V),I=R(t,a,"entryNames",V),$=R(t,a,"chunkNames",V),j=R(t,a,"assetNames",V),q=R(t,a,"inject",We),B=R(t,a,"banner",mr),Y=R(t,a,"footer",mr),G=R(t,a,"entryPoints",WO),X=R(t,a,"absWorkingDir",V),J=R(t,a,"stdin",mr),ue=R(t,a,"write",Ue)??n,oe=R(t,a,"allowOverwrite",Ue),kt=R(t,a,"mangleCache",mr);if(a.plugins=!0,wt(t,a,in ${e}() call),u&&s.push(--sourcemap${u===!0?"":=${u}}),p&&s.push("--bundle"),oe&&s.push("--allow-overwrite"),f&&s.push("--splitting"),m&&s.push("--preserve-symlinks"),h&&s.push("--metafile"),g&&s.push(--outfile=${g}),y&&s.push(--outdir=${y}),x&&s.push(--outbase=${x}),w&&s.push(--tsconfig=${w}),F&&s.push(--packages=${F}),k){let W=[];for(let we of k){if(Pt(we,"resolve extension"),we.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${we});W.push(we)}s.push(--resolve-extensions=${W.join(",")})}if(P&&s.push(--public-path=${P}),I&&s.push(--entry-names=${I}),$&&s.push(--chunk-names=${$}),j&&s.push(--asset-names=${j}),T){let W=[];for(let we of T){if(Pt(we,"main field"),we.indexOf(",")>=0)throw new Error(Invalid main field: ${we});W.push(we)}s.push(--main-fields=${W.join(",")})}if(v){let W=[];for(let we of v){if(Pt(we,"condition"),we.indexOf(",")>=0)throw new Error(Invalid condition: ${we});W.push(we)}s.push(--conditions=${W.join(",")})}if(A)for(let W of A)s.push(--external:${Pt(W,"external")});if(D)for(let W in D){if(W.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${W});s.push(--alias:${W}=${Pt(DW,"alias",W)})}if(B)for(let W in B){if(W.indexOf("=")>=0)throw new Error(Invalid banner file type: ${W});s.push(--banner:${W}=${Pt(BW,"banner",W)})}if(Y)for(let W in Y){if(W.indexOf("=")>=0)throw new Error(Invalid footer file type: ${W});s.push(--footer:${W}=${Pt(YW,"footer",W)})}if(q)for(let W of q)s.push(--inject:${Pt(W,"inject")});if(N)for(let W in N){if(W.indexOf("=")>=0)throw new Error(Invalid loader extension: ${W});s.push(--loader:${W}=${Pt(NW,"loader",W)})}if(_)for(let W in _){if(W.indexOf("=")>=0)throw new Error(Invalid out extension: ${W});s.push(--out-extension:${W}=${Pt(_W,"out extension",W)})}if(G)if(Array.isArray(G))for(let W=0,we=G.length;W<we;W++){let Nt=G[W];if(typeof Nt=="object"&&Nt!==null){let Hr=Object.create(null),Wr=R(Nt,Hr,"in",V),Or=R(Nt,Hr,"out",V);if(wt(Nt,Hr,"in entry point at index "+W),Wr===void 0)throw new Error('Missing property "in" for entry point at index '+W);if(Or===void 0)throw new Error('Missing property "out" for entry point at index '+W);i.push([Or,Wr])}else i.push(["",Pt(Nt,"entry point at index "+W)])}else for(let W in G)i.push([W,Pt(G[W],"entry point",W)]);if(J){let W=Object.create(null),we=R(J,W,"contents",ib),Nt=R(J,W,"resolveDir",V),Hr=R(J,W,"sourcefile",V),Wr=R(J,W,"loader",V);wt(J,W,'in "stdin" object'),Hr&&s.push(--sourcefile=${Hr}),Wr&&s.push(--loader=${Wr}),Nt&&(l=Nt),typeof we=="string"?c=Tr(we):we instanceof Uint8Array&&(c=we)}let Se=[];if(b)for(let W of b)W+="",Se.push(W);return{entries:i,flags:s,write:ue,stdinContents:c,stdinResolveDir:l,absWorkingDir:X,nodePaths:Se,mangleCache:ab(kt)}}function VO(e,t,r,o){let n=[],s=Object.create(null);_c(n,t,s,r,o),cb(n,t,s);let i=R(t,s,"sourcemap",sb),a=R(t,s,"sourcefile",V),c=R(t,s,"loader",V),l=R(t,s,"banner",V),u=R(t,s,"footer",V),p=R(t,s,"mangleCache",mr);return wt(t,s,in ${e}() call),i&&n.push(--sourcemap=${i===!0?"external":i}),a&&n.push(--sourcefile=${a}),c&&n.push(--loader=${c}),l&&n.push(--banner=${l}),u&&n.push(--footer=${u}),{flags:n,mangleCache:ab(p)}}function lb(e){let t={},r={didClose:!1,reason:""},o={},n=0,s=0,i=new Uint8Array(16*1024),a=0,c=k=>{let b=a+k.length;if(b>i.length){let v=new Uint8Array(b*2);v.set(i),i=v}i.set(k,a),a+=k.length;let T=0;for(;T+4<=a;){let v=hm(i,T);if(T+4+v>a)break;T+=4,h(i.subarray(T,T+v)),T+=v}T>0&&(i.copyWithin(0,T,a),a-=T)},l=k=>{r.didClose=!0,k&&(r.reason=": "+(k.message||k));let b="The service was stopped"+r.reason;for(let T in o)o[T](b,null);o={}},u=(k,b,T)=>{if(r.didClose)return T("The service is no longer running"+r.reason,null);let v=n++;o[v]=(A,F)=>{try{T(A,F)}finally{k&&k.unref()}},k&&k.ref(),e.writeToStdin(dm({id:v,isRequest:!0,value:b}))},p=(k,b)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(dm({id:k,isRequest:!1,value:b}))},f=async(k,b)=>{try{if(b.command==="ping"){p(k,{});return}if(typeof b.key=="number"){let T=t[b.key];if(!T)return;let v=T[b.command];if(v){await v(k,b);return}}throw new Error("Invalid command: "+b.command)}catch(T){let v=[xn(T,e,null,void 0,"")];try{p(k,{errors:v})}catch{}}},m=!0,h=k=>{if(m){m=!1;let T=String.fromCharCode(...k);if(T!==di)throw new Error(Cannot start service: Host version "${di}" does not match binary version ${pt(T)});return}let b=Jx(k);if(b.isRequest)f(b.id,b.value);else{let T=o[b.id];delete o[b.id],b.value.error?T(b.value.error,{}):T(null,b.value)}};return{readFromStdout:c,afterClose:l,service:{buildOrContext:({callName:k,refs:b,options:T,isTTY:v,defaultWD:A,callback:F})=>{let D=0,N=s++,_={},P={ref(){++D===1&&b&&b.ref()},unref(){--D===0&&(delete t[N],b&&b.unref())}};t[N]=_,P.ref(),KO(k,N,u,p,P,e,_,T,v,A,(I,$)=>{try{F(I,$)}finally{P.unref()}})},transform:({callName:k,refs:b,input:T,options:v,isTTY:A,fs:F,callback:D})=>{let N=pb(),_=P=>{try{if(typeof T!="string"&&!(T instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:I,mangleCache:$}=VO(k,v,A,eb),j={command:"transform",flags:I,inputFS:P!==null,input:P!==null?Tr(P):typeof T=="string"?Tr(T):T};$&&(j.mangleCache=$),u(b,j,(q,B)=>{if(q)return D(new Error(q),null);let Y=rs(B.errors,N),G=rs(B.warnings,N),X=1,J=()=>{if(--X===0){let ue={warnings:G,code:B.code,map:B.map,mangleCache:void 0,legalComments:void 0};"legalComments"in B&&(ue.legalComments=B?.legalComments),B.mangleCache&&(ue.mangleCache=B?.mangleCache),D(null,ue)}};if(Y.length>0)return D(hi("Transform failed",Y,G),null);B.codeFS&&(X++,F.readFile(B.code,(ue,oe)=>{ue!==null?D(ue,null):(B.code=oe,J())})),B.mapFS&&(X++,F.readFile(B.map,(ue,oe)=>{ue!==null?D(ue,null):(B.map=oe,J())})),J()})}catch(I){let $=[];try{_c($,v,{},A,eb)}catch{}let j=xn(I,e,N,void 0,"");u(b,{command:"error",flags:$,error:j},()=>{j.detail=N.load(j.detail),D(hi("Transform failed",[j],[]),null)})}};if((typeof T=="string"||T instanceof Uint8Array)&&T.length>1024*1024){let P=_;_=()=>F.writeFile(T,P)}_(null)},formatMessages:({callName:k,refs:b,messages:T,options:v,callback:A})=>{if(!v)throw new Error(Missing second argument in ${k}() call);let F={},D=R(v,F,"kind",V),N=R(v,F,"color",Ue),_=R(v,F,"terminalWidth",bn);if(wt(v,F,in ${k}() call),D===void 0)throw new Error(Missing "kind" in ${k}() call);if(D!=="error"&&D!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${k}() call);let P={command:"format-msgs",messages:oo(T,"messages",null,"",_),isWarning:D==="warning"};N!==void 0&&(P.color=N),_!==void 0&&(P.terminalWidth=_),u(b,P,(I,$)=>{if(I)return A(new Error(I),null);A(null,$.messages)})},analyzeMetafile:({callName:k,refs:b,metafile:T,options:v,callback:A})=>{v===void 0&&(v={});let F={},D=R(v,F,"color",Ue),N=R(v,F,"verbose",Ue);wt(v,F,in ${k}() call);let _={command:"analyze-metafile",metafile:T};D!==void 0&&(_.color=D),N!==void 0&&(_.verbose=N),u(b,_,(P,I)=>{if(P)return A(new Error(P),null);A(null,I.result)})}}}}function KO(e,t,r,o,n,s,i,a,c,l,u){let p=pb(),f=e==="context",m=(y,x)=>{let w=[];try{_c(w,a,{},c,Zx)}catch{}let k=xn(y,s,p,void 0,x);r(n,{command:"error",flags:w,error:k},()=>{k.detail=p.load(k.detail),u(hi(f?"Context failed":"Build failed",[k],[]),null)})},h;if(typeof a=="object"){let y=a.plugins;if(y!==void 0){if(!Array.isArray(y))return m(new Error('"plugins" must be an array'),"");h=y}}if(h&&h.length>0){if(s.isSync)return m(new Error("Cannot use plugins in synchronous API calls"),"");YO(t,r,o,n,s,i,a,h,p).then(y=>{if(!y.ok)return m(y.error,y.pluginName);try{g(y.requestPlugins,y.runOnEndCallbacks,y.scheduleOnDisposeCallbacks)}catch(x){m(x,"")}},y=>m(y,""));return}try{g(null,(y,x)=>x([],[]),()=>{})}catch(y){m(y,"")}function g(y,x,w){let k=s.hasFS,{entries:b,flags:T,write:v,stdinContents:A,stdinResolveDir:F,absWorkingDir:D,nodePaths:N,mangleCache:_}=zO(e,a,c,Zx,k);if(v&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let P={command:"build",key:t,entries:b,flags:T,write:v,stdinContents:A,stdinResolveDir:F,absWorkingDir:D||l,nodePaths:N,context:f};y&&(P.plugins=y),_&&(P.mangleCache=_);let I=(q,B)=>{let Y={errors:rs(q.errors,p),warnings:rs(q.warnings,p),outputFiles:void 0,metafile:void 0,mangleCache:void 0},G=Y.errors.slice(),X=Y.warnings.slice();q.outputFiles&&(Y.outputFiles=q.outputFiles.map(JO)),q.metafile&&(Y.metafile=JSON.parse(q.metafile)),q.mangleCache&&(Y.mangleCache=q.mangleCache),q.writeToStdout!==void 0&&console.log(ts(q.writeToStdout).replace(/\n$/,"")),x(Y,(J,ue)=>{if(G.length>0||J.length>0){let oe=hi("Build failed",G.concat(J),X.concat(ue));return B(oe,null,J,ue)}B(null,Y,J,ue)})},$,j;f&&(i["on-end"]=(q,B)=>new Promise(Y=>{I(B,(G,X,J,ue)=>{let oe={errors:J,warnings:ue};j&&j(G,X),$=void 0,j=void 0,o(q,oe),Y()})})),r(n,P,(q,B)=>{if(q)return u(new Error(q),null);if(!f)return I(B,(X,J)=>(w(),u(X,J)));if(B.errors.length>0)return u(hi("Context failed",B.errors,B.warnings),null);let Y=!1,G={rebuild:()=>($||($=new Promise((X,J)=>{let ue;j=(kt,Se)=>{ue||(ue=()=>kt?J(kt):X(Se))};let oe=()=>{r(n,{command:"rebuild",key:t},(Se,W)=>{Se?J(new Error(Se)):ue?ue():oe()})};oe()})),$),watch:(X={})=>new Promise((J,ue)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');wt(X,{},"in watch() call"),r(n,{command:"watch",key:t},Se=>{Se?ue(new Error(Se)):J(void 0)})}),serve:(X={})=>new Promise((J,ue)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let oe={},kt=R(X,oe,"port",bn),Se=R(X,oe,"host",V),W=R(X,oe,"servedir",V),we=R(X,oe,"keyfile",V),Nt=R(X,oe,"certfile",V),Hr=R(X,oe,"fallback",V),Wr=R(X,oe,"onRequest",nb);wt(X,oe,"in serve() call");let Or={command:"serve",key:t,onRequest:!!Wr};kt!==void 0&&(Or.port=kt),Se!==void 0&&(Or.host=Se),W!==void 0&&(Or.servedir=W),we!==void 0&&(Or.keyfile=we),Nt!==void 0&&(Or.certfile=Nt),Hr!==void 0&&(Or.fallback=Hr),r(n,Or,(id,_T)=>{if(id)return ue(new Error(id));Wr&&(i["serve-request"]=(PT,OT)=>{Wr(OT.args),o(PT,{})}),J(_T)})}),cancel:()=>new Promise(X=>{if(Y)return X();r(n,{command:"cancel",key:t},()=>{X()})}),dispose:()=>new Promise(X=>{if(Y)return X();Y=!0,r(n,{command:"dispose",key:t},()=>{X(),w(),n.unref()})})};n.ref(),u(null,G)})}}var YO=async(e,t,r,o,n,s,i,a,c)=>{let l=[],u=[],p={},f={},m=[],h=0,g=0,y=[],x=!1;a=[...a];for(let b of a){let T={};if(typeof b!="object")throw new Error(Plugin at index ${g} must be an object);let v=R(b,T,"name",V);if(typeof v!="string"||v==="")throw new Error(Plugin at index ${g} is missing a name);try{let A=R(b,T,"setup",nb);if(typeof A!="function")throw new Error("Plugin is missing a setup function");wt(b,T,on plugin ${pt(v)});let F={name:v,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};g++;let N=A({initialOptions:i,resolve:(_,P={})=>{if(!x)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof _!="string")throw new Error("The path to resolve must be a string");let I=Object.create(null),$=R(P,I,"pluginName",V),j=R(P,I,"importer",V),q=R(P,I,"namespace",V),B=R(P,I,"resolveDir",V),Y=R(P,I,"kind",V),G=R(P,I,"pluginData",vc),X=R(P,I,"with",mr);return wt(P,I,"in resolve() call"),new Promise((J,ue)=>{let oe={command:"resolve",path:_,key:e,pluginName:v};if($!=null&&(oe.pluginName=$),j!=null&&(oe.importer=j),q!=null&&(oe.namespace=q),B!=null&&(oe.resolveDir=B),Y!=null)oe.kind=Y;else throw new Error('Must specify "kind" when calling "resolve"');G!=null&&(oe.pluginData=c.store(G)),X!=null&&(oe.with=XO(X,"with")),t(o,oe,(kt,Se)=>{kt!==null?ue(new Error(kt)):J({errors:rs(Se.errors,c),warnings:rs(Se.warnings,c),path:Se.path,external:Se.external,sideEffects:Se.sideEffects,namespace:Se.namespace,suffix:Se.suffix,pluginData:c.load(Se.pluginData)})})})},onStart(_){let P='This error came from the "onStart" callback registered here:',I=Rc(new Error(P),n,"onStart");l.push({name:v,callback:_,note:I}),F.onStart=!0},onEnd(_){let P='This error came from the "onEnd" callback registered here:',I=Rc(new Error(P),n,"onEnd");u.push({name:v,callback:_,note:I}),F.onEnd=!0},onResolve(_,P){let I='This error came from the "onResolve" callback registered here:',$=Rc(new Error(I),n,"onResolve"),j={},q=R(_,j,"filter",Tc),B=R(_,j,"namespace",V);if(wt(_,j,in onResolve() call for plugin ${pt(v)}),q==null)throw new Error("onResolve() call is missing a filter");let Y=h++;p[Y]={name:v,callback:P,note:$},F.onResolve.push({id:Y,filter:q.source,namespace:B||""})},onLoad(_,P){let I='This error came from the "onLoad" callback registered here:',$=Rc(new Error(I),n,"onLoad"),j={},q=R(_,j,"filter",Tc),B=R(_,j,"namespace",V);if(wt(_,j,in onLoad() call for plugin ${pt(v)}),q==null)throw new Error("onLoad() call is missing a filter");let Y=h++;f[Y]={name:v,callback:P,note:$},F.onLoad.push({id:Y,filter:q.source,namespace:B||""})},onDispose(_){m.push(_)},esbuild:n.esbuild});N&&await N,y.push(F)}catch(A){return{ok:!1,error:A,pluginName:v}}}s["on-start"]=async(b,T)=>{c.clear();let v={errors:[],warnings:[]};await Promise.all(l.map(async({name:A,callback:F,note:D})=>{try{let N=await F();if(N!=null){if(typeof N!="object")throw new Error(Expected onStart() callback in plugin ${pt(A)} to return an object);let _={},P=R(N,_,"errors",We),I=R(N,_,"warnings",We);wt(N,_,from onStart() callback in plugin ${pt(A)}),P!=null&&v.errors.push(...oo(P,"errors",c,A,void 0)),I!=null&&v.warnings.push(...oo(I,"warnings",c,A,void 0))}}catch(N){v.errors.push(xn(N,n,c,D&&D(),A))}})),r(b,v)},s["on-resolve"]=async(b,T)=>{let v={},A="",F,D;for(let N of T.ids)try{({name:A,callback:F,note:D}=p[N]);let _=await F({path:T.path,importer:T.importer,namespace:T.namespace,resolveDir:T.resolveDir,kind:T.kind,pluginData:c.load(T.pluginData),with:T.with});if(_!=null){if(typeof _!="object")throw new Error(Expected onResolve() callback in plugin ${pt(A)} to return an object);let P={},I=R(_,P,"pluginName",V),$=R(_,P,"path",V),j=R(_,P,"namespace",V),q=R(_,P,"suffix",V),B=R(_,P,"external",Ue),Y=R(_,P,"sideEffects",Ue),G=R(_,P,"pluginData",vc),X=R(_,P,"errors",We),J=R(_,P,"warnings",We),ue=R(_,P,"watchFiles",We),oe=R(_,P,"watchDirs",We);wt(_,P,from onResolve() callback in plugin ${pt(A)}),v.id=N,I!=null&&(v.pluginName=I),$!=null&&(v.path=$),j!=null&&(v.namespace=j),q!=null&&(v.suffix=q),B!=null&&(v.external=B),Y!=null&&(v.sideEffects=Y),G!=null&&(v.pluginData=c.store(G)),X!=null&&(v.errors=oo(X,"errors",c,A,void 0)),J!=null&&(v.warnings=oo(J,"warnings",c,A,void 0)),ue!=null&&(v.watchFiles=kc(ue,"watchFiles")),oe!=null&&(v.watchDirs=kc(oe,"watchDirs"));break}}catch(_){v={id:N,errors:[xn(_,n,c,D&&D(),A)]};break}r(b,v)},s["on-load"]=async(b,T)=>{let v={},A="",F,D;for(let N of T.ids)try{({name:A,callback:F,note:D}=f[N]);let _=await F({path:T.path,namespace:T.namespace,suffix:T.suffix,pluginData:c.load(T.pluginData),with:T.with});if(_!=null){if(typeof _!="object")throw new Error(Expected onLoad() callback in plugin ${pt(A)} to return an object);let P={},I=R(_,P,"pluginName",V),$=R(_,P,"contents",ib),j=R(_,P,"resolveDir",V),q=R(_,P,"pluginData",vc),B=R(_,P,"loader",V),Y=R(_,P,"errors",We),G=R(_,P,"warnings",We),X=R(_,P,"watchFiles",We),J=R(_,P,"watchDirs",We);wt(_,P,from onLoad() callback in plugin ${pt(A)}),v.id=N,I!=null&&(v.pluginName=I),$ instanceof Uint8Array?v.contents=$:$!=null&&(v.contents=Tr($)),j!=null&&(v.resolveDir=j),q!=null&&(v.pluginData=c.store(q)),B!=null&&(v.loader=B),Y!=null&&(v.errors=oo(Y,"errors",c,A,void 0)),G!=null&&(v.warnings=oo(G,"warnings",c,A,void 0)),X!=null&&(v.watchFiles=kc(X,"watchFiles")),J!=null&&(v.watchDirs=kc(J,"watchDirs"));break}}catch(_){v={id:N,errors:[xn(_,n,c,D&&D(),A)]};break}r(b,v)};let w=(b,T)=>T([],[]);u.length>0&&(w=(b,T)=>{(async()=>{let v=[],A=[];for(let{name:F,callback:D,note:N}of u){let _,P;try{let I=await D(b);if(I!=null){if(typeof I!="object")throw new Error(Expected onEnd() callback in plugin ${pt(F)} to return an object);let $={},j=R(I,$,"errors",We),q=R(I,$,"warnings",We);wt(I,$,from onEnd() callback in plugin ${pt(F)}),j!=null&&(_=oo(j,"errors",c,F,void 0)),q!=null&&(P=oo(q,"warnings",c,F,void 0))}}catch(I){_=[xn(I,n,c,N&&N(),F)]}if(_){v.push(..._);try{b.errors.push(..._)}catch{}}if(P){A.push(...P);try{b.warnings.push(...P)}catch{}}}T(v,A)})()});let k=()=>{for(let b of m)setTimeout(()=>b(),0)};return x=!0,{ok:!0,requestPlugins:y,runOnEndCallbacks:w,scheduleOnDisposeCallbacks:k}};function pb(){let e=new Map,t=0;return{clear(){e.clear()},load(r){return e.get(r)},store(r){if(r===void 0)return-1;let o=t++;return e.set(o,r),o}}}function Rc(e,t,r){let o,n=!1;return()=>{if(n)return o;n=!0;try{let s=(e.stack+"").split(
);s.splice(1,1);let i=ub(t,s,r);if(i)return o={text:e.message,location:i},o}catch{}}}function xn(e,t,r,o,n){let s="Internal error",i=null;try{s=(e&&e.message||e)+""}catch{}try{i=ub(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:n,text:s,location:i,notes:o?[o]:[],detail:r?r.store(e):-1}}function ub(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let n=1;n<t.length;n++){let s=t[n];if(s.startsWith(o))for(s=s.slice(o.length);;){let i=/^(?:new |async )?\S+ \((.*)\)$/.exec(s);if(i){s=i[1];continue}if(i=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(s),i){s=i[1];continue}if(i=/^(\S+):(\d+):(\d+)$/.exec(s),i){let a;try{a=e.readFileSync(i[1],"utf8")}catch{break}let c=a.split(/\r\n|\r|\n|\u2028|\u2029/)[+i[2]-1]||"",l=+i[3]-1,u=c.slice(l,l+r.length)===r?r.length:0;return{file:i[1],namespace:"file",line:+i[2],column:Tr(c.slice(0,l)).length,length:Tr(c.slice(l,l+u)).length,lineText:c+
+t.slice(1).join(
),suggestion:""}}break}}return null}function hi(e,t,r){let o=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,o+1).map((s,i)=>{if(i===o)return
...;if(!s.location)return
error: ${s.text};let{file:a,line:c,column:l}=s.location,u=s.pluginName?plugin: ${s.pluginName} :"";return
${a}:${c}:${l}: ERROR: ${u}${s.text}}).join("");let n=new Error(e);for(let[s,i]of[["errors",t],["warnings",r]])Object.defineProperty(n,s,{configurable:!0,enumerable:!0,get:()=>i,set:a=>Object.defineProperty(n,s,{configurable:!0,enumerable:!0,value:a})});return n}function rs(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function ob(e,t,r){if(e==null)return null;let o={},n=R(e,o,"file",V),s=R(e,o,"namespace",V),i=R(e,o,"line",bn),a=R(e,o,"column",bn),c=R(e,o,"length",bn),l=R(e,o,"lineText",V),u=R(e,o,"suggestion",V);if(wt(e,o,t),l){let p=l.slice(0,(a&&a>0?a:0)+(c&&c>0?c:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(p)&&!/\n/.test(l)&&(l=p)}return{file:n||"",namespace:s||"",line:i||0,column:a||0,length:c||0,lineText:l||"",suggestion:u||""}}function oo(e,t,r,o,n){let s=[],i=0;for(let a of e){let c={},l=R(a,c,"id",V),u=R(a,c,"pluginName",V),p=R(a,c,"text",V),f=R(a,c,"location",rb),m=R(a,c,"notes",We),h=R(a,c,"detail",vc),g=in element ${i} of "${t}";wt(a,c,g);let y=[];if(m)for(let x of m){let w={},k=R(x,w,"text",V),b=R(x,w,"location",rb);wt(x,w,g),y.push({text:k||"",location:ob(b,g,n)})}s.push({id:l||"",pluginName:u||o,text:p||"",location:ob(f,g,n),notes:y,detail:r?r.store(h):-1}),i++}return s}function kc(e,t){let r=[];for(let o of e){if(typeof o!="string")throw new Error(${pt(t)} must be an array of strings);r.push(o)}return r}function XO(e,t){let r=Object.create(null);for(let o in e){let n=e[o];if(typeof n!="string")throw new Error(key ${pt(o)} in object ${pt(t)} must be a string);r[o]=n}return r}function JO({path:e,contents:t,hash:r}){let o=null;return{path:e,contents:t,hash:r,get text(){let n=this.contents;return(o===null||n!==t)&&(t=n,o=ts(n)),o}}}var fb=di,Oc=e=>Sc().build(e),db=(e,t)=>Sc().transform(e,t),hb=(e,t)=>Sc().formatMessages(e,t),gb=(e,t)=>Sc().analyzeMetafile(e,t);var En,mb,Pc,Sc=()=>{if(Pc)return Pc;throw En?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},Lc=e=>{let t=e.wasm,r=e.worker;if(En)throw new Error('Cannot call "initialize" more than once');return En=QO(t,r),En.catch(()=>{En=void 0}),En},QO=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),o,n,s=new Promise((c,l)=>{o=c,n=l});r.onmessage=({data:c})=>{r.onmessage=({data:l})=>i(l),c?n(c):o()},r.postMessage(e);let{readFromStdout:i,service:a}=lb({writeToStdin(c){r.postMessage(c)},isSync:!1,hasFS:!1,esbuild:{build:Oc,transform:db,formatMessages:hb,analyzeMetafile:gb,version:fb,initialize:Lc}});await s,mb=()=>{r.terminate(),En=void 0,mb=void 0,Pc=void 0},Pc={build:c=>new Promise((l,u)=>a.buildOrContext({callName:"build",refs:null,options:c,isTTY:!1,defaultWD:"/",callback:(p,f)=>p?u(p):l(f)})),transform:(c,l)=>new Promise((u,p)=>a.transform({callName:"transform",refs:null,input:c,options:l||{},isTTY:!1,fs:{readFile(f,m){m(new Error("Internal error"),null)},writeFile(f,m){m(null)}},callback:(f,m)=>f?p(f):u(m)})),formatMessages:(c,l)=>new Promise((u,p)=>a.formatMessages({callName:"formatMessages",refs:null,messages:c,options:l,callback:(f,m)=>f?p(f):u(m)})),analyzeMetafile:(c,l)=>new Promise((u,p)=>a.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof c=="string"?c:JSON.stringify(c),options:l,callback:(f,m)=>f?p(f):u(m)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function yb(){let e=globalThis,t=e.Deno?.build?.os;return typeof t=="string"?t==="windows":e.navigator?.platform?.startsWith("Win")??e.process?.platform?.startsWith("win")??!1}var ut=yb();function Ot(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function gm(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let o=t.length-1;o>=0;--o)if(e.charCodeAt(r+o)!==t.charCodeAt(o))return e;return e.slice(0,-t.length)}function ym(e,t,r=0){let o=!1,n=e.length;for(let s=e.length-1;s>=r;--s)if(t(e.charCodeAt(s))){if(o){r=s+1;break}}else o||(o=!0,n=s+1);return e.slice(r,n)}function xm(e,t){if(Ot(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function Nc(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError(URL must be a file URL: received "${e.protocol}");return e}function no(e){return e=Nc(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function os(e,t){if(e.length<=1)return e;let r=e.length;for(let o=e.length-1;o>0&&t(e.charCodeAt(o));o--)r=o;return e.slice(0,r)}function fr(e){return e===47}function bm(e,t=""){e instanceof URL&&(e=no(e)),xm(e,t);let r=ym(e,fr),o=os(r,fr);return t?gm(o,t):o}function Fr(e){return e===47||e===92}function so(e){return e>=97&&e<=122||e>=65&&e<=90}function wn(e){e=Nc(e);let t=decodeURIComponent(e.pathname.replace(/\//g,"\\").replace(/%(?![0-9A-Fa-f]{2})/g,"%25")).replace(/^\\*([A-Za-z]:)(\\|$)/,"$1\\");return e.hostname!==""&&(t=\\\\${e.hostname}${t}),t}var gi=ut?"\\":"/";function wm(e){e instanceof URL&&(e=no(e)),Ot(e);let t=-1,r=0,o=-1,n=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(fr(a)){if(!n){r=i+1;break}continue}o===-1&&(n=!1,o=i+1),a===46?t===-1?t=i:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||o===-1||s===0||s===1&&t===o-1&&t===r+1?"":e.slice(t,o)}function ss(e){return ut?wn(e):no(e)}function Rm(e){return Ot(e),e.length>0&&fr(e.charCodeAt(0))}function km(e){Ot(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return Fr(r)?!0:!!(so(r)&&t>2&&e.charCodeAt(1)===58&&Fr(e.charCodeAt(2)))}var uS={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Cc(e){return e.replaceAll(/[\s]/g,t=>uS[t]??t)}function wb(e){if(!Rm(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=Cc(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function Rb(e){if(!km(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),o=new URL("file:///");if(o.pathname=Cc(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(o.hostname=t,!o.hostname))throw new TypeError(Invalid hostname: "${o.hostname}");return o}function Rn(e){return ut?Rb(e):wb(e)}function Ic(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Ac(e){let t={},r=Object.keys(e).sort((o,n)=>n.length-o.length);for(let o of r)t[o]=e[o];return t}function kb(e){return Ic(e)&&(e.imports!==void 0?Tm(e.imports):!0)&&(e.scopes!==void 0?_m(e.scopes):!0)}function Tm(e){return Ic(e)}function _m(e){return Ic(e)&&Object.values(e).every(t=>Pm(t))}function Pm(e){return Ic(e)}function Fc(e){try{return new URL(e),!0}catch{return!1}}function Tb(e,t){let r={};for(let[o,n]of Object.entries(e)){let s=gS(o,t);if(s===null)continue;if(typeof n!="string"){console.warn("addresses need to be strings."),r[s]=null;continue}let i=Om(n,t);if(i===null){console.warn("the address was invalid."),r[s]=null;continue}if(o.endsWith("/")&&!Dr(i).endsWith("/")){console.warn("an invalid address was given for the specifier key specifierKey; since specifierKey ended in a slash, the address needs to as well."),r[s]=null;continue}r[s]=Dr(i)}return Ac(r)}function Dr(e){return e.href}function hS(e,t){let r={};for(let[n,s]of Object.entries(e)){if(!Pm(s))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let i;try{i=new URL(n,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let a=Dr(i);r[a]=Tb(s,t)}let o={};for(let n of Object.keys(r))o[n]=Ac(r[n]);return Ac(o)}function gS(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=Om(e,t);return r!==null?Dr(r):e}function Om(e,t){if(t&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")))try{return new URL(e,t)}catch{return null}try{return new URL(e)}catch{return null}}var yS=["ftp","file","http","https","ws","wss"];function xS(e){return yS.some(t=>Dr(e).startsWith(t))}function vb(e,t,r){for(let[o,n]of Object.entries(r))if(o===e){if(n===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Fc(n))throw new TypeError("resolutionResult must be an URL.");return n}else if(o.endsWith("/")&&e.startsWith(o)&&(t===null||xS(t))){if(n===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Fc(n))throw new TypeError("resolutionResult must be an URL.");let s=e.slice(o.length);if(!n.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let i=new URL(s,n);if(!Fc(i))throw new TypeError("url must be an URL.");if(!Dr(i).startsWith(n))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return Dr(i)}catch{throw new TypeError("resolution of normalizedSpecifier was blocked since the afterPrefix portion could not be URL-parsed relative to the resolutionResult mapped to by the specifierKey prefix.")}}return null}function Sm(e,t){let r={};if(!kb(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:o,scopes:n}=e;if(o!==void 0){if(!Tm(o))throw new TypeError('"imports" top-level key needs to be an object.');r=Tb(o,t)}let s={};if(n!==void 0){if(!_m(n))throw new TypeError('"scopes" top-level key needs to be an object.');s=hS(n,t)}return Object.keys(e).find(i=>i!=="imports"&&i!=="scopes")&&console.warn("an invalid top-level key was present in the import map."),{imports:r,scopes:s}}function _b(e,{imports:t={},scopes:r={}},o){let n=Dr(o),s=Om(e,o),i=s!==null?Dr(s):e;for(let[c,l]of Object.entries(r))if(c===n||c.endsWith("/")&&n.startsWith(c)){let u=vb(i,s,l);if(u!==null)return u}let a=vb(i,s,t);if(a!==null)return a;if(s!==null)return Dr(s);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}var Dc=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function Lm(e,t=""){if(!e)throw new Dc(t)}function Ob(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new Nm(e,{allowTrailingComma:t}).parse()}var Pb=globalThis.JSON.parse,Nm=class{#o=new Set( \r
);#r=new Set([..."[]{}:,/",...this.#o]);#t;#e;#i;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#i=this.#m(),this.#a=r}parse(){let t=this.#s(),r=this.#p(t),{done:o,value:n}=this.#i.next();if(!o)throw new SyntaxError(Mo(n));return r}#s(){let{done:t,value:r}=this.#i.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#m(){for(let t=0;t<this.#e;t++)if(!this.#o.has(this.#t[t])){if(this.#t[t]==="/"&&this.#t[t+1]==="*"){t+=2;let r=!1;for(;t<this.#e;t++)if(this.#t[t]==="*"&&this.#t[t+1]==="/"){r=!0;break}if(!r)throw new SyntaxError("Unexpected end of JSONC input");t++;continue}if(this.#t[t]==="/"&&this.#t[t+1]==="/"){for(t+=2;t<this.#e&&!(this.#t[t]===
||this.#t[t]==="\r");t++);continue}switch(this.#t[t]){case"{":yield{type:"BeginObject",position:t};break;case"}":yield{type:"EndObject",position:t};break;case"[":yield{type:"BeginArray",position:t};break;case"]":yield{type:"EndArray",position:t};break;case":":yield{type:"NameSeparator",position:t};break;case",":yield{type:"ValueSeparator",position:t};break;case'"':{let r=t,o=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!o);t++)o=this.#t[t]==="\\"&&!o;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#r.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#p(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#n();case"NullOrTrueOrFalseOrNumber":return this.#g(t);case"String":return this.#h(t);default:throw new SyntaxError(Mo(t))}}#f(){let t={};for(let r=!0;;r=!1){let o=this.#s();if((r||this.#a.allowTrailingComma)&&o.type==="EndObject")return t;if(o.type!=="String")throw new SyntaxError(Mo(o));let n=this.#h(o),s=this.#s();if(s.type!=="NameSeparator")throw new SyntaxError(Mo(s));let i=this.#s();Object.defineProperty(t,n,{value:this.#p(i),writable:!0,enumerable:!0,configurable:!0});let a=this.#s();if(a.type==="EndObject")return t;if(a.type!=="ValueSeparator")throw new SyntaxError(Mo(a))}}#n(){let t=[];for(let r=!0;;r=!1){let o=this.#s();if((r||this.#a.allowTrailingComma)&&o.type==="EndArray")return t;t.push(this.#p(o));let n=this.#s();if(n.type==="EndArray")return t;if(n.type!=="ValueSeparator")throw new SyntaxError(Mo(n))}}#h(t){let r;try{r=Pb(t.sourceText)}catch{throw new SyntaxError(Mo(t))}return Lm(typeof r=="string"),r}#g(t){if(t.sourceText==="null")return null;if(t.sourceText==="true")return!0;if(t.sourceText==="false")return!1;let r;try{r=Pb(t.sourceText)}catch{throw new SyntaxError(Mo(t))}return Lm(typeof r=="number"),r}};function Mo({type:e,sourceText:t,position:r}){let o="";switch(e){case"BeginObject":o="{";break;case"EndObject":o="}";break;case"BeginArray":o="[";break;case"EndArray":o="]";break;case"NameSeparator":o=":";break;case"ValueSeparator":o=",";break;case"NullOrTrueOrFalseOrNumber":case"String":o=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${o} in JSONC at position ${r}}function $c(e){if(e.protocol==="file:")return{path:ss(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function Mm(e){let t=await Deno.readTextFile(e),r=Ob(t);if(typeof r!="object"||r===null||Array.isArray(r))throw new Error(Deno config at ${e} must be an object);if("imports"in r&&(typeof r.imports!="object"||r.imports===null||Array.isArray(r.imports)))throw new Error(Deno config at ${e} has invalid "imports" key);if("scopes"in r&&(typeof r.scopes!="object"||r.scopes===null||Array.isArray(r.scopes)))throw new Error(Deno config at ${e} has invalid "scopes" key);if("lock"in r&&typeof r.lock!="boolean"&&typeof r.lock!="string")throw new Error(Deno config at ${e} has invalid "lock" key);if("importMap"in r&&typeof r.importMap!="string")throw new Error(Deno config at ${e} has invalid "importMap" key);return r}function Sb(e){if(e.imports!==void 0){let t=[];for(let[r,o]of Object.entries(e.imports))if(t.push([r,o]),!r.endsWith("/")&&o&&(o.startsWith("jsr:")||o.startsWith("npm:"))&&!e.imports[r+"/"]){let n=r+"/",s=o.slice(0,4)+"/"+o.slice(o[4]==="/"?5:4)+"/";t.push([n,s])}e.imports=Object.fromEntries(t)}}var ES=${gi}node_modules${gi},wS=${gi}node_modules;function Uc(e){return e.includes(ES)||e.endsWith(wS)}function Cm(e){return(e.namespace===""||e.namespace==="file")&&(Uc(e.resolveDir)||Uc(e.path)||Uc(e.importer))}function Im(e={}){return{name:"deno-resolver",setup(t){let r=null,o=(t.initialOptions.external??[]).map(n=>new RegExp("^"+n.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let s;if(e.importMapURL===void 0&&e.configPath!==void 0){let i=await Mm(e.configPath);if(i.imports!==void 0||i.scopes!==void 0){let a={imports:i.imports,scopes:i.scopes};Sb(a),r=Sm(a,Rn(e.configPath))}else i.importMap!==void 0&&(s=new URL(i.importMap,Rn(e.configPath)).href)}else e.importMapURL!==void 0&&(s=e.importMapURL);if(s){let i=await fetch(s),a=await i.json();r=Sm(a,new URL(i.url))}}),t.onResolve({filter:/.*/},async function(s){if(Cm(s))return;let i;if(s.importer!==""){if(s.namespace==="")throw new Error("[assert] namespace is empty");i=new URL(${s.namespace}:${s.importer})}else if(s.resolveDir!=="")i=new URL(${Rn(s.resolveDir).href}/);else return;let a;if(r!==null){let p=_b(s.path,r,new URL(i));a=new URL(p)}else a=new URL(s.path,i);for(let p of o)if(p.test(a.href))return{path:a.href,external:!0};let{path:c,namespace:l}=$c(a);return await t.resolve(c,{namespace:l,kind:s.kind})})}}}var Cge=new TextEncoder;var RS=[],kS=[],Am="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=Am.length;e<t;++e)RS[e]=Am[e],kS[Am.charCodeAt(e)]=e;var eye=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var NS=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var Lb=Im;var Nb=e=>!!(MS.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),MS=["i.gyazo.com","t.gyazo.com","scrapbox.io","api.openai.com","*.openai.azure.com","maps.googleapis.com","upload.gyazo.com","storage.googleapis.com","sentry.io"];var Mb=e=>{if(e.protocol==="file:")return{path:ss(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},Fm=e=>e.namespace==="file"?Rn(e.path):new URL(${e.namespace}:${e.path});var Cb=(e,t)=>{let r=$s(CS(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(O(r))return r;let{url:o,start:n,end:s}=S(r);return URL.canParse(o,t)?L({url:new URL(o,t),start:n,end:s}):M({name:"InvalidURLError",message:Invalid URL: ${o}})},CS=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,o=e.length,n=r;for(;n<o&&e.charCodeAt(n)>32;)n++;if(n!==r&&(t[1]==="/"||e.indexOf("*/",n)>0))return{url:e.slice(r,n),start:r,end:n}}};var IS=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],Ib=e=>IS.includes(e),Ab=e=>/^js|^ts|css$/.test(e),Fb=e=>{let t=e.url,r=bm(t);if(Ib(r))return r;if(r==="mjs")return"js";let o=new URL(t);o.search="",o.hash="";let n=wm(o.href).slice(1);if(Ib(n))return n;if(n==="mjs")return"js";let i=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return AS(i)},AS=e=>{let t=e.split("/")[1]??"plain";if(/(?:^plain$|^xml|^svg|^x?html)/.test(t))return"text";if(t.startsWith("json"))return"json";switch(t){case"javascript":return"js";case"typescript":return"ts";case"css":return"css";default:return"text"}};function jc(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function $b(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Um(e=[],t=[]){let r=Math.max(e.length,t.length);for(let o=0;o<r;o++){let n=e[o],s=t[o];if(n===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(n===void 0)return-1;if(typeof n=="string"&&typeof s=="number")return 1;if(typeof n=="number"&&typeof s=="string"||n<s)return-1;if(n>s)return 1}return 0}var is="0|[1-9]\\d*",FS="\\d*[a-zA-Z-][a-zA-Z0-9-]*",DS=(?<major>${is})\\.(?<minor>${is})\\.(?<patch>${is}),Db=(?:${is}|${FS}),jb=(?:-(?<prerelease>${Db}(?:\\.${Db})*)),Ub="[0-9A-Za-z-]+",Bb=(?:\\+(?<buildmetadata>${Ub}(?:\\.${Ub})*)),Hb=v?${DS}${jb}?${Bb}?,Wb=new RegExp(^${Hb}$),qb="(?:<|>)?=?",US="x|X|\\*",Dm=${is}|${US},Bc=v=\\s*(?<major>${Dm})(?:\\.(?<minor>${Dm})(?:\\.(?<patch>${Dm})${jb}?${Bb}?)?)?,Gb=new RegExp(^(?<operator>~>?|\\^|${qb})\\s*${Bc}$),zb=new RegExp(^(?<operator>${qb})\\s*(${Hb})$|^$);function $m(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var jm=256;var $S=new RegExp(^${is}$);function Vt(e){return e.split(".").filter(Boolean).map(t=>{if($S.test(t)){let r=Number(t);if($m(r))return r}return t})}function Ur(e){return e.split(".").filter(Boolean)}function Co(e,t){let r=Number(e);if(!$m(r))throw new TypeError(t);return r}function kn(e){return Number.isNaN(e.major)&&Number.isNaN(e.minor)&&Number.isNaN(e.patch)&&(e.prerelease===void 0||e.prerelease.length===0)&&(e.build===void 0||e.build.length===0)}function dr(e,t){return e===t?0:jc(e.major,t.major)||jc(e.minor,t.minor)||jc(e.patch,t.patch)||$b(e.prerelease,t.prerelease)||Um(e.prerelease,t.prerelease)}function Bm(e){return e.toFixed(0)}function vn(e){let t=Bm(e.major),r=Bm(e.minor),o=Bm(e.patch),n=e.prerelease?.join(".")??"",s=e.build?.join(".")??"";return[[${t}.${r}.${o},n].filter(c=>c).join("-"),s].filter(c=>c).join("+")}function jS(e,t){if(kn(t))return!0;let r=dr(e,t);switch(t.operator){case"=":case void 0:return r===0;case"!=":return r!==0;case">":return r>0;case"<":return r<0;case">=":return r>=0;case"<=":return r<=0}}function Hc(e,t){for(let r of t)if(!jS(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(kn(r))continue;let{major:o,minor:n,patch:s,prerelease:i}=r;if(i&&i.length>0&&e.major===o&&e.minor===n&&e.patch===s)return!0}return!1}return!0}function Wc(e,t){return t.some(r=>Hc(e,r))}var qc={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},as={operator:void 0,...qc};function Vb(e,t){return dr(e,t)>0}function yi(e,t){let r;for(let o of e)Wc(o,t)&&(r=r&&Vb(r,o)?r:o);return r}function BS(e){let r=e.match(zb)?.groups;if(!r)return null;let{operator:o,prerelease:n,buildmetadata:s}=r,i=r.major?{major:Co(r.major,Cannot parse comparator ${e}: invalid major version),minor:Co(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:Co(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:n?Vt(n):[],build:s?Ur(s):[]}:qc;return{operator:o||void 0,...i}}function Oe(e){return!e||e.toLowerCase()==="x"||e==="*"}function HS(e){if(!Oe(e.major))return Oe(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:Oe(e.patch)?{operator:">=",major:+e.major,minor:+e.minor,patch:0,prerelease:[],build:[]}:{operator:">=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?Vt(e.prerelease):[],build:[]}}function WS(e){if(!Oe(e.major))return Oe(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:Oe(e.patch)?{operator:"<",major:+e.major,minor:+e.minor+1,patch:0,prerelease:[],build:[]}:e.prerelease?{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:Vt(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:[],build:[]}}function qS(e){let t=e.match(new RegExp(^${Bc})),r=t?.groups;if(!r)return null;let o=t[0].length,n=e.slice(o).match(/^\s+-\s+/);if(!n)return null;let s=n[0].length,a=e.slice(o+s).match(new RegExp(^${Bc}\\s*$))?.groups;if(!a)return null;let c=HS(r),l=WS(a);return[c,l].filter(Boolean)}function GS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[as];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return n===0?[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}]:[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];let a=Vt(e.prerelease??"");return n===0?s===0?[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s,patch:i+1}]:[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s+1,patch:0}]:[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n+1,minor:0,patch:0}]}function zS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[as];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??"");return[{operator:">=",major:n,minor:s,patch:i,prerelease:a},{operator:"<",major:n,minor:s+1,patch:0}]}function VS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return o?[{operator:"<",major:n,minor:0,patch:0}]:[{operator:"<",major:n,minor:0,patch:0}];if(o)return[{operator:"<",major:n,minor:s,patch:0}];let a=Vt(e.prerelease??""),c=Ur(e.build??"");return[{operator:"<",major:n,minor:s,patch:i,prerelease:a,build:c}]}function KS(e){let t=Oe(e.minor),r=Oe(e.patch),o=+e.major,n=+e.minor,s=+e.patch;if(t)return r?[{operator:"<",major:o+1,minor:0,patch:0}]:[{operator:"<",major:o,minor:n+1,patch:0}];if(r)return[{operator:"<",major:o,minor:n+1,patch:0}];let i=Vt(e.prerelease??""),a=Ur(e.build??"");return[{operator:"<=",major:o,minor:n,patch:s,prerelease:i,build:a}]}function YS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??""),c=Ur(e.build??"");return[{operator:">",major:n,minor:s,patch:i,prerelease:a,build:c}]}function XS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[as];if(r)return o?[{operator:">=",major:n,minor:0,patch:0}]:[{operator:">=",major:n,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0}];let a=Vt(e.prerelease??""),c=Ur(e.build??"");return[{operator:">=",major:n,minor:s,patch:i,prerelease:a,build:c}]}function JS(e){let t=Oe(e.major),r=Oe(e.minor),o=Oe(e.patch),n=+e.major,s=+e.minor,i=+e.patch;if(t)return[as];if(r)return[{operator:">=",major:n,minor:0,patch:0},{operator:"<",major:n+1,minor:0,patch:0}];if(o)return[{operator:">=",major:n,minor:s,patch:0},{operator:"<",major:n,minor:s+1,patch:0}];let a=Vt(e.prerelease??""),c=Ur(e.build??"");return[{operator:void 0,major:n,minor:s,patch:i,prerelease:a,build:c}]}function QS(e){let t=e.match(Gb)?.groups;if(!t)return BS(e);switch(t.operator){case"^":return GS(t);case"~":case"~>":return zS(t);case"<":return VS(t);case"<=":return KS(t);case">":return YS(t);case">=":return XS(t);case"=":case"":return JS(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function ZS(e){return e.split(/\s+/).flatMap(QS)}function Kb(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>qS(r)||ZS(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Hm(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>jm)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${jm});e=e.trim();let t=e.match(Wb)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=Co(t.major,Cannot parse version ${e}: invalid major version),o=Co(t.minor,Cannot parse version ${e}: invalid minor version),n=Co(t.patch,Cannot parse version ${e}: invalid patch version),s=t.prerelease?Vt(t.prerelease):[],i=t.buildmetadata?Ur(t.buildmetadata):[];return{major:r,minor:o,patch:n,prerelease:s,build:i}}function Wm(e){try{return Kb(e)}catch{return}}function qm(e){try{return Hm(e)}catch{return}}var xi={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var Io=async e=>{try{let t=await fetch(e);return t.ok?L([t,!1]):M({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return M({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return M({name:"AbortError",message:t.message,request:e});throw t}};var Gm="https://jsr.io",Yb=async(e,t)=>{let r=await(t?.fetch??Io)(new Request(${t?.endpoint??Gm}/${e}/meta.json),t?.cacheFirst);return ie(r,([o])=>o.json())};var Xb=async(e,t,r)=>{let o=await(r?.fetch??Io)(new Request(${r?.endpoint??Gm}/${e}/${t}_meta.json),r?.cacheFirst);return ie(o,([n])=>n.json())};var Jb=async(e,t)=>{let r=await(t?.fetch??Io)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return ie(r,([o])=>o.json())};var eE=(e,t)=>({name:"InvalidPackageVersionError",message:No version of ${e.name} satisfies "${e.tag??"*"}" (available: ${t.slice(0,10).join(", ")}${t.length>10?, ... (${t.length-10} more versions):""}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableVersions:t}),Gc=(e,t)=>({name:"InvalidEntryPointError",message:${e.entryPoint} is not a valid entry point for ${e.name}@${e.tag??"*"} (available: ${t.join(", ")}),packageName:e.name,range:e.range,tag:e.tag,entryPoint:e.entryPoint,availableEntryPoints:t}),tE=async(e,t)=>{if(t?.resolvedVersions){let c=new Map(t.resolvedVersions.get(e.name)??[]),l=yi([...c.keys()],e.range);if(l){let u=c.get(l)??bi,p=u[e.entryPoint];return typeof p!="string"&&console.log(p),p?L(Qb(e.name,vn(l),p)):M(Gc(e,Object.keys(u)))}}let r=await Jb(e.name,t);if(O(r))return r;let o=S(r),n=new Map(Object.entries(o.versions).flatMap(([c,{exports:l}])=>{let u=qm(c);return u?[[u,l??bi]]:[]})),s=yi([...n.keys()],e.range);if(!s)return M(eE(e,Object.keys(o.versions)));let i={...bi};for(let c of Object.keys(n.get(s)??bi))i[c]=c;let a=i[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[s,i]]),L(Qb(e.name,vn(s),a))):M(Gc(e,Object.keys(i)))},Qb=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),rE=async(e,t)=>{if(t?.resolvedVersions){let a=new Map(t.resolvedVersions.get(e.name)??[]),c=yi([...a.keys()],e.range);if(c){let l=a.get(c)??bi,u=l[e.entryPoint];return u?L(Zb(e.name,vn(c),u)):M(Gc(e,Object.keys(l)))}}let r=await eL(e,t);if(O(r))return r;let o=S(r),n=await Xb(e.name,vn(o),t);if(O(n))return n;let s=S(n).exports,i=s[e.entryPoint];return i?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[o,s]]),L(Zb(e.name,vn(o),i))):M(Gc(e,Object.keys(S(n).exports)))},Zb=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),eL=async(e,t)=>{let r=await Yb(e.name,t);if(O(r))return r;let o=S(r),n=Object.keys(o.versions).flatMap(i=>{let a=qm(i);return a?[a]:[]}),s=yi(n,e.range);return s?L(s):M(eE(e,Object.keys(o.versions)))},bi={".":"./"};var tL=e=>({name:"OnlyScopeProvidedError",specifier:e}),oE=e=>({name:"PackageNotFoundError",specifier:e}),nE=e=>{if(e.protocol!=="npm:")return M({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,o,n;if(t[r]==="@"){let p=t.indexOf("/",r);if(p===-1)return M(tL(e));o=t.indexOf("/",p+1),n=t.indexOf("@",p+1)}else o=t.indexOf("/",r),n=t.indexOf("@",r);if(o===-1&&(o=t.length),n===-1&&(n=t.length),n=Math.min(n,o),r===n)return M(oE(e));let s=t.slice(r,n),i=decodeURIComponent(t.slice(n+1,o)),a=i?Wm(i)??[[xi]]:[[xi]],c=t.slice(o+1),l=c?./${c}:".",u={name:s,range:a,entryPoint:l};return i&&(u.tag=i),L(u)},sE=e=>{if(e.protocol!=="jsr:")return M({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return M({name:"ScopeNotFoundError",specifier:e});let o=t.indexOf("/",r);if(o===-1)return M(oE(e));let n=t.indexOf("/",o+1),s=t.indexOf("@",o+1);n===-1&&(n=t.length),s===-1&&(s=t.length),s=Math.min(s,n);let i=t.slice(r,s),a=decodeURIComponent(t.slice(s+1,n)),c=a?Wm(a)??[[xi]]:[[xi]],l=t.slice(n+1),u=l?./${l}:".",p={name:i,range:c,entryPoint:u};return a&&(p.tag=a),L(p)};var iE=e=>new Promise((t,r)=>{let o=new FileReader;o.addEventListener("load",()=>{let n=o.result,s=n.indexOf(";");n.startsWith("; charset=utf-8",s)?t(${n.slice(0,s)}${n.slice(s+15)}):t(n)}),o.addEventListener("error",()=>r(o.error)),o.readAsDataURL(e)});var lE=e=>{let t=new Map,r=async o=>{let n=o.namespace==="npm",s=(n?nE:sE)(Fm(o));if(O(s)){let a=Z(s);return{errors:[{text:a.name,detail:a}]}}let i=await(n?tE:rE)(S(s),{resolvedVersions:t,...e});if(O(i)){let a=Z(i);return{errors:[{text:${a.name} ${a.message},detail:a}]}}return Mb(S(i))};return{name:"remote-loader",setup({onLoad:o,onResolve:n,initialOptions:s}){for(let i of[...aE,...cE])n({filter:/.*/,namespace:i.slice(0,-1)},rL);n({filter:/.*/,namespace:"npm"},r),n({filter:/.*/,namespace:"jsr"},r);for(let i of aE)o({filter:/.*/,namespace:i.slice(0,-1)},a=>oL(Fm(a),{...e,sourcemap:s.sourcemap!==!1&&s.sourcemap!==void 0}));for(let i of cE)o({filter:/.*/,namespace:i.slice(0,-1)},()=>{throw new Error(${i} import is not supported yet.)})}}},rL=e=>({path:e.path,namespace:e.namespace}),aE=["http:","https:","data:"],cE=["node:"],oL=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(l=>l.test(e)):!0,o=t.fetch??Io,n=await o(new Request(e),r);if(O(n))return{errors:[{text:${Z(n).message} Failed to fetch ${e},detail:Z(n)}]};let[s,i]=S(n),a=Fb(s);t.onProgress?.({path:e,done:s.clone().blob().then(l=>({size:l.size,loader:a,isCache:i}))});let c=await s.blob();if(t.sourcemap&&Ab(a)){let l=await c.text(),u=Cb(l,e);if(K(u)){let{url:p,start:f,end:m}=S(u);if(p.protocol!=="data:"){let h=await o(new Request(p),r);if(O(h))return{contents:l,loader:a,warnings:[{text:${Z(h).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${p}},{text:Original URL: ${e}}],detail:Z(h)}]};let g=await S(h)[0].blob().then(iE);return{contents:l.slice(0,f)+g+l.slice(m),loader:a}}}}return{contents:new Uint8Array(await c.arrayBuffer()),loader:a}};var Ri=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,o,n,s){this.type=e,this.name=t,this.prefix=r,this.value=o,this.suffix=n,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},nL=/[$_\p{ID_Start}]/u,sL=/[$_\u200C\u200D\p{ID_Continue}]/u,Vm=".*";function iL(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function mE(e,t=!1){let r=[],o=0;for(;o<e.length;){let n=e[o],s=function(i){if(!t)throw new TypeError(i);r.push({type:"INVALID_CHAR",index:o,value:e[o++]})};if(n==="*"){r.push({type:"ASTERISK",index:o,value:e[o++]});continue}if(n==="+"||n==="?"){r.push({type:"OTHER_MODIFIER",index:o,value:e[o++]});continue}if(n==="\\"){r.push({type:"ESCAPED_CHAR",index:o++,value:e[o++]});continue}if(n==="{"){r.push({type:"OPEN",index:o,value:e[o++]});continue}if(n==="}"){r.push({type:"CLOSE",index:o,value:e[o++]});continue}if(n===":"){let i="",a=o+1;for(;a<e.length;){let c=e.substr(a,1);if(a===o+1&&nL.test(c)||a!==o+1&&sL.test(c)){i+=e[a++];continue}break}if(!i){s(Missing parameter name at ${o});continue}r.push({type:"NAME",index:o,value:i}),o=a;continue}if(n==="("){let i=1,a="",c=o+1,l=!1;if(e[c]==="?"){s(Pattern cannot start with "?" at ${c});continue}for(;c<e.length;){if(!iL(e[c],!1)){s(Invalid character '${ec}' at ${c}.),l=!0;break}if(e[c]==="\\"){a+=e[c++]+e[c++];continue}if(e[c]===")"){if(i--,i===0){c++;break}}else if(e[c]==="("&&(i++,e[c+1]!=="?")){s(Capturing groups are not allowed at ${c}),l=!0;break}a+=e[c++]}if(l)continue;if(i){s(Unbalanced pattern at ${o});continue}if(!a){s(Missing pattern at ${o});continue}r.push({type:"REGEX",index:o,value:a}),o=c;continue}r.push({type:"CHAR",index:o,value:e[o++]})}return r.push({type:"END",index:o,value:""}),r}function fE(e,t={}){let r=mE(e);t.delimiter??="/#?",t.prefixes??="./";let o=^${hr(t.delimiter)}+?,n=[],s=0,i=0,a="",c=new Set,l=k=>{if(i<r.length&&r[i].type===k)return r[i++].value},u=()=>l("OTHER_MODIFIER")??l("ASTERISK"),p=k=>{let b=l(k);if(b!==void 0)return b;let{type:T,index:v}=r[i];throw new TypeError(Unexpected ${T} at ${v}, expected ${k})},f=()=>{let k="",b;for(;b=l("CHAR")??l("ESCAPED_CHAR");)k+=b;return k},m=k=>k,h=t.encodePart||m,g="",y=k=>{g+=k},x=()=>{g.length&&(n.push(new Ri(3,"","",h(g),"",3)),g="")},w=(k,b,T,v,A)=>{let F=3;switch(A){case"?":F=1;break;case"*":F=0;break;case"+":F=2;break}if(!b&&!T&&F===3){y(k);return}if(x(),!b&&!T){if(!k)return;n.push(new Ri(3,"","",h(k),"",F));return}let D;T?T==="*"?D=Vm:D=T:D=o;let N=2;D===o?(N=1,D=""):D===Vm&&(N=0,D="");let _;if(b?_=b:T&&(_=s++),c.has(_))throw new TypeError(Duplicate name '${_}'.);c.add(_),n.push(new Ri(N,_,h(k),D,h(v),F))};for(;i<r.length;){let k=l("CHAR"),b=l("NAME"),T=l("REGEX");if(!b&&!T&&(T=l("ASTERISK")),b||T){let A=k??"";t.prefixes.indexOf(A)===-1&&(y(A),A=""),x();let F=u();w(A,b,T,"",F);continue}let v=k??l("ESCAPED_CHAR");if(v){y(v);continue}if(l("OPEN")){let A=f(),F=l("NAME"),D=l("REGEX");!F&&!D&&(D=l("ASTERISK"));let N=f();p("CLOSE");let _=u();w(A,F,D,N,_);continue}x(),p("END")}return n}function hr(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function pE(e){return e&&e.ignoreCase?"ui":"u"}function aL(e,t,r){return dE(fE(e,r),t,r)}function cs(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function dE(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let o=r.start?"^":"";for(let a of e){if(a.type===3){a.modifier===3?o+=hr(a.value):o+=(?:${hr(a.value)})${cs(a.modifier)};continue}t&&t.push(a.name);let c=^${hr(r.delimiter)}+?,l=a.value;if(a.type===1?l=c:a.type===0&&(l=Vm),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?o+=(${l})${cs(a.modifier)}:o+=((?:${l})${cs(a.modifier)});continue}if(a.modifier===3||a.modifier===1){o+=(?:${hr(a.prefix)}(${l})${hr(a.suffix)}),o+=cs(a.modifier);continue}o+=(?:${hr(a.prefix)},o+=((?:${l})(?:,o+=hr(a.suffix),o+=hr(a.prefix),o+=(?:${l}))*)${hr(a.suffix)}),a.modifier===0&&(o+="?")}let n=${hr(r.endsWith)}|$,s=${hr(r.delimiter)};if(r.end)return r.strict||(o+=${s}?),r.endsWith.length?o+=(?=${n}):o+="$",new RegExp(o,pE(r));r.strict||(o+=(?:${s}(?=${n}))?);let i=!1;if(e.length){let a=e[e.length-1];a.type===3&&a.modifier===3&&(i=r.delimiter.indexOf(a)>-1)}return i||(o+=(?=${s}|${n})),new RegExp(o,pE(r))}var Fo={delimiter:"",prefixes:"",sensitive:!0,strict:!0},cL={delimiter:".",prefixes:"",sensitive:!0,strict:!0},lL={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function pL(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function hE(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function uL(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function gE(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var yE=["ftp","file","http","https","ws","wss"];function xE(e){if(!e)return!0;for(let t of yE)if(e.test(t))return!0;return!1}function mL(e,t){if(e=hE(e,"#"),t||e==="")return e;let r=new URL("https://example.com");return r.hash=e,r.hash?r.hash.substring(1,r.hash.length):""}function fL(e,t){if(e=hE(e,"?"),t||e==="")return e;let r=new URL("https://example.com");return r.search=e,r.search?r.search.substring(1,r.search.length):""}function dL(e,t){return t||e===""?e:gE(e)?wE(e):EE(e)}function hL(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function gL(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function yL(e,t,r){if(r||e==="")return e;if(t&&!yE.includes(t))return new URL(${t}:${e}).pathname;let o=e[0]=="/";return e=new URL(o?e:"/-"+e,"https://example.com").pathname,o||(e=e.substring(2,e.length)),e}function xL(e,t,r){return bE(t)===e&&(e=""),r||e===""?e:RE(e)}function bL(e,t){return e=uL(e,":"),t||e===""?e:Km(e)}function bE(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function Km(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function EL(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function wL(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function EE(e){if(e==="")return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw new TypeError(Invalid hostname '${e}');let t=new URL("https://example.com");return t.hostname=e,t.hostname}function wE(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function RE(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function RL(e){if(e==="")return e;let t=new URL("https://example.com");return t.pathname=e[0]!=="/"?"/-"+e:e,e[0]!=="/"?t.pathname.substring(2,t.pathname.length):t.pathname}function kL(e){return e===""?e:new URL(data:${e}).pathname}function vL(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function TL(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var _L=class{#o;#r=[];#t={};#e=0;#i=1;#a=0;#s=0;#m=0;#p=0;#f=!1;constructor(e){this.#o=e}get result(){return this.#t}parse(){for(this.#r=mE(this.#o,!0);this.#e<this.#r.length;this.#e+=this.#i){if(this.#i=1,this.#r[this.#e].type==="END"){if(this.#s===0){this.#g(),this.#u()?this.#n(9,1):this.#d()?this.#n(8,1):this.#n(7,0);continue}else if(this.#s===2){this.#y(5);continue}this.#n(10,0);break}if(this.#m>0)if(this.#_())this.#m-=1;else continue;if(this.#T()){this.#m+=1;continue}switch(this.#s){case 0:this.#w()&&this.#y(1);break;case 1:if(this.#w()){this.#S();let e=7,t=1;this.#R()?(e=2,t=3):this.#f&&(e=2),this.#n(e,t)}break;case 2:this.#b()?this.#y(3):(this.#E()||this.#d()||this.#u())&&this.#y(5);break;case 3:this.#k()?this.#n(4,1):this.#b()&&this.#n(5,1);break;case 4:this.#b()&&this.#n(5,1);break;case 5:this.#P()?this.#p+=1:this.#O()&&(this.#p-=1),this.#v()&&!this.#p?this.#n(6,1):this.#E()?this.#n(7,0):this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 6:this.#E()?this.#n(7,0):this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 7:this.#d()?this.#n(8,1):this.#u()&&this.#n(9,1);break;case 8:this.#u()&&this.#n(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#n(e,t){switch(this.#s){case 0:break;case 1:this.#t.protocol=this.#l();break;case 2:break;case 3:this.#t.username=this.#l();break;case 4:this.#t.password=this.#l();break;case 5:this.#t.hostname=this.#l();break;case 6:this.#t.port=this.#l();break;case 7:this.#t.pathname=this.#l();break;case 8:this.#t.search=this.#l();break;case 9:this.#t.hash=this.#l();break;case 10:break}this.#s!==0&&e!==10&&([1,2,3,4].includes(this.#s)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#s)&&[8,9].includes(e)&&(this.#t.pathname??=this.#f?"/":""),[1,2,3,4,5,6,7].includes(this.#s)&&e===9&&(this.#t.search??="")),this.#h(e,t)}#h(e,t){this.#s=e,this.#a=this.#e+t,this.#e+=t,this.#i=0}#g(){this.#e=this.#a,this.#i=0}#y(e){this.#g(),this.#s=e}#x(e){return e<0&&(e=this.#r.length-e),e<this.#r.length?this.#r[e]:this.#r[this.#r.length-1]}#c(e,t){let r=this.#x(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#w(){return this.#c(this.#e,":")}#R(){return this.#c(this.#e+1,"/")&&this.#c(this.#e+2,"/")}#b(){return this.#c(this.#e,"@")}#k(){return this.#c(this.#e,":")}#v(){return this.#c(this.#e,":")}#E(){return this.#c(this.#e,"/")}#d(){if(this.#c(this.#e,"?"))return!0;if(this.#r[this.#e].value!=="?")return!1;let e=this.#x(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#u(){return this.#c(this.#e,"#")}#T(){return this.#r[this.#e].type=="OPEN"}#_(){return this.#r[this.#e].type=="CLOSE"}#P(){return this.#c(this.#e,"[")}#O(){return this.#c(this.#e,"]")}#l(){let e=this.#r[this.#e],t=this.#x(this.#a).index;return this.#o.substring(t,e.index)}#S(){let e={};Object.assign(e,Fo),e.encodePart=Km;let t=aL(this.#l(),void 0,e);this.#f=xE(t)}},zm=["protocol","username","password","hostname","port","pathname","search","hash"],Ao="*";function uE(e,t){if(typeof e!="string")throw new TypeError("parameter 1 is not of type 'string'.");let r=new URL(e,t);return{protocol:r.protocol.substring(0,r.protocol.length-1),username:r.username,password:r.password,hostname:r.hostname,port:r.port,pathname:r.pathname,search:r.search!==""?r.search.substring(1,r.search.length):void 0,hash:r.hash!==""?r.hash.substring(1,r.hash.length):void 0}}function io(e,t){return t?wi(e):e}function Ei(e,t,r){let o;if(typeof t.baseURL=="string")try{o=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=io(o.protocol.substring(0,o.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=io(o.username,r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=io(o.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=io(o.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=io(o.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=io(o.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=io(o.search.substring(1,o.search.length),r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=io(o.hash.substring(1,o.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=bL(t.protocol,r)),typeof t.username=="string"&&(e.username=gL(t.username,r)),typeof t.password=="string"&&(e.password=hL(t.password,r)),typeof t.hostname=="string"&&(e.hostname=dL(t.hostname,r)),typeof t.port=="string"&&(e.port=xL(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,o&&!pL(e.pathname,r)){let n=o.pathname.lastIndexOf("/");n>=0&&(e.pathname=io(o.pathname.substring(0,n+1),r)+e.pathname)}e.pathname=yL(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=fL(t.search,r)),typeof t.hash=="string"&&(e.hash=mL(t.hash,r)),e}function wi(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function PL(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function OL(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",o=^${PL(t.delimiter)}+?,n=/[$_\u200C\u200D\p{ID_Continue}]/u,s="";for(let i=0;i<e.length;++i){let a=e[i];if(a.type===3){if(a.modifier===3){s+=wi(a.value);continue}s+={${wi(a.value)}}${cs(a.modifier)};continue}let c=a.hasCustomName(),l=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!t.prefixes.includes(a.prefix)),u=i>0?e[i-1]:null,p=i<e.length-1?e[i+1]:null;if(!l&&c&&a.type===1&&a.modifier===3&&p&&!p.prefix.length&&!p.suffix.length)if(p.type===3){let f=p.value.length>0?p.value[0]:"";l=n.test(f)}else l=!p.hasCustomName();if(!l&&!a.prefix.length&&u&&u.type===3){let f=u.value[u.value.length-1];l=t.prefixes.includes(f)}l&&(s+="{"),s+=wi(a.prefix),c&&(s+=:${a.name}),a.type===2?s+=(${a.value}):a.type===1?c||(s+=(${o})):a.type===0&&(!c&&(!u||u.type===3||u.modifier!==3||l||a.prefix!=="")?s+="*":s+=(${r})),a.type===1&&c&&a.suffix.length&&n.test(a.suffix[0])&&(s+="\\"),s+=wi(a.suffix),l&&(s+="}"),a.modifier!==3&&(s+=cs(a.modifier))}return s}var kE=class{#o;#r={};#t={};#e={};#i={};#a=!1;constructor(e={},t,r){try{let o;if(typeof t=="string"?o=t:r=t,typeof e=="string"){let a=new _L(e);if(a.parse(),e=a.result,o===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=o}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(o)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let n={ignoreCase:r.ignoreCase===!0},s={pathname:Ao,protocol:Ao,username:Ao,password:Ao,hostname:Ao,port:Ao,search:Ao,hash:Ao};this.#o=Ei(s,e,!0),bE(this.#o.protocol)===this.#o.port&&(this.#o.port="");let i;for(i of zm){if(!(i in this.#o))continue;let a={},c=this.#o[i];switch(this.#t[i]=[],i){case"protocol":Object.assign(a,Fo),a.encodePart=Km;break;case"username":Object.assign(a,Fo),a.encodePart=EL;break;case"password":Object.assign(a,Fo),a.encodePart=wL;break;case"hostname":Object.assign(a,cL),gE(c)?a.encodePart=wE:a.encodePart=EE;break;case"port":Object.assign(a,Fo),a.encodePart=RE;break;case"pathname":xE(this.#r.protocol)?(Object.assign(a,lL,n),a.encodePart=RL):(Object.assign(a,Fo,n),a.encodePart=kL);break;case"search":Object.assign(a,Fo,n),a.encodePart=vL;break;case"hash":Object.assign(a,Fo,n),a.encodePart=TL;break}try{this.#i[i]=fE(c,a),this.#r[i]=dE(this.#i[i],this.#t[i],a),this.#e[i]=OL(this.#i[i],a),this.#a=this.#a||this.#i[i].some(l=>l.type===2)}catch{throw new TypeError(invalid ${i} pattern '${this.#oi}'.)}}}catch(o){throw new TypeError(Failed to construct 'URLPattern': ${o.message})}}test(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return!1;try{typeof e=="object"?r=Ei(r,e,!1):r=Ei(r,uE(e,t),!1)}catch{return!1}let o;for(o of zm)if(!this.#r[o].exec(r[o]))return!1;return!0}exec(e={},t){let r={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof e!="string"&&t)throw new TypeError("parameter 1 is not of type 'string'.");if(typeof e>"u")return;try{typeof e=="object"?r=Ei(r,e,!1):r=Ei(r,uE(e,t),!1)}catch{return null}let o={};t?o.inputs=[e,t]:o.inputs=[e];let n;for(n of zm){let s=this.#r[n].exec(r[n]);if(!s)return null;let i={};for(let[a,c]of this.#t[n].entries())if(typeof c=="string"||typeof c=="number"){let l=s[a+1];i[c]=l}o[n]={input:r[n]??"",groups:i}}return o}static compareComponent(e,t,r){let o=(a,c)=>{for(let l of["type","modifier","prefix","value","suffix"]){if(a[l]<c[l])return-1;if(a[l]!==c[l])return 1}return 0},n=new Ri(3,"","","","",3),s=new Ri(0,"","","","",3),i=(a,c)=>{let l=0;for(;l<Math.min(a.length,c.length);++l){let u=o(a[l],c[l]);if(u)return u}return a.length===c.length?0:o(a[l]??n,c[l]??n)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?i(t.#i[e],[s]):!t.#e[e]&&r.#e[e]?i([s],r.#i[e]):i(t.#i[e],r.#i[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#a}};globalThis.URLPattern||(globalThis.URLPattern=kE);var vE,TE=async(e,t)=>(vE??=Lc({wasm:e,worker:t}),await vE,async r=>{let{outputFiles:o}=await Oc({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[Lb(),lE({fetch:SL,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:o[0].text}}),SL=async(e,t)=>{let r=Nb(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let o=await Ym(e);if(o)return o}try{let o=await r(e);return o.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await Wa(e,o),L([o,!1])):await Ym(e)??M({name:"HTTPError",message:${o.status} ${o.statusText},response:o})}catch(o){let n=await Ym(e);if(n)return n;if(o instanceof TypeError)return M({name:"NetworkError",message:o.message,request:e});if(o instanceof DOMException)return M({name:"AbortError",message:o.message,request:e});throw o}},Ym=async e=>{if(e.url.startsWith("data:"))return;let t=await wo(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),L([t,!0])};var _E=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var PE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},OE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},SE=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},LE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var NE=()=>{let e;return{show:(o,{x:n,y:s})=>{e=LL(),e.append(NL(o)),e.style.visibility="hidden",document.body.append(e);let{height:i}=e.getBoundingClientRect();e.style.top=${s-i}px,e.style.left=${n}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(o=>setTimeout(o,150)),e?.remove?.()}}},LL=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},NL=e=>{let t=document.createElement("pre");return t.classList.add("tooltip-inner"),t.style.textAlign="unset",t.style.maxWidth="70vw",t.style.margin="unset",t.innerText=e,t};var ME=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:o}=NE();return{component:e,setStatus:async(s,i)=>{switch(e.textContent="",await o(),s){case"loading":e.append(SE());break;case"pass":e.append(PE());break;case"fail":e.append(OE());break;case"none":break}i!==void 0&&s!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await o();else{let{top:a,left:c}=e.getBoundingClientRect();r(i,{y:a+globalThis.scrollY,x:c})}t=!t}):e.style.pointerEvents="none"}}};var CE=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(LE()),t.addEventListener("click",e),t};var IE=e=>{let{component:t,setStatus:r}=ME(),o=document.createElement("div");return o.style.position="absolute",o.style.left="-2em",o.style.zIndex="1",o.style.display="flex",o.style.flexFlow="column",o.append(CE(e),t),{menu:o,setStatus:r}};function AE(e){return new Promise(t=>setTimeout(t,e))}function FE(e,t){let{trailing:r=!1,interval:o=0}=t??{},n,s=!1,i=l=>{n?.resolve?.({executed:!1}),n=l},a=()=>{let{...l}=n;return n=void 0,l},c=async()=>{if(s||!n)return;s=!0,o>0&&await AE(o);let{parameters:l,resolve:u,reject:p}=a();try{let f=await e(...l);s=!1,u({result:f,executed:!0})}catch(f){s=!1,p(f)}finally{r?await c():(i(),await Promise.resolve())}};return(...l)=>new Promise((u,p)=>{i({parameters:l,resolve:u,reject:p}),c()})}var DE,UE=async(e,t)=>{let r=[],n=FE(async()=>{r.forEach(({menu:i,setStatus:a})=>{a("none"),i.remove()});let s=Xx(scrapbox.Project.name,scrapbox.Page.title??"",At());for(let i of s){let a=i.lang.toLowerCase();if(_E(a))for(let c of i.startIds){let l=document.getElementById(L${c}),{menu:u,setStatus:p}=IE(async()=>{await p("loading");try{DE??=await TE(e,t);let{contents:f}=await DE(i.path);console.debug("execute:",f),await Function(return (async()=>{${f}})())(),await p("pass")}catch(f){console.error(f),await p("fail",${f})}});r.push({menu:u,setStatus:p}),l?.insertBefore?.(u,l?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await n(),scrapbox.addListener("lines:changed",n),()=>{scrapbox.removeListener("lines:changed",n),r.forEach(({menu:s,setStatus:i})=>{i("none"),s.remove()})}};function CL(e,t){for(var r in t)e[r]=t[r];return e}function $E(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var o in t)if(o!=="__source"&&e[o]!==t[o])return!0;return!1}function Vc(e,t){var r=t(),o=Q({t:{__:r,u:t}}),n=o[0].t,s=o[1];return Sa(function(){n.__=r,n.u=t,Xm(n)&&s({t:n})},[e,r,t]),te(function(){return Xm(n)&&s({t:n}),e(function(){Xm(n)&&s({t:n})})},[e]),r}function Xm(e){var t,r,o=e.u,n=e.__;try{var s=o();return!((t=n)===(r=s)&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}}function jE(e,t){this.props=e,this.context=t}(jE.prototype=new br).isPureReactComponent=!0,jE.prototype.shouldComponentUpdate=function(e,t){return $E(this.props,e)||$E(this.state,t)};var BE=re.__b;re.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),BE&&BE(e)};var Awe=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var IL=re.__e;re.__e=function(e,t,r,o){if(e.then){for(var n,s=t;s=s.__;)if((n=s.__c)&&n.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),n.__c(e,t)}IL(e,t,r,o)};var HE=re.unmount;function KE(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=CL({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return KE(o,t,r)})),e}function YE(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return YE(o,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function Jm(){this.__u=0,this.o=null,this.__b=null}function XE(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function zc(){this.i=null,this.l=null}re.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),HE&&HE(e)},(Jm.prototype=new br).__c=function(e,t){var r=t.__c,o=this;o.o==null&&(o.o=[]),o.o.push(r);var n=XE(o.__v),s=!1,i=function(){s||(s=!0,r.__R=null,n?n(a):a())};r.__R=i;var a=function(){if(!--o.__u){if(o.state.__a){var c=o.state.__a;o.__v.__k[0]=YE(c,c.__c.__P,c.__c.__O)}var l;for(o.setState({__a:o.__b=null});l=o.o.pop();)l.forceUpdate()}};o.__u++||32&t.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},Jm.prototype.componentWillUnmount=function(){this.o=[]},Jm.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=KE(this.__b,r,o.__O=o.__P)}this.__b=null}var n=t.__a&&Kr(ee,null,e.fallback);return n&&(n.__u&=-33),[Kr(ee,null,t.__a?null:e.children),n]};var WE=function(e,t,r){if(++r[1]===r[0]&&e.l.delete(t),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(r=e.i;r;){for(;r.length>3;)r.pop()();if(r[1]<r[0])break;e.i=r=r[2]}};(zc.prototype=new br).__a=function(e){var t=this,r=XE(t.__v),o=t.l.get(e);return o[0]++,function(n){var s=function(){t.props.revealOrder?(o.push(n),WE(t,e,o)):n()};r?r(s):s()}},zc.prototype.render=function(e){this.i=null,this.l=new Map;var t=bo(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&t.reverse();for(var r=t.length;r--;)this.l.set(t[r],this.i=[1,0,this.i]);return e.children},zc.prototype.componentDidUpdate=zc.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){WE(e,r,t)})};var AL=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,FL=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,DL=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,UL=/[A-Z0-9]/g,$L=typeof document<"u",jL=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};br.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(br.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var qE=re.event;function BL(){}function HL(){return this.cancelBubble}function WL(){return this.defaultPrevented}re.event=function(e){return qE&&(e=qE(e)),e.persist=BL,e.isPropagationStopped=HL,e.isDefaultPrevented=WL,e.nativeEvent=e};var JE,qL={enumerable:!1,configurable:!0,get:function(){return this.class}},GE=re.vnode;re.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,o=t.type,n={},s=o.indexOf("-")===-1;for(var i in r){var a=r[i];if(!(i==="value"&&"defaultValue"in r&&a==null||$L&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var c=i.toLowerCase();i==="defaultValue"&&"value"in r&&r.value==null?i="value":i==="download"&&a===!0?a="":c==="translate"&&a==="no"?a=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?i="ondblclick":c!=="onchange"||o!=="input"&&o!=="textarea"||jL(r.type)?c==="onfocus"?i="onfocusin":c==="onblur"?i="onfocusout":DL.test(i)&&(i=c):c=i="oninput":s&&FL.test(i)?i=i.replace(UL,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&n[i=c]&&(i="oninputCapture"),n[i]=a}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=bo(r.children).forEach(function(l){l.props.selected=n.value.indexOf(l.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=bo(r.children).forEach(function(l){l.props.selected=n.multiple?n.defaultValue.indexOf(l.props.value)!=-1:n.defaultValue==l.props.value})),r.class&&!r.className?(n.class=r.class,Object.defineProperty(n,"className",qL)):(r.className&&!r.class||r.class&&r.className)&&(n.class=n.className=r.className),t.props=n}(e),e.$$typeof=AL,GE&&GE(e)};var zE=re.__r;re.__r=function(e){zE&&zE(e),JE=e.__c};var VE=re.diffed;re.diffed=function(e){VE&&VE(e);var t=e.props,r=e.__e;r!=null&&e.type==="textarea"&&"value"in t&&t.value!==r.value&&(r.value=t.value==null?"":t.value),JE=null};var QE=({title:e,projects:t,selected:r,confirm:o})=>d("div",{className:candidate${r?" selected":""},children:[d(GL,{title:e,confirm:o}),t.map(n=>d(zL,{project:n.name,title:e,mark:n.mark,confirm:n.confirm}))]}),GL=({title:e,confirm:t})=>d("a",{className:"button",tabIndex:0,role:"menuitem",href:./${ne(e)},onClick:ZE(t),children:e}),zL=({project:e,title:t,mark:r,confirm:o})=>{let n=ZE(o);return r===""?null:d("a",{className:"mark",tabIndex:0,href:../${e}/${ne(t)},onClick:n,title:/${e}/${ne(t)},children:r instanceof URL?d("img",{src:r.href}):${r}})},ZE=e=>U(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},[e]);var ew=(e,t)=>{let[r,o]=Q(null),n=U(c=>o(l=>{if(e.length===0)return null;if(l===null)return t(e[0]);let u=e.findIndex(p=>t(p)===l);return t(c?.cyclic?e[(u+1)%e.length]:e.at(u+1)??e[0])}),[e,t]),s=U(c=>o(l=>{if(e.length===0)return null;if(l===null)return t(e[e.length-1]);let u=e.findIndex(p=>t(p)===l);return u<0?t(e[e.length-1]):t(c?.cyclic?e[(u-1+e.length)%e.length]:e.at(u-1)??e[e.length-1])}),[e,t]),i=U(()=>o(e.length===0?null:t(e[0])),[e,t]),a=U(()=>o(e.length===0?null:t(e[e.length-1])),[e,t]);return{selectedId:r,next:n,prev:s,selectFirst:i,selectLast:a}};var tw=e=>{let[t,r]=Q(null),o=H(()=>{let n=t?.getBoundingClientRect?.(),i=Ks(e.line,e.char)?.getBoundingClientRect?.();return!i||!n?{}:{top:${i.bottom-n.top}px,left:${i?.left??0-n.left}px,right:${n.right-(i?.left??0)}px}},[t,e.line,e.char]);return{updateStandardElement:r,...o}};var Zm="enableProjectsOnSuggestion",rw=(e,t)=>{let[r,o]=Q(Kc([...e],t)),n=U((s,i)=>{VL(s,i,e,t),o(Kc([...e],t))},[e,t.enableSelfProjectOnStart]);return te(()=>{let s=i=>{i.key===Zm&&o(Kc([...e],t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},[e,t.enableSelfProjectOnStart]),{projects:r,set:n}},Qm=!0,Kc=(e,t)=>{try{let r=localStorage.getItem(Zm);if(r===null)return Yc(e),e;let o=JSON.parse(r);return Array.isArray(o)&&o.every(n=>typeof n=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?o:o.includes(scrapbox.Project.name)?Qm?o:o.filter(n=>n!==scrapbox.Project.name):Qm?[...o,scrapbox.Project.name]:o:(Yc(e),e)}catch(r){if(!(r instanceof TypeError))throw r;return Yc(e),e}},VL=(e,t,r,o)=>{let n=Kc([...r],o);o.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(Qm=t),Yc(t?[...n,e]:n.filter(s=>s!==e))},Yc=e=>localStorage.setItem(Zm,JSON.stringify(e));var ow=()=>H(()=>document.documentElement.dataset.os??"",[]);var ki=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(o){if(!(o instanceof TypeError))throw o;return e}}};var nw=({progress:e})=>d("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 iw=({position:e,start:t,enableSelfProjectOnStart:r,projects:o,...n})=>{let{projects:s,set:i}=rw(o,{enableSelfProjectOnStart:r}),{updateStandardElement:a,top:c,left:l,right:u}=tw({line:e.line,char:t}),p=ow();return d(ee,{children:[d(YL,{itemCount:n.items.length,enableProjects:s,projects:o,top:c,right:u,set:i,os:p,...n}),d(KL,{updateStandardElement:a,start:t,enableProjects:s,projects:o,top:c,left:l,os:p,...n})]})},KL=({start:e,updateStandardElement:t,confirmAfter:r,cancel:o,query:n,enableProjects:s,projects:i,items:a,top:c,left:l,progress:u,callback:p,limit:f,mark:m,os:h})=>{let g=U((N,_,P)=>{let I=[${_?/${_}/${N}:N}${P?.icon?".icon":""}];r(($,{line:j})=>[${...$.slice(0,e).join("")}${I}${...$.slice(e+...n.length).join("")},{line:j,char:e+[...I].length}])},[e,n]),y=H(()=>i.size>1||!i.has(scrapbox.Project.name),[i]),x=H(()=>{let N=[];for(let _ of a){if(N.length===f)break;_.projects.some(P=>s.includes(P))&&N.push({title:_.title,projects:_.projects.flatMap(P=>s.includes(P)?[{name:P,mark:y?ki(m[P]??"",import.meta.url)||P[0]:"",confirm:I=>g(_.title,P,I)}]:[]),confirm:P=>g(_.title,void 0,P)})}return N},[s,y,a,f,m,g]),{selectedId:w,next:k,prev:b,selectLast:T,selectFirst:v}=ew(x,sw),A=U(N=>w===null?!1:(x.find(_=>sw(_)===w)?.confirm?.(N),!0),[w,x]);te(()=>p(x.length===0?void 0:{selectNext:N=>(k(N),!0),selectPrev:N=>(b(N),!0),selectFirst:()=>(v(),!0),selectLast:()=>(T(),!0),confirm:A,cancel:()=>(o(),!0)}),[p,x.length,k,b,v,T,A]);let F=H(()=>x.length>0&&c!=null&&l!=null?{top:c,left:l}:{display:"none"},[x.length,c,l]),D=U(N=>{if(!N){t(N);return}let _=N.parentNode;if(!(_ instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(_.host.parentElement)},[t]);return d("div",{ref:D,className:"container candidates","data-os":h,style:F,children:[x.map(N=>d(QE,{...N,selected:w===N.title},N.title)),a.length>f&&d("div",{className:"counter",children:${a.length-f} more links}),d(nw,{progress:u})]})},YL=({enableProjects:e,projects:t,projectScore:r,mark:o,itemCount:n,top:s,right:i,set:a,os:c,freezeUntil:l})=>{let u=H(()=>[...t].sort((f,m)=>(r.get(m)??0)-(r.get(f)??0)).flatMap(f=>r.has(f)?[{name:f,enable:e.includes(f),mark:ki(o[f]??"",import.meta.url)||f[0],score:r.get(f),onClick:()=>l(()=>{a(f,!e.includes(f)),ht().focus()})}]:[]),[t,r,e,o]),p=H(()=>n>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},[s,i,n,t.size]);return d("div",{className:"container projects","data-os":c,style:p,children:u.map(f=>d(XL,{...f},f.name))})},XL=e=>d("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name,children:e.mark instanceof URL?d("img",{src:e.mark.href}):${e.mark}}),sw=e=>e.title;var aw=e=>{let t=H(()=>ki(e.style,import.meta.url),[e.style]);return d(ee,{children:t!==""&&(t instanceof URL?d("link",{rel:"stylesheet",href:t.href}):d("style",{children:t}))})};var cw=()=>d("style",{children:.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;
}
.candidates:not(data-os*="android"):not(data-os*="ios") {
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
.projects:is(data-os*="android", data-os*="ios") > * {
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;
}
.progressstyle {
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
}});function*lw(e){if(!("nodes"in e))return;let t=0;function*r(o){for(let n of Array.isArray(o)?o:[o]){if(typeof n=="string"){t+=[...n].length;continue}switch(n.type){case"link":yield{whole:n.unit.whole,start:t},t+=[...n.unit.whole].length;break;case"indent":case"quote":t+=[...n.unit.tag].length,yield*r(n.children);break;case"deco":t+=[...n.unit.deco].length+2,yield*r(n.children),t++;break;case"strong":t+=2,yield*r(n.children),t+=2;break;default:t+=[...n.unit.whole].length;break}}}yield*r(e.nodes)}var pw=(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 r=Math.min(t.range.start.char,t.range.end.char),o=Math.max(t.range.start.char,t.range.end.char),n=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(r,o).join(""):"";if(QL(t.lines[t.position.line],n)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:n,start:r,position:t.position};if(n!=="")return e.type==="completion"?{type:"ready"}:e;let s=JL(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"}},JL=(e,t)=>{for(let{whole:r,start:o}of lw(e))if(!(t<=o||o+[...r].length<=t))return{whole:r,start:o}},QL=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var uw=()=>{let e=dt(scrapbox.Page.lines),t=dt(!1);return te(()=>{let r=()=>{t.current=!0};return scrapbox.addListener("lines:changed",r),scrapbox.addListener("layout:changed",r),()=>{scrapbox.removeListener("lines:changed",r),scrapbox.removeListener("layout:changed",r)}},[]),U(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var ZL=Bn("scrapbox-select-suggestion:useLifecycle.ts"),mw=()=>{let[e,t]=Eo(pw,{type:"ready"}),r=uw(),o=H(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:c,selection:l}=Bt();t({type:a,lines:r(),range:l.getRange({normalizeOrder:!0}),position:c.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);te(()=>{let i=()=>{o("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{o("selection:changed")},c=qa();return c.addChangeListener(a),()=>{scrapbox.removeListener("lines:changed",i),scrapbox.removeListener("layout:changed",i),c.removeChangeListener(a)}},[]),te(()=>{if(e.context!=="input")return;let i=()=>{o("cursor:changed")},a=Ro();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[n,s]=Q(e);return n!==e&&(s(e),ZL.debug("Detect changes",e)),{state:e,setEnable:U(i=>t({type:i?"enable":"disable"}),[]),cancel:U(()=>t({type:"cancel"}),[]),freezeUntil:U(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:U(async i=>{let a=r();if(!a)return;t({type:"lock"});let{cursor:c,selection:l}=Bt(),u=c.getPosition().line,p=a[u].text,[f,m]=i(p,c.getPosition());l.setRange({start:{line:u,char:0},end:{line:u,char:[...p].length}}),await ct(f),c.setPosition(m),c.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var fw=(e,t)=>{let r=e.dist-t.dist;if(r!==0)return r;let o=e.matches.map(([i])=>i).sort(),n=t.matches.map(([i])=>i).sort();for(let i=0;i<o.length;i++){let a=o[i]-(n[i]??n.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var hw=Symbol("Comlink.proxy"),eN=Symbol("Comlink.endpoint"),rf=Symbol("Comlink.releaseProxy"),ef=Symbol("Comlink.finalizer"),Jc=Symbol("Comlink.thrown"),gw=e=>typeof e=="object"&&e!==null||typeof e=="function",tN={canHandle:e=>gw(e)&&e[hw],serialize(e){let{port1:t,port2:r}=new MessageChannel;return xw(e,t),[r,[r]]},deserialize(e){return e.start(),of(e)}},rN={canHandle:e=>gw(e)&&Jc in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},yw=new Map([["proxy",tN],["throw",rN]]);function oN(e,t){for(let r of e)if(t===r||r==="*"||r instanceof RegExp&&r.test(t))return!0;return!1}function xw(e,t=globalThis,r=["*"]){t.addEventListener("message",function o(n){if(!n||!n.data)return;if(!oN(r,n.origin)){console.warn(Invalid origin '${n.origin}' for comlink proxy);return}let{id:s,type:i,path:a}=Object.assign({path:[]},n.data),c=(n.data.argumentList||[]).map(Tn),l;try{let u=a.slice(0,-1).reduce((f,m)=>f[m],e),p=a.reduce((f,m)=>f[m],e);switch(i){case"GET":l=p;break;case"SET":u[a.slice(-1)[0]]=Tn(n.data.value),l=!0;break;case"APPLY":l=p.apply(u,c);break;case"CONSTRUCT":{let f=new p(...c);l=nf(f)}break;case"ENDPOINT":{let{port1:f,port2:m}=new MessageChannel;xw(e,m),l=cN(f,[f])}break;case"RELEASE":l=void 0;break;default:return}}catch(u){l={value:u,[Jc]:0}}Promise.resolve(l).catch(u=>({value:u,[Jc]:0})).then(u=>{let[p,f]=el(u);t.postMessage(Object.assign(Object.assign({},p),{id:s}),f),i==="RELEASE"&&(t.removeEventListener("message",o),bw(t),ef in e&&typeof e[ef]=="function"&&e[ef]())}).catch(u=>{let[p,f]=el({value:new TypeError("Unserializable return value"),[Jc]:0});t.postMessage(Object.assign(Object.assign({},p),{id:s}),f)})}),t.start&&t.start()}function nN(e){return e.constructor.name==="MessagePort"}function bw(e){nN(e)&&e.close()}function of(e,t){let r=new Map;return e.addEventListener("message",function(o){let{data:n}=o;if(!n||!n.id)return;let s=r.get(n.id);if(s)try{s(n)}finally{r.delete(n.id)}}),tf(e,r,[],t)}function Xc(e){if(e)throw new Error("Proxy has been released and is not useable")}function Ew(e){return ls(e,new Map,{type:"RELEASE"}).then(()=>{bw(e)})}var Qc=new WeakMap,Zc="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let t=(Qc.get(e)||0)-1;Qc.set(e,t),t===0&&Ew(e)});function sN(e,t){let r=(Qc.get(t)||0)+1;Qc.set(t,r),Zc&&Zc.register(e,t,e)}function iN(e){Zc&&Zc.unregister(e)}function tf(e,t,r=[],o=function(){}){let n=!1,s=new Proxy(o,{get(i,a){if(Xc(n),a===rf)return()=>{iN(s),Ew(e),t.clear(),n=!0};if(a==="then"){if(r.length===0)return{then:()=>s};let c=ls(e,t,{type:"GET",path:r.map(l=>l.toString())}).then(Tn);return c.then.bind(c)}return tf(e,t,[...r,a])},set(i,a,c){Xc(n);let[l,u]=el(c);return ls(e,t,{type:"SET",path:[...r,a].map(p=>p.toString()),value:l},u).then(Tn)},apply(i,a,c){Xc(n);let l=r[r.length-1];if(l===eN)return ls(e,t,{type:"ENDPOINT"}).then(Tn);if(l==="bind")return tf(e,t,r.slice(0,-1));let[u,p]=dw(c);return ls(e,t,{type:"APPLY",path:r.map(f=>f.toString()),argumentList:u},p).then(Tn)},construct(i,a){Xc(n);let[c,l]=dw(a);return ls(e,t,{type:"CONSTRUCT",path:r.map(u=>u.toString()),argumentList:c},l).then(Tn)}});return sN(s,e),s}function aN(e){return Array.prototype.concat.apply([],e)}function dw(e){let t=e.map(el);return[t.map(r=>r[0]),aN(t.map(r=>r[1]))]}var ww=new WeakMap;function cN(e,t){return ww.set(e,t),e}function nf(e){return Object.assign(e,{[hw]:!0})}function el(e){for(let[t,r]of yw)if(r.canHandle(e)){let[o,n]=r.serialize(e);return[{type:"HANDLER",name:t,value:o},n]}return[{type:"RAW",value:e},ww.get(e)||[]]}function Tn(e){switch(e.type){case"HANDLER":return yw.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ls(e,t,r,o){return new Promise(n=>{let s=lN();t.set(s,n),e.start&&e.start(),e.postMessage(Object.assign({id:s},r),o)})}function lN(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ps=Bn("scrapbox-select-suggestion:cancelableSearch.ts"),Rw=e=>{let t=of(e);return{load:async r=>{ps.debug("start loading source");let o=await t.load([...r]);return ps.debug(loaded ${o} candidates),o},search:(r,o)=>pN(r,o??5e3,t.search),[Symbol.dispose]:()=>{t[rf](),e instanceof MessagePort?e.close():e.terminate(),ps.debug("shared worker closed.")}}},pN=(e,t,r)=>{if(ps.debug("start searching: ",e),!e.trim())return new ReadableStream({start(s){s.close()}});let o=new Date,n=!1;return new ReadableStream({async start(s){try{await r(e,t,nf((i,a)=>(n||s.enqueue([i,a]),n))),s.close()}catch(i){s.error(i)}finally{n=!0;let a=new Date().getTime()-o.getTime();ps.debug(Comlink search completed for "${e}" in ${a}ms)}},cancel(){n=!0;let i=new Date().getTime()-o.getTime();ps.debug(Comlink search cancelled for "${e}" after ${i}ms)}})};var tl=(e,t)=>{let r=t?.interval??0,o=t?.maxQueued??1/0,n,s,i=[],a=(...c)=>{if(!n)return n=(async()=>{do{await new Promise(m=>{let h=setTimeout(m,r);s=()=>{for(clearTimeout(h);i.length>0;)i.shift()("discarded");m()}});let f=i.pop();if(!f)break;f("delayed")}while(i.length>0);n=void 0})(),new Promise(f=>f(e.call(a,...c,"immediate")));for(;i.length>Math.max(o,0);)i.shift()("discarded");let{promise:l,resolve:u,reject:p}=Promise.withResolvers();return i.push(f=>{try{u(e.call(a,...c,f))}catch(m){p(m)}}),l};return a.clear=()=>{s?.()},Object.defineProperty(a,"ready",{get:()=>n}),a};var vi=e=>e.query!=="",kw=e=>(t,r)=>{if("query"in r){if(r.query===t.query)return t;let i=vi(t)?t.job:void 0;if(!r.query)return i?.abort?.(),{query:""};let{run:a,abort:c}=e(r.query),l=i?.abort?.()?.then?.(a)??a();return{query:r.query,job:{done:l,abort:()=>(c(),l)},progress:0,candidates:vi(t)?t.candidates:[]}}if(!vi(t))return t;if(!r.candidates){let{progress:i,...a}=t;return i===r.progress?t:{progress:r.progress,...a}}let{candidates:o,progress:n,...s}=t;return o===r.candidates&&n===r.progress?t:{candidates:r.candidates??o,progress:r.progress,...s}};var Ti="SharedWorker"in globalThis;var fN=Bn("scrapbox-select-suggestion:useSearch.ts"),vw=(e,t)=>{let r=H(()=>Rw(Ti?new SharedWorker(t.workerUrl,{type:"module"}).port:new Worker(t.workerUrl,{type:"module"})),[t.workerUrl]);te(()=>(r.load(t.projects),()=>{using i=r}),[r,t.projects]);let o=U(kw(i=>{let a=!1;return{run:async()=>{let c=tl((u,p)=>{p!=="discarded"&&(a||s(u))},{interval:500,maxQueued:0}),l=[];for await(let[u,p]of r.search(i,1e4)){if(a)return;l=[...l,...u],s({progress:p}),u.length!==0&&c({progress:p,candidates:l})}c({progress:1,candidates:l})},abort:()=>a=!0}}),[r]),[n,s]=Eo(o,{query:""});return te(()=>s({query:e}),[e]),H(()=>{if(!vi(n))return;let[i,a]=dN(n.candidates);return fN.debug("Detect changes",{progress:n.progress,items:a}),{progress:n.progress,projectScore:i,items:a}},[n])},dN=e=>{let t=new Map,r=[];for(let o of e.sort(fw)){let n=[...o.metadata.keys()];for(let s of n)t.set(s,(t.get(s)??0)+.5**o.dist);r.push({title:o.title,dist:o.dist,projects:n})}return[t,r]};var Tw=(e,t)=>{let r=dt({...t});te(()=>(Object.assign(r.current,t),()=>{for(let o of Object.keys(t))delete r.current[o]}),[...Object.keys(t)].sort().map(o=>t[o])),te(()=>{e(r.current)},[e])};var hN={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},_w=e=>{let{state:t,setEnable:r,...o}=mw(),n=vw(t.type==="completion"?t.context==="input"?t.query.slice(1,-1):t.query:"",e),[s,i]=Q(),{callback:a,style:c,...l}=e;return Tw(a,{enable:U(()=>r(!0),[]),disable:U(()=>r(!1),[]),...t.type!=="completion"||!s?hN:s}),d(ee,{children:[d(cw,{}),d(aw,{style:c}),t.type==="completion"&&n&&d(iw,{callback:i,...n,...t,...o,...l})]})};var Pw=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let r=t.attachShadow({mode:"open"});document.body.append(t);let{limit:o=5,debug:n=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0,workerUrl:c}=e,l=new Set([...a?[scrapbox.Project.name]:[],...e.projects??[scrapbox.Project.name]]);return ka(n),new Promise(u=>vt(d(_w,{limit:o,projects:l,mark:s,style:i,callback:u,enableSelfProjectOnStart:a,workerUrl:c}),r))};var rr=e=>e.flatMap(t=>{let r=t.slice(1),o=Math.min(...r.map(n=>n.text.length-n.text.trimStart().length));return r.map(n=>n.text.slice(o))}).join(
).trim();function*Ow(e,t){for(let[r,o]of t.entries()){let n=e.get(r);if(n&&rr(n.blocks)===rr(o)){yield{changed:!1,filename:r};continue}yield{changed:!0,filename:r}}for(let r of e.keys())t.has(r)||(yield{changed:!0,filename:r})}var Sw=e=>{let t=new Map;if(e.length===0)return t;let r=at(e.map(n=>n.text).join(
),{hasTitle:!0}),o=0;for(let n of r)switch(n.type){case"title":case"line":o++;break;case"table":o+=n.cells.length+1;break;case"codeBlock":{let s=t.get(n.fileName)??[],i=n.content.split(
).length+1;s.push(e.slice(o,o+i)),t.set(n.fileName,s),o+=i;break}}return t};var Lw=e=>{let t,r,o=async()=>{for(;t;){let[n,s]=t;t=void 0;try{let i=await e(...n);s({type:"resolve",value:i})}catch(i){s({type:"reject",value:i})}}r=void 0};return(...n)=>{let{resolve:s,promise:i}=Promise.withResolvers();return t?.[1]?.({type:"cancel"}),t=[n,s],r??=o(),i}};var rl=class{constructor(t,r){this._filename=t;this._preview=Lw(async(o,n,s)=>(this._dispose=await r(s?{filename:this.filename,before:o,after:n,render:(...i)=>{s.textContent="",s.append(...i)}}:{filename:this.filename,before:o}),!1))}get filename(){return this._filename}get blocks(){return this._blocks??[]}async update(t){if(await this._dispose?.(),!t||rr(t)===""){let a=await this._preview(this.blocks);if(a.type==="cancel")return a;if(a.type==="reject")throw a.value;return this._area?.remove?.(),this._style?.remove?.(),this._area=void 0,this._style=void 0,this._blocks=void 0,{type:"resolve",value:!0}}let r=this.blocks;this._blocks=t,this.makeStyle();let o=this.makeArea(),n=t.at(0)?.at?.(-1)?.id,s=Xr(n);if(!s)throw new Error("div.lines#L${n}" could not be found.);s.insertAdjacentElement("afterend",o);let i=()=>{let a=s.getElementsByClassName("indent")[0];a instanceof HTMLElement&&(o.style.marginLeft=a.style.marginLeft)};return this._observer?.disconnect?.(),i(),this._observer=new MutationObserver(i),this._observer.observe(s,{childList:!0,subtree:!0}),this._preview(r,t,o)}makeArea(){if(this._area)return this._area;let t=document.createElement("div");return t.classList.add("scrap-run"),t.dataset.filename=this.filename,this._area=t,t}makeStyle(){let t=this.blocks.flatMap(o=>o.slice(1).map(({id:n})=>#L${n})),r=this.blocks.flatMap(o=>o.map(({id:n})=>#L${n}));this._style||(this._style=document.createElement("style"),document.head.append(this._style)),this._style.textContent=.lines:not(:has(:is(${...r.join(",")}).cursor-line)) :is(${...t.join(",")}){display:none}}_blocks;_dispose;_preview;_area;_observer;_style};var Nw=({previewers:e})=>{let t=new Map,r=()=>{let s=Sw(At());for(let{changed:i,filename:a}of Ow(t,s)){if(!i)continue;let c=s.get(a),l=t.get(a);if(!l){if(!c)continue;let u=e.find(({when:p})=>p.test(a))?.preview;if(!u)continue;l=new rl(a,u),t.set(a,l)}l.update(c).then(u=>{switch(u.type){case"resolve":u.value&&t.delete(a);return;case"reject":throw u.value;case"cancel":return}})}},o=()=>{if(scrapbox.Layout!=="page"){scrapbox.off("lines:changed",r);return}r(),scrapbox.on("lines:changed",r)};o(),scrapbox.on("page:changed",o);let n=document.createElement("style");return n.textContent=".scrap-run{display:block;width:95%}",document.head.append(n),()=>{scrapbox.off("page:changed",o),n.remove()}};var _i=e=>{let t=new FileReader,r=new Promise(o=>t.onload=()=>o(t.result));return t.readAsDataURL(e),r};var Mw=async e=>{if(!("after"in e))return;let t=rr(e.after),o=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("parsererror");if(o){let i=document.createElement("pre"),a=document.createElement("code");a.innerText=o.innerHTML,i.append(a),e.render(i);return}let n=await _i(new Blob([t],{type:"image/svg+xml"})),s=document.createElement("img");s.src=n,e.render(s)};var sf={};Ki(sf,{default:()=>Aw});var GN=Object.create,Iw=Object.defineProperty,zN=Object.getOwnPropertyDescriptor,VN=Object.getOwnPropertyNames,KN=Object.getPrototypeOf,YN=Object.prototype.hasOwnProperty,XN=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),JN=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of VN(t))!YN.call(e,n)&&n!==r&&Iw(e,n,{get:()=>t[n],enumerable:!(o=zN(t,n))||o.enumerable});return e},QN=(e,t,r)=>(r=e!=null?GN(KN(e)):{},JN(t||!e||!e.__esModule?Iw(r,"default",{value:e,enumerable:!0}):r,e)),ZN=XN((e,t)=>{t.exports=o;var r=Object.prototype.toString;function o(n){if(!n)return!1;var s=r.call(n);return s==="[object Function]"||typeof n=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(n===window.setTimeout||n===window.alert||n===window.confirm||n===window.prompt)}}),Cw=QN(ZN()),Aw=Cw.default??Cw;var af={};Ki(af,{default:()=>Uw});var eM=Object.create,Dw=Object.defineProperty,tM=Object.getOwnPropertyDescriptor,rM=Object.getOwnPropertyNames,oM=Object.getPrototypeOf,nM=Object.prototype.hasOwnProperty,sM=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),iM=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of rM(t))!nM.call(e,n)&&n!==r&&Dw(e,n,{get:()=>t[n],enumerable:!(o=tM(t,n))||o.enumerable});return e},aM=(e,t,r)=>(r=e!=null?eM(oM(e)):{},iM(t||!e||!e.__esModule?Dw(r,"default",{value:e,enumerable:!0}):r,e)),cM=sM((e,t)=>{var r=function(n){return n.replace(/^\s+|\s+$/g,"")},o=function(n){return Object.prototype.toString.call(n)==="[object Array]"};t.exports=function(n){if(!n)return{};for(var s=Object.create(null),i=r(n).split(
),a=0;a<i.length;a++){var c=i[a],l=c.indexOf(":"),u=r(c.slice(0,l)).toLowerCase(),p=r(c.slice(l+1));typeof s[u]>"u"?s[u]=p:o(s[u])?s[u].push(p):s[u]=[s[u],p]}return s}}),Fw=aM(cM()),Uw=Fw.default??Fw;var lM=(()=>{var e=globalThis;return{default:e}})(),pM=(()=>{var e=(...t)=>Object.assign({},...t);return{default:e}})(),us=e=>{let t=o=>typeof o.default<"u"?o.default:o,r=o=>Object.assign({__esModule:!0},o);switch(e){case"npm:global/window":return t(lM);case"is-function":return t(sf);case"parse-headers":return t(af);case"npm:xtend":return t(pM);default:return console.error('module "'+e+'" not found'),null}},uM=Object.create,jw=Object.defineProperty,mM=Object.getOwnPropertyDescriptor,fM=Object.getOwnPropertyNames,dM=Object.getPrototypeOf,hM=Object.prototype.hasOwnProperty,ol=(e=>typeof us<"u"?us:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof us<"u"?us:t)[r]}):e)(function(e){if(typeof us<"u")return us.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),gM=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),yM=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of fM(t))!hM.call(e,n)&&n!==r&&jw(e,n,{get:()=>t[n],enumerable:!(o=mM(t,n))||o.enumerable});return e},xM=(e,t,r)=>(r=e!=null?uM(dM(e)):{},yM(t||!e||!e.__esModule?jw(r,"default",{value:e,enumerable:!0}):r,e)),bM=gM((e,t)=>{"use strict";var r=ol("npm:global/window"),o=ol("is-function"),n=ol("parse-headers"),s=ol("npm:xtend");t.exports=l,t.exports.default=l,l.XMLHttpRequest=r.XMLHttpRequest||f,l.XDomainRequest="withCredentials"in new l.XMLHttpRequest?l.XMLHttpRequest:r.XDomainRequest,i(["get","put","post","patch","head","delete"],function(m){l[m==="delete"?"del":m]=function(h,g,y){return g=c(h,g,y),g.method=m.toUpperCase(),u(g)}});function i(m,h){for(var g=0;g<m.length;g++)h(m[g])}function a(m){for(var h in m)if(m.hasOwnProperty(h))return!1;return!0}function c(m,h,g){var y=m;return o(h)?(g=h,typeof m=="string"&&(y={uri:m})):y=s(h,{uri:m}),y.callback=g,y}function l(m,h,g){return h=c(m,h,g),u(h)}function u(m){if(typeof m.callback>"u")throw new Error("callback argument missing");var h=!1,g=function(j,q,B){h||(h=!0,m.callback(j,q,B))};function y(){b.readyState===4&&setTimeout(k,0)}function x(){var j=void 0;if(b.response?j=b.response:j=b.responseText||p(b),P)try{j=JSON.parse(j)}catch{}return j}function w(j){return clearTimeout(I),j instanceof Error||(j=new Error(""+(j||"Unknown XMLHttpRequest Error"))),j.statusCode=0,g(j,$)}function k(){if(!v){var j;clearTimeout(I),m.useXDR&&b.status===void 0?j=200:j=b.status===1223?204:b.status;var q=$,B=null;return j!==0?(q={body:x(),statusCode:j,method:F,headers:{},url:A,rawRequest:b},b.getAllResponseHeaders&&(q.headers=n(b.getAllResponseHeaders()))):B=new Error("Internal XMLHttpRequest Error"),g(B,q,q.body)}}var b=m.xhr||null;b||(m.cors||m.useXDR?b=new l.XDomainRequest:b=new l.XMLHttpRequest);var T,v,A=b.url=m.uri||m.url,F=b.method=m.method||"GET",D=m.body||m.data,N=b.headers=m.headers||{},_=!!m.sync,P=!1,I,$={body:void 0,headers:{},statusCode:0,method:F,url:A,rawRequest:b};if("json"in m&&m.json!==!1&&(P=!0,N.accept||N.Accept||(N.Accept="application/json"),F!=="GET"&&F!=="HEAD"&&(N["content-type"]||N["Content-Type"]||(N["Content-Type"]="application/json"),D=JSON.stringify(m.json===!0?D:m.json))),b.onreadystatechange=y,b.onload=k,b.onerror=w,b.onprogress=function(){},b.onabort=function(){v=!0},b.ontimeout=w,b.open(F,A,!_,m.username,m.password),_||(b.withCredentials=!!m.withCredentials),!_&&m.timeout>0&&(I=setTimeout(function(){if(!v){v=!0,b.abort("timeout");var j=new Error("XMLHttpRequest timeout");j.code="ETIMEDOUT",w(j)}},m.timeout)),b.setRequestHeader)for(T in N)N.hasOwnProperty(T)&&b.setRequestHeader(T,N[T]);else if(m.headers&&!a(m.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in m&&(b.responseType=m.responseType),"beforeSend"in m&&typeof m.beforeSend=="function"&&m.beforeSend(b),b.send(D||null),b}function p(m){try{if(m.responseType==="document")return m.responseXML;var h=m.responseXML&&m.responseXML.documentElement.nodeName==="parsererror";if(m.responseType===""&&!h)return m.responseXML}catch{}return null}function f(){}}),$w=xM(bM()),nl=$w.default??$w;var sl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r0e=function(){function e(r){this.value=r}function t(r){var o,n;function s(c,l){return new Promise(function(u,p){var f={key:c,arg:l,resolve:u,reject:p,next:null};n?n=n.next=f:(o=n=f,i(c,l))})}function i(c,l){try{var u=r[c](l),p=u.value;p instanceof e?Promise.resolve(p.value).then(function(f){i("next",f)},function(f){i("throw",f)}):a(u.done?"return":"normal",u.value)}catch(f){a("throw",f)}}function a(c,l){switch(c){case"return":o.resolve({value:l,done:!0});break;case"throw":o.reject(l);break;default:o.resolve({value:l,done:!1});break}o=o.next,o?i(o.key,o.arg):n=null}this._invoke=s,typeof r.return!="function"&&(this.return=void 0)}return typeof Symbol=="function"&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(r){return this._invoke("next",r)},t.prototype.throw=function(r){return this._invoke("throw",r)},t.prototype.return=function(r){return this._invoke("return",r)},{wrap:function(r){return function(){return new t(r.apply(this,arguments))}},await:function(r){return new e(r)}}}(),Ww=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},qw=function(){function e(t,r){for(var o=0;o<r.length;o++){var n=r[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(t,r,o){return r&&e(t.prototype,r),o&&e(t,o),t}}(),cf=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}else return Array.from(e)},Pi="";function EM(e){return
<table style="background-color: #8CE; width: 100%; height: 100%;"><tr>
<td align="center">
<div style="display: table-cell; vertical-align: middle;">
<div style="">+e+</div>
</div>
</td></tr></table>
}var wM=
This page requires a browser that supports WebGL.<br/>
<a href="http://get.webgl.org">Click here to upgrade your browser.</a>
,RM=
It does not appear your computer can support WebGL.<br/>
<a href="http://get.webgl.org/troubleshooting/">Click here for more information.</a>
,kM=1,vM=2;function TM(e,t,r){function o(i){var a=e.parentNode;a&&(a.innerHTML=EM(i))}function n(i,a){typeof r=="function"?r(i):o(a)}if(!window.WebGLRenderingContext)return n(kM,wM),null;var s=_M(e,t);return s?s.getExtension("OES_standard_derivatives"):n(vM,RM),s}function _M(e,t){for(var r=["webgl","experimental-webgl"],o=null,n=0;n<r.length;++n)try{o=e.getContext(r[n],t)}catch{if(o)break}return o}function ms(e,t,r,o){var n=e.gl,s=n.createShader(r);n.shaderSource(s,t),n.compileShader(s);var i=n.getShaderParameter(s,n.COMPILE_STATUS);return i?s:(Pi=n.getShaderInfoLog(s),console.error("*** Error compiling shader "+s+":"+Pi),e.trigger("error",{shader:s,source:t,type:r,error:Pi,offset:o||0}),n.deleteShader(s),null)}function Bw(e,t,r,o){for(var n=e.gl,s=n.createProgram(),i=0;i<t.length;++i)n.attachShader(s,t[i]);if(r)for(var a=0;a<r.length;++a)n.bindAttribLocation(s,o?o[a]:a,r[a]);n.linkProgram(s);var c=n.getProgramParameter(s,n.LINK_STATUS);return c?s:(Pi=n.getProgramInfoLog(s),console.log("Error in program linking:"+Pi),n.deleteProgram(s),null)}function lf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=[];for(var o in e){var n=e[o],s=void 0;if(t&&(o=t+"."+o),typeof n=="number")r.push({type:"float",method:"1f",name:o,value:n});else if(Array.isArray(n)){if(typeof n[0]=="number")n.length===1?r.push({type:"float",method:"1f",name:o,value:n}):n.length>=2&&n.length<=4?r.push({type:"vec"+n.length,method:n.length+"fv",name:o,value:n}):n.length>4&&r.push({type:"float[]",method:"1fv",name:o+"[0]",value:n});else if(typeof n[0]=="string")r.push({type:"sampler2D",method:"1i",name:o,value:n});else if(Array.isArray(n[0])&&typeof n[0][0]=="number"){if(n[0].length>=2&&n[0].length<=4)for(s=0;s<n.length;s++)r.push({type:"vec"+n[0].length,method:n[s].length+"fv",name:o+"["+s+"]",value:n[s]})}else if(sl(n[0])==="object")for(s=0;s<n.length;s++)r.push.apply(r,cf(lf(n[s],o+"["+s+"]")))}else typeof n=="boolean"?r.push({type:"bool",method:"1i",name:o,value:n}):typeof n=="string"?r.push({type:"sampler2D",method:"1i",name:o,value:n}):(typeof n>"u"?"undefined":sl(n))==="object"&&r.push.apply(r,cf(lf(n,o)))}return r}function PM(e){var t=e.getBoundingClientRect();return t.top+t.height>0&&t.top<(window.innerHeight||document.documentElement.clientHeight)}function Hw(e){return(e&e-1)===0}function OM(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function SM(e,t){return e&&t?e.toString()!==t.toString():!1}function LM(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(),t.status==200?t.responseText:""}function Gw(e){var t=new Set;return Object.assign(e,{on:function(r,o){var n={};n[r]=o,t.add(n)},off:function(r,o){if(o){var n={};n[r]=o,t.delete(n)}else{var s=!0,i=!1,a=void 0;try{for(var c=t[Symbol.iterator](),l;!(s=(l=c.next()).done);s=!0){var u=l.value,p=!0,f=!1,m=void 0;try{for(var h=Object.keys(u)[Symbol.iterator](),g;!(p=(g=h.next()).done);p=!0){var y=g.value;if(y===r){t.delete(u);return}}}catch(x){f=!0,m=x}finally{try{!p&&h.return&&h.return()}finally{if(f)throw m}}}}catch(x){i=!0,a=x}finally{try{!s&&c.return&&c.return()}finally{if(i)throw a}}}},listSubscriptions:function(){var r=!0,o=!1,n=void 0;try{for(var s=t[Symbol.iterator](),i;!(r=(i=s.next()).done);r=!0){var a=i.value;console.log(a)}}catch(c){o=!0,n=c}finally{try{!r&&s.return&&s.return()}finally{if(o)throw n}}},subscribe:function(r){t.add(r)},unsubscribe:function(r){t.delete(r)},unsubscribeAll:function(){t.clear()},trigger:function(r){for(var o=arguments.length,n=Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];var i=!0,a=!1,c=void 0;try{for(var l=t[Symbol.iterator](),u;!(i=(u=l.next()).done);i=!0){var p=u.value;typeof p[r]=="function"&&p[r].apply(p,cf(n))}}catch(f){a=!0,c=f}finally{try{!i&&l.return&&l.return()}finally{if(a)throw c}}}})}var pf=function(){function e(t,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Ww(this,e),Gw(this),this.gl=t,this.texture=t.createTexture(),this.texture&&(this.valid=!0),this.bind(),this.name=r,this.source=null,this.sourceType=null,this.loading=null,this.setData(1,1,new Uint8Array([0,0,0,255]),{filtering:"linear"}),this.setFiltering(o.filtering),this.load(o)}return qw(e,[{key:"destroy",value:function(){this.valid&&(this.gl.deleteTexture(this.texture),this.texture=null,delete this.data,this.data=null,this.valid=!1)}},{key:"bind",value:function(t){this.valid&&(typeof t=="number"&&e.activeUnit!==t&&(this.gl.activeTexture(this.gl.TEXTURE0+t),e.activeUnit=t),e.activeTexture!==this.texture&&(this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),e.activeTexture=this.texture))}},{key:"load",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.loading=null,typeof t.url=="string"?(this.url===void 0||t.url!==this.url)&&this.setUrl(t.url,t):t.element?this.setElement(t.element,t):t.data&&t.width&&t.height&&this.setData(t.width,t.height,t.data,t)}},{key:"setUrl",value:function(t){var r=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.valid)return this.url=t,this.source=this.url,this.sourceType="url",this.loading=new Promise(function(n,s){var i=t.split(".").pop().toLowerCase(),a=i==="ogv"||i==="webm"||i==="mp4",c=void 0;a?(c=document.createElement("video"),c.autoplay=!0,c.muted=!0,setTimeout(function(){c.play()},1),o.filtering="nearest"):c=new Image,c.onload=function(){try{r.setElement(c,o)}catch(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,o)}n(r)},c.onerror=function(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,o),n(r)},OM()&&r.source.slice(0,5)==="data:"||(c.crossOrigin="anonymous"),c.src=r.source,a&&r.setElement(c,o)}),this.loading}},{key:"setData",value:function(t,r,o){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.width=t,this.height=r,this.source=o,this.sourceType="data",this.update(n),this.setFiltering(n),this.loading=Promise.resolve(this),this.loading}},{key:"setElement",value:function(t,r){var o=this,n=t;if(typeof t=="string"&&(t=document.querySelector(t)),t instanceof HTMLCanvasElement||t instanceof HTMLImageElement||t instanceof HTMLVideoElement)this.source=t,this.sourceType="element",t instanceof HTMLVideoElement?(this.width=this.source.videoWidth,this.height=this.source.videoHeight,t.addEventListener("canplaythrough",function(){o.intervalID=setInterval(function(){o.update(r)},15)},!0),t.addEventListener("ended",function(){t.currentTime=0,t.play()},!0)):this.update(r),this.setFiltering(r);else{var s="the 'element' parameter (element: "+JSON.stringify(n)+") must be a CSS ";s+="selector string, or a <canvas>, <image> or <video> object",console.log("Texture '"+this.name+"': "+s,r)}return this.loading=Promise.resolve(this),this.loading}},{key:"update",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.valid&&(this.bind(),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,t.UNPACK_FLIP_Y_WEBGL!==!1),this.gl.pixelStorei(this.gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.UNPACK_PREMULTIPLY_ALPHA_WEBGL||!1),this.sourceType==="element"&&(this.source instanceof HTMLCanvasElement||this.source instanceof HTMLVideoElement||this.source instanceof HTMLImageElement&&this.source.complete)?(this.source instanceof HTMLVideoElement?(this.width=this.source.videoWidth,this.height=this.source.videoHeight):(this.width=this.source.width,this.height=this.source.height),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.source)):this.sourceType==="data"&&this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.width,this.height,0,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.source),this.trigger("loaded",this))}},{key:"setFiltering",value:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.valid){this.powerOf2=Hw(this.width)&&Hw(this.height),this.filtering=t.filtering||"linear";var r=this.gl;this.bind(),this.powerOf2?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,t.TEXTURE_WRAP_S||r.REPEAT),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,t.TEXTURE_WRAP_T||r.REPEAT),this.filtering==="mipmap"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.generateMipmap(r.TEXTURE_2D)):this.filtering==="linear"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)):this.filtering==="nearest"&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST))):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),this.filtering==="mipmap"&&(this.filtering="linear"),this.filtering==="nearest"?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST)):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR)))}}}]),e}();pf.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)};pf.activeUnit=-1;var zw=function(){function e(t,r,o){var n=this;Ww(this,e),Gw(this),r=r||{},o=o||{},t.hasAttribute("data-fullscreen")&&(t.getAttribute("data-fullscreen")=="1"||t.getAttribute("data-fullscreen")=="true")?(this.width=window.innerWidth,this.height=window.innerHeight,t.width=window.innerWidth,t.height=window.innerHeight):(this.width=t.clientWidth,this.height=t.clientHeight),this.canvas=t,this.gl=void 0,this.deps={},this.program=void 0,this.textures={},this.buffers={},this.uniforms={},this.vbo={},this.isValid=!1,this.animationFrameRequest=void 0,this.BUFFER_COUNT=0,this.vertexString=r.vertexString||
#ifdef GL_ES
precision mediump float;
#endif
attribute vec2 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
void main() {
gl_Position = vec4(a_position, 0.0, 1.0);
v_texcoord = a_texcoord;
}
,this.fragmentString=r.fragmentString||
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 v_texcoord;
void main(){
gl_FragColor = vec4(0.0);
}
;var s=TM(t,r,o.onError);if(!s)return;if(this.gl=s,this.timeLoad=this.timePrev=performance.now(),this.timeDelta=0,this.forceRender=!0,this.paused=!1,this.realToCSSPixels=window.devicePixelRatio||1,t.style.backgroundColor=r.backgroundColor||"rgba(1,1,1,0)",t.hasAttribute("data-fragment"))this.fragmentString=t.getAttribute("data-fragment");else if(t.hasAttribute("data-fragment-url")){var i=t.getAttribute("data-fragment-url");nl.get(i,function(g,y,x){n.load(x,n.vertexString)})}if(t.hasAttribute("data-vertex"))this.vertexString=t.getAttribute("data-vertex");else if(t.hasAttribute("data-vertex-url")){var a=t.getAttribute("data-vertex-url");nl.get(a,function(g,y,x){n.load(n.fragmentString,x)})}if(this.load(),!this.program)return;var c=s.getAttribLocation(this.program,"a_texcoord");this.vbo.texCoords=s.createBuffer(),this.gl.bindBuffer(s.ARRAY_BUFFER,this.vbo.texCoords),this.gl.bufferData(s.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),s.STATIC_DRAW),this.gl.enableVertexAttribArray(c),this.gl.vertexAttribPointer(c,2,s.FLOAT,!1,0,0);var l=s.getAttribLocation(this.program,"a_position");if(this.vbo.vertices=s.createBuffer(),this.gl.bindBuffer(s.ARRAY_BUFFER,this.vbo.vertices),this.gl.bufferData(s.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),s.STATIC_DRAW),this.gl.enableVertexAttribArray(l),this.gl.vertexAttribPointer(l,2,s.FLOAT,!1,0,0),t.hasAttribute("data-textures")){var u=t.getAttribute("data-textures").split(",");for(var p in u)this.setUniform("u_tex"+p,u[p])}var f={x:0,y:0};document.addEventListener("mousemove",function(g){f.x=g.clientX||g.pageX,f.y=g.clientY||g.pageY},!1);var m=this;function h(){m.nMouse>1&&m.setMouse(f),m.resize()&&(m.forceRender=!0),m.render(),m.animationFrameRequest=window.requestAnimationFrame(h)}return this.setMouse({x:0,y:0}),h(),this}return qw(e,[{key:"destroy",value:function(){cancelAnimationFrame(this.animationFrameRequest),this.animated=!1,this.isValid=!1;for(var t in this.textures)t.destroy&&t.destroy();this.textures={};for(var r in this.attribs)this.gl.deleteBuffer(this.attribs[r]);this.gl.useProgram(null),this.gl.deleteProgram(this.program);for(var o in this.buffers){var n=this.buffers[o];this.gl.deleteProgram(n.program)}this.program=null,this.gl=null}},{key:"load",value:function(t,r){var o=this;r&&(this.vertexString=r),t&&(this.fragmentString=t);var n=this.fragmentString.split(/\r?\n/);this.fragmentString=#define PLATFORM_WEBGL
#line 0
,n.forEach(function(g,y){var x=g.trim();if(x.startsWith('#include "lygia')){var w=x.substring(15).replace(/\'|\"|\;|\s/g,"");if(w.endsWith("glsl")){if(o.deps[w]===void 0){var k="https://lygia.xyz"+w;o.deps[w]=LM(k)}o.fragmentString+=o.deps[w]+
#line +(y+1)+
}}else o.fragmentString+=g+
}),this.animated=!1,this.nDelta=(this.fragmentString.match(/u_delta/g)||[]).length,this.nTime=(this.fragmentString.match(/u_time/g)||[]).length,this.nDate=(this.fragmentString.match(/u_date/g)||[]).length,this.nMouse=(this.fragmentString.match(/u_mouse/g)||[]).length,this.animated=this.nDate>1||this.nTime>1||this.nMouse>1;var s=this.fragmentString.search(/sampler2D/g);if(s)for(var i=this.fragmentString.split(
),a=0;a<i.length;a++){var c=i[a].match(/uniform\s*sampler2D\s*([\w]*);\s*\/\/\s*([\w|\:\/\/|\.|\-|\_]*)/i);if(c){var l=c[2].split(".").pop().toLowerCase();c[1]&&c[2]&&(l==="jpg"||l==="jpeg"||l==="png"||l==="ogv"||l==="webm"||l==="mp4")&&this.setUniform(c[1],c[2])}var u=i[a].match(/\s*void\s*main\s*/g);if(u)break}var p=ms(this,this.vertexString,this.gl.VERTEX_SHADER),f=ms(this,this.fragmentString,this.gl.FRAGMENT_SHADER);f?this.isValid=!0:(f=ms(this,void main(){
gl_FragColor = vec4(1.0);
},this.gl.FRAGMENT_SHADER),this.isValid=!1);var m=Bw(this,[p,f]);this.gl.useProgram(m),this.gl.deleteShader(p),this.gl.deleteShader(f),this.program=m,this.change=!0,this.BUFFER_COUNT=0;var h=this.getBuffers(this.fragmentString);Object.keys(h).length&&this.loadPrograms(h),this.buffers=h,this.texureIndex=this.BUFFER_COUNT,this.trigger("load",{}),this.forceRender=!0,this.render()}},{key:"test",value:function(t,r,o){var n=this.vertexString,s=this.fragmentString,i=this.paused,a=this.gl.getExtension("EXT_disjoint_timer_query"),c=a.createQueryEXT(),l=this.isValid;(r||o)&&(this.load(r,o),l=this.isValid,this.forceRender=!0,this.render()),this.paused=!0,a.beginQueryEXT(a.TIME_ELAPSED_EXT,c),this.forceRender=!0,this.render(),a.endQueryEXT(a.TIME_ELAPSED_EXT);var u=this;function p(){u.paused=i,(r||o)&&u.load(s,n)}function f(){u.forceRender=!0,u.render();var m=a.getQueryObjectEXT(c,a.QUERY_RESULT_AVAILABLE_EXT),h=u.gl.getParameter(a.GPU_DISJOINT_EXT);if(m&&!h){var g={wasValid:l,frag:r||u.fragmentString,vert:o||u.vertexString,timeElapsedMs:a.getQueryObjectEXT(c,a.QUERY_RESULT_EXT)/1e6};p(),t(g)}else window.requestAnimationFrame(f)}f()}},{key:"loadTexture",value:function(t,r,o){var n=this;o||(o={}),typeof r=="string"?o.url=r:(typeof r>"u"?"undefined":sl(r))==="object"&&r.data&&r.width&&r.height?(o.data=r.data,o.width=r.width,o.height=r.height):(typeof r>"u"?"undefined":sl(r))==="object"&&(o.element=r),this.textures[t]?this.textures[t]&&(this.textures[t].load(o),this.textures[t].on("loaded",function(s){n.forceRender=!0})):(this.textures[t]=new pf(this.gl,t,o),this.textures[t].on("loaded",function(s){n.forceRender=!0}))}},{key:"refreshUniforms",value:function(){this.uniforms={}}},{key:"setUniform",value:function(t){for(var r={},o=arguments.length,n=Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];r[t]=n,this.setUniforms(r)}},{key:"setUniforms",value:function(t){var r=lf(t);for(var o in r)r[o].type==="sampler2D"?this.loadTexture(r[o].name,r[o].value[0]):this.uniform(r[o].method,r[o].type,r[o].name,r[o].value);this.forceRender=!0}},{key:"setMouse",value:function(t){var r=this.canvas.getBoundingClientRect();if(t&&t.x&&t.x>=r.left&&t.x<=r.right&&t.y&&t.y>=r.top&&t.y<=r.bottom){var o=(t.x-r.left)*this.realToCSSPixels,n=this.canvas.height-(t.y-r.top)*this.realToCSSPixels;this.uniform("2f","vec2","u_mouse",o,n)}}},{key:"uniform",value:function(t,r,o){this.uniforms[o]=this.uniforms[o]||{};for(var n=this.uniforms[o],s=arguments.length,i=Array(s>3?s-3:0),a=3;a<s;a++)i[a-3]=arguments[a];var c=SM(n.value,i);if(c||this.change||!n.location||!n.value){n.name=o,n.type=r,n.value=i,n.method="uniform"+t,this.gl.useProgram(this.program),n.location=this.gl.getUniformLocation(this.program,o),this.gl[n.method].apply(this.gl,[n.location].concat(n.value));for(var l in this.buffers){var u=this.buffers[l];this.gl.useProgram(u.program);var p=this.gl.getUniformLocation(u.program,o);this.gl[n.method].apply(this.gl,[p].concat(n.value))}}}},{key:"uniformTexture",value:function(t,r,o){if(this.textures[t]===void 0)this.loadTexture(t,r,o);else{this.uniform("1i","sampler2D",t,this.texureIndex);for(var n in this.buffers){var s=this.buffers[n];this.gl.useProgram(s.program),this.gl.activeTexture(this.gl.TEXTURE0+this.texureIndex),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textures[t].texture)}this.gl.useProgram(this.program),this.gl.activeTexture(this.gl.TEXTURE0+this.texureIndex),this.gl.bindTexture(this.gl.TEXTURE_2D,this.textures[t].texture),this.uniform("2f","vec2",t+"Resolution",this.textures[t].width,this.textures[t].height)}}},{key:"resize",value:function(){if(this.width!==this.canvas.clientWidth||this.height!==this.canvas.clientHeight){this.realToCSSPixels=window.devicePixelRatio||1;var t=Math.floor(this.gl.canvas.clientWidth*this.realToCSSPixels),r=Math.floor(this.gl.canvas.clientHeight*this.realToCSSPixels);return(this.gl.canvas.width!==t||this.gl.canvas.height!==r)&&(this.gl.canvas.width=t,this.gl.canvas.height=r,this.gl.viewport(0,0,this.gl.canvas.width,this.gl.canvas.height)),this.width=this.canvas.clientWidth,this.height=this.canvas.clientHeight,this.resizeSwappableBuffers(),!0}else return!1}},{key:"render",value:function(){if(this.visible=PM(this.canvas),this.forceRender||this.change||this.animated&&this.visible&&!this.paused){var t=new Date,r=performance.now();this.timeDelta=(r-this.timePrev)/1e3,this.timePrev=r,this.nDelta>1&&this.uniform("1f","float","u_delta",this.timeDelta),this.nTime>1&&this.uniform("1f","float","u_time",(r-this.timeLoad)/1e3),this.nDate&&this.uniform("4f","float","u_date",t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()*3600+t.getMinutes()*60+t.getSeconds()+t.getMilliseconds()*.001),this.uniform("2f","vec2","u_resolution",this.canvas.width,this.canvas.height);for(var o in this.buffers){var n=this.buffers[o];this.uniform("1i","sampler2D",n.name,n.bundle.input.index)}this.texureIndex=this.BUFFER_COUNT;for(var s in this.textures)this.uniformTexture(s),this.texureIndex++;this.renderPrograms(),this.trigger("render",{}),this.change=!1,this.forceRender=!1}}},{key:"pause",value:function(){this.paused=!0}},{key:"play",value:function(){this.paused=!1}},{key:"renderPrograms",value:function(){var t=this.gl,r=t.canvas.width,o=t.canvas.height;t.viewport(0,0,r,o);for(var n in this.buffers){var s=this.buffers[n];s.bundle.render(r,o,s.program,s.name),t.bindFramebuffer(t.FRAMEBUFFER,null)}t.useProgram(this.program),t.drawArrays(t.TRIANGLES,0,6)}},{key:"getBuffers",value:function(t){var r={};return t&&t.replace(/(?:^\s*)((?:#if|#elif)(?:\s*)(defined\s*\(\s*BUFFER_)(\d+)(?:\s*\))|(?:#ifdef)(?:\s*BUFFER_)(\d+)(?:\s*))/gm,function(){var o=arguments[3]||arguments[4];r["u_buffer"+o]={fragment:"#define BUFFER_"+o+
+t}}),r}},{key:"loadPrograms",value:function(t){var r=this,o=this.gl,n=ms(r,r.vertexString,o.VERTEX_SHADER);for(var s in t){var i=t[s],a=ms(r,i.fragment,o.FRAGMENT_SHADER,1);a?r.isValid=!0:(a=ms(r,void main(){
gl_FragColor = vec4(1.0);
},o.FRAGMENT_SHADER),r.isValid=!1);var c=Bw(r,[n,a]);i.name=s,i.program=c,i.bundle=r.createSwappableBuffer(r.canvas.width,r.canvas.height,c),o.deleteShader(a)}o.deleteShader(n)}},{key:"createSwappableBuffer",value:function(t,r,o){var n=this.createBuffer(t,r,o),s=this.createBuffer(t,r,o),i=this.gl;return{input:n,output:s,swap:function(){var a=n;n=s,s=a,this.input=n,this.output=s},render:function(a,c,l,u){i.useProgram(l),i.viewport(0,0,a,c),i.bindFramebuffer(i.FRAMEBUFFER,this.input.buffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this.output.texture,0),i.drawArrays(i.TRIANGLES,0,6),this.swap()},resize:function(a,c,l,u){i.useProgram(l),i.viewport(0,0,a,c),this.input.resize(a,c),this.output.resize(a,c)}}}},{key:"createBuffer",value:function(t,r,o){var n=this.gl,s=this.BUFFER_COUNT;this.BUFFER_COUNT+=2,n.getExtension("OES_texture_float");var i=n.createTexture();n.activeTexture(n.TEXTURE0+s),n.bindTexture(n.TEXTURE_2D,i),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,t,r,0,n.RGBA,n.FLOAT,null),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);var a=n.createFramebuffer();return{index:s,texture:i,buffer:a,W:t,H:r,resize:function(c,l){n.bindFramebuffer(n.FRAMEBUFFER,a);var u=Math.min(c,this.W),p=Math.min(l,this.H),f=new Float32Array(u*p*4);n.readPixels(0,0,u,p,n.RGBA,n.FLOAT,f),n.bindFramebuffer(n.FRAMEBUFFER,null);var m=s+1,h=n.createTexture();n.activeTexture(n.TEXTURE0+m),n.bindTexture(n.TEXTURE_2D,h),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,c,l,0,n.RGBA,n.FLOAT,null),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,u,p,n.RGBA,n.FLOAT,f);var g=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,null),n.deleteTexture(i),n.activeTexture(n.TEXTURE0+s),n.bindTexture(n.TEXTURE_2D,h),s=this.index=s,i=this.texture=h,a=this.buffer=g,this.W=c,this.H=l}}}},{key:"resizeSwappableBuffers",value:function(){var t=this.gl,r=t.canvas.width,o=t.canvas.height;t.viewport(0,0,r,o);for(var n in this.buffers){var s=this.buffers[n];s.bundle.resize(r,o,s.program,s.name)}t.useProgram(this.program)}},{key:"version",value:function(){return"0.1.7"}}]),e}();function NM(){var e=document.getElementsByClassName("glslCanvas");if(e.length>0){window.glslCanvases=[];for(var t=0;t<e.length;t++){var r=new zw(e[t]);r.isValid&&window.glslCanvases.push(r)}}}window.addEventListener("load",function(){NM()});var il=zw;var Vw=e=>{if(!("after"in e))return Promise.resolve(void 0);let t=document.createElement("canvas");return new il(t).load(rr(e.after)),e.render(t),Promise.resolve(void 0)};var Kw=e=>{let t="";for(let r=0;r<e.length;r+=3)r+2===e.length?t+=uf(e[r],e[r+1],0):r+1===e.length?t+=uf(e[r],0,0):t+=uf(e[r],e[r+1],e[r+2]);return t},al=e=>e<10?String.fromCharCode(48+e):(e-=10,e<26?String.fromCharCode(65+e):(e-=26,e<26?String.fromCharCode(97+e):(e-=26,e===0?"-":e===1?"_":"?"))),uf=(e,t,r)=>{let o=e>>2,n=(e&3)<<4|t>>4,s=(t&15)<<2|r>>6,i=r&63;return al(o&63)+al(n&63)+al(s&63)+al(i&63)};var Yw=async(e,t="svg")=>{let r=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream("deflate")),o=new Uint8Array(await new Response(r).arrayBuffer());returnhttps://www.plantuml.com/plantuml/${t}/~1${Kw(o)}};var Xw=async e=>{if(!("after"in e))return;let t=document.createElement("img"),r=await Yw(rr(e.after));t.src=r,e.render(t)};var mf=Promise.resolve({log:new Uint8Array(0)}),cl,Jw=(e,t,r,o)=>(mf=(async()=>{await mf,cl??=await MM(t,r);let n=new Promise(i=>{let a=c=>{if(c.data.type==="stdout"){o(c.data.message);return}c.data.type==="compile"&&(i(c.data),cl.removeEventListener("message",a))};cl.addEventListener("message",a)}),s={type:"compile",input:e};return cl.postMessage(s),n})(),mf),MM=async(e,t)=>{let r=new Worker(e,{type:"module"}),o=new Promise(s=>{let i=a=>{a.data.type==="asset-url"&&(s(),r.removeEventListener("message",i))};r.addEventListener("message",i)}),n={type:"asset-url",url:${t}};return r.postMessage(n),await o,r};var Qw=(e,t)=>async r=>{if(!("after"in r))return;let o=CM(),n="Compile is not started yet. Please wait...",s=l=>{n=[...n.split(
),l].join(
),o.log(n)},i=document.createElement("img"),a=setTimeout(()=>{r.render(o.div),o.log(n)},2e3),{svg:c}=await Jw(rr(r.after),e,t,s);if(clearTimeout(a),!c){r.render(o.div),o.log(n);return}i.src=await _i(new Blob([c],{type:"image/svg+xml"})),r.render(i)},CM=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"}),r=document.createElement("style");r.textContent='*{box-sizing:border-box;}pre{display:block;padding:9.5px;margin:0 0 10px;border:1px solid #ccc;border-radius:4px;height:20em;overflow:auto;font-size:13px;line-height:1.428571429;}pre code{padding:0;font-family:Menlo,Monaco,Consolas,"Courier New",monospace;font-size:inherit;word-break:break-all;word-wrap:break-word;white-space:pre-wrap;color:var(--code-color,#342d9c);background-color: rgba(0,0,0,0);border-radius:0;}',t.append(r);let o=document.createElement("pre"),n=document.createElement("code");return o.append(n),t.append(o),{div:e,log:s=>{n.textContent=s,o.scroll(0,o.scrollHeight)}}};function Kt(e,t){return Ne(e,{...t,weekStartsOn:1})}function _n(e,t){let r=E(e,t?.in),o=r.getFullYear(),n=C(r,0);n.setFullYear(o+1,0,4),n.setHours(0,0,0,0);let s=Kt(n),i=C(r,0);i.setFullYear(o,0,4),i.setHours(0,0,0,0);let a=Kt(i);return r.getTime()>=s.getTime()?o+1:r.getTime()>=a.getTime()?o:o-1}function Oi(e,t){let r=_n(e,t),o=C(t?.in||e,0);return o.setFullYear(r,0,4),o.setHours(0,0,0,0),Kt(o)}function ff(e,t){let r,o=t?.in;return e.forEach(n=>{!o&&typeof n=="object"&&(o=C.bind(null,n));let s=E(n,o);(!r||r<s||isNaN(+s))&&(r=s)}),C(o,r||NaN)}function Si(e,t,r){let o=Xa(e,t)/1e3;return Jo(r?.roundingMethod)(o)}function ll(e){return(t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}function fs(e){return(t,r)=>{let o=r?.context?String(r.context):"standalone",n;if(o==="formatting"&&e.formattingValues){let i=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):i;n=e.formattingValues[a]||e.formattingValues[i]}else{let i=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;n=e.values[a]||e.values[i]}let s=e.argumentCallback?e.argumentCallback(t):t;return n[s]}}var HM={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},WM={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},qM={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},GM={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},zM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},VM={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},KM=(e,t)=>{let r=Number(e),o=r%100;if(o>20||o<10)switch(o%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},YM={ordinalNumber:KM,era:fs({values:HM,defaultWidth:"wide"}),quarter:fs({values:WM,defaultWidth:"wide",argumentCallback:e=>e-1}),month:fs({values:qM,defaultWidth:"wide"}),day:fs({values:GM,defaultWidth:"wide"}),dayPeriod:fs({values:zM,defaultWidth:"wide",formattingValues:VM,defaultFormattingWidth:"wide"})};function ds(e){return(t,r={})=>{let o=r.width,n=o&&e.matchPatterns[o]||e.matchPatterns[e.defaultMatchWidth],s=t.match(n);if(!s)return null;let i=s[0],a=o&&e.parsePatterns[o]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?JM(a,p=>p.test(i)):XM(a,p=>p.test(i)),l;l=e.valueCallback?e.valueCallback(c):c,l=r.valueCallback?r.valueCallback(l):l;let u=t.slice(i.length);return{value:l,rest:u}}}function XM(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function JM(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function rR(e){return(t,r={})=>{let o=t.match(e.matchPattern);if(!o)return null;let n=o[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=r.valueCallback?r.valueCallback(i):i;let a=t.slice(n.length);return{value:i,rest:a}}}var QM=/^(\d+)(th|st|nd|rd)?/i,ZM=/\d+/i,e1={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},t1={any:[/^b/i,/^(a|c)/i]},r1={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},o1={any:[/1/i,/2/i,/3/i,/4/i]},n1={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},s1={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},i1={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},a1={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},c1={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},l1={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},p1={ordinalNumber:rR({matchPattern:QM,parsePattern:ZM,valueCallback:e=>parseInt(e,10)}),era:ds({matchPatterns:e1,defaultMatchWidth:"wide",parsePatterns:t1,defaultParseWidth:"any"}),quarter:ds({matchPatterns:r1,defaultMatchWidth:"wide",parsePatterns:o1,defaultParseWidth:"any",valueCallback:e=>e+1}),month:ds({matchPatterns:n1,defaultMatchWidth:"wide",parsePatterns:s1,defaultParseWidth:"any"}),day:ds({matchPatterns:i1,defaultMatchWidth:"wide",parsePatterns:a1,defaultParseWidth:"any"}),dayPeriod:ds({matchPatterns:c1,defaultMatchWidth:"any",parsePatterns:l1,defaultParseWidth:"any"})};var u1={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},m1={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},f1={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},kSe={date:ll({formats:u1,defaultWidth:"full"}),time:ll({formats:m1,defaultWidth:"full"}),dateTime:ll({formats:f1,defaultWidth:"full"})};function df(e,t){let r=E(e,t?.in),o=+Kt(r)-+Oi(r);return Math.round(o/Vo)+1}function oR(e,t){let r=E(e,t?.in).getDay();return r===0?7:r}function hf(e){return Math.trunc(+E(e)/1e3)}function sR(e,t,r){let o=E(e,r?.in),n=df(o,r)-t;return o.setDate(o.getDate()-n*7),o}function gs(e,t,r){let o=Er(),n=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??o.weekStartsOn??o.locale?.options?.weekStartsOn??0,s=E(e,r?.in),i=s.getDay(),a=(t%7+7)%7,c=7-n,l=t<0||t>6?t-(i+c)%7:(a+c)%7-(i+c)%7;return Te(s,l,r)}function iR(e,t,r){let o=E(e,r?.in),n=oR(o,r),s=t-n;return Te(o,s,r)}var k1=class{subPriority=0;validate(e,t){return!0}},v1=class extends k1{constructor(e,t,r,o,n){super(),this.value=e,this.validateValue=t,this.setValue=r,this.priority=o,n&&(this.subPriority=n)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,r){return this.setValue(e,t,this.value,r)}};var he=class{run(e,t,r,o){let n=this.parse(e,t,r,o);return n?{setter:new v1(n.value,this.validate,this.set,this.priority,this.subPriority),rest:n.rest}:null}validate(e,t,r){return!0}},T1=class extends he{priority=140;parse(e,t,r){switch(t){case"G":case"GG":case"GGG":return r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"});case"GGGGG":return r.era(e,{width:"narrow"});case"GGGG":default:return r.era(e,{width:"wide"})||r.era(e,{width:"abbreviated"})||r.era(e,{width:"narrow"})}}set(e,t,r){return t.era=r,e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["R","u","t","T"]},Ze={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},$r={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function et(e,t){return e&&{value:t(e.value),rest:e.rest}}function $e(e,t){let r=t.match(e);return r?{value:parseInt(r[0],10),rest:t.slice(r[0].length)}:null}function jr(e,t){let r=t.match(e);if(!r)return null;if(r[0]==="Z")return{value:0,rest:t.slice(1)};let o=r[1]==="+"?1:-1,n=r[2]?parseInt(r[2],10):0,s=r[3]?parseInt(r[3],10):0,i=r[5]?parseInt(r[5],10):0;return{value:o*(n*ko+s*Nr+i*Ka),rest:t.slice(r[0].length)}}function aR(e){return $e(Ze.anyDigitsSigned,e)}function qe(e,t){switch(e){case 1:return $e(Ze.singleDigit,t);case 2:return $e(Ze.twoDigits,t);case 3:return $e(Ze.threeDigits,t);case 4:return $e(Ze.fourDigits,t);default:return $e(new RegExp("^\\d{1,"+e+"}"),t)}}function pl(e,t){switch(e){case 1:return $e(Ze.singleDigitSigned,t);case 2:return $e(Ze.twoDigitsSigned,t);case 3:return $e(Ze.threeDigitsSigned,t);case 4:return $e(Ze.fourDigitsSigned,t);default:return $e(new RegExp("^-?\\d{1,"+e+"}"),t)}}function gf(e){switch(e){case"morning":return 4;case"evening":return 17;case"pm":case"noon":case"afternoon":return 12;case"am":case"midnight":case"night":default:return 0}}function cR(e,t){let r=t>0,o=r?t:1-t,n;if(o<=50)n=e||100;else{let s=o+50,i=Math.trunc(s/100)*100,a=e>=s%100;n=e+i-(a?100:0)}return r?n:1-n}function lR(e){return e%400===0||e%4===0&&e%100!==0}var _1=class extends he{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){let o=n=>({year:n,isTwoDigitYear:t==="yy"});switch(t){case"y":return et(qe(4,e),o);case"yo":return et(r.ordinalNumber(e,{unit:"year"}),o);default:return et(qe(t.length,e),o)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){let o=e.getFullYear();if(r.isTwoDigitYear){let s=cR(r.year,o);return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}let n=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(n,0,1),e.setHours(0,0,0,0),e}},P1=class extends he{priority=130;parse(e,t,r){let o=n=>({year:n,isTwoDigitYear:t==="YY"});switch(t){case"Y":return et(qe(4,e),o);case"Yo":return et(r.ordinalNumber(e,{unit:"year"}),o);default:return et(qe(t.length,e),o)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,o){let n=Yo(e,o);if(r.isTwoDigitYear){let i=cR(r.year,n);return e.setFullYear(i,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ne(e,o)}let s=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(s,0,o.firstWeekContainsDate),e.setHours(0,0,0,0),Ne(e,o)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},O1=class extends he{priority=130;parse(e,t){return pl(t==="R"?4:t.length,e)}set(e,t,r){let o=C(e,0);return o.setFullYear(r,0,4),o.setHours(0,0,0,0),Kt(o)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},S1=class extends he{priority=130;parse(e,t){return pl(t==="u"?4:t.length,e)}set(e,t,r){return e.setFullYear(r,0,1),e.setHours(0,0,0,0),e}incompatibleTokens=["G","y","Y","R","w","I","i","e","c","t","T"]},L1=class extends he{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return qe(t.length,e);case"Qo":return r.ordinalNumber(e,{unit:"quarter"});case"QQQ":return r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQQ":return r.quarter(e,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(e,{width:"wide",context:"formatting"})||r.quarter(e,{width:"abbreviated",context:"formatting"})||r.quarter(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","M","L","w","I","d","D","i","e","c","t","T"]},N1=class extends he{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return qe(t.length,e);case"qo":return r.ordinalNumber(e,{unit:"quarter"});case"qqq":return r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"});case"qqqqq":return r.quarter(e,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(e,{width:"wide",context:"standalone"})||r.quarter(e,{width:"abbreviated",context:"standalone"})||r.quarter(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=1&&t<=4}set(e,t,r){return e.setMonth((r-1)*3,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","Q","M","L","w","I","d","D","i","e","c","t","T"]},M1=class extends he{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){let o=n=>n-1;switch(t){case"M":return et($e(Ze.month,e),o);case"MM":return et(qe(2,e),o);case"Mo":return et(r.ordinalNumber(e,{unit:"month"}),o);case"MMM":return r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"});case"MMMMM":return r.month(e,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(e,{width:"wide",context:"formatting"})||r.month(e,{width:"abbreviated",context:"formatting"})||r.month(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}},C1=class extends he{priority=110;parse(e,t,r){let o=n=>n-1;switch(t){case"L":return et($e(Ze.month,e),o);case"LL":return et(qe(2,e),o);case"Lo":return et(r.ordinalNumber(e,{unit:"month"}),o);case"LLL":return r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"});case"LLLLL":return r.month(e,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(e,{width:"wide",context:"standalone"})||r.month(e,{width:"abbreviated",context:"standalone"})||r.month(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.setMonth(r,1),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","w","I","D","i","e","c","t","T"]},I1=class extends he{priority=100;parse(e,t,r){switch(t){case"w":return $e(Ze.week,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return qe(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,o){return Ne(Qa(e,r,o),o)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]},A1=class extends he{priority=100;parse(e,t,r){switch(t){case"I":return $e(Ze.week,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return qe(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){return Kt(sR(e,r))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},F1=[31,28,31,30,31,30,31,31,30,31,30,31],D1=[31,29,31,30,31,30,31,31,30,31,30,31],U1=class extends he{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return $e(Ze.date,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return qe(t.length,e)}}validate(e,t){let r=e.getFullYear(),o=lR(r),n=e.getMonth();return o?t>=1&&t<=D1[n]:t>=1&&t<=F1[n]}set(e,t,r){return e.setDate(r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","w","I","D","i","e","c","t","T"]},$1=class extends he{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return $e(Ze.dayOfYear,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return qe(t.length,e)}}validate(e,t){let r=e.getFullYear();return lR(r)?t>=1&&t<=366:t>=1&&t<=365}set(e,t,r){return e.setMonth(0,r),e.setHours(0,0,0,0),e}incompatibleTokens=["Y","R","q","Q","M","L","w","I","d","E","i","e","c","t","T"]},j1=class extends he{priority=90;parse(e,t,r){switch(t){case"E":case"EE":case"EEE":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEEE":return r.day(e,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"EEEE":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=gs(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},B1=class extends he{priority=90;parse(e,t,r,o){let n=s=>{let i=Math.floor((s-1)/7)*7;return(s+o.weekStartsOn+6)%7+i};switch(t){case"e":case"ee":return et(qe(t.length,e),n);case"eo":return et(r.ordinalNumber(e,{unit:"day"}),n);case"eee":return r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeeee":return r.day(e,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"});case"eeee":default:return r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=gs(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},H1=class extends he{priority=90;parse(e,t,r,o){let n=s=>{let i=Math.floor((s-1)/7)*7;return(s+o.weekStartsOn+6)%7+i};switch(t){case"c":case"cc":return et(qe(t.length,e),n);case"co":return et(r.ordinalNumber(e,{unit:"day"}),n);case"ccc":return r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"ccccc":return r.day(e,{width:"narrow",context:"standalone"});case"cccccc":return r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"});case"cccc":default:return r.day(e,{width:"wide",context:"standalone"})||r.day(e,{width:"abbreviated",context:"standalone"})||r.day(e,{width:"short",context:"standalone"})||r.day(e,{width:"narrow",context:"standalone"})}}validate(e,t){return t>=0&&t<=6}set(e,t,r,o){return e=gs(e,r,o),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]},W1=class extends he{priority=90;parse(e,t,r){let o=n=>n===0?7:n;switch(t){case"i":case"ii":return qe(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return et(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o);case"iiiii":return et(r.day(e,{width:"narrow",context:"formatting"}),o);case"iiiiii":return et(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o);case"iiii":default:return et(r.day(e,{width:"wide",context:"formatting"})||r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),o)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){return e=iR(e,r),e.setHours(0,0,0,0),e}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","E","e","c","t","T"]},q1=class extends he{priority=80;parse(e,t,r){switch(t){case"a":case"aa":case"aaa":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaaa":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(gf(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},G1=class extends he{priority=80;parse(e,t,r){switch(t){case"b":case"bb":case"bbb":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbbb":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(gf(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},z1=class extends he{priority=80;parse(e,t,r){switch(t){case"B":case"BB":case"BBB":return r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBBB":return r.dayPeriod(e,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(e,{width:"wide",context:"formatting"})||r.dayPeriod(e,{width:"abbreviated",context:"formatting"})||r.dayPeriod(e,{width:"narrow",context:"formatting"})}}set(e,t,r){return e.setHours(gf(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},V1=class extends he{priority=70;parse(e,t,r){switch(t){case"h":return $e(Ze.hour12h,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return qe(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){let o=e.getHours()>=12;return o&&r<12?e.setHours(r+12,0,0,0):!o&&r===12?e.setHours(0,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},K1=class extends he{priority=70;parse(e,t,r){switch(t){case"H":return $e(Ze.hour23h,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return qe(t.length,e)}}validate(e,t){return t>=0&&t<=23}set(e,t,r){return e.setHours(r,0,0,0),e}incompatibleTokens=["a","b","h","K","k","t","T"]},Y1=class extends he{priority=70;parse(e,t,r){switch(t){case"K":return $e(Ze.hour11h,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return qe(t.length,e)}}validate(e,t){return t>=0&&t<=11}set(e,t,r){return e.getHours()>=12&&r<12?e.setHours(r+12,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["h","H","k","t","T"]},X1=class extends he{priority=70;parse(e,t,r){switch(t){case"k":return $e(Ze.hour24h,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return qe(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){let o=r<=24?r%24:r;return e.setHours(o,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},J1=class extends he{priority=60;parse(e,t,r){switch(t){case"m":return $e(Ze.minute,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return qe(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setMinutes(r,0,0),e}incompatibleTokens=["t","T"]},Q1=class extends he{priority=50;parse(e,t,r){switch(t){case"s":return $e(Ze.second,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return qe(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},Z1=class extends he{priority=30;parse(e,t){let r=o=>Math.trunc(o*Math.pow(10,-t.length+3));return et(qe(t.length,e),r)}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},eC=class extends he{priority=10;parse(e,t){switch(t){case"X":return jr($r.basicOptionalMinutes,e);case"XX":return jr($r.basic,e);case"XXXX":return jr($r.basicOptionalSeconds,e);case"XXXXX":return jr($r.extendedOptionalSeconds,e);case"XXX":default:return jr($r.extended,e)}}set(e,t,r){return t.timestampIsSet?e:C(e,e.getTime()-Qr(e)-r)}incompatibleTokens=["t","T","x"]},tC=class extends he{priority=10;parse(e,t){switch(t){case"x":return jr($r.basicOptionalMinutes,e);case"xx":return jr($r.basic,e);case"xxxx":return jr($r.basicOptionalSeconds,e);case"xxxxx":return jr($r.extendedOptionalSeconds,e);case"xxx":default:return jr($r.extended,e)}}set(e,t,r){return t.timestampIsSet?e:C(e,e.getTime()-Qr(e)-r)}incompatibleTokens=["t","T","X"]},rC=class extends he{priority=40;parse(e){return aR(e)}set(e,t,r){return[C(e,r*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"},oC=class extends he{priority=20;parse(e){return aR(e)}set(e,t,r){return[C(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"},m1e={G:new T1,y:new _1,Y:new P1,R:new O1,u:new S1,Q:new L1,q:new N1,M:new M1,L:new C1,w:new I1,I:new A1,d:new U1,D:new $1,E:new j1,e:new B1,c:new H1,i:new W1,a:new q1,b:new G1,B:new z1,h:new V1,H:new K1,K:new Y1,k:new X1,m:new J1,s:new Q1,S:new Z1,X:new eC,x:new tC,t:new rC,T:new oC};var pR=(e,t,r=0,o=[])=>{let[n,s]=Q("uninitialized"),[i,a]=Q({ok:!0,value:t}),c=U(e,o);return te(()=>{(async()=>{let l=setTimeout(()=>s("pending"),r);try{let u=await c();if(u===void 0)return;a({ok:!0,value:u})}catch(u){a({ok:!1,value:u})}finally{clearTimeout(l),s("resolved")}})()},[c,r,...o]),i.ok?{result:i.value,state:n}:{result:i.value,state:"rejected"}};var uR=e=>{let t=e.flatMap(({changes:n,created:s,userId:i})=>n.flatMap(a=>{let c=lC(a,i,s);return c?[c]:[]})),r=[...new Set(t.map(({created:n})=>n))].sort();return{history:t.reduce((n,s)=>{if(s.type==="insert"){let a=new Map;a.set(s.created,{text:s.text,type:s.type,userId:s.userId});let c={id:s.id,snapshots:a};if(s.parentId==="_end")return[...n,c];let l=n.findIndex(({id:u})=>u===s.parentId);return l<0?(console.warn("[scrapbox-snapshot@0.1.0] The parent line the snapshot would insert before is not found. change: ",s),[...n,c]):[...n.slice(0,l),c,...n.slice(l)]}let i=n.findIndex(({id:a})=>a===s.id);return i<0?(console.warn("[scrapbox-snapshot@0.1.0] The line data to be append the change is not found. change: ",s),n):(n[i].snapshots.set(s.created,{text:s.type==="update"?s.text:void 0,type:s.type,userId:s.userId}),n)},[]),range:r}},lC=(e,t,r)=>{if("_insert"in e)return{type:"insert",id:e.lines.id,parentId:e._insert,text:e.lines.text,userId:t,created:r};if("_update"in e)return{type:"update",id:e._update,text:e.lines.text,userId:t,created:r};if("_delete"in e)return{type:"delete",id:e._delete,userId:t,created:r}};var Yt=e=>{let{fetch:t=(n,s)=>globalThis.fetch(n,s),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var Xt=e=>connect.sid=${e};var pC=(e,t,r)=>{let{sid:o,baseURL:n,head:s}=Yt(r??{});return new Request(${n}api/commits/${e}/${t}?head=${s??""},o?{headers:{Cookie:Xt(o)}}:void 0)},mR=(e,t,r)=>Yt(r??{}).fetch(pC(e,t,r));var dR=async(e,t)=>{let r=await mR(e,t);if(!r.ok)throw new Error(Failed to fetch commits for ${e}/${t}: ${r.statusText},{cause:r});return uR((await r.json()).commits)};var hR=()=>{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=>vt(d(fC,{getController:o=>r(o)}),t))},fC=({getController:e})=>{let[t,r]=Q(!0),o=U(()=>r(!1),[]),n=U(()=>r(!0),[]),s=U(()=>r(h=>!h),[]);te(()=>e({open:o,close:n,toggle:s}),[e]);let i=U(h=>{h.target instanceof HTMLElement&&h.target.id==="background"&&n()},[]),{state:a,result:c}=pR(async()=>{if(t||scrapbox.Layout!=="page")return;let h=await dR(scrapbox.Project.name,scrapbox.Page.id);return{range:h.range,getSnapshot:g=>h.history.flatMap(({snapshots:y})=>{let x=y.get(g);if(x)return x.text===void 0?[]:[x.text];let w=Math.max(...[...y.keys()].filter(b=>b<g));if(w===g)return[];let k=y.get(w)?.text;return k===void 0?[]:[k]})}},{range:[],getSnapshot:()=>[]},1e3,[t]),[l,u]=Q(0),[p,f]=Q(0);te(()=>{if(a!=="resolved")return;let h=Math.max(0,c.range.length-1);u(h),f(h)},[c]);let m=U(h=>f(parseInt(h.currentTarget.value)),[]);return d(ee,{children:[d("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}'}),d("div",{id:"background",className:modal${t?" closed":""},onClick:i,children:[d("div",{className:"controller",children:[d("button",{type:"button",className:"close-button",onClick:n,children:"x"}),a==="resolved"&&c.range.length===0&&d("span",{className:"not-found",children:"no history found."}),a!=="rejected"&&c.range.length>0&&d(ee,{children:[d("input",{type:"range",max:l,min:"0",step:"1",value:p,title:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss"),onInput:m}),d("time",{dateTime:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss"),children:pe(new Date(c.range[p]*1e3),"yyyy-MM-dd HH:mm:ss")})]})]}),a!=="rejected"?d("div",{className:"viewer",children:d("pre",{children:c.getSnapshot(c.range[p]).join(
)})}):d("div",{className:"error viewer",children:Error: ${JSON.stringify(c)}})]})]})};var ao=()=>/mobile/i.test(navigator.userAgent);function gR(e){return Ye(e)?L(e):(K(e),e)}var dC=Object.defineProperty,hC=(e,t)=>{for(var r in t)dC(e,r,{get:t[r],enumerable:!0})},gC={};hC(gC,{andThen:()=>Mp,andThenAsync:()=>Cp,inspect:()=>Ip,map:()=>Ap,mapAsync:()=>Fp,mapOr:()=>Dp,mapOrAsync:()=>Up,mapOrElse:()=>$p,mapOrElseAsync:()=>jp,okOr:()=>Bp,okOrElse:()=>$s,okOrElseAsync:()=>Hp,orElse:()=>Wp,orElseAsync:()=>qp,toNullable:()=>Gp,toResultErr:()=>zp,toResultOk:()=>xa,toUndefinable:()=>Vp,transposeToResult:()=>gR,unwrapOr:()=>js,unwrapOrElse:()=>Kp,unwrapOrElseAsync:()=>Yp});function yR(e,t){return rt(e)?e:t(e)}async function xR(e,t){return rt(e)?null:await t(e)}function bR(e,t){return je(e)&&t(e),e}function ER(e,t){if(rt(e))return e;let r=t(e);return ot(r,nr)}async function wR(e,t){if(rt(e))return null;let r=await t(e);return ot(r,nr)}function RR(e,t,r){let o,n="";return e!==null?(o=r(e),n=nr):(o=t,n=Dn),ot(o,n)}async function kR(e,t,r){if(rt(e))return ot(t,Dn);let o=await r(e);return ot(o,nr)}function vR(e,t,r){let o,n="";return je(e)?(o=r(e),n=nr):(o=t(),n=fo),ot(o,n)}async function TR(e,t,r){let o,n="";return je(e)?(o=await r(e),n=nr):(o=await t(),n=fo),ot(o,n)}function _R(e,t){return je(e)?L(e):M(t)}function PR(e,t){if(je(e))return L(e);let r=t();return M(r)}async function OR(e,t){if(je(e))return L(e);let r=await t();return M(r)}function SR(e,t){return e!==null?e:t()}async function LR(e,t){return je(e)?e:await t()}function NR(e){return rt(e)?M(void 0):L(e)}function MR(e){return rt(e)?L(void 0):M(e)}function CR(e){if(!rt(e))return e}function IR(e){return rt(e)?L(null):(K(e),e)}function AR(e,t){return je(e)?e:ot(t,Dn)}function FR(e,t){if(je(e))return e;let r=t();return ot(r,fo)}async function DR(e,t){if(je(e))return e;let r=await t();return ot(r,fo)}var yC=Object.defineProperty,xC=(e,t)=>{for(var r in t)yC(e,r,{get:t[r],enumerable:!0})},bC={};xC(bC,{andThen:()=>yR,andThenAsync:()=>xR,inspect:()=>bR,map:()=>ER,mapAsync:()=>wR,mapOr:()=>RR,mapOrAsync:()=>kR,mapOrElse:()=>vR,mapOrElseAsync:()=>TR,okOr:()=>_R,okOrElse:()=>PR,okOrElseAsync:()=>OR,orElse:()=>SR,orElseAsync:()=>LR,toResultErr:()=>MR,toResultOk:()=>NR,toUndefinable:()=>CR,transposeToResult:()=>IR,unwrapOr:()=>AR,unwrapOrElse:()=>FR,unwrapOrElseAsync:()=>DR});function UR(e,t){return st(e)?e:t(e)}async function $R(e,t){return st(e)?void 0:await t(e)}function jR(e,t){return nt(e)&&t(e),e}function BR(e,t){if(st(e))return e;let r=t(e);return it(r,sr)}async function HR(e,t){if(st(e))return;let r=await t(e);return it(r,sr)}function WR(e,t,r){let o,n="";return e!==void 0?(o=r(e),n=sr):(o=t,n=Un),it(o,n)}async function qR(e,t,r){if(st(e))return it(t,Un);let o=await r(e);return it(o,sr)}function GR(e,t,r){let o,n="";return e!==void 0?(o=r(e),n=sr):(o=t(),n=ho),it(o,n)}async function zR(e,t,r){let o,n="";return nt(e)?(o=await r(e),n=sr):(o=await t(),n=ho),it(o,n)}function VR(e,t){return nt(e)?L(e):M(t)}function KR(e,t){if(nt(e))return L(e);let r=t();return M(r)}async function YR(e,t){if(nt(e))return L(e);let r=await t();return M(r)}function XR(e,t){return e!==void 0?e:t()}async function JR(e,t){return nt(e)?e:await t()}function QR(e){return st(e)?null:e}function ZR(e){return st(e)?M(void 0):L(e)}function ek(e){return st(e)?L(void 0):M(e)}function tk(e){return st(e)?L(void 0):(K(e),e)}function rk(e,t){return nt(e)?e:it(t,Un)}function ok(e,t){if(nt(e))return e;let r=t();return it(r,ho)}async function nk(e,t){if(nt(e))return e;let r=await t();return it(r,ho)}var EC=Object.defineProperty,wC=(e,t)=>{for(var r in t)EC(e,r,{get:t[r],enumerable:!0})},RC={};wC(RC,{andThen:()=>UR,andThenAsync:()=>$R,inspect:()=>jR,map:()=>BR,mapAsync:()=>HR,mapOr:()=>WR,mapOrAsync:()=>qR,mapOrElse:()=>GR,mapOrElseAsync:()=>zR,okOr:()=>VR,okOrElse:()=>KR,okOrElseAsync:()=>YR,orElse:()=>XR,orElseAsync:()=>JR,toNullable:()=>QR,toResultErr:()=>ek,toResultOk:()=>ZR,transposeToResult:()=>tk,unwrapOr:()=>rk,unwrapOrElse:()=>ok,unwrapOrElseAsync:()=>nk});var ul=class{#o=[];#r;#t;constructor(t){if(t<=0||!Number.isSafeInteger(t))throw new RangeError(size must be a positive safe integer, got ${t});this.#r=t,this.#t=t}get locked(){return this.#r===0}get waiterCount(){return this.#o.length}acquire(){if(this.#r>0)return this.#r-=1,Promise.resolve();{let{promise:t,resolve:r}=Promise.withResolvers();return this.#o.push(r),t}}release(){let t=this.#o.shift();t?t():this.#r<this.#t&&(this.#r+=1)}};var ml=class{#o;constructor(t){this.#o=new ul(t)}get locked(){return this.#o.locked}get waiterCount(){return this.#o.waiterCount}async lock(t){await this.#o.acquire();try{return await t()}finally{this.#o.release()}}};async function*sk(e,t){if(e.length===0||e.every(({before:n,after:s})=>n===s))return;let r=S(await Mt()),o=new ml(5);try{yield*new ReadableStream({async start(n){let s=[];for(let i of e){if(i.before===i.after){n.enqueue({link:i,projectCount:0,replaced:0,done:!0});continue}let a=0,c=0,l=[];for(let u of new Set(t))l.push(o.lock(async()=>{let p=await kC(i,u,r);if(O(p)){n.error(vC(Z(p)));return}a++,c+=S(p),n.enqueue({link:i,projectCount:a,replaced:c,done:!1})}));s.push(Promise.all(l).then(()=>n.enqueue({link:i,projectCount:a,replaced:c,done:!0})))}await Promise.all(s),n.close()}})}finally{await Ct(r)}}var kC=async(e,t,r)=>{let[o]=await Promise.all([wa(t,e.before,e.after),Le(t,e.before,(n,{persistent:s})=>{if(s)return[e.after,...n.map(i=>i.text).slice(1)]},{socket:r})]);return o},co=e=>e.split(
).flatMap(t=>[...t.matchAll(/\[((?:[^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~] |.[^ ]*)[^\[\]]*)\]/g)]).map(([,t])=>t),vC=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var ik=e=>at(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return TC(r);case"table":return _C(r);case"line":return PC(r)}}).map(r=>r).join(
),TC=({fileName:e,content:t,indent:r})=>{let o=" ".repeat(r);return[${o}code:${e},...t.split(
).map(n=>${o} ${n})]},_C=({fileName:e,cells:t,indent:r})=>{let o=" ".repeat(r);return[${o}table:${e},...t.map(n=>${o} ${n.map(s=>s.map(i=>Li(i)).join("")).join(" ")})]},PC=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${Li(r)}).join("")}],Li=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Li(t)).join("")};case"strong":return${e.nodes.map(t=>Li(t)).join("")};case"decoration":{let t=e.decos.map(r=>{let o=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return o>0?"*".repeat(o):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>Li(r)).join("")}]}case"hashTag":return e.href;case"link":return e.pathType==="absolute"?e.raw:e.href;default:return e.raw}};scrapbox.PopupMenu.addButton({title:e=>co(e).length>0?"":"",onClick:e=>{let t=ik(e);if(e!=t)return t}});var ak=e=>!e.includes(
)&&/\[[^\]]+\]/.test(e);scrapbox.PopupMenu.addButton({title:e=>ak(e)?"[][]":"",onClick:e=>{if(!ak(e))return;let t=e.replaceAll("[","").replaceAll("]","");return(async()=>{let{render:r,dispose:o}=De();try{let n=scrapbox.Project.name;r({type:"spinner"},{type:"text",text:create /${n}/${t}}),await Le(n,t,([{text:s}],{persistent:i})=>{if(!i)return[s,e]}),r({type:"check-circle"},{type:"text",text:create /${n}/${t}})}catch(n){if(console.error(n),!(n instanceof Error))throw n;r({type:"exclamation-triangle"},{type:"text",text:${n.name} ${n.message}})}finally{await Fe(2e3),o()}})(),${t}}});var lk=(e,t)=>{switch(e.type){case"title":return"";case"codeBlock":return[e.fileName,
\\`\`${IC(e.fileName)},e.content,"\n"].join(
);case"table":return OC(e);case"line":return LC(e,t)}},OC=e=>{let t=[e.fileName],r=Math.max(...e.cells.map(o=>o.length));return e.cells.forEach((o,n)=>{t.push(| ${o.map(s=>s.map(i=>bs(i)).join("")).join(" | ")} |),n===0&&t.push(|${" -- |".repeat(r)})}),t.join(
)},SC=" ",LC=(e,t)=>{let r=e.nodes.map(n=>bs(n,{section:e.indent===t})).join("").trim();if(r==="")return"";if(e.indent===t)return r;let o=SC.repeat(e.indent-t-1);return/^\d+\. /.test(r)||(o+="- "),o+r},bs=(e,t)=>{let{section:r=!1}=t??{};switch(e.type){case"quote":return> ${e.nodes.map(o=>bs(o)).join("")};case"helpfeel":return\? ${e.text}\`;case"image":case"strongImage":return![image](${e.src});case"icon":case"strongIcon":return"/icons/hr","/scrapboxlab/hr".includes(e.path)?"---":"";case"strong":return**${e.nodes.map(o=>bs(o)).join("")}**;case"formula":return$${e.formula}$;case"decoration":{let o=e.nodes.map(n=>bs(n)).join("");return e.decos.includes("/")&&(o=*${o}*),r?(e.decos.includes("*-3")&&(o=`# ${o}
),e.decos.includes("*-2")&&(o=## ${o}
),e.decos.includes("*-1")&&(o=### ${o}
)):e.decos.some(n=>/\*-/.test(n[0]))&&(o=**${o}**),e.decos.includes("~")&&(o=~~${o}~~),o}case"code":return\${e.text}\`;case"commandLine":return\`${e.symbol} ${e.text}\`;case"link":switch(e.pathType){case"root":{let,o,...n=e.href.split("/");return[${e.href}](https://scrapbox.io/${o}/${ck(n.join("/"))})}case"relative":return[${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${ck(e.href)});default:return e.content===""? ${e.href} :[${e.content}](${e.href})}case"googleMap":return[${e.place}](${e.url});case"hashTag":return[#${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${e.href});case"numberList":return${e.number}. ${e.nodes.map(o=>bs(o)).join("")};case"blank":case"plain":return e.text}},ck=e=>...e.map((t,r)=>t===" "?"_":!NC.includes(t)||r===e.length-1&&MC.includes(t)?encodeURIComponent(t):t).join(""),NC='@$&+=:;",',MC=':;",',CC=[{extensions:"javascript","js",fileType:"javascript"},{extensions:"typescript","ts",fileType:"typescript"},{extensions:"cpp","hpp",fileType:"cpp"},{extensions:"c","cc","h",fileType:"c"},{extensions:"cs","csharp",fileType:"cs"},{extensions:"markdown","md",fileType:"markdown"},{extensions:"htm","html",fileType:"html"},{extensions:"json",fileType:"json"},{extensions:"xml",fileType:"xml"},{extensions:"yaml","yml",fileType:"yaml"},{extensions:"toml",fileType:"toml"},{extensions:"ini",fileType:"ini"},{extensions:"tex","sty",fileType:"tex"},{extensions:"svg",fileType:"svg"}],IC=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return CC.find(r=>r.extensions.includes(t))?.fileType??""};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{(async()=>{try{let t=es.parse(e,{hasTitle:!1}),r=Math.min(...t.map(o=>o.indent));await navigator.clipboard.writeText(t.map(o=>lk(o,r)).join(`
))}catch(t){alert(Failed to copy:
${JSON.stringify(t)})}})()}});var pk=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var uk=()=>AC(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),AC=(e,t)=>{if(e)return pk(e,t),e};var mk=()=>{let e=uk();if(!e)throw new Error("div.status-bar can't be found");let t=document.createElement("div");return e.append(t),{render:(...r)=>{t.textContent="";let o=fk(...r);o&&t.append(o)},dispose:()=>t.remove(),[Symbol.dispose]:()=>t.remove()}},fk=(...e)=>{let t=e.flatMap(o=>{switch(o.type){case"spinner":return[jC()];case"check-circle":return[BC()];case"exclamation-triangle":return[HC()];case"text":return[dl(o.text)];case"group":{let n=fk(...o.items);return n?[n]:[]}}});if(t.length===0)return;if(t.length===1)return t[0];let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},dl=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},jC=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),dl(e)},BC=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),dl(e)},HC=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),dl(e)};var xf=(e,...t)=>{let r=t.reduce((o,n)=>ve(o)?o:o instanceof Promise?o.then(s=>ve(s)?s:n(s)):n(o),e);return r instanceof Promise?r.then(o=>${o}):${e}};var Es=e=>e.ok?L(e):M({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var dk=e=>window.GM_fetch?.(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x)?.then?.(t=>ie(Es(t),r=>r.json()));function St(e){return e.val}function Ut(e){return e.err}var hk=" must not return ",qC="transformer",GC="recoverer",zC="defaultValue",ws=qC+hk,lo="called with ",Rs=zC+" must not be ",ks=GC+hk;var VC="Ok",gk="Err",yk=lo+gk,KC=lo+VC,YC="Carrying E in "+gk+" instead of throwing it directly. See .cause",bf="an instance of Error of the current realm.",q9e="The thrown value is not "+bf,G9e="The contained E should be "+bf,XC="This .cause is not "+bf;function Rt(e){return e.ok}function Ce(e){return{ok:!0,val:e,err:null}}function se(e){return!e.ok}function Lt(e){return{ok:!1,val:null,err:e}}function _e(e){return xk(e,yk)}function xk(e,t){if(se(e))throw new TypeError(t);return e.val}function Ni(e,t){if(se(e))return e;let r=St(e),o=t(r);return Ce(o)}async function Ge(e,t){if(se(e))return e;let r=St(e),o=await t(r);return Ce(o)}async function tt(e,t){if(Rt(e))return e;let r=Ut(e),o=await t(r);return Lt(o)}async function hl(e,t){if(Rt(e))return e;let r=Ut(e);return await t(r)}var gl="null",o7e=ws+gl,ZC=lo+gl,n7e=Rs+gl,s7e=ks+gl;var yl="undefined",p7e=ws+yl,eI=lo+yl,u7e=Rs+yl,m7e=ks+yl;var ze=e=>e.ok?Ce(e):Lt({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Ek=async(e,t)=>{let r=new Request(e,t);try{return Ce(await globalThis.fetch(r))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return Lt({name:"AbortError",message:o.message,request:r});if(o instanceof TypeError)return Lt({name:"NetworkError",message:o.message,request:r});throw o}};var Ie=e=>{let{fetch:t=Ek,hostName:r="scrapbox.io",...o}=e;return{fetch:t,hostName:r,...o}};var wk=e=>{let{sid:t,hostName:r}=Ie(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:Ve(t)}}:void 0)},Rk=e=>Ge(ze(e),async t=>await t.json()),kk=(()=>{let e=async t=>{let{fetch:r,...o}=Ie(t??{}),n=await r(wk(o));return se(n)?n:Rk(_e(n))};return e.toRequest=wk,e.fromResponse=Rk,e})();var Ve=e=>connect.sid=${e},po=async e=>{let t=e?.csrf??globalThis._csrf;return t?Ce(t):Ni(await kk(e),r=>r.csrfToken)};var $t=async(e,t)=>{let r=e.response.clone(),o=jo(t);try{let n=await r.json();if(!go(n))return;if(r.status===422){if(!ve(n.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:n.message}}return!o(n.name)||!ve(n.message)?void 0:n.name==="NotLoggedInError"?!go(n.detals)||!ve(n.detals.project)||!Us(oI)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},oI=jo(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var xl="null or undefined",vs=ws+xl,nI=lo+xl,Ef=Rs+xl,bl=ks+xl;function Br(e){return e==null}function El(e){return Br(e)?Lt(void 0):Ce(e)}var vk=(e,t)=>{let{sid:r,hostName:o}=Ie(t??{});return new Request(https://${o}/api/projects/${e},r?{headers:{Cookie:Ve(r)}}:void 0)},Tk=async e=>Ge(await tt(ze(e),async t=>await $t(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),_k=(()=>{let e=async(t,r)=>{let{fetch:o}=Ie(r??{}),n=vk(t,r),s=await o(n);return se(s)?s:Tk(_e(s))};return e.toRequest=vk,e.fromResponse=Tk,e})();var Pk=async(e,t)=>{let{sid:r,hostName:o,fetch:n}=Ie(t??{}),s=await po(t);if(se(s))return s;let i=new Request(https://${o}/api/embed-text/url?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":_e(s),...r?{Cookie:Ve(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await n(i);return se(a)?a:Ge(await tt(ze(_e(a)),async c=>await $t(c,["SessionError","BadRequestError","InvalidURLError"])??c),async c=>{let{title:l}=await c.json();return l})};var Ok=async(e,t)=>{let{sid:r,hostName:o,fetch:n}=Ie(t??{}),s=await po(t);if(se(s))return s;let i=new Request(https://${o}/api/embed-text/twitter?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":_e(s),...r?{Cookie:Ve(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await n(i);return se(a)?a:tt(await Ge(ze(_e(a)),c=>c.json()),async c=>c.response.status===422?{name:"InvalidURLError",message:(await c.response.json()).message}:await $t(c,["SessionError","BadRequestError"])??c)};var Sk=async e=>{let{fetch:t,sid:r,hostName:o,gyazoTeamsName:n}=Ie(e??{}),s=new Request(https://${o}/api/login/gyazo/oauth-upload/token${n??gyazoTeamsName=${n}:""},r?{headers:{Cookie:Ve(r)}}:void 0),i=await t(s);return se(i)?i:Ge(await tt(ze(_e(i)),async a=>await $t(a,["NotLoggedInError"])??a),a=>a.json().then(c=>c.token))};var Lk=async(e,t,r)=>{let o=${nu(ou(await e.arrayBuffer()))},n=await iI(e,t,o,r);if(se(n))return n;let s=_e(n);if("embedUrl"in s)return Ce(s);let i=await aI(s.signedUrl,e,r);return se(i)?i:cI(t,s.fileId,o,r)},iI=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i,csrf:a}=Ie(o??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},l=await hl(El(a),()=>po(o));if(se(l))return l;let u=new Request(https://${s}/api/gcs/${t}/upload-request,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":_e(l),...n?{Cookie:Ve(n)}:{}}}),p=await i(u);return se(p)?p:Ge(await tt(ze(_e(p)),async f=>f.response.status===402?{name:"FileCapacityError",message:(await f.response.json()).message}:f),f=>f.json())},aI=async(e,t,r)=>{let{sid:o,fetch:n}=Ie(r??{}),s=await n(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...o?{Cookie:Ve(o)}:{}}});return se(s)?s:Ni(await tt(ze(_e(s)),async i=>i.response.headers.get("Content-Type")?.includes?.("/xml")?{name:"GCSError",message:await i.response.text()}:i),()=>{})},cI=async(e,t,r,o)=>{let{sid:n,hostName:s,fetch:i,csrf:a}=Ie(o??{}),c=await hl(El(a),()=>po(o));if(se(c))return c;let l=new Request(https://${s}/api/gcs/${e}/verify,{method:"POST",body:JSON.stringify({md5:r,fileId:t}),headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":_e(c),...n?{Cookie:Ve(n)}:{}}}),u=await i(l);return se(u)?u:Ge(await tt(ze(_e(u)),async p=>p.response.status===404?{name:"NotFoundError",message:(await p.response.json()).message}:p),p=>p.json())};var Nk=(e,t)=>{let r=new FormData;return r.append("data",e),r.append("metadata",JSON.stringify({app:"Gyazo",title:e.name})),GM_fetch(https://gif.gyazo.com/${t?.teams?"teams":"gif"}/upload,{method:"POST",body:r,credentials:"include",headers:{Origin:"https://gyazo.com","sec-fetch-site":"same-site"},referrer:"https://gyazo.com/"})};var wl="",Mk=!1,Rl=new Map,Ck=async(e,t,r,o)=>{let n=Rl.get(e.href);if(n)return n;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let l=await GM_fetch(e);if(!l.ok)return;let u=l.headers.get("content-type")?.split?.(";")?.[0]??${e}.endsWith(".mp4")?"video/mp4":"video/webm",p=new File([await l.blob()],o||${t},{type:u});if(u==="video/mp4"){let h=await Nk(p);if(h.ok){let g=new URL(await h.text());return Rl.set(e.href,g),g}}let f=await Lk(p,r);if(O(f))throw Error(Z(f).name);let m=new URL(S(f).embedUrl);return Rl.set(e.href,m),m}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Mk){if(!wl)return}else{let l=await Sk();if(Mk=!0,O(l)){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(wl=S(l)||"",!wl){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let s=await GM_fetch(e);if(!s.ok)return;let i=await Zh(await s.blob(),{accessToken:wl,refererURL:t,description:o});if(!i.ok)throw new Error(Gyazo upload failed: ${i.status} ${i.statusText});let a=await i.json(),c=new URL(a.permalink_url);return Rl.set(e.href,c),c};var Fk=[["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#39;"]],lI=Object.fromEntries([...Fk.map(([e,t])=>[t,e]),["&apos;","'"],["&nbsp;"," "]]),pI=new Map(Fk),mot=new RegExp([${...pI.keys().join("")}],"g");var uI={entityList:lI},mI=1114111,fI=/&#([0-9]+);/g,dI=/&#x(\p{AHex}+);/gu,Ik=new WeakMap;function wf(e,t={}){let{entityList:r}={...uI,...t},o=Ik.get(r);return o||(o=new RegExp((${Object.keys(r).sort((n,s)=>s.length-n.length).join("|")}),"g"),Ik.set(r,o)),e.replaceAll(o,n=>r[n]).replaceAll(fI,(n,s)=>Ak(s,10)).replaceAll(dI,(n,s)=>Ak(s,16))}function Ak(e,t){let r=parseInt(e,t);return r>mI?"�":String.fromCodePoint(r)}var kl=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),o=[...e.entities.hashtags.map(i=>({type:"hashtag",...i})),...e.entities.symbols.map(i=>({type:"symbol",...i})),...e.entities.user_mentions.map(i=>({type:"mention",name:i.name,screenName:i.screen_name,indices:i.indices})),...e.entities.urls.map(i=>{let a={type:"url",indices:i.indices,url:new URL(i.expanded_url)};if(e.card&&e.card?.url===i.url){let{description:c,title:l}=e.card.binding_values,u="STRING";c?.type===u&&(a.description=c.string_value),l?.type===u&&(a.title=l.string_value)}return a}),...e.entities.media?.map?.(i=>({type:"media",indices:i.indices,media:e.mediaDetails?.flatMap?.(a=>a.url===i.url?[{type:a.type,url:new URL(a.video_info?.variants?.sort?.((c,l)=>(l.bitrate??0)-(c.bitrate??0))?.[0].url??a.media_url_https)}]:[])??[]}))??[]].sort((i,a)=>i.indices[0]-a.indices[0]),n=[];{let i=0,a=e.text;for(let{indices:c,...l}of o){let u=[...a].slice(0,c[0]-i).join("");n.push({type:"plain",text:wf(u)}),n.push(l),a=[...a].slice(c[1]-i).join(""),i=c[1]}a&&n.push({type:"plain",text:wf(a)})}let s={id:e.id_str,content:n,author:t,posted:r,replyCount:"reply_count"in e?e.reply_count:e.conversation_count};return e.self_thread&&(s.rootId=e.self_thread.id_str),e.in_reply_to_status_id_str&&(s.replyId=e.in_reply_to_status_id_str),e.parent&&(s.replyTo=kl(e.parent)),e.quoted_tweet&&(s.quote=kl(e.quoted_tweet)),s};var hI=["landing","product","enterprise","pricing","try-enterprise","contact","terms","privacy","jp-commercial-act","support","case","features","business","auth","login","logout","oauth2","_","api","app.html","assets","file","files","billing","billings","config","feed","index","io","new","opensearch","project","projects","search","setting","settings","setup-profile","slide","socket.io","stream","user","users"],vl=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,o,n]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!o||hI.includes(o)?r:n?o===e?${decodeURIComponent(n)}:/${o}/${decodeURIComponent(n)}:/${o}};var Dk=(e=gI)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:www\.|mobile\.|m\.|)(?:twitter|x)\.com\/[A-Za-z0-9_]*\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let o=await(dk(r)??Ok(t.href));if(O(o))throw Z(o);let n=S(o);return e("images"in n?{...n,id:r}:n,t)})():t},gI=async e=>{if("images"in e)return Mi(e);let{quote:t,replyTo:r,...o}=kl(e);return[...r?[...(await Mi(r)).split(
).map(n=> > ${n}),...r.quote?(await Mi(r.quote)).split(
).map(n=> > ${n}):[]]:[],...(await Mi(o)).split(
).map(n=>> ${n}),...t?(await Mi(t)).split(
).map(n=>> > ${n}):[]].join(
)},Mi=async e=>{let t=new URL(https://twitter.com/${"author"in e?e.author.screenName:e.screenName}/status/${e.id});if("images"in e)return[> @${kf(e.screenName)} ${t.origin}${t.pathname},...e.description?.split?.(
)?.map?.(n=>> ${kf(n)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(n=>[${n}])}]:[]].join(
);let r=e.content,o=e.author.screenName;return[@${kf(o)} ${t},...(await Promise.all(r.map(async n=>{switch(n.type){case"plain":return n.text;case"hashtag":return #${n.text} ;case"symbol":return #$${n.text} ;case"mention":return@${n.screenName};case"media":{let s=[],i=1;for(;i<n.media.length;i+=2)s.push([${await Rf(n.mediai-1,t)}] [${await Rf(n.mediai,t)}]);return i===n.media.length&&s.push([${await Rf(n.mediai-1,t)}]),
${s.join(`
`)}
}case"url":return${vl()(n.url)} }}))).join("").split(
)].join(
)},Tl="",yI=async()=>{if(Tl)return Tl;let e=await _k(scrapbox.Project.name);if(O(e))throw new Error(Z(e).name);return Tl=S(e).id,Tl},Rf=async(e,t)=>await Ck(e.url,t,await yI(),"")??e.url,kf=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Uk=e=>window.GM_fetch?.(https://t.co/${e})?.then?.(t=>ie(Es(t),async r=>{let o=new DOMParser().parseFromString(await r.text(),"text/html");try{return new URL(o.title)}catch(n){if(n instanceof TypeError)return;throw n}}));var $k=e=>{let t=window.GM_fetch;if("bit.ly","amzn.to","amzn.asia","goo.gl","s.nikkei.com","apple.co","nico.ms","w.wiki".includes(e.hostname)&&t)return t(e).then(o=>o.ok?new URL(o.url):e);if(e.hostname!=="t.co")return e;let r=Uk(e.pathname.slice(1));return r?r.then(o=>Ds(o,()=>e,n=>n??e)):e};var jk=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,n=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!n)return e;e.hostname=${n}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",o=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${o}#${r}]:[${t} - Wikipedia ${o}]};var Bk=e=>{if(e.hostname!=="www.wikiwand.com")return e;let,t,r=e.pathname.match(/^\/(^\/+)\/(^\/+)/)??[];return!t||!r||(e.hostname=${t}.wikipedia.org,e.pathname=/wiki/${r},e.hash=e.hash.startsWith("#/")?#${e.hash.slice(2)}:e.hash),e};var vf=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var Hk=/charset=(^;+)/,Wk=e=>window.GM_fetch?.(${e})?.then?.(t=>ie(Es(t),async r=>{let o=r.headers.get("content-type")?.match?.(Hk)?.1??await xI(r.clone());return new TextDecoder(o).decode(await r.arrayBuffer())})),xI=async e=>{let t=new DOMParser().parseFromString(await e.text(),"text/html");return t.querySelector("metacharset")?.getAttribute?.("charset")??t.querySelector('metahttp-equiv="content-type"')?.getAttribute?.("content")?.match?.(Hk)?.1??"utf-8"};var qk=(e=bI)=>async t=>e(await EI(t),t),bI=(e,t)=>{let r=(ve(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},EI=async e=>{let t=Wk(e);if(!t){let o=await Pk(e);if(O(o))throw Z(o);return S(o)}let r=await t;if(O(r))throw Z(r);return new DOMParser().parseFromString(S(r),"text/html")};var Gk=e=>{if(!/^(?:www\.)?amazon(?:\.co|com)?\.(?:au|br|ca|fr|de|in|it|jp|mx|nl|sg|es|tr|ae|uk|cn)$/.test(e.hostname))return e;let,t=e.pathname.match(/\/dp\/(\w\d+)/)??e.pathname.match(/\/gp\/product\/(\w\d+)/)??e.pathname.match(/\/exec\/obidos\/asin\/(\w\d+)/)??e.pathname.match(/\/o\/ASIN\/(\w\d+)/)??[];return t&&(e.hash="",e.search="",e.pathname=/dp/${t}),e};var zk=e=>{if(!/(?:0-9a-z-\.)?gyazo\.com/.test(e.hostname))return e;let,t=e.pathname.match(/^\/(0-9a-f{32})(?:\/raw)?$/)??[];return t?[https://gyazo.com/${t}]:e};var Vk=(e,...t)=>{if(e instanceof URL)return xf(new URL(e),...t);let r=0,o=0,n=0,s=!1,i=e.split(/(https?:\/\/\S+)/g).map(u=>{if(!/^https?:\/\/\S+$/.test(u))return u;r++;try{let p=xf(new URL(u),...t);return ve(p)?(o++,p):(s=!0,p,u)}catch(p){return console.error(p),n++,u}});if(!s)return i.join("");let{render:a,dispose:c}=mk(),l=()=>a({type:"spinner"},{type:"text",text:URL: ${o}/${r} converted, ${n} failed});return l(),Promise.all(i.map(async u=>{if(ve(u))return u;try{let p=await u0;return o++,p}catch(p){return console.error(p),n++,u1}finally{l()}})).then(u=>(a({type:"check-circle"},{type:"text",text:URL: ${o}/${r} converted, ${n} failed}),u.join(""))).finally(()=>{setTimeout(c,1e3)})};var Kk=e=>{if(!/^(?:\w+\.nicovideo\.jp|nico\.ms)$/.test(e.hostname))return e;let t=e.pathname.match(/(?:sm|nm|so|ca|ax|yo|nl|ig|na|cw|za-e|om|sk|yk|lv)\d{1,14}$/)?.0;return t?[https://nicothumb2img.vercel.app/image/${t}#.png https://nico.ms/${t}]:e};var Yk=e=>at(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return wI(r);case"table":return RI(r);case"line":return kI(r)}}).map(r=>r).join(`
),wI=({fileName:e,content:t,indent:r})=>{let o=" ".repeat(r);return[${o}code:${e},...t.split(
).map(n=>${o} ${n})]},RI=({fileName:e,cells:t,indent:r})=>{let o=" ".repeat(r);return[${o}table:${e},...t.map(n=>${o} ${n.map(s=>s.map(i=>i.raw).join("")).join(" ")})]},kI=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${Ci(r)}).join("")}],Ci=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Ci(t)).join("")};case"helpfeel":return-? ${e.text};case"commandLine":return-${e.symbol} ${e.text};case"icon":case"strongIcon":case"image":case"strongImage":case"formula":case"code":case"googleMap":return e.raw;case"strong":return${e.nodes.map(t=>Ci(t)).join("")};case"decoration":{e.decos.includes("-")||e.decos.push("-");let t=e.decos.map(r=>{let o=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return o>0?"*".repeat(o):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>Ci(r)).join("")}]}case"link":switch(e.pathType){case"root":case"relative":return${e.href};case"absolute":return[- ${e.content?${e.content} :""}${e.href}]]}case"hashTag":return#${e.href};case"numberList":return${e.number}. ${e.nodes.map(t=>Ci(t)).join("")};case"blank":case"plain":return${e.text}}};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=Yk(e);if(e!==t)return t}});var Tf=e=>{let t=e.indexOf(
);if(t<0)return;let r=e.slice(0,t).split(
).map(s=>{let[i="",a=""]=s.split(" => ",2);return[i,a]});if(r.length===0)return;let o=e.slice(t+2).split(
);if(o.length===0)return;for(let[s,i]of r){let a=s.match(/^\/(.*?)\/([gimy]*)$/);if(a){let c=new RegExp(a[1],a[2]);o=o.map(l=>l.replace(c,i.replaceAll("\\n",
)))}else o=o.map(c=>c.replaceAll(s,i.replaceAll("\\n",
)))}let n=${e.slice(0,t+2)}${o.join(`
)};if(e!==n)return n};scrapbox.PopupMenu.addButton({title:e=>Tf(e)?"replace":"",onClick:e=>{let t=Tf(e);if(t!==void 0)return t}});var Xk=e=>{let t=document.createElement("div"),r=t.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent="dialog::backdrop{background-color:#000c}dialog{flex-direction:column;align-items:center;row-gap:10px;padding:10px;background:unset;margin-top:unset;margin-bottom:unset;border:unset;height:unset}dialogopen{display:flex}dialog>*{color:var(--page-text-color, #4a4a4a);background-color:var(--dropdown-menu-bg, #fff);border:1px solid rgba(0,0,0,.2);border-radius:6px}@media (min-width: 768px){dialog{padding:30px 0}}.container{display:flex;padding:5px;gap:0.2em;flex-direction:column;width:100%;}.button-container{flex-direction:unset;}.button-container>*{flex:1;}",r.append(o);let n=document.createElement("dialog");n.insertAdjacentHTML("beforeend",`
<div class="container">
Replace Links:
<textarea class="editor"></textarea>
<div class="container button-container">
<button class="cancel">cancel</button>
<button class="replace">replace</button>
</div>
</div>
),r.append(n);let s=n.querySelector(".editor");s.rows=e.length,s.value=e.join(
);let i=()=>{n.style.minWidth=${Math.max(...s.value.split(`
).map(u=>[...u].length))+6}em};i(),s.addEventListener("input",i);let a=n.querySelector(".cancel"),c=n.querySelector(".replace"),l=new Promise(u=>{let p=()=>{u({convert:!1}),t.remove()};n.addEventListener("close",p),n.addEventListener("click",p),a.addEventListener("click",p),c.addEventListener("click",()=>{let f=s.value.split(`
);u({convert:!0,links:e.flatMap((m,h)=>m===f[h]||m===""||!f[h]?[]:[{before:m,after:f[h]??m}])}),t.remove()}),n.querySelector(".container").addEventListener("click",f=>{f.stopPropagation()})});return document.body.append(t),n.showModal(),l};var Jk=async(e,t)=>{let r=co(e),o=await Xk([...new Set(r)]);if(!o.convert||o.links.length===0)return;let n=new Map(o.links.map(s=>[s.before,De()]));for await(let{link:s,projectCount:i,replaced:a,done:c}of sk(o.links,t)){let l=n.get(s.before);if(l){if(c){l.render({type:"check-circle"},{type:"text",text:"${s.after}", ${a}l. ${i}p.}),setTimeout(()=>l.dispose(),1e3);continue}l.render({type:"spinner"},{type:"text",text:"${s.after}", ${a}l. ${i}p.})}}};var Qk=async(e,t)=>{let r=co(e)[0];if(!r)return;let o=window.prompt(Replace "${r}" to this in ${t.map(a=>"/${a}").join(", ")},r)?.replace?.(/[\[\]\n]/g," ")??"";if(o==="")return;let{render:n,dispose:s}=De(),i=S(await Mt());try{n({type:"spinner"},{type:"text",text:Replacing links in ${t.length} projects...});let a=0,l=(await Promise.all(t.map(async u=>{let[p]=await Promise.all([wa(u,r,o),Le(u,r,(f,{persistent:m})=>{if(m)return[o,...f.map(h=>h.text).slice(1)]},{socket:i})]);if(O(p))throw n({type:"exclamation-triangle"},{type:"text",text:${Z(p).name} ${Z(p).message}}),vI(Z(p));return a++,n({type:"spinner"},{type:"text",text:Replacing links in ${t.length-a} projects...}),S(p)}))).reduce((u,p)=>u+p,0);n({type:"check-circle"},{type:"text",text:Successfully replaced ${l} links.})}finally{await Ct(i),setTimeout(s,1e3)}},vI=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var Zk=e=>{let t=[scrapbox.Project.name,...e];scrapbox.PopupMenu.addButton({title:r=>{let o=co(r).length;return o>1?"update links":o===1?"update a link":""},onClick:r=>{let o=co(r).length;o>1?Jk(r,t):o===1&&Qk(r,t)}})};scrapbox.PopupMenu.addButton({title:e=>/[\n..。]/.test(e)?"\\n":"",onClick:e=>e.replace(/(\w)\n(\w)/g,"$1 $2").replaceAll(
,"").replaceAll(".",.
).replaceAll(".",.
).replaceAll("。",。
)});scrapbox.PopupMenu.addButton({title:e=>/https:\/\/(?:thumb\.|i\.)?gyazo\.com\/[a-z0-9]+/.test(e)?globalThis.GM_fetch?"copy Gyazo OCR":"open Gyazo":"",onClick:async e=>{let t=e.match(/https:\/\/(?:thumb\.|i\.)?gyazo\.com\/([a-z0-9]+)/)?.[1];if(!t)return;if(!globalThis.GM_fetch){window.open(https://gyazo.com/${t});return}let o=(await(await GM_fetch(https://gyazo.com/${t}.json)).json()).metadata?.ocr?.description;if(o)try{await navigator.clipboard.writeText(o)}catch(n){console.error(n),alert(${n.name} ${n.message})}}});scrapbox.PopupMenu.addButton({title:e=>/https:\/\/gyazo\.com\/[a-z0-9]+/.test(e)?"":"",onClick:e=>{let t=e.match(/https:\/\/gyazo\.com\/([a-z0-9]+)/)?.[1];t&&window.open(https://gyazo.com/${t}/transform)}});var ev=e=>{let t="",r=0;for(let o of e)if(o.type!=="title"){if(o.indent>r)for(let n=r;n<o.indent;n++)t+=Ii(${n!==r?"\\item":""}\\begin{itemize},n*2)+
;if(o.indent<r)for(let n=r;n>o.indent;n--)t+=Ii("\\end{itemize}",(n-1)*2)+
;r=o.indent,t+=Ii(${r>0?"\\item ":""}${TI(o)},r*2)+
}for(let o=r;o>0;o--)t+=Ii("\\end{itemize}",(o-1)*2)+
;return t},TI=e=>{switch(e.type){case"codeBlock":return _I(e);case"table":return PI(e);case"line":return OI(e)}},_I=e=>\\begin{lstlisting}language=${Jt(LI(e.fileName))},caption=${Jt(e.fileName)},label=lang:${e.fileName},numbers=left
${e.content}
\\end{lstlisting},PI=e=>{let t=\\caption{${Jt(e.fileName)}}\\label{table:${Jt(e.fileName)}},r=Math.max(...e.cells.map(n=>n.length)),o=e.cells.map(n=> ${n.map(s=>s.map(i=>Ts(i)).join("")).join(" & ")}\\\\);return\\begin{table}htbp
${t}
\\centering
\\begin{tabular}{${"c".repeat(r)}}
${o.length===0?"":o.length===1?` \\toprule
${o.join(`
`)}
\\bottomrule: \\toprule
${o0}
\\midrule
${o.slice(1).join(`
`)}
\\bottomrule`}
\\end{tabular}
\\end{table}},OI=e=>e.nodes.map(t=>Ts(t)).join(""),Ts=e=>{switch(e.type){case"quote":return\\begin{quote}
${Ii(e.nodes.map(t=>Ts(t)).join(""),2)}
\\end{quote};case"image":case"strongImage":return\\begin{figure}hbtp
iamge:\\url{${e.src}}
\\end{figure};case"icon":case"strongIcon":return\\textit{${Jt(e.path)}};case"strong":return\\textbf{${e.nodes.map(t=>Ts(t)).join("")}};case"formula":return$${e.formula}$;case"decoration":{let t=e.nodes.map(r=>Ts(r)).join("");return e.decos.includes("/")&&(t=\\textit{${t}}),e.decos.some(r=>/\*-/.test(r[0]))&&(t=\\textbf{${t}}),e.decos.includes("_")&&(t=\\uline{${t}}),e.decos.includes("-")&&(t=\\sout{${t}}),t}case"numberList":return${e.number}. ${e.nodes.map(t=>Ts(t)).join("")};case"helpfeel":return\\lstinline!? ${Jt(e.text)}!;case"code":return\\lstinline!${Jt(e.text)}!;case"commandLine":return\\lstinline!${Jt(e.symbol)} ${Jt(e.text)}!;case"link":return e.pathType==="absolute"?e.content===""?\\url{${e.href}}:\\href{${e.href}}{${Jt(e.content)}}:Jt(e.href);case"googleMap":return\\href{${e.url}}{${Jt(e.place)}};case"hashTag":return Jt(#${e.href});case"blank":case"plain":return Jt(e.text)}},SI=[{extensions:["javascript","js"],fileType:"javascript"},{extensions:["typescript","ts"],fileType:"typescript"},{extensions:["cpp","hpp"],fileType:"C++"},{extensions:["c","cc","h"],fileType:"C"},{extensions:["cs","csharp"],fileType:"cs"},{extensions:["markdown","md"],fileType:"markdown"},{extensions:["htm","html"],fileType:"html"},{extensions:["json"],fileType:"json"},{extensions:["xml"],fileType:"xml"},{extensions:["yaml","yml"],fileType:"yaml"},{extensions:["toml"],fileType:"toml"},{extensions:["ini"],fileType:"ini"},{extensions:["tex","sty"],fileType:"tex"},{extensions:["svg"],fileType:"svg"}],LI=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return SI.find(r=>r.extensions.includes(t))?.fileType??""},Jt=e=>e.replaceAll("\\","\\textbackslash ").replaceAll("#","\\#").replaceAll("%","\\%").replaceAll("$","\\$").replaceAll("&","\\&").replaceAll("~","\\textasciitilde ").replaceAll("^","\\textasciicircum ").replaceAll("_","\\_").replaceAll("{","\\{").replaceAll("}","\\}").replaceAll("|","\\textbar ").replaceAll("<","\\textless ").replaceAll(">","\\textgreater "),Ii=(e,t)=>e.split(
).map(r=>${" ".repeat(t)}${r}).join(
);scrapbox.PopupMenu.addButton({title:"TeX",onClick:e=>{navigator.clipboard.writeText(ev(at(e))).catch(t=>{console.error(t),alert(${t.name} ${t.message}
${t.stack})})}});var _l="https://keicho.herokuapp.com/api/";var tv=async(e,t)=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let r=await window.GM_fetch(${_l}web/,{mode:"cors",method:"POST",body:JSON.stringify({user:"nobody",talk:t,text:e}),headers:{"Content-Type":"application/json"}});if(!r.ok)return{ok:!1,value:{name:"ResponseError",res:r}};let o=await r.json();return{ok:!0,value:{text:o.text,buttons:o.buttons,canInput:o.can_input}}};var rv=()=>{let{popupMenu:e,render:t}=NI();Mg()?.append?.(e);let r=Ro(),o=()=>{requestAnimationFrame(()=>{let n=document.getElementsByClassName("cursor")[0];e.style.top=${parseInt(n.style.top)+parseInt(n.style.height)+4}px})};return r.addChangeListener(o),{render:t,visible:()=>!e.hidden,open:()=>e.hidden=!1,close:()=>e.hidden=!0,toggle:()=>e.hidden=!e.hidden,dispose:()=>{e.remove(),r.removeChangeListener(o)}}},NI=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});t.innerHTML=
<style>
:host {
position: absolute;
left: 0px;
width:100%;
z-index:300;
user-select:none;
font-family:"Open Sans",Helvetica,Arial,"Hiragino Sans",sans-serif;
pointer-events:none
}
.button-container {
position: relative;
display:inline-block;
max-width:70vw;
min-width:80px;
text-align:center;
background-color:#111;
padding:0 1px;
border-radius:4px;
pointer-events:auto
}
htmldata-os*='android' .button-container {
max-width:90vw
}
htmldata-os*='ios' .button-container {
max-width:90vw
}
.button {
font-size:11px;
color:#eee;
cursor:pointer;
display:inline-block;
padding:0 5px
}
.button:not(:first-of-type) {
border:0;
border-left:1px solid #eee
}
.button.selected {
background-color:#222;
text-decoration:underline
}
htmldata-os*='android' .button {
font-size:13px;
padding:6px;
min-width:12vw
}
htmldata-os*='ios' .button{
font-size:13px;
padding:6px;
min-width:12vw
}
.button div.icon {
height:2em;
max-width:10em;
display:inline-block;
overflow:hidden;
margin-left:1px;
vertical-align:top
}
.button div.icon img {
max-height:100%;
vertical-align:unset
}
</style>
<div class="button-container"></div>
;let r=t.lastElementChild;return{popupMenu:e,render:(...o)=>{r.textContent="",r.append(...o.map(({text:n,onClick:s})=>{let i=document.createElement("div");return i.classList.add("button"),i.textContent=n,s&&i.addEventListener("click",()=>s()),i}))}}};var ov=async(e="normal")=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let t=await window.GM_fetch(${_l}web/create/?mode=${e},{mode:"cors"});return t.ok?{ok:!0,value:await t.text()}:{ok:!1,value:{name:"ResponseError",res:t}}};var nv=e=>https://keicho.netlify.app/#talk=${e};var sv=e=>{let t=e.split(
),r=t[1]??t[0],o=e===t[0]?"":t[0];return o?[o.trim(),r].join(
):r};var Pl=async(e,t,r)=>{let o=Ro(),n=o.lines.findIndex(i=>i.id===t.id);n<0&&(n=o.lines.findIndex(i=>i.text===t.text)),n<0&&(n=Math.min(r,Math.max(0,o.lines.length-1)));let s=o.lines[n].text;return qa().clear(),o.setPosition({line:n,char:[...s].length}),await ct(
${e}),o.getPosition().line};var iv=e=>at(e,{hasTitle:!1}).map(t=>{if(t.type==="title")return t.text.trimEnd();let r=" ".repeat(t.indent);switch(t.type){case"codeBlock":return[${r}${t.fileName},...t.content.split(
).map(o=>${r} ${o})].join(
).trimEnd();case"table":return[${r}${t.fileName},...t.cells.map(o=>${r} ${o.flatMap(n=>n.map(s=>Ol(s))).join(" ")})].join(
).trimEnd();case"line":return${r}${t.nodes.map(o=>Ol(o)).join("")}.trimEnd()}}).join(
),Ol=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Ol(t)).join("")};case"helpfeel":case"commandLine":return e.raw;case"strongImage":case"image":case"strongIcon":case"icon":case"googleMap":return"";case"strong":case"decoration":case"numberList":return e.nodes.map(t=>Ol(t)).join("");case"formula":return\\(${e.formula}\\);case"code":return ${e.text} ;case"blank":case"plain":return e.raw;case"hashTag":return e.href;case"link":switch(e.pathType){case"absolute":return e.content? ${e.content} :"";case"root":return e.href.split("/").pop()??"";case"relative":return e.href}}};var _s=e=>/^[((]/.test(e);var cv=async e=>{let t=scrapbox.Page.lines;if(!t)return;let{cursor:r,selection:o}=Bt(),n=e?.entire||o.hasSelectionAll(),s=n?t.map(P=>P.text).join(
):o.getSelectedText(),i=e?.botIcon??"[/nishio/nisbot.icon]",{render:a,visible:c,open:l,close:u,dispose:p}=rv();u();let f=new Set,m=()=>{p();for(let P of f)P()},h=P=>f.add(P),g={text:"Exit",onClick:m},y=e?.talkId||av(s)||(n?"":av(t.slice(0,1+r.getPosition().line).map(P=>P.text).join(
))),x=!y;if(!y){let P=ov(e?.mode),I=setTimeout(()=>{a({text:"Start talking..."}),l();let j=0;I=setInterval(()=>{a({text:Start talking${".".repeat(j%3)}}),j++},1e3)},1e3),$=await P;if(clearTimeout(I),!$.ok){if($.value.name==="GMFetchNotAvailableError"){alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc.");return}if($.value.name==="ResponseError"){a({text:Error: ${$.value.res.status} ${$.value.res.statusText}},g),l(),console.error(Error: ${$.value.res.status} ${$.value.res.statusText},await $.value.res.text());return}return}y=$.value}let w=y,k=o.normalizeOrder(o.getRange()),b=n?t.length-1:k.end.line,T=t[b],v=n?"":" ".repeat(Math.min(...t.slice(k.start.line,k.end.line+1).map(P=>Zt(P.text)))),A=async P=>{let I=await tv(P,w);if(!I.ok)switch(I.value.name){case"ResponseError":return a({text:Error: ${I.value.res.status} ${I.value.res.statusText}},g),l(),console.error(Error: ${I.value.res.status} ${I.value.res.statusText},await I.value.res.text()),I;case"GMFetchNotAvailableError":return alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc."),I}return I},F="",D=async P=>{let I=iv(P).split(
).map(B=>B.trim()).join(
).trim();I.startsWith(F)&&(I=I.slice(F.length));let $=I.split(
);if($.length===0)return;if($.every(B=>_s(B))&&(F=I),$.filter(B=>!_s(B)).length<2){let B,Y;for(let G of $){if(Y=await A(G),!Y.ok)return Y;_s(G)||(B=Y)}return B??Y}let q=0;{let B;for(;q<$.length&&_s($[q]);q++)if(B=await A($[q]),!B.ok)return B}{let B=await A("まず聞いて");if(!B.ok)return B}for(;q<$.length&&!_s($[q]);q++){let B=await A($[q]);if(!B.ok)return B}return await A("おしまい")},N=async P=>{if(scrapbox.Layout!=="page"||P==="")return;let I=D(P),$=setTimeout(()=>{a({text:"Asking..."}),l();let G=0;$=setInterval(()=>{a({text:Asking${".".repeat(G%3)}}),G++},1e3)},1e3),j=await I;if(clearTimeout($),!j||!j.ok)return;let{text:q,buttons:B}=j.value,Y=sv(q);if(Y.trim()){let G=${v}${i}${Y.includes(`
)?
${Y.split(`
).map(X=> ${v}${X}).join(
)}:Y}
${v};b=await Pl(G,T,b),T=t[b]}a({text:"Send",onClick:_},{text:"🙂",onClick:()=>ct("🙂")},{text:"🙁",onClick:()=>ct("🙁")},...B.map(G=>({text:G,onClick:async()=>{b=await Pl(G,T,b),T=t[b],await N(G)}})),g),l()},_=async()=>{if(scrapbox.Layout!=="page")return;let P=scrapbox.Page.lines,I=r.getPosition().line,[$,j,q]=MI(P,I,i);$!==""&&(b=q,T=P[b],v=" ".repeat(Math.min(...P.slice(j,q+1).map(B=>Zt(B.text)))),await N($))};return x&&(b=await Pl(nv(w),T,b),T=t[b]),await N(s),{ask:_,open:l,close:u,visible:c,exit:m,onExit:h}},av=e=>{for(let t of e.split(
).reverse()){let r=t.match(/https?:\/\/keicho\.netlify\.app\/#talk=(\w+)/)?.[1];if(r)return r}},MI=(e,t,r)=>{let o=Math.max(e.findLastIndex((s,i)=>i<t&&s.text.trim().startsWith(r)),1),n=o+Go(o,e)+1;return[e.slice(n,t+1).map(s=>s.text.trim()).join(
).trim(),n,t]};scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>$ ${e}});var lv=[ln,pn,un];scrapbox.PopupMenu.addButton({title:e=>{let t=Jr({project:scrapbox.Project.name,mode:"noopen",hooks:lv});return!t||t.hookName.includes("default")?"":t.hookName.includes("task")?"":t.hookName.includes("split")?"":""},onClick:()=>{let e=window.prompt("Create a new page at",scrapbox.Project.name);e&&Jr({project:e,mode:"noopen",hooks:lv})?.()}});scrapbox.PopupMenu.addButton({title:e=>/(https?:\/\/[^\s]+)/g.test(e)?"":"",onClick:e=>{let t=e.replace(/(https?:\/\/[^\s]+)/g,"[$1#.jpg]");if(e!==t)return t}});scrapbox.PopupMenu.addButton({title:"S",onClick:e=>{window.open(https://scrapbox.io/${scrapbox.Project.name}/search/page?q=${e})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[(.*)\]/g,"$1")).join(
);window.open(https://www.google.com/search?q=${encodeURIComponent(t)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=o=>[...o].some(n=>n.charCodeAt(0)>255),r=e.split(/\n/).map(o=>o.replace(/\[(.*)\]/g,"$1")).join(
).trim().replace(/\s+/g,"+");t(r)?window.open(https://www.ldoceonline.com/search/japanese-english/direct/?q=${encodeURIComponent(r)}):window.open(https://www.oxfordlearnersdictionaries.com/search/english/?q=${encodeURIComponent(r)})}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\[(.*)\]/g,"$1")).join(
);window.open(https://www.google.com/search?q=${encodeURIComponent(t)}+site:scrapbox.io)}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"🖍",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:e=>/\$([^$]+)\$/.test(e)?"L":"",onClick:e=>{let t=e.split(/\n/).map(r=>r.replace(/\$([^$]+)\$/g,"[$ $1]")).join(
);if(e!=t)return t}});var CI=[vf,$k,vf,Bk,Gk,vl(),zk,Dk(),jk,e=>{if(e.hostname!=="ekitan.com"||!/^\/transit\/(?:route|first|last)\//.test(e.pathname))return e;let t=e.searchParams.get("dt"),r=e.searchParams.get("tm"),o=e.searchParams.get("sr"),n=new URL(e);return n.search="",t&&n.searchParams.append("dt",t),n.pathname.startsWith("/transit/route/")&&(r&&n.searchParams.append("tm",r),o&&n.searchParams.append("sr",o)),n},e=>{if(e.host!==location.host||!e.pathname.startsWith("/api/code/"))return e;let t=encodeURIComponent(${e.origin}${e.pathname});return${e}.endsWith(".svg")?${e}:${e}.endsWith(".mlt")?${e}:e},e=>{if(e.hostname==="raw.githubusercontent.com")return${e};if(e.hostname!=="github.com")return e;let[t,r,o]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!o)return e;let[,n,s]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${n&&s?L${n}-${s}/:n?L${n}/:""}https://raw.githubusercontent.com/${t}/${r}/${o}#.svg ${e}]},e=>e.hostname==="github.com"?${e}:e,Kk,qk()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=Vk(e,...CI);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return ct(r)})}});Zk(["takker","takker-memex","takker-private","takker-books"]);if(!/mobile/i.test(navigator.userAgent)){let e=(t,r)=>{t.trim()!==""&&cv({mode:r}).then(o=>{if(!o)return;let{ask:n,visible:s,onExit:i}=o,a=c=>{!s()||c.key!=="Enter"||!c.ctrlKey||c.altKey||c.shiftKey||(c.preventDefault(),c.stopPropagation(),n())};ht().addEventListener("keydown",a),i(()=>ht().removeEventListener("keydown",a))})};scrapbox.PopupMenu.addButton({title:()=>"🤖",onClick:t=>e(t)})}var Ai=(e,t)=>t.map(r=>r.replace(/@yyyy-MM-dd HH:mm:ss@/g,pe(e,"yyyy-MM-dd HH:mm:ss")).replace(/@yyyy-MM-dd@/g,pe(e,"yyyy-MM-dd")).replace(/@yyyy-MM-dd(?:([+-])(\d+)(w?))?(?:\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))?@/g,(o,n,s,i,a)=>{let c=n?n==="+"?Te(e,parseInt(s)*(i==="w"?7:1)):zt(e,parseInt(s)*(i==="w"?7:1)):e;return pe(a?Te(Ne(c),II(a)):c,"yyyy-MM-dd")}).replace(/@yyyy-ww@/g,${Xo(e)}-w${${To(e)}.padStart(2,"0")}).replace(/@yyyy-ww([+-])(\d+)(w?)@/g,(o,n,s,i)=>{let a=n==="+"?Te(e,parseInt(s)*(i==="w"?7:1)):zt(e,parseInt(s)*(i==="w"?7:1));return${Xo(a)}-w${${To(a)}.padStart(2,"0")}}).replace(/@yyyy@/g,${Xo(e)}).replace(/@yyyy([+-])(\d+)y@/g,(o,n,s)=>{let i=parseInt(s);return${Xo(e)+(n==="+"?i:-i)}})),II=e=>{switch(e){case"Sun":return 0;case"Mon":return 1;case"Tue":return 2;case"Wed":return 3;case"Thu":return 4;case"Fri":return 5;default:return 6}};var uv=async(e,t,r,o=new Date(2023,1,3))=>{if(scrapbox.Project.name!==e)return()=>{};let n=scrapbox.Project.pages;await new Promise(l=>{let u=setInterval(()=>{if(n.length===0){n=scrapbox.Project.pages;return}clearInterval(u),l()},2e3)});let s=async()=>{let l=new Date,u={start:o,end:Te(l,1)},{render:p,dispose:f}=De(),m;try{let h=await pv(t),g=await pv(r),y=Xs(u).filter(b=>{let T=Ai(b,h)[0],v=n.find(A=>A.title===T);return!v||!v.exists}),x=_y(u).filter(b=>{let T=Ai(b,g)[0],v=n.find(A=>A.title===T);return!v||!v.exists});if(y.length===0&&x.length===0)return;let w=y.length+x.length;p({type:"spinner"},{type:"text",text:create ${w} review pages...});let k=await Mt();if(O(k))throw Z(k);m=S(k);for(let b of[...y.map(T=>Ai(T,h)),...x.map(T=>Ai(T,g))])await Le(e,b[0],(T,v)=>v.persistent?void 0:b,m?{socket:m}:{}),w--,p({type:"spinner"},{type:"text",text:create ${w} review pages...});p({type:"check-circle"},{type:"text",text:created ${y.length+x.length} review pages.}),o=l}catch(h){p({type:"exclamation-triangle"},{type:"text",text:h instanceof Error?${h.name} ${h.message}:"Unknown error! (see developper console)"}),console.error(h)}finally{m&&await Ct(m),await Fe(1e3),f()}},i=s(),a=new Date,c=setInterval(()=>{let l=new Date;yt(a,l)||(a=l,i.then(()=>i=s()))},1e4);return()=>(clearTimeout(c),i)},pv=async e=>{let t=await Ra(e[0],e[1],e[2]);if(O(t)){let o=new Error;throw o.name=Z(t).name,o.message=${Z(t).message} at fetching /${e0}/${e1}/${e2},o}let r=S(t).split(
);if(r.length===0)throw new Error(template "/${e0}/${e1}/${e2}" is empty!);return r};var mv=function(){};function Di(e,t={}){mv.prototype.name=e;let r={};return new Proxy(mv,{get(o,n){return n==="caller"?null:n==="__createMock__"?Di:n==="__unenv__"?!0:n in t?t[n]:r[n]=r[n]||Di(${e}.${n.toString()})},apply(o,n,s){return Di(${e}())},construct(o,n,s){return Di(${e})},enumerate(){return[]}})}var _f=Di("mock");function AI(e){return new Error(unenv ${e} is not implemented yet!)}function me(e){return Object.assign(()=>{throw AI(e)},{__unenv__:!0})}var FI=Object.freeze(Object.create(null,{__unenv__:{get:()=>!0}})),Sl=Object.create(null),DI=globalThis.process?.env,Fi=e=>DI||globalThis.__env__||(e?Sl:globalThis),UI=new Proxy(Sl,{get(e,t){return Fi()[t]??Sl[t]},has(e,t){let r=Fi();return t in r||t in Sl},set(e,t,r){let o=Fi(!0);return o[t]=r,!0},deleteProperty(e,t){let r=Fi(!0);return delete r[t],!0},ownKeys(){let e=Fi();return Object.keys(e)}}),$I=Object.assign(function(e){let t=Date.now(),r=Math.trunc(t/1e3),o=t%1e3*1e6;if(e){let n=r-e[0],s=o-e[0];return s<0&&(n=n-1,s=1e9+s),[n,s]}return[r,o]},{bigint:function(){return BigInt(Date.now()*1e6)}}),jI=globalThis.queueMicrotask?(e,...t)=>{globalThis.queueMicrotask(e.bind(void 0,...t))}:BI();function BI(){let e=[],t=!1,r,o=-1;function n(){!t||!r||(t=!1,r.length>0?e=[...r,...e]:o=-1,e.length>0&&s())}function s(){if(t)return;let i=setTimeout(n);t=!0;let a=e.length;for(;a;){for(r=e,e=[];++o<a;)r&&r[o]();o=-1,a=e.length}r=void 0,t=!1,clearTimeout(i)}return(i,...a)=>{e.push(i.bind(void 0,...a)),e.length===1&&!t&&setTimeout(s)}}var HI="unenv",WI=[],qI="",GI={ares:"",http_parser:"",icu:"",modules:"",node:"",openssl:"",uv:"",v8:"",zlib:""};function _r(){return Pf}var zI=_r,VI=_r,KI=_r,YI=_r,XI=_r,JI=_r,QI=function(e){return e==="message"||e==="multipleResolves"?Pf:!1},ZI=_r,eA=_r,tA=function(e){return[]},rA=()=>0,oA=function(e){throw new Error("[unenv] process.binding is not supported")},fv="/",nA=function(){return fv},sA=function(e){fv=e},iA=function(){return 0},aA=function(){return 1e3},cA=function(){return 1e3},lA=function(){return 1e3},pA=function(){return 1e3},uA=function(){return[]},mA=e=>{},fA=me("process.abort"),dA=new Set,hA="",gA="",yA=FI,xA=!1,bA=()=>0,EA=()=>0,wA=me("process.cpuUsage"),RA=0,kA=me("process.dlopen"),vA=_r,TA=_r,_A=me("process.eventNames"),PA=[],OA="",SA=me("process.exit"),LA=Object.create({inspector:void 0,debug:void 0,uv:void 0,ipv6:void 0,tls_alpn:void 0,tls_sni:void 0,tls_ocsp:void 0,tls:void 0,cached_builtins:void 0}),NA=()=>[],MA=me("process.getMaxListeners"),CA=me("process.kill"),IA=Object.assign(()=>({arrayBuffers:0,rss:0,external:0,heapTotal:0,heapUsed:0}),{rss:()=>0}),AA=1e3,FA="",DA=1e3,UA=me("process.rawListeners"),$A=Object.create({name:"",lts:"",sourceUrl:void 0,headersUrl:void 0}),jA=Object.create({compact:void 0,directory:void 0,filename:void 0,getReport:me("process.report.getReport"),reportOnFatalError:void 0,reportOnSignal:void 0,reportOnUncaughtException:void 0,signal:void 0,writeReport:me("process.report.writeReport")}),BA=me("process.resourceUsage"),HA=me("process.setegid"),WA=me("process.seteuid"),qA=me("process.setgid"),GA=me("process.setgroups"),zA=me("process.setuid"),VA=me("process.setMaxListeners"),KA=me("process.setSourceMapsEnabled"),YA=_f.__createMock__("process.stdout"),XA=_f.__createMock__("process.stderr"),JA=_f.__createMock__("process.stdin"),QA=!1,ZA=()=>0,eF=0,tF=me("process.setUncaughtExceptionCaptureCallback"),rF=()=>!1,oF=!1,nF=me("process.loadEnvFile"),sF=void 0,iF={has:()=>!1},aF={ref(){},unref(){}},cF=!1,lF={register(){},unregister(){},registerBeforeExit(){}},pF=me("process.assert"),uF=me("process.openStdin"),mF=me("process._debugEnd"),fF=me("process._debugProcess"),dF=me("process._fatalException"),hF=me("process._getActiveHandles"),gF=me("process._getActiveRequests"),yF=me("process._kill"),xF=[],bF=me("process._rawDebug"),EF=me("process._startProfilerIdleNotifier"),wF=me("process.__stopProfilerIdleNotifier"),RF=me("process._tickCallback"),Yst=me("process._linkedBinding"),kF=void 0,vF=me("process.initgroups"),TF=[],_F=_r,PF=!1,OF=[],SF=0,LF=0,Pf={_events:OF,_eventsCount:SF,_exiting:PF,_maxListeners:LF,_debugEnd:mF,_debugProcess:fF,_fatalException:dF,_getActiveHandles:hF,_getActiveRequests:gF,_kill:yF,_preload_modules:xF,_rawDebug:bF,_startProfilerIdleNotifier:EF,_stopProfilerIdleNotifier:wF,_tickCallback:RF,domain:kF,initgroups:vF,moduleLoadList:TF,reallyExit:_F,exitCode:eF,abort:fA,addListener:VI,allowedNodeEnvironmentFlags:dA,hasUncaughtExceptionCaptureCallback:rF,setUncaughtExceptionCaptureCallback:tF,loadEnvFile:nF,sourceMapsEnabled:oF,throwDeprecation:cF,mainModule:sF,permission:iF,channel:aF,arch:hA,argv:WI,argv0:gA,assert:pF,binding:oA,chdir:sA,config:yA,connected:xA,constrainedMemory:bA,availableMemory:EA,cpuUsage:wA,cwd:nA,debugPort:RA,dlopen:kA,disconnect:vA,emit:QI,emitWarning:TA,env:UI,eventNames:_A,execArgv:PA,execPath:OA,exit:SA,finalization:lF,features:LA,getBuiltinModule:mA,getegid:aA,geteuid:cA,getgid:lA,getgroups:uA,getuid:pA,getActiveResourcesInfo:NA,getMaxListeners:MA,hrtime:$I,kill:CA,listeners:tA,listenerCount:rA,memoryUsage:IA,nextTick:jI,on:zI,off:YI,once:KI,openStdin:uF,pid:AA,platform:FA,ppid:DA,prependListener:ZI,prependOnceListener:eA,rawListeners:UA,release:$A,removeAllListeners:JI,removeListener:XI,report:jA,resourceUsage:BA,setegid:HA,seteuid:WA,setgid:qA,setgroups:GA,setuid:zA,setMaxListeners:VA,setSourceMapsEnabled:KA,stderr:XA,stdin:JA,stdout:YA,title:HI,traceDeprecation:QA,umask:iA,uptime:ZA,version:qI,versions:GI},Ui=Pf;var NF=Object.create,bv=Object.defineProperty,MF=Object.getOwnPropertyDescriptor,CF=Object.getOwnPropertyNames,IF=Object.getPrototypeOf,AF=Object.prototype.hasOwnProperty,Ev=(e=>typeof Uo<"u"?Uo:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof Uo<"u"?Uo:t)[r]}):e)(function(e){if(typeof Uo<"u")return Uo.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),wv=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),FF=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of CF(t))!AF.call(e,n)&&n!==r&&bv(e,n,{get:()=>t[n],enumerable:!(o=MF(t,n))||o.enumerable});return e},Rv=(e,t,r)=>(r=e!=null?NF(IF(e)):{},FF(t||!e||!e.__esModule?bv(r,"default",{value:e,enumerable:!0}):r,e)),DF=wv((e,t)=>{var r=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in Ui&&"node"in Ui.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{r=[Ev][0](${"node","util".join(":")})}catch{r=null}t.exports=r}),UF=wv((e,t)=>{var r=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in Ui&&"node"in Ui.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{r=[Ev][0](${"node","fs".join(":")})}catch{r=null}t.exports=r}),$F={},Ll=jF(globalThis,$F);function jF(e,t){return new Proxy(e,{get(r,o,n){return o in t?t[o]:e[o]},set(r,o,n){return o in t&&delete t[o],e[o]=n,!0},deleteProperty(r,o){let n=!1;return o in t&&(delete t[o],n=!0),o in e&&(delete e[o],n=!0),n},ownKeys(r){let o=Reflect.ownKeys(e),n=Reflect.ownKeys(t),s=new Set(n);return[...o.filter(i=>!s.has(i)),...n]},defineProperty(r,o,n){return o in t&&delete t[o],Reflect.defineProperty(e,o,n),!0},getOwnPropertyDescriptor(r,o){return o in t?Reflect.getOwnPropertyDescriptor(t,o):Reflect.getOwnPropertyDescriptor(e,o)},has(r,o){return o in t||o in e}})}var dv=["debug","info","warning","error","fatal"];function hv(e,t){let r=dv.indexOf(e);if(r<0)throw new TypeError(Invalid log level: ${JSON.stringify(e)}.);let o=dv.indexOf(t);if(o<0)throw new TypeError(Invalid log level: ${JSON.stringify(t)}.);return r-o}function $i(e=[]){return kv.getLogger(e)}var Of=Symbol.for("logtape.rootLogger"),kv=class Do{static getLogger(t=[]){let r=Of in Ll?Ll[Of]??null:null;return r==null&&(r=new Do(null,[]),Ll[Of]=r),typeof t=="string"?r.getChild(t):t.length===0?r:r.getChild(t)}constructor(t,r){Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"category",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sinks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parentSinks",{enumerable:!0,configurable:!0,writable:!0,value:"inherit"}),Object.defineProperty(this,"filters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lowestLevel",{enumerable:!0,configurable:!0,writable:!0,value:"debug"}),Object.defineProperty(this,"contextLocalStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.parent=t,this.children={},this.category=r,this.sinks=[],this.filters=[]}getChild(t){let r=typeof t=="string"?t:t[0],o=this.children[r],n=o instanceof Do?o:o?.deref();return n==null&&(n=new Do(this,[...this.category,r]),this.children[r]="WeakRef"in Ll?new WeakRef(n):n),typeof t=="string"||t.length===1?n:n.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks="inherit";this.filters.length>0;)this.filters.shift();this.lowestLevel="debug"}resetDescendants(){for(let t of Object.values(this.children))(t instanceof Do?t:t.deref())?.resetDescendants();this.reset()}with(t){return new BF(this,{...t})}filter(t){for(let r of this.filters)if(!r(t))return!1;return this.filters.length<1?this.parent?.filter(t)??!0:!0}*getSinks(t){if(!(this.lowestLevel===null||hv(t,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks==="inherit")for(let r of this.parent.getSinks(t))yield r;for(let r of this.sinks)yield r}}emit(t,r){if(!(this.lowestLevel===null||hv(t.level,this.lowestLevel)<0||!this.filter(t))){for(let o of this.getSinks(t.level))if(!r?.has(o))try{o(t)}catch(n){let s=new Set(r);s.add(o),HF.log("fatal","Failed to emit a log record to sink {sink}: {error}",{sink:o,error:n,record:t},s)}}}log(t,r,o,n){let s=Do.getLogger().contextLocalStorage?.getStore()??{},i,a=typeof o=="function"?{category:this.category,level:t,timestamp:Date.now(),get message(){return gv(r,this.properties)},rawMessage:r,get properties(){return i==null&&(i={...s,...o()}),i}}:{category:this.category,level:t,timestamp:Date.now(),message:gv(r,{...s,...o}),rawMessage:r,properties:{...s,...o}};this.emit(a,n)}logLazily(t,r,o={}){let n=Do.getLogger().contextLocalStorage?.getStore()??{},s,i;function a(){if((i==null||s==null)&&(i=r((c,...l)=>(s=c,yv(c,l))),s==null))throw new TypeError("No log record was made.");return[i,s]}this.emit({category:this.category,level:t,get message(){return a()[0]},get rawMessage(){return a()[1]},timestamp:Date.now(),properties:{...n,...o}})}logTemplate(t,r,o,n={}){let s=Do.getLogger().contextLocalStorage?.getStore()??{};this.emit({category:this.category,level:t,message:yv(r,o),rawMessage:r,timestamp:Date.now(),properties:{...s,...n}})}debug(t,...r){typeof t=="string"?this.log("debug",t,r[0]??{}):typeof t=="function"?this.logLazily("debug",t):this.logTemplate("debug",t,r)}info(t,...r){typeof t=="string"?this.log("info",t,r[0]??{}):typeof t=="function"?this.logLazily("info",t):this.logTemplate("info",t,r)}warn(t,...r){typeof t=="string"?this.log("warning",t,r[0]??{}):typeof t=="function"?this.logLazily("warning",t):this.logTemplate("warning",t,r)}error(t,...r){typeof t=="string"?this.log("error",t,r[0]??{}):typeof t=="function"?this.logLazily("error",t):this.logTemplate("error",t,r)}fatal(t,...r){typeof t=="string"?this.log("fatal",t,r[0]??{}):typeof t=="function"?this.logLazily("fatal",t):this.logTemplate("fatal",t,r)}},BF=class vv{constructor(t,r){Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.logger=t,this.properties=r}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(t){return this.logger.getChild(t).with(this.properties)}with(t){return new vv(this.logger,{...this.properties,...t})}log(t,r,o,n){this.logger.log(t,r,typeof o=="function"?()=>({...this.properties,...o()}):{...this.properties,...o},n)}logLazily(t,r){this.logger.logLazily(t,r,this.properties)}logTemplate(t,r,o){this.logger.logTemplate(t,r,o,this.properties)}debug(t,...r){typeof t=="string"?this.log("debug",t,r[0]??{}):typeof t=="function"?this.logLazily("debug",t):this.logTemplate("debug",t,r)}info(t,...r){typeof t=="string"?this.log("info",t,r[0]??{}):typeof t=="function"?this.logLazily("info",t):this.logTemplate("info",t,r)}warn(t,...r){typeof t=="string"?this.log("warning",t,r[0]??{}):typeof t=="function"?this.logLazily("warning",t):this.logTemplate("warning",t,r)}error(t,...r){typeof t=="string"?this.log("error",t,r[0]??{}):typeof t=="function"?this.logLazily("error",t):this.logTemplate("error",t,r)}fatal(t,...r){typeof t=="string"?this.log("fatal",t,r[0]??{}):typeof t=="function"?this.logLazily("fatal",t):this.logTemplate("fatal",t,r)}},HF=kv.getLogger(["logtape","meta"]);function gv(e,t){let r=[],o="";for(let n=0;n<e.length;n++){let s=e.charAt(n),i=e.charAt(n+1);if(s==="{"&&i==="{")o=o+s,n++;else if(s==="}"&&i==="}")o=o+s,n++;else if(s==="{")r.push(o),o="";else if(s==="}"){let a;o.match(/^\s|\s$/)?a=o in t?t[o]:t[o.trim()]:a=t[o],r.push(a),o=""}else o=o+s}return r.push(o),r}function yv(e,t){let r=[];for(let o=0;o<e.length;o++)r.push(e[o]),o<t.length&&r.push(t[o]);return r}var WF=Rv(DF()),Nl=WF.default,xv={debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},Tv="Deno"in globalThis&&"inspect"in globalThis.Deno&&typeof globalThis.Deno.inspect=="function"?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):Nl!=null&&"inspect"in Nl&&typeof Nl.inspect=="function"?(e,t)=>Nl.inspect(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function _v(e={}){let t=e.timestamp==null||e.timestamp==="date-time-timezone"?i=>new Date(i).toISOString().replace("T"," ").replace("Z"," +00:00"):e.timestamp==="date-time-tz"?i=>new Date(i).toISOString().replace("T"," ").replace("Z"," +00"):e.timestamp==="date-time"?i=>new Date(i).toISOString().replace("T"," ").replace("Z",""):e.timestamp==="time-timezone"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z"," +00:00"):e.timestamp==="time-tz"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z"," +00"):e.timestamp==="time"?i=>new Date(i).toISOString().replace(/.*T/,"").replace("Z",""):e.timestamp==="date"?i=>new Date(i).toISOString().replace(/T.*/,""):e.timestamp==="rfc3339"?i=>new Date(i).toISOString():e.timestamp,r=e.category??"·",o=e.value??Tv,n=e.level==null||e.level==="ABBR"?i=>xv[i]:e.level==="abbr"?i=>xv[i].toLowerCase():e.level==="FULL"?i=>i.toUpperCase():e.level==="full"?i=>i:e.level==="L"?i=>i.charAt(0).toUpperCase():e.level==="l"?i=>i.charAt(0):e.level,s=e.format??(({timestamp:i,level:a,category:c,message:l})=>${i} ${a} ${c}: ${l});return i=>{let a="";for(let p=0;p<i.message.length;p++)p%2===0?a+=i.message[p]:a+=o(i.message[p]);let c=t(i.timestamp),l=n(i.level),u=typeof r=="function"?r(i.category):i.category.join(r);return${s({timestamp:c,level:l,category:u,message:a,record:i})}
}}var Qst=_v(),Sf="\x1B[0m",Lf={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},Nf={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},qF={debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};function GF(e={}){let t=e.format,r=typeof e.timestampStyle>"u"?"dim":e.timestampStyle,o=e.timestampColor??null,n=${r==null?"":Nfr}${o==null?"":Lfo},s=r==null&&o==null?"":Sf,i=typeof e.levelStyle>"u"?"bold":e.levelStyle,a=e.levelColors??qF,c=typeof e.categoryStyle>"u"?"dim":e.categoryStyle,l=e.categoryColor??null,u=${c==null?"":Nfc}${l==null?"":Lfl},p=c==null&&l==null?"":Sf;return _v({timestamp:"date-time-tz",value(f){return Tv(f,{colors:!0})},...e,format({timestamp:f,level:m,category:h,message:g,record:y}){let x=a[y.level];return f=${n}${f}${s},m=${i==null?"":Nfi}${x==null?"":Lfx}${m}${i==null&&x==null?"":Sf},t==null?${f} ${m} ${u}${h}:${p} ${g}:t({timestamp:f,level:m,category:${u}${h}${p},message:g,record:y})}})}var Zst=GF();var zF=Rv(UF()),VF=zF.default;function Ps(){throw new Error("File sink is not available in the browser.")}var KF={openSync:Ps,writeSync:Ps,flushSync:Ps,closeSync:Ps,statSync:Ps,renameSync:Ps},Pn=VF,eit=Pn==null?KF:{openSync(e){return Pn.openSync(e,"a")},writeSync:Pn.writeSync,flushSync:Pn.fsyncSync,closeSync:Pn.closeSync,statSync:Pn.statSync,renameSync:Pn.renameSync};async function*Pv(e){let t=[],r=[],o=new Map,n=[];for(let s of e)s.isValid&&(s.id?s.isMember||t.push(s.id):r.push(s.name),n.push(s.name),o.set(s.name,s.checked));for(let s=0;s<t.length;s+=50){let i=t.slice(s,s+50);if(i.length===0)break;i.length===1&&i.push(i[0]);let a=await ba(i);if(O(a)){r=n;break}for(let c of S(a).projects)o.has(c.name)&&(yield L({...c,checked:o.get(c.name)??0}))}for(let s of r){let i=await Bo(s);yield K(i)?L({...S(i),checked:o.get(s)??0}):M({...Z(i),project:s})}}var If=(e,t)=>t.some(r=>e instanceof r),Ov,Sv;function YF(){return Ov||(Ov=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function XF(){return Sv||(Sv=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Af=new WeakMap,Mf=new WeakMap,Ml=new WeakMap;function JF(e){let t=new Promise((r,o)=>{let n=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(On(e.result)),n()},i=()=>{o(e.error),n()};e.addEventListener("success",s),e.addEventListener("error",i)});return Ml.set(t,e),t}function QF(e){if(Af.has(e))return;let t=new Promise((r,o)=>{let n=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),n()},i=()=>{o(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});Af.set(e,t)}var Ff={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Af.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return On(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Cv(e){Ff=e(Ff)}function ZF(e){return XF().includes(e)?function(...t){return e.apply(Df(this),t),On(this.request)}:function(...t){return On(e.apply(Df(this),t))}}function eD(e){return typeof e=="function"?ZF(e):(e instanceof IDBTransaction&&QF(e),If(e,YF())?new Proxy(e,Ff):e)}function On(e){if(e instanceof IDBRequest)return JF(e);if(Mf.has(e))return Mf.get(e);let t=eD(e);return t!==e&&(Mf.set(e,t),Ml.set(t,e)),t}var Df=e=>Ml.get(e);function Iv(e,t,{blocked:r,upgrade:o,blocking:n,terminated:s}={}){let i=indexedDB.open(e,t),a=On(i);return o&&i.addEventListener("upgradeneeded",c=>{o(On(i.result),c.oldVersion,c.newVersion,On(i.transaction),c)}),r&&i.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),n&&c.addEventListener("versionchange",l=>n(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}var tD=["get","getKey","getAll","getAllKeys","count"],rD=["put","add","delete","clear"],Cf=new Map;function Lv(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(Cf.get(t))return Cf.get(t);let r=t.replace(/FromIndex$/,""),o=t!==r,n=rD.includes(r);if(!(r in(o?IDBIndex:IDBObjectStore).prototype)||!(n||tD.includes(r)))return;let s=async function(i,...a){let c=this.transaction(i,n?"readwrite":"readonly"),l=c.store;return o&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),n&&c.done]))[0]};return Cf.set(t,s),s}Cv(e=>({...e,get:(t,r,o)=>Lv(t,r)||e.get(t,r,o),has:(t,r)=>!!Lv(t,r)||e.has(t,r)}));var oD=["continue","continuePrimaryKey","advance"],Nv={},Uf=new WeakMap,Av=new WeakMap,nD={get(e,t){if(!oD.includes(t))return e[t];let r=Nv[t];return r||(r=Nv[t]=function(...o){Uf.set(this,Av.get(this)[t](...o))}),r}};async function*sD(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let r=new Proxy(t,nD);for(Av.set(r,t),Ml.set(r,Df(t));t;)yield r,t=await(Uf.get(r)||t.continue()),Uf.delete(r)}function Mv(e,t){return t===Symbol.asyncIterator&&If(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&If(e,[IDBIndex,IDBObjectStore])}Cv(e=>({...e,get(t,r,o){return Mv(t,r)?sD:e.get(t,r,o)},has(t,r){return Mv(t,r)||e.has(t,r)}}));var Fv,$f=async()=>{let e=$i(["@takker/cosense-storage","open"]);return Fv??=await Iv("scrapbox-storage",4,{upgrade(t,r,o){e.infostart updating DB: ${r} -> ${o};let n=Date.now();for(let a of t.objectStoreNames)t.deleteObjectStore(a);t.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let i=t.createObjectStore("projects",{keyPath:"id"});i.createIndex("checked","checked"),i.createIndex("name","name"),e.infofinish updating DB: ${Date.now()-n}ms},blocked(t,r){let o=The database "@takker/cosense-storage"(v${r}) is blocked because the older one (v${t}) is opened in other tabs.
Please close the other tabs and reload this page.;e.error(o),alert(o)},blocking(t,r){let o=The database "@takker/cosense-storage"(v${t}) is blocking the newer one (v${r}) opened.
Please close this page.;e.error(o),alert(o)}}),Fv};var Dv=(e,t)=>(jf||(jf=new BroadcastChannel($v),jf.addEventListener("message",r=>Uv(r.data))),Cl.set(t,new Set(e).union(Cl.get(t)??new Set)),()=>Cl.delete(t)),Bf=(e,t)=>{if((t.added?.size??0)+(t.updated?.size??0)+(t.deleted?.size??0)===0)return;let r={type:"links:changed",project:e,diff:t};Uv(r);let o=new BroadcastChannel($v);o.postMessage(r),o.close()},Uv=e=>{for(let[t,r]of Cl)r.has(e.project)&&t(e)},$v="scrapbox-storage-notify",jf,Cl=new Map;var jv=async(e,t)=>{let r=await $f(),o=$i(["@takker/cosense-storage","check"]),n=new Map;try{{o.debugcheck updates of links...;let i=new Set,a=r.transaction("projects","readwrite"),c=hf(new Date),l=c-600;for await(let f of a.store.index("checked").iterate(IDBKeyRange.lowerBound(l,!0))){let m=f.value;if(m.isValid===!1){i.add(m.id);continue}i.add(m.name);let h=m.checked;if(h+t>c||m?.updating&&h>l)continue;let g=structuredClone(m);g.updating=!0,n.set(m.id,g),f.update(g)}let u=[],p=a.store.index("name");for(let f of e)i.has(f)||u.push(p.get(f).then(m=>{m?.updating&&(m?.checked??0)>l||n.set(f,m??iD(f))}));if(await Promise.all(u),await a.done,n.size===0){o.debugchecked. No project needs upgrade.;return}o.debugchecked. ${n.size} projects maybe need upgrade.}let s=hf(new Date);for await(let i of Pv(n.values())){if(O(i)){let{project:h,name:g}=Z(i);switch(g){default:continue;case"NotFoundError":o.warn("${h}" is not found.);break;case"NotMemberError":o.warn(You are not a member of "${h}".);break;case"NotLoggedInError":o.warn(You are not a member of "${h}" or You are not logged in yet.);break}n.set(h,{id:h,name:h,checked:s,updating:!1,isValid:!1,reason:g});continue}let{checked:a,...c}=S(i);if(c.updated<a){o.debugno updates in "${c.name}",n.set(c.name,{...c,isValid:!0,checked:s,updating:!1});continue}o.debugstart downloading and storing links of "${c.name}";let l=new Set(await r.getAllKeysFromIndex("titles","project",c.name)),u=0,p=0;for await(let h of $h(c.name)){if(O(h)){let{name:w,message:k}=Z(h);o.errorFailed to get links of "${c.name}" with ${w}: ${k};break}let g=S(h),y={},x=r.transaction("titles","readwrite");await Promise.all(g.map(async w=>{let k={...w,project:c.name},b=await x.store.get(w.id);if(!b)return y.added?.set?.(w.id,k)??(y.added=new Map([[w.id,k]])),x.store.add(k);if(l.delete(w.id),!!aD(k,b))return y.updated?.set?.(w.id,[b,k])??(y.updated=new Map([[w.id,[b,k]]])),x.store.put(k)})),await x.done,u+=y.added?.size??0,p+=y.updated?.size??0,o.debugUpdating "/${c.name}": +${u} pages, ~${p} pages,Bf(c.name,y)}let f=r.transaction("titles","readwrite"),m=new Map((await Promise.all([...l].map(async h=>{let g=await f.store.get(h);if(!g)return[];let y=[[h,g]];return await f.store.delete(h),y}))).flat());await f.done,o.debugFinish downloading and storing links of "${c.name}",o.debugUpdate "/${c.name}": +${u} pages, ~${p} pages, -${m.size} pages,n.set(c.name,{...c,isValid:!0,checked:s,updating:!1}),Bf(c.name,{deleted:m})}}finally{let s=r.transaction("projects","readwrite");await Promise.all([...n].map(([,i])=>(i.updating=!1,s.store.put({...i})))),await s.done}},Il=async e=>{let t=[...new Set(e)];if(t.length===0)return[];let r=Date.now(),n=(await $f()).transaction("titles","readonly"),s=n.store.index("project"),i=(await Promise.all(t.map(c=>s.getAll(c)))).flat();return await n.done,$i(["@takker/cosense-storage","load"]).debugRead ${i.length} links from ${t.length} projects in ${Date.now()-r}ms,i},iD=e=>({name:e,displayName:e,id:"",isValid:!0,publicVisible:!0,isMember:!0,loginStrategies:[],theme:"default",gyazoTeamsName:null,translation:!0,infobox:!0,checked:0,updated:0,created:0,updating:!0}),aD=(e,t)=>e.updated>t.updated||e.links.sort().join()!==t.links.sort().join();var Wt=e=>${e.getFullYear()}-${vr(e.getMonth()+1)}-${vr(e.getDate())},ji=e=>{let[t,r,o]=e.split("-").map(n=>parseInt(n,10));return{year:t,month:r,date:o}},Bi=e=>${Yo(e)}-w${vr(To(e))},Al=e=>{let[t,r]=e.split("-w").map(o=>parseInt(o,10));return Ne(Qa(new Date(t,0,1),r))};var Bv="takker-memex",Hv=async(e=new Date(2023,0,24))=>{if(scrapbox.Project.name!==Bv)return()=>{};let t=scrapbox.Project.pages;await new Promise(i=>{let a=setInterval(()=>{if(t.length===0){t=scrapbox.Project.pages;return}clearInterval(a),i()},2e3)});let r=async()=>{let i=new Date,c=Xs({start:e,end:i}).filter(f=>{let m=kr(f),h=t.find(g=>g.title===m);return!h||!h.exists});if(c.length===0)return;let{render:l,dispose:u}=De(),p;try{l({type:"spinner"},{type:"text",text:load tasks for ${c.length} diary pages});let f=new Map,m=new Set,h=c.map(x=>Wt(x));for(let{title:x,links:w,project:k}of await Il(["takker","takker-memex"]))for(let b of[x,...w]){let T=pr(b);if(!T)continue;if(O(T)){let{name:F,message:D}=Z(T);console.error(/${k}/${b}: ${F} ${D});continue}let v=ae(b);if(m.has(v))continue;m.add(v);let A=S(T);if(A.freshness?.status!=="done")for(let F of c){let D=cn(A,F);if(!D)continue;let N=Wt(D.base);h.includes(N)&&(f.set(N,[...f.get(N)??[],D]),Oo(A))}}let g=await Mt();if(O(g))throw Z(g);p=S(g);let y=0;l({type:"spinner"},{type:"text",text:create 0/${c.length} diary pages...});for(let x of c){let w=kr(x),k=f.get(Wt(x))?.map?.(v=>be(v))??[],b=#${pe(x,"yyyy-MM-dd")},T=#${pe(x,"yyyy-MM-dd HH:mm:ss")};await Le(Bv,w,(v,{persistent:A})=>{if(A)return;let F=[...v.map(D=>D.text),...k];return F.some(D=>D.includes(b))?nn(F):nn([...F,T])},{socket:p}),y++,l({type:"spinner"},{type:"text",text:create ${y}/${c.length} diary pages...})}l({type:"check-circle"},{type:"text",text:created ${c.length} diary pages.}),e=i}catch(f){l({type:"exclamation-triangle"},{type:"text",text:f instanceof Error?${f.name} ${f.message}:"Unknown error! (see developper console)"}),console.error(f)}finally{p&&await Ct(p),await Fe(1e3),u()}},o=r(),n=new Date,s=setInterval(()=>{let i=new Date;yt(n,i)||(n=i,o.then(()=>o=r()))},1e4);return()=>(clearTimeout(s),o)};Hv(new Date(2024,11,24));var Wf=(...e)=>{let t=e.flatMap(o=>{if(typeof o=="string")return[Fl(o)];if(Array.isArray(o.type))return[Wv(o.type)];switch(o.type){case"text":return[Fl(o.text)];case"group":{let n=Wf(...o.items);return n?[n]:[]}default:return[Wv(o.type)]}});if(t.length===0)return;if(t.length===1)return t[0];let r=document.createElement("span");return r.classList.add("item-group"),r.append(...t),r},Fl=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},Wv=e=>{if(Array.isArray(e)){let t=document.createElement("span");t.classList.add("fa-stack");let r=Hf(e[0]);r.classList.add("fa-stack-1x");let o=Hf(e[1]);return o.classList.add("fa-stack-1x"),t.append(r,o),Fl(t)}return Fl(Hf(e))},Hf=e=>{let t=document.createElement("i");switch(e){case"spinner":t.classList.add("fa","fa-spinner");break;case"check-circle":case"gyazo":case"ocr":case"calendar":case"trim":t.classList.add("kamon",kamon-${e});break;case"markdown":case"google":t.classList.add("fab",fa-${e});break;case"copy":case"clipboard":t.classList.add("far",fa-${e});break;default:t.classList.add("fas",fa-${e});break}return t};var{cursor:qf,selection:Gf}=Bt(),Gv=e=>{let{className:t,display:r,onClick:o,context:n="page"}=e,s=document.createElement("div");t&&s.classList.add(t),qv(n)||(s.style.display="none");let i=(...l)=>{if(l.length===1&&l[0]===""){s.style.display="none";return}s.textContent="";let u=Wf(...l);u&&s.append(u)},a=typeof r=="function"?r({cursor:qf,selection:Gf}):r;return i(...Array.isArray(a)?a:[a]),s.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o({cursor:qf,selection:Gf,setDisplay:i})}),{status:s,context:n,update:()=>{if(qv(n)?s.removeAttribute("style"):s.style.display="none",typeof r=="function"){let l=r({cursor:qf,selection:Gf});i(...Array.isArray(l)?l:[l])}}}},qv=e=>e!=="stream"?scrapbox.Layout===e:scrapbox.Layout==="list"&&location.pathname.startsWith("/stream");var zv=()=>{let e=document.createElement("style");e.textContent=.status-bar.left {
position: absolute;
top: 0;
left: 0;
max-width: 80vw;
overflow-x: auto;
overflow-y: hidden;
}
.status-bar.left:empty {
display: none;
}
.status-bar.left > div {
border-left: unset;
}
.status-bar.left > div {
border-right: 1px solid var(--tool-light-color, #a9aaaf);
}
.status-bar.left > div:first-of-type {
border-top-left-radius: unset;
}
.status-bar.left > div:last-of-type {
border-top-right-radius: 3px;
},document.head.append(e);let t=document.createElement("div");return t.classList.add("status-bar","left"),document.getElementsByClassName("footer")[0].append(t),t};var zf=new Set,{cursor:cD,selection:lD}=Bt(),pD=zv();var gr=e=>{let t=Gv(e);return zf.add(t),pD.append(t.status),()=>{t.status.remove(),zf.delete(t)}},Vf=()=>{for(let{update:e}of zf)e()};cD.addChangeListener(()=>Vf());lD.addChangeListener(()=>Vf());scrapbox.addListener("layout:changed",Vf);var Vv=async(e,t)=>{try{let r=t.getSelectedText()||gt(e.getPosition().line);if(!r)return;await navigator.clipboard.writeText(r)}catch(r){console.error(r),alert(Faild to copy:
${JSON.stringify(r)})}},Kv=async(e,t)=>{try{let r=t.hasSelection(),o=r?t.getRange().start.line:e.getPosition().line,n=r?t.getSelectedText():gt(o);if(!n)return;await navigator.clipboard.writeText(n),r||t.setRange({start:{line:o,char:0},end:{line:o,char:n.length}}),e.focus(),Tt("Delete")}catch(r){console.error(r),alert(Faild to cut:
${JSON.stringify(r)})}},Yv=async e=>{try{let t=await navigator.clipboard.readText();if(!t)return;e.focus(),await ct(t)}catch(t){console.error(t),alert(Faild to paste:
${JSON.stringify(t)})}},Xv=e=>{e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?e.hide():(e.focus(),e.showEditPopupMenu())};globalThis.addEventListener("keydown",e=>{if(e.key!=="i"||e.shiftKey||e.altKey||e.metaKey||!e.ctrlKey||e.isComposing)return;let t=Ro();t.hasFocus||(e.preventDefault(),t.focus())});var Kf=class{get editor(){return document.getElementById("editor")}get lines(){return document.getElementsByClassName("lines")?.[0]}get computeLine(){return document.getElementById("compute-line")}get grid(){return document.getElementsByClassName("related-page-list clearfix")?.[0]?.getElementsByClassName("grid")?.[0]}get cursorLine(){return document.getElementsByClassName("cursor-line")?.[0]}get textInput(){return document.getElementById("text-input")}get cursor(){return document.getElementsByClassName("cursor")?.[0]}get selections(){return document.getElementsByClassName("selections")?.[0]}get popupMenu(){return document.getElementsByClassName("popup-menu")?.[0]}get pageMenus(){return document.getElementsByClassName("page-menu")?.[0]}get pageInfoMenu(){return document.getElementById("page-info-menu")}get pageEditMenu(){return document.getElementById("page-edit-menu")}get pageEditButtons(){return this.pageEditMenu.nextElementSibling.getElementsByTagName("a")}get randomJumpButton(){return document.getElementsByClassName("random-jump-button")?.[0]}get pageCustomButtons(){return document.getElementsByClassName("page-menu-extension")}},Jv=new Kf;var Qv=e=>new Promise(t=>setTimeout(t,e));async function Pr(e,{wait:t=1}={}){let r=Jv.textInput;r.focus(),r.value=e;let o=document.createEvent("UIEvent");o.initEvent("input",!0,!1),r.dispatchEvent(o),await Qv(t)}if(ao()){let e="Timestamp";scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/add-time.png"}),scrapbox.PageMenu(e).addItem({title:"#YYYY-MM-DD HH:mm:ss ",onClick:()=>Pr(pe(new Date,"#yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD HH:mm:ss ",onClick:()=>Pr(pe(new Date,"yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD",onClick:()=>Pr(pe(new Date,"yyyy-MM-dd"))}),scrapbox.PageMenu(e).addItem({title:"HH:mm:ss ",onClick:()=>Pr(pe(new Date,"HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"⬜",onClick:()=>Pr("⬜")}),scrapbox.PageMenu(e).addItem({title:"🚧",onClick:()=>Pr("🚧")}),scrapbox.PageMenu(e).addItem({title:"⌛",onClick:()=>Pr("⌛")}),scrapbox.PageMenu(e).addItem({title:"📝",onClick:()=>Pr("📝")}),scrapbox.PageMenu(e).addItem({title:"✅",onClick:()=>Pr("✅")}),scrapbox.PageMenu(e).addItem({title:"❌",onClick:()=>Pr("❌")})}scrapbox.PageMenu.addItem({title:"Open kakeru",image:"https://i.kakeru.app/15c3b1a40b6b3c2ebd68f33f4c86b3f6-opaque.png",onClick:()=>window.open("https://kakeru.app")});var Hi=e=>{let{fetch:t=(n,s)=>globalThis.fetch(n,s),baseURL:r="https://scrapbox.io/",...o}=e;return{fetch:t,baseURL:r,...o}};var uD=(e,t,r)=>{let{sid:o,baseURL:n,followRename:s,projects:i}=Hi(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(${n}api/pages/${e}/${ne(t)}?${a},o?{headers:{Cookie:ke(o)}}:void 0)},Yf=(e,t,r)=>Hi(r??{}).fetch(uD(e,t,r));var Xf=e=>{let t=Math.round(e/5),r=Math.floor(t/6),o=Math.floor((t-r*6)/3),n=t-r*6-o*3;return${r>20?🍅x${(e/30).toFixed(1)}:"🍅".repeat(r)}${"🍊".repeat(o)}${"🍓".repeat(n)}};var mD=()=>{let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.textAlign="right",e},Os=new Map,Dl,Jf=()=>{for(let r of Os.values())r.remove();Os.clear();let e=tl(()=>fD(At()),{interval:1e3,maxQueued:0}),t=()=>{e.clear(),e()};if(scrapbox.Layout!=="page"){if(scrapbox.removeListener("lines:changed",t),!Dl)return;clearInterval(Dl),Dl=void 0;return}t(),scrapbox.addListener("lines:changed",t),Dl=setInterval(t,60*1e3)},fD=e=>{for(let t of e){let r=xt(t.text);if(!r?.record?.start){Os.get(t.id)?.remove?.(),Os.delete(t.id);continue}let o=Os.get(t.id)??mD();Xr(t.id)?.append?.(o),Os.set(t.id,o),o.textContent=Xf(_o(r.record.end??new Date,r.record.start))}};scrapbox.Project.name==="takker-memex"&&(Jf(),scrapbox.addListener("page:changed",Jf),scrapbox.addListener("lines:changed",Jf));var dD=e=>{let[t,r]=e.reduce((o,{text:n})=>{let s=xt(n);return s?.record?.start?s.record.end?(o[1].push(s.record.end),o):(s.record.start&&o[0].push(s.record.start),o):o},[[],[]]);if(t.length===0&&t.push(...r),t.length!==0)return ff(t)},hD=async(e,t)=>{let[r,o]=await Promise.all([Yf(e,kr(t),{fetch:Zv}),Yf(e,kr(zt(t,1)),{fetch:Zv})]),n=r.ok?(await r.json()).lines:[];return o.ok&&n.push(...(await o.json()).lines),n},Zv=async(e,t)=>{let r=await wo(new Request(e,t));return!r||Si(new Date,new Date(${r.headers.get("Date")}))>=60?globalThis.fetch(e,t):r},{render:gD}=De(),eT=async()=>{let e=dD(await hD("takker-memex",new Date))??wr(new Date);gD({type:"text",text:Xf(_o(new Date,e))})};eT();setInterval(eT,60*1e3);async function tT(e,{from:t,to:r,merge:o}){if(t===r)return{success:!0,dup:!1};let n=await ar(t,e);if(O(n))return{success:!1,at:"from",name:Z(n).name,message:Z(n).message};let s=S(n);if(!s.persistent)return{success:!1,at:"from",name:"EmptyPageError",message:"The request page is empty."};let i=await ar(r,e);if(O(i))return{success:!1,at:"to",name:Z(i).name,message:Z(i).message};let a=S(n);return a.persistent&&!o?{success:!1,at:"to",name:"NoEmptyPageError",message:The same page already exists in "/${r}"}:(await Le(r,e,c=>[...c,...s.lines.slice(1)].map(l=>l.text)),await Fh(t,e),{success:!0,dup:a.persistent})}var Qf=async()=>{let e=scrapbox.Page.title,t=scrapbox.Project.name,r=globalThis.prompt(Take "/${t}/${e}" from "${t}" to:,"takker");if(!r)return;let{render:o,dispose:n}=De();o({type:"spinner"},{type:"text",text:/${t}/${e} → /${r}/${e}});try{let s=await tT(e,{from:t,to:r,merge:!0});if(!s.success){o({type:"exclamation-triangle"},{type:"text",text:${s.name} ${s.message}});return}return o({type:"check-circle"},{type:"text",text:Moved ${s.dup?"and merged ":""}to "/${r}/${e}".}),https://scrapbox.io/${r}/${ne(e)}}catch(s){o({type:"exclamation-triangle"},{type:"text",text:s instanceof Error?${s.name} ${s.message}:"Unknown error! (see developper console)"}),console.error(s)}finally{setTimeout(()=>n(),1e3)}};scrapbox.PageMenu.addItem({title:"Transport",onClick:async()=>{await Qf()}});scrapbox.PageMenu.addItem({title:"Transport and Open",onClick:async()=>{let e=await Qf();e&&window.open(e)}});var yD="button.";document.getElementById("editor").addEventListener("click",async e=>{let t=e.target;if(t.tagName==="IMG"&&t.classList.contains("icon")&&t.title.endsWith("-button")){e.preventDefault(),e.stopImmediatePropagation();try{let r=../${encodeURIComponent(t.title)}/${yD},{execute:o}=await import(r);o()}catch(r){console.log(r)}}});scrapbox.PageMenu.addItem({title:"Copy link for Markdown",onClick:()=>{let e=scrapbox.Page.title.replaceAll(" ","_").replace(/[/?#\{}^|<>]/g,t=>encodeURIComponent(t));navigator.clipboard.writeText(${scrapbox.Page.title}(https://${location.hostname}/${scrapbox.Project.name}/${e}${location.hash})).catch(t=>alert(${t.name}: ${t.message}))}});zr.PageMenu.addMenu({image:"https://img.icons8.com/ios/180/FFFFFF/inbox.png",title:"~task",onClick:()=>{let{cursor:e,selection:t}=Bt(),r=e.getPosition().line,o=t.getSelectedText(),n=o||e.lines[r].text,s=n.split(
).map(i=>i.replace(/^\s*(.+)$/g,$1~@${pe(new Date,"yyyy-MM-dd")})).join(
);o||t.setRange({start:{line:r,char:0},end:{line:r,char:n.length}}),ct(s)}});var Wi=e=>Vc(...H(()=>{let t={tasks:[],errors:[],load:async()=>{},loading:!1},r=Promise.resolve();return[o=>{t.load=()=>(r=(async()=>{await r,t={...t,loading:!0},o(),await jv(e,60),t={...t,loading:!1},o()})(),r);let n=()=>{r=(async()=>{await r,t={...t,loading:!0},o();let[s,i]=xD(await Il(e));t={...t,tasks:s,errors:i,loading:!1},o()})()};return n(),Dv(e,n)},()=>t]},e)),xD=e=>{let t=new Set,r=[],o=[];for(let{title:n,links:s,project:i}of e)for(let a of[n,...s]){let c=ae(a);if(t.has(c))continue;t.add(c);let l=pr(a);if(l){if(O(l)){o.push({project:i,title:a,...Z(l)});continue}r.push({project:i,title:a,...S(l)})}}return[r,o]};var Ul=()=>{let[e,t]=Eo(bD,{isOpen:!1,prevOverflowY:""}),r=dt(null),o=U(()=>{t(i=>{r?.current?.showModal?.();let a=r?.current?.open??!1,c=i.isOpen?i.prevOverflowY:document.documentElement.style.overflowY;return document.documentElement.style.overflowY="hidden",{isOpen:a,prevOverflowY:c}})},[]),n=U(()=>{t(i=>{r?.current?.close?.();let a=r?.current?.open??!1;return a?{isOpen:a,prevOverflowY:i.prevOverflowY}:(i.prevOverflowY?document.documentElement.style.overflowY=i.prevOverflowY:document.documentElement.style.removeProperty("overflow-y"),{isOpen:a})})},[]),s=H(()=>{let i;return a=>{if(!a){i?.(),r.current=null;return}let c=new AbortController;a.addEventListener("cancel",n,{signal:c.signal}),a.addEventListener("click",l=>{if(l.target!==l.currentTarget){l.stopPropagation();return}n()},{signal:c.signal}),i=()=>{c.abort()},r.current=a}},[n]);return{isOpen:e.isOpen,open:o,close:n,ref:s}},bD=(e,t)=>{let r=t(e);return e.isOpen===r.isOpen&&e.prevOverflowY===r.prevOverflowY?e:r.isOpen?r:{isOpen:!1}};var qi=String.raw.fa,.far{font-weight:900;font-family:"Font Awesome 5 Free";-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}.far{font-weight:400}.fa-spinner{animation:spin 2s infinite linear}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(359deg)}}.fa-spinner:before{content:"\f110"}.fa-sync:before{content:"\f021"}.fa-bookmark:before{content:"\f02e"}.fa-fw{text-align:center;width:1.25em}.kamon:before{font-family:AppIcons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;text-transform:none}.kamon-check-circle:before{content:"\e018"}.timeline-wrap{display:flex;flex-direction:column;height:100%;overflow-y:hidden;--timeline-bg: var(--dropdown-menu-bg, #fff);--timeline-text-color: var(--page-text-color, #4a4a4a);--timeline-link-color: var(--page-link-color, #5e8af7);--row-header-width: 40px;--timeline-border-color: #888;--timeline-border: solid 1px var(--timeline-border-color);--timeline-hour-height: 40px;background-color:var(--timeline-bg);color:var(--timeline-text-color);.column-header{flex:none;display:flex;flex-direction:row;.cell{flex:1 1 1px;h2{font-weight:400;margin:0;text-align:center;width:100%}}}.week-container{position:relative;height:100%;overflow-y:auto;scrollbar-width:none;.week{flex:auto;display:flex;width:100%;.borders{.border{height:var(--timeline-hour-height)}.border:after{content:attr(data-time);font-size:10px;text-align:right;border-top:var(--timeline-border);position:absolute;width:100%;margin-top:-1px;pointer-events:none}}.timeline{flex:auto;border-left:var(--timeline-border);position:relative;.indicator{position:absolute;top:calc(var(--start) * 40px - .5px);width:100%;height:1px;background-color:red}.copy{position:absolute;top:1.5em}.event{position:absolute;top:calc(var(--start) * 40px - 1px);height:calc(40px * var(--duration) / 60);outline:none;--event-bg2: var(--timeline-text-color);--event-bg: var(--timeline-bg);--event-bg-ratio: 50%;--event-color-ratio: 0%;--event-border-color-ratio: 0%;background-color:color-mix(in srgb,var(--event-bg) var(--event-bg-ratio),var(--event-bg2));color:color-mix(in srgb,var(--event-bg) var(--event-color-ratio),var(--timeline-text-color));border:var(--timeline-border);border-color:color-mix(in srgb,var(--event-bg) var(--event-border-color-ratio),var(--timeline-border-color));border-radius:4px;overflow:hidden;text-wrap:nowrap;max-width:100%;text-overflow:ellipsis}.eventdata-status=done{--event-bg-ratio: 90%;--event-color-ratio: 50%;--event-border-color-ratio: 50%}.eventdata-status=expired{font-weight:700}a.event{--event-bg2: var(--timeline-link-color);text-decoration:none}}.timeline:first-child{border-right:var(--timeline-border)}}}}.wedget{position:fixed;top:60px;left:10px;max-height:calc(90vh - 60px);max-width:100px;width:calc(100vw / 767 * 100 - 10px);min-width:60px;border:solid 1px #888;border-radius:4px;display:flex;flex-direction:column;background-color:var(--dropdown-menu-bg, #fff);color:var(--page-text-color, #4a4a4a);&:not(.open){display:none}}dialog{flex-direction:column;align-items:center;row-gap:10px;&::backdrop{background-color:#000c}padding:10px;background:unset;margin-top:unset;margin-bottom:unset;border:unset;height:unset;overflow-y:hidden;&open{display:flex}>*{color:var(--page-text-color, #4a4a4a);background-color:var(--dropdown-menu-bg, #fff);border:1px solid rgba(0,0,0,.2);border-radius:6px}}@media (min-width: 768px){dialog{padding:30px 0;--item-width: 600px}}.result{padding:15px;width:calc(var(--item-width, 100%) - 30px);overflow-y:scroll}.controller{padding:5px;width:calc(var(--item-width, 100%) - 10px);display:flex;flex-wrap:wrap;flex:none;gap:.2em}.progress{flex-grow:1;>*{padding:0 2px}}a{text-decoration:none;color:var(--page-link-color, #5e8af7);&:hover{color:var(--page-link-hover-color, #2d67f5)}}button{cursor:pointer;background:unset;color:unset;border:unset}.copy,.close,.today{font-family:"Font Awesome 5 Free"}.navi{font-family:AppIcons;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;text-transform:none}.close,.today{font-weight:900}ul{list-style-type:none;word-break:break-all}.task-list li:not(data-freshness^="-"):not(data-freshness="0"){font-weight:700}.scheduler details li{&data-status=done{opacity:.4}&data-status=expired{font-weight:700}}.task-list li{&data-type=deadline .label.type{color:var(--takker-scheduler-label-deadline-color, rgb(255, 75, 0))}&data-type=todo .label.type{color:var(--takker-scheduler-label-todo-color, rgb(246, 170, 0))}&data-type=note .label.type{color:var(--takker-scheduler-label-note-color, rgb(200, 200, 203))}&data-type=up-down .label.type{color:var(--takker-scheduler-label-up-down-color, rgb(77, 196, 255))}}:is(data-page-no=expired,data-page-no=errors) li{opacity:1!important}.scheduler{--takker-scheduler-summary-meter-width: 10em;overflow-y:hidden}.label{display:inline-block;font-size:90%;padding:0 3px}.type{text-align:center;width:2.5em;border:1px solid;border-radius:3px}.freshness{text-align:right;width:2.5em}.start,.duration{text-align:right;width:3em}
;var Ss=({text:e,title:t})=>{let[r,o]=Q(""),n=U(async s=>{s.preventDefault(),s.stopPropagation();try{await navigator.clipboard.writeText(e),o("Copied"),await Fe(1e3),o("")}catch(i){alert(Failed to copy the code block
Error:${i instanceof Error?i.message:i}),console.error(i)}},[e]);return d("button",{type:"button",className:"copy",title:t??"Copy",onClick:n,children:r})};var ED=60*60*24*1e3,rT=(e,t)=>{let r=ge(e.refDate),o=(t.getTime()-r.getTime())/ED;switch(r.setHours(0),r.setMinutes(0),e.status){case"done":return-1/0;case"deadline":return o/(e.speed??1);case"todo":return Math.min(o/(e.speed??1),0);case"note":return t.getTime()<r.getTime()?-1/0:-o/(e.speed??1);case"up-down":{let n=e.speed??30;return n*(-1+Math.cos(Math.PI*2*o/n))}}};var nT=(e,t)=>{if(t.score!==e.score)return t.score-e.score;let r=oT(e.freshness),o=oT(t.freshness);return r!==o?o-r:lr(Ar(e),Ar(t))?-1:1},oT=e=>{switch(e.status){case"todo":return 3;case"note":return 2;case"deadline":return 5;case"up-down":return 1;case"done":return 0}};var Gi=({loading:e,onClick:t})=>e?d("div",{children:d("i",{className:"fa fa-spinner"})}):d("button",{type:"button",className:"navi reload",onClick:t,children:""});var Ls=()=>{let[e,t]=Q(new Date);return te(()=>{let r=setInterval(()=>t(new Date),6e4);return()=>{clearInterval(r)}},[]),e};var sT=e=>{switch(e){case"todo":return"ToDo";case"note":return"覚書";case"deadline":return"締切";case"up-down":return"浮遊";case"done":return"完了"}};var iT=(e,t)=>new URL(/${e.project}/${ne(e.title)},t??location.href);var $l=({children:e,project:t,title:r,className:o,...n})=>d("a",{...n,className:[o??"","page-link"].join(" "),type:"link",href:iT({project:t,title:r}).pathname,...t===scrapbox.Project.name?{rel:"route"}:{rel:"noopener noreferrer",target:"_blank"},children:e});var aT=({action:e,pActions:t})=>{let r=H(()=>sT(e.freshness.status),[e.freshness.status]),o=H(()=>Cr(Ar(e)).slice(11)||" ",[Ar(e)]),n=H(()=>ci(e),[e]),s=Math.floor(Math.round(e.score)/7),i=Ls(),a=H(()=>e.executed!==void 0&&Zo(Mr(ge(e.executed.start),e.executed.duration),i),[e.executed?.start,e.executed?.duration,i]),c=H(()=>[...t,e].map(l=>${l.raw}).join(
),[t,e]);return d("li",{"data-type":e.freshness.status,"data-freshness":e.score.toFixed(0),"data-level":s,...s<0?{style:{opacity:wD(e).toFixed(2)}}:{},children:[d(Ss,{text:c,title:"ここまでコピー"}),d("span",{className:"label type",children:r}),d("i",{className:label far fa-fw${a?" fa-bookmark":""}}),d("span",{className:"label freshness",children:e.score.toFixed(0)}),d("time",{className:"label start",children:o}),d("span",{className:"label duration",children:[n,"m"]}),d($l,{project:e.project,title:e.raw,children:e.name})]})},wD=e=>Math.max(.8*Math.exp(Math.log(8/7)/7*e.score),.05);var cT=(e=Wt(new Date))=>{let[t,r]=Q(e),o=U(()=>{r(s=>{switch(s){case"errors":return"expired";case"expired":return Wt(new Date);default:{let i=ge(ji(s));return i.setDate(i.getDate()+1),Wt(i)}}})},[]),n=U(()=>{r(s=>{let i=Wt(new Date);switch(s){case"errors":return"errors";case"expired":return"errors";case i:return"expired";default:{let a=ge(ji(s));return a.setDate(a.getDate()-1),Wt(a)}}})},[]);return{pageNo:t,next:o,prev:n}};var jl=(e,t)=>te(()=>(scrapbox.on(e,t),()=>scrapbox.off(e,t)),[]);var zi=(e,t)=>{let r=dt({...t});te(()=>(Object.assign(r.current,t),()=>{for(let o of Object.keys(t))delete r.current[o]}),[...Object.keys(t)].sort().map(o=>t[o])),te(()=>{e(r.current)},[e])};var lT=e=>{let t=document.createElement("div");t.dataset.userscriptName="takker-workflow@0.0.1/next-action-viewer";let r=t.attachShadow({mode:"open"});return document.body.append(t),new Promise(o=>vt(d(RD,{getController:o,projects:e}),r))},RD=({getController:e,projects:t})=>{let{tasks:r,errors:o,load:n,loading:s}=Wi(t),{pageNo:i,next:a,prev:c}=cT(),l=H(()=>{if(i==="errors")return o.map(g=>({name:${g.title}
name:${g.name}
message:${g.message},raw:g.title,freshness:{refDate:{year:9999,month:1,date:1},status:"todo"},project:g.project,generated:!0,score:0}));if(i==="expired"){let g=new Date;return r.flatMap(y=>!Ir(y)&&lr(Uy(y),Ht(g))&&y.freshness===void 0&&y.recurrence===void 0?[{...y,score:0,freshness:{refDate:y.executed.start,status:"todo"}}]:[]).sort((y,x)=>lr(Ar(y),Ar(x))?-1:0)}let h=ge(ji(i));return r.flatMap(g=>{if(!g.freshness)return[];if(Oo(g))return[];let y=rT(g.freshness,h);return y>-999?[{...g,score:y}]:[]}).sort(nT)},[r,o,i]),{ref:u,open:p,close:f}=Ul();zi(e,{open:p,close:f});let m=H(()=>[i,...l.map(h=> ${h.raw})].join(
),[l,i]);return jl("page:changed",f),d(ee,{children:[d("style",{children:qi}),d("dialog",{ref:u,children:[d("div",{className:"controller",children:[d(Ss,{text:m,title:"Copy All Tasks"}),d("span",{children:i}),d("button",{type:"button",className:"navi left",onClick:c,children:""}),d("button",{type:"button",className:"navi right",onClick:a,children:""}),d(Gi,{loading:s,onClick:n}),d("button",{type:"button",className:"close",onClick:f,children:""})]}),d("ul",{className:"result task-list","data-page-no":i,children:l.map((h,g)=>d(aT,{action:h,pActions:l.slice(0,g)},h.raw))})]})]})};var Hl=(e,t)=>/${e}/${ae(t)},Vi=new Map,Zf=new Map,pT=(e,t)=>{Vi.set(e,t);for(let r of Zf.get(e)??[])r(t)},Bl=()=>{Sn!==void 0&&(clearInterval(Sn),Sn=void 0);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Hl(e,t);if(!Vi.has(r))return;let o=At().map(n=>n.text);Sn=setInterval(()=>{ae(t)===ae(o[0])&&(pT(r,o),Sn!==void 0&&(clearInterval(Sn),Sn=void 0))},1e3)},Sn;scrapbox.on("page:changed",()=>{scrapbox.off("lines:changed",Bl);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Hl(e,t);Vi.has(r)&&scrapbox.on("lines:changed",Bl)});var kD=(e,t)=>{let r=Hl(e,t),o=Vi.get(r);return o||(Vi.set(r,[]),ar(e,t).then(n=>{if(O(n))return[];let s=S(n).lines.map(i=>i.text);pT(r,s),t===scrapbox.Page.title&&!scrapbox.listeners("lines:changed").includes(Bl)&&scrapbox.on("lines:changed",Bl)})),o??[]},uT=(e,t)=>{let[r,o]=Q(kD(e,t));return te(()=>{let n=Hl(e,t),s=Zf.get(n)??new Set;return s.add(o),Zf.set(n,s),()=>{s.delete(o)}},[e,t]),r};var ed=e=>e.duration===void 0?void 0:Ht(Mr(ge(e.start),e.duration)),td=(e,t)=>{let r=ge(e.start),o=t.getTime(),n=Math.round((o-r.getTime())/(60*1e3));if(n<=0)return[void 0,e];if(e.duration<=n)return[e,void 0];let s={start:e.start,duration:n};return[s,{start:ed(s),duration:e.duration-n}]};var Ln=e=>"title"in e,vD=e=>e.record?.duration!==void 0,mT=(e,t)=>Ln(e)&&e.status==="done"?e.status:vD(e)?Ln(e)&&e.executed?lr(Ht(t),e.executed.start)?"moved":"expired":"done":lr(ed(e.plan),Ht(t))?Ln(e)?"expired":"done":"undone";var fT=(e,t)=>{let r=pr(e.title.slice(1,-1));if(!e.plan.start)return;let o={name:r&&K(r)?S(r).name:e.title,plan:{start:Ht(e.plan.start),duration:(e.plan.duration??0)/60}};if(e.record.start&&(o.record={start:Ht(e.record.start)},e.record.end&&(o.record.duration=_o(e.record.end,e.record.start))),!r||O(r))return o;let n=S(r),s={...o,title:n.raw,project:t};return n.freshness&&(s.status=n.freshness.status),Ir(n)||(s.executed=n.executed),s},rd=(e,t)=>{let r=rc(e);return r!==void 0?{name:e.name,project:t,title:r,executed:e.executed,plan:e.executed,status:e.freshness?.status}:{name:e.name,plan:e.executed}};var dT=(e,t,r)=>{let o=[od(e,zt(t,1),r),od(e,t,r),od(e,Te(t,1),r)],n=H(()=>o.flat(),o);return H(()=>{let s=wr(t),i=Ja(t);return n.flatMap(a=>{let[,c]=td(a.plan,s);if(!c)return[];let[l]=td(c,i);if(!l)return[];let{plan:u,...p}=a;return[{plan:l,...p}]}).sort((a,c)=>lr(a.plan.start,c.plan.start)?-1:0)},[n,t])},od=(e,t,r)=>{let o=uT(e,kr(t)),n=H(()=>_D(o,e),[o,e]);return H(()=>n.length!==0?n:TD(t,r),[n,t,r])},TD=(e,t)=>t.flatMap(r=>{if(r.freshness?.status==="done")return[];if(Ir(r))return[];if(Oo(r)){let n=tc(r,e);return n?[rd(n,r.project)]:[]}let o=ge(r.executed.start);return yt(o,e)?[rd(r,r.project)]:[]}),_D=(e,t)=>{let r=[];for(let o of en(e)){if(Po(o))continue;let n=fT(o,t);n&&r.push(n)}return r};var hT=({event:e})=>{let t=H(()=>e.plan.start.hours+e.plan.start.minutes/60,[e.plan.start]),r=H(()=>--start: ${t}; --duration: ${e.plan.duration};,[t,e.plan.duration]),o=Ls(),n=H(()=>mT(e,o),[e,o]);return Ln(e)?d($l,{className:"event","data-status":n,style:r,title:e.title,project:e.project,children:e.name}):d("div",{className:"event","data-status":n,title:e.name,style:r,children:e.name})};var gT=({project:e,date:t,tasks:r})=>{let o=dT(e,t,r),n=H(()=>o.flatMap(a=>Ln(a)?[${a.title}]:[]).join(
),[o]),s=Ls(),i=H(()=>yt(s,t)&&d("div",{className:"indicator",style:--start: ${vy(s)+ky(s)/60}}),[s,t]);return d("div",{className:"timeline",role:"gridcell",children:[o.map(a=>d(hT,{event:a},a.name)),i,d(Ss,{text:n})]})};var nd=({dateList:e,tasks:t,project:r,hasColumn:o})=>d("div",{className:"timeline-wrap",role:"grid",children:[(o??!0)&&d("div",{className:"column-header",role:"row",children:e.map(n=>d("div",{className:"cell",role:"columnheader",children:d("h2",{children:Zs(n)})},Wt(n)))}),d("div",{className:"week-container",role:"presentation",children:d("div",{className:"week",role:"presentation",children:[d("div",{className:"borders",children:[...Array(24).keys()].map(n=>d("div",{className:"border","data-time":${vr(n)}:00},n))}),e.map(n=>d(gT,{project:r,date:n,tasks:t},Wt(n)))]})})]});var sd=(e,t,r)=>{let[o,n]=Q(e),s=U(()=>n(t),[t]),i=U(()=>n(r),[t]),a=U(c=>n(c),[]);return{pageNo:o,next:s,prev:i,jump:a}};var yT=e=>{let t=dt(new Set),[r,o]=Q(e),n=U(()=>{for(let l of t.current)l()},[]),s=U(()=>{o(!0),n()},[]),i=U(()=>o(!1),[]),a=U(()=>o(l=>(l||n(),!l)),[]),c=U(l=>(t.current.add(l),()=>t.current.delete(l)),[]);return{isOpen:r,open:s,close:i,toggle:a,onOpen:c}};var ET=e=>{let t=document.createElement("div");t.dataset.userscriptName="takker-scheduler/weekly-scheduler";let r=t.attachShadow({mode:"open"});return document.body.append(t),new Promise(o=>vt(d(PD,{getController:o,projects:e,mainProject:e[0]}),r))},wT=(e,t)=>{let r=document.createElement("div");r.dataset.userscriptName="takker-scheduler/timeline-wedget";let o=r.attachShadow({mode:"open"});return document.body.append(r),new Promise(n=>vt(d(OD,{getController:n,projects:e,mainProject:e[0],open:t}),o))},xT=!1,PD=({getController:e,projects:t,mainProject:r})=>{let{tasks:o,load:n,loading:s}=Wi(t),{pageNo:i,next:a,prev:c,jump:l}=sd(Bi(new Date),SD,LD),u=H(()=>{let y=Al(i);return[0,1,2,3,4,5,6].map(x=>Te(y,x))},[i]),{ref:p,open:f,close:m,isOpen:h}=Ul();xT||=h,zi(e,{open:f,close:m,isOpen:h}),jl("page:changed",m);let g=U(()=>l(Bi(new Date)),[l]);return d(ee,{children:[d("style",{children:qi}),d("dialog",{ref:p,children:[d("div",{className:"controller",children:[d("span",{children:i}),d("button",{type:"button",className:"navi left",onClick:c,children:""}),d("button",{type:"button",className:"navi right",onClick:a,children:""}),d("button",{type:"button",className:"today",onClick:g,children:""}),d(Gi,{loading:s,onClick:n}),d("button",{type:"button",className:"close",onClick:m,children:""})]}),xT&&d("div",{ref:RT,className:"result scheduler","data-page-no":i,children:d(nd,{dateList:u,tasks:o,project:r})})]})]})},bT=!1,OD=({projects:e,mainProject:t,getController:r,open:o})=>{let{tasks:n,load:s,loading:i}=Wi(e),{pageNo:a,next:c,prev:l,jump:u}=sd(new Date,ND,MD),p=H(()=>[a],[a]),f=U(()=>u(new Date),[u]),{isOpen:m,open:h,close:g}=yT(o);return bT||=m,zi(r,{open:h,close:g,isOpen:m}),d(ee,{children:[d("style",{children:qi}),bT&&d("div",{className:wedget${m?" open":""},ref:RT,children:[d("div",{className:"controller",children:[d("span",{children:Wt(a)}),d("button",{type:"button",className:"navi left",onClick:l,children:""}),d("button",{type:"button",className:"navi right",onClick:c,children:""}),d("button",{type:"button",className:"today",onClick:f,children:""}),d(Gi,{loading:i,onClick:s})]}),d(nd,{dateList:p,tasks:n,project:t,hasColumn:!1})]})]})},SD=e=>Bi(Ko(Al(e),1)),LD=e=>Bi(Ty(Al(e),1)),ND=e=>Te(e,1),MD=e=>zt(e,1),RT=e=>{let t=e?.getElementsByClassName?.("indicator")?.[0];if(!t)return;let r=globalThis.scrollY;t.scrollIntoView({block:"center"}),globalThis.scroll(0,r)};Jh({project:"takker-dist"});ka(!0);eg({maxCount:10,accessToken:CD,onClick:async(e,t)=>{try{if(t.ctrlKey){await navigator.clipboard.writeText(e.permalink_url);return}let r=document.getElementById("text-input");if(!r)throw Error("#text-input is not ditected.");r.focus(),r.value=e.permalink_url;let o=new InputEvent("input",{bubbles:!0});r.dispatchEvent(o),await scrapbox.Page.waitForSave()}catch(r){alert(${r}),console.error(r)}}});ny().then(e=>{scrapbox.PageMenu.addItem({title:"Fulltext Search",onClick:()=>{e.toggle()}})});var ID="https://scrapbox.io/files/67344295032adf96d1e4c276.wasm",AD="/api/code/takker-dist/for-any-project-min/esbuild-worker.js";(async()=>{let e=new Request(ID),t=await wo(e);t||(t=await fetch(e),await Wa(e,t)),await UE(await WebAssembly.compileStreaming(t),AD)})();(async()=>{let e=[scrapbox.Project.name,"takker","takker-memex","takker-books","takker-private","villagepump","hub","arpla","work4ai","unnamedcamp","unnamed-project","nishio","enchi","rashitamemo","motoso","shokai","masui","rakusai","yuiseki","akiroom","c4j","miyamonz","mrsekut-p","masuilab","kidaaam-92022284","nwtgck","juneboku","marshmallow-rm","sushitecture","sno2wman","inteltank","issac-37765679","blu3mo","yosider","Mijinko","Mijinko-other","scrapbox-drinkup","nota-techconf","customize","scrapboxlab","scrasobox","programming-notes","tus-alpine","tus-alpine-private","guiland","evergreens","fab-wiki"],t=await Pw({projects:e,mark:{...Object.fromEntries([["takker","takker"],["takker-memex","takker"],["takker-books","takker-books"],["takker-private","takker-private"],["nishio","nishio"],["rashitamemo","rashita"],["enchi","雑談_2022-04-12~"],["rakusai","rakusai"],["masui","概要"],["shokai","shokai"],["yuiseki","yuiseki"],["akiroom","はじめに"],["inteltank","sawachin"],["motoso","もとそのもと"],["villagepump","井戸端"],["hub","scrapbox.io%2Fhub_について"],["masuilab","増井研に入ったらまずやること"],["marshmallow-rm","読書猿マシュマロ全質問回答"],["miyamonz","miyamonz"],["mrsekut-p","mrsekut"],["kidaaam-92022284","kidooom"],["c4j","Code_for_Japan"],["suto3","suto3"],["blu3mo","blu3mo"],["nwtgck","nwtgck"],["juneboku","juneboku"],["jigsaw","jgs"],["sno2wman","SnO2WMaN"],["sushitecture","hashrock"],["unnamedcamp","知を営む"],["unnamed-project","unnamed-project"],["issac-37765679","cFQ2f7LRuLYP"],["blu3mo","blu3mo"],["yosider","yosider"],["Mijinko","Mijinko_SD"],["Mijinko-other","Mijinko_SD"],["customize","みんなのカスタマイズ"],["scrapboxlab","入会手続き"],["scrasobox","Scrapboxとあそぶ"],["programming-notes","参加する"],["guiland","概要と参加方法"],["work4ai","work4ai"],["evergreens","HOME"],["fab-wiki","fab-wikiに参加する"]].map(([n,s])=>[n,https://scrapbox.io/api/pages/${n}/${s}/icon])),"NDLSH-SB":"📚","scrapbox-drinkup":"https://scrapbox.io/assets/img/page-icon/scrapbox_beaver.png","nota-techconf":"https://i.gyazo.com/727f42bbd9e2534d99d70e6ea90705b3.jpg","plurality-japanese":"⿻"},workerUrl:"/api/code/takker-dist/for-any-project-min/select-suggestion-worker.js",enableSelfProjectOnStart:!0}),r=n=>{n.preventDefault(),n.stopPropagation()},o=()=>document.querySelector(".line .popup-menu")!==null;zu.bind({"<Tab>":n=>{o()||t.selectNext?.({cyclic:!0})&&r(n)},"<S-Tab>":n=>{o()||t.selectPrev?.({cyclic:!0})&&r(n)},"<Enter>":n=>{o()||t.confirm?.()&&r(n)},"<Esc>":n=>{o()||t.cancel?.()&&r(n)}})})();Nw({previewers:[{when:/(?:^|\.)svg$/,preview:Mw},{when:/(?:^|\.)glsl$/,preview:Vw},{when:/(?:^|\.)(?:plantuml|puml|pu)$/,preview:Xw},{when:/(?:^|\.)tikz\(tex\)$/,preview:Qw("/api/code/takker-dist/for-any-project-min/tex-worker.js","https://scrapbox.io/files/65d1645c19cd8e002433c3df")}]});(async()=>{let{toggle:e}=await hR();scrapbox.PageMenu.addItem({title:"履歴スライダー",image:"https://1.bp.blogspot.com/-UZtkSEX0wh4/U5l5_dNcEsI/AAAAAAAAhWs/UzJGVzyiX8Y/s800/kaichu_dokei.png",onClick:e})})();uv("takker",["takker","振り返り(takker-workflow@0.0.1)のtemplate","txt"],["takker","1週間の振り返り(takker-workflow@0.0.1)のtemplate","txt"],new Date(2024,11,24));ao()&&(gr({display:{type:"caret-left"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?$a():Aa()}}),gr({display:{type:"caret-right"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Ua():Ia()}}),gr({display:{type:"caret-up"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?ja():Fa()}}),gr({display:{type:"caret-down"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Ba():Da()}}),gr({display:{type:"copy"},onClick:async({cursor:e,selection:t})=>await Vv(e,t)}),gr({display:{type:"cut"},onClick:async({cursor:e,selection:t})=>await Kv(e,t)}),gr({display:{type:"clipboard"},onClick:async({cursor:e})=>await Yv(e)}),gr({display:{type:"undo"},onClick:()=>zg()}),gr({display:{type:"redo"},onClick:()=>Vg()}),gr({display:({cursor:e})=>e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?{type:["i-cursor","slash"]}:{type:"i-cursor"},onClick:({cursor:e})=>Xv(e)}));if(ao()&&scrapbox.Project.name!=="takker-memex"){let e="task";scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/todo-list--v2.png"}),scrapbox.PageMenu(e).addItem({title:"Book starting",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:on}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>sn({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"})})}if(ao()){let e="New Page",t=[ln,pn,un];scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/cut-paper.png"}),scrapbox.PageMenu(e).addItem({title:"New Page",onClick:()=>{let r=window.prompt("Create a new page at",scrapbox.Project.name);r&&Jr({project:r,mode:"noopen",hooks:t})?.()}}),scrapbox.PageMenu(e).addItem({title:"New Page and Open",onClick:()=>{let r=window.prompt("Create a new page at",scrapbox.Project.name);r&&Jr({project:r,mode:"self",hooks:t})?.()}})}(async()=>{let e="next-action",t=head styledata-userscript-name="${e}";document.querySelector(t)?.remove?.();let r=document.createElement("style");r.dataset.userscriptName=e,r.textContent=
button:is(#${e}, #scheduler).tool-btn::before {
position: absolute;
font: 900 20px/46px "Font Awesome 5 Free";
}
button#${e}.tool-btn::before {
content: "\\f0ae";
}
button#scheduler.tool-btn::before {
content: "\\f073";
font-weight: 400;
}
button:is(#${e}, #scheduler).tool-btn img {
opacity: 0;
},document.head.append(r);let o=["takker-memex","takker"],{open:n}=await lT(o);scrapbox.PageMenu.addMenu({title:e,image:"/assets/img/favicon/apple-touch-icon.png",onClick:n});let s=await ET(o);scrapbox.PageMenu.addMenu({title:"scheduler",image:"/assets/img/favicon/apple-touch-icon.png",onClick:s.open});{let i="takker-scheduler/wedget",a=JSON.parse(localStorage.getItem(i)??"{}"),c=scrapbox.Project.name;a[c]??=!1;let l=await wT(o,a[c]),u=()=>{a[c]=!l.isOpen,l.isOpen?l.close():l.open?.(),localStorage.setItem(i,JSON.stringify(a))};ao()?gr({display:{type:"calendar"},onClick:u}):scrapbox.PageMenu.addItem({title:"toggle wedget",onClick:u})}})();var kT=e=>String(e).padStart(2,"0"),vT=e=>${e.getFullYear()}-${kT(e.getMonth()+1)}-${kT(e.getDate())};for(let e of document.getElementsByClassName("new-button")){let t=#${vT(new Date)};e.href=/${scrapbox.Project.name}/new?body=${encodeURIComponent(`
+t)}}console.log('The hrefs of "New Button" have been changed.');scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=es.parse(e,{hasTitle:!1});if(console.log("Parserd text:"),console.log(t),navigator.clipboard){let r=FD(t).join(`
);console.log(r),navigator.clipboard.writeText(r).catch(o=>console.log(o)),console.log("Copied.")}}});function FD(e){let t=Math.min(...e.map(n=>n.indent)),r=t,o=["<p>"];for(let n of e.filter(s=>s.type==="line")){let s=n.indent-r;s<0&&o.push(...[...Array(-s)].map(a=>"</ul>")),s>0&&o.push(...[...Array(s)].map(a=>'<ul style="margin-top: 5px;margin-bottom: 5px;">'));let i=n.nodes.map(a=>Wl(a)).join("");n.indent>t?o.push(<li>${i}</li>):o.push(${i}<br/>),r=n.indent}return o.push(...[...Array(r-t)].map(n=>"</ul>")),o.push("</p>"),o}function Wl(e){switch(e.type){case"quote":return<span style="
font-style: italic;
background-color: rgba(128,128,128,0.1);
display: block;
border-left: solid 4px #a0a0a0;
padding-left: 4px;">${e.nodes.map(s=>Wl(s)).join("")}</span>;case"image":case"strongImage":return<img src="${e.src}" style="max-width: 50vw;"/>;case"icon":let t="",r="",o="";switch(e.pathType){case"root":r=https://scrapbox.io${e.path},t=https://scrapbox.io/api/pages/${e.path}/icon,o=e.path.replace(/^\/[^\/]+\/(.*)/,"$1");break;case"relative":r=https://scrapbox.io/${scrapbox.Project.name}/${e.path},t=https://scrapbox.io/api/pages/${scrapbox.Project.name}/${e.path}/icon,o=e.path;break}return<a target="_blank" href="${r}"><img style="
height: 1.3em;
vertical-align: top;" src="${t}" alt="${o}" /></a>;case"strongIcon":return"";case"formula":return\\( ${e.formula} \\);case"helpfeel":return"";case"decoration":let n=e.nodes.map(s=>Wl(s)).join("");return e.decos.includes("*-4")&&(n=<h4>${n}</h4>),e.decos.includes("*-3")&&(n=<h5>${n}</h5>),e.decos.includes("*-2")&&(n=<h6>${n}</h6>),e.decos.includes("*-1")&&(n=<strong>${n}</strong>),e.decos.includes("/")&&(n=<i>${n}</i>),e.decos.includes("-")&&(n=<strike>${n}</strike>),e.decos.includes("!")&&(n=<pre>${n}</pre>),n;case"strong":return<strong>${e.nodes.map(s=>Wl(s)).join("")}</strong>;case"code":return<code>${e.text}</code>;case"commandLine":case"googleMap":return"";case"blank":return<span>${e.text}</span>;case"link":switch(e.pathType){case"root":return<a target="_blank" href="https://scrapbox.io${e.href}">${e.href}</a>;case"relative":return<a target="_blank" href="https://scrapbox.io/${scrapbox.Project.name}/${e.href}">${e.href}</a>;case"absolute":return<a target="_blank" href="${e.href}">${e.content||e.href}</a>}case"hashTag":return<a href="https://scrapbox.io/${scrapbox.Project.name}/${e.href}">#${e.href}</a>;case"plain":return<span>${e.text}</span>}}scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=window.open();t.document.write(<html>
<body>
<textarea spellcheck="true">${e}</textarea>
</body>
</html>),t.document.close()}});scrapbox.PopupMenu.addButton({title:e=>{let t=e.replace(/[\r\n]/g,"").length,r=e.trim().split(/[\r\n\s]+/).length;return${t}c ${r}w},onClick:()=>null});if(ao()){let e="task";scrapbox.PageMenu.addMenu({title:e,image:"https://img.icons8.com/ios/180/FFFFFF/todo-list--v2.png"}),scrapbox.PageMenu.addMenu({title:"Toggle task",image:"https://img.icons8.com/ios/180/FFFFFF/repeat.png",onClick:Uu}),scrapbox.PageMenu(e).addItem({title:"Add task",image:"https://img.icons8.com/ios/180/FFFFFF/plus-math.png",onClick:ti}),scrapbox.PageMenu(e).addItem({title:"Start task",image:"https://img.icons8.com/ios/180/FFFFFF/start--v1.png",onClick:tn}),scrapbox.PageMenu(e).addItem({title:"End task",image:"https://img.icons8.com/ios/180/FFFFFF/stop-squared.png",onClick:eo}),scrapbox.PageMenu(e).addItem({title:"Posteriori end task",image:"https://img.icons8.com/ios/180/FFFFFF/end--v1.png",onClick:ri}),scrapbox.PageMenu(e).addItem({title:"Book starting",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:async()=>{let[t,r]=DD(),o=Lr().slice(t,r+1).map(n=>{let s=n.text,i=n.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=pr(i);if(!a||!a.ok)return s;let c=a.value;if(c.freshness?.status==="done")return s;let l=cn(c);return l.title=${i},l?be(l):s}).join(
);await Ca(t,r,o),await on()}}),scrapbox.PageMenu(e).addItem({title:"Walk a day",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:()=>oi()}),scrapbox.PageMenu(e).addItem({title:"Move today",image:"https://img.icons8.com/ios/180/FFFFFF/date-to.png",onClick:()=>ni()}),scrapbox.PageMenu(e).addItem({title:"Format",image:"https://img.icons8.com/ios/180/FFFFFF/sort-by-start-date.png",onClick:()=>ii(scrapbox.Project.name,scrapbox.Page.title)}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>sn({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"})}),scrapbox.PageMenu(e).addItem({title:"Sync",onClick:()=>window.open("https://script.google.com/macros/s/AKfycbyAgN8nmUXjVXL_tahDzVyyrMzFaI4CJVmIapk8G0GuxxVN-7oUbuDJOf31fP7SFjx9/exec")})}var DD=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:o}=He();return r===""?[o.line,o.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var TT="scrapbox-episopass",ql=!1;scrapbox.PopupMenu.addButton({title:e=>ql?"remove EP":/https:\/\/scrapbox\.io\/files\/\w+\.html/.test(e)?"run EP":"",onClick:async e=>{if(document.getElementById(TT)?.remove(),ql){ql=!1;return}if(!/https:\/\/scrapbox\.io\/files\/\w+\.html/.test(e))return;let t=e.match(/https:\/\/scrapbox\.io(\/files\/\w+\.html)/)[1];try{let o=await(await fetch(t)).text();if(!o.includes("<title>EpisoPass</title>"))return;let n=new Blob([o],{type:"text/html"}),s=URL.createObjectURL(n);document.getElementsByClassName("cursor-line")[0].insertAdjacentHTML("beforeend",<iframe id="${TT}" src="${s}" width="800" height="400"></iframe>`),ql=!0;return}catch(r){console.error("Failed to load an EpisoPass html: ",r)}}});export{gr as addButton,ct as insertText,zu as scrapBindings};
/** @license
* esbuild-wasm@v0.24.0
*
* MIT License
*
* Copyright (c) 2020 Evan Wallace
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*! Bundled license information:
comlink/dist/esm/comlink.mjs:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*)
*/
code:tex-worker.js
var ht=Object.defineProperty;var Ge=(t,e)=>{for(var r in e)ht(t,r,{get:er,enumerable:!0})};var be={};Ge(be,{close:()=>Et,deleteEverything:()=>ue,eof:()=>Rt,eoln:()=>$t,erstat:()=>Lt,executeAsync:()=>xe,get:()=>At,inputln:()=>Mt,pages:()=>C,printBoolean:()=>Pt,printChar:()=>Ut,printFloat:()=>St,printInteger:()=>vt,printNewline:()=>kt,printString:()=>Tt,put:()=>Nt,readFileSync:()=>se,reset:()=>Ft,rewrite:()=>Ct,setConsole:()=>de,setFileLoader:()=>ge,setInput:()=>he,setMemory:()=>me,tex_final_end:()=>ye,writeFileSync:()=>fe});var X={},m=[],re,O="",P=null,G=null,N=null,F=null,W=null,He=null,H=null,C=1100,z=(C-100)*1024*64,gt=C*1024*64,oe=0,I=!1,xt=()=>{W&&(Wz>>2=z+8,Wz+4>>2=gt),F.asyncify_start_unwind(z),oe=oe+1},yt=()=>{F.asyncify_start_rewind(z),F.main()},bt=()=>{oe=oe-1,F.asyncify_stop_rewind()},ue=()=>{m=[],X={},P=null,G=null,N=null,re=void 0,H=null,F=null,W=null,I=!1},fe=(t,e)=>{Xt=e},se=t=>{for(let e of m)if(e.filename==t)return e.content.slice(0,e.position);throw Error(Could not find file ${t})},Be=(t,e)=>{let r=I;I&&(bt(),I=!1);let n=new Uint8Array;if(Xt)n=Xt;else if(e=="r"&&m.findIndex(s=>s.filename==t&&!s.erstat)==-1)return r||t.match(/\.(aux|log|dvi)$/)?(m.push({filename:t,erstat:1}),m.length-1):(xt(),I=!0,setTimeout(async()=>{try{let s=await He(t);Xt=s}catch{}yt()},0),-1);return m.push({filename:t,position:0,position2:0,erstat:0,eoln:!1,content:n,descriptor:m.length}),m.length-1},wt=()=>{},$=(t,e,r,n)=>{for(r===void 0&&(r=0),n===void 0&&(n=e.length-r);n>t.content.length-t.position;){let o=new Uint8Array(1+t.content.length*2);o.set(t.content),t.content=o}t.content.subarray(t.position).set(e.subarray(r,r+n)),t.position+=n},_t=(t,e,r,n,o)=>(r===void 0&&(r=0),n===void 0&&(n=e.length-r),n>t.content.length-o&&(n=t.content.length-o),e.subarray(r).set(t.content.subarray(o,o+n)),n),M=t=>{if(re&&(O+=t,O.indexOf(`
)>=0)){let e=O.split(
);O=e.pop();for(let r of e)r.length&&re(r)}},de=t=>{re=t},me=t=>{P=t,W=new Int32Array(t)},he=(t,e)=>{G=t,e&&(N=e)},ge=t=>{He=t},xe=t=>(F=t,H=Promise.withResolvers(),F.main(),F.asyncify_stop_unwind(),H.promise),Tt=(t,e)=>{let r=t<0?{stdout:!0}:m[t],n=new Uint8Array(P,e,1)[0],o=new Uint8Array(P,e+1,n),s=String.fromCharCode.apply(null,o);if(r.stdout){M(s);return}$(r,new TextEncoder().encode(s))},Pt=(t,e)=>{let r=t<0?{stdout:!0}:m[t],n=e?"TRUE":"FALSE";if(r.stdout){M(n);return}$(r,new TextEncoder().encode(n))},Ut=(t,e)=>{let r=t<0?{stdout:!0}:m[t];if(r.stdout){M(String.fromCharCode(e));return}let n=new Uint8Array(1);n[0]=e,$(r,n)},vt=(t,e)=>{let r=t<0?{stdout:!0}:m[t];if(r.stdout){M(e.toString());return}$(r,new TextEncoder().encode(${e}))},St=(t,e)=>{let r=t<0?{stdout:!0}:m[t];if(r.stdout){M(e.toString());return}$(r,new TextEncoder().encode(${e}))},kt=(t,e)=>{let r=t<0?{stdout:!0}:m[t];if(r.stdout){M(
);return}$(r,new TextEncoder().encode(
))},Ft=(t,e)=>{let r=new Uint8Array(P,e,t),n=String.fromCharCode.apply(null,r);return n=n.replace(/\000+$/g,""),n.startsWith("{")&&(n=n.replace(/^{/g,""),n=n.replace(/}.*/g,"")),n.startsWith('"')&&(n=n.replace(/^"/g,""),n=n.replace(/".*/g,"")),n=n.replace(/ +$/g,""),n=n.replace(/^\*/,""),n=n.replace(/^TeXfonts:/,""),n=="TeXformats:TEX.POOL"&&(n="tex.pool"),n=="TTY:"?(m.push({filename:"stdin",stdin:!0,position:0,position2:0,erstat:0,eoln:!1,content:new TextEncoder().encode(G)}),m.length-1):Be(n,"r")},Ct=(t,e)=>{let r=new Uint8Array(P,e,t),n=String.fromCharCode.apply(null,r);return n=n.replace(/ +$/g,""),n.startsWith('"')&&(n=n.replace(/^"/g,""),n=n.replace(/".*/g,"")),n=="TTY:"?(m.push({filename:"stdout",stdout:!0,erstat:0}),m.length-1):Be(n,"w")},Et=t=>{let e=m[t];e.descriptor&&wt(e.descriptor)},Rt=t=>m[t].eof?1:0,Lt=t=>m[t].erstat,$t=t=>m[t].eoln?1:0,Mt=(t,e,r,n,o,s,a)=>{let i=m[t],c=new Uint8Array(P,r,a),d=new Uint32Array(P,n,4),l=new Uint32Array(P,o,4);l[0]=d[0],e&&!i.eof&&i.eoln&&(i.position2=i.position2+1);let h=i.content.indexOf(10,i.position2);if(h<0&&(h=i.content.length),i.position2>=i.content.length)return i.stdin&&(N&&N(),ye()),i.eof=!0,!1;for(c.subarray(d[0]).set(i.content.subarray(i.position2,h)),l[0]=d[0]+h-i.position2;c[l[0]-1]==32;)l[0]=l[0]-1;return i.position2=h,i.eoln=!0,!0},At=(t,e,r)=>{let n=m[t],o=new Uint8Array(P);if(n.stdin)n.position>=G.length?(o[e]=13,n.eof=!0,N&&N(),ye()):o[e]=G[n.position].charCodeAt(0);else if(n.descriptor){if(_t(n,o,e,r,n.position)==0){o[e]=0,n.eof=!0,n.eoln=!0;return}}else{n.eof=!0,n.eoln=!0;return}n.eoln=!1,o[e]==10&&(n.eoln=!0),o[e]==13&&(n.eoln=!0),n.position=n.position+r},Nt=(t,e,r)=>{let n=m[t],o=new Uint8Array(P);$(n,o,e,r)},ye=()=>{O.length&&M(
),H&&H.resolve()};var we={};Ge(we,{getCurrentDay:()=>Ot,getCurrentMinutes:()=>Dt,getCurrentMonth:()=>zt,getCurrentYear:()=>It});var Dt=()=>{let t=new Date;return 60*t.getHours()+t.getMinutes()},Ot=()=>new Date().getDate(),zt=()=>new Date().getMonth()+1,It=()=>new Date().getFullYear();var Ve,Ye,Ze=async(t,e)=>{Ye??=await e.fileLoader("tex.wasm"),Ve??=new Uint8Array(await e.fileLoader("core.dump"),0,C*65536),fe("input.tex",new TextEncoder().encode(t));let r=new WebAssembly.Memory({initial:C,maximum:C});new Uint8Array(r.buffer,0,C*65536).set(Ve.slice(0)),me(r.buffer),he( input.tex
\\end
),ge(e.fileLoader),e.console&&de(e.console);let o=await WebAssembly.instantiate(Ye,{library:{...be,...we},env:{memory:r}});await xe(o.instance.exports);let s=se("input.log");try{return{dvi:se("input.dvi"),log:s}}catch{return{log:s}}finally{ue()}};async function*qe(t){let e=await new Response(t).arrayBuffer(),r=new DataView(e),n=e.byteLength-4;for(;r.getUint32(n,!0)!==101010256;)n--;let o=n;o+=4,o+=4;let s=r.getUint16(o,!0);o+=2,o+=2,o+=4;let a=r.getUint32(o,!0);o+=4,o=a;for(let i=0;i<s;i++){o+=4,o+=4,o+=4,o+=4,o+=4;let c=r.getUint32(o,!0);o+=4;let d=r.getUint32(o,!0);o+=4;let l=r.getUint16(o,!0);o+=2;let h=r.getUint16(o,!0);o+=2;let w=r.getUint16(o,!0);o+=2,o+=8;let _=r.getUint32(o,!0);o+=4,o+=l+h+w,yield Xt(r,_,c,d)}}var Xt=(t,e,r,n)=>{e+=4,e+=2,e+=2;let o=t.getUint16(e,!0);e+=2,e+=4,e+=4,e+=8;let s=t.getUint16(e,!0);e+=2;let a=t.getUint16(e,!0);e+=2;let i=new TextDecoder().decode(new Uint8Array(t.buffer,t.byteOffset+e,s));e+=s,e+=a;let c=new Uint8Array(t.buffer,t.byteOffset+e,r);if(o==0)return Ke(i,r,n,c,!0);if(o==8)return Ke(i,r,n,c,!1);throw"unknown compression method: "+o},Ke=(t,e,r,n,o)=>{if(o)return{name:t,csize:e,usize:r,arrayBuffer:()=>Promise.resolve(n),file:()=>Promise.resolve(new File([n],t)),text:()=>Promise.resolve(new TextDecoder().decode(n))};let s,a=async()=>(s??=await Wt(n),s);return{name:t,csize:e,usize:r,arrayBuffer:a,file:async()=>new File([await a()],t),text:async()=>new TextDecoder().decode(await a())}};var zn=(()=>{let t=new Uint32Array(256);for(let e=0;e<256;e++){let r=e;for(let n=0;n<8;n++)r&1?r=3988292384^r>>>1:r=r>>>1;t[e]=r}return t})();var Wt=t=>new Response(new Response(t).body.pipeThrough(new DecompressionStream("deflate-raw"))).arrayBuffer();var je=async(t,e)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(t,e);if(s)return s}},Qe=async(t,e)=>{let n=(await globalThis.caches.keys()).filter(s=>s.startsWith("api")).sort().reverse().at(0);if(!n)return;await(await caches.open(n)).put(t,e.clone())};var Je=[1,0,0,1,0,0],Gt=t=>Math.abs(t[0]-1)<Number.EPSILON&&Math.abs(t[1])<Number.EPSILON&&Math.abs(t[2])<Number.EPSILON&&Math.abs(t[3]-1)<Number.EPSILON&&Math.abs(t[4])<Number.EPSILON&&Math.abs(t[5])<Number.EPSILON;var _e=(t,e,r)=>[t[0]*e,t[1]*e,t[2]*r,t[3]*r,t[4],t[5]],Te=(t,e,r)=>[t[0],t[1],t[2],t[3],t[0]*e+t[2]*r+t[4],t[1]*e+t[3]*r+t[5]],Pe=(t,e)=>{let r=e*Math.PI/180,n=Math.cos(r),o=Math.sin(r);return[t[0]*n+t[2]*o,t[1]*n+t[3]*o,-t[0]*o+t[2]*n,-t[1]*o+t[3]*n,t[4],t[5]]},Ue=t=>Gt(t)?"":transform="matrix(${t.join(" ")})";var et=t=>{let e=new FileReader,r=new Promise(n=>e.onload=()=>n(e.result));return e.readAsDataURL(t),r};var tt=async(t,e)=>(await Promise.all([...t].sort().map(async r=>[r.slice(0,-4),await et(new Blob([await e(r)],{type:"font/truetype"}))]))).map(([r,n])=>@font-face{font-family:${r};src:local(${r}),url(${n})format("truetype");}.${r}{font-family:${r};}).join("");var nt=async(t,e)=>{let r=0,n="black",o=e.svg?1:0,s=[...Je],a="",i=0,c="",d=0,l=0,h=0,w=0,_=new Set;for(let u of t)switch(u.type){case"text":{let p=0,b=0,f="";for(let L of u.text){let y=L.codePointAt(0)??0,pe=u.font.metrics.characters.at(y);if(pe===void 0)throw Error(Could not find font metric for ${y});p+=pe.width,b=Math.max(b,pe.height),f+=String.fromCodePoint(y>=0&&y<=9?161+y:y>=10&&y<=19?173+y-10:y===20?8729:y>=21&&y<=32?184+y-21:y===127?196:y)}let T=u.font.metrics.design_size/1048576*65536/1048576,g=u.left*r,x=p*r*T,v=b*r*T,le=u.top*r;a=u.font.name,i=u.font.metrics.design_size/1048576*u.font.scaleFactor/u.font.designSize;let ne=["#000","black"].includes(n)?"CanvasText":n;if(_.add(${a}.ttf),o<=0){let L=d==u.top&&g>l+2;c+=<span class="text ${a}" style="top:${le-v}pt;left:${g}pt;color:${ne};font-size:${i}pt;"><span ${L?'class="has-space" ':""} style="vertical-align:${-v}pt;">${f}</span></span>
,d=u.top,l=g+x}else{let L=u.top*r;c+=<text alignment-baseline="baseline" y="${L}" x="${g}" fill="${ne}" font-size="${i}" font-family="${a}">${f}</text>
}break}case"rect":{let p=u.height*r,b=u.width*r,f=u.left*r,g=u.top*r-p,x=["#000","black"].includes(n)?"CanvasText":n;c+=o>0?<rect x="${f}" y="${g}" width="${b}" height="${p}" fill="${x}" ${Ue(s)}></rect>
:<span class="rect" style="background: ${x}; top: ${g}pt; left: ${f}pt; width: ${b}pt; height: ${p}pt;"></span>
;break}case"special":break;case"info":{r=u.magnification*u.numerator/1e3/u.denominator*72.27/1e5/2.54;break}case"svg":{let p=u.svg;for(let T of u.svg.matchAll(/<svg\s[^>]+>/g)){let g=T[0];g==="<svg beginpicture>"&&(p=p.replace(g,o>0?"":ve(h,w))),o++}for(let T of u.svg.matchAll(/<\/svg\s[^>]+>/g)){let g=T[0];g==="</svg endpicture>"&&(p=p.replace(g,o===1?"</svg>":"")),o=Math.max(0,o-1)}let b=u.top*r,f=u.left*r;c+=p.replaceAll("{?x}",${f}).replaceAll("{?y}",${b});break}case"papersize":w=u.height,h=u.width;break;case"color":n=u.color;break;case"ps":s=u.interpret(s);break;case"psfile":c+=o>0?u.toSVG(s):${ve(h,w)}${u.toSVG(s)}</svg>};break}for(let u=o;u>0;u--)c+="</svg>";let k=<title>${e.title??"input.tex"}</title>,U=<style>${await tt(_,e.fileLoader)}:root{color-scheme:light dark;background-color:Canvas;color:CanvasText;}.page{position:relative;width:100%;}.text{line-height:0;position:absolute;overflow:visible;}.rect{position:absolute;min-width:1px;min-height:1px;}</style>;return c=c.replace(/("#000"|"black")/g,'"CanvasText"').replace(/("#fff"|"white")/g,'"var(--background-primary, Canvas)"'),e.svg?${ve(h,w)}${k}${U}${c}:<!DOCTYPE html><html><head><meta charset="UTF-8">${k}${U}</head><body>${c}</body></html>},ve=(t,e)=><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${t}pt" height="${e}pt" viewBox="-72 -72 ${t} ${e}">;var rt=t=>{let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=e.getUint16(0),n=e.getUint16(2),o=e.getUint16(4),s=e.getUint16(6),a={header:Math.max(18,n),character_info:s-o+1,width:e.getUint16(8),height:e.getUint16(10),depth:e.getUint16(12),italic_correction:e.getUint16(14),lig_kern:e.getUint16(16),kern:e.getUint16(18),extensible_character:e.getUint16(20),font_parameter:e.getUint16(22)};if(!(o<=s+1&&s<256))throw new Error(Smallest character code (${o}) must be larger than largest character code (${s}) and largest character code must be less than 256 (actual: ${s}));if(a.extensible_character>256)throw new Error(Extensible character must be less than 256 (actual: ${a.extensible_character}));{let x=6+n+a.character_info+a.width+a.height+a.depth+a.italic_correction+a.lig_kern+a.kern+a.extensible_character+a.font_parameter;if(r!==x)throw new Error(entire_file_length must be ${x} (actual: ${r}))}let i=24,c=x=>[...Array(x).keys()].map(v=>e.getUint32(i+v*4)),d=e.buffer.slice(i,i+a.header*4);i+=a.header*4;let l=c(a.character_info);i+=a.character_info*4;let h=c(a.width);i+=a.width*4;let w=c(a.height);i+=a.height*4;let _=c(a.depth);i+=a.depth*4;let k=c(a.italic_correction);i+=a.italic_correction*4;let U=c(a.lig_kern);i+=a.lig_kern*4;let u=c(a.kern);i+=a.kern*4;let p=c(a.extensible_character);i+=a.extensible_character*4;let b=c(a.font_parameter);i+=a.font_parameter*4;let f=Ht(d),T=Bt(l),g=Yt(b,f.coding_scheme);return{checksum:f.checksum,design_size:f.design_size,family:f.family,face:f.face,ligKernPrograms:Vt(U),characters:T.map(x=>{let{width_index:v,height_index:le,depth_index:ne,italic_index:L}=x,y={width:h[v],height:w.at(le)??0,depth:_.at(ne)??0,italic_correction:k.at(L)??0};switch(x.type){case"lig":y.lig_kern_program=U[x.lig_kern_index];break;case"link":y.next_larger_char=x.next_larger_char;break;case"ext":y.extensible_recipe=p[x.extensible_index];break;default:break}return y}),...g}},Ht=t=>{let e=new DataView(t),r=e.getUint32(0),n=e.getUint32(4),o=e.getUint8(8);if(o>39)throw new Error("Invalid TFM file");let s=new TextDecoder().decode(t.slice(9,9+o)),a=e.getUint8(48);if(a>20)throw new Error("Invalid TFM file");let i=new TextDecoder().decode(t.slice(49,49+a)),c=new Uint8Array(t,68,4),d=c[0],l=c[3];return{checksum:r,design_size:n,coding_scheme:s,family:i,seven_bit_safe_flag:d,face:l}},Bt=t=>t.map(e=>{let r=e>>24,n=e>>20&15,o=e>>16&15,s=e>>10&1118481,a=e>>8&3,i=e&255;switch(a){case 1:return{type:"lig",width_index:r,height_index:n,depth_index:o,italic_index:s,lig_kern_index:i};case 2:return{type:"link",width_index:r,height_index:n,depth_index:o,italic_index:s,next_larger_char:i};case 3:return{type:"ext",width_index:r,height_index:n,depth_index:o,italic_index:s,extensible_index:i};default:return{width_index:r,height_index:n,depth_index:o,italic_index:s}}}),Vt=t=>t.map((e,r)=>{let n=e>>24;if((r===0||r===t.length)&&n===255)throw Error(Font has ${r===0?"right":"left"} boundary char. This is not supported yet.);let o=e>>16&255,s=e>>8&255,a=e&255;if(s>=128){let h=256*(s-128)+a;return{skip_byte:n,next_char:o,op_byte:s,kern:a}}let i=s>>2,c=(s&2)==0,d=(s&1)==0,l=a;return n>=128?{skip_byte:n,next_char:o,op_byte:s,remainder:a}:{skip_byte:n,next_char:o,op_byte:s,kern:a}}),Yt=(t,e)=>{let r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],i=t[5];if(e==="TeX math italic")return{coding_scheme:e,slant:r,spacing:n,space_stretch:o,space_shrink:s,x_height:a,quad:i};let c=t[6];if(e==="TeX math symbols"){let d=t[7],l=t[8],h=t[9],w=t[10],_=t[11],k=t[12],U=t[13],u=t[14],p=t[15],b=t[16],f=t[17],T=t[18],g=t[19],x=t[20],v=t[21];return{coding_scheme:e,slant:r,spacing:n,space_stretch:o,space_shrink:s,x_height:a,quad:i,extra_space:c,num1:d,num2:l,num3:h,denom1:w,denom2:_,sup1:k,sup2:U,sup3:u,sub1:p,sub2:b,supdrop:f,subdrop:T,delim1:g,delim2:x,axis_height:v}}if(e==="TeX math extension"||e==="euler substitutions only"){let d=t[7],l=t.slice(8,13);return{coding_scheme:e,slant:r,spacing:n,space_stretch:o,space_shrink:s,x_height:a,quad:i,extra_space:c,default_rule_thickness:d,big_op_spacing:l}}return{coding_scheme:e,slant:r,spacing:n,space_stretch:o,space_shrink:s,x_height:a,quad:i,extra_space:c}};var Cn=t=>{let e=t[0];if(0<=e&&e<128)return[{opcode:0,c:e},1];if(171<=e&&e<235)return[{opcode:171,k:e-171},1];if(249<e&&e<=255)return[{opcode:138},1];let r=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(e){case 128:case 129:case 130:case 131:{let n=e-128+1;return t.byteLength<n+1?void 0:[{opcode:0,c:Se(t,1,n)},n+1]}case 132:case 137:return t.byteLength<9?void 0:[{opcode:e,a:r.getInt32(1),b:r.getInt32(5)},9];case 133:case 134:case 135:case 136:{let n=e-128+1;return t.byteLength<n+1?void 0:[{opcode:133,c:Se(t,1,n)},n+1]}case 138:case 140:case 141:case 142:return[{opcode:e},1];case 139:return t.byteLength<45?void 0:[{opcode:e,c_0:r.getUint32(1),c_1:r.getUint32(5),c_2:r.getUint32(9),c_3:r.getUint32(13),c_4:r.getUint32(17),c_5:r.getUint32(21),c_6:r.getUint32(25),c_7:r.getUint32(29),c_8:r.getUint32(33),c_9:r.getUint32(37),p:r.getInt32(41)},45];case 143:case 144:case 145:case 146:{let n=e-143+1;return t.byteLength<n+1?void 0:[{opcode:143,b:E(t,1,n)},n+1]}case 147:case 152:return[{opcode:e,b:0},1];case 148:case 149:case 150:case 151:{let n=e-147;return t.byteLength<n+1?void 0:[{opcode:147,b:E(t,1,n)},n+1]}case 153:case 154:case 155:case 156:{let n=e-152;return t.byteLength<n+1?void 0:[{opcode:152,b:E(t,1,n)},n+1]}case 157:case 158:case 159:case 160:{let n=e-157+1;return t.byteLength<n+1?void 0:[{opcode:157,a:E(t,1,n)},n+1]}case 161:case 166:return[{opcode:e,a:0},1];case 162:case 163:case 164:case 165:{let n=e-161;return t.byteLength<n+1?void 0:[{opcode:161,a:E(t,1,n)},n+1]}case 167:case 168:case 169:case 170:{let n=e-166;return t.byteLength<n+1?void 0:[{opcode:166,a:E(t,1,n)},n+1]}case 235:case 236:case 237:case 238:{let n=e-235+1;return t.byteLength<n+1?void 0:[{opcode:171,k:E(t,1,n)},n+1]}case 239:case 240:case 241:case 242:{let n=e-239+1;if(t.byteLength<n+1)return;let o=Se(t,1,n);return t.byteLength<n+1+o?void 0:[{opcode:239,x:t.subarray(n+1,n+1+o),k:o},n+1+o]}case 243:case 244:case 245:case 246:{let n=e-243+1;if(t.byteLength<n+1)return;let o=E(t,1,n);if(t.byteLength<n+15)return;let s=t[n+13],a=t[n+14];return t.byteLength<n+15+s+a?void 0:[{opcode:243,k:o,c:r.getUint32(n+1),s:r.getUint32(n+5),d:r.getUint32(n+9),a:s,l:a,n:new TextDecoder().decode(t.subarray(n+15,n+15+s+a))},n+15+s+a]}case 247:{if(t.byteLength<15)return;let n=t[1],o=t[14];return t.byteLength<15+o?void 0:[{opcode:e,i:n,num:r.getUint32(2),den:r.getUint32(6),mag:r.getUint32(10),x:new TextDecoder().decode(t.subarray(15,15+o)),k:o},15+o]}case 248:return t.byteLength<29?void 0:[{opcode:e,p:r.getUint32(1),num:r.getUint32(5),den:r.getUint32(9),mag:r.getUint32(13),l:r.getUint32(17),u:r.getUint32(21),s:r.getUint16(25),t:r.getUint16(27)},29];case 249:return t.byteLength<6?void 0:[{opcode:e,q:r.getUint32(1),i:r.getUint8(5)},6]}};function*ot(t){let e=t,r=0;for(;r<t.byteLength;){let[n,o]=Cn(e)??[,0];if(r+=o,e=e.subarray(o),!n)break;if(n.opcode===249){if(e.every(s=>s===223))break;throw Error("Only 223 bytes are permitted after the post-postamble.")}yield n}}var Se=(t,e,r)=>[...t.subarray(e,e+r)].reduce((n,o,s)=>n+o*256**(r-s-1),0),E=(t,e,r)=>{switch(r){case 1:return t[e];case 2:{let n=t[e]*256+t[e+1];return n|(n&2**15)*131070}case 3:{let n=t[e]*65536+t[e+1]*256+t[e+2];return n|(n&2**23)*510}case 4:return(t[e]<<24)+t[e+1]*2**16+t[e+2]*2**8+t[e+3]}};var st=()=>{let t=[],e="black";return r=>{let n=new TextDecoder().decode(r.data);if(n.startsWith("color push "))return t.push(e),e=it(n.slice(11)),{type:"color",color:e};if(n.startsWith("color pop")){let o=t.pop();if(!o)throw new Error("Popped from empty color stack");return e=o,{type:"color",color:e}}}},En=t=>${Math.round(t).toString(16)}.padStart(2,"0"),it=t=>{if(t==="gray 0")return"black";if(t==="gray 1")return"white";if(t.startsWith("rgb "))return#${t.split(" ").slice(1).map(e=>En(parseFloat(e)*255)).join("")};if(t.startsWith("gray ")){let e=t.split(" ")[1];return it(rgb ${e} ${e} ${e})}return"black"};var at=()=>{let t="";return(e,r)=>{let n=new TextDecoder().decode(e.data);if(!n.startsWith("dvisvgm:raw "))return;if(t+=n.slice(12),r?.type==="special"){let s=new TextDecoder().decode(r.data);if(e.horizontal===r.horizontal&&e.vertical===r.vertical&&s.startsWith("dvisvgm:raw "))return null}let o=t.replaceAll("{?nl}",
);return t="",{type:"svg",svg:o,left:e.horizontal,top:e.vertical}}};var ct=t=>{let e=new TextDecoder().decode(t.data);if(!e.startsWith("papersize="))return;let[r,n]=e.slice(10).split(",");if(r===void 0||n===void 0)throw Error("Papersize special requires two arguments.");if(!r.endsWith("pt"))throw Error("Papersize special width must be in points.");if(!n.endsWith("pt"))throw Error("Papersize special height must be in points.");return{type:"papersize",width:parseFloat(r.slice(0,-2)),height:parseFloat(n.slice(0,-2))}};var lt=[],pt=(t,e,r,n)=>{let o=[],s={matrix:e,horizontal:r,vertical:n},a={pop:()=>o.pop(),exch:()=>{let i=o.pop(),c=o.pop();i&&o.push(i),c&&o.push(c)},dup:()=>{o.push(o[o.length-1])},mark:()=>o.push(new ze),neg:()=>{let i=o.pop();i&&o.push(new S(-i.value))},add:()=>{let i=o.pop(),c=o.pop();i&&c&&o.push(new S(i.value+c.value))},sub:()=>{let i=o.pop(),c=o.pop();i&&c&&o.push(new S(c.value-i.value))},mul:()=>{let i=o.pop(),c=o.pop();i&&c&&o.push(new S(i.value*c.value))},div:()=>{let i=o.pop(),c=o.pop();i&&c&&o.push(new S(c.value/i.value))},gsave:()=>lt.push([...e]),grestore:()=>{let i=lt.pop();i&&(s.matrix=i)},currentpoint:()=>o.push(new S(s.horizontal),new S(s.vertical)),moveto:()=>{let i=o.pop(),c=o.pop();s.horizontal=c?.value,s.vertical=i?.value},scale:()=>{let i=o.pop(),c=o.pop();c&&i&&(s.matrix=_e(s.matrix,c.value,i.value))},translate:()=>{let i=o.pop(),c=o.pop();c&&i&&(s.matrix=Te(s.matrix,c.value,i.value))},rotate:()=>{let i=o.pop();i&&(s.matrix=Pe(s.matrix,i.value))}};for(let i of Rn(t)){if(/^[+-]?\d+(\.\d*)?$/.test(i)){o.push(new S(i));continue}if(i[0]==="("){o.push(new De(i));continue}if(i==="["){a.mark();continue}if(i==="]"){let c=new Oe,d=o.pop();if(!d)continue;for(;d.name!=="mark";)c.push(d);o.push(c)}if(i[0]==="/"&&o.push(new Ie(i)),i[0]==="{"&&o.push(new Xe(i)),i in a){a[i](void 0);continue}throw Error("Invalid or unimplemented postscript expression")}return s};function*Rn(t){let e="",r=0,n=0,o=t[Symbol.iterator]();for(let s of o){let a;switch(s){case" ":case" ":case
:if(n){e[e.length-1]!==" "&&(e+=" ");continue}if(r){switch(s){case" ":e+=" ";break;case
:e+="\\n";break;case" ":e+="\\t";break}continue}e&&(yield e,e="");continue;case"[":case"]":if(!n&&!r){e&&(yield e),e="",yield s;continue}e+=s;continue;case"{":r||(n==0&&e&&(yield e),++n),e+=s;continue;case"}":if(e+=s,r||(--n,n))continue;yield e,e="";continue;case"(":++r,e&&!n&&r==1&&(yield e),r>1&&(e+="\\"),e+=s;continue;case")":if(--r,r&&(e+="\\"),e+=s,n||r)continue;yield e,e="";continue;case"\\":if(e+=s,a=o.next(),a.done)throw Error("Invalid escape character.");a.done||(e+=a.value);continue;case"/":!n&&!r&&e&&(yield e),e+=s;continue;case"%":do a=o.next();while(!a.done&&a.value!==
);continue;default:e+=s}}e&&(yield e)}var R=class{name;value;constructor(e){this.name=e}},S=class extends R{constructor(e){super("number"),this.value=typeof e=="number"?e:parseFloat(e)}},De=class extends R{constructor(e){super("string"),this.value=e.replace(/^\(|\)$/g,"")}},Oe=class extends R{constructor(e){super("array"),this.value=e||[]}push(e){this.value.push(e)}pop(){return this.value.pop()}},ze=class extends R{constructor(){super("mark"),this.value="-mark-"}},Ie=class extends R{constructor(e){super("identifier"),this.value=e.replace(/^\//,"")}},Xe=class extends R{constructor(e){super("procedure"),this.value=e}};var ut=()=>{let t="";return(e,r)=>{let n=new TextDecoder().decode(e.data);if(!n.startsWith("ps: "))return;if(t+=n.slice(4),r?.type==="special"&&new TextDecoder().decode(r.data).startsWith("ps: "))return null;let o=s=>{let a=pt(t,s,e.horizontal,e.vertical);return e.emitChange({horizontal:a.horizontal,vertical:a.vertical,w:e.w,x:e.x,y:e.y,z:e.z}),a.matrix};return t="",{type:"ps",ps:t,interpret:o}}};async function*ft(t,e){let r=Ln(t,e.tfmLoader),n=await r.next(),o=n.done?void 0:n.value;for(;o;){let s=o,a=await r.next();if(o=a.done?void 0:a.value,s.type==="special"&&e.plugins){let i=!1;for(let c of e.plugins){let d=c(s,o);if(d!==void 0){d!==null&&(yield d),i=!0;break}}i||(yield s);continue}yield s}}async function*Ln(t,e){let r=2,n=254e5,o=473628672,s=1e3,a="",i=0,c=0,d=0,l={horizontal:0,vertical:0,w:0,x:0,y:0,z:0,fontNum:0},h=[],w=new Map,_="",k=ot(t),U=k.next(),u=U.done?void 0:U.value;for(;u;){let p=u,b=k.next();switch(u=b.done?void 0:b.value,p.opcode){case 0:case 133:if(_+=String.fromCharCode(p.c),u?.opcode!==0&&u?.opcode!==133||!u){let f=w.get(l.fontNum);if(!f)throw Error(Font "${l.fontNum}" is not loaded);yield{type:"text",text:_,font:f,top:l.vertical,left:l.horizontal},p.opcode===0&&(l.horizontal+=$n(_,f)),_=""}break;case 132:case 137:p.a>0&&p.b>0&&(yield{type:"rect",left:l.horizontal,top:l.vertical,height:p.a,width:p.b}),p.opcode===132&&(l.horizontal+=p.b);break;case 138:case 140:break;case 139:l.horizontal=0,l.vertical=0,l.w=0,l.x=0,l.y=0,l.z=0,l.fontNum=0,h.splice(0,h.length);break;case 141:h.push({...l});break;case 142:{let f=h.pop();f&&(l.horizontal=f.horizontal,l.vertical=f.vertical,l.w=f.w,l.x=f.x,l.y=f.y,l.z=f.z);break}case 143:l.horizontal+=p.b;break;case 147:p.b!==0&&(l.w=p.b),l.horizontal+=l.w;break;case 152:p.b!==0&&(l.x=p.b),l.horizontal+=l.x;break;case 157:l.vertical+=p.a;break;case 161:p.a!==0&&(l.y=p.a),l.vertical+=l.y;break;case 166:p.a!==0&&(l.z=p.a),l.vertical+=l.z;break;case 171:case 235:case 236:case 237:case 238:l.fontNum=p.k;break;case 239:yield{type:"special",data:p.x,...l,emitChange:f=>{l.horizontal=f.horizontal,l.vertical=f.vertical,l.w=f.w,l.x=f.x,l.y=f.y,l.z=f.z}};break;case 243:{if(w.has(p.k))break;let f=p.n,T=p.s,g=p.d,x=p.c,v=rt(new Uint32Array((await e(${p.n}.tfm)).buffer));w.set(p.k,{name:f,checksum:x,scaleFactor:T,designSize:g,metrics:v});break}case 247:r=p.i,n=p.num,o=p.den,s=p.mag,a=p.x,yield{type:"info",version:r,numerator:n,denominator:o,magnification:s,comment:a};break;case 248:i=p.l,c=p.u,d=p.t;break;case 249:yield{type:"info",version:r,numerator:n,denominator:o,magnification:s,comment:a,maxHeight:i,maxWidth:c,pages:d,dviVersion:p.i};break}}}var $n=(t,e)=>{let r=0;for(let o of t){let s=o.codePointAt(0)??0,a=e.metrics.characters.at(s);if(a===void 0)throw Error(Could not find font metric for ${s});r+=a.width}let n=e.metrics.design_size/1048576*65536/1048576;return r*n*e.scaleFactor/e.designSize};globalThis.onmessage=async t=>{let e=t.data;switch(e.type){case"asset-url":{mt=e.url;let r={type:e.type};globalThis.postMessage(r)}break;case"compile":{let{dvi:r,log:n}=await Ze(e.input,{fileLoader:We,console:c=>{let d={type:"stdout",message:c};globalThis.postMessage(d)}});if(!r){let c={type:e.type,log:n};globalThis.postMessage(c,[n.buffer]);return}let o=[],s=new Set;for await(let c of ft(r,{plugins:[ct,ut(),at(),st()],tfmLoader:We}))o.push(c),c.type==="text"&&s.add(c.font.name);let a=await nt(o,{fileLoader:We,svg:!0}),i={type:e.type,svg:a,log:n};globalThis.postMessage(i,[n.buffer])}break}};var dt,We=async t=>{dt??=await Mn();let e=dt.get(t);if(!e){let r=new Error(File ${t} not found in assets`);throw console.log(r),r}return new Uint8Array(await e())},mt="",Mn=async()=>{let t=new Request(mt),e=await je(t,{ignoreSearch:!0}),r=e??await fetch(t);e||await Qe(t,r);let n=new Map;for await(let{name:o,arrayBuffer:s}of qe(await r.arrayBuffer()))n.set(o,s);return n};
code:esbuild-worker.js
var b="0.24.0";(()=>{let r=()=>{let c=new Error("not implemented");return c.code="ENOSYS",c};if(!globalThis.fs){let c="";globalThis.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(i,s){c+=f.decode(s);let n=c.lastIndexOf(`
);return n!=-1&&(console.log(c.substring(0,n)),c=c.substring(n+1)),s.length},write(i,s,n,o,h,u){if(n!==0||o!==s.length||h!==null){u(r());return}let m=this.writeSync(i,s);u(null,m)},chmod(i,s,n){n(r())},chown(i,s,n,o){o(r())},close(i,s){s(r())},fchmod(i,s,n){n(r())},fchown(i,s,n,o){o(r())},fstat(i,s){s(r())},fsync(i,s){s(null)},ftruncate(i,s,n){n(r())},lchown(i,s,n,o){o(r())},link(i,s,n){n(r())},lstat(i,s){s(r())},mkdir(i,s,n){n(r())},open(i,s,n,o){o(r())},read(i,s,n,o,h,u){u(r())},readdir(i,s){s(r())},readlink(i,s){s(r())},rename(i,s,n){n(r())},rmdir(i,s){s(r())},stat(i,s){s(r())},symlink(i,s,n){n(r())},truncate(i,s,n){n(r())},unlink(i,s){s(r())},utimes(i,s,n,o){o(r())}}}if(globalThis.process||(globalThis.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw r()},pid:-1,ppid:-1,umask(){throw r()},cwd(){throw r()},chdir(){throw r()}}),!globalThis.crypto)throw new Error("globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)");if(!globalThis.performance)throw new Error("globalThis.performance is not available, polyfill required (performance.now only)");if(!globalThis.TextEncoder)throw new Error("globalThis.TextEncoder is not available, polyfill required");if(!globalThis.TextDecoder)throw new Error("globalThis.TextDecoder is not available, polyfill required");let y=new TextEncoder("utf-8"),f=new TextDecoder("utf-8");globalThis.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;let c=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},i=(e,t)=>{this.mem.setUint32(e+0,t,!0)},s=e=>{let t=this.mem.getUint32(e+0,!0),l=this.mem.getInt32(e+4,!0);return t+l*4294967296},n=e=>{let t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;let l=this.mem.getUint32(e,!0);return this._values[l]},o=(e,t)=>{if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,2146959360,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let a=this._ids.get(t);a===void 0&&(a=this._idPool.pop(),a===void 0&&(a=this._values.length),this._values[a]=t,this._goRefCounts[a]=0,this._ids.set(t,a)),this._goRefCounts[a]++;let g=0;switch(typeof t){case"object":t!==null&&(g=1);break;case"string":g=2;break;case"symbol":g=3;break;case"function":g=4;break}this.mem.setUint32(e+4,2146959360|g,!0),this.mem.setUint32(e,a,!0)},h=e=>{let t=s(e+0),l=s(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,l)},u=e=>{let t=s(e+0),l=s(e+8),a=new Array(l);for(let g=0;g<l;g++)a[g]=n(t+g*8);return a},m=e=>{let t=s(e+0),l=s(e+8);return f.decode(new DataView(this._inst.exports.mem.buffer,t,l))},d=Date.now()-performance.now();this.importObject={_gotest:{add:(e,t)=>e+t},gojs:{"runtime.wasmExit":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;let t=s(e+8),l=s(e+16),a=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,l,a))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,c(e+8,(d+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;let t=new Date().getTime();c(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;let t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},s(e+8))),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;let t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(h(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;let t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){let l=this._values[t];this._values[t]=null,this._ids.delete(l),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,o(e+24,m(e+8))},"syscall/js.valueGet":e=>{e>>>=0;let t=Reflect.get(n(e+8),m(e+16));e=this._inst.exports.getsp()>>>0,o(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(n(e+8),m(e+16),n(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(n(e+8),m(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,o(e+24,Reflect.get(n(e+8),s(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(n(e+8),s(e+16),n(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{let t=n(e+8),l=Reflect.get(t,m(e+16)),a=u(e+32),g=Reflect.apply(l,t,a);e=this._inst.exports.getsp()>>>0,o(e+56,g),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{let t=n(e+8),l=u(e+16),a=Reflect.apply(t,void 0,l);e=this._inst.exports.getsp()>>>0,o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{let t=n(e+8),l=u(e+16),a=Reflect.construct(t,l);e=this._inst.exports.getsp()>>>0,o(e+40,a),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,o(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,c(e+16,parseInt(n(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;let t=y.encode(String(n(e+8)));o(e+16,t),c(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;let t=n(e+8);h(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,n(e+8)instanceof n(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;let t=h(e+8),l=n(e+32);if(!(l instanceof Uint8Array||l instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=l.subarray(0,t.length);t.set(a),c(e+40,a.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;let t=n(e+8),l=h(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}let a=l.subarray(0,t.length);t.set(a),c(e+40,a.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(c){if(!(c instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=c,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,globalThis,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[globalThis,5],[this,6]]),this._idPool=[],this.exited=!1;let i=4096,s=d=>{let e=i,t=y.encode(d+"\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!==0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(d=>{o.push(s(d))}),o.push(0),Object.keys(this.env).sort().forEach(d=>{o.push(s(${d}=${this.envd}))}),o.push(0);let u=i;if(o.forEach(d=>{this.mem.setUint32(i,d,!0),this.mem.setUint32(i+4,0,!0),i+=8}),i>=12288)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(n,u),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(c){let i=this;return function(){let s={id:c,this:this,args:arguments};return i._pendingEvent=s,i._resume(),s.result}}}})();onmessage=({data:r})=>{let y=new TextDecoder,f=globalThis.fs,c="";f.writeSync=(h,u)=>{if(h===1)postMessage(u);else if(h===2){c+=y.decode(u);let m=c.split(
);m.length>1&&console.log(m.slice(0,-1).join(
)),c=m[m.length-1]}else throw new Error("Bad write");return u.length};let i=[],s,n=0;onmessage=({data:h})=>(h.length>0&&(i.push(h),s&&s()),o),f.read=(h,u,m,d,e,t)=>{if(h!==0||m!==0||d!==u.length||e!==null)throw new Error("Bad read");if(i.length===0){s=()=>f.read(h,u,m,d,e,t);return}let l=i[0],a=Math.max(0,Math.min(d,l.length-n));u.set(l.subarray(n,n+a),m),n+=a,n===l.length&&(i.shift(),n=0),t(null,a)};let o=new globalThis.Go;return o.argv=["",--service=${b}],w(r,o).then(h=>{postMessage(null),o.run(h)},h=>{postMessage(h)}),o};async function w(r,y){if(r instanceof WebAssembly.Module)return WebAssembly.instantiate(r,y.importObject);let f=r instanceof Response?r:await fetch(r);if(!f.ok)throw new Error(Failed to download ${JSON.stringify(r)}`);if("instantiateStreaming"in WebAssembly&&/^application\/wasm($|;)/i.test(f.headers.get("Content-Type")||""))return(await WebAssembly.instantiateStreaming(f,y.importObject)).instance;let c=await f.arrayBuffer();return(await WebAssembly.instantiate(c,y.importObject)).instance}
/** @license esbuild-wasm@0.24.0
*
* MIT License
*
* Copyright (c) 2020 Evan Wallace
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
code:select-suggestion-worker.js
var G=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof require<"u"?require:r)t}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Qe=(e,r)=>{if(e.length!==r.length)return!1;let t=...e.sort(),o=...r.sort();return t.every((n,a)=>n===oa)};function Xe(e,r={}){let{signal:t,persistent:o=!0}=r;return t?.aborted?Promise.reject(t.reason):new Promise((n,a)=>{let s=()=>{clearTimeout(+i),a(t?.reason)},i=bt(()=>{t?.removeEventListener("abort",s),n()},e);if(t?.addEventListener("abort",s,{once:!0}),o===!1)try{Deno.unrefTimer(+i)}catch(c){if(!(c instanceof ReferenceError))throw clearTimeout(+i),c;console.error("persistent option is only available in Deno")}})}var Ze=2**31-1;function bt(e,r){let t=r=Math.trunc(Math.max(r,0)||0),o=Date.now(),n,a=()=>{t=r-(Date.now()-o),n=t>Ze?Number(setTimeout(a,Ze)):Number(setTimeout(e,t))};return a(),{valueOf:()=>n}}var rr=Symbol("Comlink.proxy"),xt=Symbol("Comlink.endpoint"),Tt=Symbol("Comlink.releaseProxy"),_e=Symbol("Comlink.finalizer"),ae=Symbol("Comlink.thrown"),tr=e=>typeof e=="object"&&e!==null||typeof e=="function",_t={canHandle:e=>tr(e)&&err,serialize(e){let{port1:r,port2:t}=new MessageChannel;return Z(e,r),[t,t]},deserialize(e){return e.start(),Ft(e)}},Ot={canHandle:e=>tr(e)&&ae in e,serialize({value:e}){let r;return e instanceof Error?r={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:r={isError:!1,value:e},[r,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},or=new Map("proxy",_t],["throw",Ot);function kt(e,r){for(let t of e)if(r===t||t==="*"||t instanceof RegExp&&t.test(r))return!0;return!1}function Z(e,r=globalThis,t="*"){r.addEventListener("message",function o(n){if(!n||!n.data)return;if(!kt(t,n.origin)){console.warn(Invalid origin '${n.origin}' for comlink proxy);return}let{id:a,type:s,path:l}=Object.assign({path:[]},n.data),i=(n.data.argumentList||[]).map(q),c;try{let f=l.slice(0,-1).reduce((u,m)=>um,e),p=l.reduce((u,m)=>um,e);switch(s){case"GET":c=p;break;case"SET":f[l.slice(-1)0]=q(n.data.value),c=!0;break;case"APPLY":c=p.apply(f,i);break;case"CONSTRUCT":{let u=new p(...i);c=It(u)}break;case"ENDPOINT":{let{port1:u,port2:m}=new MessageChannel;Z(e,m),c=vt(u,u)}break;case"RELEASE":c=void 0;break;default:return}}catch(f){c={value:f,ae:0}}Promise.resolve(c).catch(f=>({value:f,ae:0})).then(f=>{letp,u=ce(f);r.postMessage(Object.assign(Object.assign({},p),{id:a}),u),s==="RELEASE"&&(r.removeEventListener("message",o),nr(r),_e in e&&typeof e_e=="function"&&e_e())}).catch(f=>{letp,u=ce({value:new TypeError("Unserializable return value"),ae:0});r.postMessage(Object.assign(Object.assign({},p),{id:a}),u)})}),r.start&&r.start()}function Nt(e){return e.constructor.name==="MessagePort"}function nr(e){Nt(e)&&e.close()}function Ft(e,r){let t=new Map;return e.addEventListener("message",function(o){let{data:n}=o;if(!n||!n.id)return;let a=t.get(n.id);if(a)try{a(n)}finally{t.delete(n.id)}}),Oe(e,t,[],r)}function se(e){if(e)throw new Error("Proxy has been released and is not useable")}function sr(e){return V(e,new Map,{type:"RELEASE"}).then(()=>{nr(e)})}var ie=new WeakMap,le="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{let r=(ie.get(e)||0)-1;ie.set(e,r),r===0&&sr(e)});function St(e,r){let t=(ie.get(r)||0)+1;ie.set(r,t),le&&le.register(e,r,e)}function Lt(e){le&&le.unregister(e)}function Oe(e,r,t=[],o=function(){}){let n=!1,a=new Proxy(o,{get(s,l){if(se(n),l===Tt)return()=>{Lt(a),sr(e),r.clear(),n=!0};if(l==="then"){if(t.length===0)return{then:()=>a};let i=V(e,r,{type:"GET",path:t.map(c=>c.toString())}).then(q);return i.then.bind(i)}return Oe(e,r,...t,l)},set(s,l,i){se(n);letc,f=ce(i);return V(e,r,{type:"SET",path:...t,l.map(p=>p.toString()),value:c},f).then(q)},apply(s,l,i){se(n);let c=tt.length-1;if(c===xt)return V(e,r,{type:"ENDPOINT"}).then(q);if(c==="bind")return Oe(e,r,t.slice(0,-1));letf,p=er(i);return V(e,r,{type:"APPLY",path:t.map(u=>u.toString()),argumentList:f},p).then(q)},construct(s,l){se(n);leti,c=er(l);return V(e,r,{type:"CONSTRUCT",path:t.map(f=>f.toString()),argumentList:i},c).then(q)}});return St(a,e),a}function Pt(e){return Array.prototype.concat.apply([],e)}function er(e){let r=e.map(ce);return[r.map(t=>t0),Pt(r.map(t=>t1))]}var ar=new WeakMap;function vt(e,r){return ar.set(e,r),e}function It(e){return Object.assign(e,{rr:!0})}function ce(e){for(letr,tof or)if(t.canHandle(e)){leto,n=t.serialize(e);return{type:"HANDLER",name:r,value:o},n}return[{type:"RAW",value:e},ar.get(e)||[]]}function q(e){switch(e.type){case"HANDLER":return or.get(e.name).deserialize(e.value);case"RAW":return e.value}}function V(e,r,t,o){return new Promise(n=>{let a=At();r.set(a,n),e.start&&e.start(),e.postMessage(Object.assign({id:a},t),o)})}function At(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var P=!1;var ir=e=>Object.fromEntries(...Object.entries(console).map((r,t)=>{if(typeof t!="function")returnr,t;switch(r){case"warn":case"error":return[r,(...o)=>t(%c${e},ke,...o)];case"log":case"info":case"debug":return[r,(...o)=>{P!==!0&&(!P||!P.has(e))||t(%c${e},ke,...o)}];case"assert":return[r,(o,...n)=>{P!==!0&&(!P||!P.has(e))||t(o,%c${e},ke,...n)}];case"time":case"timeEnd":return[r,o=>{P!==!0&&(!P||!P.has(e))||t(${e} ${o})}];default:returnr,(...o)=>{if(!(P!==!0&&(!P||!P.has(e))))return t(...o)}}})),ke="color: gray";var lr=function(){};function ee(e,r={}){lr.prototype.name=e;let t={};return new Proxy(lr,{get(o,n){return n==="caller"?null:n==="__createMock__"?ee:n==="__unenv__"?!0:n in r?rn:tn=tn||ee(${e}.${n.toString()})},apply(o,n,a){return ee(${e}())},construct(o,n,a){return ee([${e}])},enumerate(){return[]}})}var Ne=ee("mock");function Mt(e){return new Error([unenv] ${e} is not implemented yet!)}function d(e){return Object.assign(()=>{throw Mt(e)},{__unenv__:!0})}var Ut=Object.freeze(Object.create(null,{__unenv__:{get:()=>!0}})),ue=Object.create(null),Ct=globalThis.process?.env,X=e=>Ct||globalThis.__env__||(e?ue:globalThis),jt=new Proxy(ue,{get(e,r){return X()r??uer},has(e,r){let t=X();return r in t||r in ue},set(e,r,t){let o=X(!0);return or=t,!0},deleteProperty(e,r){let t=X(!0);return delete tr,!0},ownKeys(){let e=X();return Object.keys(e)}}),Bt=Object.assign(function(e){let r=Date.now(),t=Math.trunc(r/1e3),o=r%1e3*1e6;if(e){let n=t-e0,a=o-e0;return a<0&&(n=n-1,a=1e9+a),n,a}returnt,o},{bigint:function(){return BigInt(Date.now()*1e6)}}),Dt=globalThis.queueMicrotask?(e,...r)=>{globalThis.queueMicrotask(e.bind(void 0,...r))}:$t();function $t(){let e=[],r=!1,t,o=-1;function n(){!r||!t||(r=!1,t.length>0?e=...t,...e:o=-1,e.length>0&&a())}function a(){if(r)return;let s=setTimeout(n);r=!0;let l=e.length;for(;l;){for(t=e,e=[];++o<l;)t&&to();o=-1,l=e.length}t=void 0,r=!1,clearTimeout(s)}return(s,...l)=>{e.push(s.bind(void 0,...l)),e.length===1&&!r&&setTimeout(a)}}var Gt="unenv",qt=[],Wt="",Vt={ares:"",http_parser:"",icu:"",modules:"",node:"",openssl:"",uv:"",v8:"",zlib:""};function I(){return Fe}var Ht=I,zt=I,Yt=I,Kt=I,Jt=I,Qt=I,Zt=function(e){return e==="message"||e==="multipleResolves"?Fe:!1},Xt=I,eo=I,ro=function(e){return[]},to=()=>0,oo=function(e){throw new Error("unenv process.binding is not supported")},cr="/",no=function(){return cr},so=function(e){cr=e},ao=function(){return 0},io=function(){return 1e3},lo=function(){return 1e3},co=function(){return 1e3},uo=function(){return 1e3},po=function(){return[]},fo=e=>{},mo=d("process.abort"),go=new Set,Eo="",yo="",ho=Ut,Ro=!1,wo=()=>0,bo=()=>0,xo=d("process.cpuUsage"),To=0,_o=d("process.dlopen"),Oo=I,ko=I,No=d("process.eventNames"),Fo=[],So="",Lo=d("process.exit"),Po=Object.create({inspector:void 0,debug:void 0,uv:void 0,ipv6:void 0,tls_alpn:void 0,tls_sni:void 0,tls_ocsp:void 0,tls:void 0,cached_builtins:void 0}),vo=()=>[],Io=d("process.getMaxListeners"),Ao=d("process.kill"),Mo=Object.assign(()=>({arrayBuffers:0,rss:0,external:0,heapTotal:0,heapUsed:0}),{rss:()=>0}),Uo=1e3,Co="",jo=1e3,Bo=d("process.rawListeners"),Do=Object.create({name:"",lts:"",sourceUrl:void 0,headersUrl:void 0}),$o=Object.create({compact:void 0,directory:void 0,filename:void 0,getReport:d("process.report.getReport"),reportOnFatalError:void 0,reportOnSignal:void 0,reportOnUncaughtException:void 0,signal:void 0,writeReport:d("process.report.writeReport")}),Go=d("process.resourceUsage"),qo=d("process.setegid"),Wo=d("process.seteuid"),Vo=d("process.setgid"),Ho=d("process.setgroups"),zo=d("process.setuid"),Yo=d("process.setMaxListeners"),Ko=d("process.setSourceMapsEnabled"),Jo=Ne.__createMock__("process.stdout"),Qo=Ne.__createMock__("process.stderr"),Zo=Ne.__createMock__("process.stdin"),Xo=!1,en=()=>0,rn=0,tn=d("process.setUncaughtExceptionCaptureCallback"),on=()=>!1,nn=!1,sn=d("process.loadEnvFile"),an=void 0,ln={has:()=>!1},cn={ref(){},unref(){}},un=!1,pn={register(){},unregister(){},registerBeforeExit(){}},fn=d("process.assert"),mn=d("process.openStdin"),dn=d("process._debugEnd"),gn=d("process._debugProcess"),En=d("process._fatalException"),yn=d("process._getActiveHandles"),hn=d("process._getActiveRequests"),Rn=d("process._kill"),wn=[],bn=d("process._rawDebug"),xn=d("process._startProfilerIdleNotifier"),Tn=d("process.__stopProfilerIdleNotifier"),_n=d("process._tickCallback"),Zs=d("process._linkedBinding"),On=void 0,kn=d("process.initgroups"),Nn=[],Fn=I,Sn=!1,Ln=[],Pn=0,vn=0,Fe={_events:Ln,_eventsCount:Pn,_exiting:Sn,_maxListeners:vn,_debugEnd:dn,_debugProcess:gn,_fatalException:En,_getActiveHandles:yn,_getActiveRequests:hn,_kill:Rn,_preload_modules:wn,_rawDebug:bn,_startProfilerIdleNotifier:xn,_stopProfilerIdleNotifier:Tn,_tickCallback:_n,domain:On,initgroups:kn,moduleLoadList:Nn,reallyExit:Fn,exitCode:rn,abort:mo,addListener:zt,allowedNodeEnvironmentFlags:go,hasUncaughtExceptionCaptureCallback:on,setUncaughtExceptionCaptureCallback:tn,loadEnvFile:sn,sourceMapsEnabled:nn,throwDeprecation:un,mainModule:an,permission:ln,channel:cn,arch:Eo,argv:qt,argv0:yo,assert:fn,binding:oo,chdir:so,config:ho,connected:Ro,constrainedMemory:wo,availableMemory:bo,cpuUsage:xo,cwd:no,debugPort:To,dlopen:_o,disconnect:Oo,emit:Zt,emitWarning:ko,env:jt,eventNames:No,execArgv:Fo,execPath:So,exit:Lo,finalization:pn,features:Po,getBuiltinModule:fo,getegid:io,geteuid:lo,getgid:co,getgroups:po,getuid:uo,getActiveResourcesInfo:vo,getMaxListeners:Io,hrtime:Bt,kill:Ao,listeners:ro,listenerCount:to,memoryUsage:Mo,nextTick:Dt,on:Ht,off:Kt,once:Yt,openStdin:mn,pid:Uo,platform:Co,ppid:jo,prependListener:Xt,prependOnceListener:eo,rawListeners:Bo,release:Do,removeAllListeners:Qt,removeListener:Jt,report:$o,resourceUsage:Go,setegid:qo,seteuid:Wo,setgid:Vo,setgroups:Ho,setuid:zo,setMaxListeners:Yo,setSourceMapsEnabled:Ko,stderr:Qo,stdin:Zo,stdout:Jo,title:Gt,traceDeprecation:Xo,umask:ao,uptime:en,version:Wt,versions:Vt},re=Fe;var In=Object.create,gr=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Mn=Object.getOwnPropertyNames,Un=Object.getPrototypeOf,Cn=Object.prototype.hasOwnProperty,Er=(e=>typeof G<"u"?G:typeof Proxy<"u"?new Proxy(e,{get:(r,t)=>(typeof G<"u"?G:r)t}):e)(function(e){if(typeof G<"u")return G.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),yr=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),jn=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Mn(r))!Cn.call(e,n)&&n!==t&&gr(e,n,{get:()=>rn,enumerable:!(o=An(r,n))||o.enumerable});return e},hr=(e,r,t)=>(t=e!=null?In(Un(e)):{},jn(r||!e||!e.__esModule?gr(t,"default",{value:e,enumerable:!0}):t,e)),Bn=yr((e,r)=>{var t=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in re&&"node"in re.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{t=Er0(${["node","util"].join(":")})}catch{t=null}r.exports=t}),Dn=yr((e,r)=>{var t=null;if(typeof window>"u"&&("process"in globalThis&&"versions"in re&&"node"in re.versions&&typeof globalThis.caches>"u"&&typeof globalThis.addEventListener!="function"||"Bun"in globalThis))try{t=Er0(${["node","fs"].join(":")})}catch{t=null}r.exports=t}),$n={},pe=Gn(globalThis,$n);function Gn(e,r){return new Proxy(e,{get(t,o,n){return o in r?ro:eo},set(t,o,n){return o in r&&delete ro,eo=n,!0},deleteProperty(t,o){let n=!1;return o in r&&(delete ro,n=!0),o in e&&(delete eo,n=!0),n},ownKeys(t){let o=Reflect.ownKeys(e),n=Reflect.ownKeys(r),a=new Set(n);return...o.filter(s=>!a.has(s)),...n},defineProperty(t,o,n){return o in r&&delete ro,Reflect.defineProperty(e,o,n),!0},getOwnPropertyDescriptor(t,o){return o in r?Reflect.getOwnPropertyDescriptor(r,o):Reflect.getOwnPropertyDescriptor(e,o)},has(t,o){return o in r||o in e}})}var ur="debug","info","warning","error","fatal";function pr(e,r){let t=ur.indexOf(e);if(t<0)throw new TypeError(Invalid log level: ${JSON.stringify(e)}.);let o=ur.indexOf(r);if(o<0)throw new TypeError(Invalid log level: ${JSON.stringify(r)}.);return t-o}function te(e=[]){return Rr.getLogger(e)}var Se=Symbol.for("logtape.rootLogger"),Rr=class B{static getLogger(r=[]){let t=Se in pe?peSe??null:null;return t==null&&(t=new B(null,[]),peSe=t),typeof r=="string"?t.getChild(r):r.length===0?t:t.getChild(r)}constructor(r,t){Object.defineProperty(this,"parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"children",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"category",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sinks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"parentSinks",{enumerable:!0,configurable:!0,writable:!0,value:"inherit"}),Object.defineProperty(this,"filters",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lowestLevel",{enumerable:!0,configurable:!0,writable:!0,value:"debug"}),Object.defineProperty(this,"contextLocalStorage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.parent=r,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(r){let t=typeof r=="string"?r:r0,o=this.childrent,n=o instanceof B?o:o?.deref();return n==null&&(n=new B(this,...this.category,t),this.childrent="WeakRef"in pe?new WeakRef(n):n),typeof r=="string"||r.length===1?n:n.getChild(r.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks="inherit";this.filters.length>0;)this.filters.shift();this.lowestLevel="debug"}resetDescendants(){for(let r of Object.values(this.children))(r instanceof B?r:r.deref())?.resetDescendants();this.reset()}with(r){return new qn(this,{...r})}filter(r){for(let t of this.filters)if(!t(r))return!1;return this.filters.length<1?this.parent?.filter(r)??!0:!0}*getSinks(r){if(!(this.lowestLevel===null||pr(r,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks==="inherit")for(let t of this.parent.getSinks(r))yield t;for(let t of this.sinks)yield t}}emit(r,t){if(!(this.lowestLevel===null||pr(r.level,this.lowestLevel)<0||!this.filter(r))){for(let o of this.getSinks(r.level))if(!t?.has(o))try{o(r)}catch(n){let a=new Set(t);a.add(o),Wn.log("fatal","Failed to emit a log record to sink {sink}: {error}",{sink:o,error:n,record:r},a)}}}log(r,t,o,n){let a=B.getLogger().contextLocalStorage?.getStore()??{},s,l=typeof o=="function"?{category:this.category,level:r,timestamp:Date.now(),get message(){return fr(t,this.properties)},rawMessage:t,get properties(){return s==null&&(s={...a,...o()}),s}}:{category:this.category,level:r,timestamp:Date.now(),message:fr(t,{...a,...o}),rawMessage:t,properties:{...a,...o}};this.emit(l,n)}logLazily(r,t,o={}){let n=B.getLogger().contextLocalStorage?.getStore()??{},a,s;function l(){if((s==null||a==null)&&(s=t((i,...c)=>(a=i,mr(i,c))),a==null))throw new TypeError("No log record was made.");returns,a}this.emit({category:this.category,level:r,get message(){return l()0},get rawMessage(){return l()1},timestamp:Date.now(),properties:{...n,...o}})}logTemplate(r,t,o,n={}){let a=B.getLogger().contextLocalStorage?.getStore()??{};this.emit({category:this.category,level:r,message:mr(t,o),rawMessage:t,timestamp:Date.now(),properties:{...a,...n}})}debug(r,...t){typeof r=="string"?this.log("debug",r,t0??{}):typeof r=="function"?this.logLazily("debug",r):this.logTemplate("debug",r,t)}info(r,...t){typeof r=="string"?this.log("info",r,t0??{}):typeof r=="function"?this.logLazily("info",r):this.logTemplate("info",r,t)}warn(r,...t){typeof r=="string"?this.log("warning",r,t0??{}):typeof r=="function"?this.logLazily("warning",r):this.logTemplate("warning",r,t)}error(r,...t){typeof r=="string"?this.log("error",r,t0??{}):typeof r=="function"?this.logLazily("error",r):this.logTemplate("error",r,t)}fatal(r,...t){typeof r=="string"?this.log("fatal",r,t0??{}):typeof r=="function"?this.logLazily("fatal",r):this.logTemplate("fatal",r,t)}},qn=class wr{constructor(r,t){Object.defineProperty(this,"logger",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.logger=r,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(r){return this.logger.getChild(r).with(this.properties)}with(r){return new wr(this.logger,{...this.properties,...r})}log(r,t,o,n){this.logger.log(r,t,typeof o=="function"?()=>({...this.properties,...o()}):{...this.properties,...o},n)}logLazily(r,t){this.logger.logLazily(r,t,this.properties)}logTemplate(r,t,o){this.logger.logTemplate(r,t,o,this.properties)}debug(r,...t){typeof r=="string"?this.log("debug",r,t0??{}):typeof r=="function"?this.logLazily("debug",r):this.logTemplate("debug",r,t)}info(r,...t){typeof r=="string"?this.log("info",r,t0??{}):typeof r=="function"?this.logLazily("info",r):this.logTemplate("info",r,t)}warn(r,...t){typeof r=="string"?this.log("warning",r,t0??{}):typeof r=="function"?this.logLazily("warning",r):this.logTemplate("warning",r,t)}error(r,...t){typeof r=="string"?this.log("error",r,t0??{}):typeof r=="function"?this.logLazily("error",r):this.logTemplate("error",r,t)}fatal(r,...t){typeof r=="string"?this.log("fatal",r,t0??{}):typeof r=="function"?this.logLazily("fatal",r):this.logTemplate("fatal",r,t)}},Wn=Rr.getLogger("logtape","meta");function fr(e,r){let t=[],o="";for(let n=0;n<e.length;n++){let a=e.charAt(n),s=e.charAt(n+1);if(a==="{"&&s==="{")o=o+a,n++;else if(a==="}"&&s==="}")o=o+a,n++;else if(a==="{")t.push(o),o="";else if(a==="}"){let l;o.match(/^\s|\s$/)?l=o in r?ro:ro.trim():l=ro,t.push(l),o=""}else o=o+a}return t.push(o),t}function mr(e,r){let t=[];for(let o=0;o<e.length;o++)t.push(eo),o<r.length&&t.push(ro);return t}var Vn=hr(Bn()),fe=Vn.default,dr={debug:"DBG",info:"INF",warning:"WRN",error:"ERR",fatal:"FTL"},br="Deno"in globalThis&&"inspect"in globalThis.Deno&&typeof globalThis.Deno.inspect=="function"?(e,r)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...r}):fe!=null&&"inspect"in fe&&typeof fe.inspect=="function"?(e,r)=>fe.inspect(e,{maxArrayLength:1/0,maxStringLength:1/0,...r}):e=>JSON.stringify(e);function xr(e={}){let r=e.timestamp==null||e.timestamp==="date-time-timezone"?s=>new Date(s).toISOString().replace("T"," ").replace("Z"," +00:00"):e.timestamp==="date-time-tz"?s=>new Date(s).toISOString().replace("T"," ").replace("Z"," +00"):e.timestamp==="date-time"?s=>new Date(s).toISOString().replace("T"," ").replace("Z",""):e.timestamp==="time-timezone"?s=>new Date(s).toISOString().replace(/.*T/,"").replace("Z"," +00:00"):e.timestamp==="time-tz"?s=>new Date(s).toISOString().replace(/.*T/,"").replace("Z"," +00"):e.timestamp==="time"?s=>new Date(s).toISOString().replace(/.*T/,"").replace("Z",""):e.timestamp==="date"?s=>new Date(s).toISOString().replace(/T.*/,""):e.timestamp==="rfc3339"?s=>new Date(s).toISOString():e.timestamp,t=e.category??"·",o=e.value??br,n=e.level==null||e.level==="ABBR"?s=>drs:e.level==="abbr"?s=>drs.toLowerCase():e.level==="FULL"?s=>s.toUpperCase():e.level==="full"?s=>s:e.level==="L"?s=>s.charAt(0).toUpperCase():e.level==="l"?s=>s.charAt(0):e.level,a=e.format??(({timestamp:s,level:l,category:i,message:c})=>${s} [${l}] ${i}: ${c});return s=>{let l="";for(let p=0;p<s.message.length;p++)p%2===0?l+=s.messagep:l+=o(s.messagep);let i=r(s.timestamp),c=n(s.level),f=typeof t=="function"?t(s.category):s.category.join(t);return`${a({timestamp:i,level:c,category:f,message:l,record:s})}
}}var ra=xr(),Le="\x1B[0m",Pe={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},ve={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",strikethrough:"\x1B[9m"},Hn={debug:"blue",info:"green",warning:"yellow",error:"red",fatal:"magenta"};function zn(e={}){let r=e.format,t=typeof e.timestampStyle>"u"?"dim":e.timestampStyle,o=e.timestampColor??null,n=${t==null?"":vet}${o==null?"":Peo},a=t==null&&o==null?"":Le,s=typeof e.levelStyle>"u"?"bold":e.levelStyle,l=e.levelColors??Hn,i=typeof e.categoryStyle>"u"?"dim":e.categoryStyle,c=e.categoryColor??null,f=${i==null?"":vei}${c==null?"":Pec},p=i==null&&c==null?"":Le;return xr({timestamp:"date-time-tz",value(u){return br(u,{colors:!0})},...e,format({timestamp:u,level:m,category:E,message:T,record:N}){let v=l[N.level];return u=${n}${u}${a},m=${s==null?"":ves}${v==null?"":Pev}${m}${s==null&&v==null?"":Le},r==null?${u} ${m} ${f}${E}:${p} ${T}:r({timestamp:u,level:m,category:${f}${E}${p},message:T,record:N})}})}var ta=zn();var Yn=hr(Dn()),Kn=Yn.default;function H(){throw new Error("File sink is not available in the browser.")}var Jn={openSync:H,writeSync:H,flushSync:H,closeSync:H,statSync:H,renameSync:H},W=Kn,oa=W==null?Jn:{openSync(e){return W.openSync(e,"a")},writeSync:W.writeSync,flushSync:W.fsyncSync,closeSync:W.closeSync,statSync:W.statSync,renameSync:W.renameSync};var Tr=" must not return ",Qn="transformer",Zn="recoverer",Xn="defaultValue",z=Qn+Tr,U="called with ",Y=Xn+" must not be ",K=Zn+Tr;var es="Ok",_r="Err",Or=U+_r,kr=U+es,rs="Carrying E in "+_r+" instead of throwing it directly. See .cause",Ie="an instance of Error of the current realm.",pa="The thrown value is not "+Ie,fa="The contained E should be "+Ie,ts="This .cause is not "+Ie;function R(e){return e.ok}function y(e){return{ok:!0,val:e,err:null}}function g(e){return!e.ok}function b(e){return{ok:!1,val:null,err:e}}function h(e){return Nr(e,Or)}function J(e){return Fr(e,kr)}function Nr(e,r){if(g(e))throw new TypeError(r);return e.val}function Fr(e,r){if(R(e))throw new TypeError(r);return e.err}function F(e){return e.val}function S(e){return e.err}async function x(e,r){if(g(e))return e;let t=F(e),o=await r(t);return y(o)}async function _(e,r){if(R(e))return e;let t=S(e),o=await r(t);return b(o)}var me="null",Oi=z+me,ss=U+me,ki=Y+me,Ni=K+me;var de="undefined",vi=z+de,as=U+de,Ii=Y+de,Ai=K+de;var O=e=>e.ok?y(e):b({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Pr=async(e,r)=>{let t=new Request(e,r);try{return y(await globalThis.fetch(t))}catch(o){if(o instanceof DOMException&&o.name==="AbortError")return b({name:"AbortError",message:o.message,request:t});if(o instanceof TypeError)return b({name:"NetworkError",message:o.message,request:t});throw o}};var w=e=>{let{fetch:r=Pr,hostName:t="scrapbox.io",...o}=e;return{fetch:r,hostName:t,...o}};var k=e=>connect.sid=${e};function ge(e,r={}){if(e===null)return"null";if(Array.isArray(e))return us(e,r);switch(typeof e){case"string":return JSON.stringify(e);case"bigint":return${e}n;case"object":return e.constructor?.name!=="Object"?e.constructor?.name:ps(e,r);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function us(e,r){let{threshold:t=20}=r,o=e.map(s=>ge(s,r)),n=o.join(", ");if(n.length<=t)return${n};let a=o.join(,
);return[
${vr(2,a)}
]}function ps(e,r){let{threshold:t=20}=r,o=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(s=>${s.toString()}: ${ge(es,r)}),n=o.join(", ");if(n.length<=t)return{${n}};let a=o.join(,
);return{
${vr(2,a)}
}}function vr(e,r){let t=" ".repeat(e);return r.split(
).map(o=>${t}${o}).join(
)}function Ee(e,r,...t){let o;return Object.defineProperties(e,{name:{get:()=>o||(o=${r}(${t.map(n=>ge(n)).join(", ")}),o)}})}function Ir(e){return Array.isArray(e)}function Ar(e){return Ee(r=>Ir(r)&&r.every(t=>e(t)),"isArrayOf",e)}function Ae(e){let r=new Set(e);return Ee(t=>r.has(t),"isLiteralOneOf",e)}function Me(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function ye(e){return typeof e=="string"}var L=async(e,r)=>{let t=e.response.clone(),o=Ae(r);try{let n=await t.json();if(!Me(n))return;if(t.status===422){if(!ye(n.message))return;for(let a of["NoQueryError","InvalidURLError"])if(r.includes(a))return{name:a,message:n.message}}return!o(n.name)||!ye(n.message)?void 0:n.name==="NotLoggedInError"?!Me(n.detals)||!ye(n.detals.project)||!Ar(fs)(n.detals.loginStrategies)?void 0:{name:n.name,message:n.message,details:{project:n.detals.project,loginStrategies:n.detals.loginStrategies}}:{name:n.name,message:n.message}}catch(n){if(n instanceof SyntaxError)return;throw n}},fs=Ae(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var oe=e=>e.replaceAll(" ","_").toLowerCase(),Mr=e=>e.replaceAll("_"," ");var he="null or undefined",Q=z+he,ms=U+he,Ue=Y+he,Re=K+he;var Cr=(e,r)=>{let{sid:t,hostName:o}=w(r??{});return new Request(https://${o}/api/projects/${e},t?{headers:{Cookie:k(t)}}:void 0)},jr=async e=>x(await _(O(e),async r=>await L(r,["NotFoundError","NotLoggedInError","NotMemberError"])??r),r=>r.json()),$r=(()=>{let e=async(r,t)=>{let{fetch:o}=w(t??{}),n=Cr(r,t),a=await o(n);return g(a)?a:jr(h(a))};return e.toRequest=Cr,e.fromResponse=jr,e})(),Br=(e,r)=>{let{sid:t,hostName:o}=w(r??{}),n=new URLSearchParams(e.map(a=>["ids",a]));return new Request(https://${o}/api/projects?${n},t?{headers:{Cookie:k(t)}}:void 0)},Dr=async e=>x(await _(O(e),async r=>await L(r,["NotLoggedInError"])??r),r=>r.json()),Gr=(()=>{let e=async(r,t)=>{let{fetch:o}=w(t??{}),n=await o(Br(r,t));return g(n)?n:Dr(h(n))};return e.toRequest=Br,e.fromResponse=Dr,e})();var qr=(e,r)=>{let{sid:t,hostName:o,followingId:n}=w(r??{});return new Request(https://${o}/api/pages/${e}/search/titles${n??followingId=${n}:""},t?{headers:{Cookie:k(t)}}:void 0)},Wr=async e=>x(await _(O(e),async r=>r.response.status===422?{name:"InvalidFollowingIdError",message:await r.response.text()}:await L(r,["NotFoundError","NotLoggedInError"])??r),r=>r.json().then(t=>({pages:t,followingId:r.headers.get("X-following-id")??""}))),Es=(()=>{let e=async(r,t)=>{let o=await w(t??{}).fetch(qr(r,t));return g(o)?o:Wr(h(o))};return e.toRequest=qr,e.fromResponse=Wr,e})();async function*Vr(e,r){let t;do{let o=await Es(e,{followingId:t,...r});if(g(o)){yield o;return}let n=h(o);yield y(n.pages),t=n.followingId}while(t)}var ys=new TextEncoder().encode("0123456789abcdef"),Hr=new Uint8Array(128).fill(16);ys.forEach((e,r)=>Hr[e]=r);new TextEncoder().encode("ABCDEF").forEach((e,r)=>Hr[e]=r+10);var hs=new TextEncoder().encode("0123456789abcdef"),zr=new Uint8Array(128).fill(16);hs.forEach((e,r)=>zr[e]=r);new TextEncoder().encode("ABCDEF").forEach((e,r)=>zr[e]=r+10);async function*Yr(e){let r=[],t=[],o=new Map,n=[];for(let a of e)a.isValid&&(a.id?a.isMember||r.push(a.id):t.push(a.name),n.push(a.name),o.set(a.name,a.checked));for(let a=0;a<r.length;a+=50){let s=r.slice(a,a+50);if(s.length===0)break;s.length===1&&s.push(s[0]);let l=await Gr(s);if(g(l)){t=n;break}for(let i of h(l).projects)o.has(i.name)&&(yield y({...i,checked:o.get(i.name)??0}))}for(let a of t){let s=await $r(a);yield R(s)?y({...h(s),checked:o.get(a)??0}):b({...J(s),project:a})}}var Be=(e,r)=>r.some(t=>e instanceof t),Kr,Jr;function Rs(){return Kr||(Kr=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ws(){return Jr||(Jr=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var De=new WeakMap,Ce=new WeakMap,be=new WeakMap;function bs(e){let r=new Promise((t,o)=>{let n=()=>{e.removeEventListener("success",a),e.removeEventListener("error",s)},a=()=>{t($(e.result)),n()},s=()=>{o(e.error),n()};e.addEventListener("success",a),e.addEventListener("error",s)});return be.set(r,e),r}function xs(e){if(De.has(e))return;let r=new Promise((t,o)=>{let n=()=>{e.removeEventListener("complete",a),e.removeEventListener("error",s),e.removeEventListener("abort",s)},a=()=>{t(),n()},s=()=>{o(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",a),e.addEventListener("error",s),e.addEventListener("abort",s)});De.set(e,r)}var $e={get(e,r,t){if(e instanceof IDBTransaction){if(r==="done")return De.get(e);if(r==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return $(e[r])},set(e,r,t){return e[r]=t,!0},has(e,r){return e instanceof IDBTransaction&&(r==="done"||r==="store")?!0:r in e}};function et(e){$e=e($e)}function Ts(e){return ws().includes(e)?function(...r){return e.apply(Ge(this),r),$(this.request)}:function(...r){return $(e.apply(Ge(this),r))}}function _s(e){return typeof e=="function"?Ts(e):(e instanceof IDBTransaction&&xs(e),Be(e,Rs())?new Proxy(e,$e):e)}function $(e){if(e instanceof IDBRequest)return bs(e);if(Ce.has(e))return Ce.get(e);let r=_s(e);return r!==e&&(Ce.set(e,r),be.set(r,e)),r}var Ge=e=>be.get(e);function rt(e,r,{blocked:t,upgrade:o,blocking:n,terminated:a}={}){let s=indexedDB.open(e,r),l=$(s);return o&&s.addEventListener("upgradeneeded",i=>{o($(s.result),i.oldVersion,i.newVersion,$(s.transaction),i)}),t&&s.addEventListener("blocked",i=>t(i.oldVersion,i.newVersion,i)),l.then(i=>{a&&i.addEventListener("close",()=>a()),n&&i.addEventListener("versionchange",c=>n(c.oldVersion,c.newVersion,c))}).catch(()=>{}),l}function tt(e,{blocked:r}={}){let t=indexedDB.deleteDatabase(e);return r&&t.addEventListener("blocked",o=>r(o.oldVersion,o)),$(t).then(()=>{})}var Os=["get","getKey","getAll","getAllKeys","count"],ks=["put","add","delete","clear"],je=new Map;function Qr(e,r){if(!(e instanceof IDBDatabase&&!(r in e)&&typeof r=="string"))return;if(je.get(r))return je.get(r);let t=r.replace(/FromIndex$/,""),o=r!==t,n=ks.includes(t);if(!(t in(o?IDBIndex:IDBObjectStore).prototype)||!(n||Os.includes(t)))return;let a=async function(s,...l){let i=this.transaction(s,n?"readwrite":"readonly"),c=i.store;return o&&(c=c.index(l.shift())),(await Promise.all([c[t](...l),n&&i.done]))[0]};return je.set(r,a),a}et(e=>({...e,get:(r,t,o)=>Qr(r,t)||e.get(r,t,o),has:(r,t)=>!!Qr(r,t)||e.has(r,t)}));var Ns=["continue","continuePrimaryKey","advance"],Zr={},qe=new WeakMap,ot=new WeakMap,Fs={get(e,r){if(!Ns.includes(r))return e[r];let t=Zr[r];return t||(t=Zr[r]=function(...o){qe.set(this,ot.get(this)[r](...o))}),t}};async function*Ss(...e){let r=this;if(r instanceof IDBCursor||(r=await r.openCursor(...e)),!r)return;r=r;let t=new Proxy(r,Fs);for(ot.set(t,r),be.set(t,Ge(r));r;)yield t,r=await(qe.get(t)||r.continue()),qe.delete(t)}function Xr(e,r){return r===Symbol.asyncIterator&&Be(e,[IDBIndex,IDBObjectStore,IDBCursor])||r==="iterate"&&Be(e,[IDBIndex,IDBObjectStore])}et(e=>({...e,get(r,t,o){return Xr(r,t)?Ss:e.get(r,t,o)},has(r,t){return Xr(r,t)||e.has(r,t)}}));var nt,We=async()=>{let e=te(["@takker/cosense-storage","open"]);return nt??=await rt("scrapbox-storage",4,{upgrade(r,t,o){e.infostart updating DB: ${t} -> ${o};let n=Date.now();for(let l of r.objectStoreNames)r.deleteObjectStore(l);r.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let s=r.createObjectStore("projects",{keyPath:"id"});s.createIndex("checked","checked"),s.createIndex("name","name"),e.infofinish updating DB: ${Date.now()-n}ms},blocked(r,t){let o=The database "@takker/cosense-storage"(v${t}) is blocked because the older one (v${r}) is opened in other tabs.
Please close the other tabs and reload this page.;e.error(o),alert(o)},blocking(r,t){let o=The database "@takker/cosense-storage"(v${r}) is blocking the newer one (v${t}) opened.
Please close this page.;e.error(o),alert(o)}}),nt};var st=(e,r)=>(Ve||(Ve=new BroadcastChannel(it),Ve.addEventListener("message",t=>at(t.data))),xe.set(r,new Set(e).union(xe.get(r)??new Set)),()=>xe.delete(r)),He=(e,r)=>{if((r.added?.size??0)+(r.updated?.size??0)+(r.deleted?.size??0)===0)return;let t={type:"links:changed",project:e,diff:r};at(t);let o=new BroadcastChannel(it);o.postMessage(t),o.close()},at=e=>{for(let[r,t]of xe)t.has(e.project)&&r(e)},it="scrapbox-storage-notify",Ve,xe=new Map;var Ls=Math.pow(10,8)*24*60*60*1e3,ag=-Ls;var Ps=3600;var lt=Ps*24,ig=lt*7,vs=lt*365.2425,Is=vs/12,lg=Is*3,ze=Symbol.for("constructDateFrom");function ct(e,r){return typeof e=="function"?e(r):e&&typeof e=="object"&&ze in e?e[ze](r):e instanceof Date?new e.constructor(r):new Date(r)}function ut(e,r){return ct(r||e,e)}function Ye(e){return Math.trunc(+ut(e)/1e3)}var pt=async(e,r)=>{let t=await We(),o=te(["@takker/cosense-storage","check"]),n=new Map;try{{o.debugcheck updates of links...;let s=new Set,l=t.transaction("projects","readwrite"),i=Ye(new Date),c=i-600;for await(let u of l.store.index("checked").iterate(IDBKeyRange.lowerBound(c,!0))){let m=u.value;if(m.isValid===!1){s.add(m.id);continue}s.add(m.name);let E=m.checked;if(E+r>i||m?.updating&&E>c)continue;let T=structuredClone(m);T.updating=!0,n.set(m.id,T),u.update(T)}let f=[],p=l.store.index("name");for(let u of e)s.has(u)||f.push(p.get(u).then(m=>{m?.updating&&(m?.checked??0)>c||n.set(u,m??As(u))}));if(await Promise.all(f),await l.done,n.size===0){o.debugchecked. No project needs upgrade.;return}o.debugchecked. ${n.size} projects maybe need upgrade.}let a=Ye(new Date);for await(let s of Yr(n.values())){if(g(s)){let{project:E,name:T}=J(s);switch(T){default:continue;case"NotFoundError":o.warn("${E}" is not found.);break;case"NotMemberError":o.warn(You are not a member of "${E}".);break;case"NotLoggedInError":o.warn(You are not a member of "${E}" or You are not logged in yet.);break}n.set(E,{id:E,name:E,checked:a,updating:!1,isValid:!1,reason:T});continue}let{checked:l,...i}=h(s);if(i.updated<l){o.debugno updates in "${i.name}",n.set(i.name,{...i,isValid:!0,checked:a,updating:!1});continue}o.debugstart downloading and storing links of "${i.name}";let c=new Set(await t.getAllKeysFromIndex("titles","project",i.name)),f=0,p=0;for await(let E of Vr(i.name)){if(g(E)){let{name:A,message:M}=J(E);o.errorFailed to get links of "${i.name}" with ${A}: ${M};break}let T=h(E),N={},v=t.transaction("titles","readwrite");await Promise.all(T.map(async A=>{let M={...A,project:i.name},ne=await v.store.get(A.id);if(!ne)return N.added?.set?.(A.id,M)??(N.added=new Map([[A.id,M]])),v.store.add(M);if(c.delete(A.id),!!Ms(M,ne))return N.updated?.set?.(A.id,[ne,M])??(N.updated=new Map([[A.id,[ne,M]]])),v.store.put(M)})),await v.done,f+=N.added?.size??0,p+=N.updated?.size??0,o.debugUpdating "/${i.name}": +${f} pages, ~${p} pages,He(i.name,N)}let u=t.transaction("titles","readwrite"),m=new Map((await Promise.all([...c].map(async E=>{let T=await u.store.get(E);if(!T)return[];let N=[[E,T]];return await u.store.delete(E),N}))).flat());await u.done,o.debugFinish downloading and storing links of "${i.name}",o.debugUpdate "/${i.name}": +${f} pages, ~${p} pages, -${m.size} pages,n.set(i.name,{...i,isValid:!0,checked:a,updating:!1}),He(i.name,{deleted:m})}}finally{let a=t.transaction("projects","readwrite");await Promise.all([...n].map(([,s])=>(s.updating=!1,a.store.put({...s})))),await a.done}},ft=async e=>{let r=[...new Set(e)];if(r.length===0)return[];let t=Date.now(),n=(await We()).transaction("titles","readonly"),a=n.store.index("project"),s=(await Promise.all(r.map(i=>a.getAll(i)))).flat();return await n.done,te(["@takker/cosense-storage","load"]).debugRead ${s.length} links from ${r.length} projects in ${Date.now()-t}ms,s},As=e=>({name:e,displayName:e,id:"",isValid:!0,publicVisible:!0,isMember:!0,loginStrategies:[],theme:"default",gyazoTeamsName:null,translation:!0,infobox:!0,checked:0,updated:0,created:0,updating:!0}),Ms=(e,r)=>e.updated>r.updated||e.links.sort().join()!==r.links.sort().join();globalThis.Deno||tt("userscript-links").catch(e=>console.error(e));var mt=e=>{let r=new Map,t=[...e].reverse();{let s=1;for(let l of t){r.set(l,(r.get(l)??0)|s);let i=l.toLowerCase();r.set(i,(r.get(i)??0)|s);let c=l.toUpperCase();r.set(c,(r.get(c)??0)|s),s<<=1}}let o=t.length,n=~(-1<<o),a=1<<o-1;return s=>{let l=0,i=n,c=[...s].reverse(),f=[],p=c.length;f[p]=o;for(let u of c){let m=r.get(u)??0,E=m|l,T=(m&i)+i^i|m,N=l|~(T|i),v=i&T;f[p-1]=f[p]+(N&a?1:v&a?-1:0),i=v<<1|~(E|N<<1),l=N<<1&E,p--}return f}};var Us=[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],dt=e=>{let r=Mr(e.trim()).split(/\s+/).sort((t,o)=>o.length-t.length);if(!(r.length===0||r.every(t=>t==="")))return t=>r.reduce((o,n)=>Cs(n,o),t)},Cs=(e,r)=>{let t=[...e].length,o=Us[t],n=mt(e);return r.flatMap(({title:a,dist:s,matches:l,...i})=>{l??=[],s??=0;let c=n(a).flatMap((p,u)=>p<=o&&l.every(([m,E])=>u+t<=m||E<u)?[[u,p]]:[]);if(c.length===0)return[];let f=c.reduce((p,[u,m])=>(p.dist<=m||(p.dist=m,p.start=u),p),{dist:t,start:0});return l.push([f.start,f.start+t-1]),[{title:a,dist:f.dist+s,matches:l,...i}]})};var Et=e=>{let r=new Map;for(let t of e)Ke(r,t);return r},yt=(e,r)=>{let t=new Map(e);if(r.added)for(let[,o]of r.added)Ke(t,o);if(r.updated)for(let[,[o,n]]of r.updated)gt(t,o),Ke(t,n);if(r.deleted)for(let[,o]of r.deleted)gt(t,o);return t},Ke=(e,r)=>{let t=oe(r.title),o=e.get(t);if((o?.updated??0)>r.updated)return;let n=o?.metadata??new Map;n.set(r.project,{image:r.image}),e.set(t,{title:r.title,titleLc:t,updated:r.updated,linked:o?.linked??0,metadata:n});for(let a of r.links){let s=oe(a),l=e.get(s),i=l?.metadata??new Map;i.set(r.project,i.get(r.project)??{image:r.image}),e.set(s,{title:l?.title??a,titleLc:s,updated:l?.updated??0,linked:(l?.linked??0)+1,metadata:i})}},gt=(e,r)=>{let t=oe(r.title),o=e.get(t);if(!o||(o.updated??0)>r.updated)return;let n=o.metadata;n.delete(r.project),n.size<=0?e.delete(t):e.set(t,{title:o.title,titleLc:t,updated:r.updated,linked:o.linked,metadata:n});for(let a of r.links){let s=oe(a),l=e.get(s);if(!l)continue;let i=l.metadata;i.delete(r.project),i.size<=0?e.delete(s):e.set(s,{title:l.title,titleLc:s,updated:r.updated,linked:l.linked-1,metadata:i})}};var Je=ir("scrapbox-select-suggestion:search.worker.ts"),Te=[],ht=[],Rt=()=>{},wt={async load(e){if(Je.debug("start loading source"),!Qe(ht,e)){ht=[...e],Rt();let t=await ft(e),o=Et(t);Te=[...o.values()],await pt(e,600),Rt=st(e,({diff:n})=>{o=yt(o,n),Te=[...o.values()]})}return Te.length},async search(e,r,t){if(Je.debug("start searching: ",e),!e.trim())return;let o=dt(e);if(!o){t([],1);return}let n=[...Te],a=Math.ceil(n.length/r);for(let s=0;s<a;s++){let l=(s+1)/a,i=[...o(n.values().drop(s*r).take(r))];if(Je.debug(${s}/${a} search result:`,i),await t(i,l))return;await Xe(0)}}},js=e=>typeof e=="object"&&!!e&&"SharedWorkerGlobalScope"in e;js(self)?self.addEventListener("connect",e=>Z(wt,e.ports0)):Z(wt);
/*! Bundled license information:
comlink/dist/esm/comlink.mjs:
(**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*)
*/
code:takker-project.css
@import"https://fonts.googleapis.com/css?family=M+PLUS+Rounded+1c";html,body,#editor,.grid li{font-family:helvetica,arial,"M PLUS Rounded 1c",Sawarabi Gothic,Noto Sans JP,sans-serif}body *:before{--code-number-color: var(--code-color, #342d9c)}.section-title{counter-reset:codeline}.code-block span.indent code.code-body{counter-increment:codeline;margin-left:-1.5em;padding-left:2.3em}.code-block span.indent code.code-body:before{content:counter(codeline);position:absolute;display:inline-block;z-index:10;margin-left:-2.4em;width:2em;padding-right:.2em;text-align:right;vertical-align:bottom;border-right:solid 1px #fff;color:var(--code-number-color)}.code-block span.indent code.code-body:before{opacity:.5}.cursor-line .code-block span.indent code.code-body:before{opacity:1;font-weight:bolder;background-color:var(--accent-color)}.navbar-form .dropdown.open .dropdown-menu{min-width:100%;max-height:calc(100vh - 130px)!important;overflow-y:auto}.page-list-item.pin+.page-list-item:not(.pin){grid-column-start:1}.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):not([href^="https://scrapbox.io"]):after{font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";font-weight:900;font-size:.8rem;content:" ";display:inline-block}.line .deco-\.{font-size:.8em;position:relative;top:-.5em}.line:not(.cursor-line) .deco-\. a:is(.page-link:not(.icon),.link) span:not(.empty-char-index)+span+span~span{display:inline-block;width:0;text-indent:-9999px}.line:not(.cursor-line) .deco-\. .page-link:not(.icon) span.empty-char-index~span.char-index{display:inherit;width:inherit;text-indent:inherit}.line:not(.cursor-line) .deco-\. a.page-link:not(.icon) span.empty-char-index+span:before{content:"#"}.line .deco-\. :is(.page-link:not(.icon),.link):before{display:inline-block;min-width:1.15em;padding-left:1px;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";text-align:center;vertical-align:middle;font-weight:900;content:""}.line .deco-\..deco-\/{font-style:initial}.line .deco-\..deco-\/ :is(.page-link:not(.icon),.link):before{font-weight:400;content:""}div.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):is(href$=".pdf",[href^="https://twitter.com"],[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):after{display:none}.line span:not(.deco-\.)>span>a.link:is(href$=".pdf",[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{display:inline-block;width:1em;height:1em;vertical-align:-1px;text-align:center;background-size:contain;background-repeat:no-repeat;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands"}.line a.link:not(.icon)href$=".pdf":before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"]):before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{content:"";font-weight:400;margin-right:3px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index{display:inline-block;width:0;text-indent:-9999px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index:nth-of-type(30)~span.char-index{display:inherit;width:inherit;text-indent:inherit}.deco-\"{border-radius:.2em;padding:0 .4em;background-color:#8080801a;font-size:95%;font-style:italic}.deco-\":before{color:#a0a0a0;font-size:85%;font-family:"Font Awesome 5 Free";content:"";font-weight:900;vertical-align:super}.line .indent-mark .dot{opacity:0}.line .indent-mark .c-0+.dot{opacity:1}.line .indent-mark .c-1+.dot{opacity:.8}.line .indent-mark .c-2+.dot{opacity:.6}.line .indent-mark .c-3+.dot{opacity:.4}.line .indent-mark .c-4+.dot{opacity:.2}.line strong:not(class){background:linear-gradient(transparent 60%,#abff4f99 60% 100%)}.time-range .lines{user-select:unset;-webkit-user-select:unset}.line:not(.cursor-line) .deco-\|{display:inline-flex}.line .deco-\| img.image{object-fit:contain;margin:0}.line class^=level .deco-\|{flex-wrap:wrap}.line .level-1 .deco-\|>span{width:100%}.line .level-2 .deco-\|>span{width:50%}.line .level-3 .deco-\|>span{width:calc(100%/3)}.line .level-4 .deco-\|>span{width:25%}.line .level-5 .deco-\|>span{width:20%}.line class^=level .deco-\| img.image{object-fit:cover;width:100%;height:100%}.line .deco-\|>span,.line class^=level .deco-\|>span{overflow:hidden}.line .deco-\| img.image,.line class^=level .deco-\| img.image{margin:.2em}.selections .popup-menu .button-container .button:empty{display:none}.strong-button>strong,.italic-button>i,.strike-button>strike{display:inline-block;width:0;text-indent:-9999px}.selections .popup-menu .button-container .button:is(.link-button,.new-page-button,.copy-plain-button){font-size:0}.selections .popup-menu .button-container .button{font-family:Open Sans,Helvetica,Arial,Hiragino Sans,sans-serif,"Font Awesome 5 Free","Font Awesome 5 Brands";font-size:11px;line-height:20px;font-weight:600;display:inline-block;text-align:center}.link-button:after{font-size:11px;content:""}.strong-button:after{content:""}.italic-button:after{content:""}.strike-button:after{content:""}.copy-plain-button:after{font-size:11px;content:""}.new-page-button:after{font-size:11px;content:""}.line a.iconhref$="/hr"{pointer-events:none}.page-column{grid-template-columns:var(--page-column-columns, 46px minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas, "spacer page menu")}@media (991px < width){.page-column:has(.page-sidebar){grid-template-columns:var(--page-column-columns-sidebar, minmax(200px, 3fr) minmax(170px, 1fr) min-content);grid-template-areas:var(--page-column-areas-sidebar, "page sidebar menu")}}@media (min-width: 768px) and (max-width: 991px){.page-column{grid-template-columns:var(--page-column-columns-768, minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas-768, "page menu")}}@media (max-width: 767px){.page-column{display:grid;grid-template-columns:var(--page-column-columns-767, 1fr);grid-template-areas:var(--page-column-areas-767, "page")}}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: minmax(200px, 960px) min-content;--page-column-areas-sidebar: "page menu"}.page-sidebar:not(:has(.definition-term)){display:none}.deco-\#{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace}.grid li.page-list-item a .pin{background-color:transparent;background-image:none}.grid li.page-list-item a .pin:after{content:"";font-family:"Font Awesome 5 Free";font-weight:900;font-size:20px;color:#1f915e;bottom:0}.deco-\>{position:absolute;width:100%;text-align:right}li.page-list-item.grid-style-item div.title{-webkit-line-clamp:2}.line.number-list .dot{background-color:transparent!important;display:list-item}.line.number-list .dot:before{display:block;position:absolute;font-family:"Font Awesome 5 Free";top:-11px;content:"";font-weight:900;font-size:11px;color:#c9c9c9;opacity:0}.line.number-list .c-0+.dot:before{opacity:1}.line.number-list .c-1+.dot:before{opacity:.8}.line.number-list .c-2+.dot:before{opacity:.6}.line.number-list .c-3+.dot:before{opacity:.4}.line.number-list .c-4+.dot:before{opacity:.2}img[src^="https://i.kakeru.app"]{background-color:#fff}.brand-icon{display:none!important}.navbar-brand:before{content:"";font-family:"Font Awesome 5 Free";font-size:28px;font-weight:900;color:#bbb}body{--empty-page-link-color: #309b98;--empty-page-link-hover-color: #28807d}.project-home .title{font-size:2rem}.expandable-menu{max-width:calc(100% - 232px)}@media screen and (min-width: 768px) and (max-width: 991px){.expandable-menu{max-width:calc(100% - 247px)}}@media screen and (min-width: 992px) and (max-width: 1260px){.expandable-menu{max-width:calc(100% - 262px)}}.line .indent-mark .dot{top:11px;width:6px;height:3px;background-color:#c9c9c9}.dropdown-menu,.drawer .drawer-menu{background-color:var(--dropdown-menu-bg, #fff);border:var(--dropdown-menu-border, unset)}.dropdown-menu>li>a,.drawer .drawer-menu ul li a,.page-menu ul>li>div{color:var(--dropdown-menu-text-color, #333)}.dropdown-menu>li>a:active,.drawer-menu ul li a:active,data-hover-visible :is(.dropdown-menu,.drawer-menu)>li>:is(a:hover,a:focus){color:var(--dropdown-menu-text-hover-color, #262626);background-color:var(--dropdown-menu-text-hover-bg, #f5f5f5)}:is(.dropdown-menu,.drawer-menu) .divider{color:var(--dropdown-menu-divider-color, #e5e5e5)}@media (prefers-color-scheme: dark){body{--body-bg: #202228;--navbar-bg: rgba(55, 59, 68, .3);--navbar-icon-color: #fff;--navbar-icon-active-color: #338c46;--navbar-icon-hovered-color: #338c46;--search-form-bg: rgba(255, 255, 255, .13);--search-form-icon-color: #fff;--search-form-icon-focus-color: #4a4a4a;--card-title-color: #f0f0f0;--card-title-bg: #2b2e38;--card-bg: #373b44;--card-hover-bg: rgba(0, 0, 0, .1);--card-active-bg: rgba(229, 229, 229, .1);--card-backside: #545860;--card-description-color: #c4c4c4;--card-description-link-color: #80c9fe;--card-description-code-color: #ccc;--card-box-shadow-color: #000;--card-box-shadow: 0 2px 0 var(--card-box-shadow-color);--card-box-hover-shadow: 0 2px 0 rgba(0, 0, 0, .23);--card-title-bg-pinned: #2b2e38;--relation-label-bg: #2b2e38;--relation-label-text: #dddede;--relation-label-links-bg: #80c9fe;--relation-label-links-text: #202228;--relation-label-empty-bg: #fb7476;--relation-label-empty-text: #fff;--tool-color: #535863;--tool-light-color: #353b48;--tool-badge-bg: #2b2e38;--tool-bg: #2b2e38;--tool-text-color: #dddede;--new-button-vertical-color: #fff;--new-button-horizontal-color: #fff;--new-button-bg: #46af5d;--new-button-hover-bg: #338c46;--new-button-active-bg: #346447;--telomere-border: #545863;--telomere-unread: #56a066;--page-text-color: rgba(255, 255, 255, .87);--page-link-color: #80c9fe;--page-link-hover-color: #6a9ec6;--page-link-color-cursor-line: #a985e4;--page-bg: #373b44;--empty-page-link-color: #fb7476;--empty-page-link-hover-color: #b47576;--line-title-color: rgba(255, 255, 255, .87);--line-permalink-color: rgba(234, 218, 74, .35);--code-color: #ccc;--code-bg: rgba(0, 0, 0, .18);--quote-bg-color: rgba(0, 0, 0, .2);--cursor-color: #fff}body{--dark-theme-bg: #24292f;--dark-theme-border: solid 1px #888}body{--navbar-bg: rgba(2, 167, 137, .5)}body{--new-button-horizontal-color: #b44a29;--new-button-vertical-color: var(--new-button-horizontal-color);--new-button-bg: #f4835f;--new-button-hover-bg: #f2693e;--new-button-active-bg: #ef4c17}body{--tool-color: #535863;--tool-light-color: #353b48;--tool-badge-bg: #2b2e38;--tool-bg: #2b2e38;--tool-text-color: #dddede;--body-headings-color: var(--tool-color)}body{--code-line-number-color: #D181FF;--cursor-code-line-number-color: #FF00F0}body{--dropdown-menu-bg: #373b44;--dropdown-menu-border: 1px solid #8888882d;--dropdown-menu-text-color: var(--page-text-color);--dropdown-menu-divider-color: #e5e5e5;--dropdown-menu-text-hover-color: var(--page-text-color);--dropdown-menu-text-hover-bg: #373b44}body{--card-title-bg: var(--navbar-bg);--card-title-bg-pinned: var(--navbar-bg)}html:not(data-display-style^=presentation) .page{box-shadow:none;border:solid 1px #888}.table-block .cell{border-bottom:solid 1px #888}.line code.helpfeel{background-color:var(--code-bg)}.line span.code-block .code-block-start{border:solid 1px #66667F;background-color:#272822;padding:2px 5px;color:#7c9ff7}.line span.code-block .code-block-start a{color:#7c9ff7}.code-block{--code-bg: #2d2b57;--code-color: #e3dfff;font-weight:400}code.highlight .hljs-subst{color:#e3dfff}code.highlight .hljs-title{color:#fad000;font-weight:400}code.highlight .hljs-name{color:#a1feff}code.highlight .hljs-tag{color:#fff}code.highlight .hljs-attr{color:#f8d000;font-style:italic}code.highlight :is(.hljs-built_in,.hljs-selector-tag,.hljs-section){color:#fb9e00}code.highlight .hljs-keyword{color:#fb9e00}code.highlight :is(.hljs-string,.hljs-attribute,.hljs-symbol,.hljs-bullet,.hljs-addition,.hljs-code,.hljs-regexp,.hljs-selector-class,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-template-tag,.hljs-quote,.hljs-deletion){color:#4cd213}code.highlight :is(.hljs-meta,.hljs-meta .hljs-string){color:#fb9e00}code.highlight .hljs-comment{color:#ac65ff}code.highlight :is(.hljs-keyword,.hljs-selector-tag,.hljs-literal,.hljs-name){font-weight:400}code.highlight :is(.hljs-literal,.hljs-number){color:#fa658d}code.highlight .hljs-emphasis{font-style:italic}code.highlight .hljs-strong{font-weight:700}code.highlight :is(.hljs-selector-pseudo,.hljs-deletion){color:#e06c75}::selection{color:unset;background:#0073e680}.selection{background-color:#fff7}.line .indent-mark .dot{background-color:gray}.line.number-list .dot:before{color:gray}}.page-linkhref*=".@":before{content:"✅"}.page-linkhref*="@20":not(href*=".@"):before{content:"⬜"}html:not(data-display-style^=presentation) body{background-image:url(https://i.gyazo.com/8d65198f72652e8887d2c941f39805b4.png)}.grid li.page-list-item a .description .formula{display:inline}.page-link:is(href^="/tosuke-notes",href^="/blu3mo/",href^="/masuilab/",href^="/takker-memex",href^="/takker-books",href^="/takker-CEPM",href^="/takker-MBRC",href^="/takker-CVBH",href^="/takker-CVST",href^="/takker-PS",href^="/takker-SM",href^="/takker-SoM",href^="/takker-private"):before{content:"🔒"}
code:takker-user.css
@media screen and (min-width: 400px){html:is(data-os*=android,data-os*=ios) .popup-menu .button-container .button,.popup-menu .button-container .button:is(data-os*=android,data-os*=ios){min-width:3em}}:not(data-display-style^=presentation) .page-column{--page-column-columns: 100px minmax(200px, 960px) min-content 1fr;--page-column-areas: "spacer page menu spacer2";--page-column-columns-sidebar: 100px minmax(200px, 3fr) minmax(170px, 1fr) min-content;--page-column-areas-sidebar: "spacer page sidebar menu";--page-column-columns-768: var(--page-column-columns);--page-column-areas-768: var(--page-column-areas);--page-column-columns-767: minmax(60px, calc(100% / 767 * 100)) 1fr;--page-column-areas-767: "spacer page"}@container (width > 1236px){:not(data-display-style^=presentation) .page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}data-display-style^=presentation data-userscript-name="takker-scheduler/timeline-wedget"{display:none}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: var(--page-column-columns);--page-column-areas-sidebar: var(--page-column-areas)}.page-sidebar:not(:has(.definition-term)){display:none}.search-form .form-group input:focus{color:var(--page-text-color);background-color:var(--search-form-bg, rgba(255,255,255,.15))}.line span.code-block .code-block-start title=css a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=html a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=javascript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=typescript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cpp a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=c a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cs a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=python a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=toml a:before,.line span.code-block .code-block-start title=json a:before,.line span.code-block .code-block-start title=yaml a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=xml a:before{content:"謹";display:inline-block}.line span.code-block .code-block-start title=gitignore a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=markdown a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=txt a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=csv a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=fish a:before,.line span.code-block .code-block-start title=bash a:before,.line span.code-block .code-block-start title=zsh a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=dos a:before{content:"";display:inline-block}.line code,.line span.code-block{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace;font-size:105%}data-os=android{.page-column{div.page-menu{position:fixed;display:flex;flex-direction:row-reverse;right:0;.dropdown-menu-top,.dropdown-menu-right{top:46px}}}}
code:takker-memex.css
body *:before{--code-number-color: var(--code-color, #342d9c)}.section-title{counter-reset:codeline}.code-block span.indent code.code-body{counter-increment:codeline;margin-left:-1.5em;padding-left:2.3em}.code-block span.indent code.code-body:before{content:counter(codeline);position:absolute;display:inline-block;z-index:10;margin-left:-2.4em;width:2em;padding-right:.2em;text-align:right;vertical-align:bottom;border-right:solid 1px #fff;color:var(--code-number-color)}.code-block span.indent code.code-body:before{opacity:.5}.cursor-line .code-block span.indent code.code-body:before{opacity:1;font-weight:bolder;background-color:var(--accent-color)}.navbar-form .dropdown.open .dropdown-menu{min-width:100%;max-height:calc(100vh - 130px)!important;overflow-y:auto}.page-list-item.pin+.page-list-item:not(.pin){grid-column-start:1}.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):not([href^="https://scrapbox.io"]):after{font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";font-weight:900;font-size:.8rem;content:" ";display:inline-block}.line .deco-\.{font-size:.8em;position:relative;top:-.5em}.line:not(.cursor-line) .deco-\. a:is(.page-link:not(.icon),.link) span:not(.empty-char-index)+span+span~span{display:inline-block;width:0;text-indent:-9999px}.line:not(.cursor-line) .deco-\. .page-link:not(.icon) span.empty-char-index~span.char-index{display:inherit;width:inherit;text-indent:inherit}.line:not(.cursor-line) .deco-\. a.page-link:not(.icon) span.empty-char-index+span:before{content:"#"}.line .deco-\. :is(.page-link:not(.icon),.link):before{display:inline-block;min-width:1.15em;padding-left:1px;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";text-align:center;vertical-align:middle;font-weight:900;content:""}.line .deco-\..deco-\/{font-style:initial}.line .deco-\..deco-\/ :is(.page-link:not(.icon),.link):before{font-weight:400;content:""}div.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):is(href$=".pdf",[href^="https://twitter.com"],[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):after{display:none}.line span:not(.deco-\.)>span>a.link:is(href$=".pdf",[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{display:inline-block;width:1em;height:1em;vertical-align:-1px;text-align:center;background-size:contain;background-repeat:no-repeat;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands"}.line a.link:not(.icon)href$=".pdf":before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"]):before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{content:"";font-weight:400;margin-right:3px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index{display:inline-block;width:0;text-indent:-9999px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index:nth-of-type(30)~span.char-index{display:inherit;width:inherit;text-indent:inherit}.deco-\"{border-radius:.2em;padding:0 .4em;background-color:#8080801a;font-size:95%;font-style:italic}.deco-\":before{color:#a0a0a0;font-size:85%;font-family:"Font Awesome 5 Free";content:"";font-weight:900;vertical-align:super}.line .indent-mark .dot{opacity:0}.line .indent-mark .c-0+.dot{opacity:1}.line .indent-mark .c-1+.dot{opacity:.8}.line .indent-mark .c-2+.dot{opacity:.6}.line .indent-mark .c-3+.dot{opacity:.4}.line .indent-mark .c-4+.dot{opacity:.2}.line strong:not(class){background:linear-gradient(transparent 60%,#abff4f99 60% 100%)}.time-range .lines{user-select:unset;-webkit-user-select:unset}.line:not(.cursor-line) .deco-\|{display:inline-flex}.line .deco-\| img.image{object-fit:contain;margin:0}.line class^=level .deco-\|{flex-wrap:wrap}.line .level-1 .deco-\|>span{width:100%}.line .level-2 .deco-\|>span{width:50%}.line .level-3 .deco-\|>span{width:calc(100%/3)}.line .level-4 .deco-\|>span{width:25%}.line .level-5 .deco-\|>span{width:20%}.line class^=level .deco-\| img.image{object-fit:cover;width:100%;height:100%}.line .deco-\|>span,.line class^=level .deco-\|>span{overflow:hidden}.line .deco-\| img.image,.line class^=level .deco-\| img.image{margin:.2em}.selections .popup-menu .button-container .button:empty{display:none}.strong-button>strong,.italic-button>i,.strike-button>strike{display:inline-block;width:0;text-indent:-9999px}.selections .popup-menu .button-container .button:is(.link-button,.new-page-button,.copy-plain-button){font-size:0}.selections .popup-menu .button-container .button{font-family:Open Sans,Helvetica,Arial,Hiragino Sans,sans-serif,"Font Awesome 5 Free","Font Awesome 5 Brands";font-size:11px;line-height:20px;font-weight:600;display:inline-block;text-align:center}.link-button:after{font-size:11px;content:""}.strong-button:after{content:""}.italic-button:after{content:""}.strike-button:after{content:""}.copy-plain-button:after{font-size:11px;content:""}.new-page-button:after{font-size:11px;content:""}.line a.iconhref$="/hr"{pointer-events:none}.page-column{grid-template-columns:var(--page-column-columns, 46px minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas, "spacer page menu")}@media (991px < width){.page-column:has(.page-sidebar){grid-template-columns:var(--page-column-columns-sidebar, minmax(200px, 3fr) minmax(170px, 1fr) min-content);grid-template-areas:var(--page-column-areas-sidebar, "page sidebar menu")}}@media (min-width: 768px) and (max-width: 991px){.page-column{grid-template-columns:var(--page-column-columns-768, minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas-768, "page menu")}}@media (max-width: 767px){.page-column{display:grid;grid-template-columns:var(--page-column-columns-767, 1fr);grid-template-areas:var(--page-column-areas-767, "page")}}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: minmax(200px, 960px) min-content;--page-column-areas-sidebar: "page menu"}.deco-\#{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace}.grid li.page-list-item a .pin{background-color:transparent;background-image:none}.grid li.page-list-item a .pin:after{content:"";font-family:"Font Awesome 5 Free";font-weight:900;font-size:20px;color:#1f915e;bottom:0}@media screen and (min-width: 400px){html:is(data-os*=android,data-os*=ios) .popup-menu .button-container .button,.popup-menu .button-container .button:is(data-os*=android,data-os*=ios){min-width:3em}}:not(data-display-style^=presentation) .page-column{--page-column-columns: 100px minmax(200px, 960px) min-content 1fr;--page-column-areas: "spacer page menu spacer2";--page-column-columns-sidebar: 100px minmax(200px, 3fr) minmax(170px, 1fr) min-content;--page-column-areas-sidebar: "spacer page sidebar menu";--page-column-columns-768: var(--page-column-columns);--page-column-areas-768: var(--page-column-areas);--page-column-columns-767: minmax(60px, calc(100% / 767 * 100)) 1fr;--page-column-areas-767: "spacer page"}@container (width > 1236px){:not(data-display-style^=presentation) .page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}data-display-style^=presentation data-userscript-name="takker-scheduler/timeline-wedget"{display:none}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: var(--page-column-columns);--page-column-areas-sidebar: var(--page-column-areas)}.page-sidebar:not(:has(.definition-term)){display:none}.deco-\>{position:absolute;width:100%;text-align:right}.search-form .form-group input:focus{color:var(--page-text-color);background-color:var(--search-form-bg, rgba(255,255,255,.15))}.line span.code-block .code-block-start title=css a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=html a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=javascript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=typescript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cpp a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=c a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cs a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=python a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=toml a:before,.line span.code-block .code-block-start title=json a:before,.line span.code-block .code-block-start title=yaml a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=xml a:before{content:"謹";display:inline-block}.line span.code-block .code-block-start title=gitignore a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=markdown a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=txt a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=csv a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=fish a:before,.line span.code-block .code-block-start title=bash a:before,.line span.code-block .code-block-start title=zsh a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=dos a:before{content:"";display:inline-block}.line code,.line span.code-block{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace;font-size:105%}.table-block .cell{border:solid 1px var(--telomere-border, #808b8c)}li.page-list-item.grid-style-item div.title{-webkit-line-clamp:2}.line.number-list .dot{background-color:transparent!important;display:list-item}.line.number-list .dot:before{display:block;position:absolute;font-family:"Font Awesome 5 Free";top:-11px;content:"";font-weight:900;font-size:11px;color:#c9c9c9;opacity:0}.line.number-list .c-0+.dot:before{opacity:1}.line.number-list .c-1+.dot:before{opacity:.8}.line.number-list .c-2+.dot:before{opacity:.6}.line.number-list .c-3+.dot:before{opacity:.4}.line.number-list .c-4+.dot:before{opacity:.2}img[src^="https://i.kakeru.app"]{background-color:#fff}@media screen{.quick-launch .left-box{position:fixed;top:-2px;left:40px;z-index:1000}}@media screen and (min-width: 768px) and (max-width: 991px){.quick-launch .left-box{left:55px}}@media screen and (min-width: 992px) and (max-width: 1260px){.quick-launch .left-box{left:70px}}@media screen and (min-width: 1261px){.quick-launch .left-box{left:calc((100% - 1280px)/2 + 80px)}}.expandable-menu{max-width:calc(100% - 291px)}@media screen and (min-width: 768px) and (max-width: 991px){.expandable-menu{max-width:calc(100% - 306px)}}@media screen and (min-width: 992px) and (max-width: 1260px){.expandable-menu{max-width:calc(100% - 321px)}}.deco-\* img.image{max-height:600px}.page-linkhref*=".@":before{content:"✅"}.page-linkhref*="@20":not(href*=".@"):before{content:"⬜"}data-os=android{.page-column{div.page-menu{position:fixed;display:flex;flex-direction:row-reverse;right:0;.dropdown-menu-top,.dropdown-menu-right{top:46px}}}}.dropdown-menu,.drawer .drawer-menu{background-color:var(--dropdown-menu-bg, #fff);border:var(--dropdown-menu-border, unset)}.dropdown-menu>li>a,.drawer .drawer-menu ul li a,.page-menu ul>li>div{color:var(--dropdown-menu-text-color, #333)}.dropdown-menu>li>a:active,.drawer-menu ul li a:active,data-hover-visible :is(.dropdown-menu,.drawer-menu)>li>:is(a:hover,a:focus){color:var(--dropdown-menu-text-hover-color, #262626);background-color:var(--dropdown-menu-text-hover-bg, #f5f5f5)}:is(.dropdown-menu,.drawer-menu) .divider{color:var(--dropdown-menu-divider-color, #e5e5e5)}body{--dropdown-menu-bg: #373b44;--dropdown-menu-border: 1px solid #8888882d;--dropdown-menu-text-color: var(--page-text-color);--dropdown-menu-text-hover-color: var(--page-text-color);--dropdown-menu-text-hover-bg: #373b44}.line:not(.cursor-line) .deco-\'{position:absolute;width:100%;text-align:center}.navbar-brand:before{content:"";width:44px;height:44px;position:absolute;background-color:#252a30;background-image:url(https://daiiz-apps.appspot.com/today/jp.svg);background-size:cover;background-position:center;border-radius:6px}.line:not(.cursor-line) class="deco-( deco-)":not(:has(img.icon)){border-radius:50%;border:.05em solid var(--page-text-color, #4a4a4a);line-height:1;color:var(--page-text-color, #4a4a4a);font-weight:600;padding:5px;a{color:var(--page-text-color, #4a4a4a)}}
code:takker-private.css
body *:before{--code-number-color: var(--code-color, #342d9c)}.section-title{counter-reset:codeline}.code-block span.indent code.code-body{counter-increment:codeline;margin-left:-1.5em;padding-left:2.3em}.code-block span.indent code.code-body:before{content:counter(codeline);position:absolute;display:inline-block;z-index:10;margin-left:-2.4em;width:2em;padding-right:.2em;text-align:right;vertical-align:bottom;border-right:solid 1px #fff;color:var(--code-number-color)}.code-block span.indent code.code-body:before{opacity:.5}.cursor-line .code-block span.indent code.code-body:before{opacity:1;font-weight:bolder;background-color:var(--accent-color)}.navbar-form .dropdown.open .dropdown-menu{min-width:100%;max-height:calc(100vh - 130px)!important;overflow-y:auto}.page-list-item.pin+.page-list-item:not(.pin){grid-column-start:1}.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):not([href^="https://scrapbox.io"]):after{font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";font-weight:900;font-size:.8rem;content:" ";display:inline-block}.line .deco-\.{font-size:.8em;position:relative;top:-.5em}.line:not(.cursor-line) .deco-\. a:is(.page-link:not(.icon),.link) span:not(.empty-char-index)+span+span~span{display:inline-block;width:0;text-indent:-9999px}.line:not(.cursor-line) .deco-\. .page-link:not(.icon) span.empty-char-index~span.char-index{display:inherit;width:inherit;text-indent:inherit}.line:not(.cursor-line) .deco-\. a.page-link:not(.icon) span.empty-char-index+span:before{content:"#"}.line .deco-\. :is(.page-link:not(.icon),.link):before{display:inline-block;min-width:1.15em;padding-left:1px;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands";text-align:center;vertical-align:middle;font-weight:900;content:""}.line .deco-\..deco-\/{font-style:initial}.line .deco-\..deco-\/ :is(.page-link:not(.icon),.link):before{font-weight:400;content:""}div.line span:not(.modal-image):not(.pointing-device-map)>a.link:not(.icon):is(href$=".pdf",[href^="https://twitter.com"],[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):after{display:none}.line span:not(.deco-\.)>span>a.link:is(href$=".pdf",[href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"],[href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{display:inline-block;width:1em;height:1em;vertical-align:-1px;text-align:center;background-size:contain;background-repeat:no-repeat;font-family:"Font Awesome 5 Free","Font Awesome 5 Brands"}.line a.link:not(.icon)href$=".pdf":before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://github.com"],[href^="https://raw.githubusercontent.com"],[href^="https://gist.github.com"]):before{content:"";font-weight:400;margin-right:1px}:is(.line,.line .deco) a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]):before{content:"";font-weight:400;margin-right:3px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index{display:inline-block;width:0;text-indent:-9999px}.line .deco-\. a.link:is([href^="https://ja.wikipedia.org"],[href^="https://en.wikipedia.org"]) span.char-index:nth-of-type(30)~span.char-index{display:inherit;width:inherit;text-indent:inherit}.deco-\"{border-radius:.2em;padding:0 .4em;background-color:#8080801a;font-size:95%;font-style:italic}.deco-\":before{color:#a0a0a0;font-size:85%;font-family:"Font Awesome 5 Free";content:"";font-weight:900;vertical-align:super}.line .indent-mark .dot{opacity:0}.line .indent-mark .c-0+.dot{opacity:1}.line .indent-mark .c-1+.dot{opacity:.8}.line .indent-mark .c-2+.dot{opacity:.6}.line .indent-mark .c-3+.dot{opacity:.4}.line .indent-mark .c-4+.dot{opacity:.2}.line strong:not(class){background:linear-gradient(transparent 60%,#abff4f99 60% 100%)}.time-range .lines{user-select:unset;-webkit-user-select:unset}.line:not(.cursor-line) .deco-\|{display:inline-flex}.line .deco-\| img.image{object-fit:contain;margin:0}.line class^=level .deco-\|{flex-wrap:wrap}.line .level-1 .deco-\|>span{width:100%}.line .level-2 .deco-\|>span{width:50%}.line .level-3 .deco-\|>span{width:calc(100%/3)}.line .level-4 .deco-\|>span{width:25%}.line .level-5 .deco-\|>span{width:20%}.line class^=level .deco-\| img.image{object-fit:cover;width:100%;height:100%}.line .deco-\|>span,.line class^=level .deco-\|>span{overflow:hidden}.line .deco-\| img.image,.line class^=level .deco-\| img.image{margin:.2em}.selections .popup-menu .button-container .button:empty{display:none}.strong-button>strong,.italic-button>i,.strike-button>strike{display:inline-block;width:0;text-indent:-9999px}.selections .popup-menu .button-container .button:is(.link-button,.new-page-button,.copy-plain-button){font-size:0}.selections .popup-menu .button-container .button{font-family:Open Sans,Helvetica,Arial,Hiragino Sans,sans-serif,"Font Awesome 5 Free","Font Awesome 5 Brands";font-size:11px;line-height:20px;font-weight:600;display:inline-block;text-align:center}.link-button:after{font-size:11px;content:""}.strong-button:after{content:""}.italic-button:after{content:""}.strike-button:after{content:""}.copy-plain-button:after{font-size:11px;content:""}.new-page-button:after{font-size:11px;content:""}.line a.iconhref$="/hr"{pointer-events:none}.page-column{grid-template-columns:var(--page-column-columns, 46px minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas, "spacer page menu")}@media (991px < width){.page-column:has(.page-sidebar){grid-template-columns:var(--page-column-columns-sidebar, minmax(200px, 3fr) minmax(170px, 1fr) min-content);grid-template-areas:var(--page-column-areas-sidebar, "page sidebar menu")}}@media (min-width: 768px) and (max-width: 991px){.page-column{grid-template-columns:var(--page-column-columns-768, minmax(200px, 960px) min-content);grid-template-areas:var(--page-column-areas-768, "page menu")}}@media (max-width: 767px){.page-column{display:grid;grid-template-columns:var(--page-column-columns-767, 1fr);grid-template-areas:var(--page-column-areas-767, "page")}}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: minmax(200px, 960px) min-content;--page-column-areas-sidebar: "page menu"}.deco-\#{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace}.grid li.page-list-item a .pin{background-color:transparent;background-image:none}.grid li.page-list-item a .pin:after{content:"";font-family:"Font Awesome 5 Free";font-weight:900;font-size:20px;color:#1f915e;bottom:0}@media screen and (min-width: 400px){html:is(data-os*=android,data-os*=ios) .popup-menu .button-container .button,.popup-menu .button-container .button:is(data-os*=android,data-os*=ios){min-width:3em}}:not(data-display-style^=presentation) .page-column{--page-column-columns: 100px minmax(200px, 960px) min-content 1fr;--page-column-areas: "spacer page menu spacer2";--page-column-columns-sidebar: 100px minmax(200px, 3fr) minmax(170px, 1fr) min-content;--page-column-areas-sidebar: "spacer page sidebar menu";--page-column-columns-768: var(--page-column-columns);--page-column-areas-768: var(--page-column-areas);--page-column-columns-767: minmax(60px, calc(100% / 767 * 100)) 1fr;--page-column-areas-767: "spacer page"}@container (width > 1236px){:not(data-display-style^=presentation) .page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}data-display-style^=presentation data-userscript-name="takker-scheduler/timeline-wedget"{display:none}.page-column:not(:has(.definition-term)){--page-column-columns-sidebar: var(--page-column-columns);--page-column-areas-sidebar: var(--page-column-areas)}.page-sidebar:not(:has(.definition-term)){display:none}.deco-\>{position:absolute;width:100%;text-align:right}.search-form .form-group input:focus{color:var(--page-text-color);background-color:var(--search-form-bg, rgba(255,255,255,.15))}.line span.code-block .code-block-start title=css a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=html a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=javascript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=typescript a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cpp a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=c a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=cs a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=python a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=toml a:before,.line span.code-block .code-block-start title=json a:before,.line span.code-block .code-block-start title=yaml a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=xml a:before{content:"謹";display:inline-block}.line span.code-block .code-block-start title=gitignore a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=markdown a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=txt a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=csv a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=fish a:before,.line span.code-block .code-block-start title=bash a:before,.line span.code-block .code-block-start title=zsh a:before{content:"";display:inline-block}.line span.code-block .code-block-start title=dos a:before{content:"";display:inline-block}.line code,.line span.code-block{font-family:Cica,Menlo,Monaco,Consolas,Courier New,monospace;font-size:105%}.table-block .cell{border:solid 1px var(--telomere-border, #808b8c)}.line.number-list .dot{background-color:transparent!important;display:list-item}.line.number-list .dot:before{display:block;position:absolute;font-family:"Font Awesome 5 Free";top:-11px;content:"";font-weight:900;font-size:11px;color:#c9c9c9;opacity:0}.line.number-list .c-0+.dot:before{opacity:1}.line.number-list .c-1+.dot:before{opacity:.8}.line.number-list .c-2+.dot:before{opacity:.6}.line.number-list .c-3+.dot:before{opacity:.4}.line.number-list .c-4+.dot:before{opacity:.2}img[src^="https://i.kakeru.app"]{background-color:#fff}[data-os=android]{.page-column{div.page-menu{position:fixed;display:flex;flex-direction:row-reverse;right:0;.dropdown-menu-top,.dropdown-menu-right{top:46px}}}}.dropdown-menu,.drawer .drawer-menu{background-color:var(--dropdown-menu-bg, #fff);border:var(--dropdown-menu-border, unset)}.dropdown-menu>li>a,.drawer .drawer-menu ul li a,.page-menu ul>li>div{color:var(--dropdown-menu-text-color, #333)}.dropdown-menu>li>a:active,.drawer-menu ul li a:active,data-hover-visible :is(.dropdown-menu,.drawer-menu)>li>:is(a:hover,a:focus){color:var(--dropdown-menu-text-hover-color, #262626);background-color:var(--dropdown-menu-text-hover-bg, #f5f5f5)}:is(.dropdown-menu,.drawer-menu) .divider{color:var(--dropdown-menu-divider-color, #e5e5e5)}body{--dropdown-menu-bg: #373b44;--dropdown-menu-border: 1px solid #8888882d;--dropdown-menu-text-color: var(--page-text-color);--dropdown-menu-text-hover-color: var(--page-text-color);--dropdown-menu-text-hover-bg: #373b44}html,body,#editor,.grid li{font-family:ヒラギノ角ゴ Pro W3,Hiragino Kaku Gothic Pro,メイリオ,Meiryo,MS Pゴシック,-apple-system,BlinkMacSystemFont,sans-serif}