for-any-project-min
code:script.js
var Jv=Object.defineProperty;var En=(e,t)=>{for(var r in t)Jv(e,r,{get:tr,enumerable:!0})};var Ua={};En(Ua,{Decoder:()=>a0,Encoder:()=>i0,PacketType:()=>te,protocol:()=>fp});function it(e){if(e)return Qv(e)}function Qv(e){for(var t in it.prototype)et=it.prototypet;return e}it.prototype.on=it.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};it.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};it.prototype.off=it.prototype.removeListener=it.prototype.removeAllListeners=it.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 n,o=0;o<r.length;o++)if(n=ro,n===t||n.fn===t){r.splice(o,1);break}return r.length===0&&delete this._callbacks"$"+e,this};it.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,n=1;n<arguments.length;n++)tn-1=argumentsn;if(r){r=r.slice(0);for(var n=0,o=r.length;n<o;++n)rn.apply(this,t)}return this};it.prototype.emitReserved=it.prototype.emit;it.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};it.prototype.hasListeners=function(e){return!!this.listeners(e).length};var Zv=typeof ArrayBuffer=="function",e0=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,dp=Object.prototype.toString,t0=typeof Blob=="function"||typeof Blob<"u"&&dp.call(Blob)==="object BlobConstructor",r0=typeof File=="function"||typeof File<"u"&&dp.call(File)==="object FileConstructor";function Fa(e){return Zv&&(e instanceof ArrayBuffer||e0(e))||t0&&e instanceof Blob||r0&&e instanceof File}function as(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(as(er))return!0;return!1}if(Fa(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return as(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&as(er))return!0;return!1}function n0(e){let t=[],r=e.data,n=e;return n.data=$a(r,t),n.attachments=t.length,{packet:n,buffers:t}}function $a(e,t){if(!e)return e;if(Fa(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 n=0;n<e.length;n++)rn=$a(en,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(rn=$a(en,t));return r}return e}function o0(e,t){return e.data=ja(e.data,t),delete e.attachments,e}function ja(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=ja(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=ja(er,t));return e}var s0="connect","connect_error","disconnect","disconnecting","newListener","removeListener",fp=5,te;(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"})(te||(te={}));var i0=class{constructor(e){this.replacer=e}encode(e){return(e.type===te.EVENT||e.type===te.ACK)&&as(e)?this.encodeAsBinary({type:e.type===te.EVENT?te.BINARY_EVENT:te.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===te.BINARY_EVENT||e.type===te.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=n0(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function pp(e){return Object.prototype.toString.call(e)==="object Object"}var a0=class mp extends it{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 n=r.type===te.BINARY_EVENT;n||r.type===te.BINARY_ACK?(r.type=n?te.EVENT:te.ACK,this.reconstructor=new c0(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Fa(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,n={type:Number(t.charAt(0))};if(ten.type===void 0)throw new Error("unknown packet type "+n.type);if(n.type===te.BINARY_EVENT||n.type===te.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");n.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(s,r)}else n.nsp="/";let o=t.charAt(r+1);if(o!==""&&Number(o)==o){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}n.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(mp.isPayloadValid(n.type,s))n.data=s;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case te.CONNECT:return pp(r);case te.DISCONNECT:return r===void 0;case te.CONNECT_ERROR:return typeof r=="string"||pp(r);case te.EVENT:case te.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&s0.indexOf(r0)===-1);case te.ACK:case te.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},c0=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=o0(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};var Yt=Object.create(null);Yt.open="0";Yt.close="1";Yt.ping="2";Yt.pong="3";Yt.message="4";Yt.upgrade="5";Yt.noop="6";var us=Object.create(null);Object.keys(Yt).forEach(e=>{us[Yte]=e});var Wa={type:"error",data:"parser error"},bp=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",xp=typeof ArrayBuffer=="function",wp=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ps=({type:e,data:t},r,n)=>bp&&t instanceof Blob?r?n(t):hp(t,n):xp&&(t instanceof ArrayBuffer||wp(t))?r?n(t):hp(new Blob(t),n):n(Yte+(t||"")),hp=(e,t)=>{let r=new FileReader;return r.onload=function(){let n=r.result.split(",")1;t("b"+(n||""))},r.readAsDataURL(e)};function gp(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Ba;function l0(e,t){if(bp&&e.data instanceof Blob)return e.data.arrayBuffer().then(gp).then(t);if(xp&&(e.data instanceof ArrayBuffer||wp(e.data)))return t(gp(e.data));ps(e,!1,r=>{Ba||(Ba=new TextEncoder),t(Ba.encode(r))})}var yp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ao=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<yp.length;e++)aoyp.charCodeAt(e)=e;var u0=e=>{let t=e.length*.75,r=e.length,n,o=0,s,i,a,c;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let l=new ArrayBuffer(t),p=new Uint8Array(l);for(n=0;n<r;n+=4)s=aoe.charCodeAt(n),i=aoe.charCodeAt(n+1),a=aoe.charCodeAt(n+2),c=aoe.charCodeAt(n+3),po++=s<<2|i>>4,po++=(i&15)<<4|a>>2,po++=(a&3)<<6|c&63;return l},p0=typeof ArrayBuffer=="function",ds=(e,t)=>{if(typeof e!="string")return{type:"message",data:vp(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:d0(e.substring(1),t)}:usr?e.length>1?{type:usr,data:e.substring(1)}:{type:usr}:Wa},d0=(e,t)=>{if(p0){let r=u0(e);return vp(r,t)}else return{base64:!0,data:e}},vp=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},kp="",Ep=(e,t)=>{let r=e.length,n=new Array(r),o=0;e.forEach((s,i)=>{ps(s,!1,a=>{ni=a,++o===r&&t(n.join(kp))})})},Tp=(e,t)=>{let r=e.split(kp),n=[];for(let o=0;o<r.length;o++){let s=ds(ro,t);if(n.push(s),s.type==="error")break}return n};function Pp(){return new TransformStream({transform(e,t){l0(e,r=>{let n=r.length,o;if(n<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,n);else if(n<65536){o=new Uint8Array(3);let s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,n)}else{o=new Uint8Array(9);let s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(o0|=128),t.enqueue(o),t.enqueue(r)})}})}var Ha;function cs(e){return e.reduce((t,r)=>t+r.length,0)}function ls(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),n=0;for(let o=0;o<t;o++)ro=e0n++,n===e0.length&&(e.shift(),n=0);return e.length&&n<e0.length&&(e0=e0.slice(n)),r}function Rp(e,t){Ha||(Ha=new TextDecoder);let r=[],n=0,o=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(n===0){if(cs(r)<1)break;let c=ls(r,1);s=(c0&128)===128,o=c0&127,o<126?n=3:o===126?n=1:n=2}else if(n===1){if(cs(r)<2)break;let c=ls(r,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(cs(r)<8)break;let c=ls(r,8),l=new DataView(c.buffer,c.byteOffset,c.length),p=l.getUint32(0);if(p>Math.pow(2,21)-1){a.enqueue(Wa);break}o=p*Math.pow(2,32)+l.getUint32(4),n=3}else{if(cs(r)<o)break;let c=ls(r,o);a.enqueue(ds(s?c:Ha.decode(c),t)),n=0}if(o===0||o>e){a.enqueue(Wa);break}}}})}var qa=4;function Te(e){if(e)return f0(e)}function f0(e){for(var t in Te.prototype)et=Te.prototypet;return e}Te.prototype.on=Te.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};Te.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Te.prototype.off=Te.prototype.removeListener=Te.prototype.removeAllListeners=Te.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 n,o=0;o<r.length;o++)if(n=ro,n===t||n.fn===t){r.splice(o,1);break}return r.length===0&&delete this._callbacks"$"+e,this};Te.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,n=1;n<arguments.length;n++)tn-1=argumentsn;if(r){r=r.slice(0);for(var n=0,o=r.length;n<o;++n)rn.apply(this,t)}return this};Te.prototype.emitReserved=Te.prototype.emit;Te.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};Te.prototype.hasListeners=function(e){return!!this.listeners(e).length};var co=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Lt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),m0="arraybuffer";function _p(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(rn=en),r),{})}var h0=Lt.setTimeout,g0=Lt.clearTimeout;function lo(e,t){t.useNativeTimers?(e.setTimeoutFn=h0.bind(Lt),e.clearTimeoutFn=g0.bind(Lt)):(e.setTimeoutFn=Lt.setTimeout.bind(Lt),e.clearTimeoutFn=Lt.clearTimeout.bind(Lt))}var y0=1.33;function b0(e){return typeof e=="string"?x0(e):Math.ceil((e.byteLength||e.size)*y0)}function x0(e){let t=0,r=0;for(let n=0,o=e.length;n<o;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function Lp(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function w0(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function v0(e){let t={},r=e.split("&");for(let n=0,o=r.length;n<o;n++){let s=rn.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var k0=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},Ka=class extends Te{constructor(e){super(),this.writable=!1,lo(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 k0(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=ds(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=w0(e);return t.length?"?"+t:""}},E0=class extends Ka{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)};Tp(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,Ep(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=Lp()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Cp=!1;try{Cp=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var T0=Cp;function P0(){}var R0=class extends E0{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",(n,o)=>{this.onError("xhr post error",n,o)})}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}},Tn=class fs extends Te{constructor(t,r,n){super(),this.createRequest=t,lo(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;let r=_p(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&n.setRequestHeader(o,this._opts.extraHeaderso)}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var o;n.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=fs.requestsCount++,fs.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=P0,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete fs.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()}};Tn.requestsCount=0;Tn.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Sp);else if(typeof addEventListener=="function"){let e="onpagehide"in Lt?"pagehide":"unload";addEventListener(e,Sp,!1)}}function Sp(){for(let e in Tn.requests)Tn.requests.hasOwnProperty(e)&&Tn.requestse.abort()}var S0=function(){let e=Op({xdomain:!1});return e&&e.responseType!==null}(),Ya=class extends R0{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=S0&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Tn(Op,this.uri(),e)}};function Op(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||T0))return new XMLHttpRequest}catch{}if(!t)try{return new Lt["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Np=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",_0=class extends Ka{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=Np?{}:_p(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(n){return this.emitReserved("error",n)}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,n=t===e.length-1;ps(r,this.supportsBinary,o=>{try{this.doWrite(r,o)}catch{}n&&co(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(tthis.opts.timestampParam=Lp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},za=Lt.WebSocket||Lt.MozWebSocket,Va=class extends _0{createSocket(e,t,r){return Np?new za(e,t,r):t?new za(e,t):new za(e)}doWrite(e,t){this.ws.send(t)}},Mp=class extends Ka{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=Rp(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Pp();n.readable.pipeTo(e.writable),this._writer=n.writable.getWriter();let o=()=>{r.read().then(({done:i,value:a})=>{i||(this.onPacket(a),o())}).catch(i=>{})};o();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,n=t===e.length-1;this._writer.write(r).then(()=>{n&&co(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},L0={websocket:Va,webtransport:Mp,polling:Ya},C0=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,O0="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function ys(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf(""),n=e.indexOf("");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let o=C0.exec(e||""),s={},i=14;for(;i--;)s[O0i]=oi||"";return r!=-1&&n!=-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=N0(s,s.path),s.queryKey=M0(s,s.query),s}function N0(e,t){let r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function M0(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(n,o,s){o&&(ro=s)}),r}var Ga=typeof addEventListener=="function"&&typeof removeEventListener=="function",ms=[];Ga&&addEventListener("offline",()=>{ms.forEach(e=>e())},!1);var hs=class gs extends Te{constructor(t,r){if(super(),this.binaryType=m0,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 n=ys(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=ys(r.host).host);lo(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(n=>{let o=n.prototype.name;this.transports.push(o),this._transportsByNameo=n}),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=v0(this.opts.query)),Ga&&(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"})},ms.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=qa,r.transport=t,this.id&&(r.sid=this.id);let n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptionst);return new this._transportsByNamet(n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&gs.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",gs.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 n=this.writeBufferr.data;if(n&&(t+=b0(n)),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,co(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,o){if(typeof r=="function"&&(o=r,r=void 0),typeof n=="function"&&(o=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let s={type:t,data:r,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),o&&this.once("flush",o),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{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?n():t()}):this.upgrading?n():t()),this}_onError(t){if(gs.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(),Ga&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=ms.indexOf(this._offlineEventListener);n!==-1&&ms.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};hs.protocol=qa;var A0=class extends hs{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;hs.priorWebsocketSuccess=!1;let n=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;hs.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 u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function o(){r||(r=!0,l(),t.close(),t=null)}let s=p=>{let u=new Error("probe error: "+p);u.transport=t.name,o(),this.emitReserved("upgradeError",u)};function i(){s("transport closed")}function a(){s("socket closed")}function c(p){t&&p.name!==t.name&&o()}let l=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",n),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}},Xa=class extends A0{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(n=>L0n).filter(n=>!!n)),super(e,r)}};var SN=Xa.protocol;function I0(e,t="",r){let n=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),n=ys(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let o=n.host.indexOf(":")!==-1?""+n.host+"":n.host;return n.id=n.protocol+"://"+o+":"+n.port+t,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}function Ut(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var D0=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Ap=class extends Te{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=Ut(e,"open",this.onopen.bind(this)),Ut(e,"packet",this.onpacket.bind(this)),Ut(e,"error",this.onerror.bind(this)),Ut(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,n,o;if(D0.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:te.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=(n=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||n===void 0?void 0:n.writable,a=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._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 n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.ackse=t;return}let o=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"))},n),s=(...i)=>{this.io.clearTimeoutFn(o),t.apply(this,i)};s.withError=!0,this.ackse=s}emitWithAck(e,...t){return new Promise((r,n)=>{let o=(s,i)=>s?n(s):r(i);o.withError=!0,t.push(o),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((n,...o)=>r!==this._queue0?void 0:(n!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(n)):(this._queue.shift(),t&&t(null,...o)),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:te.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 te.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 te.EVENT:case te.BINARY_EVENT:this.onevent(e);break;case te.ACK:case te.BINARY_ACK:this.onack(e);break;case te.DISCONNECT:this.ondisconnect();break;case te.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(...n){r||(r=!0,t.packet({type:te.ACK,id:e,data:n}))}}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:te.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 Rn(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}Rn.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};Rn.prototype.reset=function(){this.attempts=0};Rn.prototype.setMin=function(e){this.ms=e};Rn.prototype.setMax=function(e){this.max=e};Rn.prototype.setJitter=function(e){this.jitter=e};var Ja=class extends Te{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,lo(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 Rn({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||Ua;this.encoder=new n.Encoder,this.decoder=new n.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 Xa(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=Ut(t,"open",function(){r.onopen(),e&&e()}),o=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=Ut(t,"error",o);if(this._timeout!==!1){let i=this._timeout,a=this.setTimeoutFn(()=>{n(),o(new Error("timeout")),t.close()},i);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(n),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(Ut(e,"ping",this.onping.bind(this)),Ut(e,"data",this.ondata.bind(this)),Ut(e,"error",this.onerror.bind(this)),Ut(e,"close",this.onclose.bind(this)),Ut(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){co(()=>{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 Ap(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(n=>{n?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):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)}},uo={};function Pn(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=I0(e,t.path||"/socket.io"),n=r.source,o=r.id,s=r.path,i=uoo&&s in uoo.nsps,a=t.forceNew||t"force new connection"||t.multiplex===!1||i,c;return a?c=new Ja(n,t):(uoo||(uoo=new Ja(n,t)),c=uoo),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Pn,{Manager:Ja,Socket:Ap,io:Pn,connect:Pn});var Ip=" must not return ",$0="transformer",j0="recoverer",F0="defaultValue",rM=$0+Ip,Dp="called with ",nM=F0+" must not be ",oM=j0+Ip,U0="Ok",$p="Err",B0=Dp+$p,H0=Dp+U0,sM="Carrying E in "+$p+" instead of throwing it directly. See .cause",Qa="an instance of Error of the current realm.",iM="The thrown value is not "+Qa,aM="The contained E should be "+Qa,cM="This .cause is not "+Qa;function Wr(e){return e.ok}function ce(e){return{ok:!0,val:e,err:null}}function K(e){return!e.ok}function Ie(e){return{ok:!1,val:null,err:e}}function V(e){return W0(e,B0)}function vr(e){return q0(e,H0)}function W0(e,t){if(K(e))throw new TypeError(t);return e.val}function q0(e,t){if(Wr(e))throw new TypeError(t);return e.err}function Za(e){return e.val}function jp(e){return e.err}async function Fp(e,t){if(K(e))return e;let r=Za(e);return await t(r)}function Sn(e,t){if(K(e))return e;let r=Za(e),n=t(r);return ce(n)}async function xe(e,t){if(K(e))return e;let r=Za(e),n=await t(r);return ce(n)}async function ve(e,t){if(Wr(e))return e;let r=jp(e),n=await t(r);return Ie(n)}async function ec(e,t){if(Wr(e))return e;let r=jp(e);return await t(r)}var ot=e=>{if(e?.connected)return Promise.resolve(ce(e));e??=Pn("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]});let t=new Promise(r=>{let n=o=>r(Ie(o));e.once("connect",()=>{e.off("disconnect",n),r(ce(e))}),e.once("disconnect",n)});return e.connect(),t},at=e=>{if(e.disconnected)return Promise.resolve(ce(void 0));let t=new Promise(r=>{let n=o=>{if(o!=="io client disconnect"){r(Ie(o));return}r(ce(void 0)),e.off("disconnect",n)};e.on("disconnect",n)});return e.disconnect(),t};var Up=e=>z0.includes(e.name),z0="SocketIOError","DuplicateTitleError","NotFastForwardError";var Bp=(e,t,r,n)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(ce(void 0));let{resolve:o,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(p)},c=f=>{if(f==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(f==="io server disconnect"){a(),o(Ie({name:"SocketIOError"}));return}};e.on("disconnect",c);let l=n?.timeout??9e4,p=setTimeout(()=>{a(),o(Ie({name:"TimeoutError",message:exceeded ${l} (ms)}))},l),u=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",u,f=>{if(a(),"error"in f){o(Ie(Up(f.error)?f.error:{name:"UnexpectedRequestError",...f}));return}o(ce(f.data))}),s};var ge=e=>e.ok?ce(e):Ie({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Hp=async(e,t)=>{let r=new Request(e,t);try{return ce(await globalThis.fetch(r))}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return Ie({name:"AbortError",message:n.message,request:r});if(n instanceof TypeError)return Ie({name:"NetworkError",message:n.message,request:r});throw n}};var ie=e=>{let{fetch:t=Hp,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Wp=e=>{let{sid:t,hostName:r}=ie(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:ye(t)}}:void 0)},qp=e=>xe(ge(e),async t=>await t.json()),bs=(()=>{let e=async t=>{let{fetch:r,...n}=ie(t??{}),o=await r(Wp(n));return K(o)?o:qp(V(o))};return e.toRequest=Wp,e.fromResponse=qp,e})();var ye=e=>connect.sid=${e},Vt=async e=>{let t=e?.csrf??globalThis._csrf;return t?ce(t):Sn(await bs(e),r=>r.csrfToken)};function xs(e,t={}){if(e===null)return"null";if(Array.isArray(e))return G0(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:K0(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function G0(e,t){let{threshold:r=20}=t,n=e.map(i=>xs(i,t)),o=n.join(", ");if(o.length<=r)return[${o}];let s=n.join(`, );return[
${zp(2,s)}
]}function K0(e,t){let{threshold:r=20}=t,n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${xs(ei,t)}),o=n.join(", ");if(o.length<=r)return{${o}};let s=n.join(, );return{
${zp(2,s)}
}}function zp(e,t){let r=" ".repeat(e);return t.split(
).map(n=>${r}${n}).join(
)}function ze(e,t,...r){let n;return Object.defineProperties(e,{name:{get:()=>n||(n=${t}(${r.map(o=>xs(o)).join(", ")}),n)}})}function ir(e){return Array.isArray(e)}function tc(e){return ze(t=>ir(t)&&t.every(r=>e(r)),"isArrayOf",e)}function ws(e){let t=new Set(e);return ze(r=>t.has(r),"isLiteralOneOf",e)}function po(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function Ge(e){return typeof e=="string"}var Ne=async(e,t)=>{let r=e.response.clone(),n=ws(t);try{let o=await r.json();if(!po(o))return;if(r.status===422){if(!Ge(o.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:o.message}}return!n(o.name)||!Ge(o.message)?void 0:o.name==="NotLoggedInError"?!po(o.detals)||!Ge(o.detals.project)||!tc(Y0)(o.detals.loginStrategies)?void 0:{name:o.name,message:o.message,details:{project:o.detals.project,loginStrategies:o.detals.loginStrategies}}:{name:o.name,message:o.message}}catch(o){if(o instanceof SyntaxError)return;throw o}},Y0=ws(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var oe=e=>e.replaceAll(" ","_").toLowerCase();var ue=e=>[...e].map((t,r)=>t===" "?"_":!V0.includes(t)||r===e.length-1&&X0.includes(t)?encodeURIComponent(t):t).join(""),V0='@$&+=:;",',X0=':;",';var Gp=" must not return ",J0="transformer",Q0="recoverer",Z0="defaultValue",ek=J0+Gp,tk="called with ",rk=Z0+" must not be ",nk=Q0+Gp,vs="null or undefined",XM=ek+vs,JM=tk+vs,ok=rk+vs,QM=nk+vs;function rc(e){return e!=null}function sk(e){return e==null}function ik(e,t){if(rc(e))return e;throw new TypeError(t)}function Kp(e){return{ok:!0,val:e,err:null}}function Yp(e){return{ok:!1,val:null,err:e}}function Vp(e,t){if(rc(e))return Kp(e);let r=t();return Yp(r)}function nc(e){return sk(e)?Yp(void 0):Kp(e)}function Xp(e,t){return rc(e)?e:ik(t,ok)}var Jp=(e,t,r)=>{let{sid:n,hostName:o,followRename:s,projects:i}=ie(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(https://${o}/api/pages/${e}/${ue(t)}?${a},n?{headers:{Cookie:ye(n)}}:void 0)},Qp=async e=>ve(await xe(ge(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:Xp(await Ne(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),Ct=(()=>{let e=async(t,r,n)=>Fp(await ie(n??{}).fetch(Jp(t,r,n)),o=>Qp(o));return e.toRequest=Jp,e.fromResponse=Qp,e})();var Zp=(e,t)=>{let{sid:r,hostName:n}=ie(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:ye(r)}}:void 0)},ed=async e=>xe(await ve(ge(e),async t=>await Ne(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),ar=(()=>{let e=async(t,r)=>{let{fetch:n}=ie(r??{}),o=Zp(t,r),s=await n(o);return K(s)?s:ed(V(s))};return e.toRequest=Zp,e.fromResponse=ed,e})(),td=(e,t)=>{let{sid:r,hostName:n}=ie(t??{}),o=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${n}/api/projects?${o},r?{headers:{Cookie:ye(r)}}:void 0)},rd=async e=>xe(await ve(ge(e),async t=>await Ne(t,["NotLoggedInError"])??t),t=>t.json()),ks=(()=>{let e=async(t,r)=>{let{fetch:n}=ie(r??{}),o=await n(td(t,r));return K(o)?o:rd(V(o))};return e.toRequest=td,e.fromResponse=rd,e})();var sc=async(e,t,r)=>{let[n,o,s]=await Promise.all([Ct(e,t,r),ak(r),ck(e,r)]);return K(n)?n:K(o)?o:K(s)?s:ce({...V(n),projectId:V(s),userId:V(o)})},oc,ak=async e=>{if(oc)return ce(oc);let t=await bs(e);if(K(t))return t;let r=V(t);return"id"in r?(oc=r.id,ce(r.id)):Ie({name:"NotLoggedInError",message:"This script cannot be used without login"})},nd=new Map,ck=async(e,t)=>{let r=nd.get(e);return r?ce(r):Sn(await ar(e,t),({id:n})=>(nd.set(e,n),n))};function Pe(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,s)=>{let i=()=>{clearTimeout(c),s(r?.reason)},c=setTimeout(()=>{r?.removeEventListener("abort",i),o()},e);if(r?.addEventListener("abort",i,{once:!0}),n===!1)try{Deno.unrefTimer(c)}catch(l){if(!(l instanceof ReferenceError))throw l;console.error("persistent option is only available in Deno")}})}var qr=async(e,t,r,n)=>{let o=await ot(n?.socket);if(K(o))return Ie({name:"UnexpectedRequestError",error:vr(o)});let s=V(o),i=await sc(e,t);if(K(i))return i;let a=V(i);try{let c=0,l=[],p;for(;n?.maxAttempts===void 0||c<n.maxAttempts;){let u=r(a,c,l,p);if(l=u instanceof Promise?await u:u,c++,l.length===0)return ce(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 d=await Bp(s,"commit",f);if(Wr(d))return a.commitId=V(d).commitId,ce(a.commitId);let h=vr(d),g=h.name;if(g==="SocketIOServerDisconnectError"||g==="UnexpectedRequestError")return Ie(h);if(g==="TimeoutError"||g==="SocketIOError"){await Pe(3e3);continue}if(g==="NotFastForwardError"){await Pe(1e3);let y=await sc(e,t);if(K(y))return y;a=V(y)}p=g;break}}return Ie({name:"RetryError",attempts:c,message:Retrying exceeded the maxAttempts (${c}).})}finally{n?.socket||await at(s)}};var ic=(e,t)=>{let r=e.length>t.length,n=r?t:e,o=r?e:t,s=n.length+1,i=n.length+o.length+3,a=new Array(i);a.fill(-1);let c=[];function l(g,y,w){let R=Math.max(y,w),E=R-g;for(;E<n.length&&R<o.length&&n[E]===o[R];)++E,++R;return a[g+s]=c.length,c.push([{x:E,y:R},a[g+(y>w?-1:1)+s]]),R}let p=new Array(i);p.fill(-1);let u=-1,f=o.length-n.length;do{++u;for(let g=-u;g<=f-1;++g)p[g+s]=l(g,p[g-1+s]+1,p[g+1+s]);for(let g=f+u;g>=f+1;--g)p[g+s]=l(g,p[g-1+s]+1,p[g+1+s]);p[f+s]=l(f,p[f-1+s]+1,p[f+1+s])}while(p[f+s]!==o.length);let d=[],h=a[f+s];for(;h!==-1;)d.push(c[h][0]),h=c[h][1];return{from:e,to:t,editDistance:f+u*2,buildSES:function*(){let g=0,y=0;for(let{x:w,y:R}of lk(d))for(;g<w||y<R;)R-w>y-g?(yield{value:o[y],type:r?"deleted":"added"},++y):R-w<y-g?(yield{value:n[g],type:r?"added":"deleted"},++g):(yield{value:n[g],type:"common"},++g,++y)}}};function*ac(e){let t=[],r=[];function*n(){if(t.length>r.length){for(let o=0;o<r.length;o++)yield od(t[o],r[o]);for(let o=r.length;o<t.length;o++)yield t[o]}else{for(let o=0;o<t.length;o++)yield od(t[o],r[o]);for(let o=t.length;o<r.length;o++)yield r[o]}t=[],r=[]}for(let o of e)switch(o.type){case"added":t.push(o);break;case"deleted":r.push(o);break;case"common":yield*n(),yield o;break}yield*n()}var od=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*lk(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var sd=e=>e.padStart(8,"0"),cc=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${sd(t).slice(-8)}${e.slice(-6)}0000${sd(r)}};function*lc(e,t,{userId:r}){let{buildSES:n}=ic(e.map(({text:i})=>i),t),o=0,s=e[0].id;for(let i of ac(n())){switch(i.type){case"added":yield{_insert:s,lines:{id:cc(r),text:i.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:i.value}};break}o++,s=e[o]?.id??"_end"}}var uk=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),id=(e,t)=>{let r=e[e.length-1];return r!==void 0&&uk(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)},ad=(e,t)=>{if(t.hasTitle??!0){let[r,...n]=e;return r===void 0?[]:[{type:"title",rows:[r]},...n.reduce(id,[])]}return e.reduce(id,[])};var cd=e=>e.split( ).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var ld=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:s,content:r.map(i=>i.text.substring(n+1)).join(
)}};var re=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let a of n){let c=a.exec(o);if(c===null)continue;let l=o.substring(0,c.index),p=o.substring(c.index+(c[0]?.length??0)),u=e(c[0]??"",s);return[...dt(l,s),...u,...dt(p,s)]}return i?.()??[]};var le=e=>[{type:"plain",raw:e,text:e}],ud=re(le,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var pk=/\[\s+\]/,dk=(e,t)=>t.context==="table"?le(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],pd=re(dk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[pk]});var fk=/.*?/,mk=(e,t)=>t.context==="table"?le(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],dd=re(mk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[fk]});var hk=/^[$%] .+$/,gk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e[0]??"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:n}]},fd=re(gk,{parseOnNested:!1,parseOnQuoted:!1,patterns:[hk]});var yk=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,bk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),s=new Set(n);if(s.has("*")){let i=n.split("*").length-1;s.delete("*"),s.add(*-${Math.min(i,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(s),nodes:dt(o,{...t,nested:!0})}]},md=re(bk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[yk]});var xk=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,wk=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,vk=/\[https?:\/\/[^\s\]]+\]/,kk=/https?:\/\/[^\s]+/,Ek=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let s=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},hd=re(Ek,{parseOnNested:!0,parseOnQuoted:!0,patterns:[xk,wk,vk,kk]});var Tk=/\[\$ .+? \]/,Pk=/\[\$ [^\]]+\]/,Rk=(e,t)=>t.context==="table"?le(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],gd=re(Rk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Tk,Pk]});var yd=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,bd=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,Sk=e=>{let[t="",r="",n=""]=e.split(","),o=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(n)?Number.parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:i}},_k=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.match(yd)??e.match(bd);if(r===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,o="",s=""]=n?r:[r[0],r[2],r[1]],{latitude:i,longitude:a,zoom:c}=Sk(o),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}]},xd=re(_k,{parseOnNested:!1,parseOnQuoted:!0,patterns:[yd,bd]});var Lk=/(?:^|\s)#\S+/,Ck=(e,t)=>{if(t.context==="table")return le(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...le(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},wd=re(Ck,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Lk]});var Ok=/^\? .+$/,Nk=(e,t)=>t.context==="table"?le(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],vd=re(Nk,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Ok]});var Mk=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,Ak=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),n=t.substring(0,r),o=n.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:n,pathType:o,type:"icon",raw:e}))},kd=re(Ak,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Mk]});var Ik=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,Dk=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,$k=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,jk=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,Fk=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Uk(e),Uk=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),Bk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,i]=Fk(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:i}]},Ed=re(Bk,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Ik,Dk,$k,jk]});var Hk=/\[\/?[^[\]]+\]/,Wk=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},Td=re(Wk,{parseOnNested:!0,parseOnQuoted:!0,patterns:[Hk]});var qk=/^[0-9]+\. .*$/,zk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=Number.parseInt(n,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:dt(s,{...t,nested:!1})}]},Pd=re(zk,{parseOnNested:!1,parseOnQuoted:!1,patterns:[qk]});var Gk=/^>.*$/,Kk=(e,t)=>t.context==="table"?le(e,t):[{type:"quote",raw:e,nodes:dt(e.substring(1),{...t,quoted:!0})}],Rd=re(Kk,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Gk]});var Yk=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,Vk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.substring(2,e.length-2),n=r.lastIndexOf(".icon"),o=r.substring(0,n),s=o.startsWith("/")?"root":"relative",i=r.substring(n+5,r.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:o,pathType:s,type:"strongIcon",raw:e}))},Sd=re(Vk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Yk]});var Xk=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,Jk=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,Qk=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},_d=re(Qk,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Xk,Jk]});var Zk=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,eE=(e,t)=>t.context==="table"?le(e,t):[{type:"strong",raw:e,nodes:dt(e.substring(2,e.length-2),{...t,nested:!0})}],Ld=re(eE,{parseOnNested:!1,parseOnQuoted:!0,patterns:[Zk]});var tE=(e,t,r)=>e===""?[]:r?.()??[],rE=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>ud(t,r))(),dt=rE(tE,Rd,vd,Pd,dd,fd,gd,pd,md,_d,Sd,Ld,Ed,hd,kd,xd,Td,wd);var Cd=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:dt(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Od=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:s,cells:r.map(i=>i.text.substring(n+1)).map(i=>i.split(" ").map(a=>dt(a,{nested:!1,quoted:!1,context:"table"})))}};var Nd=e=>({type:"title",text:e.rows[0].text});var Md=e=>{switch(e.type){case"title":return Nd(e);case"codeBlock":return ld(e);case"table":return Od(e);case"line":return Cd(e)}};var Ue=(e,t)=>{let r=cd(e);return ad(r,{hasTitle:t?.hasTitle??!0}).map(Md)},Ad=e=>/^\s*\S.*$/m.exec(e)?.[0]?.trim()??"Untitled";var nE=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,oE=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,sE=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,iE=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Es=e=>{if(nE.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(oE);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"dotbe"}}}{let t=e.match(sE);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"short"}}}{let t=e.match(iE);if(t){let[,r,n]=t;return{listId:n,params:new URLSearchParams(r),pathType:"list"}}}};var Dd=e=>{let t=Ue(e,{hasTitle:!0}).flatMap(h=>{switch(h.type){case"codeBlock":case"title":return[];case"line":case"table":return h}}),r=new Map,n=[],o=new Set,s=[],i=new Set,a=[],c=null,l=new Set,p=new Set,u=new RegExp(${location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),f=h=>{switch(h.type){case"hashTag":if(r.has(oe(h.href)))return;r.set(oe(h.href),!1),n.push(h.href);return;case"link":switch(h.pathType){case"relative":{let g=Id(h.href);if(r.get(oe(g)))return;r.set(oe(g),!0),n.push(g);return}case"root":{let g=Id(h.href);if(/^\/[\w\d-]+\/?$/.test(g)||o.has(oe(g)))return;o.add(oe(g)),s.push(g);return}case"absolute":{if(h.content)return;let g=Es(h.href);if(g&&g.pathType!=="list"){c??=https://i.ytimg.com/vi/${g.videoId}/mqdefault.jpg;return}let y=h.href.match(u)?.[1];y&&l.add(y);return}default:return}case"icon":case"strongIcon":{if(h.pathType==="root"||i.has(oe(h.path)))return;i.add(oe(h.path)),a.push(h.path);return}case"image":case"strongImage":{c??=h.src.endsWith("/thumb/1000")?h.src.replace(/\/thumb\/1000$/,"/raw"):h.src;{let g=h.src.match(u)?.[1];g&&l.add(g)}if(h.type==="image"){let g=h.link.match(u)?.[1];g&&l.add(g)}return}case"helpfeel":p.add(h.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let g of h.nodes)f(g);return}default:return}},d=[];for(let h of t)switch(h.type){case"line":for(let g of h.nodes)f(g);continue;case"table":{for(let g of h.cells)for(let y of g)for(let w of y)f(w);if(!["infobox","cosense"].includes(h.fileName))continue;d.push(...h.cells.map(g=>g.map(y=>y.map(w=>w.raw).join("")).join(" ").trim()));continue}}return[n,s,a,c,[...l],[...p],d]},Id=e=>e.replace(/#[a-f\d]{24,32}$/,""),$d=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?[t.trimStart().slice(2)]:[]);var zr=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));function*jd(e,t,r){let n=t.flatMap(d=>d.split( ));for(let d of lc(e.lines,n,{userId:r}))yield d;(e.lines[0].text!==n[0]||!e.persistent)&&(yield{title:n[0]});let o=e.lines.slice(1,6).map(d=>d.text),s=n.slice(1,6);o.join("")!==s.join("")&&(yield{descriptions:s});let[i,a,c,l,p,u,f]=Dd(n.join(
));zr(e.links,i)||(yield{links:i}),zr(e.projectLinks,a)||(yield{projectLinks:a}),zr(e.icons,c)||(yield{icons:c}),e.image!==l&&(yield{image:l}),zr(e.files,p)||(yield{files:p}),zr($d(e.lines),u)||(yield{helpfeels:u}),zr(e.infoboxDefinition,f)||(yield{infoboxDefinition:f})}var Fd=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,n=t?.[2]?parseInt(t[2])+1:2;return${r}_${n}};var we=(e,t,r,n)=>qr(e,t,async(o,s,i,a)=>{if(a==="DuplicateTitleError"){let p=Fd(t);return i.map(u=>("title"in u&&(u.title=p),u))}let c=r(o.lines,{...o,attempts:s}),l=c instanceof Promise?await c:c;return l===void 0?[]:l.length===0?[{deleted:!0}]:[...jd(o,l,o.userId)]},n);var Ud=(e,t,r)=>qr(e,t,n=>n.persistent?[{deleted:!0}]:[],r);var Ts=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i}=ie(n??{}),a=await Vt(n);if(K(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":V(a),...o?{Cookie:ye(o)}:{}},body:JSON.stringify({from:t,to:r})}),l=await i(c);return K(l)?l:xe(await ve(ge(V(l)),async p=>await Ne(p,["NotFoundError","NotLoggedInError","NotMemberError"])??p),async p=>{let{message:u}=await p.json();return parseInt(u.match(/\d+/)?.[0]??"0")})};var Bd=(e,t)=>{let{sid:r,hostName:n,followingId:o}=ie(t??{});return new Request(https://${n}/api/pages/${e}/search/titles${o??followingId=${o}:""},r?{headers:{Cookie:ye(r)}}:void 0)},Hd=async e=>xe(await ve(ge(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await Ne(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),lE=(()=>{let e=async(t,r)=>{let n=await ie(r??{}).fetch(Bd(t,r));return K(n)?n:Hd(V(n))};return e.toRequest=Bd,e.fromResponse=Hd,e})();async function*Wd(e,t){let r;do{let n=await lE(e,{followingId:r,...t});if(K(n)){yield n;return}let o=V(n);yield ce(o.pages),r=o.followingId}while(r)}var qd=async(e,t,r)=>{let{sid:n,hostName:o,fetch:s}=ie(r??{}),i=new Request(https://${o}/api/pages/${t}/search/query?q=${encodeURIComponent(e)},n?{headers:{Cookie:ye(n)}}:void 0),a=await s(i);return K(a)?a:xe(await ve(ge(V(a)),async c=>await Ne(c,["NotFoundError","NotLoggedInError","NotMemberError","NoQueryError"])??c),c=>c.json())};var zd=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=ie(t??{}),s=await Vt(t);if(K(s))return s;let i=new Request(https://${n}/api/embed-text/url?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":V(s),...r?{Cookie:ye(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(i);return K(a)?a:xe(await ve(ge(V(a)),async c=>await Ne(c,["SessionError","BadRequestError","InvalidURLError"])??c),async c=>{let{title:l}=await c.json();return l})};var Gd=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=ie(t??{}),s=await Vt(t);if(K(s))return s;let i=new Request(https://${n}/api/embed-text/twitter?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":V(s),...r?{Cookie:ye(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(i);return K(a)?a:ve(await xe(ge(V(a)),c=>c.json()),async c=>c.response.status===422?{name:"InvalidURLError",message:(await c.response.json()).message}:await Ne(c,["SessionError","BadRequestError"])??c)};var Kd=async e=>{let{fetch:t,sid:r,hostName:n,gyazoTeamsName:o}=ie(e??{}),s=new Request(https://${n}/api/login/gyazo/oauth-upload/token${o??gyazoTeamsName=${o}:""},r?{headers:{Cookie:ye(r)}}:void 0),i=await t(s);return K(i)?i:xe(await ve(ge(V(i)),async a=>await Ne(a,["NotLoggedInError"])??a),a=>a.json().then(c=>c.token))};var Yd=(e,t,r,n)=>{let{sid:o,hostName:s}=ie(n??{});return new Request(https://${s}/api/code/${e}/${ue(t)}/${ue(r)},o?{headers:{Cookie:ye(o)}}:void 0)},Vd=async e=>xe(await ve(ge(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 Ne(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),Ps=(()=>{let e=async(t,r,n,o)=>{let s=Yd(t,r,n,o),i=await ie(o??{}).fetch(s);return K(i)?i:Vd(V(i))};return e.toRequest=Yd,e.fromResponse=Vd,e})();var Qd=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],n=new Uint8Array(uc),o=0,s=0,i=0;[r,n,o,s,i]=Jd(r,n,o,s,i,t);let a=uc-o;a<9&&(a+=uc);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,n,o,s,i]=Jd(r,n,o,s,i,new Uint8Array(c.buffer));let l=new ArrayBuffer(16),p=new DataView(l);return p.setUint32(0,r[0],!0),p.setUint32(4,r[1],!0),p.setUint32(8,r[2],!0),p.setUint32(12,r[3],!0),l},uc=64,U=(e,t)=>e<<t|e>>>32-t,ct=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,Xd=(e,t)=>{let[r,n,o,s]=e,i=ct(t,0),a=ct(t,4),c=ct(t,8),l=ct(t,12),p=ct(t,16),u=ct(t,20),f=ct(t,24),d=ct(t,28),h=ct(t,32),g=ct(t,36),y=ct(t,40),w=ct(t,44),R=ct(t,48),E=ct(t,52),b=ct(t,56),k=ct(t,60);return r=n+U(((o^s)&n^s)+r+i+3614090360,7),s=r+U(((n^o)&r^o)+s+a+3905402710,12),o=s+U(((r^n)&s^n)+o+c+606105819,17),n=o+U(((s^r)&o^r)+n+l+3250441966,22),r=n+U(((o^s)&n^s)+r+p+4118548399,7),s=r+U(((n^o)&r^o)+s+u+1200080426,12),o=s+U(((r^n)&s^n)+o+f+2821735955,17),n=o+U(((s^r)&o^r)+n+d+4249261313,22),r=n+U(((o^s)&n^s)+r+h+1770035416,7),s=r+U(((n^o)&r^o)+s+g+2336552879,12),o=s+U(((r^n)&s^n)+o+y+4294925233,17),n=o+U(((s^r)&o^r)+n+w+2304563134,22),r=n+U(((o^s)&n^s)+r+R+1804603682,7),s=r+U(((n^o)&r^o)+s+E+4254626195,12),o=s+U(((r^n)&s^n)+o+b+2792965006,17),n=o+U(((s^r)&o^r)+n+k+1236535329,22),r=n+U(((n^o)&s^o)+r+a+4129170786,5),s=r+U(((r^n)&o^n)+s+f+3225465664,9),o=s+U(((s^r)&n^r)+o+w+643717713,14),n=o+U(((o^s)&r^s)+n+i+3921069994,20),r=n+U(((n^o)&s^o)+r+u+3593408605,5),s=r+U(((r^n)&o^n)+s+y+38016083,9),o=s+U(((s^r)&n^r)+o+k+3634488961,14),n=o+U(((o^s)&r^s)+n+p+3889429448,20),r=n+U(((n^o)&s^o)+r+g+568446438,5),s=r+U(((r^n)&o^n)+s+b+3275163606,9),o=s+U(((s^r)&n^r)+o+l+4107603335,14),n=o+U(((o^s)&r^s)+n+h+1163531501,20),r=n+U(((n^o)&s^o)+r+E+2850285829,5),s=r+U(((r^n)&o^n)+s+c+4243563512,9),o=s+U(((s^r)&n^r)+o+d+1735328473,14),n=o+U(((o^s)&r^s)+n+R+2368359562,20),r=n+U((n^o^s)+r+u+4294588738,4),s=r+U((r^n^o)+s+h+2272392833,11),o=s+U((s^r^n)+o+w+1839030562,16),n=o+U((o^s^r)+n+b+4259657740,23),r=n+U((n^o^s)+r+a+2763975236,4),s=r+U((r^n^o)+s+p+1272893353,11),o=s+U((s^r^n)+o+d+4139469664,16),n=o+U((o^s^r)+n+y+3200236656,23),r=n+U((n^o^s)+r+E+681279174,4),s=r+U((r^n^o)+s+i+3936430074,11),o=s+U((s^r^n)+o+l+3572445317,16),n=o+U((o^s^r)+n+f+76029189,23),r=n+U((n^o^s)+r+g+3654602809,4),s=r+U((r^n^o)+s+R+3873151461,11),o=s+U((s^r^n)+o+k+530742520,16),n=o+U((o^s^r)+n+c+3299628645,23),r=n+U((o^(n|~s))+r+i+4096336452,6),s=r+U((n^(r|~o))+s+d+1126891415,10),o=s+U((r^(s|~n))+o+b+2878612391,15),n=o+U((s^(o|~r))+n+u+4237533241,21),r=n+U((o^(n|~s))+r+R+1700485571,6),s=r+U((n^(r|~o))+s+l+2399980690,10),o=s+U((r^(s|~n))+o+y+4293915773,15),n=o+U((s^(o|~r))+n+a+2240044497,21),r=n+U((o^(n|~s))+r+h+1873313359,6),s=r+U((n^(r|~o))+s+k+4264355552,10),o=s+U((r^(s|~n))+o+f+2734768916,15),n=o+U((s^(o|~r))+n+E+1309151649,21),r=n+U((o^(n|~s))+r+p+4149444226,6),s=r+U((n^(r|~o))+s+w+3174756917,10),o=s+U((r^(s|~n))+o+c+718787259,15),n=o+U((s^(o|~r))+n+g+3951481745,21),[e[0]+r>>>0,e[1]+n>>>0,e[2]+o>>>0,e[3]+s>>>0]},Jd=(e,t,r,n,o,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=Xd(e,t);let a=i;for(;a+64<=s.length;)e=Xd(e,s.slice(a,a+64)),a+=64;t.fill(0).set(s.slice(a),0),r=s.length-a}return[n,o]=uE(n,o,s.length),[e,t,r,n,o]},uE=(e,t,r)=>(e+=r,e>4294967295&&(t+=1),[e>>>0,t]);var pE=new TextEncoder;function dE(e){let t=typeof e;return t!=="object"?t:e===null?"null":e?.constructor?.name??"object"}function Zd(e){if(typeof e=="string")return pE.encode(e);if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new TypeError(Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${dE(e)})}var ef=new TextEncoder().encode("0123456789abcdef"),Oj=new TextEncoder,fE=new TextDecoder;function tf(e){let t=Zd(e),r=new Uint8Array(t.length*2);for(let n=0;n<t.length;n++){let o=t[n];r[n*2]=ef[o>>4],r[n*2+1]=ef[o&15]}return fE.decode(r)}var rf=async(e,t,r)=>{let n=${tf(Qd(await e.arrayBuffer()))},o=await mE(e,t,n,r);if(K(o))return o;let s=V(o);if("embedUrl"in s)return ce(s);let i=await hE(s.signedUrl,e,r);return K(i)?i:gE(t,s.fileId,n,r)},mE=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i,csrf:a}=ie(n??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},l=await ec(nc(a),()=>Vt(n));if(K(l))return l;let p=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":V(l),...o?{Cookie:ye(o)}:{}}}),u=await i(p);return K(u)?u:xe(await ve(ge(V(u)),async f=>f.response.status===402?{name:"FileCapacityError",message:(await f.response.json()).message}:f),f=>f.json())},hE=async(e,t,r)=>{let{sid:n,fetch:o}=ie(r??{}),s=await o(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...n?{Cookie:ye(n)}:{}}});return K(s)?s:Sn(await ve(ge(V(s)),async i=>i.response.headers.get("Content-Type")?.includes?.("/xml")?{name:"GCSError",message:await i.response.text()}:i),()=>{})},gE=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i,csrf:a}=ie(n??{}),c=await ec(nc(a),()=>Vt(n));if(K(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":V(c),...o?{Cookie:ye(o)}:{}}}),p=await i(l);return K(p)?p:xe(await ve(ge(V(p)),async u=>u.response.status===404?{name:"NotFoundError",message:(await u.response.json()).message}:u),u=>u.json())};var nf=" must not return ",yE="transformer",bE="recoverer",xE="defaultValue",lF=yE+nf,of="called with ",uF=xE+" must not be ",pF=bE+nf,wE="Ok",sf="Err",vE=of+sf,kE=of+wE,dF="Carrying E in "+sf+" instead of throwing it directly. See .cause",pc="an instance of Error of the current realm.",fF="The thrown value is not "+pc,mF="The contained E should be "+pc,hF="This .cause is not "+pc;function kr(e){return e.ok}function be(e){return{ok:!0,val:e,err:null}}function G(e){return!e.ok}function Z(e){return{ok:!1,val:null,err:e}}function B(e){return EE(e,vE)}function ne(e){return TE(e,kE)}function EE(e,t){if(G(e))throw new TypeError(t);return e.val}function TE(e,t){if(kr(e))throw new TypeError(t);return e.err}function af(e){return e.val}function PE(e){return e.err}async function Ot(e,t){if(G(e))return e;let r=af(e),n=await t(r);return be(n)}function cf(e,t,r){if(kr(e)){let o=af(e);return r(o)}let n=PE(e);return t(n)}var lf=async e=>{let t=e.title??".watchlistrc",r="projectsLastAccessed.json",n=await Ps(e.project,t,r),o=G(n)?{}:JSON.parse(B(n)||"{}"),s=JSON.parse(localStorage.getItem("projectsLastAccessed")??"{}"),i=new Set([...Object.keys(o),...Object.keys(s)]),a=Object.fromEntries([...i].map(l=>[l,Math.max(o[l]??0,s[l]??0)]).sort((l,p)=>p[1]-l[1])),c=JSON.stringify(a);localStorage.setItem("projectsLastAccessed",c),await we(e.project,t,()=>[t,"This page is automatically generated. DO NOT EDIT ANYTHING, WHITCH WILL BE OVERWRITTEN.","",code:${r}, ${c},""])};scrapbox.PageMenu.addMenu({title:"Gyazo",image:"https://i.gyazo.com/503a911fea542532aa5aba0a88eb7b60.png",onClick:()=>window.open("https://gyazo.com/captures")});var Ls,J,ff,RE,Gr,uf,mf,dc,hf,gc,fc,mc,gf,fo={},yf=[],SE=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Cs=Array.isArray;function Er(e,t){for(var r in t)e[r]=t[r];return e}function yc(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function cr(e,t,r){var n,o,s,i={};for(s in t)s=="key"?n=t[s]:s=="ref"?o=t[s]:i[s]=t[s];if(arguments.length>2&&(i.children=arguments.length>3?Ls.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 Ss(e,i,n,o,null)}function Ss(e,t,r,n,o){var s={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++ff,__i:-1,__u:0};return o==null&&J.vnode!=null&&J.vnode(s),s}function Y(e){return e.children}function Bt(e,t){this.props=e,this.context=t}function _n(e,t){if(t==null)return e.__?_n(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"?_n(e):null}function bf(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 bf(e)}}function hc(e){(!e.__d&&(e.__d=!0)&&Gr.push(e)&&!_s.__r++||uf!==J.debounceRendering)&&((uf=J.debounceRendering)||mf)(_s)}function _s(){var e,t,r,n,o,s,i,a;for(Gr.sort(dc);e=Gr.shift();)e.__d&&(t=Gr.length,n=void 0,s=(o=(r=e).__v).__e,i=[],a=[],r.__P&&((n=Er({},o)).__v=o.__v+1,J.vnode&&J.vnode(n),bc(r.__P,n,o,r.__n,r.__P.namespaceURI,32&o.__u?[s]:null,i,s??_n(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,vf(i,n,a),n.__e!=s&&bf(n)),Gr.length>t&&Gr.sort(dc));_s.__r=0}function xf(e,t,r,n,o,s,i,a,c,l,p){var u,f,d,h,g,y,w=n&&n.__k||yf,R=t.length;for(c=_E(r,t,w,c,R),u=0;u<R;u++)(d=r.__k[u])!=null&&(f=d.__i===-1?fo:w[d.__i]||fo,d.__i=u,y=bc(e,d,f,o,s,i,a,c,l,p),h=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&xc(f.ref,null,d),p.push(d.ref,d.__c||h,d)),g==null&&h!=null&&(g=h),4&d.__u||f.__k===d.__k?c=wf(d,c,e):typeof d.type=="function"&&y!==void 0?c=y:h&&(c=h.nextSibling),d.__u&=-7);return r.__e=g,c}function _E(e,t,r,n,o){var s,i,a,c,l,p=r.length,u=p,f=0;for(e.__k=new Array(o),s=0;s<o;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?Ss(null,i,null,null,null):Cs(i)?Ss(Y,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?Ss(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=LE(i,r,c,u))!==-1&&(u--,(a=r[l])&&(a.__u|=2)),a==null||a.__v===null?(l==-1&&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(u)for(s=0;s<p;s++)(a=r[s])!=null&&!(2&a.__u)&&(a.__e==n&&(n=_n(a)),kf(a,a));return n}function wf(e,t,r){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=wf(n[o],t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=_n(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Tr(e,t){return t=t||[],e==null||typeof e=="boolean"||(Cs(e)?e.some(function(r){Tr(r,t)}):t.push(e)),t}function LE(e,t,r,n){var o,s,i=e.key,a=e.type,c=t[r];if(c===null||c&&i==c.key&&a===c.type&&!(2&c.__u))return r;if(n>(c!=null&&!(2&c.__u)?1:0))for(o=r-1,s=r+1;o>=0||s<t.length;){if(o>=0){if((c=t[o])&&!(2&c.__u)&&i==c.key&&a===c.type)return o;o--}if(s<t.length){if((c=t[s])&&!(2&c.__u)&&i==c.key&&a===c.type)return s;s++}}return-1}function pf(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||SE.test(t)?r:r+"px"}function Rs(e,t,r,n,o){var s;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||pf(e.style,t,"");if(r)for(t in r)n&&r[t]===n[t]||pf(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(hf,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?n?r.u=n.u:(r.u=gc,e.addEventListener(t,s?mc:fc,s)):e.removeEventListener(t,s?mc:fc,s);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=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 df(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=gc++;else if(t.t<r.u)return;return r(J.event?J.event(t):t)}}}function bc(e,t,r,n,o,s,i,a,c,l){var p,u,f,d,h,g,y,w,R,E,b,k,v,L,O,$,S,T=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(c=!!(32&r.__u),s=[a=t.__e=r.__e]),(p=J.__b)&&p(t);e:if(typeof T=="function")try{if(w=t.props,R="prototype"in T&&T.prototype.render,E=(p=T.contextType)&&n[p.__c],b=p?E?E.props.value:p.__:n,r.__c?y=(u=t.__c=r.__c).__=u.__E:(R?t.__c=u=new T(w,b):(t.__c=u=new Bt(w,b),u.constructor=T,u.render=OE),E&&E.sub(u),u.props=w,u.state||(u.state={}),u.context=b,u.__n=n,f=u.__d=!0,u.__h=[],u._sb=[]),R&&u.__s==null&&(u.__s=u.state),R&&T.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Er({},u.__s)),Er(u.__s,T.getDerivedStateFromProps(w,u.__s))),d=u.props,h=u.state,u.__v=t,f)R&&T.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),R&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(R&&T.getDerivedStateFromProps==null&&w!==d&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(w,b),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(w,u.__s,b)===!1||t.__v==r.__v)){for(t.__v!=r.__v&&(u.props=w,u.state=u.__s,u.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(P){P&&(P.__=t)}),k=0;k<u._sb.length;k++)u.__h.push(u._sb[k]);u._sb=[],u.__h.length&&i.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(w,u.__s,b),R&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(d,h,g)})}if(u.context=b,u.props=w,u.__P=e,u.__e=!1,v=J.__r,L=0,R){for(u.state=u.__s,u.__d=!1,v&&v(t),p=u.render(u.props,u.state,u.context),O=0;O<u._sb.length;O++)u.__h.push(u._sb[O]);u._sb=[]}else do u.__d=!1,v&&v(t),p=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++L<25);u.state=u.__s,u.getChildContext!=null&&(n=Er(Er({},n),u.getChildContext())),R&&!f&&u.getSnapshotBeforeUpdate!=null&&(g=u.getSnapshotBeforeUpdate(d,h)),a=xf(e,Cs($=p!=null&&p.type===Y&&p.key==null?p.props.children:p)?$:[$],t,r,n,o,s,i,a,c,l),u.base=t.__e,t.__u&=-161,u.__h.length&&i.push(u),y&&(u.__E=u.__=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(S=s.length;S--;)yc(s[S]);else t.__e=r.__e,t.__k=r.__k;J.__e(P,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=CE(r.__e,t,r,n,o,s,i,c,l);return(p=J.diffed)&&p(t),128&t.__u?void 0:a}function vf(e,t,r){for(var n=0;n<r.length;n++)xc(r[n],r[++n],r[++n]);J.__c&&J.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(s){s.call(o)})}catch(s){J.__e(s,o.__v)}})}function CE(e,t,r,n,o,s,i,a,c){var l,p,u,f,d,h,g,y=r.props,w=t.props,R=t.type;if(R=="svg"?o="http://www.w3.org/2000/svg":R=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((d=s[l])&&"setAttribute"in d==!!R&&(R?d.localName==R:d.nodeType==3)){e=d,s[l]=null;break}}if(e==null){if(R==null)return document.createTextNode(w);e=document.createElementNS(o,R,w.is&&w),a&&(J.__m&&J.__m(t,s),a=!1),s=null}if(R===null)y===w||a&&e.data===w||(e.data=w);else{if(s=s&&Ls.call(e.childNodes),y=r.props||fo,!a&&s!=null)for(y={},l=0;l<e.attributes.length;l++)y[(d=e.attributes[l]).name]=d.value;for(l in y)if(d=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")u=d;else if(!(l in w)){if(l=="value"&&"defaultValue"in w||l=="checked"&&"defaultChecked"in w)continue;Rs(e,l,null,d,o)}}for(l in w)d=w[l],l=="children"?f=d:l=="dangerouslySetInnerHTML"?p=d:l=="value"?h=d:l=="checked"?g=d:a&&typeof d!="function"||y[l]===d||Rs(e,l,d,y[l],o);if(p)a||u&&(p.__html===u.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(u&&(e.innerHTML=""),xf(e,Cs(f)?f:[f],t,r,n,R=="foreignObject"?"http://www.w3.org/1999/xhtml":o,s,i,s?s[0]:r.__k&&_n(r,0),a,c),s!=null)for(l=s.length;l--;)yc(s[l]);a||(l="value",R=="progress"&&h==null?e.removeAttribute("value"):h!==void 0&&(h!==e[l]||R=="progress"&&!h||R=="option"&&h!==y[l])&&Rs(e,l,h,y[l],o),l="checked",g!==void 0&&g!==e[l]&&Rs(e,l,g,y[l],o))}return e}function xc(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(o){J.__e(o,r)}}function kf(e,t,r){var n,o;if(J.unmount&&J.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||xc(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){J.__e(s,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&kf(n[o],t,r||typeof e.type!="function");r||yc(e.__e),e.__c=e.__=e.__e=void 0}function OE(e,t,r){return this.constructor(e,r)}function lt(e,t,r){var n,o,s,i;t==document&&(t=document.documentElement),J.__&&J.__(e,t),o=(n=typeof r=="function")?null:r&&r.__k||t.__k,s=[],i=[],bc(t,e=(!n&&r||t).__k=cr(Y,null,[e]),o||fo,fo,t.namespaceURI,!n&&r?[r]:o?null:t.firstChild?Ls.call(t.childNodes):null,s,!n&&r?r:o?o.__e:t.firstChild,n,i),vf(s,e,i)}function mo(e,t){var r={__c:t="__cC"+gf++,__:e,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,s;return this.getChildContext||(o=new Set,(s={})[t]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(i){this.props.value!==i.value&&o.forEach(function(a){a.__e=!0,hc(a)})},this.sub=function(i){o.add(i);var a=i.componentWillUnmount;i.componentWillUnmount=function(){o&&o.delete(i),a&&a.call(i)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}Ls=yf.slice,J={__e:function(e,t,r,n){for(var o,s,i;t=t.__;)if((o=t.__c)&&!o.__)try{if((s=o.constructor)&&s.getDerivedStateFromError!=null&&(o.setState(s.getDerivedStateFromError(e)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),i=o.__d),i)return o.__E=o}catch(a){e=a}throw e}},ff=0,RE=function(e){return e!=null&&e.constructor==null},Bt.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Er({},this.state),typeof e=="function"&&(e=e(Er({},r),this.props)),e&&Er(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),hc(this))},Bt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),hc(this))},Bt.prototype.render=Y,Gr=[],mf=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,dc=function(e,t){return e.__v.__b-t.__v.__b},_s.__r=0,hf=/(PointerCapture)$|Capture$/i,gc=0,fc=df(!1),mc=df(!0),gf=0;var Kr,Re,wc,Ef,ho=0,Of=[],De=J,Tf=De.__b,Pf=De.__r,Rf=De.diffed,Sf=De.__c,_f=De.unmount,Lf=De.__;function go(e,t){De.__h&&De.__h(Re,e,ho||t),ho=0;var r=Re.__H||(Re.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function X(e){return ho=1,Pr(Nf,e)}function Pr(e,t,r){var n=go(Kr++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):Nf(void 0,t),function(a){var c=n.__N?n.__N[0]:n.__[0],l=n.t(c,a);c!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=Re,!Re.u)){var o=function(a,c,l){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(f){return!!f.__c});if(p.every(function(f){return!f.__N}))return!s||s.call(this,a,c,l);var u=n.__c.props!==a;return p.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(u=!0)}}),s&&s.call(this,a,c,l)||u};Re.u=!0;var s=Re.shouldComponentUpdate,i=Re.componentWillUpdate;Re.componentWillUpdate=function(a,c,l){if(this.__e){var p=s;s=void 0,o(a,c,l),s=p}i&&i.call(this,a,c,l)},Re.shouldComponentUpdate=o}return n.__N||n.__}function ee(e,t){var r=go(Kr++,3);!De.__s&&kc(r.__H,t)&&(r.__=e,r.i=t,Re.__H.__h.push(r))}function Ns(e,t){var r=go(Kr++,4);!De.__s&&kc(r.__H,t)&&(r.__=e,r.i=t,Re.__h.push(r))}function Ke(e){return ho=5,C(function(){return{current:e}},[])}function C(e,t){var r=go(Kr++,7);return kc(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function I(e,t){return ho=8,C(function(){return e},t)}function lr(e){var t=Re.context[e.__c],r=go(Kr++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(Re)),t.props.value):e.__}function NE(){for(var e;e=Of.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Os),e.__H.__h.forEach(vc),e.__H.__h=[]}catch(t){e.__H.__h=[],De.__e(t,e.__v)}}De.__b=function(e){Re=null,Tf&&Tf(e)},De.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Lf&&Lf(e,t)},De.__r=function(e){Pf&&Pf(e),Kr=0;var t=(Re=e.__c).__H;t&&(wc===Re?(t.__h=[],Re.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Os),t.__h.forEach(vc),t.__h=[],Kr=0)),wc=Re},De.diffed=function(e){Rf&&Rf(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Of.push(t)!==1&&Ef===De.requestAnimationFrame||((Ef=De.requestAnimationFrame)||ME)(NE)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),wc=Re=null},De.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Os),r.__h=r.__h.filter(function(n){return!n.__||vc(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],De.__e(n,r.__v)}}),Sf&&Sf(e,t)},De.unmount=function(e){_f&&_f(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Os(n)}catch(o){t=o}}),r.__H=void 0,t&&De.__e(t,r.__v))};var Cf=typeof requestAnimationFrame=="function";function ME(e){var t,r=function(){clearTimeout(n),Cf&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,100);Cf&&(t=requestAnimationFrame(r))}function Os(e){var t=Re,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),Re=t}function vc(e){var t=Re;e.__c=e.__(),Re=t}function kc(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Nf(e,t){return typeof t=="function"?t(e):t}function Ye(e){return typeof e=="number"}var AE=(e,t,r)=>{let n=t.name||"anonymous predicate",o=typeof e,s=JSON.stringify(e,null,2);returnExpected ${r??"a value"} that satisfies the predicate ${n}, got ${o}: ${s}},IE=AE,Ec=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name=this.constructor.name}};function Mf(e,t,r={}){if(!t(e))throw new Ec(r.message??IE(e,t,r.name))}function Af(e,t,r={}){return Mf(e,t,r),e}function wt(e){return typeof e>"u"}var Ms=!1,If=null,Df=()=>{scrapbox.addListener("lines:changed",()=>Ms=!1),scrapbox.addListener("layout:changed",()=>Ms=!1),Df=void 0},$f=()=>(Df?.(),Ms||(If=scrapbox.Page.lines,Ms=!0),If);var jf=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Ff=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var Uf=()=>As(document.getElementById("editor"),"div#editor"),yo=()=>As(document.getElementsByClassName("lines").item(0),"div.lines");var Ve=()=>{let e=document.getElementById("text-input");if(e)return Ff(e,"textarea#text-input"),e};var Bf=()=>As(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Hf=()=>As(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),As=(e,t)=>{if(e)return jf(e,t),e};var gt=()=>{let e=yo();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 ur=e=>e.match(/^(\s*)/)?.[1]?.length??0,Yr=(e,t)=>{let r=ur(Wf(e,t)),n=0;for(;e+n+1<t.length&&ur(Wf(e+n+1,t))>r;)n++;return n},Wf=(e,t)=>{let r=t[e];return Ge(r)?r:r.text};var Tc=e=>{if(wt(e))return;if(Ye(e))return Is(e)?.id;if(Ge(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)},qf=e=>{if(wt(e))return;if(Ye(e))return e;let t=Tc(e);return t?gt().findIndex(r=>r.id===t):-1};var Is=e=>{if(wt(e))return;if(Ye(e))return gt()[e];let t=Tc(e);return t?gt().find(r=>r.id===t):void 0},Vr=e=>{if(zf(e))return e;let t=Tc(e);if(wt(t))return t;let r=document.getElementById(L${t});if(!wt(r))return r},zf=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var pr=()=>Af($f(),ir),tt=e=>{if(wt(e))return;if(Ye(e)||Ge(e))return Is(e)?.text;if(!(e instanceof HTMLElement))return;if(zf(e))return Is(e)?.text;if(e.classList.contains("char-index"))return e.textContent??void 0;if(e.classList.contains("line")||e.getElementsByClassName("lines")?.[0])return gt().map(({text:n})=>n).join( );let t=[],r=Is(e);if(!wt(r)){for(let n of $E(e))t.push(jE(n));return r.text.slice(Math.min(...t),Math.max(...t)+1)}};var Gf=()=>{let e=yo()?.firstElementChild;if(!wt(e))return e},Kf=()=>{let e=yo()?.lastElementChild;if(!wt(e))return e};var Pc=e=>{let t=qf(e);if(!wt(t))return Yr(t,pr())};function*$E(e){let t=e.getElementsByClassName("char-index");for(let r=0;r<t.length;r++)yield t[0]}var Rc=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index"),jE=e=>{if(!Rc(e))throw Error("A char DOM is required.");let t=e.className.match(/c-(\d+)/)?.[1];if(wt(t))throw Error('.char-index must have ".c-{\\d}"');return parseInt(t)},Yf=e=>{let t=e?.getElementsByClassName?.("c-0")?.[0];return Rc(t)?t:void 0};var bo=(e,t)=>{let r=Vr(e)?.getElementsByClassName?.(c-${t})?.[0];return Rc(r)?r:void 0};var Be=(e,t)=>{let{noModifiedKeys:r=!1,...n}=t??{},o={bubbles:!0,cancelable:!0,keyCode:FE[e],...r?{}:{...n}},s=Ve();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",o)),s.dispatchEvent(new KeyboardEvent("keyup",o))},FE={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 Sc=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 Pe(10)};var He=()=>{let e=Ve();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 _c=e=>{let{top:t,bottom:r}=e.getBoundingClientRect();return t>=0&&r<=globalThis.innerHeight};function*vt(e,t){for(let r=e;r<t;r++)yield r}var Lc=()=>{Be("Home"),Be("Home")};var Vf=async()=>{let e=Gf();if(!e)throw Error(".line:first-of-type can't be found.");_c(e)||e.scrollIntoView({block:"center"});let t=Yf(e);if(!t)throw Error(".line:first-of-type .c-0 can't be found.");let{left:r,top:n}=t.getBoundingClientRect();await Sc(e,{X:r,Y:n})},Xf=async()=>{await Jf(Kf())},Cc=async e=>{await Jf(Vr(e))},Jf=async e=>{if(!e)throw Error("The target line DOM is failed to find.");_c(e)||e.scrollIntoView({block:"center"});let{right:t,top:r,height:n}=e.getElementsByClassName("text")0.getBoundingClientRect();await Sc(e,{X:t+1,Y:r+n/2})};var Qf=(e=1)=>{for(let t of vt(0,e))Be("z",{ctrlKey:!0})},Zf=(e=1)=>{for(let t of vt(0,e))Be("z",{shiftKey:!0,ctrlKey:!0})};var em=async(e,t)=>{await Cc(e),Lc(),Be("Enter"),Be("ArrowUp"),await Xe(t)},yt=async(e,t,r)=>{await Cc(e),Lc();for(let n of vt(e,t))Be("ArrowDown",{shiftKey:!0});Be("End",{shiftKey:!0}),await Xe(r)};var Ds=(e=1)=>{for(let t of vt(0,e))Be("ArrowRight",{ctrlKey:!0})},$s=(e=1)=>{for(let t of vt(0,e))Be("ArrowLeft",{ctrlKey:!0})};var js=(e=1)=>{for(let t of vt(0,e))Be("ArrowUp",{ctrlKey:!0})},Fs=(e=1)=>{for(let t of vt(0,e))Be("ArrowDown",{ctrlKey:!0})},Us=(e=1)=>{for(let t of vt(0,e))Be("ArrowRight",{altKey:!0})},Bs=(e=1)=>{for(let t of vt(0,e))Be("ArrowLeft",{altKey:!0})};var Hs=(e=1)=>{for(let t of vt(0,e))Be("ArrowUp",{altKey:!0})},Ws=(e=1)=>{for(let t of vt(0,e))Be("ArrowDown",{altKey:!0})},Xe=async e=>{let t=Ve();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await Pe(1)};var _e=()=>{let e=Hf();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 n=tm(...r);n&&t.append(n)},dispose:()=>t.remove()}},tm=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnBE();case"check-circle":returnHE();case"exclamation-triangle":returnWE();case"text":returnqs(n.text);case"group":{let o=tm(...n.items);return o?o:[]}}});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},qs=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},BE=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),qs(e)},HE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),qs(e)},WE=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),qs(e)};var Ln=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_${oe(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var qE=(e,t,r)=>{let n=new URL(/${e}/${ue(t)},location.href);if(r?.body&&(n.search=?body=${encodeURIComponent(r.body)}),r?.id&&(n.hash=#${r.id}),r?.context&&Ln({...r?.context,to:{project:e,title:t}}),r?.newTab!==!1&&(r?.newTab===!0||e!==scrapbox.Project.name)){globalThis.open(n);return}if(r?.reload!==!1&&(r?.reload===!0||e!==scrapbox.Project.name)){globalThis.open(n,"_self");return}let o=document.createElement("a");o.href=n.toString(),document.body.append(o),o.click(),o.remove()},xo=(e,t,r)=>qE(e,t,{newTab:!1,reload:!1,body:r});var Cn=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(e,t);if(s)return s}},zs=async(e,t)=>{let r=t.clone();return await(await caches.open(zE(new Date))).put(e,r)},zE=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var kt=()=>{let e=Ve();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,n=r.find(s=>s.constructor.name==="Cursor");if(!n)throw Error('#text-input must has a "Cursor" store.');let o=r.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:n,selection:o}};var Rr=()=>kt().cursor;var Gs=()=>kt().selection;var wo=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),rm=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 Ks=new Map,Oc=new Map,Nc=()=>{scrapbox.on("layout:changed",()=>{let e=Ve();if(e)for(lett,rof Ks)for(letn,oof r)for(let s of o)e.addEventListener(t,n,rm(s))}),Nc=void 0},nm=(e,t,r)=>{Nc?.();let n=Ks.get(e)??new Map,o=n.get(t)??new Set;if(o.has(wo(r)))return;if(o.add(wo(r)),n.set(t,o),Ks.set(e,n),typeof r=="object"&&r?.once){let i=Oc.get(t)??new Map,a=wo(r),c=function(p){return Mc(e,t,r),i.delete(a),t.call(this,p)};i.set(a,c),Oc.set(t,i);let l=Ve();if(!l)return;l.addEventListener(e,c,r)}let s=Ve();s&&s.addEventListener(e,t,r)},Mc=(e,t,r)=>{Nc?.();let n=Ks.get(e);if(!n)return;let o=n.get(t);if(!o)return;let s=wo(r);if(o.delete(s),typeof r=="object"&&r?.once){let a=Oc.get(t);if(!a)return;let c=a.get(s);if(!c)return;let l=Ve();if(!l)return;l.removeEventListener(e,c,r),a.delete(s);return}let i=Ve();i&&i.removeEventListener(e,t,r)};var om={"&":"\\x26","!":"\\x21","#":"\\x23",$:"\\$","%":"\\x25","*":"\\*","+":"\\+",",":"\\x2c",".":"\\.",":":"\\x3a",";":"\\x3b","<":"\\x3c","=":"\\x3d",">":"\\x3e","?":"\\?","@":"\\x40","^":"\\^","":"\\x60","~":"\\x7e","(":"\\(",")":"\\)","[":"\\[","]":"\\]","{":"\\{","}":"\\}","/":"\\/","-":"\\x2d","\\":"\\\\","|":"\\|"},GE=new RegExp(${Object.values(om).join("")},"gu");function sm(e){return e.replaceAll(GE,t=>om[t]).replace(/^[0-9a-zA-Z]/,t=>\\x${t.codePointAt(0).toString(16)})}var KE=0,v2=Array.isArray;function m(e,t,r,n,o,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:--KE,__i:-1,__u:0,__source:o,__self:s};if(typeof e=="function"&&(i=e.defaultProps))for(a in i)c[a]===void 0&&(c[a]=i[a]);return J.vnode&&J.vnode(l),l}var im=({project:e,title:t,words:r,lines:n,query:o,close:s})=>{let i=I(c=>{Ln({type:"search",query:o,to:{project:e,title:t}}),!(c.metaKey||c.ctrlKey||c.altKey||c.shiftKey)&&s()},[e,t,o,s]),a=C(()=>{let c=new RegExp((${r.map(l=>sm(l)).join("|")}),"i");return n.flatMap(l=>{let p=l.split(c);return m("span",{children:p.map((u,f)=>f%2===0?u:m("strong",{children:u}))})})},[n,r]);return m("a",{href:/${e}/${ue(t)},target:${e===scrapbox.Project.name?"":"_blank"},rel:${e===scrapbox.Project.name?"route":"noopener noreferrer"},onClick:i,children:[t,m("div",{className:"description",children:a})]})};var am=e=>{let[t,r]=X(e),n=I(()=>r(!0),[]),o=I(()=>r(!1),[]),s=I(()=>r(i=>!i),[]);return[t,{open:n,close:o,toggle:s}]};var cm=" must not return ",YE="transformer",VE="recoverer",XE="defaultValue",I2=YE+cm,lm="called with ",D2=XE+" must not be ",$2=VE+cm,JE="Ok",um="Err",QE=lm+um,ZE=lm+JE,j2="Carrying E in "+um+" instead of throwing it directly. See .cause",Ac="an instance of Error of the current realm.",F2="The thrown value is not "+Ac,U2="The contained E should be "+Ac,B2="This .cause is not "+Ac;function Ic(e){return e.ok}function vo(e){return!e.ok}function Xr(e){return eT(e,QE)}function pm(e){return tT(e,ZE)}function eT(e,t){if(vo(e))throw new TypeError(t);return e.val}function tT(e,t){if(Ic(e))throw new TypeError(t);return e.err}var dm=(e,t)=>{let[r,n]=X(),[o,s]=X(!1),i=Ke(Promise.resolve());return ee(()=>{if(t===""){n(void 0);return}let a=!1;return i.current=(async()=>{if(await i.current,!a){s(!0);try{let c=await qd(t,e);if(a)return;n(Ic(c)?Xr(c):void 0)}finally{s(!1)}}})(),()=>a=!0},[t,e]),{loading:o,result:r}};var fm=()=>m("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 > * {
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 {
}
.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 rT=()=>m("i",{className:"spinner"}),mm=({exportOps:e})=>{let[t,r]=X(""),n=scrapbox.Project.name,{loading:o,result:s}=dm(n,t),i=I(d=>{r(d.currentTarget.value)},[]),[a,{open:c,close:l,toggle:p}]=am(!1),u=Ke({open:c,close:l,toggle:p});ee(()=>{Object.assign(u.current,{open:c,close:l,toggle:p})},[]),ee(()=>e(u.current),[e]);let f=I(d=>{d.target instanceof HTMLElement&&d.target.id==="background"&&l()},[]);return m(Y,{children:[m(fm,{}),m("div",{id:"background",className:modal${a?"":" closed"},onClick:f,children:[m("div",{className:"controller",children:[m("input",{type:"text",value:t,onInput:i}),m("div",{className:"info",children:[o&&m(rT,{}),${s?.pages?.length??0} pages]})]}),s?.pages&&s.pages.length>0&&m("ul",{className:"result",children:s.pages.map(d=>m("li",{children:m(im,{...d,project:n,query:t,close:l})},d.title))})]})]})};var hm=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});return document.body.append(e),new Promise(r=>{lt(m(mm,{exportOps:r}),t)})};var Ys=(e,t)=>Object.hasOwn(e,t),gm={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:">"},wm=e=>{let t=e.toLowerCase();return Ys(gm,t)?gm[t]:e},ym={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:"/","?"},nT=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return Ys(ym,e)?ymet?1:0:e},bm={"<":"lt",">":"gt"},oT=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,Dc=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=nT(e.code||"",t):(r=wm(r),r===" "&&(r="Space")),oT.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let n="";return e.altKey&&(n+="a-"),e.ctrlKey&&(n+="c-"),e.metaKey&&(n+="m-"),t&&(n+="s-"),Ys(bm,r)&&(r=bmr),n||r.length>1?<${n}${r}>:r},xm={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},sT=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,n=t,o={key:wm(n)};for(let s of r.split("-").slice(0,-1)){let i=s.toLowerCase();if(!Ys(xm,i))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let a=xmi;if(oa!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(oa=!0,o.key.length===1&&o.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:o}},vm=e=>{let t=sT(e);return t.ok?{ok:!0,value:Dc(t.value)}:t},km=e=>e.match(/<^<>\s+>|\s\S|^$/g);var Nt=!1;var Em=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,r;switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{Nt!==!0&&(!Nt||!Nt.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{Nt!==!0&&(!Nt||!Nt.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{Nt!==!0&&(!Nt||!Nt.has(e))||r(${e} ${n})}];default:returnt,(...n)=>{if(!(Nt!==!0&&(!Nt||!Nt.has(e))))return r(...n)}}}));var Jr=Em("ScrapBindings:mod.ts"),Vs=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let n=new Map,o=[];for(lets,iof t instanceof Map?t.entries():typeof t=="string"?t,r:Object.entries(t)){let a=Tm(s);if(!a.ok){for(let l of a.value)Jr.error(${s}: ${l.message});n.set(s,a.value);continue}let c=a.value;this.bindings.set(c,i),c.startsWith(this.currentSequence)&&this.filtered.add(c),o.push(c)}return Jr.debug("Binded the following commands:",o),this.emitChange(),n}unbind(...t){for(let r of t){let n=Tm(r);if(!n.ok)continue;let o=n.value;this.bindings.delete(o),this.filtered.delete(o)}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()),Jr.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=Dc(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,Jr.debug("sequence",this.currentSequence);let n;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}n=()=>{Jr.debug(run ${s});try{i(t)}catch(a){Jr.error(a)}finally{this.backToInitial()}}}let o=this.filtered.size;if(Jr.debug(${o} candidates: ${[...this.filtered.keys()].join(", ")}),o>0&&(this.prevBestMatchCommand=n),this.prevBestMatchCommand&&o<2){if(this.prevBestMatchCommand(),o===0){this.handleKeydown(t);return}return}if(o===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)}},iT={name:"InvalidSequenceError",message:"cannot parse the sequence"},Tm=e=>{let t=km(e);if(!t)return{ok:!1,value:iT};let r="",n=[];for(let o of t){let s=vm(o);if(!s.ok){n.push(s.value);continue}r+=s.value}return n.length>0?{ok:!1,value:n}:{ok:!0,value:r}};var Pm=()=>{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 p=Pc(r.line)??0,u={start:{line:r.line,char:0},end:{line:r.line+p,char:tt(r.line+p)?.length??0}};return{selectionRange:u,selectedText:scrapbox.Page.lines.slice(u.start.line,u.end.line+1).map(f=>f.text).join(` )}}let{start:n,end:o}=e,s=n.line>o.line,i=s?o.line:n.line,a=s?o.char:n.char,c=s?n.line:o.line,l=s?n.char:o.char;return{selectedText:t,selectionRange:{start:{line:i,char:a},end:{line:c,char:l}}}};var $c=(e,{title:t,projectTo:r,mode:n})=>{let[o,...s]=e.split(
),i=o.replaceAll("[","").replaceAll("]","").trim(),a=Math.min(...[o,...s].map(l=>ur(l))),c=[from ${t},o.slice(a),...s.map(l=>l.slice(a))];return{text:${i},pages:[{project:r,title:i,lines:c,mode:n}]}};$c.hookName="default-hook";var dr=e=>{let{project:t=scrapbox.Project.name,mode:r="newtab"}=e??{},n=[...e?.hooks??[],$c],{selectionRange:{start:o,end:s},selectedText:i}=Pm();if(!i||scrapbox.Layout!=="page")return;let a=(()=>{for(let u of n){let f=u(i,{title:scrapbox.Page.title,projectFrom:scrapbox.Project.name,projectTo:t,lines:gt().slice(o.line,s.line+1),mode:r});if(f)return[u.hookName,f]}})();if(!a)return;let[c,l]=a,p=async()=>{let u=l instanceof Promise?await l:l;if(u.pages.length===0&&u.text===i)return;let f,{render:d,dispose:h}=_e();try{if(u.pages.length>0){let y=u.pages.length;d({type:"spinner"},{type:"text",text:Create new ${y} pages...});let w=await ot(e?.socket);if(G(w))throw ne(w);f=B(w);let R=0;await Promise.all(u.pages.map(async E=>{let b=Array.isArray(E.lines)?k=>[...k.map(v=>v.text),...E.lines]:E.lines;await we(E.project,E.title,b,{socket:f}),d({type:"spinner"},{type:"text",text:Create ${y-++R} pages...})}))}d({type:"spinner"},{type:"text",text:${u.pages.length>0?"Created. ":""}Removing cut text...});let g=u.text;if(i===g)return;await we(scrapbox.Project.name,scrapbox.Page.title,y=>{let w=y.map(R=>R.text);return[...w.slice(0,o.line),...${wo.line.slice(0,o.char)}${g}${w.slice(s.line).join(` ).slice(s.char)}.split(`
)]}),d({type:"check-circle"},{type:"text",text:"Removed."});for(let y of u.pages)switch(y.mode){case"self":y.project===scrapbox.Project.name?xo(y.project,y.title):globalThis.open(https://scrapbox.io/${y.project}/${ue(y.title)},"_self");break;case"newtab":globalThis.open(https://scrapbox.io/${y.project}/${ue(y.title)});break}}catch(g){d({type:"exclamation-triangle"},{type:"text",text:"Failed to create new pages (see console)."}),console.error(g)}finally{let g=Pe(1e3);f&&await at(f),await g,h()}};return p.hookName=c,p};function aT(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Rm(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function cT(e){if(!aT(e)&&typeof e!="number")return!1;let t=Rm(e);return!isNaN(Number(t))}function Sr(e,t){let r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}var lT={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return Sr(t==="yy"?n%100:n,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):Sr(r+1,2)},d(e,t){return Sr(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 Sr(e.getHours()%12||12,t.length)},H(e,t){return Sr(e.getHours(),t.length)},m(e,t){return Sr(e.getMinutes(),t.length)},s(e,t){return Sr(e.getSeconds(),t.length)},S(e,t){let r=t.length,n=e.getMilliseconds(),o=Math.trunc(n*Math.pow(10,r-3));return Sr(o,t.length)}},uT=/(\w)\1*|''|'(''|[^'])+('|$)|./g,pT=/^'([^]*?)'?$/,dT=/''/g,fT=/[a-zA-Z]/;function ft(e,t){let r=Rm(e);if(!cT(r))throw new RangeError("Invalid time value");let n=t.match(uT);return n?n.map(o=>{if(o==="''")return"'";let s=o[0];if(s==="'")return mT(o);let i=lT[s];if(i)return i(r,o);if(s.match(fT))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return o}).join(""):""}function mT(e){let t=e.match(pT);return t?t[1].replace(dT,"'"):e}function hT(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Sm(e){return hT(e).getDate()}var gT=Math.pow(10,8)*24*60*60*1e3,F3=-gT;var yT=3600,_m=yT*24,U3=_m*7,bT=_m*365.2425,xT=bT/12,B3=xT*3;function wT(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Lm(e){return wT(e).getMonth()}function vT(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Cm(e){return vT(e).getFullYear()}var Om=e=>{let t=new Map;for(let r of e){let n=${Cm(r)}-${Lm(r)}-${Sm(r)},o=t.get(n);o&&o.getTime()>r.getTime()||t.set(n,r)}return[...t.values()]};var kT=Math.pow(10,8)*24*60*60*1e3,AW=-kT,Mm=6048e5,ET=864e5,Fc=6e4,Am=36e5,TT=1e3;var PT=3600;var Im=PT*24,IW=Im*7,RT=Im*365.2425,ST=RT/12,DW=ST*3,Nm=Symbol.for("constructDateFrom");function Ce(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Nm in e?e[Nm](t):e instanceof Date?new e.constructor(t):new Date(t)}function ae(e,t){return Ce(t||e,e)}function We(e,t,r){let n=ae(e,r?.in);return isNaN(t)?Ce(r?.in||e,NaN):(t&&n.setDate(n.getDate()+t),n)}function _T(e,t,r){let n=ae(e,r?.in);if(isNaN(t))return Ce(r?.in||e,NaN);if(!t)return n;let o=n.getDate(),s=Ce(r?.in||e,n.getTime());s.setMonth(n.getMonth()+t+1,0);let i=s.getDate();return o>=i?s:(n.setFullYear(s.getFullYear(),s.getMonth(),o),n)}function Dm(e,t,r){let{years:n=0,months:o=0,weeks:s=0,days:i=0,hours:a=0,minutes:c=0,seconds:l=0}=t,p=ae(e,r?.in),u=o||n?_T(p,o+n*12):p,f=i||s?We(u,i+s*7):u,d=c+a*60,h=(l+d*60)*1e3;return Ce(r?.in||e,+f+h)}function $m(e,t,r){return Ce(r?.in||e,+ae(e)+t)}function jm(e,t,r){return $m(e,t*Am,r)}var LT={};function Qs(){return LT}function ut(e,t){let r=Qs(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=ae(e,t?.in),s=o.getDay(),i=(s<n?7:0)+s-n;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function On(e,t){return ut(e,{...t,weekStartsOn:1})}function CT(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=Ce(r,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let s=On(o),i=Ce(r,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);let a=On(i);return r.getTime()>=s.getTime()?n+1:r.getTime()>=a.getTime()?n:n-1}function Xs(e){let t=ae(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 Zs(e,...t){let r=Ce.bind(null,e||t.find(n=>typeof n=="object"));return t.map(r)}function Nn(e,t){let r=ae(e,t?.in);return r.setHours(0,0,0,0),r}function Fm(e,t,r){let[n,o]=Zs(r?.in,e,t),s=Nn(n),i=Nn(o),a=+s-Xs(s),c=+i-Xs(i);return Math.round((a-c)/ET)}function OT(e,t){let r=CT(e,t),n=Ce(t?.in||e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),On(n)}function Lr(e,t,r){let n=ae(e,r?.in);return n.setTime(n.getTime()+t*Fc),n}function ei(e,t,r){return $m(e,t*1e3,r)}function ti(e,t,r){return We(e,t*7,r)}function Um(e,t){let r=+ae(e)-+ae(t);return r<0?-1:r>0?1:r}function Et(e,t,r){let[n,o]=Zs(r?.in,e,t);return+Nn(n)==+Nn(o)}function NT(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Qr(e){return!(!NT(e)&&typeof e!="number"||isNaN(+ae(e)))}function Bm(e,t,r){let[n,o]=Zs(r?.in,e,t),s=n.getFullYear()-o.getFullYear(),i=n.getMonth()-o.getMonth();return s*12+i}function MT(e){return t=>{let r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function AT(e,t){return+ae(e)-+ae(t)}function Uc(e,t,r){let n=AT(e,t)/Fc;return MT(r?.roundingMethod)(n)}function Hm(e,t){let r=ae(e,t?.in);return r.setHours(23,59,59,999),r}function Wm(e,t){let[r,n]=Zs(e,t.start,t.end);return{start:r,end:n}}function qm(e,t){let{start:r,end:n}=Wm(t?.in,e),o=+r>+n,s=o?+r:+n,i=o?n:r;i.setHours(0,0,0,0);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,o=!o);let c=[];for(;+i<=s;)c.push(Ce(r,i)),i.setDate(i.getDate()+a),i.setHours(0,0,0,0);return o?c.reverse():c}function zm(e,t){let{start:r,end:n}=Wm(t?.in,e),o=+r>+n,s=ut(o?n:r,t),i=ut(o?r:n,t);s.setHours(15),i.setHours(15);let a=+i.getTime(),c=s,l=t?.step??1;if(!l)return[];l<0&&(l=-l,o=!o);let p=[];for(;+c<=a;)c.setHours(0),p.push(Ce(r,c)),c=ti(c,l),c.setHours(15);return o?p.reverse():p}function jc(e){return(t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}var IT={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},DT={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},$T={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},$W={date:jc({formats:IT,defaultWidth:"full"}),time:jc({formats:DT,defaultWidth:"full"}),dateTime:jc({formats:$T,defaultWidth:"full"})};function ko(e){return(t,r)=>{let n=r?.context?String(r.context):"standalone",o;if(n==="formatting"&&e.formattingValues){let i=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{let i=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;o=e.values[a]||e.values[i]}let s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}var jT={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},FT={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},UT={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"]},BT={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"]},HT={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"}},WT={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"}},qT=(e,t)=>{let r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},jW={ordinalNumber:qT,era:ko({values:jT,defaultWidth:"wide"}),quarter:ko({values:FT,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ko({values:UT,defaultWidth:"wide"}),day:ko({values:BT,defaultWidth:"wide"}),dayPeriod:ko({values:HT,defaultWidth:"wide",formattingValues:WT,defaultFormattingWidth:"wide"})};function Eo(e){return(t,r={})=>{let n=r.width,o=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;let i=s[0],a=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?GT(a,u=>u.test(i)):zT(a,u=>u.test(i)),l;l=e.valueCallback?e.valueCallback(c):c,l=r.valueCallback?r.valueCallback(l):l;let p=t.slice(i.length);return{value:l,rest:p}}}function zT(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function GT(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function KT(e){return(t,r={})=>{let n=t.match(e.matchPattern);if(!n)return null;let o=n[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(o.length);return{value:i,rest:a}}}var YT=/^(\d+)(th|st|nd|rd)?/i,VT=/\d+/i,XT={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},JT={any:[/^b/i,/^(a|c)/i]},QT={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ZT={any:[/1/i,/2/i,/3/i,/4/i]},eP={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},tP={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]},rP={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},nP={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]},oP={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},sP={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}},FW={ordinalNumber:KT({matchPattern:YT,parsePattern:VT,valueCallback:e=>parseInt(e,10)}),era:Eo({matchPatterns:XT,defaultMatchWidth:"wide",parsePatterns:JT,defaultParseWidth:"any"}),quarter:Eo({matchPatterns:QT,defaultMatchWidth:"wide",parsePatterns:ZT,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Eo({matchPatterns:eP,defaultMatchWidth:"wide",parsePatterns:tP,defaultParseWidth:"any"}),day:Eo({matchPatterns:rP,defaultMatchWidth:"wide",parsePatterns:nP,defaultParseWidth:"any"}),dayPeriod:Eo({matchPatterns:oP,defaultMatchWidth:"any",parsePatterns:sP,defaultParseWidth:"any"})};function iP(e,t){let r=ae(e,t?.in),n=+On(r)-+OT(r);return Math.round(n/Mm)+1}function ri(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=Qs(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,i=Ce(t?.in||e,0);i.setFullYear(n+1,0,s),i.setHours(0,0,0,0);let a=ut(i,t),c=Ce(t?.in||e,0);c.setFullYear(n,0,s),c.setHours(0,0,0,0);let l=ut(c,t);return+r>=+a?n+1:+r>=+l?n:n-1}function aP(e,t){let r=Qs(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=ri(e,t),s=Ce(t?.in||e,0);return s.setFullYear(o,0,n),s.setHours(0,0,0,0),ut(s,t)}function Mn(e,t){let r=ae(e,t?.in),n=+ut(r,t)-+aP(r,t);return Math.round(n/Mm)+1}function _r(e,t){let r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}var cP={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return _r(t==="yy"?n%100:n,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):_r(r+1,2)},d(e,t){return _r(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 _r(e.getHours()%12||12,t.length)},H(e,t){return _r(e.getHours(),t.length)},m(e,t){return _r(e.getMinutes(),t.length)},s(e,t){return _r(e.getSeconds(),t.length)},S(e,t){let r=t.length,n=e.getMilliseconds(),o=Math.trunc(n*Math.pow(10,r-3));return _r(o,t.length)}};function Gm(e,t){return ae(e,t?.in).getDate()}function lP(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=r.getMonth(),s=Ce(r,0);return s.setFullYear(n,o+1,0),s.setHours(0,0,0,0),s.getDate()}function Km(e,t){return ae(e,t?.in).getHours()}function uP(e,t){let r=ae(e,t?.in).getDay();return r===0?7:r}function Ym(e,t){return ae(e,t?.in).getMinutes()}function Bc(e,t){return ae(e,t?.in).getFullYear()}function Zr(e,t){return+ae(e)>+ae(t)}var pP=class{subPriority=0;validate(e,t){return!0}},dP=class extends pP{constructor(e,t,r,n,o){super(),this.value=e,this.validateValue=t,this.setValue=r,this.priority=n,o&&(this.subPriority=o)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,r){return this.setValue(e,t,this.value,r)}};var pe=class{run(e,t,r,n){let o=this.parse(e,t,r,n);return o?{setter:new dP(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,t,r){return!0}},fP=class extends pe{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"]},$e={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}/},Xt={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 je(e,t){return e&&{value:t(e.value),rest:e.rest}}function Le(e,t){let r=t.match(e);return r?{value:parseInt(r[0],10),rest:t.slice(r[0].length)}:null}function Jt(e,t){let r=t.match(e);if(!r)return null;if(r[0]==="Z")return{value:0,rest:t.slice(1)};let n=r[1]==="+"?1:-1,o=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:n*(o*Am+s*Fc+i*TT),rest:t.slice(r[0].length)}}function Vm(e){return Le($e.anyDigitsSigned,e)}function Me(e,t){switch(e){case 1:return Le($e.singleDigit,t);case 2:return Le($e.twoDigits,t);case 3:return Le($e.threeDigits,t);case 4:return Le($e.fourDigits,t);default:return Le(new RegExp("^\\d{1,"+e+"}"),t)}}function Js(e,t){switch(e){case 1:return Le($e.singleDigitSigned,t);case 2:return Le($e.twoDigitsSigned,t);case 3:return Le($e.threeDigitsSigned,t);case 4:return Le($e.fourDigitsSigned,t);default:return Le(new RegExp("^-?\\d{1,"+e+"}"),t)}}function Hc(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 Xm(e,t){let r=t>0,n=r?t:1-t,o;if(n<=50)o=e||100;else{let s=n+50,i=Math.trunc(s/100)*100,a=e>=s%100;o=e+i-(a?100:0)}return r?o:1-o}function Jm(e){return e%400===0||e%4===0&&e%100!==0}var mP=class extends pe{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){let n=o=>({year:o,isTwoDigitYear:t==="yy"});switch(t){case"y":return je(Me(4,e),n);case"yo":return je(r.ordinalNumber(e,{unit:"year"}),n);default:return je(Me(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){let n=e.getFullYear();if(r.isTwoDigitYear){let s=Xm(r.year,n);return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}let o=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(o,0,1),e.setHours(0,0,0,0),e}},hP=class extends pe{priority=130;parse(e,t,r){let n=o=>({year:o,isTwoDigitYear:t==="YY"});switch(t){case"Y":return je(Me(4,e),n);case"Yo":return je(r.ordinalNumber(e,{unit:"year"}),n);default:return je(Me(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,n){let o=ri(e,n);if(r.isTwoDigitYear){let i=Xm(r.year,o);return e.setFullYear(i,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),ut(e,n)}let s=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(s,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),ut(e,n)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},gP=class extends pe{priority=130;parse(e,t){return Js(t==="R"?4:t.length,e)}set(e,t,r){let n=Ce(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),On(n)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},yP=class extends pe{priority=130;parse(e,t){return Js(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"]},bP=class extends pe{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return Me(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"]},xP=class extends pe{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return Me(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"]},wP=class extends pe{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){let n=o=>o-1;switch(t){case"M":return je(Le($e.month,e),n);case"MM":return je(Me(2,e),n);case"Mo":return je(r.ordinalNumber(e,{unit:"month"}),n);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}},vP=class extends pe{priority=110;parse(e,t,r){let n=o=>o-1;switch(t){case"L":return je(Le($e.month,e),n);case"LL":return je(Me(2,e),n);case"Lo":return je(r.ordinalNumber(e,{unit:"month"}),n);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"]};function Wc(e,t,r){let n=ae(e,r?.in),o=Mn(n,r)-t;return n.setDate(n.getDate()-o*7),ae(n,r?.in)}var kP=class extends pe{priority=100;parse(e,t,r){switch(t){case"w":return Le($e.week,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return Me(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,n){return ut(Wc(e,r,n),n)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]};function EP(e,t,r){let n=ae(e,r?.in),o=iP(n,r)-t;return n.setDate(n.getDate()-o*7),n}var TP=class extends pe{priority=100;parse(e,t,r){switch(t){case"I":return Le($e.week,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return Me(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){return On(EP(e,r))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},PP=[31,28,31,30,31,30,31,31,30,31,30,31],RP=[31,29,31,30,31,30,31,31,30,31,30,31],SP=class extends pe{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return Le($e.date,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return Me(t.length,e)}}validate(e,t){let r=e.getFullYear(),n=Jm(r),o=e.getMonth();return n?t>=1&&t<=RP[o]:t>=1&&t<=PP[o]}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"]},_P=class extends pe{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return Le($e.dayOfYear,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return Me(t.length,e)}}validate(e,t){let r=e.getFullYear();return Jm(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"]};function qc(e,t,r){let n=Qs(),o=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=ae(e,r?.in),i=s.getDay(),a=(t%7+7)%7,c=7-o,l=t<0||t>6?t-(i+c)%7:(a+c)%7-(i+c)%7;return We(s,l,r)}var LP=class extends pe{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,n){return e=qc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},CP=class extends pe{priority=90;parse(e,t,r,n){let o=s=>{let i=Math.floor((s-1)/7)*7;return(s+n.weekStartsOn+6)%7+i};switch(t){case"e":case"ee":return je(Me(t.length,e),o);case"eo":return je(r.ordinalNumber(e,{unit:"day"}),o);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,n){return e=qc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},OP=class extends pe{priority=90;parse(e,t,r,n){let o=s=>{let i=Math.floor((s-1)/7)*7;return(s+n.weekStartsOn+6)%7+i};switch(t){case"c":case"cc":return je(Me(t.length,e),o);case"co":return je(r.ordinalNumber(e,{unit:"day"}),o);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,n){return e=qc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]};function NP(e,t,r){let n=ae(e,r?.in),o=uP(n,r),s=t-o;return We(n,s,r)}var MP=class extends pe{priority=90;parse(e,t,r){let n=o=>o===0?7:o;switch(t){case"i":case"ii":return Me(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return je(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiii":return je(r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiiii":return je(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiii":default:return je(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"}),n)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){return e=NP(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"]},AP=class extends pe{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(Hc(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},IP=class extends pe{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(Hc(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},DP=class extends pe{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(Hc(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},$P=class extends pe{priority=70;parse(e,t,r){switch(t){case"h":return Le($e.hour12h,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return Me(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){let n=e.getHours()>=12;return n&&r<12?e.setHours(r+12,0,0,0):!n&&r===12?e.setHours(0,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},jP=class extends pe{priority=70;parse(e,t,r){switch(t){case"H":return Le($e.hour23h,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return Me(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"]},FP=class extends pe{priority=70;parse(e,t,r){switch(t){case"K":return Le($e.hour11h,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return Me(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"]},UP=class extends pe{priority=70;parse(e,t,r){switch(t){case"k":return Le($e.hour24h,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return Me(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){let n=r<=24?r%24:r;return e.setHours(n,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},BP=class extends pe{priority=60;parse(e,t,r){switch(t){case"m":return Le($e.minute,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return Me(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"]},HP=class extends pe{priority=50;parse(e,t,r){switch(t){case"s":return Le($e.second,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return Me(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},WP=class extends pe{priority=30;parse(e,t){let r=n=>Math.trunc(n*Math.pow(10,-t.length+3));return je(Me(t.length,e),r)}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},qP=class extends pe{priority=10;parse(e,t){switch(t){case"X":return Jt(Xt.basicOptionalMinutes,e);case"XX":return Jt(Xt.basic,e);case"XXXX":return Jt(Xt.basicOptionalSeconds,e);case"XXXXX":return Jt(Xt.extendedOptionalSeconds,e);case"XXX":default:return Jt(Xt.extended,e)}}set(e,t,r){return t.timestampIsSet?e:Ce(e,e.getTime()-Xs(e)-r)}incompatibleTokens=["t","T","x"]},zP=class extends pe{priority=10;parse(e,t){switch(t){case"x":return Jt(Xt.basicOptionalMinutes,e);case"xx":return Jt(Xt.basic,e);case"xxxx":return Jt(Xt.basicOptionalSeconds,e);case"xxxxx":return Jt(Xt.extendedOptionalSeconds,e);case"xxx":default:return Jt(Xt.extended,e)}}set(e,t,r){return t.timestampIsSet?e:Ce(e,e.getTime()-Xs(e)-r)}incompatibleTokens=["t","T","X"]},GP=class extends pe{priority=40;parse(e){return Vm(e)}set(e,t,r){return[Ce(e,r*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"},KP=class extends pe{priority=20;parse(e){return Vm(e)}set(e,t,r){return[Ce(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"},UW={G:new fP,y:new mP,Y:new hP,R:new gP,u:new yP,Q:new bP,q:new xP,M:new wP,L:new vP,w:new kP,I:new TP,d:new SP,D:new _P,E:new LP,e:new CP,c:new OP,i:new MP,a:new AP,b:new IP,B:new DP,h:new $P,H:new jP,K:new FP,k:new UP,m:new BP,s:new HP,S:new WP,X:new qP,x:new zP,t:new GP,T:new KP};function fr(e,t,r){return We(e,-t,r)}var YP=/(\w)\1*|''|'(''|[^'])+('|$)|./g,VP=/^'([^]*?)'?$/,XP=/''/g,JP=/[a-zA-Z]/;function Ht(e,t){let r=ae(e);if(!Qr(r))throw new RangeError("Invalid time value");let n=t.match(YP);return n?n.map(o=>{if(o==="''")return"'";let s=o[0];if(s==="'")return QP(o);let i=cP[s];if(i)return i(r,o);if(s.match(JP))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return o}).join(""):""}function QP(e){let t=e.match(VP);return t?t[1].replace(XP,"'"):e}function ZP(e,t,r){let n=ae(e,r?.in),o=n.getFullYear(),s=n.getDate(),i=Ce(r?.in||e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);let a=lP(i);return n.setMonth(t,Math.min(s,a)),n}function Qm(e,t,r){let n=ae(e,r?.in);return isNaN(+n)?Ce(r?.in||e,NaN):(t.year!=null&&n.setFullYear(t.year),t.month!=null&&(n=ZP(n,t.month)),t.date!=null&&n.setDate(t.date),t.hours!=null&&n.setHours(t.hours),t.minutes!=null&&n.setMinutes(t.minutes),t.seconds!=null&&n.setSeconds(t.seconds),t.milliseconds!=null&&n.setMilliseconds(t.milliseconds),n)}function Zm(e,t,r){return ti(e,-t,r)}var eh=e=>e==null,Cr=e=>typeof e=="string";async function*th(e){let t=[],r,n=i=>{if(!r){t.push(i);return}r(i),r=void 0},o=()=>t.length>0?Promise.resolve(t.pop()):new Promise(i=>r=i),s=0;for(let i of e)i.then(a=>n({state:"fulfilled",value:a})).catch(a=>n({state:"rejected",reason:a})),s++;for(let i=0;i<s;i++)yield await o()}var mt=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,n,o,s,i,a,c,l,p,u,f,d,h]=t,g={title:h,base:new Date(parseInt(r),parseInt(n)-1,parseInt(o)),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(p)),g.record.start=y}if(u){let y=new Date(g.base);y.setHours(parseInt(u)),y.setMinutes(parseInt(f)),y.setSeconds(parseInt(d)),g.record.start&&Zr(g.record.start,y)&&y.setDate(y.getDate()+1),g.record.end=y}return g};var An=e=>e.record?.start??e.plan?.start??e.base,rh=e=>e.record?.end??(eh(e.plan?.duration)?e.base:ei(An(e),e.plan.duration));var Se=({title:e,base:t,plan:r,record:n})=>["",Ht(t,"yyyy-MM-dd")," ",r?.start?Ht(r.start,"HH:mm"):" ".repeat(5)," ",r?.duration?${r.duration/60}.padStart(4,"0"):" ".repeat(4)," ",n?.start?Ht(n?.start,"HH:mm:ss"):" ".repeat(8)," ",n?.end?Ht(n?.end,"HH:mm:ss"):" ".repeat(8),"",e].join("");function*nh(e){for(let t of en(e))Cr(t)||(yield t)}function*en(e){for(let t=0;t<e.length;t++){let r=e[t],n=Cr(r)?r:r.text,o=Yr(t,e),s=mt(n);if(!s){yield n;continue}yield{...s,lines:e.slice(t+1,t+1+o).map(i=>Cr(i)?i:i.text)},t+=o}}var eR=5*60,zc=async()=>{let e=He().position.line,t=mt(tt(e)??""),r=t?.base??new Date,n={start:t?.plan?.start?ei(t.plan.start,eR+(t.plan.duration??0)):void 0,duration:t?.plan?.duration};await em(e+1,Se({title:"",base:r,plan:n,record:{}}))};var ni=async()=>{let e=He().position.line,t=mt(tt(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;n||await yt(e,e,Se({record:{start:r?void 0:new Date},...o}))};var In=async()=>{let e=He().position.line,t=mt(tt(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;r&&await yt(e,e,Se({record:{start:r,end:n?void 0:new Date},...o}))};var Gc=async()=>{let e=He().position.line,t=mt(tt(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;if(r){if(n)return;await In();return}if(n)return;let s;for(let{text:a}of pr().slice(0,(e??0)+1).reverse()){let{record:c}=mt(a)??{};if(c?.end){s=c.end;break}}let i=new Date;await yt(e,e,Se({record:{start:s??i,end:i},...o}))};var tn=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:n}=He();return r===""?[n.line,n.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var Kc=(e,t=7)=>new Date((e+2592e3*((t+1)**1.5-1)/5221.154823442138)*1e3);var Yc=(e,t)=>{let r,n,o,s,i=null;if(i=e.match(/^(.*?)(s|e):([^\s]+)\s+d:(\d+)/))[,n,s,o,r]=i;else if(i=e.match(/^(.*?)d:(\d+)\s+(s|e):([^\s]+)/))[,n,r,s,o]=i;else if(i=e.match(/^(.*?)(s|e):([^\s]+)/))[,n,s,o]=i;else return(i=e.match(/^(.*?)d:(\d+)/))?([,n,r]=i,{name:n.trimEnd(),duration:parseInt(r)*60}):void 0;for(let{test:a,parse:c}of tR){let l=o.match(a);if(!l)continue;let p=c(l),u=p.isDuration?Dm(t,p):Qm(t,p);return s==="s"?{name:n.trimEnd(),start:u,...r!==void 0?{duration:parseInt(r)*60}:{}}:{name:n.trimEnd(),start:Kc(t.getTime()/1e3,(u.getTime()-t.getTime())/(24*60*60*1e3)),...r!==void 0?{duration:parseInt(r)*60}:{}}}},tR=[{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 To=async()=>{let e=new Date,[t,r]=tn(),n=pr().slice(t,r+1).map(s=>s.text),o=n.flatMap(s=>{let i=s.trimEnd();if(i==="")return s;let{name:a,start:c,duration:l}=Yc(i,e)??{};return!a||!c&&!l?s:[Se({title:a.trim(),base:c??e,plan:{start:c,duration:l},record:{}})]}).join( );n.join(
)!==o&&await yt(t,r,o)};var oi=async(e,t,r)=>{let n=[];for(let o=e;o<=t;o++){let s=tt(o)??"",i=mt(s);if(!i){n.push(s);continue}n.push(Se(r(i,o)))}await yt(e,t,n.join(
))};var Vc=async(e=1)=>{let[t,r]=tn();await oi(t,r,n=>(n.base=We(n.base,e),n))};var Xc=async()=>{let[e,t]=tn(),r=new Date;await oi(e,t,n=>(Et(n.base,r)||(n.base=r),n))};var rR="日刊記録sheet",nR=/日刊記録sheet (\d{4})-(\d{2})-(\d{2})/,Po=["[** 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 Jc=e=>{let t=e.match(nR);if(!t)return;let[,r,n,o]=t,s=new Date(parseInt(r),parseInt(n)-1,parseInt(o));return Qr(s)?s:void 0},Ro=e=>Ht(e,'${rR}' yyyy-MM-dd),si=e=>{let t=Jc(e[0]);if(!t)return e;let r=oR(t),n=[],o=[];for(let a of en(e.slice(1))){if(typeof a=="string"){if(Po.includes(a)||r!==""&&r===a)continue;o.push(a);continue}n.push(a)}let s=n.sort((a,c)=>Um(An(a),An(c)));if(s.length===0)return[e[0],r,...Po,...o];let i=[0,0,0,0,0,0,0,0];for(let a=1;a<Po.length;a++){let c=jm(new Date(t.getFullYear(),t.getMonth(),t.getDate()),3*a),l=s.findIndex(d=>Zr(An(d),c));if(l<0){i[a]=-1;continue}if(l===0)continue;let p=s[l-1],u=An(p),f=rh(p);i[a]=(f.getTime()-u.getTime())/2<c.getTime()-u.getTime()?l:l-1}return[e[0],r,...s.flatMap((a,c)=>[...i.flatMap((l,p)=>l===c?[Po[p]]:[]),Se(a),...a.lines]),...i.flatMap((a,c)=>a===-1?[Po[c]]:[]),...o]},oR=e=>yesterday: ${Ro(fr(e,1))};var Qc=async(e,t)=>{let r=()=>{},n=setTimeout(()=>{let{render:o,dispose:s}=_e();r=s,o({type:"spinner"},{type:"text",text:"formatting..."})},500);await we(e,t,o=>si(o.map(s=>s.text))),clearTimeout(n),r()};async function*Zc(e,t,r){let n=[...t],o=[];for(;n.length>0;){let s=n.shift();if(!s)break;let i=s.base,a=[s];for(let c=0;c<n.length;c++)Et(n[c].base,i)&&(a.push(...n.splice(c,1)),c--);o.push((async()=>(await we(e,Ro(i),c=>si([...c.map(l=>l.text),...a.flatMap(l=>[Se(l),...l.lines??[]])]),r),{date:i,size:a.length}))())}yield*th(o)}var So=async({from:{project:e,title:t},to:r})=>{let n=await Ct(e,t);if(G(n))throw ne(n);let o=Jc(t),{lines:s}=B(n),i=[];for(let u of nh(s))o&&Et(u.base,o)||i.push(u);let{render:a,dispose:c}=_e();a({type:"spinner"},{type:"text",text:copying ${i.length} tasks...});let l=await ot();if(G(l))throw ne(l);let p=B(l);try{let u=0,f=!1;for await(let d of Zc(r,i,{socket:p})){if(d.state!=="fulfilled"){console.error(d.reason),f=!0;continue}u+=d.value.size,a({type:"spinner"},{type:"text",text:copying ${i.length-u} 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 we(e,t,d=>{let h=[];for(let g of en(d)){if(Cr(g)){h.push(g);continue}o&&Et(g.base,o)&&h.push(Se(g),...g.lines)}return h},{socket:p}),a({type:"check-circle"},{type:"text",text:"Moved"})}finally{await at(p),await Pe(1e3),c()}};var oh=e=>typeof e=="string";var Or=e=>e.match(/^(\s*)/)?.[1]?.length??0,ih=(e,t)=>{let r=Or(sh(e,t)),n=0;for(;e+n+1<t.length&&Or(sh(e+n+1,t))>r;)n++;return n},sh=(e,t)=>{let r=t[e];return oh(r)?r:r.text};var Wt=e=>${e}.padStart(2,"0");var rn=e=>"hours"in e,Mt=(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,Qt=e=>${${e.year}.padStart(4,"0")}-${Wt(e.month)}-${Wt(e.date)}${"hours"in e?T${Wt(e.hours)}:${Wt(e.minutes)}:""},de=e=>{let t=Qt(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 ch=e=>{switch(e.toLowerCase()){case"y":return"yearly";case"m":return"monthly";case"w":return"weekly";case"d":return"daily";default:return}};var lh=e=>{switch(e){case"+":return"todo";case"-":return"note";case"!":return"deadline";case".":return"done";case"~":return"up-down";default:return}},uh=e=>{switch(e){case"todo":return"+";case"note":return"-";case"deadline":return"!";case"done":return".";case"up-down":return"~"}};var Nr=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,n,o,s,i,a,c,l,p,u,f,d,h,g,y,w,R,E,b,k,v,L,O,$,S,T,P,_,N,M,j,A,W]=t,F=${e.slice(0,t.index).trim()}${e.slice((t.index??0)+r.length).trim()},q=ph(s,i,a,c,l);if(!Qr(de(q)))return Z({name:"InvalidDateError",message:The reference point of the task "${Qt(q)}" is an invalid date.});let z=dh(q,f,d,h,p||g,u||y,w);if(z!==void 0){if(Ye(z)&&isNaN(z)||!Ye(z)&&!Qr(de(z)))return Z({name:"InvalidDateError",message:The estimated end of the task${Ye(z)?"": "${Qt(z)}"} is an invalid date.});if(Ye(z)&&z<0||!Ye(z)&&Mt(z,q))return Z({name:"TaskRangeError",message:The reference point of an task cannot be after its estimated end. reference point:${Qt(q)}
estimated end:${Qt(Ye(z)?ht(Lr(de(q),z)):z)}})}let se=/^[\uFE00-\uFE0F]*[✅❌]/.test(e)?"done":lh(n),Q=se?{status:se,refDate:q}:void 0;Q&&o&&(Q.speed=parseInt(o));let et=ph(v||s,L||i,O||a,b||$||c,k||S||l);if(!Qr(de(et)))return Z({name:"InvalidDateError",message:The start of the task/event "${Qt(et)}" is an invalid date.});let Ee=dh(et,_||f,N||d,M||h,T||j||p||g,P||A||u||y,W||w),D=rn(et)&&Ye(Ee)?{start:et,duration:Ee}:void 0;if(D){let st={name:F,executed:D,generated:!1,raw:e};return Q&&(st.freshness=Q),(R||E)&&(st.recurrence={frequency:ch(R??"D")??"daily",count:E?parseInt(E):1}),be(st)}if(!Q)return Z({name:"InvalidDateError",message:"Task requires freshness to be spec"});let he={name:F,freshness:Q,generated:!1,raw:e};return z&&(he.estimated=z),be(D?{...he,executed:D}:he)},Zt=e=>!("executed"in e),Dn=e=>"recurrence"in e,fh=e=>!("executed"in e||"freshness"in e&&rn(e.freshness.refDate)&&e.estimated&&(Ye(e.estimated)||rn(e.estimated))),Lo=e=>"executed"in e?e.executed.duration:Ye(e.estimated)?e.estimated:void 0,er=e=>Zt(e)?e.freshness.refDate:e.executed.start,mh=e=>{if(!Zt(e)){let r=de(e.executed.start);return ht(Lr(r,e.executed.duration))}if(Ye(e.estimated)&&rn(e.freshness.refDate)){let r=de(e.freshness.refDate);return ht(Lr(r,e.estimated))}let t=de(Ye(e.estimated)?e.freshness.refDate:e.estimated??e.freshness.refDate);return t.setHours(0),t.setMinutes(0),ht(We(t,1))},uR=e=>{let t=e.freshness?${uh(e.freshness.status)}${e.freshness.speed??""}:"",r=${Qt(er(e))},n=Lo(e);return${t}@${r}${n===void 0?"":D${n}}${e.name}},ii=(e,t)=>{let r=ht(t),{recurrence:n,executed:o}=e;switch(n.frequency){case"yearly":{if(Math.abs(r.year-o.start.year)%(n.count??1)!==0||o.start.month!==r.month||o.start.date!==r.date)return;break}case"monthly":{if(Bm(de(r),de(o.start))%(n.count??1)!==0)return;break}case"weekly":case"daily":{let a=n.frequency==="weekly"?7:1;if(Fm(de(r),de(o.start))%((n.count??1)*a)!==0)return;break}}let s={...o.start};s.year=r.year,s.month=r.month,s.date=r.date;let i={name:e.name,executed:{start:s,duration:o.duration},generated:!0,raw:e.raw};return e.freshness&&(i.freshness=e.freshness),i},ai=e=>e.freshness?e.generated?uR(e):e.raw:e.generated?void 0:e.raw,ph=(e,t,r,n,o)=>{let s=parseInt(e),i=parseInt(t),a=parseInt(r),c=n?parseInt(n):void 0,l=o?parseInt(o):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}},dh=(e,t,r,n,o,s,i)=>{if(!t&&!r&&!n&&!o&&!s&&!i)return;if(i)return parseInt(i);let a=t?parseInt(t):e.year,c=r?parseInt(r):e.month,l=n?parseInt(n):e.date,p=o?parseInt(o):void 0,u=s?parseInt(s):void 0,f=p!==void 0&&u!==void 0?{year:a,month:c,date:l,hours:p,minutes:u}:{year:a,month:c,date:l};return!rn(e)||!rn(f)?f:Math.round((de(f).getTime()-de(e).getTime())/(60*1e3))};var el=(e,t)=>{if(!e.generated&&Dn(e)){let s=ii(e,t);return s?el(s,t):void 0}let r=de(Zt(e)?e.freshness.refDate:e.executed.start),n=Lo(e),o=ai(e);return{title:o!==void 0?${o}:e.name,base:r,plan:{start:fh(e)?void 0:r,duration:n!==void 0?n*60:void 0},record:{}}};var tl={あさごはん:"#log-breakfast",ひるごはん:"#log-lunch",よるごはん:"#log-dinner"},nn=(e,{title:t,projectTo:r,mode:n})=>{let[o,...s]=e.split( ),i=mt(o);if(!i)return;if(s.length===0)return{text:e,pages:[]};let{title:a,base:c,record:l,...p}=i,u=pR(a,c,l),f=Se({title:${u},base:c,record:l,...p}),d=Math.min(...s.map(g=>Or(g))),h=[.../[\[\]]/.test(a)&&a!==${u}?[a]:[],...t in tl?[...s.map(g=>g.slice(d)),"",tl[t],"#log-eatenfood"]:[...s.map(g=> ${g.slice(d)}),""]];return{text:f,pages:[{project:r,title:u,lines:hh(t,h,[l.start??c]),mode:n}]}};nn.hookName="task-hook";var pR=(e,t,r)=>{let n=ft(r.start??t,"yyyy-MM-dd");if(e in tl)return${n} ${e};if(Nr(e.slice(1,-1)))return e.slice(1,-1);let o=e.replace(/[\[\]]/g,"").trim();return${o}${o.endsWith(n)?"": ${n}}},on=(e,{title:t,projectTo:r,mode:n,lines:o})=>{let[s,...i]=e.split( );if(i.length===0)return;let a=s.replace(/[\[\]]/g,"").trim(),c=Math.min(...i.map(u=>Or(u))),l=r.startsWith("takker")?Om([new Date,...o.map(({updated:u})=>new Date(u*1e3))]).sort((u,f)=>f.getTime()-u.getTime()):[],p=["",.../[\[\]]/.test(s)?[s.trimStart()]:[],...i.map(u=>u.slice(c))];return{text:${" ".repeat(Or(s))}${a},pages:[{project:r,title:a,lines:hh(t,p,l),mode:n}]}};on.hookName="new-page-hook";var sn=(e,{projectTo:t,mode:r})=>{if(e.includes( )||!/\[[^\]]+\]/.test(e))return;let[n,o]=e.match(/^(\s*)(.*)$/)?.slice?.(1)??["",e],s=[...o.matchAll(/\[([^\]])\]/g)].map(a=>oe(a[1])),i=o.replaceAll("[","").replaceAll("]","");return{text:${n}${i},pages:[{project:t,title:i,lines:(a,{links:c})=>{let l=c.map(p=>oe(p));if(!s.every(p=>l.includes(p)))return[...a.map(p=>p.text),o]},mode:r}]}};sn.hookName="splitted-link-hook";var hh=(e,t,r)=>(n,{links:o})=>{let s=o.map(u=>oe(u)),i=s.includes(oe(e))?[]:[from ${e}],a=r.flatMap(u=>{let f=ft(u,"yyyy-MM-dd");if(s.includes(f))return[];let d=ft(u,"HH:mm:ss");return[#${f} ${d}]}),c=n.map(u=>u.text),l=c.findIndex(u=>/^#\d{4}-\d{2}-\d{2}/.test(u)),p=l<0?c.length:l;return[...c.slice(0,p),...i,...t,"",...a,...c.slice(p)]};var gh=e=>e.preventDefault(),yh=e=>e.stopPropagation(),bh={"<A-a><A-c>":async e=>{gh(e),yh(e);let[t,r]=dR(),n=pr().slice(t,r+1).map(o=>{let s=o.text,i=o.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=Nr(i);if(!a||vo(a))return s;let c=Xr(a);if(c.freshness?.status==="done")return s;let l=el(c,new Date);return l?(l.title=${i},Se(l)):s}).join( );await yt(t,r,n),await To()},"<A-a><A-m>":e=>{scrapbox.Layout==="page"&&(gh(e),yh(e),So({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"}))}},dR=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:n}=He();return r===""?[n.line,n.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var an=e=>e.preventDefault(),cn=e=>e.stopPropagation(),rl={"<A-a><A-a>":e=>{an(e),cn(e),zc()},"<A-a><A-s>":e=>{an(e),cn(e),ni()},"<A-a><A-e>":e=>{an(e),cn(e),In()},"<A-a><A-0>":e=>{an(e),cn(e),Gc()},"<A-a><A-1>":e=>{an(e),cn(e),Vc(1)},"<A-a><A-t>":e=>{an(e),cn(e),Xc()},"<A-a><A-S>":e=>{scrapbox.Layout==="page"&&(an(e),cn(e),Qc(scrapbox.Project.name,scrapbox.Page.title))}};var Je=e=>e.preventDefault(),Qe=e=>e.stopPropagation(),ln=(e,t)=>{let r=Bf()?.getElementsByClassName?.("button");if(!r)return;let n=[...r].find(o=>t instanceof RegExp?t.test(o.textContent??""):o.textContent===t);n instanceof HTMLDivElement&&e.target===document.activeElement&&(Je(e),Qe(e),n.click())},fR={"-":e=>ln(e,""),"]":e=>ln(e,""),c:e=>ln(e,"Copy plain"),$:e=>ln(e,""),"{":e=>ln(e,/{{c\d+}}/),"}":e=>ln(e,"reset cloze"),n:e=>ln(e,"make note")},mR={"<C-]>":e=>{let{position:{line:t,char:r}}=He(),n=bo(t,r)?.closest("a.page-link")??Vr(t)?.querySelector?.("a.page-link");n instanceof HTMLAnchorElement&&(Je(e),Qe(e),n.click())},"<C-o>":e=>{Je(e),Qe(e),history.back()}},hR={"<C-home>":e=>{Je(e),Qe(e),Vf()},"<C-end>":e=>{Je(e),Qe(e),Xf()}},xh=[nn,on,sn],gR={"<C-X>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(Je(e),Qe(e),dr({project:t,mode:"self",hooks:xh})?.())},"<C-D>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(Je(e),Qe(e),dr({project:t,mode:"noopen",hooks:xh})?.())},"<C-h>":e=>{Je(e),Qe(e),$s()},"<C-j>":e=>{Je(e),Qe(e),Fs()},"<C-k>":e=>{Je(e),Qe(e),js()},"<C-l>":e=>{Je(e),Qe(e),Ds()},"<A-h>":e=>{Je(e),Qe(e),Bs()},"<A-j>":e=>{Je(e),Qe(e),Ws()},"<A-k>":e=>{Je(e),Qe(e),Hs()},"<A-l>":e=>{Je(e),Qe(e),Us()}};scrapbox.TimeStamp.removeAllFormats();var yR={"<A-t><A-t>":e=>{Je(e),Qe(e),Xe(ft(new Date,"#yyyy-MM-dd HH:mm:ss "))},"<A-t><A-j>":e=>{Je(e),Qe(e),Xe(ft(new Date,"yyyy-MM-dd HH:mm:ss "))},"<A-t><A-k>":e=>{Je(e),Qe(e),Xe(ft(new Date,"HH:mm:ss "))},"<A-t><A-l>":e=>{Je(e),Qe(e),Xe(ft(new Date,"yyyy-MM-dd"))}},wh={...fR,...mR,...hR,...gR,...yR,...bh};var{render:bR}=_e(),nl,xR=e=>{nl!==void 0&&cancelAnimationFrame(nl),nl=requestAnimationFrame(()=>bR({type:"text",text:e}))},ol=new Vs({addEventListener:nm,removeEventListener:Mc},{onSequenceUpdate:xR}),vh=ol.bind({...wh,...scrapbox.Project.name==="takker-memex"?rl:{}});vh.size>0&&alert([...vh.entries()].map(([e,t])=>${e}:
${t.map(r=>- ${r}).join(`
)}).join(`
));var wR=/https?:\/\/vimeo\.com\/([0-9]+)/i,kh=e=>{let t=e.match(wR);if(t)return t[1]};var vR=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Eh=e=>{let t=e.match(vR);if(!t)return;let[,r,n]=t;return{videoId:n,pathType:r}};var kR=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Th=e=>{let t=e.match(kR);if(!t)return;let[,r]=t;return r};var Ph=e=>{let{type:t,pathType:r,content:n,href:o,...s}=e;if(n===""){let i=Es(o);if(i)return{type:"youtube",href:o,...i,...s};let a=kh(o);if(a)return{type:"vimeo",videoId:a,href:o,...s};let c=Eh(o);if(c)return{type:"spotify",href:o,...c,...s};let l=Th(o);if(l)return{type:"anchor-fm",videoId:l,href:o,...s};if(TR(o))return{type:"video",href:o,...s}}return ER(o)?{type:"audio",content:n,href:o,...s}:{type:"absoluteLink",content:n,href:o,...s}},ER=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),TR=e=>/\.(?:mp4|webm)$/.test(e);var Rh=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),n=await ks([]);if(G(n))return r;let o=B(n).projects.map(s=>s.id);return r.filter(s=>!o.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var PR;(e=>{})(PR||={});var RR="0.13.3",sl,il,Sh=(e=RR)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(il)throw il;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,sl=new Promise((n,o)=>{r.onload=()=>n(window.katex),r.onerror=s=>{il=s,o(s)},document.head.append(r)})}return sl||new Promise(r=>{let n=setInterval(()=>{window.katex&&(clearInterval(n),r(window.katex))},500)})};var ci=(e,t)=>{let[r,n]=X("");return{ref:I(s=>{if(!s){n("");return}Sh().then(i=>{try{i.render(e,s,t),n("")}catch(a){if(a instanceof Error&&a.name==="ParseError")n(a.message.slice(19));else throw a}})},[e,...Object.values(t??{})]),error:r}};var _h=e=>{let t=[],r=new Set,n=o=>{r.delete(o);let s=t.pop();if(!s)return;let i=s[0]().finally(()=>n(i)).then(a=>s[1](a)).catch(a=>s[2](a));r.add(i)};return o=>{if(r.size<e){let s=o().finally(()=>n(s));return r.add(s),s}return new Promise((s,i)=>{t.push([o,s,i])})}};var SR="0.6.5",Oh=ScrapBubble-${SR},Lh=await globalThis.caches.open(Oh);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Oh&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var Ch=_h(3);async function*li(e,t){let r=((t?.saveFailedResponse?Lh.match(e):void 0)??Cn(e,t)).then(i=>["cache",i]);{let i=Pe(1e3).then(()=>"timeout"),a=await Promise.race([r,i]);if(a!=="timeout"){a[1]&&(yield["cache",a[1]]);let c=await Ch(()=>fetch(e));!c.ok&&t?.saveFailedResponse&&await Lh.put(e,c.clone()),yield["network",c]}}let n=Ch(()=>fetch(e)).then(i=>["network",i]),[o,s]=await Promise.race([r,n]);if(o==="network"){yield[o,s];return}s&&(yield[o,s]),yield await n}var Nh=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var ui=()=>{let e=new Map;return{dispatch:(t,r)=>{let n=e.get(t);if(n)for(let o of n)o(r)},on:(t,r)=>{let n=e.get(t)??new Set;n.add(r),e.set(t,n)},off:(t,r)=>{let n=e.get(t);n&&n.delete(r)}}};var Tt=!1,Mh=e=>{Tt=typeof e=="boolean"?e:new Set(e)},Mr=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{Tt!==!0&&(!Tt||!Tt.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{Tt!==!0&&(!Tt||!Tt.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{Tt!==!0&&(!Tt||!Tt.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(Tt!==!0&&(!Tt||!Tt.has(e))))return r(...n)}]}}));var al=ui(),pi=new Map,_R=Mr("ScrapBubble:useProject.ts"),Ah=e=>{let[t,r]=X();return ee(()=>{al.on(e,r);let n=pi.get(e);return n?r(n.loading?void 0:n.value):(pi.set(e,{loading:!0}),r(void 0),(async()=>{try{let o=ar.toRequest(e);for await(let[,s]of li(o)){let i=await ar.fromResponse(s);pi.set(e,{loading:!1,value:i}),al.dispatch(e,i);break}}catch(o){_R.error(o),pi.delete(e)}})()),()=>al.off(e,r)},[e]),t};var LR=["default-light","default-dark","default-minimal"],CR=["paper-light","paper-dark-dark","paper-dark"],Ih=["blue","purple","green","orange","red"],OR=["hacker1","hacker2"],Dh=["winter","spring","summer","automn"],$h=["tropical"],jh=["kyoto","newyork","paris"],Fh=["mred","lgreen"],oY=["default-light","default-minimal","paper-light",...Ih,...Dh,...$h,...jh,...Fh];var NR=[...LR,...CR,...Ih,...OR,...Dh,...$h,...jh,...Fh];function Uh(e){return NR.includes(e)}var Bh="default-light",un=e=>{let t=Ah(e);return C(()=>{if(!t||G(t))return Bh;let r=B(t).theme;return Uh(r)?r:Bh},[t])};var $n=(e,t)=>new Promise(r=>{let n=!1,o=()=>{n=!0,r(!1)};e.addEventListener("click",o),e.addEventListener("pointerleave",o),setTimeout(()=>{n||r(!0),e.removeEventListener("click",o),e.removeEventListener("pointerleave",o),r(!1)},t)});var jn=e=>{let{top:t,right:r,left:n,bottom:o}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),i=(n-s.left)/s.width>.5;return{top:Math.round(o-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...i?{right:Math.round(s.right-r)}:{left:Math.round(n-s.left)},maxWidth:i?r-10:document.documentElement.clientWidth-n-10}};var Hh=({project:e,title:t,descriptions:r,thumbnail:n,linkTo:o,bubble:s,delay:i,prefetch:a})=>{let c=C(()=>n?[]:Ue(r.join( ),{hasTitle:!1}),[n,r]),l=un(e),p=I(async({currentTarget:f})=>{a(e,t),await $n(f,i)&&s({project:e,title:t,linkTo:o,type:"link",position:jn(f)})},[e,t,i,o?.project,o?.titleLc]),u=C(()=>o?()=>{Ln({type:"page",from:{project:o.project??e,title:o.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,o?.project,o?.titleLc]);return m("a",{className:"related-page-card page-link",type:"link","data-theme":l,href:/${e}/${ue(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:p,onClick:u,children:[m("div",{class:"hover"}),m("div",{class:"content",children:[m("div",{class:"header",children:m("div",{class:"title",children:t})}),n?m("div",{class:"thumbnail",children:m("img",{src:n})}):m("div",{class:"description",children:c.flatMap((f,d)=>f.type==="line"?[m("p",{children:f.nodes.map(h=>m(Wh,{node:h,project:e}))},d)]:[])})]})]})},Wh=({node:e,project:t})=>{switch(e.type){case"code":return m("code",{children:e.text});case"formula":return m(MR,{node:e});case"commandLine":return m("code",{children:[e.symbol," $",e.text]});case"helpfeel":return m("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return m(Y,{children:e.nodes.map(r=>m(Wh,{node:r,project:t}))});case"icon":case"strongIcon":return m(AR,{node:e,project:t});case"hashTag":return m(IR,{node:e});case"link":return m(DR,{node:e});case"plain":case"blank":return m(Y,{children:e.text});default:return m(Y,{})}},MR=({node:{formula:e}})=>{let{ref:t,error:r}=ci(e);return m("span",{className:formula ${r?" error":""},children:r?m("code",{children:e}):m("span",{className:"katex-display",ref:t})})},AR=({node:{pathType:e,path:t},project:r})=>{let[n,o]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return m("img",{class:"icon",src:/api/pages/${n}/${ue(o)}/icon})},IR=({node:{href:e}})=>m("span",{class:"page-link",children:["#",e]}),DR=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?m("span",{class:"page-link",children:t}):m("span",{class:"link",children:r||t});var me=(e,t)=>/${e.toLowerCase()}/${oe(t)},di=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var Vh=Symbol.for("immer-nothing"),qh=Symbol.for("immer-draftable"),fe=Symbol.for("immer-state");function At(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var Fn=Object.getPrototypeOf;function Un(e){return!!e&&!!e[fe]}function hr(e){return e?Xh(e)||Array.isArray(e)||!!e[qh]||!!e.constructor?.[qh]||yi(e)||bi(e):!1}var $R=Object.prototype.constructor.toString();function Xh(e){if(!e||typeof e!="object")return!1;let t=Fn(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)===$R}function Co(e,t){gi(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function gi(e){let t=e[fe];return t?t.type_:Array.isArray(e)?1:yi(e)?2:bi(e)?3:0}function ul(e,t){return gi(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Jh(e,t,r){let n=gi(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function jR(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function yi(e){return e instanceof Map}function bi(e){return e instanceof Set}function rt(e){return e.copy_||e.base_}function pl(e,t){if(yi(e))return new Map(e);if(bi(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Xh(e);if(t===!0||t==="class_only"&&!r){let n=Object.getOwnPropertyDescriptors(e);delete n[fe];let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++){let i=o[s],a=n[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(n[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(Fn(e),n)}else{let n=Fn(e);if(n!==null&&r)return{...e};let o=Object.create(n);return Object.assign(o,e)}}function hl(e,t=!1){return xi(e)||Un(e)||!hr(e)||(gi(e)>1&&(e.set=e.add=e.clear=e.delete=FR),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>hl(n,!0))),e}function FR(){At(2)}function xi(e){return Object.isFrozen(e)}var dl={};function pn(e){let t=dl[e];return t||At(0,e),t}function UR(e,t){dl[e]||(dl[e]=t)}var Oo;function fi(){return Oo}function BR(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function zh(e,t){t&&(pn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function fl(e){ml(e),e.drafts_.forEach(HR),e.drafts_=null}function ml(e){e===Oo&&(Oo=e.parent_)}function Gh(e){return Oo=BR(Oo,e)}function HR(e){let t=e[fe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Kh(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[fe].modified_&&(fl(t),At(4)),hr(e)&&(e=mi(t,e),t.parent_||hi(t,e)),t.patches_&&pn("Patches").generateReplacementPatches_(r[fe].base_,e,t.patches_,t.inversePatches_)):e=mi(t,r,[]),fl(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Vh?e:void 0}function mi(e,t,r){if(xi(t))return t;let n=t[fe];if(!n)return Co(t,(o,s)=>Yh(e,n,t,o,s,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return hi(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,i=!1;n.type_===3&&(s=new Set(o),o.clear(),i=!0),Co(s,(a,c)=>Yh(e,n,o,a,c,r,i)),hi(e,o,!1),r&&e.patches_&&pn("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Yh(e,t,r,n,o,s,i){if(Un(o)){let a=s&&t&&t.type_!==3&&!ul(t.assigned_,n)?s.concat(n):void 0,c=mi(e,o,a);if(Jh(r,n,c),Un(c))e.canAutoFreeze_=!1;else return}else i&&r.add(o);if(hr(o)&&!xi(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;mi(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&hi(e,o)}}function hi(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&hl(t,r)}function WR(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:fi(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=gl;r&&(o=[n],s=No);let{revoke:i,proxy:a}=Proxy.revocable(o,s);return n.draft_=a,n.revoke_=i,a}var gl={get(e,t){if(t===fe)return e;let r=rt(e);if(!ul(r,t))return qR(e,r,t);let n=r[t];return e.finalized_||!hr(n)?n:n===cl(e.base_,t)?(ll(e),e.copy_[t]=Mo(n,e)):n},has(e,t){return t in rt(e)},ownKeys(e){return Reflect.ownKeys(rt(e))},set(e,t,r){let n=Qh(rt(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=cl(rt(e),t),s=o?.[fe];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(jR(r,o)&&(r!==void 0||ul(e.base_,t)))return!0;ll(e),mr(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 cl(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ll(e),mr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=rt(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){At(11)},getPrototypeOf(e){return Fn(e.base_)},setPrototypeOf(){At(12)}},No={};Co(gl,(e,t)=>{No[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});No.deleteProperty=function(e,t){return No.set.call(this,e,t,void 0)};No.set=function(e,t,r){return gl.set.call(this,e[0],t,r,e[0])};function cl(e,t){let r=e[fe];return(r?rt(r):e)[t]}function qR(e,t,r){let n=Qh(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function Qh(e,t){if(!(t in e))return;let r=Fn(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Fn(r)}}function mr(e){e.modified_||(e.modified_=!0,e.parent_&&mr(e.parent_))}function ll(e){e.copy_||(e.copy_=pl(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var zR=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(a=s,...c){return i.produce(a,l=>r.call(this,l,...c))}}typeof r!="function"&&At(6),n!==void 0&&typeof n!="function"&&At(7);let o;if(hr(t)){let s=Gh(this),i=Mo(t,void 0),a=!0;try{o=r(i),a=!1}finally{a?fl(s):ml(s)}return zh(s,n),Kh(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===Vh&&(o=void 0),this.autoFreeze_&&hl(o,!0),n){let s=[],i=[];pn("Patches").generateReplacementPatches_(t,o,s,i),n(s,i)}return o}else At(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,a=>t(a,...i));let n,o;return[this.produce(t,r,(s,i)=>{n=s,o=i}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){hr(e)||At(8),Un(e)&&(e=GR(e));let t=Gh(this),r=Mo(e,void 0);return r[fe].isManual_=!0,ml(t),r}finishDraft(e,t){let r=e&&e[fe];(!r||!r.isManual_)&&At(9);let{scope_:n}=r;return zh(n,t),Kh(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=pn("Patches").applyPatches_;return Un(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Mo(e,t){let r=yi(e)?pn("MapSet").proxyMap_(e,t):bi(e)?pn("MapSet").proxySet_(e,t):WR(e,t);return(t?t.scope_:fi()).drafts_.push(r),r}function GR(e){return Un(e)||At(10,e),Zh(e)}function Zh(e){if(!hr(e)||xi(e))return e;let t=e[fe],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=pl(e,t.scope_.immer_.useStrictShallowCopy_)}else r=pl(e,!0);return Co(r,(n,o)=>{Jh(r,n,Zh(o))}),t&&(t.finalized_=!1),r}function eg(){class e extends Map{constructor(c,l){super(),this[fe]={type_:2,parent_:l,scope_:l?l.scope_:fi(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:c,draft_:this,isManual_:!1,revoked_:!1}}get size(){return rt(this[fe]).size}has(c){return rt(this[fe]).has(c)}set(c,l){let p=this[fe];return i(p),(!rt(p).has(c)||rt(p).get(c)!==l)&&(r(p),mr(p),p.assigned_.set(c,!0),p.copy_.set(c,l),p.assigned_.set(c,!0)),this}delete(c){if(!this.has(c))return!1;let l=this[fe];return i(l),r(l),mr(l),l.base_.has(c)?l.assigned_.set(c,!1):l.assigned_.delete(c),l.copy_.delete(c),!0}clear(){let c=this[fe];i(c),rt(c).size&&(r(c),mr(c),c.assigned_=new Map,Co(c.base_,l=>{c.assigned_.set(l,!1)}),c.copy_.clear())}forEach(c,l){let p=this[fe];rt(p).forEach((u,f,d)=>{c.call(l,this.get(f),f,this)})}get(c){let l=this[fe];i(l);let p=rt(l).get(c);if(l.finalized_||!hr(p)||p!==l.base_.get(c))return p;let u=Mo(p,l);return r(l),l.copy_.set(c,u),u}keys(){return rt(this[fe]).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 p=this.get(l.value);return{done:!1,value:[l.value,p]}}}}[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 n extends Set{constructor(c,l){super(),this[fe]={type_:3,parent_:l,scope_:l?l.scope_:fi(),modified_:!1,finalized_:!1,copy_:void 0,base_:c,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return rt(this[fe]).size}has(c){let l=this[fe];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[fe];return i(l),this.has(c)||(s(l),mr(l),l.copy_.add(c)),this}delete(c){if(!this.has(c))return!1;let l=this[fe];return i(l),s(l),mr(l),l.copy_.delete(c)||(l.drafts_.has(c)?l.copy_.delete(l.drafts_.get(c)):!1)}clear(){let c=this[fe];i(c),rt(c).size&&(s(c),mr(c),c.copy_.clear())}values(){let c=this[fe];return i(c),s(c),c.copy_.values()}entries(){let c=this[fe];return i(c),s(c),c.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(c,l){let p=this.values(),u=p.next();for(;!u.done;)c.call(l,u.value,u.value,this),u=p.next()}}function o(a,c){return new n(a,c)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(c=>{if(hr(c)){let l=Mo(c,a);a.drafts_.set(c,l),a.copy_.add(l)}else a.copy_.add(c)}))}function i(a){a.revoked_&&At(3,JSON.stringify(rt(a)))}UR("MapSet",{proxyMap_:t,proxySet_:o})}var Pt=new zR,wi=Pt.produce,SY=Pt.produceWithPatches.bind(Pt),_Y=Pt.setAutoFreeze.bind(Pt),LY=Pt.setUseStrictShallowCopy.bind(Pt),CY=Pt.applyPatches.bind(Pt),OY=Pt.createDraft.bind(Pt),NY=Pt.finishDraft.bind(Pt);eg();var tg=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},rg=(e,t)=>wi(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:n,linked:o,projectLinked:s,...i}=t;Object.assign(r,i),yl(t)||(r.lines=n),o&&(r.linked??=o),s&&(r.projectLinked??=s);return}yl(r)&&!yl(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)}),yl=e=>e.lines[0].id==="dummy";var ng=(e,t)=>{let r=new Map,n=oe(t.title);for(let c of t.links){let l=bl(e,c);l.linked=[n],r.set(me(e,c),l)}let o=me(e,n),s=t.projectLinks.map(c=>{let l=di(c);return me(l.project,l.titleLc)}),i={...vi(e,t),linked:[],projectLinked:[]};r.set(o,i);let a=t.links.map(c=>oe(c));for(let c of t.relatedPages.links1hop){c.linksLc.includes(n)&&i.linked.push(c.titleLc);for(let f of c.linksLc.filter(d=>a.includes(d))){let d=me(e,f),h=r.get(d)??bl(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=me(e,c.titleLc),p=vi(e,c),u=r.get(l)?.linked;u&&(p.linked=u),r.set(l,p)}for(let c of t.relatedPages.projectLinks1hop){let l=me(c.projectName,c.titleLc);s.includes(l)||i.projectLinked.push(l);let p=vi(c.projectName,c),u=r.get(l)?.projectLinked;u&&(p.projectLinked=u),r.set(l,p)}i.isLinkedCorrect=!0;for(let c of t.relatedPages.links2hop){for(let f of c.linksLc){let d=me(e,f),h=r.get(d)??bl(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=me(e,c.titleLc),p=vi(e,c),u=r.get(l)?.linked;u&&(p.linked=u),r.set(l,p)}return r},vi=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:oe(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:t.descriptions,image:t.image,lines:"lines"in t?t.lines:[t.title,...t.descriptions].map(r=>({text:r,id:"dummy",userId:"dummy",updated:t.updated,created:t.updated})),updated:t.updated,isLinkedCorrect:!1}),bl=(e,t)=>({project:e,titleLc:oe(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var ki=Mr("ScrapBubble:bubble.ts"),xl=new Map,Ei=new Set,wl=ui();function*sg(e){for(let t of e)yield xl.get(t)}var ig=(e,t)=>wl.on(e,t),ag=(e,t)=>wl.off(e,t),cg=async(e,t,r,n)=>{let o=[];for(let s of[...t].reverse()){let i=me(s,e);Ei.has(i)||o.push(KR(s,e,r,n))}await Promise.all(o)},og=0,KR=async(e,t,r,n)=>{let o=me(e,t);if(Ei.has(o))return;Ei.add(o);let s=og++,i=${s} Check update ${o};ki.time(i);try{let a=Ct.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[c,l]of li(a,{ignoreSearch:!0,saveFailedResponse:!0})){ki.debug(${s}${c} ${o});let p=await Ct.fromResponse(l);if(kr(p)){let u=ng(e,B(p));for(let[f,d]of u){let h=xl.get(f),g=rg(h,d);g&&h!==g&&(xl.set(f,g),wl.dispatch(f,d))}}if(n?.ignoreFetch===!0||c==="cache"&&!Nh(l,n?.maxAge??60))break}}catch(a){ki.error(a)}finally{Ei.delete(o),ki.timeEnd(i),og--}};var lg=Mr("ScrapBubble:useBubbleData.ts"),Bn=e=>{let[t,r]=X(vl(e));return ee(()=>{r(vl(e));let n,o=()=>{clearTimeout(n),n=setTimeout(()=>{lg.debug(Update ${e.length} pages),r(vl(e))},10)};return e.forEach(s=>ig(s,o)),()=>e.forEach(s=>ag(s,o))},e),t},vl=e=>{let t=[...sg(e)].flatMap(r=>r?[r]:[]);return lg.debug(Required: ${e.length} pages, ${t.length} found,t),t};var ug=({source:e,linked:t,externalLinked:r,projectsForSort:n,...o})=>{let s=C(()=>[...t.keys(),...r.keys()],[t,r]),i=Bn(s),a=C(()=>[...n],[n]),c=C(()=>{let p=(u,f)=>{let d=a.indexOf(u.project),h=a.indexOf(f.project);return d===h?f.updated-u.updated:d<0?1:h<0?-1:d-h};return[...i].sort(p)},[i,a]),l=C(()=>({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 m("ul",{className:"card-bubble",style:l,onClick:o.onClick,children:c.map(({project:p,titleLc:u,lines:[{text:f}],descriptions:d,image:h})=>{let g=me(p,u),y=t.get(g)??r.get(g);return m("li",{children:m(Hh,{project:p,title:f,linkTo:y,descriptions:d,thumbnail:h??"",...o})},g)})})};var Hn=e=>{e:if(e.pathType==="root"){let[,r="",n=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(r==="")break e;let[,o]=n?.match?.(/#([a-f\d]{24,32})$/)??["",""];return n===""?{project:r}:o===""?{project:r,title:n}:{project:r,title:n.slice(0,-1-o.length),hash:o}}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 kl=(e,t)=>t.some(r=>{let n=!e.project;switch(r.type){case"hashTag":return n&&oe(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==n)return!1;let{project:o,title:s=""}=Hn({pathType:r.pathType,href:r.href});return n?!o&&oe(s)===e.titleLc:o===e.project&&oe(s)===e.titleLc}case"quote":case"strong":case"decoration":return kl(e,r.nodes)}});var Ar=mo({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),dg=({lines:e,project:t,title:r,whiteList:n,noIndent:o,hash:s,linkTo:i,...a})=>{let c=C(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),l=C(()=>{let d=0;return Ue(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[d++]};case"codeBlock":{let g=d;return d+=h.content.split(
).length+1,{...h,ids:c.slice(g,d)}}case"table":{let g=d;return d+=h.cells.length+1,{...h,ids:c.slice(g,d)}}}})},[e,c]),p=C(()=>{if(s&&c.includes(s))return s;if(i)return l.find(d=>d.type!=="line"?!1:kl(i,d.nodes))?.id},[l,c,s,i?.project,i?.titleLc]),u=Ke(null);ee(()=>{if(!p)return;let d=u.current?.querySelector(data-id="${p}"),h=globalThis.scrollY;d?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,h)},[p]);let f=un(t);return m("div",{className:"lines","data-theme":f,ref:u,children:m(Ar.Provider,{value:{project:t,title:r,whiteList:n,...a},children:l.map(d=>{switch(d.type){case"title":return m(Y,{children:[m(qn,{index:d.id,indent:0,noIndent:o,permalink:d.id===p,children:m("a",{className:"page-link",type:"link",href:/${t}/${ue(d.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:d.text})},d.id),m("hr",{})]});case"codeBlock":return m(YR,{block:d,noIndent:o,ids:d.ids,scrollId:p},d.ids[0]);case"table":return m(VR,{block:d,noIndent:o,ids:d.ids,scrollId:p},d.ids[0]);case"line":return m(qn,{index:d.id,indent:d.indent,noIndent:o,permalink:d.id===p,children:d.nodes.length>0?d.nodes.map(h=>m(Wn,{node:h})):m("br",{})},d.id)}})})})},qn=({index:e,indent:t,noIndent:r,children:n,permalink:o})=>m("div",{className:line${o?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:n}),YR=({block:{fileName:e,content:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:i}=lr(Ar),[a,c]=X(""),l=I(async p=>{p.preventDefault(),p.stopPropagation();try{await navigator.clipboard.writeText(t),c("Copied"),await Pe(1e3),c("")}catch(u){alert(Failed to copy the code block Error: ${u})}},[t]);return m(Y,{children:[m(qn,{index:n[0],indent:r,permalink:n[0]===o,children:m("span",{className:"code-block",children:[m("span",{className:"code-block-start",children:m("a",{href:/api/code/${s}/${ue(i)}/${e},target:"_blank",children:e})}),m("span",{className:"copy",title:"Copy",onClick:l,children:a})]})}),m(Y,{children:t.split(
).map((p,u)=>m(qn,{index:n[u+1],indent:r,permalink:n[u+1]===o,children:m("code",{className:"code-block",children:p})}))})]})},VR=({block:{fileName:e,cells:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:i}=lr(Ar);return m(Y,{children:[m(qn,{index:n[0],indent:r,permalink:n[0]===o,children:m("span",{className:"table-block",children:m("span",{className:"table-block-start",children:m("a",{href:/api/table/${s}/${ue(i)}/${e}.csv,target:"_blank",children:e})})})}),m(Y,{children:t.map((a,c)=>m(qn,{index:n[c+1],indent:r,permalink:n[c+1]===o,children:m("span",{className:"table-block table-block-row",children:a.map((l,p)=>m("span",{className:cell col-${p},children:l.map(u=>m(Wn,{node:u}))}))})}))})]})},Wn=({node:e})=>{switch(e.type){case"code":return m("code",{className:"code",children:e.text});case"formula":return m(XR,{node:e});case"commandLine":return m(QR,{node:e});case"helpfeel":return m("code",{className:"helpfeel",children:[m("span",{className:"prefix",children:"?"})," ",m("span",{className:"entry",children:e.text})]});case"quote":return m("blockquote",{className:"quote",children:e.nodes.map(t=>m(Wn,{node:t}))});case"strong":return m("strong",{children:e.nodes.map(t=>m(Wn,{node:t}))});case"decoration":return m(JR,{node:e});case"plain":case"blank":return m(Y,{children:e.text});case"hashTag":return m(tS,{node:e});case"link":return m(rS,{node:e});case"googleMap":return m(ZR,{node:e});case"icon":return m(pg,{node:e});case"strongIcon":return m(pg,{node:e,strong:!0});case"image":return m(eS,{node:e});case"strongImage":return m("img",{className:"image strong-image",src:e.src});case"numberList":return m(Y,{children:[${e.number}. ,e.nodes.map(t=>m(Wn,{node:t}))]})}},XR=({node:{formula:e}})=>{let{ref:t,error:r}=ci(e);return m("span",{className:formula ${r?" error":""},children:r?m("code",{children:e}):m("span",{className:"katex-display",ref:t})})},JR=({node:{decos:e,nodes:t}})=>m("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>m(Wn,{node:r}))}),QR=({node:e})=>{let[t,r]=X(""),n=I(async o=>{o.preventDefault(),o.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await Pe(1e3),r("")}catch(s){alert(Failed to copy the code block
Error: ${s})}},[e.text]);return m(Y,{children:[m("code",{className:"cli",children:[m("span",{className:"prefix",children:e.symbol})," ",m("span",{className:"command",children:e.text})]}),m("span",{className:"tool-buttons",children:m("span",{title:"Copy",className:"copy",onClick:n,children:t})})]})},ZR=({node:{place:e,latitude:t,longitude:r,zoom:n}})=>m("span",{className:"pointing-device-map",children:m("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${n}z,rel:"noopner noreferrer",target:"_blank",children:m("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${n}&_csrf=${globalThis._csrf}})})}),pg=({node:{pathType:e,path:t},strong:r})=>{let{project:n}=lr(Ar),[o,s]=e==="relative"?[n,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[n,t],i=ue(s);return m("a",{href:/${o}/${i},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",children:m("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${o}/${i}/icon,children:s})})},eS=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return m("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank",children:m("img",{className:"image",src:t})})},tS=({node:{href:e}})=>{let{project:t}=lr(Ar),r=fg(t,e),n=mg(t,e,"hashtag");return m("a",{href:/${t}/${ue(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:n,children:["#",e]})},rS=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return m(nS,{pathType:e,href:t.href});case"absolute":{let r=Ph({pathType:e,...t});switch(r.type){case"youtube":return m(oS,{...r});case"vimeo":return m(sS,{...r});case"spotify":return m(iS,{...r});case"anchor-fm":return m(aS,{...r});case"audio":return m(cS,{...r});case"video":return m(uS,{...r});case"absoluteLink":return m("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},nS=({pathType:e,href:t})=>{let{project:r}=lr(Ar),{project:n=r,title:o,hash:s=""}=Hn({pathType:e,href:t}),i=mg(n,o,"link",s),a=fg(n,o??"");return m("a",{className:page-link${o!==void 0&&a?" empty-page-link":""},type:"link",href:/${n}${o===void 0?"":/${ue(o)}${s===""?"":#${s}}},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",onPointerEnter:i,children:t})},oS=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 m("div",{className:"iframe-video-player",children:m("iframe",{src:t,allowFullScreen:!0})})},sS=({videoId:e})=>m("div",{className:"iframe-video-player",children:m("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0})}),iS=e=>m("div",{className:"iframe-video-player",children:m("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0})}),aS=e=>m("div",{className:"iframe-video-player",children:m("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0})}),cS=e=>e.content===""?m("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):m(lS,{...e}),lS=({href:e,content:t})=>{let r=Ke(null),n=I(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return m("span",{className:"audio-link",children:[m("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),m("span",{className:"play",onClick:n,children:"♬"}),m("audio",{preload:"none",src:e,ref:r})]})},uS=({href:e})=>m("div",{className:"video-player",children:m("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),fg=(e,t)=>{let{whiteList:r}=lr(Ar),n=C(()=>(r.has(e)?[...r]:[e,...r]).map(s=>me(s,t)),[r,e]),o=Bn(n);return C(()=>tg(o),o)},mg=(e,t,r,n)=>{let{delay:o,bubble:s,prefetch:i}=lr(Ar);return I(async({currentTarget:a})=>{t&&(i(e,t),await $n(a,o)&&s({project:e,title:t,hash:n,type:r,position:jn(a)}))},[e,t,n,r,o,i,s])};var hg=({pages:e,onClick:t,source:r,whiteList:n,...o})=>{let[s,i]=X(me(e[0].project,e[0].titleLc)),a=C(()=>({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 m("div",{className:"text-bubble",style:a,onClick:t,children:[e.length>1&&m("div",{role:"tablist",children:e.map(c=>m(pS,{project:c.project,titleLc:c.titleLc,selected:s===me(c.project,c.titleLc),tabSelector:i},me(c.project,c.titleLc)))}),e.map(c=>m(dS,{selected:s===me(c.project,c.titleLc),...c,title:c.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:n,...o},me(c.project,c.titleLc)))]})},pS=({project:e,titleLc:t,tabSelector:r,selected:n})=>{let o=I(()=>r(me(e,t)),[e,t]),s=un(e);return m("button",{role:"tab","aria-selected":n,"data-theme":s,tabIndex:-1,onClick:o,children:e})},dS=({selected:e,...t})=>{let r=un(t.project);return m("div",{role:"tabpanel","data-theme":r,hidden:!e,children:m(dg,{...t})})};var gg=Mr("ScrapBubble:Bubble.tsx"),yg=({source:e,parentTitles:t,whiteList:r,...n})=>{let o=C(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,i,a]=mS(e,o,r,t);return m(Y,{children:[fS(a)&&m(hg,{pages:a,source:e,whiteList:r,onClick:n.hide,...n}),m(ug,{linked:s,externalLinked:i,onClick:n.hide,source:e,projectsForSort:o,...n})]})},fS=e=>e.length>0,mS=(e,t,r,n)=>{let[[o,s,i],a]=X([new Map,new Map,[]]),c=C(()=>{let u=[...t].map(f=>me(f,e.title));return gg.debug("projects",u),u},[t,e.title]),l=Bn(c),p=C(()=>n.map(u=>oe(u)),[n]);return Ns(()=>{let u=new Map,f=new Map,d=[];for(let h of l){let g={project:h.project,titleLc:h.titleLc};for(let w of h.projectLinked??[]){let{project:R,titleLc:E}=di(w);p.includes(E)&&r.has(R)||f.has(w)||f.set(w,g)}if(!r.has(h.project))continue;let y={titleLc:h.titleLc};for(let w of h.linked??[]){if(p.includes(w))continue;let R=me(h.project,w);u.has(R)||u.set(R,y)}p.includes(h.titleLc)||h.exists&&d.push(h)}a(wi(h=>{gg.debug(depth: ${p.length}, bubbled from ${me(e.project,e.title)}, bubbles,,l,"before",h[0],"internal cards,",u,"external cards",f);for(let g of h[0].keys())u.has(g)||h[0].delete(g);for(let[g,y]of u)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]=d}))},[l,r,p]),[o,s,i]};var bg=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var xg=e=>{let t=C(()=>bg(e.style,import.meta.url),[e.style]);return m(Y,{children:t!==""&&(t instanceof URL?m("link",{rel:"stylesheet",href:t.href}):m("style",{children:t}))})};var wg=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 vg=()=>{let[e,t]=X([{bubble:n=>r(0,n),hide:()=>r(0)}]),r=I((n,o)=>{t(([s,...i])=>[s,...o?[...i.slice(0,n),o===i.at(n)?.source?i.at(n):{source:o,parentTitles:[scrapbox.Page.title??"",...i.slice(0,n).map(a=>a.source.title)],bubble:a=>r(n+1,a),hide:()=>r(n+1)}]:[...i.slice(0,n)]])},[]);return e};var El=(e,t,r,n,o)=>{ee(()=>(e.addEventListener(t,r,n),()=>e.removeEventListener(t,r,n)),[e,t,n,...o??[]])};var kg=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),Ti=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var Tl="scrap-bubble",Eg=({delay:e,whiteList:t,watchList:r,style:n})=>{let[{bubble:o,hide:s},...i]=vg(),a=I((c,l)=>cg(l,t.has(c)?t:new Set([c]),r),[t,r]);return El(document,"pointerenter",async c=>{let l=c.target;if(!Ti(l)&&!kg(l))return;let{project:p=scrapbox.Project.name,title:u,hash:f=""}=Ti(l)?Hn({pathType:"root",href:${new URL(l.href).pathname}${new URL(l.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(p==="")return;let d=decodeURIComponent(u??"");a(p,d),await $n(l,e)&&o({project:p,title:d,hash:f,position:jn(l),type:hS(l)})},{capture:!0},[e,t,r]),El(document,"click",c=>{c.target.dataset.userscriptName!==Tl&&s()},{capture:!0},[s]),ee(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),m(Y,{children:[m("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),m("style",{children:wg}),m(xg,{style:n}),i.map(c=>m(yg,{...c,whiteList:t,delay:e,prefetch:a},me(c.source.project,c.source.title)))]})},hS=e=>Ti(e)?e.type==="link"?"link":"hashtag":"title";var Tg=async e=>{let{delay:t=500,whiteList:r=[],watchList:n=(await Rh()).slice(0,100),style:o="",debug:s=!1}=e??{};Mh(s);let i=document.createElement("div");i.dataset.userscriptName=Tl,document.body.append(i);let a=i.attachShadow({mode:"open"});lt(m(Eg,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(n),style:o}),a)};var gS=["takker-memex","takker-private","takker","takker-books","villagepump"],zn=[];switch(scrapbox.Project.name){case"hub":case"villagepump":case"verbalizing-community":zn.push("villagepump","hub","verbalizing-community");break;case"programming-notes":case"customize":case"scrapboxlab":zn.push("programming-notes","customize","scrapboxlab");break;case"sta":zn.push("sta-taskmanagement");break;case"sta-taskmanagement":case"taskmanagement":zn.push("sta-taskmanagement","taskmanagement");break;case"plurality-japanese":zn.push("nishio","tkgshn");break}Tg({delay:/mobile/i.test(navigator.userAgent)?300:500,whiteList:[...gS,...zn],style:@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";
@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";});var Pg=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 Rg=(e,t,r)=>{if(r.length===0)return[];let n=r.map(a=>a.text).join(
),o=Ue(n,{hasTitle:!0}),s=new Map,i=0;for(let a of o)switch(a.type){case"title":case"line":{i++;break}case"table":i+=a.cells.length+1;break;case"codeBlock":{let{fileName:c,lang:l}=Pg(a.fileName),p=s.get(c);s.set(c,{path:p?.path??https://scrapbox.io/api/code/${e}/${ue(t)}/${ue(c)},lang:p?.lang??l,startIds:[...p?.startIds??[],r[i].id]}),i+=a.content.split( ).length+1;break}}return s.values()};function Rl(e){let t=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(qt(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let o of n)t(o)}else{let o=Object.keys(n);r.write8(6),r.write32(o.length);for(let s of o)r.write(qt(s)),t(n[s])}},r=new Pi;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Pl(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Sg(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return Gn(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[Gn(r.read())]=t();return a}default:throw new Error("Invalid packet")}},r=new Pi(e),n=r.read32(),o=(n&1)===0;n>>>=1;let s=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:s}}var Pi=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);Pl(this.buf,t,r)}write(t){let r=this._write(4+t.length);Pl(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 Sl(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),n=this._read(r.length);return r.set(this.buf.subarray(n,n+t)),r}},qt,Gn,_g;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;qt=r=>e.encode(r),Gn=r=>t.decode(r),_g='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(qt("")instanceof Uint8Array))throw new Error(Invariant violation: "${_g} 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 Sl(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Pl(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var Ao="0.24.0";var qe=JSON.stringify,Lg="warning",Cg="silent";function Og(e){if(nt(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var _i=()=>null,Oe=e=>typeof e=="boolean"?null:"a boolean",H=e=>typeof e=="string"?null:"a string",Li=e=>e instanceof RegExp?null:"a RegExp object",fn=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ag=e=>typeof e=="function"?null:"a function",Ae=e=>Array.isArray(e)?null:"an array",It=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",bS=e=>typeof e=="object"&&e!==null?null:"an array or an object";var Ng=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ig=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",xS=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",wS=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",Dg=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function x(e,t,r,n){let o=e[r];if(t[r+""]=!0,o===void 0)return;let s=n(o);if(s!==null)throw new Error(${qe(r)} must be ${s});return o}function Ze(e,t,r){for(let n in e)if(!(n in t))throw new Error(Invalid option ${r}: ${qe(n)})}function $g(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let n=e[r];if(typeof n=="string"||n===!1)t[r]=n;else throw new Error(Expected ${qe(r)} in mangle cache to map to either a string or false)}}return t}function Ci(e,t,r,n,o){let s=x(t,r,"color",Oe),i=x(t,r,"logLevel",H),a=x(t,r,"logLimit",fn);s!==void 0?e.push(--color=${s}):n&&e.push("--color=true"),e.push(--log-level=${i||o}),e.push(--log-limit=${a||0})}function nt(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+qe(r):""} to be a string, got ${typeof e} instead);return e}function jg(e,t,r){let n=x(t,r,"legalComments",H),o=x(t,r,"sourceRoot",H),s=x(t,r,"sourcesContent",Oe),i=x(t,r,"target",wS),a=x(t,r,"format",H),c=x(t,r,"globalName",H),l=x(t,r,"mangleProps",Li),p=x(t,r,"reserveProps",Li),u=x(t,r,"mangleQuoted",Oe),f=x(t,r,"minify",Oe),d=x(t,r,"minifySyntax",Oe),h=x(t,r,"minifyWhitespace",Oe),g=x(t,r,"minifyIdentifiers",Oe),y=x(t,r,"lineLimit",fn),w=x(t,r,"drop",Ae),R=x(t,r,"dropLabels",Ae),E=x(t,r,"charset",H),b=x(t,r,"treeShaking",Oe),k=x(t,r,"ignoreAnnotations",Oe),v=x(t,r,"jsx",H),L=x(t,r,"jsxFactory",H),O=x(t,r,"jsxFragment",H),$=x(t,r,"jsxImportSource",H),S=x(t,r,"jsxDev",Oe),T=x(t,r,"jsxSideEffects",Oe),P=x(t,r,"define",It),_=x(t,r,"logOverride",It),N=x(t,r,"supported",It),M=x(t,r,"pure",Ae),j=x(t,r,"keepNames",Oe),A=x(t,r,"platform",H),W=x(t,r,"tsconfigRaw",xS);if(n&&e.push(--legal-comments=${n}),o!==void 0&&e.push(--source-root=${o}),s!==void 0&&e.push(--sources-content=${s}),i&&(Array.isArray(i)?e.push(--target=${Array.from(i).map(Og).join(",")}):e.push(--target=${Og(i)})),a&&e.push(--format=${a}),c&&e.push(--global-name=${c}),A&&e.push(--platform=${A}),W&&e.push(--tsconfig-raw=${typeof W=="string"?W:JSON.stringify(W)}),f&&e.push("--minify"),d&&e.push("--minify-syntax"),h&&e.push("--minify-whitespace"),g&&e.push("--minify-identifiers"),y&&e.push(--line-limit=${y}),E&&e.push(--charset=${E}),b!==void 0&&e.push(--tree-shaking=${b}),k&&e.push("--ignore-annotations"),w)for(let F of w)e.push(--drop:${nt(F,"drop")});if(R&&e.push(--drop-labels=${Array.from(R).map(F=>nt(F,"dropLabels")).join(",")}),l&&e.push(--mangle-props=${l.source}),p&&e.push(--reserve-props=${p.source}),u!==void 0&&e.push(--mangle-quoted=${u}),v&&e.push(--jsx=${v}),L&&e.push(--jsx-factory=${L}),O&&e.push(--jsx-fragment=${O}),$&&e.push(--jsx-import-source=${$}),S&&e.push("--jsx-dev"),T&&e.push("--jsx-side-effects"),P)for(let F in P){if(F.indexOf("=")>=0)throw new Error(Invalid define: ${F});e.push(--define:${F}=${nt(PF,"define",F)})}if(_)for(let F in _){if(F.indexOf("=")>=0)throw new Error(Invalid log override: ${F});e.push(--log-override:${F}=${nt(_F,"log override",F)})}if(N)for(let F in N){if(F.indexOf("=")>=0)throw new Error(Invalid supported: ${F});let q=N[F];if(typeof q!="boolean")throw new Error(Expected value for supported ${qe(F)} to be a boolean, got ${typeof q} instead);e.push(--supported:${F}=${q})}if(M)for(let F of M)e.push(--pure:${nt(F,"pure")});j&&e.push("--keep-names")}function vS(e,t,r,n,o){let s=[],i=[],a=Object.create(null),c=null,l=null;Ci(s,t,a,r,n),jg(s,t,a);let p=x(t,a,"sourcemap",Ig),u=x(t,a,"bundle",Oe),f=x(t,a,"splitting",Oe),d=x(t,a,"preserveSymlinks",Oe),h=x(t,a,"metafile",Oe),g=x(t,a,"outfile",H),y=x(t,a,"outdir",H),w=x(t,a,"outbase",H),R=x(t,a,"tsconfig",H),E=x(t,a,"resolveExtensions",Ae),b=x(t,a,"nodePaths",Ae),k=x(t,a,"mainFields",Ae),v=x(t,a,"conditions",Ae),L=x(t,a,"external",Ae),O=x(t,a,"packages",H),$=x(t,a,"alias",It),S=x(t,a,"loader",It),T=x(t,a,"outExtension",It),P=x(t,a,"publicPath",H),_=x(t,a,"entryNames",H),N=x(t,a,"chunkNames",H),M=x(t,a,"assetNames",H),j=x(t,a,"inject",Ae),A=x(t,a,"banner",It),W=x(t,a,"footer",It),F=x(t,a,"entryPoints",bS),q=x(t,a,"absWorkingDir",H),z=x(t,a,"stdin",It),se=x(t,a,"write",Oe)??o,Q=x(t,a,"allowOverwrite",Oe),et=x(t,a,"mangleCache",It);if(a.plugins=!0,Ze(t,a,in ${e}() call),p&&s.push(--sourcemap${p===!0?"":=${p}}),u&&s.push("--bundle"),Q&&s.push("--allow-overwrite"),f&&s.push("--splitting"),d&&s.push("--preserve-symlinks"),h&&s.push("--metafile"),g&&s.push(--outfile=${g}),y&&s.push(--outdir=${y}),w&&s.push(--outbase=${w}),R&&s.push(--tsconfig=${R}),O&&s.push(--packages=${O}),E){let D=[];for(let he of E){if(nt(he,"resolve extension"),he.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${he});D.push(he)}s.push(--resolve-extensions=${D.join(",")})}if(P&&s.push(--public-path=${P}),_&&s.push(--entry-names=${_}),N&&s.push(--chunk-names=${N}),M&&s.push(--asset-names=${M}),k){let D=[];for(let he of k){if(nt(he,"main field"),he.indexOf(",")>=0)throw new Error(Invalid main field: ${he});D.push(he)}s.push(--main-fields=${D.join(",")})}if(v){let D=[];for(let he of v){if(nt(he,"condition"),he.indexOf(",")>=0)throw new Error(Invalid condition: ${he});D.push(he)}s.push(--conditions=${D.join(",")})}if(L)for(let D of L)s.push(--external:${nt(D,"external")});if($)for(let D in $){if(D.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${D});s.push(--alias:${D}=${nt($D,"alias",D)})}if(A)for(let D in A){if(D.indexOf("=")>=0)throw new Error(Invalid banner file type: ${D});s.push(--banner:${D}=${nt(AD,"banner",D)})}if(W)for(let D in W){if(D.indexOf("=")>=0)throw new Error(Invalid footer file type: ${D});s.push(--footer:${D}=${nt(WD,"footer",D)})}if(j)for(let D of j)s.push(--inject:${nt(D,"inject")});if(S)for(let D in S){if(D.indexOf("=")>=0)throw new Error(Invalid loader extension: ${D});s.push(--loader:${D}=${nt(SD,"loader",D)})}if(T)for(let D in T){if(D.indexOf("=")>=0)throw new Error(Invalid out extension: ${D});s.push(--out-extension:${D}=${nt(TD,"out extension",D)})}if(F)if(Array.isArray(F))for(let D=0,he=F.length;D<he;D++){let st=F[D];if(typeof st=="object"&&st!==null){let or=Object.create(null),sr=x(st,or,"in",H),Kt=x(st,or,"out",H);if(Ze(st,or,"in entry point at index "+D),sr===void 0)throw new Error('Missing property "in" for entry point at index '+D);if(Kt===void 0)throw new Error('Missing property "out" for entry point at index '+D);i.push([Kt,sr])}else i.push(["",nt(st,"entry point at index "+D)])}else for(let D in F)i.push([D,nt(F[D],"entry point",D)]);if(z){let D=Object.create(null),he=x(z,D,"contents",Dg),st=x(z,D,"resolveDir",H),or=x(z,D,"sourcefile",H),sr=x(z,D,"loader",H);Ze(z,D,'in "stdin" object'),or&&s.push(--sourcefile=${or}),sr&&s.push(--loader=${sr}),st&&(l=st),typeof he=="string"?c=qt(he):he instanceof Uint8Array&&(c=he)}let Ee=[];if(b)for(let D of b)D+="",Ee.push(D);return{entries:i,flags:s,write:se,stdinContents:c,stdinResolveDir:l,absWorkingDir:q,nodePaths:Ee,mangleCache:$g(et)}}function kS(e,t,r,n){let o=[],s=Object.create(null);Ci(o,t,s,r,n),jg(o,t,s);let i=x(t,s,"sourcemap",Ig),a=x(t,s,"sourcefile",H),c=x(t,s,"loader",H),l=x(t,s,"banner",H),p=x(t,s,"footer",H),u=x(t,s,"mangleCache",It);return Ze(t,s,in ${e}() call),i&&o.push(--sourcemap=${i===!0?"external":i}),a&&o.push(--sourcefile=${a}),c&&o.push(--loader=${c}),l&&o.push(--banner=${l}),p&&o.push(--footer=${p}),{flags:o,mangleCache:$g(u)}}function Fg(e){let t={},r={didClose:!1,reason:""},n={},o=0,s=0,i=new Uint8Array(16*1024),a=0,c=E=>{let b=a+E.length;if(b>i.length){let v=new Uint8Array(b*2);v.set(i),i=v}i.set(E,a),a+=E.length;let k=0;for(;k+4<=a;){let v=Sl(i,k);if(k+4+v>a)break;k+=4,h(i.subarray(k,k+v)),k+=v}k>0&&(i.copyWithin(0,k,a),a-=k)},l=E=>{r.didClose=!0,E&&(r.reason=": "+(E.message||E));let b="The service was stopped"+r.reason;for(let k in n)n[k](b,null);n={}},p=(E,b,k)=>{if(r.didClose)return k("The service is no longer running"+r.reason,null);let v=o++;n[v]=(L,O)=>{try{k(L,O)}finally{E&&E.unref()}},E&&E.ref(),e.writeToStdin(Rl({id:v,isRequest:!0,value:b}))},u=(E,b)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(Rl({id:E,isRequest:!1,value:b}))},f=async(E,b)=>{try{if(b.command==="ping"){u(E,{});return}if(typeof b.key=="number"){let k=t[b.key];if(!k)return;let v=k[b.command];if(v){await v(E,b);return}}throw new Error("Invalid command: "+b.command)}catch(k){let v=[dn(k,e,null,void 0,"")];try{u(E,{errors:v})}catch{}}},d=!0,h=E=>{if(d){d=!1;let k=String.fromCharCode(...E);if(k!==Ao)throw new Error(Cannot start service: Host version "${Ao}" does not match binary version ${qe(k)});return}let b=Sg(E);if(b.isRequest)f(b.id,b.value);else{let k=n[b.id];delete n[b.id],b.value.error?k(b.value.error,{}):k(null,b.value)}};return{readFromStdout:c,afterClose:l,service:{buildOrContext:({callName:E,refs:b,options:k,isTTY:v,defaultWD:L,callback:O})=>{let $=0,S=s++,T={},P={ref(){++$===1&&b&&b.ref()},unref(){--$===0&&(delete t[S],b&&b.unref())}};t[S]=T,P.ref(),ES(E,S,p,u,P,e,T,k,v,L,(_,N)=>{try{O(_,N)}finally{P.unref()}})},transform:({callName:E,refs:b,input:k,options:v,isTTY:L,fs:O,callback:$})=>{let S=Ug(),T=P=>{try{if(typeof k!="string"&&!(k instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:_,mangleCache:N}=kS(E,v,L,Cg),M={command:"transform",flags:_,inputFS:P!==null,input:P!==null?qt(P):typeof k=="string"?qt(k):k};N&&(M.mangleCache=N),p(b,M,(j,A)=>{if(j)return $(new Error(j),null);let W=Kn(A.errors,S),F=Kn(A.warnings,S),q=1,z=()=>{if(--q===0){let se={warnings:F,code:A.code,map:A.map,mangleCache:void 0,legalComments:void 0};"legalComments"in A&&(se.legalComments=A?.legalComments),A.mangleCache&&(se.mangleCache=A?.mangleCache),$(null,se)}};if(W.length>0)return $(Io("Transform failed",W,F),null);A.codeFS&&(q++,O.readFile(A.code,(se,Q)=>{se!==null?$(se,null):(A.code=Q,z())})),A.mapFS&&(q++,O.readFile(A.map,(se,Q)=>{se!==null?$(se,null):(A.map=Q,z())})),z()})}catch(_){let N=[];try{Ci(N,v,{},L,Cg)}catch{}let M=dn(_,e,S,void 0,"");p(b,{command:"error",flags:N,error:M},()=>{M.detail=S.load(M.detail),$(Io("Transform failed",[M],[]),null)})}};if((typeof k=="string"||k instanceof Uint8Array)&&k.length>1024*1024){let P=T;T=()=>O.writeFile(k,P)}T(null)},formatMessages:({callName:E,refs:b,messages:k,options:v,callback:L})=>{if(!v)throw new Error(Missing second argument in ${E}() call);let O={},$=x(v,O,"kind",H),S=x(v,O,"color",Oe),T=x(v,O,"terminalWidth",fn);if(Ze(v,O,in ${E}() call),$===void 0)throw new Error(Missing "kind" in ${E}() call);if($!=="error"&&$!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${E}() call);let P={command:"format-msgs",messages:gr(k,"messages",null,"",T),isWarning:$==="warning"};S!==void 0&&(P.color=S),T!==void 0&&(P.terminalWidth=T),p(b,P,(_,N)=>{if(_)return L(new Error(_),null);L(null,N.messages)})},analyzeMetafile:({callName:E,refs:b,metafile:k,options:v,callback:L})=>{v===void 0&&(v={});let O={},$=x(v,O,"color",Oe),S=x(v,O,"verbose",Oe);Ze(v,O,in ${E}() call);let T={command:"analyze-metafile",metafile:k};$!==void 0&&(T.color=$),S!==void 0&&(T.verbose=S),p(b,T,(P,_)=>{if(P)return L(new Error(P),null);L(null,_.result)})}}}}function ES(e,t,r,n,o,s,i,a,c,l,p){let u=Ug(),f=e==="context",d=(y,w)=>{let R=[];try{Ci(R,a,{},c,Lg)}catch{}let E=dn(y,s,u,void 0,w);r(o,{command:"error",flags:R,error:E},()=>{E.detail=u.load(E.detail),p(Io(f?"Context failed":"Build failed",[E],[]),null)})},h;if(typeof a=="object"){let y=a.plugins;if(y!==void 0){if(!Array.isArray(y))return d(new Error('"plugins" must be an array'),"");h=y}}if(h&&h.length>0){if(s.isSync)return d(new Error("Cannot use plugins in synchronous API calls"),"");TS(t,r,n,o,s,i,a,h,u).then(y=>{if(!y.ok)return d(y.error,y.pluginName);try{g(y.requestPlugins,y.runOnEndCallbacks,y.scheduleOnDisposeCallbacks)}catch(w){d(w,"")}},y=>d(y,""));return}try{g(null,(y,w)=>w([],[]),()=>{})}catch(y){d(y,"")}function g(y,w,R){let E=s.hasFS,{entries:b,flags:k,write:v,stdinContents:L,stdinResolveDir:O,absWorkingDir:$,nodePaths:S,mangleCache:T}=vS(e,a,c,Lg,E);if(v&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let P={command:"build",key:t,entries:b,flags:k,write:v,stdinContents:L,stdinResolveDir:O,absWorkingDir:$||l,nodePaths:S,context:f};y&&(P.plugins=y),T&&(P.mangleCache=T);let _=(j,A)=>{let W={errors:Kn(j.errors,u),warnings:Kn(j.warnings,u),outputFiles:void 0,metafile:void 0,mangleCache:void 0},F=W.errors.slice(),q=W.warnings.slice();j.outputFiles&&(W.outputFiles=j.outputFiles.map(RS)),j.metafile&&(W.metafile=JSON.parse(j.metafile)),j.mangleCache&&(W.mangleCache=j.mangleCache),j.writeToStdout!==void 0&&console.log(Gn(j.writeToStdout).replace(/\n$/,"")),w(W,(z,se)=>{if(F.length>0||z.length>0){let Q=Io("Build failed",F.concat(z),q.concat(se));return A(Q,null,z,se)}A(null,W,z,se)})},N,M;f&&(i["on-end"]=(j,A)=>new Promise(W=>{_(A,(F,q,z,se)=>{let Q={errors:z,warnings:se};M&&M(F,q),N=void 0,M=void 0,n(j,Q),W()})})),r(o,P,(j,A)=>{if(j)return p(new Error(j),null);if(!f)return _(A,(q,z)=>(R(),p(q,z)));if(A.errors.length>0)return p(Io("Context failed",A.errors,A.warnings),null);let W=!1,F={rebuild:()=>(N||(N=new Promise((q,z)=>{let se;M=(et,Ee)=>{se||(se=()=>et?z(et):q(Ee))};let Q=()=>{r(o,{command:"rebuild",key:t},(Ee,D)=>{Ee?z(new Error(Ee)):se?se():Q()})};Q()})),N),watch:(q={})=>new Promise((z,se)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');Ze(q,{},"in watch() call"),r(o,{command:"watch",key:t},Ee=>{Ee?se(new Error(Ee)):z(void 0)})}),serve:(q={})=>new Promise((z,se)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let Q={},et=x(q,Q,"port",fn),Ee=x(q,Q,"host",H),D=x(q,Q,"servedir",H),he=x(q,Q,"keyfile",H),st=x(q,Q,"certfile",H),or=x(q,Q,"fallback",H),sr=x(q,Q,"onRequest",Ag);Ze(q,Q,"in serve() call");let Kt={command:"serve",key:t,onRequest:!!sr};et!==void 0&&(Kt.port=et),Ee!==void 0&&(Kt.host=Ee),D!==void 0&&(Kt.servedir=D),he!==void 0&&(Kt.keyfile=he),st!==void 0&&(Kt.certfile=st),or!==void 0&&(Kt.fallback=or),r(o,Kt,(up,Yv)=>{if(up)return se(new Error(up));sr&&(i["serve-request"]=(Vv,Xv)=>{sr(Xv.args),n(Vv,{})}),z(Yv)})}),cancel:()=>new Promise(q=>{if(W)return q();r(o,{command:"cancel",key:t},()=>{q()})}),dispose:()=>new Promise(q=>{if(W)return q();W=!0,r(o,{command:"dispose",key:t},()=>{q(),R(),o.unref()})})};o.ref(),p(null,F)})}}var TS=async(e,t,r,n,o,s,i,a,c)=>{let l=[],p=[],u={},f={},d=[],h=0,g=0,y=[],w=!1;a=[...a];for(let b of a){let k={};if(typeof b!="object")throw new Error(Plugin at index ${g} must be an object);let v=x(b,k,"name",H);if(typeof v!="string"||v==="")throw new Error(Plugin at index ${g} is missing a name);try{let L=x(b,k,"setup",Ag);if(typeof L!="function")throw new Error("Plugin is missing a setup function");Ze(b,k,on plugin ${qe(v)});let O={name:v,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};g++;let S=L({initialOptions:i,resolve:(T,P={})=>{if(!w)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof T!="string")throw new Error("The path to resolve must be a string");let _=Object.create(null),N=x(P,_,"pluginName",H),M=x(P,_,"importer",H),j=x(P,_,"namespace",H),A=x(P,_,"resolveDir",H),W=x(P,_,"kind",H),F=x(P,_,"pluginData",_i),q=x(P,_,"with",It);return Ze(P,_,"in resolve() call"),new Promise((z,se)=>{let Q={command:"resolve",path:T,key:e,pluginName:v};if(N!=null&&(Q.pluginName=N),M!=null&&(Q.importer=M),j!=null&&(Q.namespace=j),A!=null&&(Q.resolveDir=A),W!=null)Q.kind=W;else throw new Error('Must specify "kind" when calling "resolve"');F!=null&&(Q.pluginData=c.store(F)),q!=null&&(Q.with=PS(q,"with")),t(n,Q,(et,Ee)=>{et!==null?se(new Error(et)):z({errors:Kn(Ee.errors,c),warnings:Kn(Ee.warnings,c),path:Ee.path,external:Ee.external,sideEffects:Ee.sideEffects,namespace:Ee.namespace,suffix:Ee.suffix,pluginData:c.load(Ee.pluginData)})})})},onStart(T){let P='This error came from the "onStart" callback registered here:',_=Ri(new Error(P),o,"onStart");l.push({name:v,callback:T,note:_}),O.onStart=!0},onEnd(T){let P='This error came from the "onEnd" callback registered here:',_=Ri(new Error(P),o,"onEnd");p.push({name:v,callback:T,note:_}),O.onEnd=!0},onResolve(T,P){let _='This error came from the "onResolve" callback registered here:',N=Ri(new Error(_),o,"onResolve"),M={},j=x(T,M,"filter",Li),A=x(T,M,"namespace",H);if(Ze(T,M,in onResolve() call for plugin ${qe(v)}),j==null)throw new Error("onResolve() call is missing a filter");let W=h++;u[W]={name:v,callback:P,note:N},O.onResolve.push({id:W,filter:j.source,namespace:A||""})},onLoad(T,P){let _='This error came from the "onLoad" callback registered here:',N=Ri(new Error(_),o,"onLoad"),M={},j=x(T,M,"filter",Li),A=x(T,M,"namespace",H);if(Ze(T,M,in onLoad() call for plugin ${qe(v)}),j==null)throw new Error("onLoad() call is missing a filter");let W=h++;f[W]={name:v,callback:P,note:N},O.onLoad.push({id:W,filter:j.source,namespace:A||""})},onDispose(T){d.push(T)},esbuild:o.esbuild});S&&await S,y.push(O)}catch(L){return{ok:!1,error:L,pluginName:v}}}s["on-start"]=async(b,k)=>{c.clear();let v={errors:[],warnings:[]};await Promise.all(l.map(async({name:L,callback:O,note:$})=>{try{let S=await O();if(S!=null){if(typeof S!="object")throw new Error(Expected onStart() callback in plugin ${qe(L)} to return an object);let T={},P=x(S,T,"errors",Ae),_=x(S,T,"warnings",Ae);Ze(S,T,from onStart() callback in plugin ${qe(L)}),P!=null&&v.errors.push(...gr(P,"errors",c,L,void 0)),_!=null&&v.warnings.push(...gr(_,"warnings",c,L,void 0))}}catch(S){v.errors.push(dn(S,o,c,$&&$(),L))}})),r(b,v)},s["on-resolve"]=async(b,k)=>{let v={},L="",O,$;for(let S of k.ids)try{({name:L,callback:O,note:$}=u[S]);let T=await O({path:k.path,importer:k.importer,namespace:k.namespace,resolveDir:k.resolveDir,kind:k.kind,pluginData:c.load(k.pluginData),with:k.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onResolve() callback in plugin ${qe(L)} to return an object);let P={},_=x(T,P,"pluginName",H),N=x(T,P,"path",H),M=x(T,P,"namespace",H),j=x(T,P,"suffix",H),A=x(T,P,"external",Oe),W=x(T,P,"sideEffects",Oe),F=x(T,P,"pluginData",_i),q=x(T,P,"errors",Ae),z=x(T,P,"warnings",Ae),se=x(T,P,"watchFiles",Ae),Q=x(T,P,"watchDirs",Ae);Ze(T,P,from onResolve() callback in plugin ${qe(L)}),v.id=S,_!=null&&(v.pluginName=_),N!=null&&(v.path=N),M!=null&&(v.namespace=M),j!=null&&(v.suffix=j),A!=null&&(v.external=A),W!=null&&(v.sideEffects=W),F!=null&&(v.pluginData=c.store(F)),q!=null&&(v.errors=gr(q,"errors",c,L,void 0)),z!=null&&(v.warnings=gr(z,"warnings",c,L,void 0)),se!=null&&(v.watchFiles=Si(se,"watchFiles")),Q!=null&&(v.watchDirs=Si(Q,"watchDirs"));break}}catch(T){v={id:S,errors:[dn(T,o,c,$&&$(),L)]};break}r(b,v)},s["on-load"]=async(b,k)=>{let v={},L="",O,$;for(let S of k.ids)try{({name:L,callback:O,note:$}=f[S]);let T=await O({path:k.path,namespace:k.namespace,suffix:k.suffix,pluginData:c.load(k.pluginData),with:k.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onLoad() callback in plugin ${qe(L)} to return an object);let P={},_=x(T,P,"pluginName",H),N=x(T,P,"contents",Dg),M=x(T,P,"resolveDir",H),j=x(T,P,"pluginData",_i),A=x(T,P,"loader",H),W=x(T,P,"errors",Ae),F=x(T,P,"warnings",Ae),q=x(T,P,"watchFiles",Ae),z=x(T,P,"watchDirs",Ae);Ze(T,P,from onLoad() callback in plugin ${qe(L)}),v.id=S,_!=null&&(v.pluginName=_),N instanceof Uint8Array?v.contents=N:N!=null&&(v.contents=qt(N)),M!=null&&(v.resolveDir=M),j!=null&&(v.pluginData=c.store(j)),A!=null&&(v.loader=A),W!=null&&(v.errors=gr(W,"errors",c,L,void 0)),F!=null&&(v.warnings=gr(F,"warnings",c,L,void 0)),q!=null&&(v.watchFiles=Si(q,"watchFiles")),z!=null&&(v.watchDirs=Si(z,"watchDirs"));break}}catch(T){v={id:S,errors:[dn(T,o,c,$&&$(),L)]};break}r(b,v)};let R=(b,k)=>k([],[]);p.length>0&&(R=(b,k)=>{(async()=>{let v=[],L=[];for(let{name:O,callback:$,note:S}of p){let T,P;try{let _=await $(b);if(_!=null){if(typeof _!="object")throw new Error(Expected onEnd() callback in plugin ${qe(O)} to return an object);let N={},M=x(_,N,"errors",Ae),j=x(_,N,"warnings",Ae);Ze(_,N,from onEnd() callback in plugin ${qe(O)}),M!=null&&(T=gr(M,"errors",c,O,void 0)),j!=null&&(P=gr(j,"warnings",c,O,void 0))}}catch(_){T=[dn(_,o,c,S&&S(),O)]}if(T){v.push(...T);try{b.errors.push(...T)}catch{}}if(P){L.push(...P);try{b.warnings.push(...P)}catch{}}}k(v,L)})()});let E=()=>{for(let b of d)setTimeout(()=>b(),0)};return w=!0,{ok:!0,requestPlugins:y,runOnEndCallbacks:R,scheduleOnDisposeCallbacks:E}};function Ug(){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 n=t++;return e.set(n,r),n}}}function Ri(e,t,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let s=(e.stack+"").split( );s.splice(1,1);let i=Bg(t,s,r);if(i)return n={text:e.message,location:i},n}catch{}}}function dn(e,t,r,n,o){let s="Internal error",i=null;try{s=(e&&e.message||e)+""}catch{}try{i=Bg(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:o,text:s,location:i,notes:n?[n]:[],detail:r?r.store(e):-1}}function Bg(e,t,r){let n=" at ";if(e.readFileSync&&!t[0].startsWith(n)&&t[1].startsWith(n))for(let o=1;o<t.length;o++){let s=t[o];if(s.startsWith(n))for(s=s.slice(n.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,p=c.slice(l,l+r.length)===r?r.length:0;return{file:i[1],namespace:"file",line:+i[2],column:qt(c.slice(0,l)).length,length:qt(c.slice(l,l+p)).length,lineText:c+
+t.slice(1).join(
),suggestion:""}}break}}return null}function Io(e,t,r){let n=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,n+1).map((s,i)=>{if(i===n)return
...;if(!s.location)return
${a}:${c}:${l}: ERROR: ${p}${s.text}}).join("");let o=new Error(e);for(let[s,i]of[["errors",t],["warnings",r]])Object.defineProperty(o,s,{configurable:!0,enumerable:!0,get:()=>i,set:a=>Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:a})});return o}function Kn(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Mg(e,t,r){if(e==null)return null;let n={},o=x(e,n,"file",H),s=x(e,n,"namespace",H),i=x(e,n,"line",fn),a=x(e,n,"column",fn),c=x(e,n,"length",fn),l=x(e,n,"lineText",H),p=x(e,n,"suggestion",H);if(Ze(e,n,t),l){let u=l.slice(0,(a&&a>0?a:0)+(c&&c>0?c:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(u)&&!/\n/.test(l)&&(l=u)}return{file:o||"",namespace:s||"",line:i||0,column:a||0,length:c||0,lineText:l||"",suggestion:p||""}}function gr(e,t,r,n,o){let s=[],i=0;for(let a of e){let c={},l=x(a,c,"id",H),p=x(a,c,"pluginName",H),u=x(a,c,"text",H),f=x(a,c,"location",Ng),d=x(a,c,"notes",Ae),h=x(a,c,"detail",_i),g=in element ${i} of "${t}";Ze(a,c,g);let y=[];if(d)for(let w of d){let R={},E=x(w,R,"text",H),b=x(w,R,"location",Ng);Ze(w,R,g),y.push({text:E||"",location:Mg(b,g,o)})}s.push({id:l||"",pluginName:p||n,text:u||"",location:Mg(f,g,o),notes:y,detail:r?r.store(h):-1}),i++}return s}function Si(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(${qe(t)} must be an array of strings);r.push(n)}return r}function PS(e,t){let r=Object.create(null);for(let n in e){let o=e[n];if(typeof o!="string")throw new Error(key ${qe(n)} in object ${qe(t)} must be a string);r[n]=o}return r}function RS({path:e,contents:t,hash:r}){let n=null;return{path:e,contents:t,hash:r,get text(){let o=this.contents;return(n===null||o!==t)&&(t=o,n=Gn(o)),n}}}var Wg=Ao,Ni=e=>Mi().build(e),qg=(e,t)=>Mi().transform(e,t),zg=(e,t)=>Mi().formatMessages(e,t),Gg=(e,t)=>Mi().analyzeMetafile(e,t);var mn,Hg,Oi,Mi=()=>{if(Oi)return Oi;throw mn?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')},Ai=e=>{let t=e.wasm,r=e.worker;if(mn)throw new Error('Cannot call "initialize" more than once');return mn=SS(t,r),mn.catch(()=>{mn=void 0}),mn},SS=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),n,o,s=new Promise((c,l)=>{n=c,o=l});r.onmessage=({data:c})=>{r.onmessage=({data:l})=>i(l),c?o(c):n()},r.postMessage(e);let{readFromStdout:i,service:a}=Fg({writeToStdin(c){r.postMessage(c)},isSync:!1,hasFS:!1,esbuild:{build:Ni,transform:qg,formatMessages:zg,analyzeMetafile:Gg,version:Wg,initialize:Ai}});await s,Hg=()=>{r.terminate(),mn=void 0,Hg=void 0,Oi=void 0},Oi={build:c=>new Promise((l,p)=>a.buildOrContext({callName:"build",refs:null,options:c,isTTY:!1,defaultWD:"/",callback:(u,f)=>u?p(u):l(f)})),transform:(c,l)=>new Promise((p,u)=>a.transform({callName:"transform",refs:null,input:c,options:l||{},isTTY:!1,fs:{readFile(f,d){d(new Error("Internal error"),null)},writeFile(f,d){d(null)}},callback:(f,d)=>f?u(f):p(d)})),formatMessages:(c,l)=>new Promise((p,u)=>a.formatMessages({callName:"formatMessages",refs:null,messages:c,options:l,callback:(f,d)=>f?u(f):p(d)})),analyzeMetafile:(c,l)=>new Promise((p,u)=>a.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof c=="string"?c:JSON.stringify(c),options:l,callback:(f,d)=>f?u(f):p(d)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function pt(e){if(typeof e!="string")throw new TypeError(Path must be a string. Received ${JSON.stringify(e)})}function tr(e){return e===47||e===92}function yr(e){return e>=97&&e<=122||e>=65&&e<=90}function $i(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError("Must be a file URL.");return e}function Kg(e){e=$i(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}function Ll(e){pt(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return tr(r)?!0:!!(yr(r)&&t>2&&e.charCodeAt(1)===58&&tr(e.charCodeAt(2)))}var ji=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function Fi(e,t=""){if(!e)throw new ji(t)}var US={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Ui(e){return e.replaceAll(/[\s]/g,t=>US[t]??t)}function Xg(e){if(!Ll(e))throw new TypeError("Must be an absolute path.");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Ui(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError("Invalid hostname.");return n}function br(e){return e===47}function Qg(e){return e=$i(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Ol(e){return pt(e),e.length>0&&br(e.charCodeAt(0))}function ey(e){if(!Ol(e))throw new TypeError("Must be an absolute path.");let t=new URL("file:///");return t.pathname=Ui(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}var QS=(()=>{let{Deno:e}=globalThis;if(typeof e?.build?.os=="string")return e.build.os;let{navigator:t}=globalThis;return t?.appVersion?.includes?.("Win")?"windows":"linux"})(),Fe=QS==="windows";var Yn=Fe?"\\":"/";function Bi(e){return Fe?Kg(e):Qg(e)}function $o(e){return Fe?Xg(e):ey(e)}function Hi(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Wi(e){let t={},r=Object.keys(e).sort((n,o)=>o.length-n.length);for(let n of r)t[n]=e[n];return t}function ty(e){return Hi(e)&&(e.imports!==void 0?Nl(e.imports):!0)&&(e.scopes!==void 0?Ml(e.scopes):!0)}function Nl(e){return Hi(e)}function Ml(e){return Hi(e)&&Object.values(e).every(t=>Al(t))}function Al(e){return Hi(e)}function qi(e){try{return new URL(e),!0}catch{return!1}}function ny(e,t){let r={};for(let[n,o]of Object.entries(e)){let s=e_(n,t);if(s===null)continue;if(typeof o!="string"){console.warn("addresses need to be strings."),r[s]=null;continue}let i=Il(o,t);if(i===null){console.warn("the address was invalid."),r[s]=null;continue}if(n.endsWith("/")&&!rr(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]=rr(i)}return Wi(r)}function rr(e){return e.href}function ZS(e,t){let r={};for(let[o,s]of Object.entries(e)){if(!Al(s))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let i;try{i=new URL(o,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let a=rr(i);r[a]=ny(s,t)}let n={};for(let o of Object.keys(r))n[o]=Wi(r[o]);return Wi(n)}function e_(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=Il(e,t);return r!==null?rr(r):e}function Il(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 t_=["ftp","file","http","https","ws","wss"];function r_(e){return t_.some(t=>rr(e).startsWith(t))}function ry(e,t,r){for(let[n,o]of Object.entries(r))if(n===e){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!qi(o))throw new TypeError("resolutionResult must be an URL.");return o}else if(n.endsWith("/")&&e.startsWith(n)&&(t===null||r_(t))){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!qi(o))throw new TypeError("resolutionResult must be an URL.");let s=e.slice(n.length);if(!o.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let i=new URL(s,o);if(!qi(i))throw new TypeError("url must be an URL.");if(!rr(i).startsWith(o))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return rr(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 Dl(e,t){let r={};if(!ty(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:n,scopes:o}=e;if(n!==void 0){if(!Nl(n))throw new TypeError('"imports" top-level key needs to be an object.');r=ny(n,t)}let s={};if(o!==void 0){if(!Ml(o))throw new TypeError('"scopes" top-level key needs to be an object.');s=ZS(o,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 oy(e,{imports:t={},scopes:r={}},n){let o=rr(n),s=Il(e,n),i=s!==null?rr(s):e;for(let[c,l]of Object.entries(r))if(c===o||c.endsWith("/")&&o.startsWith(c)){let p=ry(i,s,l);if(p!==null)return p}let a=ry(i,s,t);if(a!==null)return a;if(s!==null)return rr(s);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}function iy(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new $l(e,{allowTrailingComma:t}).parse()}var sy=globalThis.JSON.parse,$l=class{#i=new Set( \r
);#n=new Set([..."[]{}:,/",...this.#i]);#t;#e;#s;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#s=this.#d(),this.#a=r}parse(){let t=this.#o(),r=this.#u(t),{done:n,value:o}=this.#s.next();if(!n)throw new SyntaxError(Dr(o));return r}#o(){let{done:t,value:r}=this.#s.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#d(){for(let t=0;t<this.#e;t++)if(!this.#i.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,n=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!n);t++)n=this.#t[t]==="\\"&&!n;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#n.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#u(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#r();case"NullOrTrueOrFalseOrNumber":return this.#g(t);case"String":return this.#h(t);default:throw new SyntaxError(Dr(t))}}#f(){let t={};for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndObject")return t;if(n.type!=="String")throw new SyntaxError(Dr(n));let o=this.#h(n),s=this.#o();if(s.type!=="NameSeparator")throw new SyntaxError(Dr(s));let i=this.#o();Object.defineProperty(t,o,{value:this.#u(i),writable:!0,enumerable:!0,configurable:!0});let a=this.#o();if(a.type==="EndObject")return t;if(a.type!=="ValueSeparator")throw new SyntaxError(Dr(a))}}#r(){let t=[];for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndArray")return t;t.push(this.#u(n));let o=this.#o();if(o.type==="EndArray")return t;if(o.type!=="ValueSeparator")throw new SyntaxError(Dr(o))}}#h(t){let r;try{r=sy(t.sourceText)}catch{throw new SyntaxError(Dr(t))}return Fi(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=sy(t.sourceText)}catch{throw new SyntaxError(Dr(t))}return Fi(typeof r=="number"),r}};function Dr({type:e,sourceText:t,position:r}){let n="";switch(e){case"BeginObject":n="{";break;case"EndObject":n="}";break;case"BeginArray":n="[";break;case"EndArray":n="]";break;case"NameSeparator":n=":";break;case"ValueSeparator":n=",";break;case"NullOrTrueOrFalseOrNumber":case"String":n=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${n} in JSONC at position ${r}}function Gi(e){if(e.protocol==="file:")return{path:Bi(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function jl(e){let t=await Deno.readTextFile(e),r=iy(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 ay(e){if(e.imports!==void 0){let t=[];for(let[r,n]of Object.entries(e.imports))if(t.push([r,n]),!r.endsWith("/")&&n&&(n.startsWith("jsr:")||n.startsWith("npm:"))&&!e.imports[r+"/"]){let o=r+"/",s=n.slice(0,4)+"/"+n.slice(n[4]==="/"?5:4)+"/";t.push([o,s])}e.imports=Object.fromEntries(t)}}var o_=${Yn}node_modules${Yn},s_=${Yn}node_modules;function zi(e){return e.includes(o_)||e.endsWith(s_)}function Fl(e){return(e.namespace===""||e.namespace==="file")&&(zi(e.resolveDir)||zi(e.path)||zi(e.importer))}function Ul(e={}){return{name:"deno-resolver",setup(t){let r=null,n=(t.initialOptions.external??[]).map(o=>new RegExp("^"+o.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let s;if(e.importMapURL===void 0&&e.configPath!==void 0){let i=await jl(e.configPath);if(i.imports!==void 0||i.scopes!==void 0){let a={imports:i.imports,scopes:i.scopes};ay(a),r=Dl(a,$o(e.configPath))}else i.importMap!==void 0&&(s=new URL(i.importMap,$o(e.configPath)).href)}else e.importMapURL!==void 0&&(s=e.importMapURL);if(s){let i=await fetch(s),a=await i.json();r=Dl(a,new URL(i.url))}}),t.onResolve({filter:/.*/},async function(s){if(Fl(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(${$o(s.resolveDir).href}/);else return;let a;if(r!==null){let u=oy(s.path,r,new URL(i));a=new URL(u)}else a=new URL(s.path,i);for(let u of n)if(u.test(a.href))return{path:a.href,external:!0};let{path:c,namespace:l}=Gi(a);return await t.resolve(c,{namespace:l,kind:s.kind})})}}}var kte=new TextEncoder;var i_=[],a_=[],Bl="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=Bl.length;e<t;++e)i_[e]=Bl[e],a_[Bl.charCodeAt(e)]=e;var Wte=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var h_=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var cy=Ul;var ly=e=>!!(g_.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),g_=["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"];function $r(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function hn(e){return e===47}function uy(e){$r(e);let t=-1,r=0,n=-1,o=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(hn(a)){if(!o){r=i+1;break}continue}n===-1&&(o=!1,n=i+1),a===46?t===-1?t=i:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||n===-1||s===0||s===1&&t===n-1&&t===r+1?"":e.slice(t,n)}function py(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let n=t.length-1;n>=0;--n)if(e.charCodeAt(r+n)!==t.charCodeAt(n))return e;return e.slice(0,-t.length)}function dy(e,t,r=0){let n=!1,o=e.length;for(let s=e.length-1;s>=r;--s)if(t(e.charCodeAt(s))){if(n){r=s+1;break}}else n||(n=!0,o=s+1);return e.slice(r,o)}function fy(e,t){if($r(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function my(e,t){if(e.length<=1)return e;let r=e.length;for(let n=e.length-1;n>0&&t(e.charCodeAt(n));n--)r=n;return e.slice(0,r)}function hy(e,t=""){fy(e,t);let r=dy(e,hn),n=my(r,hn);return t?py(n,t):n}var Ki=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function Yi(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 gy(e){return e=Yi(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function yy(e){e=Yi(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}function by(e){return Ki?yy(e):gy(e)}var b_={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Vi(e){return e.replaceAll(/[\s]/g,t=>b_[t]??t)}function xy(e){return $r(e),e.length>0&&hn(e.charCodeAt(0))}function wy(e){if(!xy(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=Vi(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function Wl(e){return e===47||e===92}function vy(e){return e>=97&&e<=122||e>=65&&e<=90}function ky(e){$r(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return Wl(r)?!0:!!(vy(r)&&t>2&&e.charCodeAt(1)===58&&Wl(e.charCodeAt(2)))}function Ey(e){if(!ky(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Vi(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError(Invalid hostname: "${n.hostname}");return n}function Ty(e){return Ki?Ey(e):wy(e)}var Py=e=>{if(e.protocol==="file:")return{path:by(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},ql=e=>e.namespace==="file"?Ty(e.path):new URL(${e.namespace}:${e.path});var Ry=(e,t)=>{let r=Vp(P_(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(G(r))return r;let{url:n,start:o,end:s}=B(r);return URL.canParse(n,t)?be({url:new URL(n,t),start:o,end:s}):Z({name:"InvalidURLError",message:Invalid URL: ${n}})},P_=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,n=e.length,o=r;for(;o<n&&e.charCodeAt(o)>32;)o++;if(o!==r&&(t[1]==="/"||e.indexOf("*/",o)>0))return{url:e.slice(r,o),start:r,end:o}}};var R_=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],Sy=e=>R_.includes(e),_y=e=>/^js|^ts|css$/.test(e),Ly=e=>{let t=e.url,r=hy(t);if(Sy(r))return r;if(r==="mjs")return"js";let n=new URL(t);n.search="",n.hash="";let o=uy(n.href).slice(1);if(Sy(o))return o;if(o==="mjs")return"js";let i=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return S_(i)},S_=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 Xi(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function Ny(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Gl(e=[],t=[]){let r=Math.max(e.length,t.length);for(let n=0;n<r;n++){let o=e[n],s=t[n];if(o===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(o===void 0)return-1;if(typeof o=="string"&&typeof s=="number")return 1;if(typeof o=="number"&&typeof s=="string"||o<s)return-1;if(o>s)return 1}return 0}var Vn="0|[1-9]\\d*",__="\\d*[a-zA-Z-][a-zA-Z0-9-]*",L_=(?<major>${Vn})\\.(?<minor>${Vn})\\.(?<patch>${Vn}),Cy=(?:${Vn}|${__}),My=(?:-(?<prerelease>${Cy}(?:\\.${Cy})*)),Oy="[0-9A-Za-z-]+",Ay=(?:\\+(?<buildmetadata>${Oy}(?:\\.${Oy})*)),Iy=v?${L_}${My}?${Ay}?,Dy=new RegExp(^${Iy}$),$y="(?:<|>)?=?",C_="x|X|\\*",zl=${Vn}|${C_},Ji=v=\\s*(?<major>${zl})(?:\\.(?<minor>${zl})(?:\\.(?<patch>${zl})${My}?${Ay}?)?)?,jy=new RegExp(^(?<operator>~>?|\\^|${$y})\\s*${Ji}$),Fy=new RegExp(^(?<operator>${$y})\\s*(${Iy})$|^$);function Kl(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var Yl=256;var O_=new RegExp(^${Vn}$);function bt(e){return e.split(".").filter(Boolean).map(t=>{if(O_.test(t)){let r=Number(t);if(Kl(r))return r}return t})}function nr(e){return e.split(".").filter(Boolean)}function jr(e,t){let r=Number(e);if(!Kl(r))throw new TypeError(t);return r}function gn(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 Dt(e,t){return e===t?0:Xi(e.major,t.major)||Xi(e.minor,t.minor)||Xi(e.patch,t.patch)||Ny(e.prerelease,t.prerelease)||Gl(e.prerelease,t.prerelease)}function Vl(e){return e.toFixed(0)}function yn(e){let t=Vl(e.major),r=Vl(e.minor),n=Vl(e.patch),o=e.prerelease?.join(".")??"",s=e.build?.join(".")??"";return[[${t}.${r}.${n},o].filter(c=>c).join("-"),s].filter(c=>c).join("+")}function N_(e,t){if(gn(t))return!0;let r=Dt(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 Qi(e,t){for(let r of t)if(!N_(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(gn(r))continue;let{major:n,minor:o,patch:s,prerelease:i}=r;if(i&&i.length>0&&e.major===n&&e.minor===o&&e.patch===s)return!0}return!1}return!0}function Zi(e,t){return t.some(r=>Qi(e,r))}var ea={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},Xn={operator:void 0,...ea};function Uy(e,t){return Dt(e,t)>0}function jo(e,t){let r;for(let n of e)Zi(n,t)&&(r=r&&Uy(r,n)?r:n);return r}function M_(e){let r=e.match(Fy)?.groups;if(!r)return null;let{operator:n,prerelease:o,buildmetadata:s}=r,i=r.major?{major:jr(r.major,Cannot parse comparator ${e}: invalid major version),minor:jr(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:jr(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:o?bt(o):[],build:s?nr(s):[]}:ea;return{operator:n||void 0,...i}}function ke(e){return!e||e.toLowerCase()==="x"||e==="*"}function A_(e){if(!ke(e.major))return ke(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:ke(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?bt(e.prerelease):[],build:[]}}function I_(e){if(!ke(e.major))return ke(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:ke(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:bt(e.prerelease),build:[]}:{operator:"<=",major:+e.major,minor:+e.minor,patch:+e.patch,prerelease:e.prerelease?bt(e.prerelease):[],build:[]}}function D_(e){let t=e.match(new RegExp(^${Ji})),r=t?.groups;if(!r)return;let n=t[0].length,o=e.slice(n).match(/^\s+-\s+/);if(!o)return;let s=o[0].length,a=e.slice(n+s).match(new RegExp(^${Ji}\\s*$))?.groups;if(!a)return;let c=A_(r),l=I_(a);return[c,l].filter(Boolean)}function $_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[Xn];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return o===0?[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];let a=bt(e.prerelease??"");return o===0?s===0?[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s,patch:i+1}]:[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o+1,minor:0,patch:0}]}function j_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[Xn];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let a=bt(e.prerelease??"");return[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s+1,patch:0}]}function F_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:o,minor:0,patch:0}]:[{operator:"<",major:o,minor:s,patch:0}];if(n)return[{operator:"<",major:o,minor:s,patch:0}];let a=bt(e.prerelease??""),c=nr(e.build??"");return[{operator:"<",major:o,minor:s,patch:i,prerelease:a,build:c}]}function U_(e){let t=ke(e.minor),r=ke(e.patch),n=+e.major,o=+e.minor,s=+e.patch;if(t)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:o+1,patch:0}];if(r)return[{operator:"<",major:n,minor:o+1,patch:0}];let i=bt(e.prerelease??""),a=nr(e.build??"");return[{operator:"<=",major:n,minor:o,patch:s,prerelease:i,build:a}]}function B_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s+1,patch:0}];let a=bt(e.prerelease??""),c=nr(e.build??"");return[{operator:">",major:o,minor:s,patch:i,prerelease:a,build:c}]}function H_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[Xn];if(r)return n?[{operator:">=",major:o,minor:0,patch:0}]:[{operator:">=",major:o,minor:s,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0}];let a=bt(e.prerelease??""),c=nr(e.build??"");return[{operator:">=",major:o,minor:s,patch:i,prerelease:a,build:c}]}function W_(e){let t=ke(e.major),r=ke(e.minor),n=ke(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[Xn];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let a=bt(e.prerelease??""),c=nr(e.build??"");return[{operator:void 0,major:o,minor:s,patch:i,prerelease:a,build:c}]}function q_(e){let t=e.match(jy)?.groups;if(!t)return M_(e);switch(t.operator){case"^":return $_(t);case"~":case"~>":return j_(t);case"<":return F_(t);case"<=":return U_(t);case">":return B_(t);case">=":return H_(t);case"=":case"":return W_(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function z_(e){return e.split(/\s+/).flatMap(q_)}function By(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>D_(r)||z_(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function Xl(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>Yl)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${Yl});e=e.trim();let t=e.match(Dy)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=jr(t.major,Cannot parse version ${e}: invalid major version),n=jr(t.minor,Cannot parse version ${e}: invalid minor version),o=jr(t.patch,Cannot parse version ${e}: invalid patch version),s=t.prerelease?bt(t.prerelease):[],i=t.buildmetadata?nr(t.buildmetadata):[];return{major:r,minor:n,patch:o,prerelease:s,build:i}}function Jl(e){try{return By(e)}catch{return}}function Ql(e){try{return Xl(e)}catch{return}}var Fo={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var Fr=async e=>{try{let t=await fetch(e);return t.ok?be([t,!1]):Z({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return Z({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return Z({name:"AbortError",message:t.message,request:e});throw t}};var Zl="https://jsr.io",Hy=async(e,t)=>{let r=await(t?.fetch??Fr)(new Request(${t?.endpoint??Zl}/${e}/meta.json),t?.cacheFirst);return Ot(r,([n])=>n.json())};var Wy=async(e,t,r)=>{let n=await(r?.fetch??Fr)(new Request(${r?.endpoint??Zl}/${e}/${t}_meta.json),r?.cacheFirst);return Ot(n,([o])=>o.json())};var qy=async(e,t)=>{let r=await(t?.fetch??Fr)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return Ot(r,([n])=>n.json())};var Ky=(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}),ta=(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}),Yy=async(e,t)=>{if(t?.resolvedVersions){let c=new Map(t.resolvedVersions.get(e.name)??[]),l=jo([...c.keys()],e.range);if(l){let p=c.get(l)??Uo,u=p[e.entryPoint];return typeof u!="string"&&console.log(u),u?be(zy(e.name,yn(l),u)):Z(ta(e,Object.keys(p)))}}let r=await qy(e.name,t);if(G(r))return r;let n=B(r),o=new Map(Object.entries(n.versions).flatMap(([c,{exports:l}])=>{let p=Ql(c);return p?[[p,l??Uo]]:[]})),s=jo([...o.keys()],e.range);if(!s)return Z(Ky(e,Object.keys(n.versions)));let i={...Uo};for(let c of Object.keys(o.get(s)??Uo))i[c]=c;let a=i[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[s,i]]),be(zy(e.name,yn(s),a))):Z(ta(e,Object.keys(i)))},zy=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),Vy=async(e,t)=>{if(t?.resolvedVersions){let a=new Map(t.resolvedVersions.get(e.name)??[]),c=jo([...a.keys()],e.range);if(c){let l=a.get(c)??Uo,p=l[e.entryPoint];return p?be(Gy(e.name,yn(c),p)):Z(ta(e,Object.keys(l)))}}let r=await G_(e,t);if(G(r))return r;let n=B(r),o=await Wy(e.name,yn(n),t);if(G(o))return o;let s=B(o).exports,i=s[e.entryPoint];return i?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[n,s]]),be(Gy(e.name,yn(n),i))):Z(ta(e,Object.keys(B(o).exports)))},Gy=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),G_=async(e,t)=>{let r=await Hy(e.name,t);if(G(r))return r;let n=B(r),o=Object.keys(n.versions).flatMap(i=>{let a=Ql(i);return a?[a]:[]}),s=jo(o,e.range);return s?be(s):Z(Ky(e,Object.keys(n.versions)))},Uo={".":"./"};var K_=e=>({name:"OnlyScopeProvidedError",specifier:e}),Xy=e=>({name:"PackageNotFoundError",specifier:e}),Jy=e=>{if(e.protocol!=="npm:")return Z({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,n,o;if(t[r]==="@"){let u=t.indexOf("/",r);if(u===-1)return Z(K_(e));n=t.indexOf("/",u+1),o=t.indexOf("@",u+1)}else n=t.indexOf("/",r),o=t.indexOf("@",r);if(n===-1&&(n=t.length),o===-1&&(o=t.length),o=Math.min(o,n),r===o)return Z(Xy(e));let s=t.slice(r,o),i=decodeURIComponent(t.slice(o+1,n)),a=i?Jl(i)??[[Fo]]:[[Fo]],c=t.slice(n+1),l=c?./${c}:".",p={name:s,range:a,entryPoint:l};return i&&(p.tag=i),be(p)},Qy=e=>{if(e.protocol!=="jsr:")return Z({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return Z({name:"ScopeNotFoundError",specifier:e});let n=t.indexOf("/",r);if(n===-1)return Z(Xy(e));let o=t.indexOf("/",n+1),s=t.indexOf("@",n+1);o===-1&&(o=t.length),s===-1&&(s=t.length),s=Math.min(s,o);let i=t.slice(r,s),a=decodeURIComponent(t.slice(s+1,o)),c=a?Jl(a)??[[Fo]]:[[Fo]],l=t.slice(o+1),p=l?./${l}:".",u={name:i,range:c,entryPoint:p};return a&&(u.tag=a),be(u)};var Zy=e=>new Promise((t,r)=>{let n=new FileReader;n.addEventListener("load",()=>{let o=n.result,s=o.indexOf(";");o.startsWith("; charset=utf-8",s)?t(${o.slice(0,s)}${o.slice(s+15)}):t(o)}),n.addEventListener("error",()=>r(n.error)),n.readAsDataURL(e)});var rb=e=>{let t=new Map,r=async n=>{let o=n.namespace==="npm",s=(o?Jy:Qy)(ql(n));if(G(s)){let a=ne(s);return{errors:[{text:a.name,detail:a}]}}let i=await(o?Yy:Vy)(B(s),{resolvedVersions:t,...e});if(G(i)){let a=ne(i);return{errors:[{text:${a.name} ${a.message},detail:a}]}}return Py(B(i))};return{name:"remote-loader",setup({onLoad:n,onResolve:o,initialOptions:s}){for(let i of[...eb,...tb])o({filter:/.*/,namespace:i.slice(0,-1)},Y_);o({filter:/.*/,namespace:"npm"},r),o({filter:/.*/,namespace:"jsr"},r);for(let i of eb)n({filter:/.*/,namespace:i.slice(0,-1)},a=>V_(ql(a),{...e,sourcemap:s.sourcemap!==!1&&s.sourcemap!==void 0}));for(let i of tb)n({filter:/.*/,namespace:i.slice(0,-1)},()=>{throw new Error(${i} import is not supported yet.)})}}},Y_=e=>({path:e.path,namespace:e.namespace}),eb=["http:","https:","data:"],tb=["node:"],V_=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(l=>l.test(e)):!0,n=t.fetch??Fr,o=await n(new Request(e),r);if(G(o))return{errors:[{text:${ne(o).message} Failed to fetch ${e},detail:ne(o)}]};let[s,i]=B(o),a=Ly(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&&_y(a)){let l=await c.text(),p=Ry(l,e);if(kr(p)){let{url:u,start:f,end:d}=B(p);if(u.protocol!=="data:"){let h=await n(new Request(u),r);if(G(h))return{contents:l,loader:a,warnings:[{text:${ne(h).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${u}},{text:Original URL: ${e}}],detail:ne(h)}]};let g=await B(h)[0].blob().then(Zy);return{contents:l.slice(0,f)+g+l.slice(d),loader:a}}}}return{contents:new Uint8Array(await c.arrayBuffer()),loader:a}};var Wo=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,n,o,s){this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=o,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},X_=/[$_\p{ID_Start}]/u,J_=/[$_\u200C\u200D\p{ID_Continue}]/u,tu=".*";function Q_(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function sb(e,t=!1){let r=[],n=0;for(;n<e.length;){let o=e[n],s=function(i){if(!t)throw new TypeError(i);r.push({type:"INVALID_CHAR",index:n,value:e[n++]})};if(o==="*"){r.push({type:"ASTERISK",index:n,value:e[n++]});continue}if(o==="+"||o==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:e[n++]});continue}if(o==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});continue}if(o==="{"){r.push({type:"OPEN",index:n,value:e[n++]});continue}if(o==="}"){r.push({type:"CLOSE",index:n,value:e[n++]});continue}if(o===":"){let i="",a=n+1;for(;a<e.length;){let c=e.substr(a,1);if(a===n+1&&X_.test(c)||a!==n+1&&J_.test(c)){i+=e[a++];continue}break}if(!i){s(Missing parameter name at ${n});continue}r.push({type:"NAME",index:n,value:i}),n=a;continue}if(o==="("){let i=1,a="",c=n+1,l=!1;if(e[c]==="?"){s(Pattern cannot start with "?" at ${c});continue}for(;c<e.length;){if(!Q_(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 ${n});continue}if(!a){s(Missing pattern at ${n});continue}r.push({type:"REGEX",index:n,value:a}),n=c;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function ib(e,t={}){let r=sb(e);t.delimiter??="/#?",t.prefixes??="./";let n=^${$t(t.delimiter)}+?,o=[],s=0,i=0,a="",c=new Set,l=E=>{if(i<r.length&&r[i].type===E)return r[i++].value},p=()=>l("OTHER_MODIFIER")??l("ASTERISK"),u=E=>{let b=l(E);if(b!==void 0)return b;let{type:k,index:v}=r[i];throw new TypeError(Unexpected ${k} at ${v}, expected ${E})},f=()=>{let E="",b;for(;b=l("CHAR")??l("ESCAPED_CHAR");)E+=b;return E},d=E=>E,h=t.encodePart||d,g="",y=E=>{g+=E},w=()=>{g.length&&(o.push(new Wo(3,"","",h(g),"",3)),g="")},R=(E,b,k,v,L)=>{let O=3;switch(L){case"?":O=1;break;case"*":O=0;break;case"+":O=2;break}if(!b&&!k&&O===3){y(E);return}if(w(),!b&&!k){if(!E)return;o.push(new Wo(3,"","",h(E),"",O));return}let $;k?k==="*"?$=tu:$=k:$=n;let S=2;$===n?(S=1,$=""):$===tu&&(S=0,$="");let T;if(b?T=b:k&&(T=s++),c.has(T))throw new TypeError(Duplicate name '${T}'.);c.add(T),o.push(new Wo(S,T,h(E),$,h(v),O))};for(;i<r.length;){let E=l("CHAR"),b=l("NAME"),k=l("REGEX");if(!b&&!k&&(k=l("ASTERISK")),b||k){let L=E??"";t.prefixes.indexOf(L)===-1&&(y(L),L=""),w();let O=p();R(L,b,k,"",O);continue}let v=E??l("ESCAPED_CHAR");if(v){y(v);continue}if(l("OPEN")){let L=f(),O=l("NAME"),$=l("REGEX");!O&&!$&&($=l("ASTERISK"));let S=f();u("CLOSE");let T=p();R(L,O,$,S,T);continue}w(),u("END")}return o}function $t(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function nb(e){return e&&e.ignoreCase?"ui":"u"}function Z_(e,t,r){return ab(ib(e,r),t,r)}function Jn(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function ab(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let a of e){if(a.type===3){a.modifier===3?n+=$t(a.value):n+=(?:${$t(a.value)})${Jn(a.modifier)};continue}t&&t.push(a.name);let c=^${$t(r.delimiter)}+?,l=a.value;if(a.type===1?l=c:a.type===0&&(l=tu),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?n+=(${l})${Jn(a.modifier)}:n+=((?:${l})${Jn(a.modifier)});continue}if(a.modifier===3||a.modifier===1){n+=(?:${$t(a.prefix)}(${l})${$t(a.suffix)}),n+=Jn(a.modifier);continue}n+=(?:${$t(a.prefix)},n+=((?:${l})(?:,n+=$t(a.suffix),n+=$t(a.prefix),n+=(?:${l}))*)${$t(a.suffix)}),a.modifier===0&&(n+="?")}let o=${$t(r.endsWith)}|$,s=${$t(r.delimiter)};if(r.end)return r.strict||(n+=${s}?),r.endsWith.length?n+=(?=${o}):n+="$",new RegExp(n,nb(r));r.strict||(n+=(?:${s}(?=${o}))?);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||(n+=(?=${s}|${o})),new RegExp(n,nb(r))}var Br={delimiter:"",prefixes:"",sensitive:!0,strict:!0},e1={delimiter:".",prefixes:"",sensitive:!0,strict:!0},t1={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function r1(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function cb(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function n1(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function lb(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var ub=["ftp","file","http","https","ws","wss"];function pb(e){if(!e)return!0;for(let t of ub)if(e.test(t))return!0;return!1}function o1(e,t){if(e=cb(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 s1(e,t){if(e=cb(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 i1(e,t){return t||e===""?e:lb(e)?mb(e):fb(e)}function a1(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function c1(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function l1(e,t,r){if(r||e==="")return e;if(t&&!ub.includes(t))return new URL(${t}:${e}).pathname;let n=e[0]=="/";return e=new URL(n?e:"/-"+e,"https://example.com").pathname,n||(e=e.substring(2,e.length)),e}function u1(e,t,r){return db(t)===e&&(e=""),r||e===""?e:hb(e)}function p1(e,t){return e=n1(e,":"),t||e===""?e:ru(e)}function db(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function ru(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function d1(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function f1(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function fb(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 mb(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function hb(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function m1(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 h1(e){return e===""?e:new URL(data:${e}).pathname}function g1(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function y1(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var b1=class{#i;#n=[];#t={};#e=0;#s=1;#a=0;#o=0;#d=0;#u=0;#f=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=sb(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type==="END"){if(this.#o===0){this.#g(),this.#p()?this.#r(9,1):this.#m()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#y(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#R())this.#d-=1;else continue;if(this.#P()){this.#d+=1;continue}switch(this.#o){case 0:this.#v()&&this.#y(1);break;case 1:if(this.#v()){this.#L();let e=7,t=1;this.#k()?(e=2,t=3):this.#f&&(e=2),this.#r(e,t)}break;case 2:this.#x()?this.#y(3):(this.#w()||this.#m()||this.#p())&&this.#y(5);break;case 3:this.#E()?this.#r(4,1):this.#x()&&this.#r(5,1);break;case 4:this.#x()&&this.#r(5,1);break;case 5:this.#S()?this.#u+=1:this.#_()&&(this.#u-=1),this.#T()&&!this.#u?this.#r(6,1):this.#w()?this.#r(7,0):this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 6:this.#w()?this.#r(7,0):this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 7:this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 8:this.#p()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#r(e,t){switch(this.#o){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.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#f?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??="")),this.#h(e,t)}#h(e,t){this.#o=e,this.#a=this.#e+t,this.#e+=t,this.#s=0}#g(){this.#e=this.#a,this.#s=0}#y(e){this.#g(),this.#o=e}#b(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#c(e,t){let r=this.#b(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#v(){return this.#c(this.#e,":")}#k(){return this.#c(this.#e+1,"/")&&this.#c(this.#e+2,"/")}#x(){return this.#c(this.#e,"@")}#E(){return this.#c(this.#e,":")}#T(){return this.#c(this.#e,":")}#w(){return this.#c(this.#e,"/")}#m(){if(this.#c(this.#e,"?"))return!0;if(this.#n[this.#e].value!=="?")return!1;let e=this.#b(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#p(){return this.#c(this.#e,"#")}#P(){return this.#n[this.#e].type=="OPEN"}#R(){return this.#n[this.#e].type=="CLOSE"}#S(){return this.#c(this.#e,"[")}#_(){return this.#c(this.#e,"]")}#l(){let e=this.#n[this.#e],t=this.#b(this.#a).index;return this.#i.substring(t,e.index)}#L(){let e={};Object.assign(e,Br),e.encodePart=ru;let t=Z_(this.#l(),void 0,e);this.#f=pb(t)}},eu=["protocol","username","password","hostname","port","pathname","search","hash"],Ur="*";function ob(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 xr(e,t){return t?Ho(e):e}function Bo(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=xr(n.protocol.substring(0,n.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=xr(n.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=xr(n.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=xr(n.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=xr(n.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=xr(n.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=xr(n.search.substring(1,n.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=xr(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=p1(t.protocol,r)),typeof t.username=="string"&&(e.username=c1(t.username,r)),typeof t.password=="string"&&(e.password=a1(t.password,r)),typeof t.hostname=="string"&&(e.hostname=i1(t.hostname,r)),typeof t.port=="string"&&(e.port=u1(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!r1(e.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(e.pathname=xr(n.pathname.substring(0,o+1),r)+e.pathname)}e.pathname=l1(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=s1(t.search,r)),typeof t.hash=="string"&&(e.hash=o1(t.hash,r)),e}function Ho(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function x1(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function w1(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",n=^${x1(t.delimiter)}+?,o=/[$_\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+=Ho(a.value);continue}s+={${Ho(a.value)}}${Jn(a.modifier)};continue}let c=a.hasCustomName(),l=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!t.prefixes.includes(a.prefix)),p=i>0?e[i-1]:null,u=i<e.length-1?e[i+1]:null;if(!l&&c&&a.type===1&&a.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let f=u.value.length>0?u.value[0]:"";l=o.test(f)}else l=!u.hasCustomName();if(!l&&!a.prefix.length&&p&&p.type===3){let f=p.value[p.value.length-1];l=t.prefixes.includes(f)}l&&(s+="{"),s+=Ho(a.prefix),c&&(s+=:${a.name}),a.type===2?s+=(${a.value}):a.type===1?c||(s+=(${n})):a.type===0&&(!c&&(!p||p.type===3||p.modifier!==3||l||a.prefix!=="")?s+="*":s+=(${r})),a.type===1&&c&&a.suffix.length&&o.test(a.suffix[0])&&(s+="\\"),s+=Ho(a.suffix),l&&(s+="}"),a.modifier!==3&&(s+=Jn(a.modifier))}return s}var gb=class{#i;#n={};#t={};#e={};#s={};#a=!1;constructor(e={},t,r){try{let n;if(typeof t=="string"?n=t:r=t,typeof e=="string"){let a=new b1(e);if(a.parse(),e=a.result,n===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=n}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let o={ignoreCase:r.ignoreCase===!0},s={pathname:Ur,protocol:Ur,username:Ur,password:Ur,hostname:Ur,port:Ur,search:Ur,hash:Ur};this.#i=Bo(s,e,!0),db(this.#i.protocol)===this.#i.port&&(this.#i.port="");let i;for(i of eu){if(!(i in this.#i))continue;let a={},c=this.#i[i];switch(this.#t[i]=[],i){case"protocol":Object.assign(a,Br),a.encodePart=ru;break;case"username":Object.assign(a,Br),a.encodePart=d1;break;case"password":Object.assign(a,Br),a.encodePart=f1;break;case"hostname":Object.assign(a,e1),lb(c)?a.encodePart=mb:a.encodePart=fb;break;case"port":Object.assign(a,Br),a.encodePart=hb;break;case"pathname":pb(this.#n.protocol)?(Object.assign(a,t1,o),a.encodePart=m1):(Object.assign(a,Br,o),a.encodePart=h1);break;case"search":Object.assign(a,Br,o),a.encodePart=g1;break;case"hash":Object.assign(a,Br,o),a.encodePart=y1;break}try{this.#s[i]=ib(c,a),this.#n[i]=ab(this.#s[i],this.#t[i],a),this.#e[i]=w1(this.#s[i],a),this.#a=this.#a||this.#s[i].some(l=>l.type===2)}catch{throw new TypeError(invalid ${i} pattern '${this.#ii}'.)}}}catch(n){throw new TypeError(Failed to construct 'URLPattern': ${n.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=Bo(r,e,!1):r=Bo(r,ob(e,t),!1)}catch{return!1}let n;for(n of eu)if(!this.#n[n].exec(r[n]))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=Bo(r,e,!1):r=Bo(r,ob(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let o;for(o of eu){let s=this.#n[o].exec(r[o]);if(!s)return null;let i={};for(let[a,c]of this.#t[o].entries())if(typeof c=="string"||typeof c=="number"){let l=s[a+1];i[c]=l}n[o]={input:r[o]??"",groups:i}}return n}static compareComponent(e,t,r){let n=(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},o=new Wo(3,"","","","",3),s=new Wo(0,"","","","",3),i=(a,c)=>{let l=0;for(;l<Math.min(a.length,c.length);++l){let p=n(a[l],c[l]);if(p)return p}return a.length===c.length?0:n(a[l]??o,c[l]??o)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?i(t.#s[e],[s]):!t.#e[e]&&r.#e[e]?i([s],r.#s[e]):i(t.#s[e],r.#s[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=gb);var yb,bb=async(e,t)=>(yb??=Ai({wasm:e,worker:t}),await yb,async r=>{let{outputFiles:n}=await Ni({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[cy(),rb({fetch:v1,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:n[0].text}}),v1=async(e,t)=>{let r=ly(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let n=await nu(e);if(n)return n}try{let n=await r(e);return n.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await zs(e,n),be([n,!1])):await nu(e)??Z({name:"HTTPError",message:${n.status} ${n.statusText},response:n})}catch(n){let o=await nu(e);if(o)return o;if(n instanceof TypeError)return Z({name:"NetworkError",message:n.message,request:e});if(n instanceof DOMException)return Z({name:"AbortError",message:n.message,request:e});throw n}},nu=async e=>{if(e.url.startsWith("data:"))return;let t=await Cn(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),be([t,!0])};var xb=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var wb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},vb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},kb=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},Eb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var Tb=()=>{let e;return{show:(n,{x:o,y:s})=>{e=k1(),e.append(E1(n)),e.style.visibility="hidden",document.body.append(e);let{height:i}=e.getBoundingClientRect();e.style.top=${s-i}px,e.style.left=${o}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(n=>setTimeout(n,150)),e?.remove?.()}}},k1=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},E1=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 Pb=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:n}=Tb();return{component:e,setStatus:async(s,i)=>{switch(e.textContent="",await n(),s){case"loading":e.append(kb());break;case"pass":e.append(wb());break;case"fail":e.append(vb());break;case"none":break}i!==void 0&&s!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await n();else{let{top:a,left:c}=e.getBoundingClientRect();r(i,{y:a+globalThis.scrollY,x:c})}t=!t}):e.style.pointerEvents="none"}}};var Rb=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(Eb()),t.addEventListener("click",e),t};var Sb=e=>{let{component:t,setStatus:r}=Pb(),n=document.createElement("div");return n.style.position="absolute",n.style.left="-2em",n.style.zIndex="1",n.style.display="flex",n.style.flexFlow="column",n.append(Rb(e),t),{menu:n,setStatus:r}};function _b(e){return new Promise(t=>setTimeout(t,e))}function Lb(e,t){let{trailing:r=!1,interval:n=0}=t??{},o,s=!1,i=l=>{o?.resolve?.({executed:!1}),o=l},a=()=>{let{...l}=o;return o=void 0,l},c=async()=>{if(s||!o)return;s=!0,n>0&&await _b(n);let{parameters:l,resolve:p,reject:u}=a();try{let f=await e(...l);s=!1,p({result:f,executed:!0})}catch(f){s=!1,u(f)}finally{r?await c():(i(),await Promise.resolve())}};return(...l)=>new Promise((p,u)=>{i({parameters:l,resolve:p,reject:u}),c()})}var Cb,Ob=async(e,t)=>{let r=[],o=Lb(async()=>{r.forEach(({menu:i,setStatus:a})=>{a("none"),i.remove()});let s=Rg(scrapbox.Project.name,scrapbox.Page.title??"",gt());for(let i of s){let a=i.lang.toLowerCase();if(xb(a))for(let c of i.startIds){let l=document.getElementById(L${c}),{menu:p,setStatus:u}=Sb(async()=>{await u("loading");try{Cb??=await bb(e,t);let{contents:f}=await Cb(i.path);console.debug("execute:",f),await Function(return (async()=>{${f}})())(),await u("pass")}catch(f){console.error(f),await u("fail",${f})}});r.push({menu:p,setStatus:u}),l?.insertBefore?.(p,l?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await o(),scrapbox.addListener("lines:changed",o),()=>{scrapbox.removeListener("lines:changed",o),r.forEach(({menu:s,setStatus:i})=>{i("none"),s.remove()})}};function P1(e,t){for(var r in t)e[r]=t[r];return e}function Nb(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var n in t)if(n!=="__source"&&e[n]!==t[n])return!0;return!1}function Qn(e,t){var r=t(),n=X({t:{__:r,u:t}}),o=n[0].t,s=n[1];return Ns(function(){o.__=r,o.u=t,ou(o)&&s({t:o})},[e,r,t]),ee(function(){return ou(o)&&s({t:o}),e(function(){ou(o)&&s({t:o})})},[e]),r}function ou(e){var t,r,n=e.u,o=e.__;try{var s=n();return!((t=o)===(r=s)&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}}function Mb(e,t){this.props=e,this.context=t}(Mb.prototype=new Bt).isPureReactComponent=!0,Mb.prototype.shouldComponentUpdate=function(e,t){return Nb(this.props,e)||Nb(this.state,t)};var Ab=J.__b;J.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Ab&&Ab(e)};var hae=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var R1=J.__e;J.__e=function(e,t,r,n){if(e.then){for(var o,s=t;s=s.__;)if((o=s.__c)&&o.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),o.__c(e,t)}R1(e,t,r,n)};var Ib=J.unmount;function Bb(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),e.__c.__H=null),(e=P1({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map(function(n){return Bb(n,t,r)})),e}function Hb(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(n){return Hb(n,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function su(){this.__u=0,this.o=null,this.__b=null}function Wb(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function ra(){this.i=null,this.l=null}J.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Ib&&Ib(e)},(su.prototype=new Bt).__c=function(e,t){var r=t.__c,n=this;n.o==null&&(n.o=[]),n.o.push(r);var o=Wb(n.__v),s=!1,i=function(){s||(s=!0,r.__R=null,o?o(a):a())};r.__R=i;var a=function(){if(!--n.__u){if(n.state.__a){var c=n.state.__a;n.__v.__k[0]=Hb(c,c.__c.__P,c.__c.__O)}var l;for(n.setState({__a:n.__b=null});l=n.o.pop();)l.forceUpdate()}};n.__u++||32&t.__u||n.setState({__a:n.__b=n.__v.__k[0]}),e.then(i,i)},su.prototype.componentWillUnmount=function(){this.o=[]},su.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=Bb(this.__b,r,n.__O=n.__P)}this.__b=null}var o=t.__a&&cr(Y,null,e.fallback);return o&&(o.__u&=-33),[cr(Y,null,t.__a?null:e.children),o]};var Db=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]}};(ra.prototype=new Bt).__a=function(e){var t=this,r=Wb(t.__v),n=t.l.get(e);return n[0]++,function(o){var s=function(){t.props.revealOrder?(n.push(o),Db(t,e,n)):o()};r?r(s):s()}},ra.prototype.render=function(e){this.i=null,this.l=new Map;var t=Tr(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},ra.prototype.componentDidUpdate=ra.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){Db(e,r,t)})};var S1=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,_1=/^(?: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]/,L1=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,C1=/[A-Z0-9]/g,O1=typeof document<"u",N1=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};Bt.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(Bt.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var $b=J.event;function M1(){}function A1(){return this.cancelBubble}function I1(){return this.defaultPrevented}J.event=function(e){return $b&&(e=$b(e)),e.persist=M1,e.isPropagationStopped=A1,e.isDefaultPrevented=I1,e.nativeEvent=e};var qb,D1={enumerable:!1,configurable:!0,get:function(){return this.class}},jb=J.vnode;J.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,n=t.type,o={},s=n.indexOf("-")===-1;for(var i in r){var a=r[i];if(!(i==="value"&&"defaultValue"in r&&a==null||O1&&i==="children"&&n==="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"||n!=="input"&&n!=="textarea"||N1(r.type)?c==="onfocus"?i="onfocusin":c==="onblur"?i="onfocusout":L1.test(i)&&(i=c):c=i="oninput":s&&_1.test(i)?i=i.replace(C1,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&o[i=c]&&(i="oninputCapture"),o[i]=a}}n=="select"&&o.multiple&&Array.isArray(o.value)&&(o.value=Tr(r.children).forEach(function(l){l.props.selected=o.value.indexOf(l.props.value)!=-1})),n=="select"&&o.defaultValue!=null&&(o.value=Tr(r.children).forEach(function(l){l.props.selected=o.multiple?o.defaultValue.indexOf(l.props.value)!=-1:o.defaultValue==l.props.value})),r.class&&!r.className?(o.class=r.class,Object.defineProperty(o,"className",D1)):(r.className&&!r.class||r.class&&r.className)&&(o.class=o.className=r.className),t.props=o}(e),e.$$typeof=S1,jb&&jb(e)};var Fb=J.__r;J.__r=function(e){Fb&&Fb(e),qb=e.__c};var Ub=J.diffed;J.diffed=function(e){Ub&&Ub(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),qb=null};var qo=e=>e.replaceAll(" ","_").toLowerCase(),zb=e=>e.replaceAll("_"," "),na=e=>[...e].map((t,r)=>t===" "?"_":!$1.includes(t)||r===e.length-1&&j1.includes(t)?encodeURIComponent(t):t).join(""),$1='@$&+=:;",',j1=':;",';var Gb=({title:e,projects:t,selected:r,confirm:n})=>m("div",{className:candidate${r?" selected":""},children:[m(F1,{title:e,confirm:n}),t.map(o=>m(U1,{project:o.name,title:e,mark:o.mark,confirm:o.confirm}))]}),F1=({title:e,confirm:t})=>m("a",{className:"button",tabIndex:0,role:"menuitem",href:./${na(e)},onClick:Kb(t),children:e}),U1=({project:e,title:t,mark:r,confirm:n})=>r===""?m(Y,{}):m("a",{className:"mark",tabIndex:0,href:../${e}/${na(t)},onClick:Kb(n),title:/${e}/${na(t)},children:r instanceof URL?m("img",{src:r.href}):${r}}),Kb=e=>I(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},[e]);var Yb=(e,t)=>{let[r,n]=X(null),o=I(c=>n(l=>{if(e.length===0)return null;if(l===null)return t(e[0]);let p=e.findIndex(u=>t(u)===l);return t(c?.cyclic?e[(p+1)%e.length]:e.at(p+1)??e[0])}),[e,t]),s=I(c=>n(l=>{if(e.length===0)return null;if(l===null)return t(e[e.length-1]);let p=e.findIndex(u=>t(u)===l);return p<0?t(e[e.length-1]):t(c?.cyclic?e[(p-1+e.length)%e.length]:e.at(p-1)??e[e.length-1])}),[e,t]),i=I(()=>n(e.length===0?null:t(e[0])),[e,t]),a=I(()=>n(e.length===0?null:t(e[e.length-1])),[e,t]);return{selectedId:r,next:o,prev:s,selectFirst:i,selectLast:a}};var Vb=e=>{let[t,r]=X(null),n=C(()=>{let o=t?.getBoundingClientRect?.(),i=bo(e.line,e.char)?.getBoundingClientRect?.();return!i||!o?{}:{top:${i.bottom-o.top}px,left:${i?.left??0-o.left}px,right:${o.right-(i?.left??0)}px}},[t,e.line,e.char]);return{updateStandardElement:r,...n}};var au="enableProjectsOnSuggestion",Xb=(e,t)=>{let[r,n]=X(oa([...e],t)),o=I((s,i)=>{B1(s,i,e,t),n(oa([...e],t))},[e,t.enableSelfProjectOnStart]);return ee(()=>{let s=i=>{i.key===au&&n(oa([...e],t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},[e,t.enableSelfProjectOnStart]),{projects:r,set:o}},iu=!0,oa=(e,t)=>{try{let r=localStorage.getItem(au);if(r===null)return sa(e),e;let n=JSON.parse(r);return Array.isArray(n)&&n.every(o=>typeof o=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?n:n.includes(scrapbox.Project.name)?iu?n:n.filter(o=>o!==scrapbox.Project.name):iu?[...n,scrapbox.Project.name]:n:(sa(e),e)}catch(r){if(!(r instanceof TypeError))throw r;return sa(e),e}},B1=(e,t,r,n)=>{let o=oa([...r],n);n.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(iu=t),sa(t?[...o,e]:o.filter(s=>s!==e))},sa=e=>localStorage.setItem(au,JSON.stringify(e));var Jb=()=>C(()=>document.documentElement.dataset.os??"",[]);var zo=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var Qb=({progress:e})=>m("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 ex=({position:e,start:t,enableSelfProjectOnStart:r,projects:n,...o})=>{let{projects:s,set:i}=Xb(n,{enableSelfProjectOnStart:r}),{updateStandardElement:a,top:c,left:l,right:p}=Vb({line:e.line,char:t}),u=Jb();return m(Y,{children:[m(W1,{itemCount:o.items.length,enableProjects:s,projects:n,top:c,right:p,set:i,os:u,...o}),m(H1,{updateStandardElement:a,start:t,enableProjects:s,projects:n,top:c,left:l,os:u,...o})]})},H1=({start:e,updateStandardElement:t,confirmAfter:r,cancel:n,query:o,enableProjects:s,projects:i,items:a,top:c,left:l,progress:p,callback:u,limit:f,mark:d,os:h})=>{let g=I((S,T,P)=>{let _=[${T?/${T}/${S}:S}${P?.icon?".icon":""}];r((N,{line:M})=>[${...N.slice(0,e).join("")}${_}${...N.slice(e+...o.length).join("")},{line:M,char:e+[..._].length}])},[e,o]),y=C(()=>i.size>1||!i.has(scrapbox.Project.name),[i]),w=C(()=>{let S=[];for(let T of a){if(S.length===f)break;T.projects.some(P=>s.includes(P))&&S.push({title:T.title,projects:T.projects.flatMap(P=>s.includes(P)?[{name:P,mark:y?zo(d[P]??"",import.meta.url)||P[0]:"",confirm:_=>g(T.title,P,_)}]:[]),confirm:P=>g(T.title,void 0,P)})}return S},[s,y,a,f,d,g]),{selectedId:R,next:E,prev:b,selectLast:k,selectFirst:v}=Yb(w,Zb),L=I(S=>R===null?!1:(w.find(T=>Zb(T)===R)?.confirm?.(S),!0),[R,w]);ee(()=>u(w.length===0?void 0:{selectNext:S=>(E(S),!0),selectPrev:S=>(b(S),!0),selectFirst:()=>(v(),!0),selectLast:()=>(k(),!0),confirm:L,cancel:()=>(n(),!0)}),[u,w.length,E,b,v,k,L]);let O=C(()=>w.length>0&&c!=null&&l!=null?{top:c,left:l}:{display:"none"},[w.length,c,l]),$=I(S=>{if(!S){t(S);return}let T=S.parentNode;if(!(T instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(T.host.parentElement)},[t]);return m("div",{ref:$,className:"container candidates","data-os":h,style:O,children:[w.map(S=>m(Gb,{...S,selected:R===S.title},S.title)),a.length>f&&m("div",{className:"counter",children:${a.length-f} more links}),m(Qb,{progress:p})]})},W1=({enableProjects:e,projects:t,projectScore:r,mark:n,itemCount:o,top:s,right:i,set:a,os:c,freezeUntil:l})=>{let p=C(()=>[...t].sort((f,d)=>(r.get(d)??0)-(r.get(f)??0)).flatMap(f=>r.has(f)?[{name:f,enable:e.includes(f),mark:zo(n[f]??"",import.meta.url)||f[0],score:r.get(f),onClick:()=>l(()=>{a(f,!e.includes(f)),Ve().focus()})}]:[]),[t,r,e,n]),u=C(()=>o>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},[s,i,o,t.size]);return m("div",{className:"container projects","data-os":c,style:u,children:p.map(f=>m(q1,{...f},f.name))})},q1=e=>m("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name,children:e.mark instanceof URL?m("img",{src:e.mark.href}):${e.mark}}),Zb=e=>e.title;var Rt=!1,tx=e=>{Rt=typeof e=="boolean"?e:new Set(e)},jt=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},cu,...n)];case"log":case"info":case"debug":return[t,(...n)=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(%c${e},cu,...n)}];case"assert":return[t,(n,...o)=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(n,%c${e},cu,...o)}];case"time":case"timeEnd":return[t,n=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(Rt!==!0&&(!Rt||!Rt.has(e))))return r(...n)}]}})),cu="color: gray";async function*rx(e){let t=[],r=[],n=new Map,o=[];for(let s of e)s.isValid&&(s.id?s.isMember||t.push(s.id):r.push(s.name),o.push(s.name),n.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 ks(i);if(K(a)){r=o;break}for(let c of V(a).projects)n.has(c.name)&&(yield ce({...c,checked:n.get(c.name)??0}))}for(let s of r){let i=await ar(s);yield Wr(i)?ce({...V(i),checked:n.get(s)??0}):Ie({...vr(i),project:s})}}var pu=(e,t)=>t.some(r=>e instanceof r),nx,ox;function z1(){return nx||(nx=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function G1(){return ox||(ox=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var du=new WeakMap,lu=new WeakMap,ia=new WeakMap;function K1(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(Hr(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return ia.set(t,e),t}function Y1(e){if(du.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});du.set(e,t)}var fu={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return du.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Hr(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 cx(e){fu=e(fu)}function V1(e){return G1().includes(e)?function(...t){return e.apply(mu(this),t),Hr(this.request)}:function(...t){return Hr(e.apply(mu(this),t))}}function X1(e){return typeof e=="function"?V1(e):(e instanceof IDBTransaction&&Y1(e),pu(e,z1())?new Proxy(e,fu):e)}function Hr(e){if(e instanceof IDBRequest)return K1(e);if(lu.has(e))return lu.get(e);let t=X1(e);return t!==e&&(lu.set(e,t),ia.set(t,e)),t}var mu=e=>ia.get(e);function lx(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),a=Hr(i);return n&&i.addEventListener("upgradeneeded",c=>{n(Hr(i.result),c.oldVersion,c.newVersion,Hr(i.transaction),c)}),r&&i.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),o&&c.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function ux(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),Hr(r).then(()=>{})}var J1=["get","getKey","getAll","getAllKeys","count"],Q1=["put","add","delete","clear"],uu=new Map;function sx(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(uu.get(t))return uu.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=Q1.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||J1.includes(r)))return;let s=async function(i,...a){let c=this.transaction(i,o?"readwrite":"readonly"),l=c.store;return n&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),o&&c.done]))[0]};return uu.set(t,s),s}cx(e=>({...e,get:(t,r,n)=>sx(t,r)||e.get(t,r,n),has:(t,r)=>!!sx(t,r)||e.has(t,r)}));var Z1=["continue","continuePrimaryKey","advance"],ix={},hu=new WeakMap,px=new WeakMap,eL={get(e,t){if(!Z1.includes(t))return e[t];let r=ix[t];return r||(r=ix[t]=function(...n){hu.set(this,px.get(this)[t](...n))}),r}};async function*tL(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let r=new Proxy(t,eL);for(px.set(r,t),ia.set(r,mu(t));t;)yield r,t=await(hu.get(r)||t.continue()),hu.delete(r)}function ax(e,t){return t===Symbol.asyncIterator&&pu(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&pu(e,[IDBIndex,IDBObjectStore])}cx(e=>({...e,get(t,r,n){return ax(t,r)?tL:e.get(t,r,n)},has(t,r){return ax(t,r)||e.has(t,r)}}));var aa=jt("scrapbox-storage:db.ts"),dx,gu=async()=>(dx??=await lx("scrapbox-storage",4,{upgrade(e){aa.time("update DB");for(let n of e.objectStoreNames)e.deleteObjectStore(n);e.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let r=e.createObjectStore("projects",{keyPath:"id"});r.createIndex("checked","checked"),r.createIndex("name","name"),aa.timeEnd("update DB")},blocked(e,t){let r=The database "@takker/cosense-storage"(v${t}) is blocked because the older one (v${e}) is opened in other tabs. Please close the other tabs and reload this page.;aa.error(r),alert(r)},blocking(e,t){let r=The database "@takker/cosense-storage"(v${e}) is blocking the newer one (v${t}) opened.
Please close this page.;aa.error(r),alert(r)}}),dx);var la=(e,t)=>(yu||(yu=new BroadcastChannel(mx),yu.addEventListener("message",r=>fx(r.data))),ca.set(t,new Set(e).union(ca.get(t)??new Set)),()=>ca.delete(t)),bu=(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};fx(r);let n=new BroadcastChannel(mx);n.postMessage(r),n.close()},fx=e=>{for(let[t,r]of ca)r.has(e.project)&&t(e)},mx="scrapbox-storage-notify",yu,ca=new Map;var rL=Math.pow(10,8)*24*60*60*1e3,wce=-rL,nL=3600,gx=nL*24,vce=gx*7,oL=gx*365.2425,sL=oL/12,kce=sL*3,hx=Symbol.for("constructDateFrom");function iL(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&hx in e?e[hx](t):e instanceof Date?new e.constructor(t):new Date(t)}function aL(e,t){return iL(t||e,e)}function xu(e){return Math.trunc(+aL(e)/1e3)}var St=jt("scrapbox-storage:mod.ts"),ua=async(e,t)=>{let r=await gu(),n=new Map;try{{St.debug("check updates of links...");let s=new Set,i=r.transaction("projects","readwrite"),a=xu(new Date),c=a-600;for await(let u of i.store.index("checked").iterate(IDBKeyRange.lowerBound(c,!0))){let f=u.value;if(f.isValid===!1){s.add(f.id);continue}s.add(f.name);let d=f.checked;if(d+t>a||f?.updating&&d>c)continue;let h=structuredClone(f);h.updating=!0,n.set(f.id,h),u.update(h)}let l=[],p=i.store.index("name");for(let u of e)s.has(u)||l.push(p.get(u).then(f=>{n.set(u,f??cL(u))}));if(await Promise.all(l),await i.done,n.size===0){St.debug("checked. No project needs upgrade.");return}St.debug(checked. ${n.size} projects maybe need upgrade.)}let o=xu(new Date);for await(let s of rx(n.values())){if(K(s)){let{project:h,name:g}=vr(s);switch(g){default:continue;case"NotFoundError":St.warn("${h}" is not found.);break;case"NotMemberError":St.warn(You are not a member of "${h}".);break;case"NotLoggedInError":St.warn(You are not a member of "${h}" or You are not logged in yet.);break}n.set(h,{id:h,name:h,checked:o,updating:!1,isValid:!1,reason:g});continue}let{checked:i,...a}=V(s);if(a.updated<i){St.debug(no updates in "${a.name}"),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1});continue}let c=download and store links of "${a.name}";St.time(c);let l=new Set(await r.getAllKeysFromIndex("titles","project",a.name)),p=0,u=0;for await(let h of Wd(a.name)){if(K(h)){let{name:R,message:E}=vr(h);St.error(Failed to get links of "${a.name}" with ${R}: ${E});break}let g=V(h),y={},w=r.transaction("titles","readwrite");await Promise.all(g.map(async R=>{let E={...R,project:a.name};if(!l.has(R.id))return y.added?.set?.(R.id,E)??(y.added=new Map([[R.id,E]])),w.store.add(E);l.delete(R.id);let b=await w.store.get(R.id);if(!b)return y.added?.set?.(R.id,E)??(y.added=new Map([[R.id,E]])),w.store.add(E);if(!(b.updated>=E.updated))return y.updated?.set?.(R.id,[b,E])??(y.updated=new Map([[R.id,[b,E]]])),w.store.put(E)})),await w.done,p+=y.added?.size??0,u+=y.updated?.size??0,St.debug(Updating "/${a.name}": +${p} pages, ~${u} pages),bu(a.name,y)}let f=r.transaction("titles","readwrite"),d=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,St.timeEnd(c),St.debug(Update "/${a.name}": +${p} pages, ~${u} pages, -${d.size} pages),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1}),bu(a.name,{deleted:d})}}finally{let o=r.transaction("projects","readwrite");await Promise.all([...n].map(([,s])=>(s.updating=!1,o.store.put({...s})))),await o.done}},pa=async e=>{let t=[...new Set(e)];if(t.length===0)return[];let r=Date.now(),o=(await gu()).transaction("titles","readonly"),s=o.store.index("project"),i=(await Promise.all(t.map(a=>s.getAll(a)))).flat();return await o.done,St.debug(Read ${i.length} links from ${t.length} projects in ${Date.now()-r}ms),i},cL=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});ux("userscript-links").catch(e=>console.error(e));var lL=jt("scrapbox-select-suggestion:useSource.ts"),bx=e=>Qn(...C(()=>{let t=[];return[o=>{let s=pa(e).then(i=>{let a=uL(i);return t=[...a.values()],o(),a});return ua(e,600),la(e,({diff:i})=>s=s.then(a=>(lL.debug(Update: +${i.added?.size??0} pages, ~${i.updated?.size??0} pages, -${i.deleted?.size??0} pages),a=pL(a,i),t=[...a.values()],o(),a)))},()=>t]},[e])),uL=e=>{let t=new Map;for(let r of e)wu(t,r);return t},pL=(e,t)=>{let r=new Map(e);if(t.added)for(let[,n]of t.added)wu(r,n);if(t.updated)for(let[,[n,o]]of t.updated)yx(r,n),wu(r,o);if(t.deleted)for(let[,n]of t.deleted)yx(r,n);return r},wu=(e,t)=>{let r=qo(t.title),n=e.get(r);if((n?.updated??0)>t.updated)return;let o=n?.metadata??new Map;o.set(t.project,{image:t.image}),e.set(r,{title:t.title,titleLc:r,updated:t.updated,linked:n?.linked??0,metadata:o});for(let s of t.links){let i=qo(s),a=e.get(i),c=a?.metadata??new Map;c.set(t.project,c.get(t.project)??{image:t.image}),e.set(i,{title:a?.title??s,titleLc:i,updated:a?.updated??0,linked:(a?.linked??0)+1,metadata:c})}},yx=(e,t)=>{let r=qo(t.title),n=e.get(r);if(!n||(n.updated??0)>t.updated)return;let o=n.metadata;o.delete(t.project),o.size<=0?e.delete(r):e.set(r,{title:n.title,titleLc:r,updated:t.updated,linked:n.linked,metadata:o});for(let s of t.links){let i=qo(s),a=e.get(i);if(!a)continue;let c=a.metadata;c.delete(t.project),c.size<=0?e.delete(i):e.set(i,{title:a.title,titleLc:i,updated:t.updated,linked:a.linked-1,metadata:c})}};var xx=e=>{let t=C(()=>zo(e.style,import.meta.url),[e.style]);return m(Y,{children:t!==""&&(t instanceof URL?m("link",{rel:"stylesheet",href:t.href}):m("style",{children:t}))})};var wx=()=>m("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;
}
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
padding: 6px;
}
.candidates > :not(:first-child) {
border-top: 1px solid var(--select-suggest-border-color, #eee); }
.candidates > *{
line-height: 1.2em;
padding: 0.5em 10px;
}
.candidate {
display: flex;
}
a {
display: block;
text-decoration: none;
color: inherit;
}
a:not(.mark) {
width: 100%;
}
.selected a {
background-color: var(--select-suggest-selected-bg, #222); text-decoration: underline
}
img {
height: 1.3em;
width: 1.3em;
position: relative;
object-fit: cover;
object-position: 0% 0%;
}
.disabled {
filter: grayscale(1.0) opacity(0.5);
}
.counter {
color: var(--select-suggest-information-text-color, #aaa); font-size: 80%;
font-style: italic;
}
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
}});function*vx(e){if(!("nodes"in e))return;let t=0;function*r(n){for(let o of Array.isArray(n)?n:[n]){if(typeof o=="string"){t+=[...o].length;continue}switch(o.type){case"link":yield{whole:o.unit.whole,start:t},t+=[...o.unit.whole].length;break;case"indent":case"quote":t+=[...o.unit.tag].length,yield*r(o.children);break;case"deco":t+=[...o.unit.deco].length+2,yield*r(o.children),t++;break;case"strong":t+=2,yield*r(o.children),t+=2;break;default:t+=[...o.unit.whole].length;break}}}yield*r(e.nodes)}var kx=(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),n=Math.max(t.range.start.char,t.range.end.char),o=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(r,n).join(""):"";if(fL(t.lines[t.position.line],o)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:o,start:r,position:t.position};if(o!=="")return e.type==="completion"?{type:"ready"}:e;let s=dL(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"}},dL=(e,t)=>{for(let{whole:r,start:n}of vx(e))if(!(t<=n||n+[...r].length<=t))return{whole:r,start:n}},fL=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var Ex=()=>{let e=Ke(scrapbox.Page.lines),t=Ke(!1);return ee(()=>{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)}},[]),I(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var mL=jt("scrapbox-select-suggestion:useLifecycle.ts"),Tx=()=>{let[e,t]=Pr(kx,{type:"ready"}),r=Ex(),n=C(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:c,selection:l}=kt();t({type:a,lines:r(),range:l.getRange({normalizeOrder:!0}),position:c.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);ee(()=>{let i=()=>{n("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{n("selection:changed")},c=Gs();return c.addChangeListener(a),()=>{scrapbox.removeListener("lines:changed",i),scrapbox.removeListener("layout:changed",i),c.removeChangeListener(a)}},[]),ee(()=>{if(e.context!=="input")return;let i=()=>{n("cursor:changed")},a=Rr();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[o,s]=X(e);return o!==e&&(s(e),mL.debug("Detect changes",e)),{state:e,setEnable:I(i=>t({type:i?"enable":"disable"}),[]),cancel:I(()=>t({type:"cancel"}),[]),freezeUntil:I(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:I(async i=>{let a=r();if(!a)return;t({type:"lock"});let{cursor:c,selection:l}=kt(),p=c.getPosition().line,u=a[p].text,[f,d]=i(u,c.getPosition());l.setRange({start:{line:p,char:0},end:{line:p,char:[...u].length}}),await Xe(f),c.setPosition(d),c.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var Px=(e,t)=>{let r=e.dist-t.dist;if(r!==0)return r;let n=e.matches.map(([i])=>i).sort(),o=t.matches.map(([i])=>i).sort();for(let i=0;i<n.length;i++){let a=n[i]-(o[i]??o.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var Rx=e=>{let t=new Map,r=[...e].reverse();{let i=1;for(let a of r){t.set(a,(t.get(a)??0)|i);let c=a.toLowerCase();t.set(c,(t.get(c)??0)|i);let l=a.toUpperCase();t.set(l,(t.get(l)??0)|i),i<<=1}}let n=r.length,o=~(-1<<n),s=1<<n-1;return i=>{let a=0,c=o,l=[...i].reverse(),p=[],u=l.length;p[u]=n;for(let f of l){let d=t.get(f)??0,h=d|a,g=(d&c)+c^c|d,y=a|~(g|c),w=c&g;p[u-1]=p[u]+(y&s?1:w&s?-1:0),c=w<<1|~(h|y<<1),a=y<<1&h,u--}return p}};var hL=[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],Sx=e=>{let t=zb(e.trim()).split(/\s+/).sort((r,n)=>n.length-r.length);if(!(t.length===0||t.every(r=>r==="")))return r=>{let n=[...r];for(let o of t)n=gL(o,n);return n}},gL=(e,t)=>{let r=[...e].length,n=hL[r],o=Rx(e);return t.flatMap(({title:s,dist:i,matches:a,...c})=>{a??=[],i??=0;let l=o(s).flatMap((u,f)=>u<=n&&a.every(([d,h])=>f+r<=d||h<f)?[[f,u]]:[]);if(l.length===0)return[];let p=l.reduce((u,[f,d])=>(u.dist<=d||(u.dist=d,u.start=f),u),{dist:r,start:0});return a.push([p.start,p.start+r-1]),[{title:s,dist:p.dist+i,matches:a,...c}]})};var yL=jt("scrapbox-select-suggestion:cancelableSearch.ts");async function*_x(e,t,r){let n=Sx(e);if(!n)return;let o=r?.chunk??1e3,s=Math.floor(t.length/o)+1,i=0,a=new Date;try{for(;i<s;i++)await new Promise(c=>requestAnimationFrame(c)),yield[n(t.slice(i*o,(i+1)*o)),(i+1)/s]}finally{let l=new Date().getTime()-a.getTime();yL.debug(search ${(i/s*100).toPrecision(3)}% of the source for "${e}" in ${l}ms)}}var Lx=(e,t)=>{let r=t?.interval??0,n=t?.maxQueued??1/0,o,s=[],i=(...a)=>{if(!o)return o=(async()=>{do{await new Promise(f=>setTimeout(f,r));let u=s.pop();if(!u)break;u("delayed")}while(s.length>0);o=void 0})(),new Promise(u=>u(e.call(i,...a,"immediate")));for(;s.length>Math.max(n,0);)s.shift()("discarded");let{promise:c,resolve:l,reject:p}=Promise.withResolvers();return s.push(u=>{try{l(e.call(i,...a,u))}catch(f){p(f)}}),c};return Object.defineProperty(i,"ready",{get:()=>o}),i};var bn=e=>"query"in e,Cx=e=>(t,r)=>{if("query"in r){let i=bn(t)?t.query:"";if(r.query===i)return t;let a=bn(t)?t.job:void 0;if(!r.query)return a?.abort?.(),{source:t.source};let{run:c,abort:l}=e(r.query,t.source,!1),p=a?.abort?.()?.then?.(c)??c();return{query:r.query,source:t.source,job:{done:p,abort:()=>(l(),p)},progress:0,candidates:!i||!bn(t)?[]:t.candidates}}if("source"in r){if(!bn(t))return r.source===t.source?t:r;let{source:i,job:a,...c}=t;if(r.source===i)return t;let{run:l,abort:p}=e(c.query,r.source,!0),u=a.done.then(l);return{source:r.source,job:{done:u,abort:()=>a.abort().then(()=>(p(),u))},...c}}if(!bn(t))return t;if(!r.candidates){let{progress:i,...a}=t;return i===r.progress?t:{progress:r.progress,...a}}let{candidates:n,progress:o,...s}=t;return n===r.candidates&&o===r.progress?t:{candidates:r.candidates??n,progress:r.progress,...s}};var bL=jt("scrapbox-select-suggestion:useSearch.ts"),Ox=e=>{let t=I((o,s,i)=>{let a=!1,c=_x(o,s,{chunk:5e3});return{run:async()=>{if(i){let u=[];for await(let[f]of c){if(a)return;u.push(...f)}n({progress:1,candidates:u});return}let l=Lx((u,f)=>{f!=="discarded"&&(a||n(u))},{interval:500,maxQueued:0}),p=[];for await(let[u,f]of c){if(a)return;p=[...p,...u],n({progress:f}),u.length!==0&&l({progress:f,candidates:p})}l({progress:1,candidates:p})},abort:()=>a=!0}},[]),[r,n]=Pr(C(()=>Cx(t),[t]),{source:e});return[C(()=>{if(!bn(r))return;let[o,s]=xL(r.candidates);return bL.debug("Detect changes",{progress:r.progress,items:s}),{progress:r.progress,projectScore:o,items:s}},[r]),{search:I(o=>n({query:o}),[]),update:I(o=>n({source:o}),[])}]},xL=e=>{let t=new Map,r=[];for(let n of e.sort(Px)){let o=[...n.metadata.keys()];for(let s of o)t.set(s,(t.get(s)??0)+.5**n.dist);r.push({title:n.title,dist:n.dist,projects:o})}return[t,r]};var Nx=(e,t)=>{let r=Ke({...t});ee(()=>(Object.assign(r.current,t),()=>{for(let n of Object.keys(t))delete r.current[n]}),[...Object.keys(t)].sort().map(n=>t[n])),ee(()=>{e(r.current)},[e])};var wL={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},Mx=e=>{let t=bx(e.projects),[r,{update:n,search:o}]=Ox(t),{state:s,setEnable:i,...a}=Tx();n(t),o(s.type==="completion"?s.context==="input"?s.query.slice(1,-1):s.query:"");let[c,l]=X(),{callback:p,style:u,...f}=e;return Nx(p,{enable:I(()=>i(!0),[]),disable:I(()=>i(!1),[]),...s.type!=="completion"||!c?wL:c}),m(Y,{children:[m(wx,{}),m(xx,{style:u}),s.type==="completion"&&r&&m(ex,{callback:l,...r,...s,...a,...f})]})};var Ax=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let r=t.attachShadow({mode:"open"});document.body.append(t);let{limit:n=5,debug:o=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0}=e??{},c=new Set([...a?[scrapbox.Project.name]:[],...e?.projects??[scrapbox.Project.name]]);return tx(o),new Promise(l=>lt(m(Mx,{limit:n,projects:c,mark:s,style:i,callback:l,enableSelfProjectOnStart:a}),r))};var _t=e=>e.flatMap(t=>{let r=t.slice(1),n=Math.min(...r.map(o=>o.text.length-o.text.trimStart().length));return r.map(o=>o.text.slice(n))}).join(
).trim();function*Ix(e,t){for(let[r,n]of t.entries()){let o=e.get(r);if(o&&_t(o.blocks)===_t(n)){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 da={};En(da,{getTitle:()=>Ad,parse:()=>Ue});var Dx=e=>{let t=new Map;if(e.length===0)return t;let r=Ue(e.map(o=>o.text).join(
),{hasTitle:!0}),n=0;for(let o of r)switch(o.type){case"title":case"line":n++;break;case"table":n+=o.cells.length+1;break;case"codeBlock":{let s=t.get(o.fileName)??[],i=o.content.split(
).length+1;s.push(e.slice(n,n+i)),t.set(o.fileName,s),n+=i;break}}return t};var $x=e=>{let t,r,n=async()=>{for(;t;){let[o,s]=t;t=void 0;try{let i=await e(...o);s({type:"resolve",value:i})}catch(i){s({type:"reject",value:i})}}r=void 0};return(...o)=>{let{resolve:s,promise:i}=Promise.withResolvers();return t?.[1]?.({type:"cancel"}),t=[o,s],r??=n(),i}};var fa=class{constructor(t,r){this._filename=t;this._preview=$x(async(n,o,s)=>(this._dispose=await r(s?{filename:this.filename,before:n,after:o,render:(...i)=>{s.textContent="",s.append(...i)}}:{filename:this.filename,before:n}),!1))}get filename(){return this._filename}get blocks(){return this._blocks??[]}async update(t){if(await this._dispose?.(),!t||_t(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 n=this.makeArea(),o=t.at(0)?.at?.(-1)?.id,s=Vr(o);if(!s)throw new Error("div.lines#L${o}" could not be found.);s.insertAdjacentElement("afterend",n);let i=()=>{let a=s.getElementsByClassName("indent")[0];a instanceof HTMLElement&&(n.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,n)}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(n=>n.slice(1).map(({id:o})=>#L${o})),r=this.blocks.flatMap(n=>n.map(({id:o})=>#L${o}));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 jx=({previewers:e})=>{let t=new Map,r=()=>{let s=Dx(gt());for(let{changed:i,filename:a}of Ix(t,s)){if(!i)continue;let c=s.get(a),l=t.get(a);if(!l){if(!c)continue;let p=e.find(({when:u})=>u.test(a))?.preview;if(!p)continue;l=new fa(a,p),t.set(a,l)}l.update(c).then(p=>{switch(p.type){case"resolve":p.value&&t.delete(a);return;case"reject":throw p.value;case"cancel":return}})}},n=()=>{if(scrapbox.Layout!=="page"){scrapbox.off("lines:changed",r);return}r(),scrapbox.on("lines:changed",r)};n(),scrapbox.on("page:changed",n);let o=document.createElement("style");return o.textContent=".scrap-run{display:block;width:95%}",document.head.append(o),()=>{scrapbox.off("page:changed",n),o.remove()}};var Go=e=>{let t=new FileReader,r=new Promise(n=>t.onload=()=>n(t.result));return t.readAsDataURL(e),r};var Fx=async e=>{if(!("after"in e))return;let t=_t(e.after),n=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("parsererror");if(n){let i=document.createElement("pre"),a=document.createElement("code");a.innerText=n.innerHTML,i.append(a),e.render(i);return}let o=await Go(new Blob([t],{type:"image/svg+xml"})),s=document.createElement("img");s.src=o,e.render(s)};var Eu={};En(Eu,{default:()=>zx});var Ux=globalThis||(typeof window<"u"?window:self),XL=Object.create,ku=Object.defineProperty,JL=Object.getOwnPropertyDescriptor,QL=Object.getOwnPropertyNames,ZL=Object.getPrototypeOf,eC=Object.prototype.hasOwnProperty,tC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),rC=(e,t)=>{for(var r in t)ku(e,r,{get:t[r],enumerable:!0})},vu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of QL(t))!eC.call(e,o)&&o!==r&&ku(e,o,{get:()=>t[o],enumerable:!(n=JL(t,o))||n.enumerable});return e},nC=(e,t,r)=>(vu(e,t,"default"),r&&vu(r,t,"default")),Hx=(e,t,r)=>(r=e!=null?XL(ZL(e)):{},vu(t||!e||!e.__esModule?ku(r,"default",{value:e,enumerable:!0}):r,e)),Wx=tC((e,t)=>{var r;typeof window<"u"?r=window:typeof Ux<"u"?r=Ux:typeof self<"u"?r=self:r={},t.exports=r}),qx={};rC(qx,{default:()=>zx});var oC=Hx(Wx());nC(qx,Hx(Wx()));var{default:Bx,...sC}=oC,zx=Bx!==void 0?Bx:sC;var Ru={};En(Ru,{default:()=>Xx});var iC=Object.create,Pu=Object.defineProperty,aC=Object.getOwnPropertyDescriptor,cC=Object.getOwnPropertyNames,lC=Object.getPrototypeOf,uC=Object.prototype.hasOwnProperty,pC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),dC=(e,t)=>{for(var r in t)Pu(e,r,{get:t[r],enumerable:!0})},Tu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of cC(t))!uC.call(e,o)&&o!==r&&Pu(e,o,{get:()=>t[o],enumerable:!(n=aC(t,o))||n.enumerable});return e},fC=(e,t,r)=>(Tu(e,t,"default"),r&&Tu(r,t,"default")),Kx=(e,t,r)=>(r=e!=null?iC(lC(e)):{},Tu(t||!e||!e.__esModule?Pu(r,"default",{value:e,enumerable:!0}):r,e)),Yx=pC((e,t)=>{t.exports=n;var r=Object.prototype.toString;function n(o){if(!o)return!1;var s=r.call(o);return s==="[object Function]"||typeof o=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)}}),Vx={};dC(Vx,{default:()=>Xx});var mC=Kx(Yx());fC(Vx,Kx(Yx()));var{default:Gx,...hC}=mC,Xx=Gx!==void 0?Gx:hC;var Lu={};En(Lu,{default:()=>tw});var gC=Object.create,_u=Object.defineProperty,yC=Object.getOwnPropertyDescriptor,bC=Object.getOwnPropertyNames,xC=Object.getPrototypeOf,wC=Object.prototype.hasOwnProperty,vC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kC=(e,t)=>{for(var r in t)_u(e,r,{get:t[r],enumerable:!0})},Su=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of bC(t))!wC.call(e,o)&&o!==r&&_u(e,o,{get:()=>t[o],enumerable:!(n=yC(t,o))||n.enumerable});return e},EC=(e,t,r)=>(Su(e,t,"default"),r&&Su(r,t,"default")),Qx=(e,t,r)=>(r=e!=null?gC(xC(e)):{},Su(t||!e||!e.__esModule?_u(r,"default",{value:e,enumerable:!0}):r,e)),Zx=vC((e,t)=>{var r=function(o){return o.replace(/^\s+|\s+$/g,"")},n=function(o){return Object.prototype.toString.call(o)==="[object Array]"};t.exports=function(o){if(!o)return{};for(var s={},i=r(o).split( ),a=0;a<i.length;a++){var c=i[a],l=c.indexOf(":"),p=r(c.slice(0,l)).toLowerCase(),u=r(c.slice(l+1));typeof s[p]>"u"?s[p]=u:n(s[p])?s[p].push(u):s[p]=[s[p],u]}return s}}),ew={};kC(ew,{default:()=>tw});var TC=Qx(Zx());EC(ew,Qx(Zx()));var{default:Jx,...PC}=TC,tw=Jx!==void 0?Jx:PC;var Nu={};En(Nu,{default:()=>iw});var RC=Object.create,Ou=Object.defineProperty,SC=Object.getOwnPropertyDescriptor,_C=Object.getOwnPropertyNames,LC=Object.getPrototypeOf,CC=Object.prototype.hasOwnProperty,OC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),NC=(e,t)=>{for(var r in t)Ou(e,r,{get:t[r],enumerable:!0})},Cu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of _C(t))!CC.call(e,o)&&o!==r&&Ou(e,o,{get:()=>t[o],enumerable:!(n=SC(t,o))||n.enumerable});return e},MC=(e,t,r)=>(Cu(e,t,"default"),r&&Cu(r,t,"default")),nw=(e,t,r)=>(r=e!=null?RC(LC(e)):{},Cu(t||!e||!e.__esModule?Ou(r,"default",{value:e,enumerable:!0}):r,e)),ow=OC((e,t)=>{t.exports=n;var r=Object.prototype.hasOwnProperty;function n(){for(var o={},s=0;s<arguments.length;s++){var i=arguments[s];for(var a in i)r.call(i,a)&&(o[a]=i[a])}return o}}),sw={};NC(sw,{default:()=>iw});var AC=nw(ow());MC(sw,nw(ow()));var{default:rw,...IC}=AC,iw=rw!==void 0?rw:IC;var Zn=e=>{let t=n=>typeof n.default<"u"?n.default:n,r=n=>Object.assign({},n);switch(e){case"global/window":return t(Eu);case"is-function":return t(Ru);case"parse-headers":return t(Lu);case"xtend":return t(Nu);default:throw new Error('module "'+e+'" not found')}},DC=Object.create,Au=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,jC=Object.getOwnPropertyNames,FC=Object.getPrototypeOf,UC=Object.prototype.hasOwnProperty,ma=(e=>typeof Zn<"u"?Zn:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof Zn<"u"?Zn:t)[r]}):e)(function(e){if(typeof Zn<"u")return Zn.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),BC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),HC=(e,t)=>{for(var r in t)Au(e,r,{get:t[r],enumerable:!0})},Mu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of jC(t))!UC.call(e,o)&&o!==r&&Au(e,o,{get:()=>t[o],enumerable:!(n=$C(t,o))||n.enumerable});return e},WC=(e,t,r)=>(Mu(e,t,"default"),r&&Mu(r,t,"default")),cw=(e,t,r)=>(r=e!=null?DC(FC(e)):{},Mu(t||!e||!e.__esModule?Au(r,"default",{value:e,enumerable:!0}):r,e)),lw=BC((e,t)=>{"use strict";var r=ma("global/window"),n=ma("is-function"),o=ma("parse-headers"),s=ma("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(d){l[d==="delete"?"del":d]=function(h,g,y){return g=c(h,g,y),g.method=d.toUpperCase(),p(g)}});function i(d,h){for(var g=0;g<d.length;g++)h(d[g])}function a(d){for(var h in d)if(d.hasOwnProperty(h))return!1;return!0}function c(d,h,g){var y=d;return n(h)?(g=h,typeof d=="string"&&(y={uri:d})):y=s(h,{uri:d}),y.callback=g,y}function l(d,h,g){return h=c(d,h,g),p(h)}function p(d){if(typeof d.callback>"u")throw new Error("callback argument missing");var h=!1,g=function(M,j,A){h||(h=!0,d.callback(M,j,A))};function y(){b.readyState===4&&setTimeout(E,0)}function w(){var M=void 0;if(b.response?M=b.response:M=b.responseText||u(b),P)try{M=JSON.parse(M)}catch{}return M}function R(M){return clearTimeout(_),M instanceof Error||(M=new Error(""+(M||"Unknown XMLHttpRequest Error"))),M.statusCode=0,g(M,N)}function E(){if(!v){var M;clearTimeout(_),d.useXDR&&b.status===void 0?M=200:M=b.status===1223?204:b.status;var j=N,A=null;return M!==0?(j={body:w(),statusCode:M,method:O,headers:{},url:L,rawRequest:b},b.getAllResponseHeaders&&(j.headers=o(b.getAllResponseHeaders()))):A=new Error("Internal XMLHttpRequest Error"),g(A,j,j.body)}}var b=d.xhr||null;b||(d.cors||d.useXDR?b=new l.XDomainRequest:b=new l.XMLHttpRequest);var k,v,L=b.url=d.uri||d.url,O=b.method=d.method||"GET",$=d.body||d.data,S=b.headers=d.headers||{},T=!!d.sync,P=!1,_,N={body:void 0,headers:{},statusCode:0,method:O,url:L,rawRequest:b};if("json"in d&&d.json!==!1&&(P=!0,S.accept||S.Accept||(S.Accept="application/json"),O!=="GET"&&O!=="HEAD"&&(S["content-type"]||S["Content-Type"]||(S["Content-Type"]="application/json"),$=JSON.stringify(d.json===!0?$:d.json))),b.onreadystatechange=y,b.onload=E,b.onerror=R,b.onprogress=function(){},b.onabort=function(){v=!0},b.ontimeout=R,b.open(O,L,!T,d.username,d.password),T||(b.withCredentials=!!d.withCredentials),!T&&d.timeout>0&&(_=setTimeout(function(){if(!v){v=!0,b.abort("timeout");var M=new Error("XMLHttpRequest timeout");M.code="ETIMEDOUT",R(M)}},d.timeout)),b.setRequestHeader)for(k in S)S.hasOwnProperty(k)&&b.setRequestHeader(k,S[k]);else if(d.headers&&!a(d.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in d&&(b.responseType=d.responseType),"beforeSend"in d&&typeof d.beforeSend=="function"&&d.beforeSend(b),b.send($||null),b}function u(d){try{if(d.responseType==="document")return d.responseXML;var h=d.responseXML&&d.responseXML.documentElement.nodeName==="parsererror";if(d.responseType===""&&!h)return d.responseXML}catch{}return null}function f(){}}),uw={};HC(uw,{default:()=>ha});var qC=cw(lw());WC(uw,cw(lw()));var{default:aw,...zC}=qC,ha=aw!==void 0?aw:zC;var ga=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},ode=function(){function e(r){this.value=r}function t(r){var n,o;function s(c,l){return new Promise(function(p,u){var f={key:c,arg:l,resolve:p,reject:u,next:null};o?o=o.next=f:(n=o=f,i(c,l))})}function i(c,l){try{var p=r[c](l),u=p.value;u instanceof e?Promise.resolve(u.value).then(function(f){i("next",f)},function(f){i("throw",f)}):a(p.done?"return":"normal",p.value)}catch(f){a("throw",f)}}function a(c,l){switch(c){case"return":n.resolve({value:l,done:!0});break;case"throw":n.reject(l);break;default:n.resolve({value:l,done:!1});break}n=n.next,n?i(n.key,n.arg):o=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)}}}(),fw=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},mw=function(){function e(t,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),Iu=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)},Ko="";function GC(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 KC=
This page requires a browser that supports WebGL.<br/>
,YC=
It does not appear your computer can support WebGL.<br/>
,VC=1,XC=2;function JC(e,t,r){function n(i){var a=e.parentNode;a&&(a.innerHTML=GC(i))}function o(i,a){typeof r=="function"?r(i):n(a)}if(!window.WebGLRenderingContext)return o(VC,KC),null;var s=QC(e,t);return s?s.getExtension("OES_standard_derivatives"):o(XC,YC),s}function QC(e,t){for(var r=["webgl","experimental-webgl"],n=null,o=0;o<r.length;++o)try{n=e.getContext(r[o],t)}catch{if(n)break}return n}function eo(e,t,r,n){var o=e.gl,s=o.createShader(r);o.shaderSource(s,t),o.compileShader(s);var i=o.getShaderParameter(s,o.COMPILE_STATUS);return i?s:(Ko=o.getShaderInfoLog(s),console.error("*** Error compiling shader "+s+":"+Ko),e.trigger("error",{shader:s,source:t,type:r,error:Ko,offset:n||0}),o.deleteShader(s),null)}function pw(e,t,r,n){for(var o=e.gl,s=o.createProgram(),i=0;i<t.length;++i)o.attachShader(s,t[i]);if(r)for(var a=0;a<r.length;++a)o.bindAttribLocation(s,n?n[a]:a,r[a]);o.linkProgram(s);var c=o.getProgramParameter(s,o.LINK_STATUS);return c?s:(Ko=o.getProgramInfoLog(s),console.log("Error in program linking:"+Ko),o.deleteProgram(s),null)}function Du(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=[];for(var n in e){var o=e[n],s=void 0;if(t&&(n=t+"."+n),typeof o=="number")r.push({type:"float",method:"1f",name:n,value:o});else if(Array.isArray(o)){if(typeof o[0]=="number")o.length===1?r.push({type:"float",method:"1f",name:n,value:o}):o.length>=2&&o.length<=4?r.push({type:"vec"+o.length,method:o.length+"fv",name:n,value:o}):o.length>4&&r.push({type:"float[]",method:"1fv",name:n+"[0]",value:o});else if(typeof o[0]=="string")r.push({type:"sampler2D",method:"1i",name:n,value:o});else if(Array.isArray(o[0])&&typeof o[0][0]=="number"){if(o[0].length>=2&&o[0].length<=4)for(s=0;s<o.length;s++)r.push({type:"vec"+o[0].length,method:o[s].length+"fv",name:n+"["+s+"]",value:o[s]})}else if(ga(o[0])==="object")for(s=0;s<o.length;s++)r.push.apply(r,Iu(Du(o[s],n+"["+s+"]")))}else typeof o=="boolean"?r.push({type:"bool",method:"1i",name:n,value:o}):typeof o=="string"?r.push({type:"sampler2D",method:"1i",name:n,value:o}):(typeof o>"u"?"undefined":ga(o))==="object"&&r.push.apply(r,Iu(Du(o,n)))}return r}function ZC(e){var t=e.getBoundingClientRect();return t.top+t.height>0&&t.top<(window.innerHeight||document.documentElement.clientHeight)}function dw(e){return(e&e-1)===0}function eO(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function tO(e,t){return e&&t?e.toString()!==t.toString():!1}function rO(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,n){var o={};o[r]=n,t.add(o)},off:function(r,n){if(n){var o={};o[r]=n,t.delete(o)}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 p=l.value,u=!0,f=!1,d=void 0;try{for(var h=Object.keys(p)[Symbol.iterator](),g;!(u=(g=h.next()).done);u=!0){var y=g.value;if(y===r){t.delete(p);return}}}catch(w){f=!0,d=w}finally{try{!u&&h.return&&h.return()}finally{if(f)throw d}}}}catch(w){i=!0,a=w}finally{try{!s&&c.return&&c.return()}finally{if(i)throw a}}}},listSubscriptions:function(){var r=!0,n=!1,o=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){n=!0,o=c}finally{try{!r&&s.return&&s.return()}finally{if(n)throw o}}},subscribe:function(r){t.add(r)},unsubscribe:function(r){t.delete(r)},unsubscribeAll:function(){t.clear()},trigger:function(r){for(var n=arguments.length,o=Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];var i=!0,a=!1,c=void 0;try{for(var l=t[Symbol.iterator](),p;!(i=(p=l.next()).done);i=!0){var u=p.value;typeof u[r]=="function"&&u[r].apply(u,Iu(o))}}catch(f){a=!0,c=f}finally{try{!i&&l.return&&l.return()}finally{if(a)throw c}}}})}var $u=function(){function e(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};fw(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(n.filtering),this.load(n)}return mw(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,n=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(o,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),n.filtering="nearest"):c=new Image,c.onload=function(){try{r.setElement(c,n)}catch(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,n)}o(r)},c.onerror=function(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,n),o(r)},eO()&&r.source.slice(0,5)==="data:"||(c.crossOrigin="anonymous"),c.src=r.source,a&&r.setElement(c,n)}),this.loading}},{key:"setData",value:function(t,r,n){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.width=t,this.height=r,this.source=n,this.sourceType="data",this.update(o),this.setFiltering(o),this.loading=Promise.resolve(this),this.loading}},{key:"setElement",value:function(t,r){var n=this,o=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(){n.intervalID=setInterval(function(){n.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(o)+") 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=dw(this.width)&&dw(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}();$u.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)};$u.activeUnit=-1;var gw=function(){function e(t,r,n){var o=this;fw(this,e),hw(this),r=r||{},n=n||{},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||
precision mediump float;
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||
precision mediump float;
varying vec2 v_texcoord;
void main(){
gl_FragColor = vec4(0.0);
}
;var s=JC(t,r,n.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");ha.get(i,function(g,y,w){o.load(w,o.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");ha.get(a,function(g,y,w){o.load(o.fragmentString,w)})}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 p=t.getAttribute("data-textures").split(",");for(var u in p)this.setUniform("u_tex"+u,p[u])}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 d=this;function h(){d.nMouse>1&&d.setMouse(f),d.resize()&&(d.forceRender=!0),d.render(),d.animationFrameRequest=window.requestAnimationFrame(h)}return this.setMouse({x:0,y:0}),h(),this}return mw(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 n in this.buffers){var o=this.buffers[n];this.gl.deleteProgram(o.program)}this.program=null,this.gl=null}},{key:"load",value:function(t,r){var n=this;r&&(this.vertexString=r),t&&(this.fragmentString=t);var o=this.fragmentString.split(/\r?\n/);this.fragmentString=#define PLATFORM_WEBGL ,o.forEach(function(g,y){var w=g.trim();if(w.startsWith('#include "lygia')){var R=w.substring(15).replace(/\'|\"|\;|\s/g,"");if(R.endsWith("glsl")){if(n.deps[R]===void 0){var E="https://lygia.xyz"+R;n.deps[R]=rO(E)}n.fragmentString+=n.deps[R]+
}}else n.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 p=i[a].match(/\s*void\s*main\s*/g);if(p)break}var u=eo(this,this.vertexString,this.gl.VERTEX_SHADER),f=eo(this,this.fragmentString,this.gl.FRAGMENT_SHADER);f?this.isValid=!0:(f=eo(this,void main(){
gl_FragColor = vec4(1.0);
},this.gl.FRAGMENT_SHADER),this.isValid=!1);var d=pw(this,[u,f]);this.gl.useProgram(d),this.gl.deleteShader(u),this.gl.deleteShader(f),this.program=d,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,n){var o=this.vertexString,s=this.fragmentString,i=this.paused,a=this.gl.getExtension("EXT_disjoint_timer_query"),c=a.createQueryEXT(),l=this.isValid;(r||n)&&(this.load(r,n),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 p=this;function u(){p.paused=i,(r||n)&&p.load(s,o)}function f(){p.forceRender=!0,p.render();var d=a.getQueryObjectEXT(c,a.QUERY_RESULT_AVAILABLE_EXT),h=p.gl.getParameter(a.GPU_DISJOINT_EXT);if(d&&!h){var g={wasValid:l,frag:r||p.fragmentString,vert:n||p.vertexString,timeElapsedMs:a.getQueryObjectEXT(c,a.QUERY_RESULT_EXT)/1e6};u(),t(g)}else window.requestAnimationFrame(f)}f()}},{key:"loadTexture",value:function(t,r,n){var o=this;n||(n={}),typeof r=="string"?n.url=r:(typeof r>"u"?"undefined":ga(r))==="object"&&r.data&&r.width&&r.height?(n.data=r.data,n.width=r.width,n.height=r.height):(typeof r>"u"?"undefined":ga(r))==="object"&&(n.element=r),this.textures[t]?this.textures[t]&&(this.textures[t].load(n),this.textures[t].on("loaded",function(s){o.forceRender=!0})):(this.textures[t]=new $u(this.gl,t,n),this.textures[t].on("loaded",function(s){o.forceRender=!0}))}},{key:"refreshUniforms",value:function(){this.uniforms={}}},{key:"setUniform",value:function(t){for(var r={},n=arguments.length,o=Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];r[t]=o,this.setUniforms(r)}},{key:"setUniforms",value:function(t){var r=Du(t);for(var n in r)r[n].type==="sampler2D"?this.loadTexture(r[n].name,r[n].value[0]):this.uniform(r[n].method,r[n].type,r[n].name,r[n].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 n=(t.x-r.left)*this.realToCSSPixels,o=this.canvas.height-(t.y-r.top)*this.realToCSSPixels;this.uniform("2f","vec2","u_mouse",n,o)}}},{key:"uniform",value:function(t,r,n){this.uniforms[n]=this.uniforms[n]||{};for(var o=this.uniforms[n],s=arguments.length,i=Array(s>3?s-3:0),a=3;a<s;a++)i[a-3]=arguments[a];var c=tO(o.value,i);if(c||this.change||!o.location||!o.value){o.name=n,o.type=r,o.value=i,o.method="uniform"+t,this.gl.useProgram(this.program),o.location=this.gl.getUniformLocation(this.program,n),this.gl[o.method].apply(this.gl,[o.location].concat(o.value));for(var l in this.buffers){var p=this.buffers[l];this.gl.useProgram(p.program);var u=this.gl.getUniformLocation(p.program,n);this.gl[o.method].apply(this.gl,[u].concat(o.value))}}}},{key:"uniformTexture",value:function(t,r,n){if(this.textures[t]===void 0)this.loadTexture(t,r,n);else{this.uniform("1i","sampler2D",t,this.texureIndex);for(var o in this.buffers){var s=this.buffers[o];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=ZC(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 n in this.buffers){var o=this.buffers[n];this.uniform("1i","sampler2D",o.name,o.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,n=t.canvas.height;t.viewport(0,0,r,n);for(var o in this.buffers){var s=this.buffers[o];s.bundle.render(r,n,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 n=arguments[3]||arguments[4];r["u_buffer"+n]={fragment:"#define BUFFER_"+n+
+t}}),r}},{key:"loadPrograms",value:function(t){var r=this,n=this.gl,o=eo(r,r.vertexString,n.VERTEX_SHADER);for(var s in t){var i=t[s],a=eo(r,i.fragment,n.FRAGMENT_SHADER,1);a?r.isValid=!0:(a=eo(r,void main(){
gl_FragColor = vec4(1.0);
},n.FRAGMENT_SHADER),r.isValid=!1);var c=pw(r,[o,a]);i.name=s,i.program=c,i.bundle=r.createSwappableBuffer(r.canvas.width,r.canvas.height,c),n.deleteShader(a)}n.deleteShader(o)}},{key:"createSwappableBuffer",value:function(t,r,n){var o=this.createBuffer(t,r,n),s=this.createBuffer(t,r,n),i=this.gl;return{input:o,output:s,swap:function(){var a=o;o=s,s=a,this.input=o,this.output=s},render:function(a,c,l,p){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,p){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,n){var o=this.gl,s=this.BUFFER_COUNT;this.BUFFER_COUNT+=2,o.getExtension("OES_texture_float");var i=o.createTexture();o.activeTexture(o.TEXTURE0+s),o.bindTexture(o.TEXTURE_2D,i),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,t,r,0,o.RGBA,o.FLOAT,null),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);var a=o.createFramebuffer();return{index:s,texture:i,buffer:a,W:t,H:r,resize:function(c,l){o.bindFramebuffer(o.FRAMEBUFFER,a);var p=Math.min(c,this.W),u=Math.min(l,this.H),f=new Float32Array(p*u*4);o.readPixels(0,0,p,u,o.RGBA,o.FLOAT,f),o.bindFramebuffer(o.FRAMEBUFFER,null);var d=s+1,h=o.createTexture();o.activeTexture(o.TEXTURE0+d),o.bindTexture(o.TEXTURE_2D,h),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,c,l,0,o.RGBA,o.FLOAT,null),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,p,u,o.RGBA,o.FLOAT,f);var g=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,null),o.deleteTexture(i),o.activeTexture(o.TEXTURE0+s),o.bindTexture(o.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,n=t.canvas.height;t.viewport(0,0,r,n);for(var o in this.buffers){var s=this.buffers[o];s.bundle.resize(r,n,s.program,s.name)}t.useProgram(this.program)}},{key:"version",value:function(){return"0.1.7"}}]),e}();function nO(){var e=document.getElementsByClassName("glslCanvas");if(e.length>0){window.glslCanvases=[];for(var t=0;t<e.length;t++){var r=new gw(e[t]);r.isValid&&window.glslCanvases.push(r)}}}window.addEventListener("load",function(){nO()});var ya=gw;var yw=e=>{if(!("after"in e))return Promise.resolve(void 0);let t=document.createElement("canvas");return new ya(t).load(_t(e.after)),e.render(t),Promise.resolve(void 0)};var bw=e=>{let t="";for(let r=0;r<e.length;r+=3)r+2===e.length?t+=ju(e[r],e[r+1],0):r+1===e.length?t+=ju(e[r],0,0):t+=ju(e[r],e[r+1],e[r+2]);return t},ba=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?"_":"?"))),ju=(e,t,r)=>{let n=e>>2,o=(e&3)<<4|t>>4,s=(t&15)<<2|r>>6,i=r&63;return ba(n&63)+ba(o&63)+ba(s&63)+ba(i&63)};var xw=async(e,t="svg")=>{let r=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream("deflate")),n=new Uint8Array(await new Response(r).arrayBuffer());returnhttps://www.plantuml.com/plantuml/${t}/~1${bw(n)}};var ww=async e=>{if(!("after"in e))return;let t=document.createElement("img"),r=await xw(_t(e.after));t.src=r,e.render(t)};var Fu=Promise.resolve({log:new Uint8Array(0)}),xa,vw=(e,t,r,n)=>(Fu=(async()=>{await Fu,xa??=await oO(t,r);let o=new Promise(i=>{let a=c=>{if(c.data.type==="stdout"){n(c.data.message);return}c.data.type==="compile"&&(i(c.data),xa.removeEventListener("message",a))};xa.addEventListener("message",a)}),s={type:"compile",input:e};return xa.postMessage(s),o})(),Fu),oO=async(e,t)=>{let r=new Worker(e,{type:"module"}),n=new Promise(s=>{let i=a=>{a.data.type==="asset-url"&&(s(),r.removeEventListener("message",i))};r.addEventListener("message",i)}),o={type:"asset-url",url:${t}};return r.postMessage(o),await n,r};var kw=(e,t)=>async r=>{if(!("after"in r))return;let n=sO(),o="Compile is not started yet. Please wait...",s=l=>{o=[...o.split( ),l].join(
),n.log(o)},i=document.createElement("img"),a=setTimeout(()=>{r.render(n.div),n.log(o)},2e3),{svg:c}=await vw(_t(r.after),e,t,s);if(clearTimeout(a),!c){r.render(n.div),n.log(o);return}i.src=await Go(new Blob([c],{type:"image/svg+xml"})),r.render(i)},sO=()=>{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 n=document.createElement("pre"),o=document.createElement("code");return n.append(o),t.append(n),{div:e,log:s=>{o.textContent=s,n.scroll(0,n.scrollHeight)}}};var xn=()=>/mobile/i.test(navigator.userAgent);var Ew="Cannot complete the mapping as an error was thrown from an item";function Uu(e,t,r){let n=new TransformStream({async transform(o,s){try{let i=await o;s.enqueue(i)}catch(i){i instanceof AggregateError&&i.message===Ew&&s.error(i)}}});return(async()=>{let o=n.writable.getWriter(),s=[];try{for await(let i of t){let a=Promise.resolve().then(()=>r(i));o.write(a);let c=a.then(()=>s.splice(s.indexOf(c),1));s.push(c),s.length>=e&&await Promise.race(s)}await Promise.all(s),o.close()}catch{let i=[];for(let a of await Promise.allSettled(s))a.status==="rejected"&&i.push(a.reason);o.write(Promise.reject(new AggregateError(i,Ew))).catch(()=>{})}})(),Symbol.asyncIterator in n.readable&&typeof n.readable[Symbol.asyncIterator]=="function"?n.readable[Symbol.asyncIterator]():async function*(){let o=n.readable.getReader();for(;;){let{done:s,value:i}=await o.read();if(s)break;yield i}o.releaseLock()}()}async function*Tw(e,t){if(e.length===0||e.every(({before:n,after:o})=>n===o))return;let r=Xr(await ot());try{let{readable:n,writable:o}=new TransformStream(void 0),s=o.getWriter(),i=Uu(5,e,async l=>{let p=0,u=0;l.before===l.after&&(await s.ready,await s.write({link:l,projectCount:0,replaced:0,done:!0}));let f=Uu(2,new Set(t),async d=>{let h=await iO(l,d,r);if(vo(h))throw aO(pm(h));p++,u+=Xr(h),await s.ready,await s.write({link:l,projectCount:p,replaced:u,done:!1})});await Array.fromAsync(f),await s.ready,await s.write({link:l,projectCount:p,replaced:u,done:!0})}),a=Array.fromAsync(i).then(async()=>{await s.ready,await s.close()}),c=n.getReader();for(;;){let{done:l,value:p}=await c.read();if(l)return;yield p}await a}finally{await at(r)}}var iO=async(e,t,r)=>{let[n]=await Promise.all([Ts(t,e.before,e.after),we(t,e.before,(o,{persistent:s})=>{if(s)return[e.after,...o.map(i=>i.text).slice(1)]},{socket:r})]);return n},wr=e=>e.split(
).flatMap(t=>[...t.matchAll(/\[((?:[^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~] |.[^ ]*)[^\[\]]*)\]/g)]).map(([,t])=>t),aO=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var Pw=e=>Ue(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return cO(r);case"table":return lO(r);case"line":return uO(r)}}).map(r=>r).join(
),cO=({fileName:e,content:t,indent:r})=>{let n=" ".repeat(r);return[${n}code:${e},...t.split(
).map(o=>${n} ${o})]},lO=({fileName:e,cells:t,indent:r})=>{let n=" ".repeat(r);return[${n}table:${e},...t.map(o=>${n} ${o.map(s=>s.map(i=>Yo(i)).join("")).join(" ")})]},uO=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${Yo(r)}).join("")}],Yo=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Yo(t)).join("")};case"strong":return${e.nodes.map(t=>Yo(t)).join("")};case"decoration":{let t=e.decos.map(r=>{let n=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return n>0?"*".repeat(n):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>Yo(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=>wr(e).length>0?"":"",onClick:e=>{let t=Pw(e);if(e!=t)return t}});var Rw=e=>!e.includes(
)&&/\[[^\]]+\]/.test(e);scrapbox.PopupMenu.addButton({title:e=>Rw(e)?"[][]":"",onClick:e=>{if(!Rw(e))return;let t=e.replaceAll("[","").replaceAll("]","");return(async()=>{let{render:r,dispose:n}=_e();try{let o=scrapbox.Project.name;r({type:"spinner"},{type:"text",text:create /${o}/${t}}),await we(o,t,([{text:s}],{persistent:i})=>{if(!i)return[s,e]}),r({type:"check-circle"},{type:"text",text:create /${o}/${t}})}catch(o){if(console.error(o),!(o instanceof Error))throw o;r({type:"exclamation-triangle"},{type:"text",text:${o.name} ${o.message}})}finally{await Pe(2e3),n()}})(),${t}}});var _w=(e,t)=>{switch(e.type){case"title":return"";case"codeBlock":return[e.fileName, \\`\`${yO(e.fileName)},e.content,"\n"].join(
);case"table":return pO(e);case"line":return fO(e,t)}},pO=e=>{let t=[e.fileName],r=Math.max(...e.cells.map(n=>n.length));return e.cells.forEach((n,o)=>{t.push(| ${n.map(s=>s.map(i=>to(i)).join("")).join(" | ")} |),o===0&&t.push(|${" -- |".repeat(r)})}),t.join(
)},dO=" ",fO=(e,t)=>{let r=e.nodes.map(o=>to(o,{section:e.indent===t})).join("").trim();if(r==="")return"";if(e.indent===t)return r;let n=dO.repeat(e.indent-t-1);return/^\d+\. /.test(r)||(n+="- "),n+r},to=(e,t)=>{let{section:r=!1}=t??{};switch(e.type){case"quote":return> ${e.nodes.map(n=>to(n)).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(n=>to(n)).join("")}**;case"formula":return$${e.formula}$;case"decoration":{let n=e.nodes.map(o=>to(o)).join("");return e.decos.includes("/")&&(n=*${n}*),r?(e.decos.includes("*-3")&&(n=`# ${n} ),e.decos.includes("*-2")&&(n=## ${n}
),e.decos.includes("*-1")&&(n=### ${n}
)):e.decos.some(o=>/\*-/.test(o[0]))&&(n=**${n}**),e.decos.includes("~")&&(n=~~${n}~~),n}case"code":return\${e.text}\`;case"commandLine":return\`${e.symbol} ${e.text}\`;case"link":switch(e.pathType){case"root":{let,n,...o=e.href.split("/");return[${e.href}](https://scrapbox.io/${n}/${Sw(o.join("/"))})}case"relative":return[${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${Sw(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(n=>to(n)).join("")};case"blank":case"plain":return e.text}},Sw=e=>...e.map((t,r)=>t===" "?"_":!mO.includes(t)||r===e.length-1&&hO.includes(t)?encodeURIComponent(t):t).join(""),mO='@$&+=:;",',hO=':;",',gO=[{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"}],yO=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return gO.find(r=>r.extensions.includes(t))?.fileType??""};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{(async()=>{try{let t=da.parse(e,{hasTitle:!1}),r=Math.min(...t.map(n=>n.indent));await navigator.clipboard.writeText(t.map(n=>_w(n,r)).join(` ))}catch(t){alert(Failed to copy:
${JSON.stringify(t)})}})()}});var Bu=(e,...t)=>{let r=t.reduce((n,o)=>Ge(n)?n:n instanceof Promise?n.then(s=>Ge(s)?s:o(s)):o(n),e);return r instanceof Promise?r.then(n=>${n}):${e}};var ro=e=>e.ok?be(e):Z({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Lw=e=>window.GM_fetch?.(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x)?.then?.(t=>Ot(ro(t),r=>r.json()));var wa=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}},Cw=e=>typeof e=="object"&&e!==null;var Vo=class e extends Error{name="UnexpectedResponseError";status;statusText;body;path;constructor(t){super(${t.status} ${t.statusText} when fetching ${t.path.toString()}),this.status=t.status,this.statusText=t.statusText,this.body=t.body,this.path=t.path,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};var va=async e=>{let t=await e.text();if(e.ok)return be(t);if(e.status===400)return Z({name:"BadRequestError",message:t});try{let r=JSON.parse(t);if(!Cw(r)||typeof r.message!="string")throw new Vo({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)});switch(e.status){case 401:return Z({name:"UnauthorizedError",message:r.message});case 403:return Z({name:"NotPrivilegeError",message:r.message});case 404:return Z({name:"NotFoundError",message:r.message});case 422:return Z({name:"InvalidParameterError",message:r.message});case 429:return Z({name:"RateLimitError",message:r.message});default:throw new Vo({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)})}}catch(r){throw r instanceof SyntaxError?new Vo({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)}):r}};var Ow=async(e,t)=>{let{title:r,description:n,metadataIsPublic:o,collectionId:s,refererURL:i,accessToken:a,created:c,app:l,fetch:p}=wa(t),u=new FormData;u.append("imagedata",e),u.append("access_token",a),i&&u.append("referer_url",i.toString()),l!==void 0&&u.append("app",l),r!==void 0&&u.append("title",r),n!=null&&u.append("desc",n),s&&u.append("collection_id",s),o&&u.append("metadata_is_public","true"),c!==void 0&&u.append("created_at",${c});let f=await p("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:u}),d=await va(f);return G(d)?d:be(JSON.parse(B(d)))};var Nw=(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 ka="",Mw=!1,Ea=new Map,Aw=async(e,t,r,n)=>{let o=Ea.get(e.href);if(o)return o;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let c=await GM_fetch(e);if(!c.ok)return;let l=c.headers.get("content-type")?.split?.(";")?.[0]??${e}.endsWith(".mp4")?"video/mp4":"video/webm",p=new File([await c.blob()],n||${t},{type:l});if(l==="video/mp4"){let d=await Nw(p);if(d.ok){let h=new URL(await d.text());return Ea.set(e.href,h),h}}let u=await rf(p,r);if(G(u))throw Error(ne(u).name);let f=new URL(B(u).embedUrl);return Ea.set(e.href,f),f}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Mw){if(!ka)return}else{let c=await Kd();if(Mw=!0,G(c)){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(ka=B(c)||"",!ka){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let s=await GM_fetch(e);if(!s.ok)return;let i=await Ow(await s.blob(),{accessToken:ka,refererURL:t,description:n});if(G(i))throw Error(ne(i).name);let a=new URL(B(i).permalink_url);return Ea.set(e.href,a),a};var $w=[["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]],bO=Object.fromEntries([...$w.map(([e,t])=>[t,e]),["'","'"],[" "," "]]),xO=new Map($w),pme=new RegExp([${...xO.keys().join("")}],"g");var wO={entityList:bO},vO=1114111,kO=/&#([0-9]+);/g,EO=/&#x(\p{AHex}+);/gu,Iw=new WeakMap;function Hu(e,t={}){let{entityList:r}={...wO,...t},n=Iw.get(r);return n||(n=new RegExp((${Object.keys(r).sort((o,s)=>s.length-o.length).join("|")}),"g"),Iw.set(r,n)),e.replaceAll(n,o=>r[o]).replaceAll(kO,(o,s)=>Dw(s,10)).replaceAll(EO,(o,s)=>Dw(s,16))}function Dw(e,t){let r=parseInt(e,t);return r>vO?"�":String.fromCodePoint(r)}var Ta=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),n=[...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,p="STRING";c?.type===p&&(a.description=c.string_value),l?.type===p&&(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]),o=[];{let i=0,a=e.text;for(let{indices:c,...l}of n){let p=[...a].slice(0,c[0]-i).join("");o.push({type:"plain",text:Hu(p)}),o.push(l),a=[...a].slice(c[1]-i).join(""),i=c[1]}a&&o.push({type:"plain",text:Hu(a)})}let s={id:e.id_str,content:o,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=Ta(e.parent)),e.quoted_tweet&&(s.quote=Ta(e.quoted_tweet)),s};var TO=["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"],Pa=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,n,o]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!n||TO.includes(n)?r:o?n===e?${decodeURIComponent(o)}:/${n}/${decodeURIComponent(o)}:/${n}};var jw=(e=PO)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:(?:www\.|mobile\.|m\.)?twitter|x)\.com\/[\w\d_]+\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let n=await(Lw(r)??Gd(t.href));if(G(n))throw ne(n);let o=B(n);return e("images"in o?{...o,id:r}:o,t)})():t},PO=async e=>{if("images"in e)return Xo(e);let{quote:t,replyTo:r,...n}=Ta(e);return[...r?[...(await Xo(r)).split( ).map(o=> > ${o}),...r.quote?(await Xo(r.quote)).split(
).map(o=> > ${o}):[]]:[],...(await Xo(n)).split(
).map(o=>> ${o}),...t?(await Xo(t)).split(
).map(o=>> > ${o}):[]].join(
)?.map?.(o=>> ${qu(o)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(o=>[${o}])}]:[]].join(
);let r=e.content,n=e.author.screenName;return[@${qu(n)} ${t},...(await Promise.all(r.map(async o=>{switch(o.type){case"plain":return o.text;case"hashtag":return #${o.text} ;case"symbol":return #$${o.text} ;case"mention":return@${o.screenName};case"media":{let s=[],i=1;for(;i<o.media.length;i+=2)s.push([${await Wu(o.mediai-1,t)}] [${await Wu(o.mediai,t)}]);return i===o.media.length&&s.push([${await Wu(o.mediai-1,t)}]), ${s.join(`
`)}
}case"url":return${Pa()(o.url)} }}))).join("").split(
)].join(
)},Ra="",RO=async()=>{if(Ra)return Ra;let e=await ar(scrapbox.Project.name);if(G(e))throw new Error(ne(e).name);return Ra=B(e).id,Ra},Wu=async(e,t)=>await Aw(e.url,t,await RO(),"")??e.url,qu=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Fw=e=>window.GM_fetch?.(https://t.co/${e})?.then?.(t=>Ot(ro(t),async r=>{let n=new DOMParser().parseFromString(await r.text(),"text/html");try{return new URL(n.title)}catch(o){if(o instanceof TypeError)return;throw o}}));var Uw=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(n=>n.ok?new URL(n.url):e);if(e.hostname!=="t.co")return e;let r=Fw(e.pathname.slice(1));return r?r.then(n=>cf(n,()=>e,o=>o??e)):e};var Bw=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,o=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!o)return e;e.hostname=${o}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",n=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${n}#${r}]:[${t} - Wikipedia ${n}]};var Hw=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 zu=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var Ww=/charset=(^;+)/,qw=e=>window.GM_fetch?.(${e})?.then?.(t=>Ot(ro(t),async r=>{let n=r.headers.get("content-type")?.match?.(Ww)?.1??await SO(r.clone());return new TextDecoder(n).decode(await r.arrayBuffer())})),SO=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?.(Ww)?.1??"utf-8"};var zw=(e=_O)=>async t=>e(await LO(t),t),_O=(e,t)=>{let r=(Ge(e)?e:e.title).replace(/\s/g," ").replaceAll("","[").replaceAll("","]");return r?[${t.hash?${decodeURIComponent(t.hash.slice(1))} | :""}${r} ${t}]:${t}},LO=async e=>{let t=qw(e);if(!t){let n=await zd(e);if(G(n))throw ne(n);return B(n)}let r=await t;if(G(r))throw ne(r);return new DOMParser().parseFromString(B(r),"text/html")};var Gw=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 Kw=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 Yw=(e,...t)=>{if(e instanceof URL)return Bu(new URL(e),...t);let r=0,n=0,o=0,s=!1,i=e.split(/(https?:\/\/\S+)/g).map(p=>{if(!/^https?:\/\/\S+$/.test(p))return p;r++;try{let u=Bu(new URL(p),...t);return Ge(u)?(n++,u):(s=!0,u,p)}catch(u){return console.error(u),o++,p}});if(!s)return i.join("");let{render:a,dispose:c}=_e(),l=()=>a({type:"spinner"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed});return l(),Promise.all(i.map(async p=>{if(Ge(p))return p;try{let u=await p0;return n++,u}catch(u){return console.error(u),o++,p1}finally{l()}})).then(p=>(a({type:"check-circle"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed}),p.join(""))).finally(()=>{setTimeout(c,1e3)})};var Vw=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 Xw=e=>Ue(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return CO(r);case"table":return OO(r);case"line":return NO(r)}}).map(r=>r).join(` ),CO=({fileName:e,content:t,indent:r})=>{let n=" ".repeat(r);return[${n}code:${e},...t.split(
).map(o=>${n} ${o})]},OO=({fileName:e,cells:t,indent:r})=>{let n=" ".repeat(r);return[${n}table:${e},...t.map(o=>${n} ${o.map(s=>s.map(i=>i.raw).join("")).join(" ")})]},NO=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${Jo(r)}).join("")}],Jo=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Jo(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=>Jo(t)).join("")};case"decoration":{e.decos.includes("-")||e.decos.push("-");let t=e.decos.map(r=>{let n=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return n>0?"*".repeat(n):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>Jo(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=>Jo(t)).join("")};case"blank":case"plain":return${e.text}}};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=Xw(e);if(e!==t)return t}});var Gu=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 n=e.slice(t+2).split(
);if(n.length===0)return;for(let[s,i]of r){let a=s.match(/^\/(.*?)\/([gimy]*)$/);if(a){let c=new RegExp(a[1],a[2]);n=n.map(l=>l.replace(c,i.replaceAll("\\n",
)))}else n=n.map(c=>c.replaceAll(s,i.replaceAll("\\n",
)))}let o=${e.slice(0,t+2)}${n.join(`
)};if(e!==o)return o};scrapbox.PopupMenu.addButton({title:e=>Gu(e)?"replace":"",onClick:e=>{let t=Gu(e);if(t!==void 0)return t}});var Jw=e=>{let t=document.createElement("div"),r=t.attachShadow({mode:"open"}),n=document.createElement("style");n.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(n);let o=document.createElement("dialog");o.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(o);let s=o.querySelector(".editor");s.rows=e.length,s.value=e.join(
);let i=()=>{o.style.minWidth=${Math.max(...s.value.split(`
).map(p=>[...p].length))+6}em};i(),s.addEventListener("input",i);let a=o.querySelector(".cancel"),c=o.querySelector(".replace"),l=new Promise(p=>{let u=()=>{p({convert:!1}),t.remove()};o.addEventListener("close",u),o.addEventListener("click",u),a.addEventListener("click",u),c.addEventListener("click",()=>{let f=s.value.split(`
);p({convert:!0,links:e.flatMap((d,h)=>d===f[h]||d===""||!f[h]?[]:[{before:d,after:f[h]??d}])}),t.remove()}),o.querySelector(".container").addEventListener("click",f=>{f.stopPropagation()})});return document.body.append(t),o.showModal(),l};var Qw=async(e,t)=>{let r=wr(e),n=await Jw([...new Set(r)]);if(!n.convert||n.links.length===0)return;let o=new Map(n.links.map(s=>[s.before,_e()]));for await(let{link:s,projectCount:i,replaced:a,done:c}of Tw(n.links,t)){let l=o.get(s.before);if(!l)return;if(c){l.render({type:"check-circle"},{type:"text",text:"${s.after}", ${a}l. ${i}p.}),setTimeout(()=>l.dispose(),1e3);return}l.render({type:"spinner"},{type:"text",text:"${s.after}", ${a}l. ${i}p.})}};var Zw=async(e,t)=>{let r=wr(e)[0];if(!r)return;let n=window.prompt(Replace "${r}" to this in ${t.map(a=>"/${a}").join(", ")},r)?.replace?.(/[\[\]\n]/g," ")??"";if(n==="")return;let{render:o,dispose:s}=_e(),i=B(await ot());try{o({type:"spinner"},{type:"text",text:Replacing links in ${t.length} projects...});let a=0,l=(await Promise.all(t.map(async p=>{let[u]=await Promise.all([Ts(p,r,n),we(p,r,(f,{persistent:d})=>{if(d)return[n,...f.map(h=>h.text).slice(1)]},{socket:i})]);if(G(u))throw o({type:"exclamation-triangle"},{type:"text",text:${ne(u).name} ${ne(u).message}}),MO(ne(u));return a++,o({type:"spinner"},{type:"text",text:Replacing links in ${t.length-a} projects...}),B(u)}))).reduce((p,u)=>p+u,0);o({type:"check-circle"},{type:"text",text:Successfully replaced ${l} links.})}finally{await at(i),setTimeout(s,1e3)}},MO=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var ev=e=>{let t=[scrapbox.Project.name,...e];scrapbox.PopupMenu.addButton({title:r=>{let n=wr(r).length;return n>1?"update links":n===1?"update a link":""},onClick:r=>{let n=wr(r).length;n>1?Qw(r,t):n===1&&Zw(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 n=(await(await GM_fetch(https://gyazo.com/${t}.json)).json()).metadata?.ocr?.description;if(n)try{await navigator.clipboard.writeText(n)}catch(o){console.error(o),alert(${o.name} ${o.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 tv=e=>{let t="",r=0;for(let n of e)if(n.type!=="title"){if(n.indent>r)for(let o=r;o<n.indent;o++)t+=Qo(${o!==r?"\\item":""}\\begin{itemize},o*2)+ ;if(n.indent<r)for(let o=r;o>n.indent;o--)t+=Qo("\\end{itemize}",(o-1)*2)+
;r=n.indent,t+=Qo(${r>0?"\\item ":""}${AO(n)},r*2)+
}for(let n=r;n>0;n--)t+=Qo("\\end{itemize}",(n-1)*2)+
${e.content}
\\end{lstlisting},DO=e=>{let t=\\caption{${xt(e.fileName)}}\\label{table:${xt(e.fileName)}},r=Math.max(...e.cells.map(o=>o.length)),n=e.cells.map(o=> ${o.map(s=>s.map(i=>no(i)).join("")).join(" & ")}\\\\);return\\begin{table}htbp ${t}
\\centering
\\begin{tabular}{${"c".repeat(r)}}
${n.length===0?"":n.length===1?` \\toprule
${n.join(`
`)}
\\bottomrule: \\toprule
\\midrule
${n.slice(1).join(`
`)}
\\bottomrule`}
\\end{tabular}
\\end{table}},$O=e=>e.nodes.map(t=>no(t)).join(""),no=e=>{switch(e.type){case"quote":return\\begin{quote}
${Qo(e.nodes.map(t=>no(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{${xt(e.path)}};case"strong":return\\textbf{${e.nodes.map(t=>no(t)).join("")}};case"formula":return$${e.formula}$;case"decoration":{let t=e.nodes.map(r=>no(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=>no(t)).join("")};case"helpfeel":return\\lstinline!? ${xt(e.text)}!;case"code":return\\lstinline!${xt(e.text)}!;case"commandLine":return\\lstinline!${xt(e.symbol)} ${xt(e.text)}!;case"link":return e.pathType==="absolute"?e.content===""?\\url{${e.href}}:\\href{${e.href}}{${xt(e.content)}}:xt(e.href);case"googleMap":return\\href{${e.url}}{${xt(e.place)}};case"hashTag":return xt(#${e.href});case"blank":case"plain":return xt(e.text)}},jO=[{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"}],FO=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return jO.find(r=>r.extensions.includes(t))?.fileType??""},xt=e=>e.replaceAll("\\","\\textbackslash ").replaceAll("#","\\#").replaceAll("%","\\%").replaceAll("$","\\$").replaceAll("&","\\&").replaceAll("~","\\textasciitilde ").replaceAll("^","\\textasciicircum ").replaceAll("_","\\_").replaceAll("{","\\{").replaceAll("}","\\}").replaceAll("|","\\textbar ").replaceAll("<","\\textless ").replaceAll(">","\\textgreater "),Qo=(e,t)=>e.split( ).map(r=>${" ".repeat(t)}${r}).join(
);scrapbox.PopupMenu.addButton({title:"TeX",onClick:e=>{navigator.clipboard.writeText(tv(Ue(e))).catch(t=>{console.error(t),alert(${t.name} ${t.message}
${t.stack})})}});var Sa="https://keicho.herokuapp.com/api/";var rv=async(e,t)=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let r=await window.GM_fetch(${Sa}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 n=await r.json();return{ok:!0,value:{text:n.text,buttons:n.buttons,canInput:n.can_input}}};var nv=()=>{let{popupMenu:e,render:t}=UO();Uf()?.append?.(e);let r=Rr(),n=()=>{requestAnimationFrame(()=>{let o=document.getElementsByClassName("cursor")[0];e.style.top=${parseInt(o.style.top)+parseInt(o.style.height)+4}px})};return r.addChangeListener(n),{render:t,visible:()=>!e.hidden,open:()=>e.hidden=!1,close:()=>e.hidden=!0,toggle:()=>e.hidden=!e.hidden,dispose:()=>{e.remove(),r.removeChangeListener(n)}}},UO=()=>{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
}
max-width:90vw
}
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
}
font-size:13px;
padding:6px;
min-width:12vw
}
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:(...n)=>{r.textContent="",r.append(...n.map(({text:o,onClick:s})=>{let i=document.createElement("div");return i.classList.add("button"),i.textContent=o,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(${Sa}web/create/?mode=${e},{mode:"cors"});return t.ok?{ok:!0,value:await t.text()}:{ok:!1,value:{name:"ResponseError",res:t}}};var sv=e=>https://keicho.netlify.app/#talk=${e};var iv=e=>{let t=e.split( ),r=t[1]??t[0],n=e===t[0]?"":t[0];return n?[n.trim(),r].join(
):r};var _a=async(e,t,r)=>{let n=Rr(),o=n.lines.findIndex(i=>i.id===t.id);o<0&&(o=n.lines.findIndex(i=>i.text===t.text)),o<0&&(o=Math.min(r,Math.max(0,n.lines.length-1)));let s=n.lines[o].text;return Gs().clear(),n.setPosition({line:o,char:[...s].length}),await Xe(
${e}),n.getPosition().line};var av=e=>Ue(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(n=>${r} ${n})].join(
).trimEnd();case"table":return[${r}${t.fileName},...t.cells.map(n=>${r} ${n.flatMap(o=>o.map(s=>La(s))).join(" ")})].join(
).trimEnd();case"line":return${r}${t.nodes.map(n=>La(n)).join("")}.trimEnd()}}).join(
),La=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>La(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=>La(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 oo=e=>/^[((]/.test(e);var lv=async e=>{let t=scrapbox.Page.lines;if(!t)return;let{cursor:r,selection:n}=kt(),o=e?.entire||n.hasSelectionAll(),s=o?t.map(P=>P.text).join(
):n.getSelectedText(),i=e?.botIcon??"[/nishio/nisbot.icon]",{render:a,visible:c,open:l,close:p,dispose:u}=nv();p();let f=new Set,d=()=>{u();for(let P of f)P()},h=P=>f.add(P),g={text:"Exit",onClick:d},y=e?.talkId||cv(s)||(o?"":cv(t.slice(0,1+r.getPosition().line).map(P=>P.text).join(
))),w=!y;if(!y){let P=ov(e?.mode),_=setTimeout(()=>{a({text:"Start talking..."}),l();let M=0;_=setInterval(()=>{a({text:Start talking${".".repeat(M%3)}}),M++},1e3)},1e3),N=await P;if(clearTimeout(_),!N.ok){if(N.value.name==="GMFetchNotAvailableError"){alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc.");return}if(N.value.name==="ResponseError"){a({text:Error: ${N.value.res.status} ${N.value.res.statusText}},g),l(),console.error(Error: ${N.value.res.status} ${N.value.res.statusText},await N.value.res.text());return}return}y=N.value}let R=y,E=n.normalizeOrder(n.getRange()),b=o?t.length-1:E.end.line,k=t[b],v=o?"":" ".repeat(Math.min(...t.slice(E.start.line,E.end.line+1).map(P=>ur(P.text)))),L=async P=>{let _=await rv(P,R);if(!_.ok)switch(_.value.name){case"ResponseError":return a({text:Error: ${_.value.res.status} ${_.value.res.statusText}},g),l(),console.error(Error: ${_.value.res.status} ${_.value.res.statusText},await _.value.res.text()),_;case"GMFetchNotAvailableError":return alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc."),_}return _},O="",$=async P=>{let _=av(P).split(
).map(A=>A.trim()).join(
).trim();_.startsWith(O)&&(_=_.slice(O.length));let N=_.split(
);if(N.length===0)return;if(N.every(A=>oo(A))&&(O=_),N.filter(A=>!oo(A)).length<2){let A,W;for(let F of N){if(W=await L(F),!W.ok)return W;oo(F)||(A=W)}return A??W}let j=0;{let A;for(;j<N.length&&oo(N[j]);j++)if(A=await L(N[j]),!A.ok)return A}{let A=await L("まず聞いて");if(!A.ok)return A}for(;j<N.length&&!oo(N[j]);j++){let A=await L(N[j]);if(!A.ok)return A}return await L("おしまい")},S=async P=>{if(scrapbox.Layout!=="page"||P==="")return;let _=$(P),N=setTimeout(()=>{a({text:"Asking..."}),l();let F=0;N=setInterval(()=>{a({text:Asking${".".repeat(F%3)}}),F++},1e3)},1e3),M=await _;if(clearTimeout(N),!M||!M.ok)return;let{text:j,buttons:A}=M.value,W=iv(j);if(W.trim()){let F=${v}${i}${W.includes(`
)?
${W.split(`
).map(q=> ${v}${q}).join(
)}:W}
${v};b=await _a(F,k,b),k=t[b]}a({text:"Send",onClick:T},{text:"🙂",onClick:()=>Xe("🙂")},{text:"🙁",onClick:()=>Xe("🙁")},...A.map(F=>({text:F,onClick:async()=>{b=await _a(F,k,b),k=t[b],await S(F)}})),g),l()},T=async()=>{if(scrapbox.Layout!=="page")return;let P=scrapbox.Page.lines,_=r.getPosition().line,[N,M,j]=BO(P,_,i);N!==""&&(b=j,k=P[b],v=" ".repeat(Math.min(...P.slice(M,j+1).map(A=>ur(A.text)))),await S(N))};return w&&(b=await _a(sv(R),k,b),k=t[b]),await S(s),{ask:T,open:l,close:p,visible:c,exit:d,onExit:h}},cv=e=>{for(let t of e.split(
).reverse()){let r=t.match(/https?:\/\/keicho\.netlify\.app\/#talk=(\w+)/)?.[1];if(r)return r}},BO=(e,t,r)=>{let n=Math.max(e.findLastIndex((s,i)=>i<t&&s.text.trim().startsWith(r)),1),o=n+Yr(n,e)+1;return[e.slice(o,t+1).map(s=>s.text.trim()).join(
).trim(),o,t]};scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>$ ${e}});var uv=[nn,on,sn];scrapbox.PopupMenu.addButton({title:e=>{let t=dr({project:scrapbox.Project.name,mode:"noopen",hooks:uv});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&&dr({project:e,mode:"noopen",hooks:uv})?.()}});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( );if(e!=t)return t}});var HO=[zu,Uw,zu,Hw,Gw,Pa(),Kw,jw(),Bw,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"),n=e.searchParams.get("sr"),o=new URL(e);return o.search="",t&&o.searchParams.append("dt",t),o.pathname.startsWith("/transit/route/")&&(r&&o.searchParams.append("tm",r),n&&o.searchParams.append("sr",n)),o},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,n]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!n)return e;let[,o,s]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${o&&s?L${o}-${s}/:o?L${o}/:""}https://raw.githubusercontent.com/${t}/${r}/${n}#.svg ${e}]},e=>e.hostname==="github.com"?${e}:e,Vw,zw()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=Yw(e,...HO);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return Xe(r)})}});ev(["takker","takker-memex","takker-private","takker-books"]);if(!/mobile/i.test(navigator.userAgent)){let e=(t,r)=>{t.trim()!==""&&lv({mode:r}).then(n=>{if(!n)return;let{ask:o,visible:s,onExit:i}=n,a=c=>{!s()||c.key!=="Enter"||!c.ctrlKey||c.altKey||c.shiftKey||(c.preventDefault(),c.stopPropagation(),o())};Ve().addEventListener("keydown",a),i(()=>Ve().removeEventListener("keydown",a))})};scrapbox.PopupMenu.addButton({title:()=>"🤖",onClick:t=>e(t)})}var Zo=(e,t)=>t.map(r=>r.replace(/@yyyy-MM-dd HH:mm:ss@/g,Ht(e,"yyyy-MM-dd HH:mm:ss")).replace(/@yyyy-MM-dd@/g,Ht(e,"yyyy-MM-dd")).replace(/@yyyy-MM-dd(?:([+-])(\d+)(w?))?(?:\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))?@/g,(n,o,s,i,a)=>{let c=o?o==="+"?We(e,parseInt(s)*(i==="w"?7:1)):fr(e,parseInt(s)*(i==="w"?7:1)):e;return Ht(a?We(ut(c),WO(a)):c,"yyyy-MM-dd")}).replace(/@yyyy-ww@/g,${Bc(e)}-w${${Mn(e)}.padStart(2,"0")}).replace(/@yyyy-ww([+-])(\d+)(w?)@/g,(n,o,s,i)=>{let a=o==="+"?We(e,parseInt(s)*(i==="w"?7:1)):fr(e,parseInt(s)*(i==="w"?7:1));return${Bc(a)}-w${${Mn(a)}.padStart(2,"0")}})),WO=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 dv=async(e,t,r)=>{if(scrapbox.Project.name!==e)return()=>{};let n=scrapbox.Project.pages;await new Promise(l=>{let p=setInterval(()=>{if(n.length===0){n=scrapbox.Project.pages;return}clearInterval(p),l()},2e3)});let o=new Date(2023,1,3),s=async()=>{let l=new Date,p={start:o,end:We(l,1)},{render:u,dispose:f}=_e(),d;try{let h=await pv(t),g=await pv(r),y=qm(p).filter(b=>{let k=Zo(b,h)[0],v=n.find(L=>L.title===k);return!v||!v.exists}),w=zm(p).filter(b=>{let k=Zo(b,g)[0],v=n.find(L=>L.title===k);return!v||!v.exists});if(y.length===0&&w.length===0)return;let R=y.length+w.length;u({type:"spinner"},{type:"text",text:create ${R} review pages...});let E=await ot();if(G(E))throw ne(E);d=B(E);for(let b of[...y.map(k=>Zo(k,h)),...w.map(k=>Zo(k,g))])await we(e,b[0],(k,v)=>v.persistent?void 0:b,d?{socket:d}:{}),R--,u({type:"spinner"},{type:"text",text:create ${R} review pages...});u({type:"check-circle"},{type:"text",text:created ${y.length+w.length} review pages.}),o=l}catch(h){u({type:"exclamation-triangle"},{type:"text",text:h instanceof Error?${h.name} ${h.message}:"Unknown error! (see developper console)"}),console.error(h)}finally{d&&await at(d),await Pe(1e3),f()}},i=s(),a=new Date,c=setInterval(()=>{let l=new Date;Et(a,l)||(a=l,i.then(()=>i=s()))},1e4);return()=>(clearTimeout(c),i)},pv=async e=>{let t=await Ps(e[0],e[1],e[2]);if(G(t)){let n=new Error;throw n.name=ne(t).name,n.message=${ne(t).message} at fetching /${e0}/${e1}/${e2},n}let r=B(t).split( );if(r.length===0)throw new Error(template "/${e0}/${e1}/${e2}" is empty!);return r};var Yu=(...e)=>{let t=e.flatMap(n=>{if(typeof n=="string")return[Ca(n)];if(Array.isArray(n.type))return[fv(n.type)];switch(n.type){case"text":return[Ca(n.text)];case"group":{let o=Yu(...n.items);return o?[o]:[]}default:return[fv(n.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},Ca=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},fv=e=>{if(Array.isArray(e)){let t=document.createElement("span");t.classList.add("fa-stack");let r=Ku(e[0]);r.classList.add("fa-stack-1x");let n=Ku(e[1]);return n.classList.add("fa-stack-1x"),t.append(r,n),Ca(t)}return Ca(Ku(e))},Ku=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:Vu,selection:Xu}=kt(),hv=e=>{let{className:t,display:r,onClick:n,context:o="page"}=e,s=document.createElement("div");t&&s.classList.add(t),mv(o)||(s.style.display="none");let i=(...l)=>{if(l.length===1&&l[0]===""){s.style.display="none";return}s.textContent="";let p=Yu(...l);p&&s.append(p)},a=typeof r=="function"?r({cursor:Vu,selection:Xu}):r;return i(...Array.isArray(a)?a:[a]),s.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),n({cursor:Vu,selection:Xu,setDisplay:i})}),{status:s,context:o,update:()=>{if(mv(o)?s.removeAttribute("style"):s.style.display="none",typeof r=="function"){let l=r({cursor:Vu,selection:Xu});i(...Array.isArray(l)?l:[l])}}}},mv=e=>e!=="stream"?scrapbox.Layout===e:scrapbox.Layout==="list"&&location.pathname.startsWith("/stream");var gv=()=>{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 Ju=new Set,{cursor:qO,selection:zO}=kt(),GO=gv();var Ft=e=>{let t=hv(e);return Ju.add(t),GO.append(t.status),()=>{t.status.remove(),Ju.delete(t)}},Qu=()=>{for(let{update:e}of Ju)e()};qO.addChangeListener(()=>Qu());zO.addChangeListener(()=>Qu());scrapbox.addListener("layout:changed",Qu);var yv=async(e,t)=>{try{let r=t.getSelectedText()||tt(e.getPosition().line);if(!r)return;await navigator.clipboard.writeText(r)}catch(r){console.error(r),alert(Faild to copy:
${JSON.stringify(r)})}},bv=async(e,t)=>{try{let r=t.hasSelection(),n=r?t.getRange().start.line:e.getPosition().line,o=r?t.getSelectedText():tt(n);if(!o)return;await navigator.clipboard.writeText(o),r||t.setRange({start:{line:n,char:0},end:{line:n,char:o.length}}),e.focus(),Be("Delete")}catch(r){console.error(r),alert(Faild to cut:
${JSON.stringify(r)})}},xv=async e=>{try{let t=await navigator.clipboard.readText();if(!t)return;e.focus(),await Xe(t)}catch(t){console.error(t),alert(Faild to paste:
${JSON.stringify(t)})}},wv=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=Rr();t.hasFocus||(e.preventDefault(),t.focus())});var Zu=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")}},vv=new Zu;var kv=e=>new Promise(t=>setTimeout(t,e));async function zt(e,{wait:t=1}={}){let r=vv.textInput;r.focus(),r.value=e;let n=document.createEvent("UIEvent");n.initEvent("input",!0,!1),r.dispatchEvent(n),await kv(t)}if(xn()){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:()=>zt(ft(new Date,"#yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD HH:mm:ss ",onClick:()=>zt(ft(new Date,"yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD",onClick:()=>zt(ft(new Date,"yyyy-MM-dd"))}),scrapbox.PageMenu(e).addItem({title:"HH:mm:ss ",onClick:()=>zt(ft(new Date,"HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"⬜",onClick:()=>zt("⬜")}),scrapbox.PageMenu(e).addItem({title:"🚧",onClick:()=>zt("🚧")}),scrapbox.PageMenu(e).addItem({title:"⌛",onClick:()=>zt("⌛")}),scrapbox.PageMenu(e).addItem({title:"📝",onClick:()=>zt("📝")}),scrapbox.PageMenu(e).addItem({title:"✅",onClick:()=>zt("✅")}),scrapbox.PageMenu(e).addItem({title:"❌",onClick:()=>zt("❌")})}scrapbox.PageMenu.addItem({title:"Open kakeru",image:"https://i.kakeru.app/15c3b1a40b6b3c2ebd68f33f4c86b3f6-opaque.png",onClick:()=>window.open("https://kakeru.app")});async function Ev(e,{from:t,to:r,merge:n}){if(t===r)return{success:!0,dup:!1};let o=await Ct(t,e);if(G(o))return{success:!1,at:"from",name:ne(o).name,message:ne(o).message};let s=B(o);if(!s.persistent)return{success:!1,at:"from",name:"EmptyPageError",message:"The request page is empty."};let i=await Ct(r,e);if(G(i))return{success:!1,at:"to",name:ne(i).name,message:ne(i).message};let a=B(o);return a.persistent&&!n?{success:!1,at:"to",name:"NoEmptyPageError",message:The same page already exists in "/${r}"}:(await we(r,e,c=>[...c,...s.lines.slice(1)].map(l=>l.text)),await Ud(t,e),{success:!0,dup:a.persistent})}var ep=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:n,dispose:o}=_e();n({type:"spinner"},{type:"text",text:/${t}/${e} → /${r}/${e}});try{let s=await Ev(e,{from:t,to:r,merge:!0});if(!s.success){n({type:"exclamation-triangle"},{type:"text",text:${s.name} ${s.message}});return}return n({type:"check-circle"},{type:"text",text:Moved ${s.dup?"and merged ":""}to "/${r}/${e}".}),https://scrapbox.io/${r}/${ue(e)}}catch(s){n({type:"exclamation-triangle"},{type:"text",text:s instanceof Error?${s.name} ${s.message}:"Unknown error! (see developper console)"}),console.error(s)}finally{setTimeout(()=>o(),1e3)}};scrapbox.PageMenu.addItem({title:"Transport",onClick:async()=>{await ep()}});scrapbox.PageMenu.addItem({title:"Transport and Open",onClick:async()=>{let e=await ep();e&&window.open(e)}});var tp=e=>e.replace(/[\[\]]/g,"").replace(/\s/g," "),wn=e=>${e}.padStart(2,"0"),Tv=e=>${e.getFullYear()}-${wn(e.getMonth()+1)}-${wn(e.getDate())} ${wn(e.getHours())}:${wn(e.getMinutes())}:${wn(e.getSeconds())},rp=e=>${e.getFullYear()}-${wn(e.getMonth()+1)}-${wn(e.getDate())};var Pv=async(e,t,r,n)=>{let{render:o,dispose:s}=_e(),i=[],a=[];for(let l of KO(r)){if(l.type==="line"){i.push(${tp(l.text)}~@${rp(new Date)});continue}let p=${tp(l.lines0)}~@${rp(new Date)};a.push([p,...l.lines.slice(1),"",#${Tv(new Date)}]),i.push(${p})}let c=B(await ot(n?.socket));try{o({type:"spinner"},{type:"text",text:Adding ${i.length} items...}),await we(e,t,l=>{let p=l.map(f=>f.text),u=p.flatMap((f,d)=>f.trim()==="[/icons/hr.icon]"?[d]:[]).pop()??-1;return u<0?[...p,...i]:[...p.slice(0,u),...i,...p.slice(u)]},{socket:c}),o({type:"spinner"},{type:"text",text:Create ${a.length} pages...}),await Promise.all(a.map(l=>we(e,l[0],p=>[p[0].text,...p.slice(1).map(u=>u.text),...l.slice(1)],{socket:c}))),o({type:"check-circle"},{type:"text",text:"Added to the inbox."})}catch(l){o({type:"exclamation-triangle"},{type:"text",text:"Failed to add (see console). Write directory instead."}),console.error(l),xo(e,t,[...i,...a].join( ))}finally{let l=Pe(1e3);n?.socket&&await at(c),await l,s()}};function*KO(e){let t=0;for(;t<e.length;){let r=ih(t,e);if(r===0){yield{type:"line",text:e[t].trim()},t++;continue}let n=Or(e[t]);yield{type:"block",lines:e.slice(t,t+r+1).map(o=>o.slice(n))},t+=r+1}}var Rv=async(e,t)=>{let r=window.prompt("Type all you think of","");if(!r||r.trim()==="")return;let n=r.trim().split(/\s+/);await Pv(e,t,n)};var YO="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)}/${YO},{execute:n}=await import(r);n()}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}))}});var es=e=>Qn(...C(()=>{let t={tasks:[],errors:[],load:async()=>{},loading:!1},r=Promise.resolve();return[n=>{t.load=()=>(r=(async()=>{await r,t={...t,loading:!0},n(),await ua(e,60),t={...t,loading:!1},n()})(),r);let o=()=>{r=(async()=>{await r,t={...t,loading:!0},n();let[s,i]=VO(await pa(e));t={...t,tasks:s,errors:i,loading:!1},n()})()};return o(),la(e,o)},()=>t]},e)),VO=e=>{let t=new Set,r=[],n=[];for(let{title:o,links:s,project:i}of e)for(let a of[o,...s]){let c=oe(a);if(t.has(c))continue;t.add(c);let l=Nr(a);if(l){if(G(l)){n.push({project:i,title:a,...ne(l)});continue}r.push({project:i,title:a,...B(l)})}}return[r,n]};var Oa=()=>{let[e,t]=Pr(XO,{isOpen:!1,prevOverflowY:""}),r=Ke(null),n=I(()=>{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}})},[]),o=I(()=>{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=C(()=>{let i;return a=>{if(!a){i?.(),r.current=null;return}let c=new AbortController;a.addEventListener("cancel",o,{signal:c.signal}),a.addEventListener("click",l=>{if(l.target!==l.currentTarget){l.stopPropagation();return}o()},{signal:c.signal}),i=()=>{c.abort()},r.current=a}},[o]);return{isOpen:e.isOpen,open:n,close:o,ref:s}},XO=(e,t)=>{let r=t(e);return e.isOpen===r.isOpen&&e.prevOverflowY===r.prevOverflowY?e:r.isOpen?r:{isOpen:!1}};var ts=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 so=({text:e,title:t})=>{let[r,n]=X(""),o=I(async s=>{s.preventDefault(),s.stopPropagation();try{await navigator.clipboard.writeText(e),n("Copied"),await Pe(1e3),n("")}catch(i){alert(Failed to copy the code block
Error:${i instanceof Error?i.message:i}),console.error(i)}},[e]);return m("button",{className:"copy",title:t??"Copy",onClick:o,children:r})};var JO=60*60*24*1e3,Sv=(e,t)=>{let r=de(e.refDate),n=(t.getTime()-r.getTime())/JO;switch(r.setHours(0),r.setMinutes(0),e.status){case"done":return-1/0;case"deadline":return n/(e.speed??1);case"todo":return Math.min(n/(e.speed??1),0);case"note":return t.getTime()<r.getTime()?-1/0:-n/(e.speed??1);case"up-down":{let o=e.speed??30;return o*(-1+Math.cos(Math.PI*2*n/o))}}};var Lv=(e,t)=>{if(t.score!==e.score)return t.score-e.score;let r=_v(e.freshness),n=_v(t.freshness);return r!==n?n-r:Mt(er(e),er(t))?-1:1},_v=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 Gt=e=>${e.getFullYear()}-${Wt(e.getMonth()+1)}-${Wt(e.getDate())},rs=e=>{let[t,r,n]=e.split("-").map(o=>parseInt(o,10));return{year:t,month:r,date:n}},ns=e=>${ri(e)}-w${Wt(Mn(e))},Na=e=>{let[t,r]=e.split("-w").map(n=>parseInt(n,10));return ut(Wc(new Date(t,0,1),r))};var os=({loading:e,onClick:t})=>e?m("div",{children:m("i",{className:"fa fa-spinner"})}):m("button",{className:"navi reload",onClick:t,children:""});var io=()=>{let[e,t]=X(new Date);return ee(()=>{let r=setInterval(()=>t(new Date),6e4);return()=>{clearInterval(r)}},[]),e};var Cv=e=>{switch(e){case"todo":return"ToDo";case"note":return"覚書";case"deadline":return"締切";case"up-down":return"浮遊";case"done":return"完了"}};var Ov=(e,t)=>new URL(/${e.project}/${ue(e.title)},t??location.href);var Ma=({children:e,project:t,title:r,className:n,...o})=>m("a",{...o,className:[n??"","page-link"].join(" "),type:"link",href:Ov({project:t,title:r}).pathname,...t===scrapbox.Project.name?{rel:"route"}:{rel:"noopener noreferrer",target:"_blank"},children:e});var Nv=({action:e,pActions:t})=>{let r=C(()=>Cv(e.freshness.status),[e.freshness.status]),n=C(()=>Qt(er(e)).slice(11)||" ",[er(e)]),o=C(()=>Lo(e),[e]),s=Math.floor(Math.round(e.score)/7),i=io(),a=C(()=>e.executed!==void 0&&Zr(Lr(de(e.executed.start),e.executed.duration),i),[e.executed?.start,e.executed?.duration,i]),c=C(()=>[...t,e].map(l=>${l.raw}).join( ),[t,e]);return m("li",{"data-type":e.freshness.status,"data-freshness":e.score.toFixed(0),"data-level":s,...s<0?{style:{opacity:QO(e).toFixed(2)}}:{},children:[m(so,{text:c,title:"ここまでコピー"}),m("span",{className:"label type",children:r}),m("i",{className:label far fa-fw${a?" fa-bookmark":""}}),m("span",{className:"label freshness",children:e.score.toFixed(0)}),m("time",{className:"label start",children:n}),m("span",{className:"label duration",children:[o,"m"]}),m(Ma,{project:e.project,title:e.raw,children:e.name})]})},QO=e=>Math.max(.8*Math.exp(Math.log(8/7)/7*e.score),.05);var Mv=(e=Gt(new Date))=>{let[t,r]=X(e),n=I(()=>{r(s=>{switch(s){case"errors":return"expired";case"expired":return Gt(new Date);default:{let i=de(rs(s));return i.setDate(i.getDate()+1),Gt(i)}}})},[]),o=I(()=>{r(s=>{let i=Gt(new Date);switch(s){case"errors":return"errors";case"expired":return"errors";case i:return"expired";default:{let a=de(rs(s));return a.setDate(a.getDate()-1),Gt(a)}}})},[]);return{pageNo:t,next:n,prev:o}};var Aa=(e,t)=>ee(()=>(scrapbox.on(e,t),()=>scrapbox.off(e,t)),[]);var ss=(e,t)=>{let r=Ke({...t});ee(()=>(Object.assign(r.current,t),()=>{for(let n of Object.keys(t))delete r.current[n]}),[...Object.keys(t)].sort().map(n=>t[n])),ee(()=>{e(r.current)},[e])};var Av=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(n=>lt(m(ZO,{getController:n,projects:e}),r))},ZO=({getController:e,projects:t})=>{let{tasks:r,errors:n,load:o,loading:s}=es(t),{pageNo:i,next:a,prev:c}=Mv(),l=C(()=>{if(i==="errors")return n.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=>!Zt(y)&&Mt(mh(y),ht(g))&&y.freshness===void 0&&y.recurrence===void 0?[{...y,score:0,freshness:{refDate:y.executed.start,status:"todo"}}]:[]).sort((y,w)=>Mt(er(y),er(w))?-1:0)}let h=de(rs(i));return r.flatMap(g=>{if(!g.freshness)return[];if(Dn(g))return[];let y=Sv(g.freshness,h);return y>-999?[{...g,score:y}]:[]}).sort(Lv)},[r,n,i]),{ref:p,open:u,close:f}=Oa();ss(e,{open:u,close:f});let d=C(()=>[i,...l.map(h=> ${h.raw})].join( ),[l,i]);return Aa("page:changed",f),m(Y,{children:[m("style",{children:ts}),m("dialog",{ref:p,children:[m("div",{className:"controller",children:[m(so,{text:d,title:"Copy All Tasks"}),m("span",{children:i}),m("button",{className:"navi left",onClick:c,children:""}),m("button",{className:"navi right",onClick:a,children:""}),m(os,{loading:s,onClick:o}),m("button",{className:"close",onClick:f,children:""})]}),m("ul",{className:"result task-list","data-page-no":i,children:l.map((h,g)=>m(Nv,{action:h,pActions:l.slice(0,g)},h.raw))})]})]})};var Da=(e,t)=>/${e}/${oe(t)},is=new Map,np=new Map,Iv=(e,t)=>{is.set(e,t);for(let r of np.get(e)??[])r(t)},Ia=()=>{vn!==void 0&&(clearInterval(vn),vn=void 0);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Da(e,t);if(!is.has(r))return;let n=gt().map(o=>o.text);vn=setInterval(()=>{oe(t)===oe(n[0])&&(Iv(r,n),vn!==void 0&&(clearInterval(vn),vn=void 0))},1e3)},vn;scrapbox.on("page:changed",()=>{scrapbox.off("lines:changed",Ia);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Da(e,t);is.has(r)&&scrapbox.on("lines:changed",Ia)});var eN=(e,t)=>{let r=Da(e,t),n=is.get(r);return n||(is.set(r,[]),Ct(e,t).then(o=>{if(G(o))return[];let s=B(o).lines.map(i=>i.text);Iv(r,s),t===scrapbox.Page.title&&!scrapbox.listeners("lines:changed").includes(Ia)&&scrapbox.on("lines:changed",Ia)})),n??[]},Dv=(e,t)=>{let[r,n]=X(eN(e,t));return ee(()=>{let o=Da(e,t),s=np.get(o)??new Set;return s.add(n),np.set(o,s),()=>{s.delete(n)}},[e,t]),r};var op=e=>e.duration===void 0?void 0:ht(Lr(de(e.start),e.duration)),sp=(e,t)=>{let r=de(e.start),n=t.getTime(),o=Math.round((n-r.getTime())/(60*1e3));if(o<=0)return[void 0,e];if(e.duration<=o)return[e,void 0];let s={start:e.start,duration:o};return[s,{start:op(s),duration:e.duration-o}]};var kn=e=>"title"in e,tN=e=>e.record?.duration!==void 0,$v=(e,t)=>kn(e)&&e.status==="done"?e.status:tN(e)?kn(e)&&e.executed?Mt(ht(t),e.executed.start)?"moved":"expired":"done":Mt(op(e.plan),ht(t))?kn(e)?"expired":"done":"undone";var jv=(e,t)=>{let r=Nr(e.title.slice(1,-1));if(!e.plan.start)return;let n={name:r&&kr(r)?B(r).name:e.title,plan:{start:ht(e.plan.start),duration:(e.plan.duration??0)/60}};if(e.record.start&&(n.record={start:ht(e.record.start)},e.record.end&&(n.record.duration=Uc(e.record.end,e.record.start))),!r||G(r))return n;let o=B(r),s={...n,title:o.raw,project:t};return o.freshness&&(s.status=o.freshness.status),Zt(o)||(s.executed=o.executed),s},ip=(e,t)=>{let r=ai(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 Fv=(e,t,r)=>{let n=[ap(e,fr(t,1),r),ap(e,t,r),ap(e,We(t,1),r)],o=C(()=>n.flat(),n);return C(()=>{let s=Nn(t),i=Hm(t);return o.flatMap(a=>{let[,c]=sp(a.plan,s);if(!c)return[];let[l]=sp(c,i);if(!l)return[];let{plan:p,...u}=a;return[{plan:l,...u}]}).sort((a,c)=>Mt(a.plan.start,c.plan.start)?-1:0)},[o,t])},ap=(e,t,r)=>{let n=Dv(e,Ro(t)),o=C(()=>nN(n,e),[n,e]);return C(()=>o.length!==0?o:rN(t,r),[o,t,r])},rN=(e,t)=>t.flatMap(r=>{if(r.freshness?.status==="done")return[];if(Zt(r))return[];if(Dn(r)){let o=ii(r,e);return o?[ip(o,r.project)]:[]}let n=de(r.executed.start);return Et(n,e)?[ip(r,r.project)]:[]}),nN=(e,t)=>{let r=[];for(let n of en(e)){if(Cr(n))continue;let o=jv(n,t);o&&r.push(o)}return r};var Uv=({event:e})=>{let t=C(()=>e.plan.start.hours+e.plan.start.minutes/60,[e.plan.start]),r=C(()=>--start: ${t}; --duration: ${e.plan.duration};,[t,e.plan.duration]),n=io(),o=C(()=>$v(e,n),[e,n]);return kn(e)?m(Ma,{className:"event","data-status":o,style:r,title:e.title,project:e.project,children:e.name}):m("div",{className:"event","data-status":o,title:e.name,style:r,children:e.name})};var Bv=({project:e,date:t,tasks:r})=>{let n=Fv(e,t,r),o=C(()=>n.flatMap(a=>kn(a)?[${a.title}]:[]).join( ),[n]),s=io(),i=C(()=>Et(s,t)?m("div",{className:"indicator",style:--start: ${Km(s)+Ym(s)/60}}):m(Y,{}),[s,t]);return m("div",{className:"timeline",role:"gridcell",children:[n.map(a=>m(Uv,{event:a},a.name)),i,m(so,{text:o})]})};var cp=({dateList:e,tasks:t,project:r,hasColumn:n})=>m("div",{className:"timeline-wrap",role:"grid",children:[(n??!0)&&m("div",{className:"column-header",role:"row",children:e.map(o=>m("div",{className:"cell",role:"columnheader",children:m("h2",{children:Gm(o)})},Gt(o)))}),m("div",{className:"week-container",role:"presentation",children:m("div",{className:"week",role:"presentation",children:[m("div",{className:"borders",children:[...Array(24).keys()].map(o=>m("div",{className:"border","data-time":${Wt(o)}:00},o))}),e.map(o=>m(Bv,{project:r,date:o,tasks:t},Gt(o)))]})})]});var lp=(e,t,r)=>{let[n,o]=X(e),s=I(()=>o(t),[t]),i=I(()=>o(r),[t]),a=I(c=>o(c),[]);return{pageNo:n,next:s,prev:i,jump:a}};var Hv=e=>{let t=Ke(new Set),[r,n]=X(e),o=I(()=>{for(let l of t.current)l()},[]),s=I(()=>{n(!0),o()},[]),i=I(()=>n(!1),[]),a=I(()=>n(l=>(l||o(),!l)),[]),c=I(l=>(t.current.add(l),()=>t.current.delete(l)),[]);return{isOpen:r,open:s,close:i,toggle:a,onOpen:c}};var zv=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(n=>lt(m(oN,{getController:n,projects:e,mainProject:e[0]}),r))},Gv=(e,t)=>{let r=document.createElement("div");r.dataset.userscriptName="takker-scheduler/timeline-wedget";let n=r.attachShadow({mode:"open"});return document.body.append(r),new Promise(o=>lt(m(sN,{getController:o,projects:e,mainProject:e[0],open:t}),n))},Wv=!1,oN=({getController:e,projects:t,mainProject:r})=>{let{tasks:n,load:o,loading:s}=es(t),{pageNo:i,next:a,prev:c,jump:l}=lp(ns(new Date),iN,aN),p=C(()=>{let y=Na(i);return[0,1,2,3,4,5,6].map(w=>We(y,w))},[i]),{ref:u,open:f,close:d,isOpen:h}=Oa();Wv||=h,ss(e,{open:f,close:d,isOpen:h}),Aa("page:changed",d);let g=I(()=>l(ns(new Date)),[l]);return m(Y,{children:[m("style",{children:ts}),m("dialog",{ref:u,children:[m("div",{className:"controller",children:[m("span",{children:i}),m("button",{className:"navi left",onClick:c,children:""}),m("button",{className:"navi right",onClick:a,children:""}),m("button",{className:"today",onClick:g,children:""}),m(os,{loading:s,onClick:o}),m("button",{className:"close",onClick:d,children:""})]}),Wv&&m("div",{ref:Kv,className:"result scheduler","data-page-no":i,children:m(cp,{dateList:p,tasks:n,project:r})})]})]})},qv=!1,sN=({projects:e,mainProject:t,getController:r,open:n})=>{let{tasks:o,load:s,loading:i}=es(e),{pageNo:a,next:c,prev:l,jump:p}=lp(new Date,cN,lN),u=C(()=>[a],[a]),f=I(()=>p(new Date),[p]),{isOpen:d,open:h,close:g}=Hv(n);return qv||=d,ss(r,{open:h,close:g,isOpen:d}),m(Y,{children:[m("style",{children:ts}),qv&&m("div",{className:wedget${d?" open":""},ref:Kv,children:[m("div",{className:"controller",children:[m("span",{children:Gt(a)}),m("button",{className:"navi left",onClick:l,children:""}),m("button",{className:"navi right",onClick:c,children:""}),m("button",{className:"today",onClick:f,children:""}),m(os,{loading:i,onClick:s})]}),m(cp,{dateList:u,tasks:o,project:t,hasColumn:!1})]})]})},iN=e=>ns(ti(Na(e),1)),aN=e=>ns(Zm(Na(e),1)),cN=e=>We(e,1),lN=e=>fr(e,1),Kv=e=>{let t=e?.getElementsByClassName?.("indicator")?.[0];if(!t)return;let r=globalThis.scrollY;t.scrollIntoView({block:"center"}),globalThis.scroll(0,r)};lf({project:"takker-dist"});hm().then(e=>{scrapbox.PageMenu.addItem({title:"Fulltext Search",onClick:()=>{e.toggle()}})});var uN="https://scrapbox.io/files/67344295032adf96d1e4c276.wasm",pN="/api/code/takker-dist/for-any-project-min/esbuild-worker.js";(async()=>{let e=new Request(uN),t=await Cn(e);t||(t=await fetch(e),await zs(e,t)),await Ob(await WebAssembly.compileStreaming(t),pN)})();(async()=>{let e=[scrapbox.Project.name,"takker","takker-memex","takker-books","takker-private","villagepump","hub","arpla","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"],t=await Ax({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","概要と参加方法"]].map(([o,s])=>[o,https://scrapbox.io/api/pages/${o}/${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":"⿻"},enableSelfProjectOnStart:!0}),r=o=>{o.preventDefault(),o.stopPropagation()},n=()=>document.querySelector(".line .popup-menu")!==null;ol.bind({"<Tab>":o=>{n()||t.selectNext?.({cyclic:!0})&&r(o)},"<S-Tab>":o=>{n()||t.selectPrev?.({cyclic:!0})&&r(o)},"<Enter>":o=>{n()||t.confirm?.()&&r(o)},"<Esc>":o=>{n()||t.cancel?.()&&r(o)}})})();jx({previewers:[{when:/(?:^|\.)svg$/,preview:Fx},{when:/(?:^|\.)glsl$/,preview:yw},{when:/(?:^|\.)(?:plantuml|puml|pu)$/,preview:ww},{when:/(?:^|\.)tikz\(tex\)$/,preview:kw("/api/code/takker-dist/for-any-project-min/tex-worker.js","https://scrapbox.io/files/65d1645c19cd8e002433c3df")}]});dv("takker",["takker","振り返り(takker-workflow@0.0.1)のtemplate","txt"],["takker","1週間の振り返り(takker-workflow@0.0.1)のtemplate","txt"]);xn()&&(Ft({display:{type:"caret-left"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Bs():$s()}}),Ft({display:{type:"caret-right"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Us():Ds()}}),Ft({display:{type:"caret-up"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Hs():js()}}),Ft({display:{type:"caret-down"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Ws():Fs()}}),Ft({display:{type:"copy"},onClick:async({cursor:e,selection:t})=>await yv(e,t)}),Ft({display:{type:"cut"},onClick:async({cursor:e,selection:t})=>await bv(e,t)}),Ft({display:{type:"clipboard"},onClick:async({cursor:e})=>await xv(e)}),Ft({display:{type:"undo"},onClick:()=>Qf()}),Ft({display:{type:"redo"},onClick:()=>Zf()}),Ft({display:({cursor:e})=>e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?{type:["i-cursor","slash"]}:{type:"i-cursor"},onClick:({cursor:e})=>wv(e)}));if(xn()&&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:To}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>So({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"})})}if(xn()){let e="New Page",t=[nn,on,sn];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&&dr({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&&dr({project:r,mode:"self",hooks:t})?.()}})}scrapbox.PageMenu.addMenu({title:"Add to inbox",image:"https://img.icons8.com/ios/180/FFFFFF/inbox.png",onClick:()=>Rv("takker-memex","メモ帳")});(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= 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;
}
opacity: 0;
}`,document.head.append(r);let n="takker-memex","takker",{open:o}=await Av(n);scrapbox.PageMenu.addMenu({title:e,image:"/assets/img/favicon/apple-touch-icon.png",onClick:o});let s=await zv(n);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 Gv(n,ac),p=()=>{ac=!l.isOpen,l.isOpen?l.close():l.open?.(),localStorage.setItem(i,JSON.stringify(a))};xn()?Ft({display:{type:"calendar"},onClick:p}):scrapbox.PageMenu.addItem({title:"toggle wedget",onClick:p})}})();export{Ft as addButton,Xe as insertText,ol 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.
*/
code:takker-memex.js
var sk=Object.defineProperty;var On=(e,t)=>{for(var r in t)sk(e,r,{get:tr,enumerable:!0})};var Va={};On(Va,{Decoder:()=>hk,Encoder:()=>mk,PacketType:()=>ne,protocol:()=>yp});function ct(e){if(e)return ik(e)}function ik(e){for(var t in ct.prototype)et=ct.prototypet;return e}ct.prototype.on=ct.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};ct.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};ct.prototype.off=ct.prototype.removeListener=ct.prototype.removeAllListeners=ct.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 n,o=0;o<r.length;o++)if(n=ro,n===t||n.fn===t){r.splice(o,1);break}return r.length===0&&delete this._callbacks"$"+e,this};ct.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,n=1;n<arguments.length;n++)tn-1=argumentsn;if(r){r=r.slice(0);for(var n=0,o=r.length;n<o;++n)rn.apply(this,t)}return this};ct.prototype.emitReserved=ct.prototype.emit;ct.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};ct.prototype.hasListeners=function(e){return!!this.listeners(e).length};var ak=typeof ArrayBuffer=="function",ck=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,gp=Object.prototype.toString,lk=typeof Blob=="function"||typeof Blob<"u"&&gp.call(Blob)==="object BlobConstructor",uk=typeof File=="function"||typeof File<"u"&&gp.call(File)==="object FileConstructor";function Ya(e){return ak&&(e instanceof ArrayBuffer||ck(e))||lk&&e instanceof Blob||uk&&e instanceof File}function ys(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(ys(er))return!0;return!1}if(Ya(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return ys(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&ys(er))return!0;return!1}function pk(e){let t=[],r=e.data,n=e;return n.data=Ga(r,t),n.attachments=t.length,{packet:n,buffers:t}}function Ga(e,t){if(!e)return e;if(Ya(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 n=0;n<e.length;n++)rn=Ga(en,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(rn=Ga(en,t));return r}return e}function dk(e,t){return e.data=Ka(e.data,t),delete e.attachments,e}function Ka(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=Ka(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=Ka(er,t));return e}var fk="connect","connect_error","disconnect","disconnecting","newListener","removeListener",yp=5,ne;(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"})(ne||(ne={}));var mk=class{constructor(e){this.replacer=e}encode(e){return(e.type===ne.EVENT||e.type===ne.ACK)&&ys(e)?this.encodeAsBinary({type:e.type===ne.EVENT?ne.BINARY_EVENT:ne.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===ne.BINARY_EVENT||e.type===ne.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=pk(e),r=this.encodeAsString(t.packet),n=t.buffers;return n.unshift(r),n}};function hp(e){return Object.prototype.toString.call(e)==="object Object"}var hk=class bp extends ct{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 n=r.type===ne.BINARY_EVENT;n||r.type===ne.BINARY_ACK?(r.type=n?ne.EVENT:ne.ACK,this.reconstructor=new gk(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(Ya(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,n={type:Number(t.charAt(0))};if(nen.type===void 0)throw new Error("unknown packet type "+n.type);if(n.type===ne.BINARY_EVENT||n.type===ne.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");n.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););n.nsp=t.substring(s,r)}else n.nsp="/";let o=t.charAt(r+1);if(o!==""&&Number(o)==o){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}n.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(bp.isPayloadValid(n.type,s))n.data=s;else throw new Error("invalid payload")}return n}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case ne.CONNECT:return hp(r);case ne.DISCONNECT:return r===void 0;case ne.CONNECT_ERROR:return typeof r=="string"||hp(r);case ne.EVENT:case ne.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&fk.indexOf(r0)===-1);case ne.ACK:case ne.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},gk=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=dk(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};var Xt=Object.create(null);Xt.open="0";Xt.close="1";Xt.ping="2";Xt.pong="3";Xt.message="4";Xt.upgrade="5";Xt.noop="6";var ws=Object.create(null);Object.keys(Xt).forEach(e=>{ws[Xte]=e});var Qa={type:"error",data:"parser error"},kp=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",Ep=typeof ArrayBuffer=="function",Tp=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,vs=({type:e,data:t},r,n)=>kp&&t instanceof Blob?r?n(t):xp(t,n):Ep&&(t instanceof ArrayBuffer||Tp(t))?r?n(t):xp(new Blob(t),n):n(Xte+(t||"")),xp=(e,t)=>{let r=new FileReader;return r.onload=function(){let n=r.result.split(",")1;t("b"+(n||""))},r.readAsDataURL(e)};function wp(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Xa;function yk(e,t){if(kp&&e.data instanceof Blob)return e.data.arrayBuffer().then(wp).then(t);if(Ep&&(e.data instanceof ArrayBuffer||Tp(e.data)))return t(wp(e.data));vs(e,!1,r=>{Xa||(Xa=new TextEncoder),t(Xa.encode(r))})}var vp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",go=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<vp.length;e++)govp.charCodeAt(e)=e;var bk=e=>{let t=e.length*.75,r=e.length,n,o=0,s,i,a,c;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let l=new ArrayBuffer(t),p=new Uint8Array(l);for(n=0;n<r;n+=4)s=goe.charCodeAt(n),i=goe.charCodeAt(n+1),a=goe.charCodeAt(n+2),c=goe.charCodeAt(n+3),po++=s<<2|i>>4,po++=(i&15)<<4|a>>2,po++=(a&3)<<6|c&63;return l},xk=typeof ArrayBuffer=="function",ks=(e,t)=>{if(typeof e!="string")return{type:"message",data:Pp(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:wk(e.substring(1),t)}:wsr?e.length>1?{type:wsr,data:e.substring(1)}:{type:wsr}:Qa},wk=(e,t)=>{if(xk){let r=bk(e);return Pp(r,t)}else return{base64:!0,data:e}},Pp=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Rp="",Sp=(e,t)=>{let r=e.length,n=new Array(r),o=0;e.forEach((s,i)=>{vs(s,!1,a=>{ni=a,++o===r&&t(n.join(Rp))})})},_p=(e,t)=>{let r=e.split(Rp),n=[];for(let o=0;o<r.length;o++){let s=ks(ro,t);if(n.push(s),s.type==="error")break}return n};function Lp(){return new TransformStream({transform(e,t){yk(e,r=>{let n=r.length,o;if(n<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,n);else if(n<65536){o=new Uint8Array(3);let s=new DataView(o.buffer);s.setUint8(0,126),s.setUint16(1,n)}else{o=new Uint8Array(9);let s=new DataView(o.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(n))}e.data&&typeof e.data!="string"&&(o0|=128),t.enqueue(o),t.enqueue(r)})}})}var Ja;function bs(e){return e.reduce((t,r)=>t+r.length,0)}function xs(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),n=0;for(let o=0;o<t;o++)ro=e0n++,n===e0.length&&(e.shift(),n=0);return e.length&&n<e0.length&&(e0=e0.slice(n)),r}function Cp(e,t){Ja||(Ja=new TextDecoder);let r=[],n=0,o=-1,s=!1;return new TransformStream({transform(i,a){for(r.push(i);;){if(n===0){if(bs(r)<1)break;let c=xs(r,1);s=(c0&128)===128,o=c0&127,o<126?n=3:o===126?n=1:n=2}else if(n===1){if(bs(r)<2)break;let c=xs(r,2);o=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),n=3}else if(n===2){if(bs(r)<8)break;let c=xs(r,8),l=new DataView(c.buffer,c.byteOffset,c.length),p=l.getUint32(0);if(p>Math.pow(2,21)-1){a.enqueue(Qa);break}o=p*Math.pow(2,32)+l.getUint32(4),n=3}else{if(bs(r)<o)break;let c=xs(r,o);a.enqueue(ks(s?c:Ja.decode(c),t)),n=0}if(o===0||o>e){a.enqueue(Qa);break}}}})}var Za=4;function Se(e){if(e)return vk(e)}function vk(e){for(var t in Se.prototype)et=Se.prototypet;return e}Se.prototype.on=Se.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};Se.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};Se.prototype.off=Se.prototype.removeListener=Se.prototype.removeAllListeners=Se.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 n,o=0;o<r.length;o++)if(n=ro,n===t||n.fn===t){r.splice(o,1);break}return r.length===0&&delete this._callbacks"$"+e,this};Se.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,n=1;n<arguments.length;n++)tn-1=argumentsn;if(r){r=r.slice(0);for(var n=0,o=r.length;n<o;++n)rn.apply(this,t)}return this};Se.prototype.emitReserved=Se.prototype.emit;Se.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};Se.prototype.hasListeners=function(e){return!!this.listeners(e).length};var yo=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),Ot=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),kk="arraybuffer";function Np(e,...t){return t.reduce((r,n)=>(e.hasOwnProperty(n)&&(rn=en),r),{})}var Ek=Ot.setTimeout,Tk=Ot.clearTimeout;function bo(e,t){t.useNativeTimers?(e.setTimeoutFn=Ek.bind(Ot),e.clearTimeoutFn=Tk.bind(Ot)):(e.setTimeoutFn=Ot.setTimeout.bind(Ot),e.clearTimeoutFn=Ot.clearTimeout.bind(Ot))}var Pk=1.33;function Rk(e){return typeof e=="string"?Sk(e):Math.ceil((e.byteLength||e.size)*Pk)}function Sk(e){let t=0,r=0;for(let n=0,o=e.length;n<o;n++)t=e.charCodeAt(n),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(n++,r+=4);return r}function Mp(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function _k(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function Lk(e){let t={},r=e.split("&");for(let n=0,o=r.length;n<o;n++){let s=rn.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var Ck=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},rc=class extends Se{constructor(e){super(),this.writable=!1,bo(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 Ck(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=ks(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=_k(e);return t.length?"?"+t:""}},Ok=class extends rc{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)};_p(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,Sp(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=Mp()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Ip=!1;try{Ip=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Nk=Ip;function Mk(){}var Ik=class extends Ok{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",(n,o)=>{this.onError("xhr post error",n,o)})}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 Es extends Se{constructor(t,r,n){super(),this.createRequest=t,bo(this,n),this._opts=n,this._method=n.method||"GET",this._uri=r,this._data=n.data!==void 0?n.data:null,this._create()}_create(){var t;let r=Np(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let n=this._xhr=this.createRequest(r);try{n.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&n.setRequestHeader(o,this._opts.extraHeaderso)}}catch{}if(this._method==="POST")try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{n.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(n),"withCredentials"in n&&(n.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(n.timeout=this._opts.requestTimeout),n.onreadystatechange=()=>{var o;n.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(n.getResponseHeader("set-cookie"))),n.readyState===4&&(n.status===200||n.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof n.status=="number"?n.status:0)},0))},n.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=Es.requestsCount++,Es.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=Mk,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Es.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",Op);else if(typeof addEventListener=="function"){let e="onpagehide"in Ot?"pagehide":"unload";addEventListener(e,Op,!1)}}function Op(){for(let e in Nn.requests)Nn.requests.hasOwnProperty(e)&&Nn.requestse.abort()}var Dk=function(){let e=Dp({xdomain:!1});return e&&e.responseType!==null}(),nc=class extends Ik{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Dk&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Nn(Dp,this.uri(),e)}};function Dp(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Nk))return new XMLHttpRequest}catch{}if(!t)try{return new Ot["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Ap=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Ak=class extends rc{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=Ap?{}:Np(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(n){return this.emitReserved("error",n)}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,n=t===e.length-1;vs(r,this.supportsBinary,o=>{try{this.doWrite(r,o)}catch{}n&&yo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(tthis.opts.timestampParam=Mp()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},ec=Ot.WebSocket||Ot.MozWebSocket,oc=class extends Ak{createSocket(e,t,r){return Ap?new ec(e,t,r):t?new ec(e,t):new ec(e)}doWrite(e,t){this.ws.send(t)}},$p=class extends rc{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=Cp(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),n=Lp();n.readable.pipeTo(e.writable),this._writer=n.writable.getWriter();let o=()=>{r.read().then(({done:i,value:a})=>{i||(this.onPacket(a),o())}).catch(i=>{})};o();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,n=t===e.length-1;this._writer.write(r).then(()=>{n&&yo(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},$k={websocket:oc,webtransport:$p,polling:nc},Fk=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,jk="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function Ss(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf(""),n=e.indexOf("");r!=-1&&n!=-1&&(e=e.substring(0,r)+e.substring(r,n).replace(/:/g,";")+e.substring(n,e.length));let o=Fk.exec(e||""),s={},i=14;for(;i--;)s[jki]=oi||"";return r!=-1&&n!=-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=Uk(s,s.path),s.queryKey=Bk(s,s.query),s}function Uk(e,t){let r=/\/{2,9}/g,n=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&n.splice(0,1),t.slice(-1)=="/"&&n.splice(n.length-1,1),n}function Bk(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(n,o,s){o&&(ro=s)}),r}var tc=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ts=[];tc&&addEventListener("offline",()=>{Ts.forEach(e=>e())},!1);var Ps=class Rs extends Se{constructor(t,r){if(super(),this.binaryType=kk,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 n=Ss(t);r.hostname=n.host,r.secure=n.protocol==="https"||n.protocol==="wss",r.port=n.port,n.query&&(r.query=n.query)}else r.host&&(r.hostname=Ss(r.host).host);bo(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(n=>{let o=n.prototype.name;this.transports.push(o),this._transportsByNameo=n}),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=Lk(this.opts.query)),tc&&(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"})},Ts.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=Za,r.transport=t,this.id&&(r.sid=this.id);let n=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptionst);return new this._transportsByNamet(n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&Rs.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",Rs.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 n=this.writeBufferr.data;if(n&&(t+=Rk(n)),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,yo(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,n){return this._sendPacket("message",t,r,n),this}send(t,r,n){return this._sendPacket("message",t,r,n),this}_sendPacket(t,r,n,o){if(typeof r=="function"&&(o=r,r=void 0),typeof n=="function"&&(o=n,n=null),this.readyState==="closing"||this.readyState==="closed")return;n=n||{},n.compress=n.compress!==!1;let s={type:t,data:r,options:n};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),o&&this.once("flush",o),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},n=()=>{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?n():t()}):this.upgrading?n():t()),this}_onError(t){if(Rs.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(),tc&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let n=Ts.indexOf(this._offlineEventListener);n!==-1&&Ts.splice(n,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};Ps.protocol=Za;var Hk=class extends Ps{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;Ps.priorWebsocketSuccess=!1;let n=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Ps.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 u=new Error("probe error");u.transport=t.name,this.emitReserved("upgradeError",u)}}))};function o(){r||(r=!0,l(),t.close(),t=null)}let s=p=>{let u=new Error("probe error: "+p);u.transport=t.name,o(),this.emitReserved("upgradeError",u)};function i(){s("transport closed")}function a(){s("socket closed")}function c(p){t&&p.name!==t.name&&o()}let l=()=>{t.removeListener("open",n),t.removeListener("error",s),t.removeListener("close",i),this.off("close",a),this.off("upgrading",c)};t.once("open",n),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}},sc=class extends Hk{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(n=>$kn).filter(n=>!!n)),super(e,r)}};var $N=sc.protocol;function Wk(e,t="",r){let n=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),n=Ss(e)),n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443")),n.path=n.path||"/";let o=n.host.indexOf(":")!==-1?""+n.host+"":n.host;return n.id=n.protocol+"://"+o+":"+n.port+t,n.href=n.protocol+"://"+o+(r&&r.port===n.port?"":":"+n.port),n}function Wt(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var qk=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),Fp=class extends Se{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=Wt(e,"open",this.onopen.bind(this)),Wt(e,"packet",this.onpacket.bind(this)),Wt(e,"error",this.onerror.bind(this)),Wt(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,n,o;if(qk.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:ne.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=(n=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||n===void 0?void 0:n.writable,a=this.connected&&!(!((o=this.io.engine)===null||o===void 0)&&o._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 n=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(n===void 0){this.ackse=t;return}let o=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"))},n),s=(...i)=>{this.io.clearTimeoutFn(o),t.apply(this,i)};s.withError=!0,this.ackse=s}emitWithAck(e,...t){return new Promise((r,n)=>{let o=(s,i)=>s?n(s):r(i);o.withError=!0,t.push(o),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((n,...o)=>r!==this._queue0?void 0:(n!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(n)):(this._queue.shift(),t&&t(null,...o)),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:ne.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 ne.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 ne.EVENT:case ne.BINARY_EVENT:this.onevent(e);break;case ne.ACK:case ne.BINARY_ACK:this.onack(e);break;case ne.DISCONNECT:this.ondisconnect();break;case ne.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(...n){r||(r=!0,t.packet({type:ne.ACK,id:e,data:n}))}}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:ne.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 In(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}In.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};In.prototype.reset=function(){this.attempts=0};In.prototype.setMin=function(e){this.ms=e};In.prototype.setMax=function(e){this.max=e};In.prototype.setJitter=function(e){this.jitter=e};var ic=class extends Se{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,bo(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 In({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let n=t.parser||Va;this.encoder=new n.Encoder,this.decoder=new n.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 sc(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let n=Wt(t,"open",function(){r.onopen(),e&&e()}),o=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=Wt(t,"error",o);if(this._timeout!==!1){let i=this._timeout,a=this.setTimeoutFn(()=>{n(),o(new Error("timeout")),t.close()},i);this.opts.autoUnref&&a.unref(),this.subs.push(()=>{this.clearTimeoutFn(a)})}return this.subs.push(n),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(Wt(e,"ping",this.onping.bind(this)),Wt(e,"data",this.ondata.bind(this)),Wt(e,"error",this.onerror.bind(this)),Wt(e,"close",this.onclose.bind(this)),Wt(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){yo(()=>{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 Fp(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(n=>{n?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",n)):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)}},xo={};function Mn(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=Wk(e,t.path||"/socket.io"),n=r.source,o=r.id,s=r.path,i=xoo&&s in xoo.nsps,a=t.forceNew||t"force new connection"||t.multiplex===!1||i,c;return a?c=new ic(n,t):(xoo||(xoo=new ic(n,t)),c=xoo),r.query&&!t.query&&(t.query=r.queryKey),c.socket(r.path,t)}Object.assign(Mn,{Manager:ic,Socket:Fp,io:Mn,connect:Mn});var jp=" must not return ",zk="transformer",Gk="recoverer",Kk="defaultValue",dM=zk+jp,Up="called with ",fM=Kk+" must not be ",mM=Gk+jp,Yk="Ok",Bp="Err",Vk=Up+Bp,Xk=Up+Yk,hM="Carrying E in "+Bp+" instead of throwing it directly. See .cause",ac="an instance of Error of the current realm.",gM="The thrown value is not "+ac,yM="The contained E should be "+ac,bM="This .cause is not "+ac;function Kr(e){return e.ok}function ce(e){return{ok:!0,val:e,err:null}}function K(e){return!e.ok}function Ae(e){return{ok:!1,val:null,err:e}}function V(e){return Jk(e,Vk)}function Tr(e){return Qk(e,Xk)}function Jk(e,t){if(K(e))throw new TypeError(t);return e.val}function Qk(e,t){if(Kr(e))throw new TypeError(t);return e.err}function cc(e){return e.val}function Hp(e){return e.err}async function Wp(e,t){if(K(e))return e;let r=cc(e);return await t(r)}function Dn(e,t){if(K(e))return e;let r=cc(e),n=t(r);return ce(n)}async function ve(e,t){if(K(e))return e;let r=cc(e),n=await t(r);return ce(n)}async function ke(e,t){if(Kr(e))return e;let r=Hp(e),n=await t(r);return Ae(n)}async function lc(e,t){if(Kr(e))return e;let r=Hp(e);return await t(r)}var ze=e=>{if(e?.connected)return Promise.resolve(ce(e));e??=Mn("https://scrapbox.io",{reconnectionDelay:5e3,transports:["websocket"]});let t=new Promise(r=>{let n=o=>r(Ae(o));e.once("connect",()=>{e.off("disconnect",n),r(ce(e))}),e.once("disconnect",n)});return e.connect(),t},nt=e=>{if(e.disconnected)return Promise.resolve(ce(void 0));let t=new Promise(r=>{let n=o=>{if(o!=="io client disconnect"){r(Ae(o));return}r(ce(void 0)),e.off("disconnect",n)};e.on("disconnect",n)});return e.disconnect(),t};var qp=e=>Zk.includes(e.name),Zk="SocketIOError","DuplicateTitleError","NotFastForwardError";var zp=(e,t,r,n)=>{if(t==="cursor")return e.emit(t,r),Promise.resolve(ce(void 0));let{resolve:o,promise:s,reject:i}=Promise.withResolvers(),a=()=>{e.off("disconnect",c),clearTimeout(p)},c=f=>{if(f==="io client disconnect"){a(),i(new Error("io client disconnect"));return}if(f==="io server disconnect"){a(),o(Ae({name:"SocketIOError"}));return}};e.on("disconnect",c);let l=n?.timeout??9e4,p=setTimeout(()=>{a(),o(Ae({name:"TimeoutError",message:exceeded ${l} (ms)}))},l),u=t==="commit"?{method:"commit",data:r}:{method:"room:join",data:r};return e.emit("socket.io-request",u,f=>{if(a(),"error"in f){o(Ae(qp(f.error)?f.error:{name:"UnexpectedRequestError",...f}));return}o(ce(f.data))}),s};var be=e=>e.ok?ce(e):Ae({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Gp=async(e,t)=>{let r=new Request(e,t);try{return ce(await globalThis.fetch(r))}catch(n){if(n instanceof DOMException&&n.name==="AbortError")return Ae({name:"AbortError",message:n.message,request:r});if(n instanceof TypeError)return Ae({name:"NetworkError",message:n.message,request:r});throw n}};var ie=e=>{let{fetch:t=Gp,hostName:r="scrapbox.io",...n}=e;return{fetch:t,hostName:r,...n}};var Kp=e=>{let{sid:t,hostName:r}=ie(e??{});return new Request(https://${r}/api/users/me,t?{headers:{Cookie:xe(t)}}:void 0)},Yp=e=>ve(be(e),async t=>await t.json()),_s=(()=>{let e=async t=>{let{fetch:r,...n}=ie(t??{}),o=await r(Kp(n));return K(o)?o:Yp(V(o))};return e.toRequest=Kp,e.fromResponse=Yp,e})();var xe=e=>connect.sid=${e},Jt=async e=>{let t=e?.csrf??globalThis._csrf;return t?ce(t):Dn(await _s(e),r=>r.csrfToken)};function Ls(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:t0(e,t);case"function":return e.name||"(anonymous)"}return e?.toString()??"undefined"}function e0(e,t){let{threshold:r=20}=t,n=e.map(i=>Ls(i,t)),o=n.join(", ");if(o.length<=r)return[${o}];let s=n.join(`, );return[
${Vp(2,s)}
]}function t0(e,t){let{threshold:r=20}=t,n=[...Object.keys(e),...Object.getOwnPropertySymbols(e)].map(i=>${i.toString()}: ${Ls(ei,t)}),o=n.join(", ");if(o.length<=r)return{${o}};let s=n.join(, );return{
${Vp(2,s)}
}}function Vp(e,t){let r=" ".repeat(e);return t.split(
).map(n=>${r}${n}).join(
)}function Ge(e,t,...r){let n;return Object.defineProperties(e,{name:{get:()=>n||(n=${t}(${r.map(o=>Ls(o)).join(", ")}),n)}})}function cr(e){return Array.isArray(e)}function uc(e){return Ge(t=>cr(t)&&t.every(r=>e(r)),"isArrayOf",e)}function Cs(e){let t=new Set(e);return Ge(r=>t.has(r),"isLiteralOneOf",e)}function wo(e){return e!=null&&!Array.isArray(e)&&typeof e=="object"}function Ke(e){return typeof e=="string"}var Me=async(e,t)=>{let r=e.response.clone(),n=Cs(t);try{let o=await r.json();if(!wo(o))return;if(r.status===422){if(!Ke(o.message))return;for(let s of["NoQueryError","InvalidURLError"])if(t.includes(s))return{name:s,message:o.message}}return!n(o.name)||!Ke(o.message)?void 0:o.name==="NotLoggedInError"?!wo(o.detals)||!Ke(o.detals.project)||!uc(r0)(o.detals.loginStrategies)?void 0:{name:o.name,message:o.message,details:{project:o.detals.project,loginStrategies:o.detals.loginStrategies}}:{name:o.name,message:o.message}}catch(o){if(o instanceof SyntaxError)return;throw o}},r0=Cs(["google","github","microsoft","gyazo","email","saml","easy-trial"]);var re=e=>e.replaceAll(" ","_").toLowerCase();var ue=e=>[...e].map((t,r)=>t===" "?"_":!n0.includes(t)||r===e.length-1&&o0.includes(t)?encodeURIComponent(t):t).join(""),n0='@$&+=:;",',o0=':;",';var Xp=" must not return ",s0="transformer",i0="recoverer",a0="defaultValue",c0=s0+Xp,l0="called with ",u0=a0+" must not be ",p0=i0+Xp,Os="null or undefined",iI=c0+Os,aI=l0+Os,d0=u0+Os,cI=p0+Os;function pc(e){return e!=null}function f0(e){return e==null}function m0(e,t){if(pc(e))return e;throw new TypeError(t)}function Jp(e){return{ok:!0,val:e,err:null}}function Qp(e){return{ok:!1,val:null,err:e}}function Zp(e,t){if(pc(e))return Jp(e);let r=t();return Qp(r)}function dc(e){return f0(e)?Qp(void 0):Jp(e)}function ed(e,t){return pc(e)?e:m0(t,d0)}var td=(e,t,r)=>{let{sid:n,hostName:o,followRename:s,projects:i}=ie(r??{}),a=new URLSearchParams([["followRename",${s??!0}],...i?.map?.(c=>["projects",c])??[]]);return new Request(https://${o}/api/pages/${e}/${ue(t)}?${a},n?{headers:{Cookie:xe(n)}}:void 0)},rd=async e=>ke(await ve(be(e),t=>t.json()),async t=>t.response.status===414?{name:"TooLongURIError",message:"project ids may be too much."}:ed(await Me(t,["NotFoundError","NotLoggedInError","NotMemberError"]),t)),Nt=(()=>{let e=async(t,r,n)=>Wp(await ie(n??{}).fetch(td(t,r,n)),o=>rd(o));return e.toRequest=td,e.fromResponse=rd,e})();var nd=(e,t)=>{let{sid:r,hostName:n}=ie(t??{});return new Request(https://${n}/api/projects/${e},r?{headers:{Cookie:xe(r)}}:void 0)},od=async e=>ve(await ke(be(e),async t=>await Me(t,["NotFoundError","NotLoggedInError","NotMemberError"])??t),t=>t.json()),lr=(()=>{let e=async(t,r)=>{let{fetch:n}=ie(r??{}),o=nd(t,r),s=await n(o);return K(s)?s:od(V(s))};return e.toRequest=nd,e.fromResponse=od,e})(),sd=(e,t)=>{let{sid:r,hostName:n}=ie(t??{}),o=new URLSearchParams(e.map(s=>["ids",s]));return new Request(https://${n}/api/projects?${o},r?{headers:{Cookie:xe(r)}}:void 0)},id=async e=>ve(await ke(be(e),async t=>await Me(t,["NotLoggedInError"])??t),t=>t.json()),Ns=(()=>{let e=async(t,r)=>{let{fetch:n}=ie(r??{}),o=await n(sd(t,r));return K(o)?o:id(V(o))};return e.toRequest=sd,e.fromResponse=id,e})();var mc=async(e,t,r)=>{let[n,o,s]=await Promise.all([Nt(e,t,r),h0(r),g0(e,r)]);return K(n)?n:K(o)?o:K(s)?s:ce({...V(n),projectId:V(s),userId:V(o)})},fc,h0=async e=>{if(fc)return ce(fc);let t=await _s(e);if(K(t))return t;let r=V(t);return"id"in r?(fc=r.id,ce(r.id)):Ae({name:"NotLoggedInError",message:"This script cannot be used without login"})},ad=new Map,g0=async(e,t)=>{let r=ad.get(e);return r?ce(r):Dn(await lr(e,t),({id:n})=>(ad.set(e,n),n))};function Ee(e,t={}){let{signal:r,persistent:n=!0}=t;return r?.aborted?Promise.reject(r.reason):new Promise((o,s)=>{let i=()=>{clearTimeout(c),s(r?.reason)},c=setTimeout(()=>{r?.removeEventListener("abort",i),o()},e);if(r?.addEventListener("abort",i,{once:!0}),n===!1)try{Deno.unrefTimer(c)}catch(l){if(!(l instanceof ReferenceError))throw l;console.error("persistent option is only available in Deno")}})}var Yr=async(e,t,r,n)=>{let o=await ze(n?.socket);if(K(o))return Ae({name:"UnexpectedRequestError",error:Tr(o)});let s=V(o),i=await mc(e,t);if(K(i))return i;let a=V(i);try{let c=0,l=[],p;for(;n?.maxAttempts===void 0||c<n.maxAttempts;){let u=r(a,c,l,p);if(l=u instanceof Promise?await u:u,c++,l.length===0)return ce(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 d=await zp(s,"commit",f);if(Kr(d))return a.commitId=V(d).commitId,ce(a.commitId);let h=Tr(d),g=h.name;if(g==="SocketIOServerDisconnectError"||g==="UnexpectedRequestError")return Ae(h);if(g==="TimeoutError"||g==="SocketIOError"){await Ee(3e3);continue}if(g==="NotFastForwardError"){await Ee(1e3);let y=await mc(e,t);if(K(y))return y;a=V(y)}p=g;break}}return Ae({name:"RetryError",attempts:c,message:Retrying exceeded the maxAttempts (${c}).})}finally{n?.socket||await nt(s)}};var hc=(e,t)=>{let r=e.length>t.length,n=r?t:e,o=r?e:t,s=n.length+1,i=n.length+o.length+3,a=new Array(i);a.fill(-1);let c=[];function l(g,y,w){let R=Math.max(y,w),E=R-g;for(;E<n.length&&R<o.length&&n[E]===o[R];)++E,++R;return a[g+s]=c.length,c.push([{x:E,y:R},a[g+(y>w?-1:1)+s]]),R}let p=new Array(i);p.fill(-1);let u=-1,f=o.length-n.length;do{++u;for(let g=-u;g<=f-1;++g)p[g+s]=l(g,p[g-1+s]+1,p[g+1+s]);for(let g=f+u;g>=f+1;--g)p[g+s]=l(g,p[g-1+s]+1,p[g+1+s]);p[f+s]=l(f,p[f-1+s]+1,p[f+1+s])}while(p[f+s]!==o.length);let d=[],h=a[f+s];for(;h!==-1;)d.push(c[h][0]),h=c[h][1];return{from:e,to:t,editDistance:f+u*2,buildSES:function*(){let g=0,y=0;for(let{x:w,y:R}of y0(d))for(;g<w||y<R;)R-w>y-g?(yield{value:o[y],type:r?"deleted":"added"},++y):R-w<y-g?(yield{value:n[g],type:r?"added":"deleted"},++g):(yield{value:n[g],type:"common"},++g,++y)}}};function*gc(e){let t=[],r=[];function*n(){if(t.length>r.length){for(let o=0;o<r.length;o++)yield cd(t[o],r[o]);for(let o=r.length;o<t.length;o++)yield t[o]}else{for(let o=0;o<t.length;o++)yield cd(t[o],r[o]);for(let o=t.length;o<r.length;o++)yield r[o]}t=[],r=[]}for(let o of e)switch(o.type){case"added":t.push(o);break;case"deleted":r.push(o);break;case"common":yield*n(),yield o;break}yield*n()}var cd=(e,t)=>({value:e.value,oldValue:t.value,type:"replaced"});function*y0(e){for(let t=e.length-1;t>=0;t--)yield e[t]}var ld=e=>e.padStart(8,"0"),yc=e=>{let t=Math.floor(new Date().getTime()/1e3).toString(16),r=Math.floor(16777214*Math.random()).toString(16);return${ld(t).slice(-8)}${e.slice(-6)}0000${ld(r)}};function*bc(e,t,{userId:r}){let{buildSES:n}=hc(e.map(({text:i})=>i),t),o=0,s=e[0].id;for(let i of gc(n())){switch(i.type){case"added":yield{_insert:s,lines:{id:yc(r),text:i.value}};continue;case"deleted":yield{_delete:s,lines:-1};break;case"replaced":yield{_update:s,lines:{text:i.value}};break}o++,s=e[o]?.id??"_end"}}var b0=(e,t)=>(e.type==="codeBlock"||e.type==="table")&&t.indent>(e.rows[0]?.indent??0),ud=(e,t)=>{let r=e[e.length-1];return r!==void 0&&b0(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)},pd=(e,t)=>{if(t.hasTitle??!0){let[r,...n]=e;return r===void 0?[]:[{type:"title",rows:[r]},...n.reduce(ud,[])]}return e.reduce(ud,[])};var dd=e=>e.split( ).map(t=>({indent:/^\s+/.exec(t)?.[0]?.length??0,text:t}));var fd=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*code:/,"");return{indent:n,type:"codeBlock",fileName:s,content:r.map(i=>i.text.substring(n+1)).join(
)}};var oe=(e,{parseOnNested:t,parseOnQuoted:r,patterns:n})=>(o,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let a of n){let c=a.exec(o);if(c===null)continue;let l=o.substring(0,c.index),p=o.substring(c.index+(c[0]?.length??0)),u=e(c[0]??"",s);return[...mt(l,s),...u,...mt(p,s)]}return i?.()??[]};var le=e=>[{type:"plain",raw:e,text:e}],md=oe(le,{parseOnNested:!0,parseOnQuoted:!0,patterns:[/^()(.*)()$/]});var x0=/\[\s+\]/,w0=(e,t)=>t.context==="table"?le(e,t):[{type:"blank",raw:e,text:e.substring(1,e.length-1)}],hd=oe(w0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[x0]});var v0=/.*?/,k0=(e,t)=>t.context==="table"?le(e,t):[{type:"code",raw:e,text:e.substring(1,e.length-1)}],gd=oe(k0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[v0]});var E0=/^[$%] .+$/,T0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e[0]??"",n=e.substring(2);return[{type:"commandLine",raw:e,symbol:r,text:n}]},yd=oe(T0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[E0]});var P0=/\[[!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\]]+\]|[^\]])+\]/,R0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.indexOf(" "),n=e.substring(1,r),o=e.substring(r+1,e.length-1),s=new Set(n);if(s.has("*")){let i=n.split("*").length-1;s.delete("*"),s.add(*-${Math.min(i,10)})}return[{type:"decoration",raw:e,rawDecos:n,decos:Array.from(s),nodes:mt(o,{...t,nested:!0})}]},bd=oe(R0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[P0]});var S0=/\[https?:\/\/[^\s\]]+\s+[^\]]*[^\s]\]/,_0=/\[[^[\]]*[^\s]\s+https?:\/\/[^\s\]]+\]/,L0=/\[https?:\/\/[^\s\]]+\]/,C0=/https?:\/\/[^\s]+/,O0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.startsWith("[")&&e.endsWith("]")?e.substring(1,e.length-1):e,n=/^https?:\/\/[^\s\]]/.test(r),o=(n?/^https?:\/\/[^\s\]]+/:/https?:\/\/[^\s\]]+$/).exec(r);if(o?.[0]===void 0)return[];let s=n?r.substring(o[0].length):r.substring(0,o.index-1);return[{type:"link",raw:e,pathType:"absolute",href:o[0],content:s.trim()}]},xd=oe(O0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[S0,_0,L0,C0]});var N0=/\[\$ .+? \]/,M0=/\[\$ [^\]]+\]/,I0=(e,t)=>t.context==="table"?le(e,t):[{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ]")?2:1))}],wd=oe(I0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[N0,M0]});var vd=/\[([^\]]*[^\s])\s+([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)\]/,kd=/\[([NS]\d+(?:\.\d+)?,[EW]\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+([^\]]*[^\s]))?\]/,D0=e=>{let[t="",r="",n=""]=e.split(","),o=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(n)?Number.parseInt(n.replace(/^Z/,""),10):14;return{latitude:o,longitude:s,zoom:i}},A0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.match(vd)??e.match(kd);if(r===null)return[];let n=e.startsWith("[N")||e.startsWith("[S"),[,o="",s=""]=n?r:[r[0],r[2],r[1]],{latitude:i,longitude:a,zoom:c}=D0(o),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}]},Ed=oe(A0,{parseOnNested:!1,parseOnQuoted:!0,patterns:[vd,kd]});var $0=/(?:^|\s)#\S+/,F0=(e,t)=>{if(t.context==="table")return le(e,t);if(e.startsWith("#"))return[{type:"hashTag",raw:e,href:e.substring(1)}];let r=e.substring(0,1),n=e.substring(1);return[...le(r,t),{type:"hashTag",raw:n,href:n.substring(1)}]},Td=oe(F0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[$0]});var j0=/^\? .+$/,U0=(e,t)=>t.context==="table"?le(e,t):[{type:"helpfeel",raw:e,text:e.substring(2)}],Pd=oe(U0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[j0]});var B0=/\[[^[\]]*\.icon(?:\*[1-9]\d*)?\]/,H0=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),n=t.substring(0,r),o=n.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:n,pathType:o,type:"icon",raw:e}))},Rd=oe(H0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[B0]});var W0=/\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?(?:\s+https?:\/\/[^\s\]]+)?\]/i,q0=/\[https?:\/\/[^\s\]]+\s+https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)(?:\?[^\]\s]+)?\]/i,z0=/\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?(?:\s+https?:\/\/[^\s\]]+)?\]/,G0=/\[https?:\/\/[^\s\]]+\s+https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}(?:\/raw)?\]/,K0=e=>/^https?:\/\/[^\s\]]+\.(png|jpe?g|gif|svg|webp)(\?[^\]\s]+)?$/i.test(e)||Y0(e),Y0=e=>/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}(\/raw)?$/.test(e),V0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.search(/\s/),n=r!==-1?e.substring(1,r):e.substring(1,e.length-1),o=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",[s,i]=K0(o)?[o,n]:[n,o];return[{type:"image",raw:e,src:/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(s)?${s}/thumb/1000:s,link:i}]},Sd=oe(V0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[W0,q0,z0,G0]});var X0=/\[\/?[^[\]]+\]/,J0=e=>{let t=e.substring(1,e.length-1);return[{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}]},_d=oe(J0,{parseOnNested:!0,parseOnQuoted:!0,patterns:[X0]});var Q0=/^[0-9]+\. .*$/,Z0=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.indexOf(" "),n=e.substring(0,r-1),o=Number.parseInt(n,10),s=e.substring(r+1,e.length);return[{type:"numberList",raw:e,rawNumber:n,number:o,nodes:mt(s,{...t,nested:!1})}]},Ld=oe(Z0,{parseOnNested:!1,parseOnQuoted:!1,patterns:[Q0]});var eE=/^>.*$/,tE=(e,t)=>t.context==="table"?le(e,t):[{type:"quote",raw:e,nodes:mt(e.substring(1),{...t,quoted:!0})}],Cd=oe(tE,{parseOnNested:!1,parseOnQuoted:!1,patterns:[eE]});var rE=/\[\[[^[\]]*\.icon(?:\*\d+)?\]\]/,nE=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.substring(2,e.length-2),n=r.lastIndexOf(".icon"),o=r.substring(0,n),s=o.startsWith("/")?"root":"relative",i=r.substring(n+5,r.length),a=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(a).fill({}).map(()=>({path:o,pathType:s,type:"strongIcon",raw:e}))},Od=oe(nE,{parseOnNested:!1,parseOnQuoted:!0,patterns:[rE]});var oE=/\[\[https?:\/\/[^\s\]]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,sE=/\[\[https?:\/\/(?:[0-9a-z-]+\.)?gyazo\.com\/[0-9a-f]{32}\]\]/,iE=(e,t)=>{if(t.context==="table")return le(e,t);let r=e.substring(2,e.length-2),n=/^https?:\/\/([0-9a-z-]\.)?gyazo\.com\/[0-9a-f]{32}$/.test(r);return[{type:"strongImage",raw:e,src:n?${r}/thumb/1000:r}]},Nd=oe(iE,{parseOnNested:!1,parseOnQuoted:!0,patterns:[oE,sE]});var aE=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,cE=(e,t)=>t.context==="table"?le(e,t):[{type:"strong",raw:e,nodes:mt(e.substring(2,e.length-2),{...t,nested:!0})}],Md=oe(cE,{parseOnNested:!1,parseOnQuoted:!0,patterns:[aE]});var lE=(e,t,r)=>e===""?[]:r?.()??[],uE=(...e)=>(t,r)=>e.reduceRight((n,o)=>()=>o(t,r,n),()=>md(t,r))(),mt=uE(lE,Cd,Pd,Ld,gd,yd,wd,hd,bd,Nd,Od,Md,Sd,xd,Rd,Ed,_d,Td);var Id=e=>{let{indent:t,text:r}=e.rows[0];return{indent:t,type:"line",nodes:mt(r.substring(t),{nested:!1,quoted:!1,context:"line"})}};var Dd=e=>{let{rows:[t,...r]}=e,{indent:n=0,text:o=""}=t??{},s=o.replace(/^\s*table:/,"");return{indent:n,type:"table",fileName:s,cells:r.map(i=>i.text.substring(n+1)).map(i=>i.split(" ").map(a=>mt(a,{nested:!1,quoted:!1,context:"table"})))}};var Ad=e=>({type:"title",text:e.rows[0].text});var $d=e=>{switch(e.type){case"title":return Ad(e);case"codeBlock":return fd(e);case"table":return Dd(e);case"line":return Id(e)}};var Be=(e,t)=>{let r=dd(e);return pd(r,{hasTitle:t?.hasTitle??!0}).map($d)},Fd=e=>/^\s*\S.*$/m.exec(e)?.[0]?.trim()??"Untitled";var pE=/https?:\/\/(?:www\.|music\.|)youtube\.com\/watch/,dE=/https?:\/\/youtu\.be\/([a-zA-Z\d_-]+)(?:\?([^\s]{0,100})|)/,fE=/https?:\/\/(?:www\.|)youtube\.com\/shorts\/([a-zA-Z\d_-]+)(?:\?([^\s]+)|)/,mE=/https?:\/\/(?:www\.|music\.|)youtube\.com\/playlist\?((?:[^\s]+&|)list=([a-zA-Z\d_-]+)(?:&[^\s]+|))/,Ms=e=>{if(pE.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(dE);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"dotbe"}}}{let t=e.match(fE);if(t){let[,r,n]=t;return{videoId:r,params:new URLSearchParams(n),pathType:"short"}}}{let t=e.match(mE);if(t){let[,r,n]=t;return{listId:n,params:new URLSearchParams(r),pathType:"list"}}}};var Ud=e=>{let t=Be(e,{hasTitle:!0}).flatMap(h=>{switch(h.type){case"codeBlock":case"title":return[];case"line":case"table":return h}}),r=new Map,n=[],o=new Set,s=[],i=new Set,a=[],c=null,l=new Set,p=new Set,u=new RegExp(${location?.origin??"https://scrapbox.io"}/files/([a-z0-9]{24})(?:|\\.[a-zA-Z0-9]+)(?:|\\?[^\\s]*)$),f=h=>{switch(h.type){case"hashTag":if(r.has(re(h.href)))return;r.set(re(h.href),!1),n.push(h.href);return;case"link":switch(h.pathType){case"relative":{let g=jd(h.href);if(r.get(re(g)))return;r.set(re(g),!0),n.push(g);return}case"root":{let g=jd(h.href);if(/^\/[\w\d-]+\/?$/.test(g)||o.has(re(g)))return;o.add(re(g)),s.push(g);return}case"absolute":{if(h.content)return;let g=Ms(h.href);if(g&&g.pathType!=="list"){c??=https://i.ytimg.com/vi/${g.videoId}/mqdefault.jpg;return}let y=h.href.match(u)?.[1];y&&l.add(y);return}default:return}case"icon":case"strongIcon":{if(h.pathType==="root"||i.has(re(h.path)))return;i.add(re(h.path)),a.push(h.path);return}case"image":case"strongImage":{c??=h.src.endsWith("/thumb/1000")?h.src.replace(/\/thumb\/1000$/,"/raw"):h.src;{let g=h.src.match(u)?.[1];g&&l.add(g)}if(h.type==="image"){let g=h.link.match(u)?.[1];g&&l.add(g)}return}case"helpfeel":p.add(h.text);return;case"numberList":case"strong":case"quote":case"decoration":{for(let g of h.nodes)f(g);return}default:return}},d=[];for(let h of t)switch(h.type){case"line":for(let g of h.nodes)f(g);continue;case"table":{for(let g of h.cells)for(let y of g)for(let w of y)f(w);if(!["infobox","cosense"].includes(h.fileName))continue;d.push(...h.cells.map(g=>g.map(y=>y.map(w=>w.raw).join("")).join(" ").trim()));continue}}return[n,s,a,c,[...l],[...p],d]},jd=e=>e.replace(/#[a-f\d]{24,32}$/,""),Bd=e=>e.flatMap(({text:t})=>/^\s*\? .*$/.test(t)?[t.trimStart().slice(2)]:[]);var Vr=(e,t)=>e.length===t.length&&e.every(r=>t.includes(r));function*Hd(e,t,r){let n=t.flatMap(d=>d.split( ));for(let d of bc(e.lines,n,{userId:r}))yield d;(e.lines[0].text!==n[0]||!e.persistent)&&(yield{title:n[0]});let o=e.lines.slice(1,6).map(d=>d.text),s=n.slice(1,6);o.join("")!==s.join("")&&(yield{descriptions:s});let[i,a,c,l,p,u,f]=Ud(n.join(
));Vr(e.links,i)||(yield{links:i}),Vr(e.projectLinks,a)||(yield{projectLinks:a}),Vr(e.icons,c)||(yield{icons:c}),e.image!==l&&(yield{image:l}),Vr(e.files,p)||(yield{files:p}),Vr(Bd(e.lines),u)||(yield{helpfeels:u}),Vr(e.infoboxDefinition,f)||(yield{infoboxDefinition:f})}var Wd=e=>{let t=e.match(/(.+?)(?:_(\d+))?$/),r=t?.[1]??e,n=t?.[2]?parseInt(t[2])+1:2;return${r}_${n}};var me=(e,t,r,n)=>Yr(e,t,async(o,s,i,a)=>{if(a==="DuplicateTitleError"){let p=Wd(t);return i.map(u=>("title"in u&&(u.title=p),u))}let c=r(o.lines,{...o,attempts:s}),l=c instanceof Promise?await c:c;return l===void 0?[]:l.length===0?[{deleted:!0}]:[...Hd(o,l,o.userId)]},n);var qd=(e,t,r)=>Yr(e,t,n=>n.persistent?[{deleted:!0}]:[],r);var Is=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i}=ie(n??{}),a=await Jt(n);if(K(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":V(a),...o?{Cookie:xe(o)}:{}},body:JSON.stringify({from:t,to:r})}),l=await i(c);return K(l)?l:ve(await ke(be(V(l)),async p=>await Me(p,["NotFoundError","NotLoggedInError","NotMemberError"])??p),async p=>{let{message:u}=await p.json();return parseInt(u.match(/\d+/)?.[0]??"0")})};var zd=(e,t)=>{let{sid:r,hostName:n,followingId:o}=ie(t??{});return new Request(https://${n}/api/pages/${e}/search/titles${o??followingId=${o}:""},r?{headers:{Cookie:xe(r)}}:void 0)},Gd=async e=>ve(await ke(be(e),async t=>t.response.status===422?{name:"InvalidFollowingIdError",message:await t.response.text()}:await Me(t,["NotFoundError","NotLoggedInError"])??t),t=>t.json().then(r=>({pages:r,followingId:t.headers.get("X-following-id")??""}))),yE=(()=>{let e=async(t,r)=>{let n=await ie(r??{}).fetch(zd(t,r));return K(n)?n:Gd(V(n))};return e.toRequest=zd,e.fromResponse=Gd,e})();async function*Kd(e,t){let r;do{let n=await yE(e,{followingId:r,...t});if(K(n)){yield n;return}let o=V(n);yield ce(o.pages),r=o.followingId}while(r)}var Yd=async(e,t,r)=>{let{sid:n,hostName:o,fetch:s}=ie(r??{}),i=new Request(https://${o}/api/pages/${t}/search/query?q=${encodeURIComponent(e)},n?{headers:{Cookie:xe(n)}}:void 0),a=await s(i);return K(a)?a:ve(await ke(be(V(a)),async c=>await Me(c,["NotFoundError","NotLoggedInError","NotMemberError","NoQueryError"])??c),c=>c.json())};var Vd=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=ie(t??{}),s=await Jt(t);if(K(s))return s;let i=new Request(https://${n}/api/embed-text/url?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":V(s),...r?{Cookie:xe(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(i);return K(a)?a:ve(await ke(be(V(a)),async c=>await Me(c,["SessionError","BadRequestError","InvalidURLError"])??c),async c=>{let{title:l}=await c.json();return l})};var Xd=async(e,t)=>{let{sid:r,hostName:n,fetch:o}=ie(t??{}),s=await Jt(t);if(K(s))return s;let i=new Request(https://${n}/api/embed-text/twitter?url=${encodeURIComponent(${e})},{method:"POST",headers:{"Content-Type":"application/json;charset=utf-8","X-CSRF-TOKEN":V(s),...r?{Cookie:xe(r)}:{}},body:JSON.stringify({timeout:3e3})}),a=await o(i);return K(a)?a:ke(await ve(be(V(a)),c=>c.json()),async c=>c.response.status===422?{name:"InvalidURLError",message:(await c.response.json()).message}:await Me(c,["SessionError","BadRequestError"])??c)};var Jd=async e=>{let{fetch:t,sid:r,hostName:n,gyazoTeamsName:o}=ie(e??{}),s=new Request(https://${n}/api/login/gyazo/oauth-upload/token${o??gyazoTeamsName=${o}:""},r?{headers:{Cookie:xe(r)}}:void 0),i=await t(s);return K(i)?i:ve(await ke(be(V(i)),async a=>await Me(a,["NotLoggedInError"])??a),a=>a.json().then(c=>c.token))};var Qd=(e,t,r,n)=>{let{sid:o,hostName:s}=ie(n??{});return new Request(https://${s}/api/code/${e}/${ue(t)}/${ue(r)},o?{headers:{Cookie:xe(o)}}:void 0)},Zd=async e=>ve(await ke(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 Me(t,["NotLoggedInError","NotMemberError"])??t),t=>t.text()),Ds=(()=>{let e=async(t,r,n,o)=>{let s=Qd(t,r,n,o),i=await ie(o??{}).fetch(s);return K(i)?i:Zd(V(i))};return e.toRequest=Qd,e.fromResponse=Zd,e})();var rf=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],n=new Uint8Array(xc),o=0,s=0,i=0;[r,n,o,s,i]=tf(r,n,o,s,i,t);let a=xc-o;a<9&&(a+=xc);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,n,o,s,i]=tf(r,n,o,s,i,new Uint8Array(c.buffer));let l=new ArrayBuffer(16),p=new DataView(l);return p.setUint32(0,r[0],!0),p.setUint32(4,r[1],!0),p.setUint32(8,r[2],!0),p.setUint32(12,r[3],!0),l},xc=64,U=(e,t)=>e<<t|e>>>32-t,lt=(e,t)=>e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24,ef=(e,t)=>{let[r,n,o,s]=e,i=lt(t,0),a=lt(t,4),c=lt(t,8),l=lt(t,12),p=lt(t,16),u=lt(t,20),f=lt(t,24),d=lt(t,28),h=lt(t,32),g=lt(t,36),y=lt(t,40),w=lt(t,44),R=lt(t,48),E=lt(t,52),b=lt(t,56),k=lt(t,60);return r=n+U(((o^s)&n^s)+r+i+3614090360,7),s=r+U(((n^o)&r^o)+s+a+3905402710,12),o=s+U(((r^n)&s^n)+o+c+606105819,17),n=o+U(((s^r)&o^r)+n+l+3250441966,22),r=n+U(((o^s)&n^s)+r+p+4118548399,7),s=r+U(((n^o)&r^o)+s+u+1200080426,12),o=s+U(((r^n)&s^n)+o+f+2821735955,17),n=o+U(((s^r)&o^r)+n+d+4249261313,22),r=n+U(((o^s)&n^s)+r+h+1770035416,7),s=r+U(((n^o)&r^o)+s+g+2336552879,12),o=s+U(((r^n)&s^n)+o+y+4294925233,17),n=o+U(((s^r)&o^r)+n+w+2304563134,22),r=n+U(((o^s)&n^s)+r+R+1804603682,7),s=r+U(((n^o)&r^o)+s+E+4254626195,12),o=s+U(((r^n)&s^n)+o+b+2792965006,17),n=o+U(((s^r)&o^r)+n+k+1236535329,22),r=n+U(((n^o)&s^o)+r+a+4129170786,5),s=r+U(((r^n)&o^n)+s+f+3225465664,9),o=s+U(((s^r)&n^r)+o+w+643717713,14),n=o+U(((o^s)&r^s)+n+i+3921069994,20),r=n+U(((n^o)&s^o)+r+u+3593408605,5),s=r+U(((r^n)&o^n)+s+y+38016083,9),o=s+U(((s^r)&n^r)+o+k+3634488961,14),n=o+U(((o^s)&r^s)+n+p+3889429448,20),r=n+U(((n^o)&s^o)+r+g+568446438,5),s=r+U(((r^n)&o^n)+s+b+3275163606,9),o=s+U(((s^r)&n^r)+o+l+4107603335,14),n=o+U(((o^s)&r^s)+n+h+1163531501,20),r=n+U(((n^o)&s^o)+r+E+2850285829,5),s=r+U(((r^n)&o^n)+s+c+4243563512,9),o=s+U(((s^r)&n^r)+o+d+1735328473,14),n=o+U(((o^s)&r^s)+n+R+2368359562,20),r=n+U((n^o^s)+r+u+4294588738,4),s=r+U((r^n^o)+s+h+2272392833,11),o=s+U((s^r^n)+o+w+1839030562,16),n=o+U((o^s^r)+n+b+4259657740,23),r=n+U((n^o^s)+r+a+2763975236,4),s=r+U((r^n^o)+s+p+1272893353,11),o=s+U((s^r^n)+o+d+4139469664,16),n=o+U((o^s^r)+n+y+3200236656,23),r=n+U((n^o^s)+r+E+681279174,4),s=r+U((r^n^o)+s+i+3936430074,11),o=s+U((s^r^n)+o+l+3572445317,16),n=o+U((o^s^r)+n+f+76029189,23),r=n+U((n^o^s)+r+g+3654602809,4),s=r+U((r^n^o)+s+R+3873151461,11),o=s+U((s^r^n)+o+k+530742520,16),n=o+U((o^s^r)+n+c+3299628645,23),r=n+U((o^(n|~s))+r+i+4096336452,6),s=r+U((n^(r|~o))+s+d+1126891415,10),o=s+U((r^(s|~n))+o+b+2878612391,15),n=o+U((s^(o|~r))+n+u+4237533241,21),r=n+U((o^(n|~s))+r+R+1700485571,6),s=r+U((n^(r|~o))+s+l+2399980690,10),o=s+U((r^(s|~n))+o+y+4293915773,15),n=o+U((s^(o|~r))+n+a+2240044497,21),r=n+U((o^(n|~s))+r+h+1873313359,6),s=r+U((n^(r|~o))+s+k+4264355552,10),o=s+U((r^(s|~n))+o+f+2734768916,15),n=o+U((s^(o|~r))+n+E+1309151649,21),r=n+U((o^(n|~s))+r+p+4149444226,6),s=r+U((n^(r|~o))+s+w+3174756917,10),o=s+U((r^(s|~n))+o+c+718787259,15),n=o+U((s^(o|~r))+n+g+3951481745,21),[e[0]+r>>>0,e[1]+n>>>0,e[2]+o>>>0,e[3]+s>>>0]},tf=(e,t,r,n,o,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=ef(e,t);let a=i;for(;a+64<=s.length;)e=ef(e,s.slice(a,a+64)),a+=64;t.fill(0).set(s.slice(a),0),r=s.length-a}return[n,o]=bE(n,o,s.length),[e,t,r,n,o]},bE=(e,t,r)=>(e+=r,e>4294967295&&(t+=1),[e>>>0,t]);var xE=new TextEncoder;function wE(e){let t=typeof e;return t!=="object"?t:e===null?"null":e?.constructor?.name??"object"}function nf(e){if(typeof e=="string")return xE.encode(e);if(e instanceof Uint8Array)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new TypeError(Cannot validate the input as it must be a Uint8Array, a string, or an ArrayBuffer: received a value of the type ${wE(e)})}var of=new TextEncoder().encode("0123456789abcdef"),BF=new TextEncoder,vE=new TextDecoder;function sf(e){let t=nf(e),r=new Uint8Array(t.length*2);for(let n=0;n<t.length;n++){let o=t[n];r[n*2]=of[o>>4],r[n*2+1]=of[o&15]}return vE.decode(r)}var af=async(e,t,r)=>{let n=${sf(rf(await e.arrayBuffer()))},o=await kE(e,t,n,r);if(K(o))return o;let s=V(o);if("embedUrl"in s)return ce(s);let i=await EE(s.signedUrl,e,r);return K(i)?i:TE(t,s.fileId,n,r)},kE=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i,csrf:a}=ie(n??{}),c={md5:r,size:e.size,contentType:e.type,name:e.name},l=await lc(dc(a),()=>Jt(n));if(K(l))return l;let p=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":V(l),...o?{Cookie:xe(o)}:{}}}),u=await i(p);return K(u)?u:ve(await ke(be(V(u)),async f=>f.response.status===402?{name:"FileCapacityError",message:(await f.response.json()).message}:f),f=>f.json())},EE=async(e,t,r)=>{let{sid:n,fetch:o}=ie(r??{}),s=await o(e,{method:"PUT",body:t,headers:{"Content-Type":t.type,...n?{Cookie:xe(n)}:{}}});return K(s)?s:Dn(await ke(be(V(s)),async i=>i.response.headers.get("Content-Type")?.includes?.("/xml")?{name:"GCSError",message:await i.response.text()}:i),()=>{})},TE=async(e,t,r,n)=>{let{sid:o,hostName:s,fetch:i,csrf:a}=ie(n??{}),c=await lc(dc(a),()=>Jt(n));if(K(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":V(c),...o?{Cookie:xe(o)}:{}}}),p=await i(l);return K(p)?p:ve(await ke(be(V(p)),async u=>u.response.status===404?{name:"NotFoundError",message:(await u.response.json()).message}:u),u=>u.json())};var cf=" must not return ",PE="transformer",RE="recoverer",SE="defaultValue",xj=PE+cf,lf="called with ",wj=SE+" must not be ",vj=RE+cf,_E="Ok",uf="Err",LE=lf+uf,CE=lf+_E,kj="Carrying E in "+uf+" instead of throwing it directly. See .cause",wc="an instance of Error of the current realm.",Ej="The thrown value is not "+wc,Tj="The contained E should be "+wc,Pj="This .cause is not "+wc;function Pr(e){return e.ok}function we(e){return{ok:!0,val:e,err:null}}function W(e){return!e.ok}function Z(e){return{ok:!1,val:null,err:e}}function B(e){return OE(e,LE)}function ee(e){return NE(e,CE)}function OE(e,t){if(W(e))throw new TypeError(t);return e.val}function NE(e,t){if(Pr(e))throw new TypeError(t);return e.err}function pf(e){return e.val}function ME(e){return e.err}async function Mt(e,t){if(W(e))return e;let r=pf(e),n=await t(r);return we(n)}function df(e,t,r){if(Pr(e)){let o=pf(e);return r(o)}let n=ME(e);return t(n)}var ff=async e=>{let t=e.title??".watchlistrc",r="projectsLastAccessed.json",n=await Ds(e.project,t,r),o=W(n)?{}:JSON.parse(B(n)||"{}"),s=JSON.parse(localStorage.getItem("projectsLastAccessed")??"{}"),i=new Set([...Object.keys(o),...Object.keys(s)]),a=Object.fromEntries([...i].map(l=>[l,Math.max(o[l]??0,s[l]??0)]).sort((l,p)=>p[1]-l[1])),c=JSON.stringify(a);localStorage.setItem("projectsLastAccessed",c),await me(e.project,t,()=>[t,"This page is automatically generated. DO NOT EDIT ANYTHING, WHITCH WILL BE OVERWRITTEN.","",code:${r}, ${c},""])};scrapbox.PageMenu.addMenu({title:"Gyazo",image:"https://i.gyazo.com/503a911fea542532aa5aba0a88eb7b60.png",onClick:()=>window.open("https://gyazo.com/captures")});var js,J,yf,IE,Xr,mf,bf,vc,xf,Pc,kc,Ec,wf,vo={},vf=[],DE=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Us=Array.isArray;function Rr(e,t){for(var r in t)e[r]=t[r];return e}function Rc(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function ur(e,t,r){var n,o,s,i={};for(s in t)s=="key"?n=t[s]:s=="ref"?o=t[s]:i[s]=t[s];if(arguments.length>2&&(i.children=arguments.length>3?js.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 $s(e,i,n,o,null)}function $s(e,t,r,n,o){var s={type:e,props:t,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++yf,__i:-1,__u:0};return o==null&&J.vnode!=null&&J.vnode(s),s}function Y(e){return e.children}function qt(e,t){this.props=e,this.context=t}function An(e,t){if(t==null)return e.__?An(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"?An(e):null}function kf(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 kf(e)}}function Tc(e){(!e.__d&&(e.__d=!0)&&Xr.push(e)&&!Fs.__r++||mf!==J.debounceRendering)&&((mf=J.debounceRendering)||bf)(Fs)}function Fs(){var e,t,r,n,o,s,i,a;for(Xr.sort(vc);e=Xr.shift();)e.__d&&(t=Xr.length,n=void 0,s=(o=(r=e).__v).__e,i=[],a=[],r.__P&&((n=Rr({},o)).__v=o.__v+1,J.vnode&&J.vnode(n),Sc(r.__P,n,o,r.__n,r.__P.namespaceURI,32&o.__u?[s]:null,i,s??An(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,Pf(i,n,a),n.__e!=s&&kf(n)),Xr.length>t&&Xr.sort(vc));Fs.__r=0}function Ef(e,t,r,n,o,s,i,a,c,l,p){var u,f,d,h,g,y,w=n&&n.__k||vf,R=t.length;for(c=AE(r,t,w,c,R),u=0;u<R;u++)(d=r.__k[u])!=null&&(f=d.__i===-1?vo:w[d.__i]||vo,d.__i=u,y=Sc(e,d,f,o,s,i,a,c,l,p),h=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&_c(f.ref,null,d),p.push(d.ref,d.__c||h,d)),g==null&&h!=null&&(g=h),4&d.__u||f.__k===d.__k?c=Tf(d,c,e):typeof d.type=="function"&&y!==void 0?c=y:h&&(c=h.nextSibling),d.__u&=-7);return r.__e=g,c}function AE(e,t,r,n,o){var s,i,a,c,l,p=r.length,u=p,f=0;for(e.__k=new Array(o),s=0;s<o;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?$s(null,i,null,null,null):Us(i)?$s(Y,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?$s(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=$E(i,r,c,u))!==-1&&(u--,(a=r[l])&&(a.__u|=2)),a==null||a.__v===null?(l==-1&&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(u)for(s=0;s<p;s++)(a=r[s])!=null&&!(2&a.__u)&&(a.__e==n&&(n=An(a)),Rf(a,a));return n}function Tf(e,t,r){var n,o;if(typeof e.type=="function"){for(n=e.__k,o=0;n&&o<n.length;o++)n[o]&&(n[o].__=e,t=Tf(n[o],t,r));return t}e.__e!=t&&(t&&e.type&&!r.contains(t)&&(t=An(e)),r.insertBefore(e.__e,t||null),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Sr(e,t){return t=t||[],e==null||typeof e=="boolean"||(Us(e)?e.some(function(r){Sr(r,t)}):t.push(e)),t}function $E(e,t,r,n){var o,s,i=e.key,a=e.type,c=t[r];if(c===null||c&&i==c.key&&a===c.type&&!(2&c.__u))return r;if(n>(c!=null&&!(2&c.__u)?1:0))for(o=r-1,s=r+1;o>=0||s<t.length;){if(o>=0){if((c=t[o])&&!(2&c.__u)&&i==c.key&&a===c.type)return o;o--}if(s<t.length){if((c=t[s])&&!(2&c.__u)&&i==c.key&&a===c.type)return s;s++}}return-1}function hf(e,t,r){t[0]=="-"?e.setProperty(t,r??""):e[t]=r==null?"":typeof r!="number"||DE.test(t)?r:r+"px"}function As(e,t,r,n,o){var s;e:if(t=="style")if(typeof r=="string")e.style.cssText=r;else{if(typeof n=="string"&&(e.style.cssText=n=""),n)for(t in n)r&&t in r||hf(e.style,t,"");if(r)for(t in r)n&&r[t]===n[t]||hf(e.style,t,r[t])}else if(t[0]=="o"&&t[1]=="n")s=t!=(t=t.replace(xf,"$1")),t=t.toLowerCase()in e||t=="onFocusOut"||t=="onFocusIn"?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+s]=r,r?n?r.u=n.u:(r.u=Pc,e.addEventListener(t,s?Ec:kc,s)):e.removeEventListener(t,s?Ec:kc,s);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=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 gf(e){return function(t){if(this.l){var r=this.l[t.type+e];if(t.t==null)t.t=Pc++;else if(t.t<r.u)return;return r(J.event?J.event(t):t)}}}function Sc(e,t,r,n,o,s,i,a,c,l){var p,u,f,d,h,g,y,w,R,E,b,k,v,L,C,O,S,T=t.type;if(t.constructor!==void 0)return null;128&r.__u&&(c=!!(32&r.__u),s=[a=t.__e=r.__e]),(p=J.__b)&&p(t);e:if(typeof T=="function")try{if(w=t.props,R="prototype"in T&&T.prototype.render,E=(p=T.contextType)&&n[p.__c],b=p?E?E.props.value:p.__:n,r.__c?y=(u=t.__c=r.__c).__=u.__E:(R?t.__c=u=new T(w,b):(t.__c=u=new qt(w,b),u.constructor=T,u.render=jE),E&&E.sub(u),u.props=w,u.state||(u.state={}),u.context=b,u.__n=n,f=u.__d=!0,u.__h=[],u._sb=[]),R&&u.__s==null&&(u.__s=u.state),R&&T.getDerivedStateFromProps!=null&&(u.__s==u.state&&(u.__s=Rr({},u.__s)),Rr(u.__s,T.getDerivedStateFromProps(w,u.__s))),d=u.props,h=u.state,u.__v=t,f)R&&T.getDerivedStateFromProps==null&&u.componentWillMount!=null&&u.componentWillMount(),R&&u.componentDidMount!=null&&u.__h.push(u.componentDidMount);else{if(R&&T.getDerivedStateFromProps==null&&w!==d&&u.componentWillReceiveProps!=null&&u.componentWillReceiveProps(w,b),!u.__e&&(u.shouldComponentUpdate!=null&&u.shouldComponentUpdate(w,u.__s,b)===!1||t.__v==r.__v)){for(t.__v!=r.__v&&(u.props=w,u.state=u.__s,u.__d=!1),t.__e=r.__e,t.__k=r.__k,t.__k.some(function(P){P&&(P.__=t)}),k=0;k<u._sb.length;k++)u.__h.push(u._sb[k]);u._sb=[],u.__h.length&&i.push(u);break e}u.componentWillUpdate!=null&&u.componentWillUpdate(w,u.__s,b),R&&u.componentDidUpdate!=null&&u.__h.push(function(){u.componentDidUpdate(d,h,g)})}if(u.context=b,u.props=w,u.__P=e,u.__e=!1,v=J.__r,L=0,R){for(u.state=u.__s,u.__d=!1,v&&v(t),p=u.render(u.props,u.state,u.context),C=0;C<u._sb.length;C++)u.__h.push(u._sb[C]);u._sb=[]}else do u.__d=!1,v&&v(t),p=u.render(u.props,u.state,u.context),u.state=u.__s;while(u.__d&&++L<25);u.state=u.__s,u.getChildContext!=null&&(n=Rr(Rr({},n),u.getChildContext())),R&&!f&&u.getSnapshotBeforeUpdate!=null&&(g=u.getSnapshotBeforeUpdate(d,h)),a=Ef(e,Us(O=p!=null&&p.type===Y&&p.key==null?p.props.children:p)?O:[O],t,r,n,o,s,i,a,c,l),u.base=t.__e,t.__u&=-161,u.__h.length&&i.push(u),y&&(u.__E=u.__=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(S=s.length;S--;)Rc(s[S]);else t.__e=r.__e,t.__k=r.__k;J.__e(P,t,r)}else s==null&&t.__v==r.__v?(t.__k=r.__k,t.__e=r.__e):a=t.__e=FE(r.__e,t,r,n,o,s,i,c,l);return(p=J.diffed)&&p(t),128&t.__u?void 0:a}function Pf(e,t,r){for(var n=0;n<r.length;n++)_c(r[n],r[++n],r[++n]);J.__c&&J.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(s){s.call(o)})}catch(s){J.__e(s,o.__v)}})}function FE(e,t,r,n,o,s,i,a,c){var l,p,u,f,d,h,g,y=r.props,w=t.props,R=t.type;if(R=="svg"?o="http://www.w3.org/2000/svg":R=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),s!=null){for(l=0;l<s.length;l++)if((d=s[l])&&"setAttribute"in d==!!R&&(R?d.localName==R:d.nodeType==3)){e=d,s[l]=null;break}}if(e==null){if(R==null)return document.createTextNode(w);e=document.createElementNS(o,R,w.is&&w),a&&(J.__m&&J.__m(t,s),a=!1),s=null}if(R===null)y===w||a&&e.data===w||(e.data=w);else{if(s=s&&js.call(e.childNodes),y=r.props||vo,!a&&s!=null)for(y={},l=0;l<e.attributes.length;l++)y[(d=e.attributes[l]).name]=d.value;for(l in y)if(d=y[l],l!="children"){if(l=="dangerouslySetInnerHTML")u=d;else if(!(l in w)){if(l=="value"&&"defaultValue"in w||l=="checked"&&"defaultChecked"in w)continue;As(e,l,null,d,o)}}for(l in w)d=w[l],l=="children"?f=d:l=="dangerouslySetInnerHTML"?p=d:l=="value"?h=d:l=="checked"?g=d:a&&typeof d!="function"||y[l]===d||As(e,l,d,y[l],o);if(p)a||u&&(p.__html===u.__html||p.__html===e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(u&&(e.innerHTML=""),Ef(e,Us(f)?f:[f],t,r,n,R=="foreignObject"?"http://www.w3.org/1999/xhtml":o,s,i,s?s[0]:r.__k&&An(r,0),a,c),s!=null)for(l=s.length;l--;)Rc(s[l]);a||(l="value",R=="progress"&&h==null?e.removeAttribute("value"):h!==void 0&&(h!==e[l]||R=="progress"&&!h||R=="option"&&h!==y[l])&&As(e,l,h,y[l],o),l="checked",g!==void 0&&g!==e[l]&&As(e,l,g,y[l],o))}return e}function _c(e,t,r){try{if(typeof e=="function"){var n=typeof e.__u=="function";n&&e.__u(),n&&t==null||(e.__u=e(t))}else e.current=t}catch(o){J.__e(o,r)}}function Rf(e,t,r){var n,o;if(J.unmount&&J.unmount(e),(n=e.ref)&&(n.current&&n.current!==e.__e||_c(n,null,t)),(n=e.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(s){J.__e(s,t)}n.base=n.__P=null}if(n=e.__k)for(o=0;o<n.length;o++)n[o]&&Rf(n[o],t,r||typeof e.type!="function");r||Rc(e.__e),e.__c=e.__=e.__e=void 0}function jE(e,t,r){return this.constructor(e,r)}function ut(e,t,r){var n,o,s,i;t==document&&(t=document.documentElement),J.__&&J.__(e,t),o=(n=typeof r=="function")?null:r&&r.__k||t.__k,s=[],i=[],Sc(t,e=(!n&&r||t).__k=ur(Y,null,[e]),o||vo,vo,t.namespaceURI,!n&&r?[r]:o?null:t.firstChild?js.call(t.childNodes):null,s,!n&&r?r:o?o.__e:t.firstChild,n,i),Pf(s,e,i)}function ko(e,t){var r={__c:t="__cC"+wf++,__:e,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,s;return this.getChildContext||(o=new Set,(s={})[t]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(i){this.props.value!==i.value&&o.forEach(function(a){a.__e=!0,Tc(a)})},this.sub=function(i){o.add(i);var a=i.componentWillUnmount;i.componentWillUnmount=function(){o&&o.delete(i),a&&a.call(i)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}js=vf.slice,J={__e:function(e,t,r,n){for(var o,s,i;t=t.__;)if((o=t.__c)&&!o.__)try{if((s=o.constructor)&&s.getDerivedStateFromError!=null&&(o.setState(s.getDerivedStateFromError(e)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,n||{}),i=o.__d),i)return o.__E=o}catch(a){e=a}throw e}},yf=0,IE=function(e){return e!=null&&e.constructor==null},qt.prototype.setState=function(e,t){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Rr({},this.state),typeof e=="function"&&(e=e(Rr({},r),this.props)),e&&Rr(r,e),e!=null&&this.__v&&(t&&this._sb.push(t),Tc(this))},qt.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Tc(this))},qt.prototype.render=Y,Xr=[],bf=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,vc=function(e,t){return e.__v.__b-t.__v.__b},Fs.__r=0,xf=/(PointerCapture)$|Capture$/i,Pc=0,kc=gf(!1),Ec=gf(!0),wf=0;var Jr,_e,Lc,Sf,Eo=0,Df=[],$e=J,_f=$e.__b,Lf=$e.__r,Cf=$e.diffed,Of=$e.__c,Nf=$e.unmount,Mf=$e.__;function To(e,t){$e.__h&&$e.__h(_e,e,Eo||t),Eo=0;var r=_e.__H||(_e.__H={__:[],__h:[]});return e>=r.__.length&&r.__.push({}),r.__[e]}function X(e){return Eo=1,_r(Af,e)}function _r(e,t,r){var n=To(Jr++,2);if(n.t=e,!n.__c&&(n.__=[r?r(t):Af(void 0,t),function(a){var c=n.__N?n.__N[0]:n.__[0],l=n.t(c,a);c!==l&&(n.__N=[l,n.__[1]],n.__c.setState({}))}],n.__c=_e,!_e.u)){var o=function(a,c,l){if(!n.__c.__H)return!0;var p=n.__c.__H.__.filter(function(f){return!!f.__c});if(p.every(function(f){return!f.__N}))return!s||s.call(this,a,c,l);var u=n.__c.props!==a;return p.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(u=!0)}}),s&&s.call(this,a,c,l)||u};_e.u=!0;var s=_e.shouldComponentUpdate,i=_e.componentWillUpdate;_e.componentWillUpdate=function(a,c,l){if(this.__e){var p=s;s=void 0,o(a,c,l),s=p}i&&i.call(this,a,c,l)},_e.shouldComponentUpdate=o}return n.__N||n.__}function te(e,t){var r=To(Jr++,3);!$e.__s&&Oc(r.__H,t)&&(r.__=e,r.i=t,_e.__H.__h.push(r))}function Hs(e,t){var r=To(Jr++,4);!$e.__s&&Oc(r.__H,t)&&(r.__=e,r.i=t,_e.__h.push(r))}function Ye(e){return Eo=5,N(function(){return{current:e}},[])}function N(e,t){var r=To(Jr++,7);return Oc(r.__H,t)&&(r.__=e(),r.__H=t,r.__h=e),r.__}function A(e,t){return Eo=8,N(function(){return e},t)}function pr(e){var t=_e.context[e.__c],r=To(Jr++,9);return r.c=e,t?(r.__==null&&(r.__=!0,t.sub(_e)),t.props.value):e.__}function UE(){for(var e;e=Df.shift();)if(e.__P&&e.__H)try{e.__H.__h.forEach(Bs),e.__H.__h.forEach(Cc),e.__H.__h=[]}catch(t){e.__H.__h=[],$e.__e(t,e.__v)}}$e.__b=function(e){_e=null,_f&&_f(e)},$e.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Mf&&Mf(e,t)},$e.__r=function(e){Lf&&Lf(e),Jr=0;var t=(_e=e.__c).__H;t&&(Lc===_e?(t.__h=[],_e.__h=[],t.__.forEach(function(r){r.__N&&(r.__=r.__N),r.i=r.__N=void 0})):(t.__h.forEach(Bs),t.__h.forEach(Cc),t.__h=[],Jr=0)),Lc=_e},$e.diffed=function(e){Cf&&Cf(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Df.push(t)!==1&&Sf===$e.requestAnimationFrame||((Sf=$e.requestAnimationFrame)||BE)(UE)),t.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.i=void 0})),Lc=_e=null},$e.__c=function(e,t){t.some(function(r){try{r.__h.forEach(Bs),r.__h=r.__h.filter(function(n){return!n.__||Cc(n)})}catch(n){t.some(function(o){o.__h&&(o.__h=[])}),t=[],$e.__e(n,r.__v)}}),Of&&Of(e,t)},$e.unmount=function(e){Nf&&Nf(e);var t,r=e.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Bs(n)}catch(o){t=o}}),r.__H=void 0,t&&$e.__e(t,r.__v))};var If=typeof requestAnimationFrame=="function";function BE(e){var t,r=function(){clearTimeout(n),If&&cancelAnimationFrame(t),setTimeout(e)},n=setTimeout(r,100);If&&(t=requestAnimationFrame(r))}function Bs(e){var t=_e,r=e.__c;typeof r=="function"&&(e.__c=void 0,r()),_e=t}function Cc(e){var t=_e;e.__c=e.__(),_e=t}function Oc(e,t){return!e||e.length!==t.length||t.some(function(r,n){return r!==e[n]})}function Af(e,t){return typeof t=="function"?t(e):t}function Ve(e){return typeof e=="number"}var HE=(e,t,r)=>{let n=t.name||"anonymous predicate",o=typeof e,s=JSON.stringify(e,null,2);returnExpected ${r??"a value"} that satisfies the predicate ${n}, got ${o}: ${s}},WE=HE,Nc=class e extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.name=this.constructor.name}};function $f(e,t,r={}){if(!t(e))throw new Nc(r.message??WE(e,t,r.name))}function Ff(e,t,r={}){return $f(e,t,r),e}function Et(e){return typeof e>"u"}var Ws=!1,jf=null,Uf=()=>{scrapbox.addListener("lines:changed",()=>Ws=!1),scrapbox.addListener("layout:changed",()=>Ws=!1),Uf=void 0},Bf=()=>(Uf?.(),Ws||(jf=scrapbox.Page.lines,Ws=!0),jf);var Hf=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var Wf=(e,t)=>{if(!(e instanceof HTMLTextAreaElement))throw new TypeError("${t}" must be HTMLTextAreaElement but actual is "${e}")};var qf=()=>qs(document.getElementById("editor"),"div#editor"),Po=()=>qs(document.getElementsByClassName("lines").item(0),"div.lines");var Xe=()=>{let e=document.getElementById("text-input");if(e)return Wf(e,"textarea#text-input"),e};var zf=()=>qs(document.getElementsByClassName("popup-menu")?.[0],"div.popup-menu");var Gf=()=>qs(document.getElementsByClassName("status-bar")?.[0],"div.status-bar"),qs=(e,t)=>{if(e)return Hf(e,t),e};var xt=()=>{let e=Po();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 dr=e=>e.match(/^(\s*)/)?.[1]?.length??0,Qr=(e,t)=>{let r=dr(Kf(e,t)),n=0;for(;e+n+1<t.length&&dr(Kf(e+n+1,t))>r;)n++;return n},Kf=(e,t)=>{let r=t[e];return Ke(r)?r:r.text};var Mc=e=>{if(Et(e))return;if(Ve(e))return zs(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)},Yf=e=>{if(Et(e))return;if(Ve(e))return e;let t=Mc(e);return t?xt().findIndex(r=>r.id===t):-1};var zs=e=>{if(Et(e))return;if(Ve(e))return xt()[e];let t=Mc(e);return t?xt().find(r=>r.id===t):void 0},Zr=e=>{if(Vf(e))return e;let t=Mc(e);if(Et(t))return t;let r=document.getElementById(L${t});if(!Et(r))return r},Vf=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var zt=()=>Ff(Bf(),cr),Je=e=>{if(Et(e))return;if(Ve(e)||Ke(e))return zs(e)?.text;if(!(e instanceof HTMLElement))return;if(Vf(e))return zs(e)?.text;if(e.classList.contains("char-index"))return e.textContent??void 0;if(e.classList.contains("line")||e.getElementsByClassName("lines")?.[0])return xt().map(({text:n})=>n).join( );let t=[],r=zs(e);if(!Et(r)){for(let n of zE(e))t.push(GE(n));return r.text.slice(Math.min(...t),Math.max(...t)+1)}};var Xf=()=>{let e=Po()?.firstElementChild;if(!Et(e))return e},Jf=()=>{let e=Po()?.lastElementChild;if(!Et(e))return e};var Ic=e=>{let t=Yf(e);if(!Et(t))return Qr(t,zt())};function*zE(e){let t=e.getElementsByClassName("char-index");for(let r=0;r<t.length;r++)yield t[0]}var Dc=e=>e instanceof HTMLSpanElement&&e.classList.contains("char-index"),GE=e=>{if(!Dc(e))throw Error("A char DOM is required.");let t=e.className.match(/c-(\d+)/)?.[1];if(Et(t))throw Error('.char-index must have ".c-{\\d}"');return parseInt(t)},Qf=e=>{let t=e?.getElementsByClassName?.("c-0")?.[0];return Dc(t)?t:void 0};var Ro=(e,t)=>{let r=Zr(e)?.getElementsByClassName?.(c-${t})?.[0];return Dc(r)?r:void 0};var He=(e,t)=>{let{noModifiedKeys:r=!1,...n}=t??{},o={bubbles:!0,cancelable:!0,keyCode:KE[e],...r?{}:{...n}},s=Xe();if(!s)throw Error("#text-input must exist.");s.dispatchEvent(new KeyboardEvent("keydown",o)),s.dispatchEvent(new KeyboardEvent("keyup",o))},KE={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 Ac=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 Ee(10)};var Le=()=>{let e=Xe();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 $c=e=>{let{top:t,bottom:r}=e.getBoundingClientRect();return t>=0&&r<=globalThis.innerHeight};function*Tt(e,t){for(let r=e;r<t;r++)yield r}var Fc=()=>{He("Home"),He("Home")};var Zf=async()=>{let e=Xf();if(!e)throw Error(".line:first-of-type can't be found.");$c(e)||e.scrollIntoView({block:"center"});let t=Qf(e);if(!t)throw Error(".line:first-of-type .c-0 can't be found.");let{left:r,top:n}=t.getBoundingClientRect();await Ac(e,{X:r,Y:n})},em=async()=>{await tm(Jf())},jc=async e=>{await tm(Zr(e))},tm=async e=>{if(!e)throw Error("The target line DOM is failed to find.");$c(e)||e.scrollIntoView({block:"center"});let{right:t,top:r,height:n}=e.getElementsByClassName("text")0.getBoundingClientRect();await Ac(e,{X:t+1,Y:r+n/2})};var rm=(e=1)=>{for(let t of Tt(0,e))He("z",{ctrlKey:!0})},nm=(e=1)=>{for(let t of Tt(0,e))He("z",{shiftKey:!0,ctrlKey:!0})};var om=async(e,t)=>{await jc(e),Fc(),He("Enter"),He("ArrowUp"),await Qe(t)},it=async(e,t,r)=>{await jc(e),Fc();for(let n of Tt(e,t))He("ArrowDown",{shiftKey:!0});He("End",{shiftKey:!0}),await Qe(r)};var Gs=(e=1)=>{for(let t of Tt(0,e))He("ArrowRight",{ctrlKey:!0})},Ks=(e=1)=>{for(let t of Tt(0,e))He("ArrowLeft",{ctrlKey:!0})};var Ys=(e=1)=>{for(let t of Tt(0,e))He("ArrowUp",{ctrlKey:!0})},Vs=(e=1)=>{for(let t of Tt(0,e))He("ArrowDown",{ctrlKey:!0})},Xs=(e=1)=>{for(let t of Tt(0,e))He("ArrowRight",{altKey:!0})},Js=(e=1)=>{for(let t of Tt(0,e))He("ArrowLeft",{altKey:!0})};var Qs=(e=1)=>{for(let t of Tt(0,e))He("ArrowUp",{altKey:!0})},Zs=(e=1)=>{for(let t of Tt(0,e))He("ArrowDown",{altKey:!0})},Qe=async e=>{let t=Xe();if(!t)throw Error("#text-input is not ditected.");t.focus(),t.value=e;let r=new InputEvent("input",{bubbles:!0});t.dispatchEvent(r),await Ee(1)};var Re=()=>{let e=Gf();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 n=sm(...r);n&&t.append(n)},dispose:()=>t.remove()}},sm=(...e)=>{let t=e.flatMap(n=>{switch(n.type){case"spinner":returnVE();case"check-circle":returnXE();case"exclamation-triangle":returnJE();case"text":returnei(n.text);case"group":{let o=sm(...n.items);return o?o:[]}}});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},ei=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},VE=()=>{let e=document.createElement("i");return e.classList.add("fa","fa-spinner"),ei(e)},XE=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle"),ei(e)},JE=()=>{let e=document.createElement("i");return e.classList.add("fas","fa-exclamation-triangle"),ei(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_${re(e.to.title)}]=r,localStorage.setItem("pageTransitionContext",JSON.stringify(t))};var QE=(e,t,r)=>{let n=new URL(/${e}/${ue(t)},location.href);if(r?.body&&(n.search=?body=${encodeURIComponent(r.body)}),r?.id&&(n.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(n);return}if(r?.reload!==!1&&(r?.reload===!0||e!==scrapbox.Project.name)){globalThis.open(n,"_self");return}let o=document.createElement("a");o.href=n.toString(),document.body.append(o),o.click(),o.remove()},So=(e,t,r)=>QE(e,t,{newTab:!1,reload:!1,body:r});var Fn=async(e,t)=>{let r=await globalThis.caches.keys();for(let n of r.sort().reverse()){let s=await(await caches.open(n)).match(e,t);if(s)return s}},ti=async(e,t)=>{let r=t.clone();return await(await caches.open(ZE(new Date))).put(e,r)},ZE=e=>api-${e.getFullYear()}-${${e.getMonth()+1}.padStart(2,"0")}-${${e.getDate()}.padStart(2,"0")};var Pt=()=>{let e=Xe();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,n=r.find(s=>s.constructor.name==="Cursor");if(!n)throw Error('#text-input must has a "Cursor" store.');let o=r.find(s=>s.constructor.name==="Selection");if(!o)throw Error('#text-input must has a "Selection" store.');return{cursor:n,selection:o}};var Lr=()=>Pt().cursor;var ri=()=>Pt().selection;var _o=e=>e===void 0?0:typeof e=="boolean"?Number(e):(e.capture?1:0)|(e.once?2:0)|(e.passive?4:0),im=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 ni=new Map,Uc=new Map,Bc=()=>{scrapbox.on("layout:changed",()=>{let e=Xe();if(e)for(lett,rof ni)for(letn,oof r)for(let s of o)e.addEventListener(t,n,im(s))}),Bc=void 0},am=(e,t,r)=>{Bc?.();let n=ni.get(e)??new Map,o=n.get(t)??new Set;if(o.has(_o(r)))return;if(o.add(_o(r)),n.set(t,o),ni.set(e,n),typeof r=="object"&&r?.once){let i=Uc.get(t)??new Map,a=_o(r),c=function(p){return Hc(e,t,r),i.delete(a),t.call(this,p)};i.set(a,c),Uc.set(t,i);let l=Xe();if(!l)return;l.addEventListener(e,c,r)}let s=Xe();s&&s.addEventListener(e,t,r)},Hc=(e,t,r)=>{Bc?.();let n=ni.get(e);if(!n)return;let o=n.get(t);if(!o)return;let s=_o(r);if(o.delete(s),typeof r=="object"&&r?.once){let a=Uc.get(t);if(!a)return;let c=a.get(s);if(!c)return;let l=Xe();if(!l)return;l.removeEventListener(e,c,r),a.delete(s);return}let i=Xe();i&&i.removeEventListener(e,t,r)};var cm={"&":"\\x26","!":"\\x21","#":"\\x23",$:"\\$","%":"\\x25","*":"\\*","+":"\\+",",":"\\x2c",".":"\\.",":":"\\x3a",";":"\\x3b","<":"\\x3c","=":"\\x3d",">":"\\x3e","?":"\\?","@":"\\x40","^":"\\^","":"\\x60","~":"\\x7e","(":"\\(",")":"\\)","[":"\\[","]":"\\]","{":"\\{","}":"\\}","/":"\\/","-":"\\x2d","\\":"\\\\","|":"\\|"},eT=new RegExp(${Object.values(cm).join("")},"gu");function lm(e){return e.replaceAll(eT,t=>cm[t]).replace(/^[0-9a-zA-Z]/,t=>\\x${t.codePointAt(0).toString(16)})}var tT=0,O2=Array.isArray;function m(e,t,r,n,o,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:--tT,__i:-1,__u:0,__source:o,__self:s};if(typeof e=="function"&&(i=e.defaultProps))for(a in i)c[a]===void 0&&(c[a]=i[a]);return J.vnode&&J.vnode(l),l}var um=({project:e,title:t,words:r,lines:n,query:o,close:s})=>{let i=A(c=>{$n({type:"search",query:o,to:{project:e,title:t}}),!(c.metaKey||c.ctrlKey||c.altKey||c.shiftKey)&&s()},[e,t,o,s]),a=N(()=>{let c=new RegExp((${r.map(l=>lm(l)).join("|")}),"i");return n.flatMap(l=>{let p=l.split(c);return m("span",{children:p.map((u,f)=>f%2===0?u:m("strong",{children:u}))})})},[n,r]);return m("a",{href:/${e}/${ue(t)},target:${e===scrapbox.Project.name?"":"_blank"},rel:${e===scrapbox.Project.name?"route":"noopener noreferrer"},onClick:i,children:[t,m("div",{className:"description",children:a})]})};var pm=e=>{let[t,r]=X(e),n=A(()=>r(!0),[]),o=A(()=>r(!1),[]),s=A(()=>r(i=>!i),[]);return[t,{open:n,close:o,toggle:s}]};var dm=" must not return ",rT="transformer",nT="recoverer",oT="defaultValue",z2=rT+dm,fm="called with ",G2=oT+" must not be ",K2=nT+dm,sT="Ok",mm="Err",iT=fm+mm,aT=fm+sT,Y2="Carrying E in "+mm+" instead of throwing it directly. See .cause",Wc="an instance of Error of the current realm.",V2="The thrown value is not "+Wc,X2="The contained E should be "+Wc,J2="This .cause is not "+Wc;function qc(e){return e.ok}function Lo(e){return!e.ok}function en(e){return cT(e,iT)}function hm(e){return lT(e,aT)}function cT(e,t){if(Lo(e))throw new TypeError(t);return e.val}function lT(e,t){if(qc(e))throw new TypeError(t);return e.err}var gm=(e,t)=>{let[r,n]=X(),[o,s]=X(!1),i=Ye(Promise.resolve());return te(()=>{if(t===""){n(void 0);return}let a=!1;return i.current=(async()=>{if(await i.current,!a){s(!0);try{let c=await Yd(t,e);if(a)return;n(qc(c)?en(c):void 0)}finally{s(!1)}}})(),()=>a=!0},[t,e]),{loading:o,result:r}};var ym=()=>m("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 > * {
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 {
}
.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 uT=()=>m("i",{className:"spinner"}),bm=({exportOps:e})=>{let[t,r]=X(""),n=scrapbox.Project.name,{loading:o,result:s}=gm(n,t),i=A(d=>{r(d.currentTarget.value)},[]),[a,{open:c,close:l,toggle:p}]=pm(!1),u=Ye({open:c,close:l,toggle:p});te(()=>{Object.assign(u.current,{open:c,close:l,toggle:p})},[]),te(()=>e(u.current),[e]);let f=A(d=>{d.target instanceof HTMLElement&&d.target.id==="background"&&l()},[]);return m(Y,{children:[m(ym,{}),m("div",{id:"background",className:modal${a?"":" closed"},onClick:f,children:[m("div",{className:"controller",children:[m("input",{type:"text",value:t,onInput:i}),m("div",{className:"info",children:[o&&m(uT,{}),${s?.pages?.length??0} pages]})]}),s?.pages&&s.pages.length>0&&m("ul",{className:"result",children:s.pages.map(d=>m("li",{children:m(um,{...d,project:n,query:t,close:l})},d.title))})]})]})};var xm=()=>{let e=document.createElement("div"),t=e.attachShadow({mode:"open"});return document.body.append(e),new Promise(r=>{ut(m(bm,{exportOps:r}),t)})};var oi=(e,t)=>Object.hasOwn(e,t),wm={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:">"},Tm=e=>{let t=e.toLowerCase();return oi(wm,t)?wm[t]:e},vm={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:"/","?"},pT=(e,t)=>{if(e.startsWith("Key")){let r=e.slice(3);return t||(r=r.toLowerCase()),r}return oi(vm,e)?vmet?1:0:e},km={"<":"lt",">":"gt"},dT=/^($|Unidentified$|Process$|Dead$|Alt|Control|Hyper|Meta|Shift|Super|OS)/,zc=e=>{let t=e.shiftKey,r=e.key||"Unidentified";if(r==="Unidentified"?r=pT(e.code||"",t):(r=Tm(r),r===" "&&(r="Space")),dT.test(r))return"";r.length===1?t=!1:r=r.toLowerCase();let n="";return e.altKey&&(n+="a-"),e.ctrlKey&&(n+="c-"),e.metaKey&&(n+="m-"),t&&(n+="s-"),oi(km,r)&&(r=kmr),n||r.length>1?<${n}${r}>:r},Em={a:"altKey",c:"ctrlKey",m:"metaKey",s:"shiftKey"},fT=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,n=t,o={key:Tm(n)};for(let s of r.split("-").slice(0,-1)){let i=s.toLowerCase();if(!oi(Em,i))return{ok:!1,value:{name:"UnknownModifierError",modifier:s,context:e,message:${e}: Unknown modifier: ${s}}};let a=Emi;if(oa!==void 0)return{ok:!1,value:{name:"DuplicateModifierError",modifier:s,context:e,message:${e}: Duplicate modifier: ${s}}};if(oa=!0,o.key.length===1&&o.shiftKey)return{ok:!1,value:{name:"DisallowedModifierError",modifier:s,context:e,message:${e}: Unusable modifier with single-character keys: ${s}}}}return{ok:!0,value:o}},Pm=e=>{let t=fT(e);return t.ok?{ok:!0,value:zc(t.value)}:t},Rm=e=>e.match(/<^<>\s+>|\s\S|^$/g);var It=!1;var Sm=e=>Object.fromEntries(...Object.entries(console).map((t,r)=>{if(typeof r!="function")returnt,r;switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{It!==!0&&(!It||!It.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{It!==!0&&(!It||!It.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{It!==!0&&(!It||!It.has(e))||r(${e} ${n})}];default:returnt,(...n)=>{if(!(It!==!0&&(!It||!It.has(e))))return r(...n)}}}));var tn=Sm("ScrapBindings:mod.ts"),si=class{constructor(t,r){this.target=t;this.onSequenceUpdate=r?.onSequenceUpdate,this.flushInterval=r?.flushInterval??1e3}bind(t,r){let n=new Map,o=[];for(lets,iof t instanceof Map?t.entries():typeof t=="string"?t,r:Object.entries(t)){let a=_m(s);if(!a.ok){for(let l of a.value)tn.error(${s}: ${l.message});n.set(s,a.value);continue}let c=a.value;this.bindings.set(c,i),c.startsWith(this.currentSequence)&&this.filtered.add(c),o.push(c)}return tn.debug("Binded the following commands:",o),this.emitChange(),n}unbind(...t){for(let r of t){let n=_m(r);if(!n.ok)continue;let o=n.value;this.bindings.delete(o),this.filtered.delete(o)}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()),tn.debug("reset the sequence")};handleKeydown=t=>{if(!t.isTrusted)return;let r=zc(t);if(!r)return;if(clearTimeout(this.timer),t.isComposing){this.backToInitial();return}this.currentSequence+=r,tn.debug("sequence",this.currentSequence);let n;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}n=()=>{tn.debug(run ${s});try{i(t)}catch(a){tn.error(a)}finally{this.backToInitial()}}}let o=this.filtered.size;if(tn.debug(${o} candidates: ${[...this.filtered.keys()].join(", ")}),o>0&&(this.prevBestMatchCommand=n),this.prevBestMatchCommand&&o<2){if(this.prevBestMatchCommand(),o===0){this.handleKeydown(t);return}return}if(o===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)}},mT={name:"InvalidSequenceError",message:"cannot parse the sequence"},_m=e=>{let t=Rm(e);if(!t)return{ok:!1,value:mT};let r="",n=[];for(let o of t){let s=Pm(o);if(!s.ok){n.push(s.value);continue}r+=s.value}return n.length>0?{ok:!1,value:n}:{ok:!0,value:r}};var Lm=()=>{if(scrapbox.Layout!=="page")return{selectionRange:{start:{line:0,char:0},end:{line:0,char:0}},selectedText:""};let{selectionRange:e,selectedText:t,position:r}=Le();if(!t){let p=Ic(r.line)??0,u={start:{line:r.line,char:0},end:{line:r.line+p,char:Je(r.line+p)?.length??0}};return{selectionRange:u,selectedText:scrapbox.Page.lines.slice(u.start.line,u.end.line+1).map(f=>f.text).join(` )}}let{start:n,end:o}=e,s=n.line>o.line,i=s?o.line:n.line,a=s?o.char:n.char,c=s?n.line:o.line,l=s?n.char:o.char;return{selectedText:t,selectionRange:{start:{line:i,char:a},end:{line:c,char:l}}}};var Gc=(e,{title:t,projectTo:r,mode:n})=>{let[o,...s]=e.split(
),i=o.replaceAll("[","").replaceAll("]","").trim(),a=Math.min(...[o,...s].map(l=>dr(l))),c=[from ${t},o.slice(a),...s.map(l=>l.slice(a))];return{text:${i},pages:[{project:r,title:i,lines:c,mode:n}]}};Gc.hookName="default-hook";var fr=e=>{let{project:t=scrapbox.Project.name,mode:r="newtab"}=e??{},n=[...e?.hooks??[],Gc],{selectionRange:{start:o,end:s},selectedText:i}=Lm();if(!i||scrapbox.Layout!=="page")return;let a=(()=>{for(let u of n){let f=u(i,{title:scrapbox.Page.title,projectFrom:scrapbox.Project.name,projectTo:t,lines:xt().slice(o.line,s.line+1),mode:r});if(f)return[u.hookName,f]}})();if(!a)return;let[c,l]=a,p=async()=>{let u=l instanceof Promise?await l:l;if(u.pages.length===0&&u.text===i)return;let f,{render:d,dispose:h}=Re();try{if(u.pages.length>0){let y=u.pages.length;d({type:"spinner"},{type:"text",text:Create new ${y} pages...});let w=await ze(e?.socket);if(W(w))throw ee(w);f=B(w);let R=0;await Promise.all(u.pages.map(async E=>{let b=Array.isArray(E.lines)?k=>[...k.map(v=>v.text),...E.lines]:E.lines;await me(E.project,E.title,b,{socket:f}),d({type:"spinner"},{type:"text",text:Create ${y-++R} pages...})}))}d({type:"spinner"},{type:"text",text:${u.pages.length>0?"Created. ":""}Removing cut text...});let g=u.text;if(i===g)return;await me(scrapbox.Project.name,scrapbox.Page.title,y=>{let w=y.map(R=>R.text);return[...w.slice(0,o.line),...${wo.line.slice(0,o.char)}${g}${w.slice(s.line).join(` ).slice(s.char)}.split(`
)]}),d({type:"check-circle"},{type:"text",text:"Removed."});for(let y of u.pages)switch(y.mode){case"self":y.project===scrapbox.Project.name?So(y.project,y.title):globalThis.open(https://scrapbox.io/${y.project}/${ue(y.title)},"_self");break;case"newtab":globalThis.open(https://scrapbox.io/${y.project}/${ue(y.title)});break}}catch(g){d({type:"exclamation-triangle"},{type:"text",text:"Failed to create new pages (see console)."}),console.error(g)}finally{let g=Ee(1e3);f&&await nt(f),await g,h()}};return p.hookName=c,p};function hT(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function Cm(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function gT(e){if(!hT(e)&&typeof e!="number")return!1;let t=Cm(e);return!isNaN(Number(t))}function Cr(e,t){let r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}var yT={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return Cr(t==="yy"?n%100:n,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):Cr(r+1,2)},d(e,t){return Cr(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 Cr(e.getHours()%12||12,t.length)},H(e,t){return Cr(e.getHours(),t.length)},m(e,t){return Cr(e.getMinutes(),t.length)},s(e,t){return Cr(e.getSeconds(),t.length)},S(e,t){let r=t.length,n=e.getMilliseconds(),o=Math.trunc(n*Math.pow(10,r-3));return Cr(o,t.length)}},bT=/(\w)\1*|''|'(''|[^'])+('|$)|./g,xT=/^'([^]*?)'?$/,wT=/''/g,vT=/[a-zA-Z]/;function ht(e,t){let r=Cm(e);if(!gT(r))throw new RangeError("Invalid time value");let n=t.match(bT);return n?n.map(o=>{if(o==="''")return"'";let s=o[0];if(s==="'")return kT(o);let i=yT[s];if(i)return i(r,o);if(s.match(vT))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return o}).join(""):""}function kT(e){let t=e.match(xT);return t?t[1].replace(wT,"'"):e}function ET(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Om(e){return ET(e).getDate()}var TT=Math.pow(10,8)*24*60*60*1e3,V3=-TT;var PT=3600,Nm=PT*24,X3=Nm*7,RT=Nm*365.2425,ST=RT/12,J3=ST*3;function _T(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Mm(e){return _T(e).getMonth()}function LT(e){let t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function Im(e){return LT(e).getFullYear()}var Dm=e=>{let t=new Map;for(let r of e){let n=${Im(r)}-${Mm(r)}-${Om(r)},o=t.get(n);o&&o.getTime()>r.getTime()||t.set(n,r)}return[...t.values()]};var CT=Math.pow(10,8)*24*60*60*1e3,qW=-CT,$m=6048e5,OT=864e5,Yc=6e4,Fm=36e5,NT=1e3;var MT=3600;var jm=MT*24,zW=jm*7,IT=jm*365.2425,DT=IT/12,GW=DT*3,Am=Symbol.for("constructDateFrom");function Oe(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Am in e?e[Am](t):e instanceof Date?new e.constructor(t):new Date(t)}function ae(e,t){return Oe(t||e,e)}function We(e,t,r){let n=ae(e,r?.in);return isNaN(t)?Oe(r?.in||e,NaN):(t&&n.setDate(n.getDate()+t),n)}function AT(e,t,r){let n=ae(e,r?.in);if(isNaN(t))return Oe(r?.in||e,NaN);if(!t)return n;let o=n.getDate(),s=Oe(r?.in||e,n.getTime());s.setMonth(n.getMonth()+t+1,0);let i=s.getDate();return o>=i?s:(n.setFullYear(s.getFullYear(),s.getMonth(),o),n)}function Um(e,t,r){let{years:n=0,months:o=0,weeks:s=0,days:i=0,hours:a=0,minutes:c=0,seconds:l=0}=t,p=ae(e,r?.in),u=o||n?AT(p,o+n*12):p,f=i||s?We(u,i+s*7):u,d=c+a*60,h=(l+d*60)*1e3;return Oe(r?.in||e,+f+h)}function Bm(e,t,r){return Oe(r?.in||e,+ae(e)+t)}function Hm(e,t,r){return Bm(e,t*Fm,r)}var $T={};function ci(){return $T}function pt(e,t){let r=ci(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,o=ae(e,t?.in),s=o.getDay(),i=(s<n?7:0)+s-n;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function jn(e,t){return pt(e,{...t,weekStartsOn:1})}function FT(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=Oe(r,0);o.setFullYear(n+1,0,4),o.setHours(0,0,0,0);let s=jn(o),i=Oe(r,0);i.setFullYear(n,0,4),i.setHours(0,0,0,0);let a=jn(i);return r.getTime()>=s.getTime()?n+1:r.getTime()>=a.getTime()?n:n-1}function ii(e){let t=ae(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 li(e,...t){let r=Oe.bind(null,e||t.find(n=>typeof n=="object"));return t.map(r)}function Un(e,t){let r=ae(e,t?.in);return r.setHours(0,0,0,0),r}function Wm(e,t,r){let[n,o]=li(r?.in,e,t),s=Un(n),i=Un(o),a=+s-ii(s),c=+i-ii(i);return Math.round((a-c)/OT)}function jT(e,t){let r=FT(e,t),n=Oe(t?.in||e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),jn(n)}function Nr(e,t,r){let n=ae(e,r?.in);return n.setTime(n.getTime()+t*Yc),n}function ui(e,t,r){return Bm(e,t*1e3,r)}function pi(e,t,r){return We(e,t*7,r)}function qm(e,t){let r=+ae(e)-+ae(t);return r<0?-1:r>0?1:r}function gt(e,t,r){let[n,o]=li(r?.in,e,t);return+Un(n)==+Un(o)}function UT(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function rn(e){return!(!UT(e)&&typeof e!="number"||isNaN(+ae(e)))}function zm(e,t,r){let[n,o]=li(r?.in,e,t),s=n.getFullYear()-o.getFullYear(),i=n.getMonth()-o.getMonth();return s*12+i}function BT(e){return t=>{let r=(e?Math[e]:Math.trunc)(t);return r===0?0:r}}function HT(e,t){return+ae(e)-+ae(t)}function Vc(e,t,r){let n=HT(e,t)/Yc;return BT(r?.roundingMethod)(n)}function Gm(e,t){let r=ae(e,t?.in);return r.setHours(23,59,59,999),r}function Km(e,t){let[r,n]=li(e,t.start,t.end);return{start:r,end:n}}function di(e,t){let{start:r,end:n}=Km(t?.in,e),o=+r>+n,s=o?+r:+n,i=o?n:r;i.setHours(0,0,0,0);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,o=!o);let c=[];for(;+i<=s;)c.push(Oe(r,i)),i.setDate(i.getDate()+a),i.setHours(0,0,0,0);return o?c.reverse():c}function Ym(e,t){let{start:r,end:n}=Km(t?.in,e),o=+r>+n,s=pt(o?n:r,t),i=pt(o?r:n,t);s.setHours(15),i.setHours(15);let a=+i.getTime(),c=s,l=t?.step??1;if(!l)return[];l<0&&(l=-l,o=!o);let p=[];for(;+c<=a;)c.setHours(0),p.push(Oe(r,c)),c=pi(c,l),c.setHours(15);return o?p.reverse():p}function Kc(e){return(t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}var WT={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},qT={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},zT={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},KW={date:Kc({formats:WT,defaultWidth:"full"}),time:Kc({formats:qT,defaultWidth:"full"}),dateTime:Kc({formats:zT,defaultWidth:"full"})};function Co(e){return(t,r)=>{let n=r?.context?String(r.context):"standalone",o;if(n==="formatting"&&e.formattingValues){let i=e.defaultFormattingWidth||e.defaultWidth,a=r?.width?String(r.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{let i=e.defaultWidth,a=r?.width?String(r.width):e.defaultWidth;o=e.values[a]||e.values[i]}let s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}var GT={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},KT={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},YT={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"]},VT={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"]},XT={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"}},JT={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"}},QT=(e,t)=>{let r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},YW={ordinalNumber:QT,era:Co({values:GT,defaultWidth:"wide"}),quarter:Co({values:KT,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Co({values:YT,defaultWidth:"wide"}),day:Co({values:VT,defaultWidth:"wide"}),dayPeriod:Co({values:XT,defaultWidth:"wide",formattingValues:JT,defaultFormattingWidth:"wide"})};function Oo(e){return(t,r={})=>{let n=r.width,o=n&&e.matchPatterns[n]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;let i=s[0],a=n&&e.parsePatterns[n]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?eP(a,u=>u.test(i)):ZT(a,u=>u.test(i)),l;l=e.valueCallback?e.valueCallback(c):c,l=r.valueCallback?r.valueCallback(l):l;let p=t.slice(i.length);return{value:l,rest:p}}}function ZT(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function eP(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function tP(e){return(t,r={})=>{let n=t.match(e.matchPattern);if(!n)return null;let o=n[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(o.length);return{value:i,rest:a}}}var rP=/^(\d+)(th|st|nd|rd)?/i,nP=/\d+/i,oP={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},sP={any:[/^b/i,/^(a|c)/i]},iP={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},aP={any:[/1/i,/2/i,/3/i,/4/i]},cP={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},lP={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]},uP={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},pP={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]},dP={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},fP={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}},VW={ordinalNumber:tP({matchPattern:rP,parsePattern:nP,valueCallback:e=>parseInt(e,10)}),era:Oo({matchPatterns:oP,defaultMatchWidth:"wide",parsePatterns:sP,defaultParseWidth:"any"}),quarter:Oo({matchPatterns:iP,defaultMatchWidth:"wide",parsePatterns:aP,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Oo({matchPatterns:cP,defaultMatchWidth:"wide",parsePatterns:lP,defaultParseWidth:"any"}),day:Oo({matchPatterns:uP,defaultMatchWidth:"wide",parsePatterns:pP,defaultParseWidth:"any"}),dayPeriod:Oo({matchPatterns:dP,defaultMatchWidth:"any",parsePatterns:fP,defaultParseWidth:"any"})};function mP(e,t){let r=ae(e,t?.in),n=+jn(r)-+jT(r);return Math.round(n/$m)+1}function fi(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=ci(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??o.firstWeekContainsDate??o.locale?.options?.firstWeekContainsDate??1,i=Oe(t?.in||e,0);i.setFullYear(n+1,0,s),i.setHours(0,0,0,0);let a=pt(i,t),c=Oe(t?.in||e,0);c.setFullYear(n,0,s),c.setHours(0,0,0,0);let l=pt(c,t);return+r>=+a?n+1:+r>=+l?n:n-1}function hP(e,t){let r=ci(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=fi(e,t),s=Oe(t?.in||e,0);return s.setFullYear(o,0,n),s.setHours(0,0,0,0),pt(s,t)}function Bn(e,t){let r=ae(e,t?.in),n=+pt(r,t)-+hP(r,t);return Math.round(n/$m)+1}function Or(e,t){let r=e<0?"-":"",n=Math.abs(e).toString().padStart(t,"0");return r+n}var gP={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return Or(t==="yy"?n%100:n,t.length)},M(e,t){let r=e.getMonth();return t==="M"?String(r+1):Or(r+1,2)},d(e,t){return Or(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 Or(e.getHours()%12||12,t.length)},H(e,t){return Or(e.getHours(),t.length)},m(e,t){return Or(e.getMinutes(),t.length)},s(e,t){return Or(e.getSeconds(),t.length)},S(e,t){let r=t.length,n=e.getMilliseconds(),o=Math.trunc(n*Math.pow(10,r-3));return Or(o,t.length)}};function Vm(e,t){return ae(e,t?.in).getDate()}function yP(e,t){let r=ae(e,t?.in),n=r.getFullYear(),o=r.getMonth(),s=Oe(r,0);return s.setFullYear(n,o+1,0),s.setHours(0,0,0,0),s.getDate()}function Xm(e,t){return ae(e,t?.in).getHours()}function bP(e,t){let r=ae(e,t?.in).getDay();return r===0?7:r}function Jm(e,t){return ae(e,t?.in).getMinutes()}function Xc(e,t){return ae(e,t?.in).getFullYear()}function nn(e,t){return+ae(e)>+ae(t)}var xP=class{subPriority=0;validate(e,t){return!0}},wP=class extends xP{constructor(e,t,r,n,o){super(),this.value=e,this.validateValue=t,this.setValue=r,this.priority=n,o&&(this.subPriority=o)}validate(e,t){return this.validateValue(e,this.value,t)}set(e,t,r){return this.setValue(e,t,this.value,r)}};var pe=class{run(e,t,r,n){let o=this.parse(e,t,r,n);return o?{setter:new wP(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(e,t,r){return!0}},vP=class extends pe{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"]},Fe={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}/},Qt={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 je(e,t){return e&&{value:t(e.value),rest:e.rest}}function Ce(e,t){let r=t.match(e);return r?{value:parseInt(r[0],10),rest:t.slice(r[0].length)}:null}function Zt(e,t){let r=t.match(e);if(!r)return null;if(r[0]==="Z")return{value:0,rest:t.slice(1)};let n=r[1]==="+"?1:-1,o=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:n*(o*Fm+s*Yc+i*NT),rest:t.slice(r[0].length)}}function Qm(e){return Ce(Fe.anyDigitsSigned,e)}function Ie(e,t){switch(e){case 1:return Ce(Fe.singleDigit,t);case 2:return Ce(Fe.twoDigits,t);case 3:return Ce(Fe.threeDigits,t);case 4:return Ce(Fe.fourDigits,t);default:return Ce(new RegExp("^\\d{1,"+e+"}"),t)}}function ai(e,t){switch(e){case 1:return Ce(Fe.singleDigitSigned,t);case 2:return Ce(Fe.twoDigitsSigned,t);case 3:return Ce(Fe.threeDigitsSigned,t);case 4:return Ce(Fe.fourDigitsSigned,t);default:return Ce(new RegExp("^-?\\d{1,"+e+"}"),t)}}function Jc(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 Zm(e,t){let r=t>0,n=r?t:1-t,o;if(n<=50)o=e||100;else{let s=n+50,i=Math.trunc(s/100)*100,a=e>=s%100;o=e+i-(a?100:0)}return r?o:1-o}function eh(e){return e%400===0||e%4===0&&e%100!==0}var kP=class extends pe{priority=130;incompatibleTokens=["Y","R","u","w","I","i","e","c","t","T"];parse(e,t,r){let n=o=>({year:o,isTwoDigitYear:t==="yy"});switch(t){case"y":return je(Ie(4,e),n);case"yo":return je(r.ordinalNumber(e,{unit:"year"}),n);default:return je(Ie(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r){let n=e.getFullYear();if(r.isTwoDigitYear){let s=Zm(r.year,n);return e.setFullYear(s,0,1),e.setHours(0,0,0,0),e}let o=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(o,0,1),e.setHours(0,0,0,0),e}},EP=class extends pe{priority=130;parse(e,t,r){let n=o=>({year:o,isTwoDigitYear:t==="YY"});switch(t){case"Y":return je(Ie(4,e),n);case"Yo":return je(r.ordinalNumber(e,{unit:"year"}),n);default:return je(Ie(t.length,e),n)}}validate(e,t){return t.isTwoDigitYear||t.year>0}set(e,t,r,n){let o=fi(e,n);if(r.isTwoDigitYear){let i=Zm(r.year,o);return e.setFullYear(i,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),pt(e,n)}let s=!("era"in t)||t.era===1?r.year:1-r.year;return e.setFullYear(s,0,n.firstWeekContainsDate),e.setHours(0,0,0,0),pt(e,n)}incompatibleTokens=["y","R","u","Q","q","M","L","I","d","D","i","t","T"]},TP=class extends pe{priority=130;parse(e,t){return ai(t==="R"?4:t.length,e)}set(e,t,r){let n=Oe(e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),jn(n)}incompatibleTokens=["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"]},PP=class extends pe{priority=130;parse(e,t){return ai(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"]},RP=class extends pe{priority=120;parse(e,t,r){switch(t){case"Q":case"QQ":return Ie(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"]},SP=class extends pe{priority=120;parse(e,t,r){switch(t){case"q":case"qq":return Ie(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"]},_P=class extends pe{incompatibleTokens=["Y","R","q","Q","L","w","I","D","i","e","c","t","T"];priority=110;parse(e,t,r){let n=o=>o-1;switch(t){case"M":return je(Ce(Fe.month,e),n);case"MM":return je(Ie(2,e),n);case"Mo":return je(r.ordinalNumber(e,{unit:"month"}),n);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}},LP=class extends pe{priority=110;parse(e,t,r){let n=o=>o-1;switch(t){case"L":return je(Ce(Fe.month,e),n);case"LL":return je(Ie(2,e),n);case"Lo":return je(r.ordinalNumber(e,{unit:"month"}),n);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"]};function Qc(e,t,r){let n=ae(e,r?.in),o=Bn(n,r)-t;return n.setDate(n.getDate()-o*7),ae(n,r?.in)}var CP=class extends pe{priority=100;parse(e,t,r){switch(t){case"w":return Ce(Fe.week,e);case"wo":return r.ordinalNumber(e,{unit:"week"});default:return Ie(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r,n){return pt(Qc(e,r,n),n)}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","i","t","T"]};function OP(e,t,r){let n=ae(e,r?.in),o=mP(n,r)-t;return n.setDate(n.getDate()-o*7),n}var NP=class extends pe{priority=100;parse(e,t,r){switch(t){case"I":return Ce(Fe.week,e);case"Io":return r.ordinalNumber(e,{unit:"week"});default:return Ie(t.length,e)}}validate(e,t){return t>=1&&t<=53}set(e,t,r){return jn(OP(e,r))}incompatibleTokens=["y","Y","u","q","Q","M","L","w","d","D","e","c","t","T"]},MP=[31,28,31,30,31,30,31,31,30,31,30,31],IP=[31,29,31,30,31,30,31,31,30,31,30,31],DP=class extends pe{priority=90;subPriority=1;parse(e,t,r){switch(t){case"d":return Ce(Fe.date,e);case"do":return r.ordinalNumber(e,{unit:"date"});default:return Ie(t.length,e)}}validate(e,t){let r=e.getFullYear(),n=eh(r),o=e.getMonth();return n?t>=1&&t<=IP[o]:t>=1&&t<=MP[o]}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"]},AP=class extends pe{priority=90;subpriority=1;parse(e,t,r){switch(t){case"D":case"DD":return Ce(Fe.dayOfYear,e);case"Do":return r.ordinalNumber(e,{unit:"date"});default:return Ie(t.length,e)}}validate(e,t){let r=e.getFullYear();return eh(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"]};function Zc(e,t,r){let n=ci(),o=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=ae(e,r?.in),i=s.getDay(),a=(t%7+7)%7,c=7-o,l=t<0||t>6?t-(i+c)%7:(a+c)%7-(i+c)%7;return We(s,l,r)}var $P=class extends pe{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,n){return e=Zc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["D","i","e","c","t","T"]},FP=class extends pe{priority=90;parse(e,t,r,n){let o=s=>{let i=Math.floor((s-1)/7)*7;return(s+n.weekStartsOn+6)%7+i};switch(t){case"e":case"ee":return je(Ie(t.length,e),o);case"eo":return je(r.ordinalNumber(e,{unit:"day"}),o);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,n){return e=Zc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","c","t","T"]},jP=class extends pe{priority=90;parse(e,t,r,n){let o=s=>{let i=Math.floor((s-1)/7)*7;return(s+n.weekStartsOn+6)%7+i};switch(t){case"c":case"cc":return je(Ie(t.length,e),o);case"co":return je(r.ordinalNumber(e,{unit:"day"}),o);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,n){return e=Zc(e,r,n),e.setHours(0,0,0,0),e}incompatibleTokens=["y","R","u","q","Q","M","L","I","d","D","E","i","e","t","T"]};function UP(e,t,r){let n=ae(e,r?.in),o=bP(n,r),s=t-o;return We(n,s,r)}var BP=class extends pe{priority=90;parse(e,t,r){let n=o=>o===0?7:o;switch(t){case"i":case"ii":return Ie(t.length,e);case"io":return r.ordinalNumber(e,{unit:"day"});case"iii":return je(r.day(e,{width:"abbreviated",context:"formatting"})||r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiii":return je(r.day(e,{width:"narrow",context:"formatting"}),n);case"iiiiii":return je(r.day(e,{width:"short",context:"formatting"})||r.day(e,{width:"narrow",context:"formatting"}),n);case"iiii":default:return je(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"}),n)}}validate(e,t){return t>=1&&t<=7}set(e,t,r){return e=UP(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"]},HP=class extends pe{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(Jc(r),0,0,0),e}incompatibleTokens=["b","B","H","k","t","T"]},WP=class extends pe{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(Jc(r),0,0,0),e}incompatibleTokens=["a","B","H","k","t","T"]},qP=class extends pe{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(Jc(r),0,0,0),e}incompatibleTokens=["a","b","t","T"]},zP=class extends pe{priority=70;parse(e,t,r){switch(t){case"h":return Ce(Fe.hour12h,e);case"ho":return r.ordinalNumber(e,{unit:"hour"});default:return Ie(t.length,e)}}validate(e,t){return t>=1&&t<=12}set(e,t,r){let n=e.getHours()>=12;return n&&r<12?e.setHours(r+12,0,0,0):!n&&r===12?e.setHours(0,0,0,0):e.setHours(r,0,0,0),e}incompatibleTokens=["H","K","k","t","T"]},GP=class extends pe{priority=70;parse(e,t,r){switch(t){case"H":return Ce(Fe.hour23h,e);case"Ho":return r.ordinalNumber(e,{unit:"hour"});default:return Ie(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"]},KP=class extends pe{priority=70;parse(e,t,r){switch(t){case"K":return Ce(Fe.hour11h,e);case"Ko":return r.ordinalNumber(e,{unit:"hour"});default:return Ie(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"]},YP=class extends pe{priority=70;parse(e,t,r){switch(t){case"k":return Ce(Fe.hour24h,e);case"ko":return r.ordinalNumber(e,{unit:"hour"});default:return Ie(t.length,e)}}validate(e,t){return t>=1&&t<=24}set(e,t,r){let n=r<=24?r%24:r;return e.setHours(n,0,0,0),e}incompatibleTokens=["a","b","h","H","K","t","T"]},VP=class extends pe{priority=60;parse(e,t,r){switch(t){case"m":return Ce(Fe.minute,e);case"mo":return r.ordinalNumber(e,{unit:"minute"});default:return Ie(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"]},XP=class extends pe{priority=50;parse(e,t,r){switch(t){case"s":return Ce(Fe.second,e);case"so":return r.ordinalNumber(e,{unit:"second"});default:return Ie(t.length,e)}}validate(e,t){return t>=0&&t<=59}set(e,t,r){return e.setSeconds(r,0),e}incompatibleTokens=["t","T"]},JP=class extends pe{priority=30;parse(e,t){let r=n=>Math.trunc(n*Math.pow(10,-t.length+3));return je(Ie(t.length,e),r)}set(e,t,r){return e.setMilliseconds(r),e}incompatibleTokens=["t","T"]},QP=class extends pe{priority=10;parse(e,t){switch(t){case"X":return Zt(Qt.basicOptionalMinutes,e);case"XX":return Zt(Qt.basic,e);case"XXXX":return Zt(Qt.basicOptionalSeconds,e);case"XXXXX":return Zt(Qt.extendedOptionalSeconds,e);case"XXX":default:return Zt(Qt.extended,e)}}set(e,t,r){return t.timestampIsSet?e:Oe(e,e.getTime()-ii(e)-r)}incompatibleTokens=["t","T","x"]},ZP=class extends pe{priority=10;parse(e,t){switch(t){case"x":return Zt(Qt.basicOptionalMinutes,e);case"xx":return Zt(Qt.basic,e);case"xxxx":return Zt(Qt.basicOptionalSeconds,e);case"xxxxx":return Zt(Qt.extendedOptionalSeconds,e);case"xxx":default:return Zt(Qt.extended,e)}}set(e,t,r){return t.timestampIsSet?e:Oe(e,e.getTime()-ii(e)-r)}incompatibleTokens=["t","T","X"]},eR=class extends pe{priority=40;parse(e){return Qm(e)}set(e,t,r){return[Oe(e,r*1e3),{timestampIsSet:!0}]}incompatibleTokens="*"},tR=class extends pe{priority=20;parse(e){return Qm(e)}set(e,t,r){return[Oe(e,r),{timestampIsSet:!0}]}incompatibleTokens="*"},XW={G:new vP,y:new kP,Y:new EP,R:new TP,u:new PP,Q:new RP,q:new SP,M:new _P,L:new LP,w:new CP,I:new NP,d:new DP,D:new AP,E:new $P,e:new FP,c:new jP,i:new BP,a:new HP,b:new WP,B:new qP,h:new zP,H:new GP,K:new KP,k:new YP,m:new VP,s:new XP,S:new JP,X:new QP,x:new ZP,t:new eR,T:new tR};function mr(e,t,r){return We(e,-t,r)}var rR=/(\w)\1*|''|'(''|[^'])+('|$)|./g,nR=/^'([^]*?)'?$/,oR=/''/g,sR=/[a-zA-Z]/;function wt(e,t){let r=ae(e);if(!rn(r))throw new RangeError("Invalid time value");let n=t.match(rR);return n?n.map(o=>{if(o==="''")return"'";let s=o[0];if(s==="'")return iR(o);let i=gP[s];if(i)return i(r,o);if(s.match(sR))throw new RangeError("Format string contains an unescaped latin alphabet character "+s+"");return o}).join(""):""}function iR(e){let t=e.match(nR);return t?t[1].replace(oR,"'"):e}function aR(e,t,r){let n=ae(e,r?.in),o=n.getFullYear(),s=n.getDate(),i=Oe(r?.in||e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);let a=yP(i);return n.setMonth(t,Math.min(s,a)),n}function th(e,t,r){let n=ae(e,r?.in);return isNaN(+n)?Oe(r?.in||e,NaN):(t.year!=null&&n.setFullYear(t.year),t.month!=null&&(n=aR(n,t.month)),t.date!=null&&n.setDate(t.date),t.hours!=null&&n.setHours(t.hours),t.minutes!=null&&n.setMinutes(t.minutes),t.seconds!=null&&n.setSeconds(t.seconds),t.milliseconds!=null&&n.setMilliseconds(t.milliseconds),n)}function rh(e,t,r){return pi(e,-t,r)}var nh=e=>e==null,Mr=e=>typeof e=="string";async function*oh(e){let t=[],r,n=i=>{if(!r){t.push(i);return}r(i),r=void 0},o=()=>t.length>0?Promise.resolve(t.pop()):new Promise(i=>r=i),s=0;for(let i of e)i.then(a=>n({state:"fulfilled",value:a})).catch(a=>n({state:"rejected",reason:a})),s++;for(let i=0;i<s;i++)yield await o()}var dt=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,n,o,s,i,a,c,l,p,u,f,d,h]=t,g={title:h,base:new Date(parseInt(r),parseInt(n)-1,parseInt(o)),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(p)),g.record.start=y}if(u){let y=new Date(g.base);y.setHours(parseInt(u)),y.setMinutes(parseInt(f)),y.setSeconds(parseInt(d)),g.record.start&&nn(g.record.start,y)&&y.setDate(y.getDate()+1),g.record.end=y}return g};var Hn=e=>e.record?.start??e.plan?.start??e.base,sh=e=>e.record?.end??(nh(e.plan?.duration)?e.base:ui(Hn(e),e.plan.duration));var he=({title:e,base:t,plan:r,record:n})=>["",wt(t,"yyyy-MM-dd")," ",r?.start?wt(r.start,"HH:mm"):" ".repeat(5)," ",r?.duration?${r.duration/60}.padStart(4,"0"):" ".repeat(4)," ",n?.start?wt(n?.start,"HH:mm:ss"):" ".repeat(8)," ",n?.end?wt(n?.end,"HH:mm:ss"):" ".repeat(8),"",e].join("");function*ih(e){for(let t of on(e))Mr(t)||(yield t)}function*on(e){for(let t=0;t<e.length;t++){let r=e[t],n=Mr(r)?r:r.text,o=Qr(t,e),s=dt(n);if(!s){yield n;continue}yield{...s,lines:e.slice(t+1,t+1+o).map(i=>Mr(i)?i:i.text)},t+=o}}var cR=5*60,No=async()=>{let e=Le().position.line,t=dt(Je(e)??""),r=t?.base??new Date,n={start:t?.plan?.start?ui(t.plan.start,cR+(t.plan.duration??0)):void 0,duration:t?.plan?.duration};await om(e+1,he({title:"",base:r,plan:n,record:{}}))};var sn=async()=>{let e=Le().position.line,t=dt(Je(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;n||await it(e,e,he({record:{start:r?void 0:new Date},...o}))};var hr=async()=>{let e=Le().position.line,t=dt(Je(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;r&&await it(e,e,he({record:{start:r,end:n?void 0:new Date},...o}))};var el=async()=>{let e=Le().position.line,t=dt(Je(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;if(!r){await sn();return}if(!n){await hr();return}await it(e,e,he({record:{},...o}))};var Mo=async()=>{let e=Le().position.line,t=dt(Je(e)??"");if(!t)return;let{record:{start:r,end:n},...o}=t;if(r){if(n)return;await hr();return}if(n)return;let s;for(let{text:a}of zt().slice(0,(e??0)+1).reverse()){let{record:c}=dt(a)??{};if(c?.end){s=c.end;break}}let i=new Date;await it(e,e,he({record:{start:s??i,end:i},...o}))};var an=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:n}=Le();return r===""?[n.line,n.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var tl=(e,t=7)=>new Date((e+2592e3*((t+1)**1.5-1)/5221.154823442138)*1e3);var rl=(e,t)=>{let r,n,o,s,i=null;if(i=e.match(/^(.*?)(s|e):([^\s]+)\s+d:(\d+)/))[,n,s,o,r]=i;else if(i=e.match(/^(.*?)d:(\d+)\s+(s|e):([^\s]+)/))[,n,r,s,o]=i;else if(i=e.match(/^(.*?)(s|e):([^\s]+)/))[,n,s,o]=i;else return(i=e.match(/^(.*?)d:(\d+)/))?([,n,r]=i,{name:n.trimEnd(),duration:parseInt(r)*60}):void 0;for(let{test:a,parse:c}of lR){let l=o.match(a);if(!l)continue;let p=c(l),u=p.isDuration?Um(t,p):th(t,p);return s==="s"?{name:n.trimEnd(),start:u,...r!==void 0?{duration:parseInt(r)*60}:{}}:{name:n.trimEnd(),start:tl(t.getTime()/1e3,(u.getTime()-t.getTime())/(24*60*60*1e3)),...r!==void 0?{duration:parseInt(r)*60}:{}}}},lR=[{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 cn=async()=>{let e=new Date,[t,r]=an(),n=zt().slice(t,r+1).map(s=>s.text),o=n.flatMap(s=>{let i=s.trimEnd();if(i==="")return s;let{name:a,start:c,duration:l}=rl(i,e)??{};return!a||!c&&!l?s:[he({title:a.trim(),base:c??e,plan:{start:c,duration:l},record:{}})]}).join( );n.join(
)!==o&&await it(t,r,o)};var mi=async(e,t,r)=>{let n=[];for(let o=e;o<=t;o++){let s=Je(o)??"",i=dt(s);if(!i){n.push(s);continue}n.push(he(r(i,o)))}await it(e,t,n.join(
))};var Io=async(e=1)=>{let[t,r]=an();await mi(t,r,n=>(n.base=We(n.base,e),n))};var Do=async()=>{let[e,t]=an(),r=new Date;await mi(e,t,n=>(gt(n.base,r)||(n.base=r),n))};var uR="日刊記録sheet",pR=/日刊記録sheet (\d{4})-(\d{2})-(\d{2})/,Ao=["[** 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 nl=e=>{let t=e.match(pR);if(!t)return;let[,r,n,o]=t,s=new Date(parseInt(r),parseInt(n)-1,parseInt(o));return rn(s)?s:void 0},Ir=e=>wt(e,'${uR}' yyyy-MM-dd),ln=e=>{let t=nl(e[0]);if(!t)return e;let r=dR(t),n=[],o=[];for(let a of on(e.slice(1))){if(typeof a=="string"){if(Ao.includes(a)||r!==""&&r===a)continue;o.push(a);continue}n.push(a)}let s=n.sort((a,c)=>qm(Hn(a),Hn(c)));if(s.length===0)return[e[0],r,...Ao,...o];let i=[0,0,0,0,0,0,0,0];for(let a=1;a<Ao.length;a++){let c=Hm(new Date(t.getFullYear(),t.getMonth(),t.getDate()),3*a),l=s.findIndex(d=>nn(Hn(d),c));if(l<0){i[a]=-1;continue}if(l===0)continue;let p=s[l-1],u=Hn(p),f=sh(p);i[a]=(f.getTime()-u.getTime())/2<c.getTime()-u.getTime()?l:l-1}return[e[0],r,...s.flatMap((a,c)=>[...i.flatMap((l,p)=>l===c?[Ao[p]]:[]),he(a),...a.lines]),...i.flatMap((a,c)=>a===-1?[Ao[c]]:[]),...o]},dR=e=>yesterday: ${Ir(mr(e,1))};var $o=async(e,t)=>{let r=()=>{},n=setTimeout(()=>{let{render:o,dispose:s}=Re();r=s,o({type:"spinner"},{type:"text",text:"formatting..."})},500);await me(e,t,o=>ln(o.map(s=>s.text))),clearTimeout(n),r()};async function*ol(e,t,r){let n=[...t],o=[];for(;n.length>0;){let s=n.shift();if(!s)break;let i=s.base,a=[s];for(let c=0;c<n.length;c++)gt(n[c].base,i)&&(a.push(...n.splice(c,1)),c--);o.push((async()=>(await me(e,Ir(i),c=>ln([...c.map(l=>l.text),...a.flatMap(l=>[he(l),...l.lines??[]])]),r),{date:i,size:a.length}))())}yield*oh(o)}var un=async({from:{project:e,title:t},to:r})=>{let n=await Nt(e,t);if(W(n))throw ee(n);let o=nl(t),{lines:s}=B(n),i=[];for(let u of ih(s))o&>(u.base,o)||i.push(u);let{render:a,dispose:c}=Re();a({type:"spinner"},{type:"text",text:copying ${i.length} tasks...});let l=await ze();if(W(l))throw ee(l);let p=B(l);try{let u=0,f=!1;for await(let d of ol(r,i,{socket:p})){if(d.state!=="fulfilled"){console.error(d.reason),f=!0;continue}u+=d.value.size,a({type:"spinner"},{type:"text",text:copying ${i.length-u} 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 me(e,t,d=>{let h=[];for(let g of on(d)){if(Mr(g)){h.push(g);continue}o&>(g.base,o)&&h.push(he(g),...g.lines)}return h},{socket:p}),a({type:"check-circle"},{type:"text",text:"Moved"})}finally{await nt(p),await Ee(1e3),c()}};var ah=e=>typeof e=="string";var Dr=e=>e.match(/^(\s*)/)?.[1]?.length??0,lh=(e,t)=>{let r=Dr(ch(e,t)),n=0;for(;e+n+1<t.length&&Dr(ch(e+n+1,t))>r;)n++;return n},ch=(e,t)=>{let r=t[e];return ah(r)?r:r.text};var Gt=e=>${e}.padStart(2,"0");var pn=e=>"hours"in e,Dt=(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,er=e=>${${e.year}.padStart(4,"0")}-${Gt(e.month)}-${Gt(e.date)}${"hours"in e?T${Gt(e.hours)}:${Gt(e.minutes)}:""},de=e=>{let t=er(e);return new Date(t.includes("T")?t:${t}T00:00)},yt=e=>({year:e.getFullYear(),month:e.getMonth()+1,date:e.getDate(),hours:e.getHours(),minutes:e.getMinutes()});var ph=e=>{switch(e.toLowerCase()){case"y":return"yearly";case"m":return"monthly";case"w":return"weekly";case"d":return"daily";default:return}};var dh=e=>{switch(e){case"+":return"todo";case"-":return"note";case"!":return"deadline";case".":return"done";case"~":return"up-down";default:return}},fh=e=>{switch(e){case"todo":return"+";case"note":return"-";case"deadline":return"!";case"done":return".";case"up-down":return"~"}};var At=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,n,o,s,i,a,c,l,p,u,f,d,h,g,y,w,R,E,b,k,v,L,C,O,S,T,P,_,M,I,F,D,q]=t,j=${e.slice(0,t.index).trim()}${e.slice((t.index??0)+r.length).trim()},z=mh(s,i,a,c,l);if(!rn(de(z)))return Z({name:"InvalidDateError",message:The reference point of the task "${er(z)}" is an invalid date.});let G=hh(z,f,d,h,p||g,u||y,w);if(G!==void 0){if(Ve(G)&&isNaN(G)||!Ve(G)&&!rn(de(G)))return Z({name:"InvalidDateError",message:The estimated end of the task${Ve(G)?"": "${er(G)}"} is an invalid date.});if(Ve(G)&&G<0||!Ve(G)&&Dt(G,z))return Z({name:"TaskRangeError",message:The reference point of an task cannot be after its estimated end. reference point:${er(z)}
estimated end:${er(Ve(G)?yt(Nr(de(z),G)):G)}})}let se=/^[\uFE00-\uFE0F]*[✅❌]/.test(e)?"done":dh(n),Q=se?{status:se,refDate:z}:void 0;Q&&o&&(Q.speed=parseInt(o));let rt=mh(v||s,L||i,C||a,b||O||c,k||S||l);if(!rn(de(rt)))return Z({name:"InvalidDateError",message:The start of the task/event "${er(rt)}" is an invalid date.});let Pe=hh(rt,_||f,M||d,I||h,T||F||p||g,P||D||u||y,q||w),$=pn(rt)&&Ve(Pe)?{start:rt,duration:Pe}:void 0;if($){let at={name:j,executed:$,generated:!1,raw:e};return Q&&(at.freshness=Q),(R||E)&&(at.recurrence={frequency:ph(R??"D")??"daily",count:E?parseInt(E):1}),we(at)}if(!Q)return Z({name:"InvalidDateError",message:"Task requires freshness to be spec"});let ye={name:j,freshness:Q,generated:!1,raw:e};return G&&(ye.estimated=G),we($?{...ye,executed:$}:ye)},tr=e=>!("executed"in e),Ar=e=>"recurrence"in e,gh=e=>!("executed"in e||"freshness"in e&&pn(e.freshness.refDate)&&e.estimated&&(Ve(e.estimated)||pn(e.estimated))),jo=e=>"executed"in e?e.executed.duration:Ve(e.estimated)?e.estimated:void 0,rr=e=>tr(e)?e.freshness.refDate:e.executed.start,yh=e=>{if(!tr(e)){let r=de(e.executed.start);return yt(Nr(r,e.executed.duration))}if(Ve(e.estimated)&&pn(e.freshness.refDate)){let r=de(e.freshness.refDate);return yt(Nr(r,e.estimated))}let t=de(Ve(e.estimated)?e.freshness.refDate:e.estimated??e.freshness.refDate);return t.setHours(0),t.setMinutes(0),yt(We(t,1))},bR=e=>{let t=e.freshness?${fh(e.freshness.status)}${e.freshness.speed??""}:"",r=${er(rr(e))},n=jo(e);return${t}@${r}${n===void 0?"":D${n}}${e.name}},hi=(e,t)=>{let r=yt(t),{recurrence:n,executed:o}=e;switch(n.frequency){case"yearly":{if(Math.abs(r.year-o.start.year)%(n.count??1)!==0||o.start.month!==r.month||o.start.date!==r.date)return;break}case"monthly":{if(zm(de(r),de(o.start))%(n.count??1)!==0)return;break}case"weekly":case"daily":{let a=n.frequency==="weekly"?7:1;if(Wm(de(r),de(o.start))%((n.count??1)*a)!==0)return;break}}let s={...o.start};s.year=r.year,s.month=r.month,s.date=r.date;let i={name:e.name,executed:{start:s,duration:o.duration},generated:!0,raw:e.raw};return e.freshness&&(i.freshness=e.freshness),i},gi=e=>e.freshness?e.generated?bR(e):e.raw:e.generated?void 0:e.raw,mh=(e,t,r,n,o)=>{let s=parseInt(e),i=parseInt(t),a=parseInt(r),c=n?parseInt(n):void 0,l=o?parseInt(o):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}},hh=(e,t,r,n,o,s,i)=>{if(!t&&!r&&!n&&!o&&!s&&!i)return;if(i)return parseInt(i);let a=t?parseInt(t):e.year,c=r?parseInt(r):e.month,l=n?parseInt(n):e.date,p=o?parseInt(o):void 0,u=s?parseInt(s):void 0,f=p!==void 0&&u!==void 0?{year:a,month:c,date:l,hours:p,minutes:u}:{year:a,month:c,date:l};return!pn(e)||!pn(f)?f:Math.round((de(f).getTime()-de(e).getTime())/(60*1e3))};var dn=(e,t)=>{if(!e.generated&&Ar(e)){let s=hi(e,t);return s?dn(s,t):void 0}let r=de(tr(e)?e.freshness.refDate:e.executed.start),n=jo(e),o=gi(e);return{title:o!==void 0?${o}:e.name,base:r,plan:{start:gh(e)?void 0:r,duration:n!==void 0?n*60:void 0},record:{}}};var sl={あさごはん:"#log-breakfast",ひるごはん:"#log-lunch",よるごはん:"#log-dinner"},fn=(e,{title:t,projectTo:r,mode:n})=>{let[o,...s]=e.split( ),i=dt(o);if(!i)return;if(s.length===0)return{text:e,pages:[]};let{title:a,base:c,record:l,...p}=i,u=xR(a,c,l),f=he({title:${u},base:c,record:l,...p}),d=Math.min(...s.map(g=>Dr(g))),h=[.../[\[\]]/.test(a)&&a!==${u}?[a]:[],...t in sl?[...s.map(g=>g.slice(d)),"",sl[t],"#log-eatenfood"]:[...s.map(g=> ${g.slice(d)}),""]];return{text:f,pages:[{project:r,title:u,lines:bh(t,h,[l.start??c]),mode:n}]}};fn.hookName="task-hook";var xR=(e,t,r)=>{let n=ht(r.start??t,"yyyy-MM-dd");if(e in sl)return${n} ${e};if(At(e.slice(1,-1)))return e.slice(1,-1);let o=e.replace(/[\[\]]/g,"").trim();return${o}${o.endsWith(n)?"": ${n}}},mn=(e,{title:t,projectTo:r,mode:n,lines:o})=>{let[s,...i]=e.split( );if(i.length===0)return;let a=s.replace(/[\[\]]/g,"").trim(),c=Math.min(...i.map(u=>Dr(u))),l=r.startsWith("takker")?Dm([new Date,...o.map(({updated:u})=>new Date(u*1e3))]).sort((u,f)=>f.getTime()-u.getTime()):[],p=["",.../[\[\]]/.test(s)?[s.trimStart()]:[],...i.map(u=>u.slice(c))];return{text:${" ".repeat(Dr(s))}${a},pages:[{project:r,title:a,lines:bh(t,p,l),mode:n}]}};mn.hookName="new-page-hook";var hn=(e,{projectTo:t,mode:r})=>{if(e.includes( )||!/\[[^\]]+\]/.test(e))return;let[n,o]=e.match(/^(\s*)(.*)$/)?.slice?.(1)??["",e],s=[...o.matchAll(/\[([^\]])\]/g)].map(a=>re(a[1])),i=o.replaceAll("[","").replaceAll("]","");return{text:${n}${i},pages:[{project:t,title:i,lines:(a,{links:c})=>{let l=c.map(p=>re(p));if(!s.every(p=>l.includes(p)))return[...a.map(p=>p.text),o]},mode:r}]}};hn.hookName="splitted-link-hook";var bh=(e,t,r)=>(n,{links:o})=>{let s=o.map(u=>re(u)),i=s.includes(re(e))?[]:[from ${e}],a=r.flatMap(u=>{let f=ht(u,"yyyy-MM-dd");if(s.includes(f))return[];let d=ht(u,"HH:mm:ss");return[#${f} ${d}]}),c=n.map(u=>u.text),l=c.findIndex(u=>/^#\d{4}-\d{2}-\d{2}/.test(u)),p=l<0?c.length:l;return[...c.slice(0,p),...i,...t,"",...a,...c.slice(p)]};var xh=e=>e.preventDefault(),wh=e=>e.stopPropagation(),vh={"<A-a><A-c>":async e=>{xh(e),wh(e);let[t,r]=wR(),n=zt().slice(t,r+1).map(o=>{let s=o.text,i=o.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=At(i);if(!a||Lo(a))return s;let c=en(a);if(c.freshness?.status==="done")return s;let l=dn(c,new Date);return l?(l.title=${i},he(l)):s}).join( );await it(t,r,n),await cn()},"<A-a><A-m>":e=>{scrapbox.Layout==="page"&&(xh(e),wh(e),un({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"}))}},wR=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:n}=Le();return r===""?[n.line,n.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var gn=e=>e.preventDefault(),yn=e=>e.stopPropagation(),il={"<A-a><A-a>":e=>{gn(e),yn(e),No()},"<A-a><A-s>":e=>{gn(e),yn(e),sn()},"<A-a><A-e>":e=>{gn(e),yn(e),hr()},"<A-a><A-0>":e=>{gn(e),yn(e),Mo()},"<A-a><A-1>":e=>{gn(e),yn(e),Io(1)},"<A-a><A-t>":e=>{gn(e),yn(e),Do()},"<A-a><A-S>":e=>{scrapbox.Layout==="page"&&(gn(e),yn(e),$o(scrapbox.Project.name,scrapbox.Page.title))}};var Ze=e=>e.preventDefault(),et=e=>e.stopPropagation(),bn=(e,t)=>{let r=zf()?.getElementsByClassName?.("button");if(!r)return;let n=[...r].find(o=>t instanceof RegExp?t.test(o.textContent??""):o.textContent===t);n instanceof HTMLDivElement&&e.target===document.activeElement&&(Ze(e),et(e),n.click())},vR={"-":e=>bn(e,""),"]":e=>bn(e,""),c:e=>bn(e,"Copy plain"),$:e=>bn(e,""),"{":e=>bn(e,/{{c\d+}}/),"}":e=>bn(e,"reset cloze"),n:e=>bn(e,"make note")},kR={"<C-]>":e=>{let{position:{line:t,char:r}}=Le(),n=Ro(t,r)?.closest("a.page-link")??Zr(t)?.querySelector?.("a.page-link");n instanceof HTMLAnchorElement&&(Ze(e),et(e),n.click())},"<C-o>":e=>{Ze(e),et(e),history.back()}},ER={"<C-home>":e=>{Ze(e),et(e),Zf()},"<C-end>":e=>{Ze(e),et(e),em()}},kh=[fn,mn,hn],TR={"<C-X>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(Ze(e),et(e),fr({project:t,mode:"self",hooks:kh})?.())},"<C-D>":e=>{let t=window.prompt("Create a new page at",scrapbox.Project.name);t&&(Ze(e),et(e),fr({project:t,mode:"noopen",hooks:kh})?.())},"<C-h>":e=>{Ze(e),et(e),Ks()},"<C-j>":e=>{Ze(e),et(e),Vs()},"<C-k>":e=>{Ze(e),et(e),Ys()},"<C-l>":e=>{Ze(e),et(e),Gs()},"<A-h>":e=>{Ze(e),et(e),Js()},"<A-j>":e=>{Ze(e),et(e),Zs()},"<A-k>":e=>{Ze(e),et(e),Qs()},"<A-l>":e=>{Ze(e),et(e),Xs()}};scrapbox.TimeStamp.removeAllFormats();var PR={"<A-t><A-t>":e=>{Ze(e),et(e),Qe(ht(new Date,"#yyyy-MM-dd HH:mm:ss "))},"<A-t><A-j>":e=>{Ze(e),et(e),Qe(ht(new Date,"yyyy-MM-dd HH:mm:ss "))},"<A-t><A-k>":e=>{Ze(e),et(e),Qe(ht(new Date,"HH:mm:ss "))},"<A-t><A-l>":e=>{Ze(e),et(e),Qe(ht(new Date,"yyyy-MM-dd"))}},Eh={...vR,...kR,...ER,...TR,...PR,...vh};var{render:RR}=Re(),al,SR=e=>{al!==void 0&&cancelAnimationFrame(al),al=requestAnimationFrame(()=>RR({type:"text",text:e}))},cl=new si({addEventListener:am,removeEventListener:Hc},{onSequenceUpdate:SR}),Th=cl.bind({...Eh,...scrapbox.Project.name==="takker-memex"?il:{}});Th.size>0&&alert([...Th.entries()].map(([e,t])=>${e}:
${t.map(r=>- ${r}).join(`
)}).join(`
));var _R=/https?:\/\/vimeo\.com\/([0-9]+)/i,Ph=e=>{let t=e.match(_R);if(t)return t[1]};var LR=/https?:\/\/open\.spotify\.com\/(track|artist|playlist|album|episode|show)\/([a-zA-Z\d_-]+)(?:\?[^\s]{0,100}|)/,Rh=e=>{let t=e.match(LR);if(!t)return;let[,r,n]=t;return{videoId:n,pathType:r}};var CR=/https?:\/\/anchor\.fm\/[a-zA-Z\d_-]+\/episodes\/([a-zA-Z\d_-]+(?:\/[a-zA-Z\d_-]+)?)(?:\?[^\s]{0,100}|)/,Sh=e=>{let t=e.match(CR);if(!t)return;let[,r]=t;return r};var _h=e=>{let{type:t,pathType:r,content:n,href:o,...s}=e;if(n===""){let i=Ms(o);if(i)return{type:"youtube",href:o,...i,...s};let a=Ph(o);if(a)return{type:"vimeo",videoId:a,href:o,...s};let c=Rh(o);if(c)return{type:"spotify",href:o,...c,...s};let l=Sh(o);if(l)return{type:"anchor-fm",videoId:l,href:o,...s};if(NR(o))return{type:"video",href:o,...s}}return OR(o)?{type:"audio",content:n,href:o,...s}:{type:"absoluteLink",content:n,href:o,...s}},OR=e=>/\.(?:mp3|ogg|wav|aac)$/.test(e),NR=e=>/\.(?:mp4|webm)$/.test(e);var Lh=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),n=await Ns([]);if(W(n))return r;let o=B(n).projects.map(s=>s.id);return r.filter(s=>!o.includes(s))}catch(t){if(!(t instanceof SyntaxError))throw t;return[]}};var MR;(e=>{})(MR||={});var IR="0.13.3",ll,ul,Ch=(e=IR)=>{let t=https://cdnjs.cloudflare.com/ajax/libs/KaTeX/${e}/katex.min.js;if(ul)throw ul;if(!document.querySelector(scriptsrc="${t}")){let r=document.createElement("script");r.src=t,ll=new Promise((n,o)=>{r.onload=()=>n(window.katex),r.onerror=s=>{ul=s,o(s)},document.head.append(r)})}return ll||new Promise(r=>{let n=setInterval(()=>{window.katex&&(clearInterval(n),r(window.katex))},500)})};var yi=(e,t)=>{let[r,n]=X("");return{ref:A(s=>{if(!s){n("");return}Ch().then(i=>{try{i.render(e,s,t),n("")}catch(a){if(a instanceof Error&&a.name==="ParseError")n(a.message.slice(19));else throw a}})},[e,...Object.values(t??{})]),error:r}};var Oh=e=>{let t=[],r=new Set,n=o=>{r.delete(o);let s=t.pop();if(!s)return;let i=s[0]().finally(()=>n(i)).then(a=>s[1](a)).catch(a=>s[2](a));r.add(i)};return o=>{if(r.size<e){let s=o().finally(()=>n(s));return r.add(s),s}return new Promise((s,i)=>{t.push([o,s,i])})}};var DR="0.6.5",Ih=ScrapBubble-${DR},Nh=await globalThis.caches.open(Ih);(async()=>{for(let e of await globalThis.caches.keys())e.startsWith("ScrapBubble-")&&e!==Ih&&(await globalThis.caches.delete(e),console.log(ScrapBubble deleted old cache :"${e}"))})();var Mh=Oh(3);async function*bi(e,t){let r=((t?.saveFailedResponse?Nh.match(e):void 0)??Fn(e,t)).then(i=>["cache",i]);{let i=Ee(1e3).then(()=>"timeout"),a=await Promise.race([r,i]);if(a!=="timeout"){a[1]&&(yield["cache",a[1]]);let c=await Mh(()=>fetch(e));!c.ok&&t?.saveFailedResponse&&await Nh.put(e,c.clone()),yield["network",c]}}let n=Mh(()=>fetch(e)).then(i=>["network",i]),[o,s]=await Promise.race([r,n]);if(o==="network"){yield[o,s];return}s&&(yield[o,s]),yield await n}var Dh=(e,t)=>new Date(e.headers.get("Date")??0).getTime()/1e3+t<new Date().getTime()/1e3;var xi=()=>{let e=new Map;return{dispatch:(t,r)=>{let n=e.get(t);if(n)for(let o of n)o(r)},on:(t,r)=>{let n=e.get(t)??new Set;n.add(r),e.set(t,n)},off:(t,r)=>{let n=e.get(t);n&&n.delete(r)}}};var Rt=!1,Ah=e=>{Rt=typeof e=="boolean"?e:new Set(e)},$r=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},"color: gray",...n)];case"log":case"info":case"debug":return[t,(...n)=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(%c${e},"color: gray",...n)}];case"assert":return[t,(n,...o)=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(n,%c${e},"color: gray",...o)}];case"time":case"timeEnd":return[t,n=>{Rt!==!0&&(!Rt||!Rt.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(Rt!==!0&&(!Rt||!Rt.has(e))))return r(...n)}]}}));var pl=xi(),wi=new Map,AR=$r("ScrapBubble:useProject.ts"),$h=e=>{let[t,r]=X();return te(()=>{pl.on(e,r);let n=wi.get(e);return n?r(n.loading?void 0:n.value):(wi.set(e,{loading:!0}),r(void 0),(async()=>{try{let o=lr.toRequest(e);for await(let[,s]of bi(o)){let i=await lr.fromResponse(s);wi.set(e,{loading:!1,value:i}),pl.dispatch(e,i);break}}catch(o){AR.error(o),wi.delete(e)}})()),()=>pl.off(e,r)},[e]),t};var $R=["default-light","default-dark","default-minimal"],FR=["paper-light","paper-dark-dark","paper-dark"],Fh=["blue","purple","green","orange","red"],jR=["hacker1","hacker2"],jh=["winter","spring","summer","automn"],Uh=["tropical"],Bh=["kyoto","newyork","paris"],Hh=["mred","lgreen"],fY=["default-light","default-minimal","paper-light",...Fh,...jh,...Uh,...Bh,...Hh];var UR=[...$R,...FR,...Fh,...jR,...jh,...Uh,...Bh,...Hh];function Wh(e){return UR.includes(e)}var qh="default-light",xn=e=>{let t=$h(e);return N(()=>{if(!t||W(t))return qh;let r=B(t).theme;return Wh(r)?r:qh},[t])};var Wn=(e,t)=>new Promise(r=>{let n=!1,o=()=>{n=!0,r(!1)};e.addEventListener("click",o),e.addEventListener("pointerleave",o),setTimeout(()=>{n||r(!0),e.removeEventListener("click",o),e.removeEventListener("pointerleave",o),r(!1)},t)});var qn=e=>{let{top:t,right:r,left:n,bottom:o}=e.getBoundingClientRect(),s=document.body.getBoundingClientRect(),i=(n-s.left)/s.width>.5;return{top:Math.round(o-s.top),bottom:Math.round(globalThis.innerHeight-globalThis.scrollY-t),...i?{right:Math.round(s.right-r)}:{left:Math.round(n-s.left)},maxWidth:i?r-10:document.documentElement.clientWidth-n-10}};var zh=({project:e,title:t,descriptions:r,thumbnail:n,linkTo:o,bubble:s,delay:i,prefetch:a})=>{let c=N(()=>n?[]:Be(r.join( ),{hasTitle:!1}),[n,r]),l=xn(e),p=A(async({currentTarget:f})=>{a(e,t),await Wn(f,i)&&s({project:e,title:t,linkTo:o,type:"link",position:qn(f)})},[e,t,i,o?.project,o?.titleLc]),u=N(()=>o?()=>{$n({type:"page",from:{project:o.project??e,title:o.titleLc},to:{project:e,title:t}})}:()=>{},[e,t,o?.project,o?.titleLc]);return m("a",{className:"related-page-card page-link",type:"link","data-theme":l,href:/${e}/${ue(t)},rel:e===scrapbox.Project.name?"route":"noopner noreferrer",target:e!==scrapbox.Project.name?"_blank":"",onPointerEnter:p,onClick:u,children:[m("div",{class:"hover"}),m("div",{class:"content",children:[m("div",{class:"header",children:m("div",{class:"title",children:t})}),n?m("div",{class:"thumbnail",children:m("img",{src:n})}):m("div",{class:"description",children:c.flatMap((f,d)=>f.type==="line"?[m("p",{children:f.nodes.map(h=>m(Gh,{node:h,project:e}))},d)]:[])})]})]})},Gh=({node:e,project:t})=>{switch(e.type){case"code":return m("code",{children:e.text});case"formula":return m(BR,{node:e});case"commandLine":return m("code",{children:[e.symbol," $",e.text]});case"helpfeel":return m("code",{children:["? ",e.text]});case"quote":case"strong":case"decoration":return m(Y,{children:e.nodes.map(r=>m(Gh,{node:r,project:t}))});case"icon":case"strongIcon":return m(HR,{node:e,project:t});case"hashTag":return m(WR,{node:e});case"link":return m(qR,{node:e});case"plain":case"blank":return m(Y,{children:e.text});default:return m(Y,{})}},BR=({node:{formula:e}})=>{let{ref:t,error:r}=yi(e);return m("span",{className:formula ${r?" error":""},children:r?m("code",{children:e}):m("span",{className:"katex-display",ref:t})})},HR=({node:{pathType:e,path:t},project:r})=>{let[n,o]=e==="relative"?[r,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[r,t];return m("img",{class:"icon",src:/api/pages/${n}/${ue(o)}/icon})},WR=({node:{href:e}})=>m("span",{class:"page-link",children:["#",e]}),qR=({node:{pathType:e,href:t,content:r}})=>e!=="absolute"?m("span",{class:"page-link",children:t}):m("span",{class:"link",children:r||t});var ge=(e,t)=>/${e.toLowerCase()}/${re(t)},vi=e=>{let t=e.match("/([^/]+)/(.+)");if(!t)throw SyntaxError("${e}" cannnot match "/(^/+)/(.+)");return{project:t[1],titleLc:t[2]}};var Qh=Symbol.for("immer-nothing"),Kh=Symbol.for("immer-draftable"),fe=Symbol.for("immer-state");function $t(e,...t){throw new Error(Immer minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf)}var zn=Object.getPrototypeOf;function Gn(e){return!!e&&!!e[fe]}function yr(e){return e?Zh(e)||Array.isArray(e)||!!e[Kh]||!!e.constructor?.[Kh]||Ri(e)||Si(e):!1}var zR=Object.prototype.constructor.toString();function Zh(e){if(!e||typeof e!="object")return!1;let t=zn(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)===zR}function Uo(e,t){Pi(e)===0?Reflect.ownKeys(e).forEach(r=>{t(r,e[r],e)}):e.forEach((r,n)=>t(n,r,e))}function Pi(e){let t=e[fe];return t?t.type_:Array.isArray(e)?1:Ri(e)?2:Si(e)?3:0}function ml(e,t){return Pi(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function eg(e,t,r){let n=Pi(e);n===2?e.set(t,r):n===3?e.add(r):e[t]=r}function GR(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ri(e){return e instanceof Map}function Si(e){return e instanceof Set}function ot(e){return e.copy_||e.base_}function hl(e,t){if(Ri(e))return new Map(e);if(Si(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let r=Zh(e);if(t===!0||t==="class_only"&&!r){let n=Object.getOwnPropertyDescriptors(e);delete n[fe];let o=Reflect.ownKeys(n);for(let s=0;s<o.length;s++){let i=o[s],a=n[i];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(n[i]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[i]})}return Object.create(zn(e),n)}else{let n=zn(e);if(n!==null&&r)return{...e};let o=Object.create(n);return Object.assign(o,e)}}function xl(e,t=!1){return _i(e)||Gn(e)||!yr(e)||(Pi(e)>1&&(e.set=e.add=e.clear=e.delete=KR),Object.freeze(e),t&&Object.entries(e).forEach(([r,n])=>xl(n,!0))),e}function KR(){$t(2)}function _i(e){return Object.isFrozen(e)}var gl={};function wn(e){let t=gl[e];return t||$t(0,e),t}function YR(e,t){gl[e]||(gl[e]=t)}var Bo;function ki(){return Bo}function VR(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Yh(e,t){t&&(wn("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function yl(e){bl(e),e.drafts_.forEach(XR),e.drafts_=null}function bl(e){e===Bo&&(Bo=e.parent_)}function Vh(e){return Bo=VR(Bo,e)}function XR(e){let t=e[fe];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Xh(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];return e!==void 0&&e!==r?(r[fe].modified_&&(yl(t),$t(4)),yr(e)&&(e=Ei(t,e),t.parent_||Ti(t,e)),t.patches_&&wn("Patches").generateReplacementPatches_(r[fe].base_,e,t.patches_,t.inversePatches_)):e=Ei(t,r,[]),yl(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Qh?e:void 0}function Ei(e,t,r){if(_i(t))return t;let n=t[fe];if(!n)return Uo(t,(o,s)=>Jh(e,n,t,o,s,r)),t;if(n.scope_!==e)return t;if(!n.modified_)return Ti(e,n.base_,!0),n.base_;if(!n.finalized_){n.finalized_=!0,n.scope_.unfinalizedDrafts_--;let o=n.copy_,s=o,i=!1;n.type_===3&&(s=new Set(o),o.clear(),i=!0),Uo(s,(a,c)=>Jh(e,n,o,a,c,r,i)),Ti(e,o,!1),r&&e.patches_&&wn("Patches").generatePatches_(n,r,e.patches_,e.inversePatches_)}return n.copy_}function Jh(e,t,r,n,o,s,i){if(Gn(o)){let a=s&&t&&t.type_!==3&&!ml(t.assigned_,n)?s.concat(n):void 0,c=Ei(e,o,a);if(eg(r,n,c),Gn(c))e.canAutoFreeze_=!1;else return}else i&&r.add(o);if(yr(o)&&!_i(o)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Ei(e,o),(!t||!t.scope_.parent_)&&typeof n!="symbol"&&Object.prototype.propertyIsEnumerable.call(r,n)&&Ti(e,o)}}function Ti(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&xl(t,r)}function JR(e,t){let r=Array.isArray(e),n={type_:r?1:0,scope_:t?t.scope_:ki(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},o=n,s=wl;r&&(o=[n],s=Ho);let{revoke:i,proxy:a}=Proxy.revocable(o,s);return n.draft_=a,n.revoke_=i,a}var wl={get(e,t){if(t===fe)return e;let r=ot(e);if(!ml(r,t))return QR(e,r,t);let n=r[t];return e.finalized_||!yr(n)?n:n===dl(e.base_,t)?(fl(e),e.copy_[t]=Wo(n,e)):n},has(e,t){return t in ot(e)},ownKeys(e){return Reflect.ownKeys(ot(e))},set(e,t,r){let n=tg(ot(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=dl(ot(e),t),s=o?.[fe];if(s&&s.base_===r)return e.copy_[t]=r,e.assigned_[t]=!1,!0;if(GR(r,o)&&(r!==void 0||ml(e.base_,t)))return!0;fl(e),gr(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 dl(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,fl(e),gr(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=ot(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:n.enumerable,value:r[t]}},defineProperty(){$t(11)},getPrototypeOf(e){return zn(e.base_)},setPrototypeOf(){$t(12)}},Ho={};Uo(wl,(e,t)=>{Ho[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Ho.deleteProperty=function(e,t){return Ho.set.call(this,e,t,void 0)};Ho.set=function(e,t,r){return wl.set.call(this,e[0],t,r,e[0])};function dl(e,t){let r=e[fe];return(r?ot(r):e)[t]}function QR(e,t,r){let n=tg(t,r);return n?"value"in n?n.value:n.get?.call(e.draft_):void 0}function tg(e,t){if(!(t in e))return;let r=zn(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=zn(r)}}function gr(e){e.modified_||(e.modified_=!0,e.parent_&&gr(e.parent_))}function fl(e){e.copy_||(e.copy_=hl(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ZR=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,r,n)=>{if(typeof t=="function"&&typeof r!="function"){let s=r;r=t;let i=this;return function(a=s,...c){return i.produce(a,l=>r.call(this,l,...c))}}typeof r!="function"&&$t(6),n!==void 0&&typeof n!="function"&&$t(7);let o;if(yr(t)){let s=Vh(this),i=Wo(t,void 0),a=!0;try{o=r(i),a=!1}finally{a?yl(s):bl(s)}return Yh(s,n),Xh(o,s)}else if(!t||typeof t!="object"){if(o=r(t),o===void 0&&(o=t),o===Qh&&(o=void 0),this.autoFreeze_&&xl(o,!0),n){let s=[],i=[];wn("Patches").generateReplacementPatches_(t,o,s,i),n(s,i)}return o}else $t(1,t)},this.produceWithPatches=(t,r)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,a=>t(a,...i));let n,o;return[this.produce(t,r,(s,i)=>{n=s,o=i}),n,o]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){yr(e)||$t(8),Gn(e)&&(e=eS(e));let t=Vh(this),r=Wo(e,void 0);return r[fe].isManual_=!0,bl(t),r}finishDraft(e,t){let r=e&&e[fe];(!r||!r.isManual_)&&$t(9);let{scope_:n}=r;return Yh(n,t),Xh(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=wn("Patches").applyPatches_;return Gn(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Wo(e,t){let r=Ri(e)?wn("MapSet").proxyMap_(e,t):Si(e)?wn("MapSet").proxySet_(e,t):JR(e,t);return(t?t.scope_:ki()).drafts_.push(r),r}function eS(e){return Gn(e)||$t(10,e),rg(e)}function rg(e){if(!yr(e)||_i(e))return e;let t=e[fe],r;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=hl(e,t.scope_.immer_.useStrictShallowCopy_)}else r=hl(e,!0);return Uo(r,(n,o)=>{eg(r,n,rg(o))}),t&&(t.finalized_=!1),r}function ng(){class e extends Map{constructor(c,l){super(),this[fe]={type_:2,parent_:l,scope_:l?l.scope_:ki(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:c,draft_:this,isManual_:!1,revoked_:!1}}get size(){return ot(this[fe]).size}has(c){return ot(this[fe]).has(c)}set(c,l){let p=this[fe];return i(p),(!ot(p).has(c)||ot(p).get(c)!==l)&&(r(p),gr(p),p.assigned_.set(c,!0),p.copy_.set(c,l),p.assigned_.set(c,!0)),this}delete(c){if(!this.has(c))return!1;let l=this[fe];return i(l),r(l),gr(l),l.base_.has(c)?l.assigned_.set(c,!1):l.assigned_.delete(c),l.copy_.delete(c),!0}clear(){let c=this[fe];i(c),ot(c).size&&(r(c),gr(c),c.assigned_=new Map,Uo(c.base_,l=>{c.assigned_.set(l,!1)}),c.copy_.clear())}forEach(c,l){let p=this[fe];ot(p).forEach((u,f,d)=>{c.call(l,this.get(f),f,this)})}get(c){let l=this[fe];i(l);let p=ot(l).get(c);if(l.finalized_||!yr(p)||p!==l.base_.get(c))return p;let u=Wo(p,l);return r(l),l.copy_.set(c,u),u}keys(){return ot(this[fe]).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 p=this.get(l.value);return{done:!1,value:[l.value,p]}}}}[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 n extends Set{constructor(c,l){super(),this[fe]={type_:3,parent_:l,scope_:l?l.scope_:ki(),modified_:!1,finalized_:!1,copy_:void 0,base_:c,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return ot(this[fe]).size}has(c){let l=this[fe];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[fe];return i(l),this.has(c)||(s(l),gr(l),l.copy_.add(c)),this}delete(c){if(!this.has(c))return!1;let l=this[fe];return i(l),s(l),gr(l),l.copy_.delete(c)||(l.drafts_.has(c)?l.copy_.delete(l.drafts_.get(c)):!1)}clear(){let c=this[fe];i(c),ot(c).size&&(s(c),gr(c),c.copy_.clear())}values(){let c=this[fe];return i(c),s(c),c.copy_.values()}entries(){let c=this[fe];return i(c),s(c),c.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(c,l){let p=this.values(),u=p.next();for(;!u.done;)c.call(l,u.value,u.value,this),u=p.next()}}function o(a,c){return new n(a,c)}function s(a){a.copy_||(a.copy_=new Set,a.base_.forEach(c=>{if(yr(c)){let l=Wo(c,a);a.drafts_.set(c,l),a.copy_.add(l)}else a.copy_.add(c)}))}function i(a){a.revoked_&&$t(3,JSON.stringify(ot(a)))}YR("MapSet",{proxyMap_:t,proxySet_:o})}var St=new ZR,Li=St.produce,AY=St.produceWithPatches.bind(St),$Y=St.setAutoFreeze.bind(St),FY=St.setUseStrictShallowCopy.bind(St),jY=St.applyPatches.bind(St),UY=St.createDraft.bind(St),BY=St.finishDraft.bind(St);ng();var og=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},sg=(e,t)=>Li(e,r=>{if(!r)return t;if(r.updated<t.updated){let{lines:n,linked:o,projectLinked:s,...i}=t;Object.assign(r,i),vl(t)||(r.lines=n),o&&(r.linked??=o),s&&(r.projectLinked??=s);return}vl(r)&&!vl(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)}),vl=e=>e.lines[0].id==="dummy";var ig=(e,t)=>{let r=new Map,n=re(t.title);for(let c of t.links){let l=kl(e,c);l.linked=[n],r.set(ge(e,c),l)}let o=ge(e,n),s=t.projectLinks.map(c=>{let l=vi(c);return ge(l.project,l.titleLc)}),i={...Ci(e,t),linked:[],projectLinked:[]};r.set(o,i);let a=t.links.map(c=>re(c));for(let c of t.relatedPages.links1hop){c.linksLc.includes(n)&&i.linked.push(c.titleLc);for(let f of c.linksLc.filter(d=>a.includes(d))){let d=ge(e,f),h=r.get(d)??kl(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=ge(e,c.titleLc),p=Ci(e,c),u=r.get(l)?.linked;u&&(p.linked=u),r.set(l,p)}for(let c of t.relatedPages.projectLinks1hop){let l=ge(c.projectName,c.titleLc);s.includes(l)||i.projectLinked.push(l);let p=Ci(c.projectName,c),u=r.get(l)?.projectLinked;u&&(p.projectLinked=u),r.set(l,p)}i.isLinkedCorrect=!0;for(let c of t.relatedPages.links2hop){for(let f of c.linksLc){let d=ge(e,f),h=r.get(d)??kl(e,f);if(!h.linked){h.linked=[c.titleLc];continue}h.linked.push(c.titleLc)}let l=ge(e,c.titleLc),p=Ci(e,c),u=r.get(l)?.linked;u&&(p.linked=u),r.set(l,p)}return r},Ci=(e,t)=>({project:e,titleLc:"titleLc"in t?t.titleLc:re(t.title),exists:"persistent"in t?t.persistent:!0,descriptions:t.descriptions,image:t.image,lines:"lines"in t?t.lines:[t.title,...t.descriptions].map(r=>({text:r,id:"dummy",userId:"dummy",updated:t.updated,created:t.updated})),updated:t.updated,isLinkedCorrect:!1}),kl=(e,t)=>({project:e,titleLc:re(t),exists:!1,descriptions:[],image:null,lines:[{text:t,id:"dummy",userId:"dummy",updated:0,created:0}],updated:0,isLinkedCorrect:!1});var Oi=$r("ScrapBubble:bubble.ts"),El=new Map,Ni=new Set,Tl=xi();function*cg(e){for(let t of e)yield El.get(t)}var lg=(e,t)=>Tl.on(e,t),ug=(e,t)=>Tl.off(e,t),pg=async(e,t,r,n)=>{let o=[];for(let s of[...t].reverse()){let i=ge(s,e);Ni.has(i)||o.push(tS(s,e,r,n))}await Promise.all(o)},ag=0,tS=async(e,t,r,n)=>{let o=ge(e,t);if(Ni.has(o))return;Ni.add(o);let s=ag++,i=${s} Check update ${o};Oi.time(i);try{let a=Nt.toRequest(e,t,{followRename:!0,projects:[...r]});for await(let[c,l]of bi(a,{ignoreSearch:!0,saveFailedResponse:!0})){Oi.debug(${s}${c} ${o});let p=await Nt.fromResponse(l);if(Pr(p)){let u=ig(e,B(p));for(let[f,d]of u){let h=El.get(f),g=sg(h,d);g&&h!==g&&(El.set(f,g),Tl.dispatch(f,d))}}if(n?.ignoreFetch===!0||c==="cache"&&!Dh(l,n?.maxAge??60))break}}catch(a){Oi.error(a)}finally{Ni.delete(o),Oi.timeEnd(i),ag--}};var dg=$r("ScrapBubble:useBubbleData.ts"),Kn=e=>{let[t,r]=X(Pl(e));return te(()=>{r(Pl(e));let n,o=()=>{clearTimeout(n),n=setTimeout(()=>{dg.debug(Update ${e.length} pages),r(Pl(e))},10)};return e.forEach(s=>lg(s,o)),()=>e.forEach(s=>ug(s,o))},e),t},Pl=e=>{let t=[...cg(e)].flatMap(r=>r?[r]:[]);return dg.debug(Required: ${e.length} pages, ${t.length} found,t),t};var fg=({source:e,linked:t,externalLinked:r,projectsForSort:n,...o})=>{let s=N(()=>[...t.keys(),...r.keys()],[t,r]),i=Kn(s),a=N(()=>[...n],[n]),c=N(()=>{let p=(u,f)=>{let d=a.indexOf(u.project),h=a.indexOf(f.project);return d===h?f.updated-u.updated:d<0?1:h<0?-1:d-h};return[...i].sort(p)},[i,a]),l=N(()=>({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 m("ul",{className:"card-bubble",style:l,onClick:o.onClick,children:c.map(({project:p,titleLc:u,lines:[{text:f}],descriptions:d,image:h})=>{let g=ge(p,u),y=t.get(g)??r.get(g);return m("li",{children:m(zh,{project:p,title:f,linkTo:y,descriptions:d,thumbnail:h??"",...o})},g)})})};var Yn=e=>{e:if(e.pathType==="root"){let[,r="",n=""]=e.href.match(/\/([\w\-]+)(?:\/?|\/(.*))$/)??["","",""];if(r==="")break e;let[,o]=n?.match?.(/#([a-f\d]{24,32})$/)??["",""];return n===""?{project:r}:o===""?{project:r,title:n}:{project:r,title:n.slice(0,-1-o.length),hash:o}}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 Rl=(e,t)=>t.some(r=>{let n=!e.project;switch(r.type){case"hashTag":return n&&re(r.href)===e.titleLc;case"link":{if(r.pathType=="absolute"||r.pathType==="relative"!==n)return!1;let{project:o,title:s=""}=Yn({pathType:r.pathType,href:r.href});return n?!o&&re(s)===e.titleLc:o===e.project&&re(s)===e.titleLc}case"quote":case"strong":case"decoration":return Rl(e,r.nodes)}});var Fr=ko({title:"",project:"",whiteList:new Set,bubble:()=>{},hide:()=>{},delay:0,prefetch:()=>{}}),hg=({lines:e,project:t,title:r,whiteList:n,noIndent:o,hash:s,linkTo:i,...a})=>{let c=N(()=>e.flatMap(d=>typeof d=="string"?[]:[d.id]),[e]),l=N(()=>{let d=0;return Be(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[d++]};case"codeBlock":{let g=d;return d+=h.content.split(
).length+1,{...h,ids:c.slice(g,d)}}case"table":{let g=d;return d+=h.cells.length+1,{...h,ids:c.slice(g,d)}}}})},[e,c]),p=N(()=>{if(s&&c.includes(s))return s;if(i)return l.find(d=>d.type!=="line"?!1:Rl(i,d.nodes))?.id},[l,c,s,i?.project,i?.titleLc]),u=Ye(null);te(()=>{if(!p)return;let d=u.current?.querySelector(data-id="${p}"),h=globalThis.scrollY;d?.scrollIntoView?.({block:"center"}),globalThis.scroll(0,h)},[p]);let f=xn(t);return m("div",{className:"lines","data-theme":f,ref:u,children:m(Fr.Provider,{value:{project:t,title:r,whiteList:n,...a},children:l.map(d=>{switch(d.type){case"title":return m(Y,{children:[m(Xn,{index:d.id,indent:0,noIndent:o,permalink:d.id===p,children:m("a",{className:"page-link",type:"link",href:/${t}/${ue(d.text)},rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",children:d.text})},d.id),m("hr",{})]});case"codeBlock":return m(rS,{block:d,noIndent:o,ids:d.ids,scrollId:p},d.ids[0]);case"table":return m(nS,{block:d,noIndent:o,ids:d.ids,scrollId:p},d.ids[0]);case"line":return m(Xn,{index:d.id,indent:d.indent,noIndent:o,permalink:d.id===p,children:d.nodes.length>0?d.nodes.map(h=>m(Vn,{node:h})):m("br",{})},d.id)}})})})},Xn=({index:e,indent:t,noIndent:r,children:n,permalink:o})=>m("div",{className:line${o?" permalink":""},"data-id":e,"data-indent":t,style:{"margin-left":r?"":${1*t}em},children:n}),rS=({block:{fileName:e,content:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:i}=pr(Fr),[a,c]=X(""),l=A(async p=>{p.preventDefault(),p.stopPropagation();try{await navigator.clipboard.writeText(t),c("Copied"),await Ee(1e3),c("")}catch(u){alert(Failed to copy the code block Error: ${u})}},[t]);return m(Y,{children:[m(Xn,{index:n[0],indent:r,permalink:n[0]===o,children:m("span",{className:"code-block",children:[m("span",{className:"code-block-start",children:m("a",{href:/api/code/${s}/${ue(i)}/${e},target:"_blank",children:e})}),m("span",{className:"copy",title:"Copy",onClick:l,children:a})]})}),m(Y,{children:t.split(
).map((p,u)=>m(Xn,{index:n[u+1],indent:r,permalink:n[u+1]===o,children:m("code",{className:"code-block",children:p})}))})]})},nS=({block:{fileName:e,cells:t,indent:r},ids:n,scrollId:o})=>{let{project:s,title:i}=pr(Fr);return m(Y,{children:[m(Xn,{index:n[0],indent:r,permalink:n[0]===o,children:m("span",{className:"table-block",children:m("span",{className:"table-block-start",children:m("a",{href:/api/table/${s}/${ue(i)}/${e}.csv,target:"_blank",children:e})})})}),m(Y,{children:t.map((a,c)=>m(Xn,{index:n[c+1],indent:r,permalink:n[c+1]===o,children:m("span",{className:"table-block table-block-row",children:a.map((l,p)=>m("span",{className:cell col-${p},children:l.map(u=>m(Vn,{node:u}))}))})}))})]})},Vn=({node:e})=>{switch(e.type){case"code":return m("code",{className:"code",children:e.text});case"formula":return m(oS,{node:e});case"commandLine":return m(iS,{node:e});case"helpfeel":return m("code",{className:"helpfeel",children:[m("span",{className:"prefix",children:"?"})," ",m("span",{className:"entry",children:e.text})]});case"quote":return m("blockquote",{className:"quote",children:e.nodes.map(t=>m(Vn,{node:t}))});case"strong":return m("strong",{children:e.nodes.map(t=>m(Vn,{node:t}))});case"decoration":return m(sS,{node:e});case"plain":case"blank":return m(Y,{children:e.text});case"hashTag":return m(lS,{node:e});case"link":return m(uS,{node:e});case"googleMap":return m(aS,{node:e});case"icon":return m(mg,{node:e});case"strongIcon":return m(mg,{node:e,strong:!0});case"image":return m(cS,{node:e});case"strongImage":return m("img",{className:"image strong-image",src:e.src});case"numberList":return m(Y,{children:[${e.number}. ,e.nodes.map(t=>m(Vn,{node:t}))]})}},oS=({node:{formula:e}})=>{let{ref:t,error:r}=yi(e);return m("span",{className:formula ${r?" error":""},children:r?m("code",{children:e}):m("span",{className:"katex-display",ref:t})})},sS=({node:{decos:e,nodes:t}})=>m("span",{className:e.map(r=>deco-${r}).join(" "),children:t.map(r=>m(Vn,{node:r}))}),iS=({node:e})=>{let[t,r]=X(""),n=A(async o=>{o.preventDefault(),o.stopPropagation();try{await navigator.clipboard.writeText(e.text),r("Copied"),await Ee(1e3),r("")}catch(s){alert(Failed to copy the code block
Error: ${s})}},[e.text]);return m(Y,{children:[m("code",{className:"cli",children:[m("span",{className:"prefix",children:e.symbol})," ",m("span",{className:"command",children:e.text})]}),m("span",{className:"tool-buttons",children:m("span",{title:"Copy",className:"copy",onClick:n,children:t})})]})},aS=({node:{place:e,latitude:t,longitude:r,zoom:n}})=>m("span",{className:"pointing-device-map",children:m("a",{href:https://www.google.com/maps/search/${e}/@${t},${r},${n}z,rel:"noopner noreferrer",target:"_blank",children:m("img",{className:"google-map",src:/api/google-map/static-map?center=${t}%2C${r}&markers=${e}&zoom=${n}&_csrf=${globalThis._csrf}})})}),mg=({node:{pathType:e,path:t},strong:r})=>{let{project:n}=pr(Fr),[o,s]=e==="relative"?[n,t]:t.match(/\/([\w\-]+)\/(.+)$/)?.slice?.(1)??[n,t],i=ue(s);return m("a",{href:/${o}/${i},rel:o===scrapbox.Project.name?"route":"noopener noreferrer",target:o===scrapbox.Project.name?"":"_blank",children:m("img",{className:r?"icon strong-icon":"icon",alt:s,src:/api/pages/${o}/${i}/icon,children:s})})},cS=({node:{link:e,src:t}})=>{let r=e||(/https:\/\/gyazo\.com\/[^\/]+\/thumb\/1000/.test(t)?t.slice(0,-11):t);return m("a",{className:e?"link":"",href:r,rel:"noopner noreferrer",target:"_blank",children:m("img",{className:"image",src:t})})},lS=({node:{href:e}})=>{let{project:t}=pr(Fr),r=gg(t,e),n=yg(t,e,"hashtag");return m("a",{href:/${t}/${ue(e)},className:page-link${r?" empty-page-link":""},type:"hashTag",rel:t===scrapbox.Project.name?"route":"noopener noreferrer",target:t===scrapbox.Project.name?"":"_blank",onPointerEnter:n,children:["#",e]})},uS=({node:{pathType:e,...t}})=>{switch(e){case"relative":case"root":return m(pS,{pathType:e,href:t.href});case"absolute":{let r=_h({pathType:e,...t});switch(r.type){case"youtube":return m(dS,{...r});case"vimeo":return m(fS,{...r});case"spotify":return m(mS,{...r});case"anchor-fm":return m(hS,{...r});case"audio":return m(gS,{...r});case"video":return m(bS,{...r});case"absoluteLink":return m("a",{className:"link",href:r.href,rel:"noopener noreferrer",target:"_blank",children:r.content||r.href})}}}},pS=({pathType:e,href:t})=>{let{project:r}=pr(Fr),{project:n=r,title:o,hash:s=""}=Yn({pathType:e,href:t}),i=yg(n,o,"link",s),a=gg(n,o??"");return m("a",{className:page-link${o!==void 0&&a?" empty-page-link":""},type:"link",href:/${n}${o===void 0?"":/${ue(o)}${s===""?"":#${s}}},rel:n===scrapbox.Project.name?"route":"noopener noreferrer",target:n===scrapbox.Project.name?"":"_blank",onPointerEnter:i,children:t})},dS=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 m("div",{className:"iframe-video-player",children:m("iframe",{src:t,allowFullScreen:!0})})},fS=({videoId:e})=>m("div",{className:"iframe-video-player",children:m("iframe",{src:https://player.vimeo.com/video/${e},allowFullScreen:!0})}),mS=e=>m("div",{className:"iframe-video-player",children:m("iframe",{className:spotify type-${e.pathType},src:https://open.spotify.com/embed/${e.pathType}/${e.videoId},allowFullScreen:!0})}),hS=e=>m("div",{className:"iframe-video-player",children:m("iframe",{className:"anchor-fm",src:e.href.replace("/episodes/","/embed/episodes/"),allowFullScreen:!0})}),gS=e=>e.content===""?m("audio",{className:"audio-player",preload:"none",controls:!0,src:e.href}):m(yS,{...e}),yS=({href:e,content:t})=>{let r=Ye(null),n=A(()=>{r.current?.paused?(r.current.currentTime=0,r.current.play()):r.current?.pause?.()},[]);return m("span",{className:"audio-link",children:[m("a",{href:e,rel:"noopener noreferrer",target:"_blank",children:t}),m("span",{className:"play",onClick:n,children:"♬"}),m("audio",{preload:"none",src:e,ref:r})]})},bS=({href:e})=>m("div",{className:"video-player",children:m("video",{class:"video",style:{display:"inline-block"},controls:!0,loop:!0,src:e})}),gg=(e,t)=>{let{whiteList:r}=pr(Fr),n=N(()=>(r.has(e)?[...r]:[e,...r]).map(s=>ge(s,t)),[r,e]),o=Kn(n);return N(()=>og(o),o)},yg=(e,t,r,n)=>{let{delay:o,bubble:s,prefetch:i}=pr(Fr);return A(async({currentTarget:a})=>{t&&(i(e,t),await Wn(a,o)&&s({project:e,title:t,hash:n,type:r,position:qn(a)}))},[e,t,n,r,o,i,s])};var bg=({pages:e,onClick:t,source:r,whiteList:n,...o})=>{let[s,i]=X(ge(e[0].project,e[0].titleLc)),a=N(()=>({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 m("div",{className:"text-bubble",style:a,onClick:t,children:[e.length>1&&m("div",{role:"tablist",children:e.map(c=>m(xS,{project:c.project,titleLc:c.titleLc,selected:s===ge(c.project,c.titleLc),tabSelector:i},ge(c.project,c.titleLc)))}),e.map(c=>m(wS,{selected:s===ge(c.project,c.titleLc),...c,title:c.lines[0].text,hash:r.hash,linkTo:r.linkTo,whiteList:n,...o},ge(c.project,c.titleLc)))]})},xS=({project:e,titleLc:t,tabSelector:r,selected:n})=>{let o=A(()=>r(ge(e,t)),[e,t]),s=xn(e);return m("button",{role:"tab","aria-selected":n,"data-theme":s,tabIndex:-1,onClick:o,children:e})},wS=({selected:e,...t})=>{let r=xn(t.project);return m("div",{role:"tabpanel","data-theme":r,hidden:!e,children:m(hg,{...t})})};var xg=$r("ScrapBubble:Bubble.tsx"),wg=({source:e,parentTitles:t,whiteList:r,...n})=>{let o=N(()=>r.has(e.project)?new Set([e.project,...r]):new Set([e.project]),[r,e.project]),[s,i,a]=kS(e,o,r,t);return m(Y,{children:[vS(a)&&m(bg,{pages:a,source:e,whiteList:r,onClick:n.hide,...n}),m(fg,{linked:s,externalLinked:i,onClick:n.hide,source:e,projectsForSort:o,...n})]})},vS=e=>e.length>0,kS=(e,t,r,n)=>{let[[o,s,i],a]=X([new Map,new Map,[]]),c=N(()=>{let u=[...t].map(f=>ge(f,e.title));return xg.debug("projects",u),u},[t,e.title]),l=Kn(c),p=N(()=>n.map(u=>re(u)),[n]);return Hs(()=>{let u=new Map,f=new Map,d=[];for(let h of l){let g={project:h.project,titleLc:h.titleLc};for(let w of h.projectLinked??[]){let{project:R,titleLc:E}=vi(w);p.includes(E)&&r.has(R)||f.has(w)||f.set(w,g)}if(!r.has(h.project))continue;let y={titleLc:h.titleLc};for(let w of h.linked??[]){if(p.includes(w))continue;let R=ge(h.project,w);u.has(R)||u.set(R,y)}p.includes(h.titleLc)||h.exists&&d.push(h)}a(Li(h=>{xg.debug(depth: ${p.length}, bubbled from ${ge(e.project,e.title)}, bubbles,,l,"before",h[0],"internal cards,",u,"external cards",f);for(let g of h[0].keys())u.has(g)||h[0].delete(g);for(let[g,y]of u)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]=d}))},[l,r,p]),[o,s,i]};var vg=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var kg=e=>{let t=N(()=>vg(e.style,import.meta.url),[e.style]);return m(Y,{children:t!==""&&(t instanceof URL?m("link",{rel:"stylesheet",href:t.href}):m("style",{children:t}))})};var Eg=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 Tg=()=>{let[e,t]=X([{bubble:n=>r(0,n),hide:()=>r(0)}]),r=A((n,o)=>{t(([s,...i])=>[s,...o?[...i.slice(0,n),o===i.at(n)?.source?i.at(n):{source:o,parentTitles:[scrapbox.Page.title??"",...i.slice(0,n).map(a=>a.source.title)],bubble:a=>r(n+1,a),hide:()=>r(n+1)}]:[...i.slice(0,n)]])},[]);return e};var Sl=(e,t,r,n,o)=>{te(()=>(e.addEventListener(t,r,n),()=>e.removeEventListener(t,r,n)),[e,t,n,...o??[]])};var Pg=e=>e instanceof HTMLSpanElement&&e.matches(".line-title .text"),Mi=e=>e instanceof HTMLAnchorElement&&e.classList.contains("page-link");var _l="scrap-bubble",Rg=({delay:e,whiteList:t,watchList:r,style:n})=>{let[{bubble:o,hide:s},...i]=Tg(),a=A((c,l)=>pg(l,t.has(c)?t:new Set([c]),r),[t,r]);return Sl(document,"pointerenter",async c=>{let l=c.target;if(!Mi(l)&&!Pg(l))return;let{project:p=scrapbox.Project.name,title:u,hash:f=""}=Mi(l)?Yn({pathType:"root",href:${new URL(l.href).pathname}${new URL(l.href).hash}}):{project:scrapbox.Project.name,title:scrapbox.Page.title};if(p==="")return;let d=decodeURIComponent(u??"");a(p,d),await Wn(l,e)&&o({project:p,title:d,hash:f,position:qn(l),type:ES(l)})},{capture:!0},[e,t,r]),Sl(document,"click",c=>{c.target.dataset.userscriptName!==_l&&s()},{capture:!0},[s]),te(()=>(scrapbox.addListener("page:changed",s),()=>scrapbox.removeListener("page:changed",s)),[s]),m(Y,{children:[m("link",{rel:"stylesheet",href:"https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.12.0/katex.min.css"}),m("style",{children:Eg}),m(kg,{style:n}),i.map(c=>m(wg,{...c,whiteList:t,delay:e,prefetch:a},ge(c.source.project,c.source.title)))]})},ES=e=>Mi(e)?e.type==="link"?"link":"hashtag":"title";var Sg=async e=>{let{delay:t=500,whiteList:r=[],watchList:n=(await Lh()).slice(0,100),style:o="",debug:s=!1}=e??{};Ah(s);let i=document.createElement("div");i.dataset.userscriptName=_l,document.body.append(i);let a=i.attachShadow({mode:"open"});ut(m(Rg,{delay:t,whiteList:new Set([scrapbox.Project.name,...r]),watchList:new Set(n),style:o}),a)};var TS=["takker-memex","takker-private","takker","takker-books","villagepump"],Jn=[];switch(scrapbox.Project.name){case"hub":case"villagepump":case"verbalizing-community":Jn.push("villagepump","hub","verbalizing-community");break;case"programming-notes":case"customize":case"scrapboxlab":Jn.push("programming-notes","customize","scrapboxlab");break;case"sta":Jn.push("sta-taskmanagement");break;case"sta-taskmanagement":case"taskmanagement":Jn.push("sta-taskmanagement","taskmanagement");break;case"plurality-japanese":Jn.push("nishio","tkgshn");break}Sg({delay:/mobile/i.test(navigator.userAgent)?300:500,whiteList:[...TS,...Jn],style:@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";
@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";});var _g=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 Lg=(e,t,r)=>{if(r.length===0)return[];let n=r.map(a=>a.text).join(
),o=Be(n,{hasTitle:!0}),s=new Map,i=0;for(let a of o)switch(a.type){case"title":case"line":{i++;break}case"table":i+=a.cells.length+1;break;case"codeBlock":{let{fileName:c,lang:l}=_g(a.fileName),p=s.get(c);s.set(c,{path:p?.path??https://scrapbox.io/api/code/${e}/${ue(t)}/${ue(c)},lang:p?.lang??l,startIds:[...p?.startIds??[],r[i].id]}),i+=a.content.split( ).length+1;break}}return s.values()};function Cl(e){let t=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(Kt(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let o of n)t(o)}else{let o=Object.keys(n);r.write8(6),r.write32(o.length);for(let s of o)r.write(Kt(s)),t(n[s])}},r=new Ii;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ll(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Cg(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return Qn(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[Qn(r.read())]=t();return a}default:throw new Error("Invalid packet")}},r=new Ii(e),n=r.read32(),o=(n&1)===0;n>>>=1;let s=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:n,isRequest:o,value:s}}var Ii=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);Ll(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ll(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 Ol(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),n=this._read(r.length);return r.set(this.buf.subarray(n,n+t)),r}},Kt,Qn,Og;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;Kt=r=>e.encode(r),Qn=r=>t.decode(r),Og='new TextEncoder().encode("")'}else throw new Error("No UTF-8 codec found");if(!(Kt("")instanceof Uint8Array))throw new Error(Invariant violation: "${Og} 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 Ol(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ll(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}var qo="0.24.0";var qe=JSON.stringify,Ng="warning",Mg="silent";function Ig(e){if(st(e,"target"),e.indexOf(",")>=0)throw new Error(Invalid target: ${e});return e}var $i=()=>null,Ne=e=>typeof e=="boolean"?null:"a boolean",H=e=>typeof e=="string"?null:"a string",Fi=e=>e instanceof RegExp?null:"a RegExp object",kn=e=>typeof e=="number"&&e===(e|0)?null:"an integer",$g=e=>typeof e=="function"?null:"a function",De=e=>Array.isArray(e)?null:"an array",Ft=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",RS=e=>typeof e=="object"&&e!==null?null:"an array or an object";var Dg=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Fg=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",SS=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",_S=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",jg=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function x(e,t,r,n){let o=e[r];if(t[r+""]=!0,o===void 0)return;let s=n(o);if(s!==null)throw new Error(${qe(r)} must be ${s});return o}function tt(e,t,r){for(let n in e)if(!(n in t))throw new Error(Invalid option ${r}: ${qe(n)})}function Ug(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let n=e[r];if(typeof n=="string"||n===!1)t[r]=n;else throw new Error(Expected ${qe(r)} in mangle cache to map to either a string or false)}}return t}function ji(e,t,r,n,o){let s=x(t,r,"color",Ne),i=x(t,r,"logLevel",H),a=x(t,r,"logLimit",kn);s!==void 0?e.push(--color=${s}):n&&e.push("--color=true"),e.push(--log-level=${i||o}),e.push(--log-limit=${a||0})}function st(e,t,r){if(typeof e!="string")throw new Error(Expected value for ${t}${r!==void 0?" "+qe(r):""} to be a string, got ${typeof e} instead);return e}function Bg(e,t,r){let n=x(t,r,"legalComments",H),o=x(t,r,"sourceRoot",H),s=x(t,r,"sourcesContent",Ne),i=x(t,r,"target",_S),a=x(t,r,"format",H),c=x(t,r,"globalName",H),l=x(t,r,"mangleProps",Fi),p=x(t,r,"reserveProps",Fi),u=x(t,r,"mangleQuoted",Ne),f=x(t,r,"minify",Ne),d=x(t,r,"minifySyntax",Ne),h=x(t,r,"minifyWhitespace",Ne),g=x(t,r,"minifyIdentifiers",Ne),y=x(t,r,"lineLimit",kn),w=x(t,r,"drop",De),R=x(t,r,"dropLabels",De),E=x(t,r,"charset",H),b=x(t,r,"treeShaking",Ne),k=x(t,r,"ignoreAnnotations",Ne),v=x(t,r,"jsx",H),L=x(t,r,"jsxFactory",H),C=x(t,r,"jsxFragment",H),O=x(t,r,"jsxImportSource",H),S=x(t,r,"jsxDev",Ne),T=x(t,r,"jsxSideEffects",Ne),P=x(t,r,"define",Ft),_=x(t,r,"logOverride",Ft),M=x(t,r,"supported",Ft),I=x(t,r,"pure",De),F=x(t,r,"keepNames",Ne),D=x(t,r,"platform",H),q=x(t,r,"tsconfigRaw",SS);if(n&&e.push(--legal-comments=${n}),o!==void 0&&e.push(--source-root=${o}),s!==void 0&&e.push(--sources-content=${s}),i&&(Array.isArray(i)?e.push(--target=${Array.from(i).map(Ig).join(",")}):e.push(--target=${Ig(i)})),a&&e.push(--format=${a}),c&&e.push(--global-name=${c}),D&&e.push(--platform=${D}),q&&e.push(--tsconfig-raw=${typeof q=="string"?q:JSON.stringify(q)}),f&&e.push("--minify"),d&&e.push("--minify-syntax"),h&&e.push("--minify-whitespace"),g&&e.push("--minify-identifiers"),y&&e.push(--line-limit=${y}),E&&e.push(--charset=${E}),b!==void 0&&e.push(--tree-shaking=${b}),k&&e.push("--ignore-annotations"),w)for(let j of w)e.push(--drop:${st(j,"drop")});if(R&&e.push(--drop-labels=${Array.from(R).map(j=>st(j,"dropLabels")).join(",")}),l&&e.push(--mangle-props=${l.source}),p&&e.push(--reserve-props=${p.source}),u!==void 0&&e.push(--mangle-quoted=${u}),v&&e.push(--jsx=${v}),L&&e.push(--jsx-factory=${L}),C&&e.push(--jsx-fragment=${C}),O&&e.push(--jsx-import-source=${O}),S&&e.push("--jsx-dev"),T&&e.push("--jsx-side-effects"),P)for(let j in P){if(j.indexOf("=")>=0)throw new Error(Invalid define: ${j});e.push(--define:${j}=${st(Pj,"define",j)})}if(_)for(let j in _){if(j.indexOf("=")>=0)throw new Error(Invalid log override: ${j});e.push(--log-override:${j}=${st(_j,"log override",j)})}if(M)for(let j in M){if(j.indexOf("=")>=0)throw new Error(Invalid supported: ${j});let z=M[j];if(typeof z!="boolean")throw new Error(Expected value for supported ${qe(j)} to be a boolean, got ${typeof z} instead);e.push(--supported:${j}=${z})}if(I)for(let j of I)e.push(--pure:${st(j,"pure")});F&&e.push("--keep-names")}function LS(e,t,r,n,o){let s=[],i=[],a=Object.create(null),c=null,l=null;ji(s,t,a,r,n),Bg(s,t,a);let p=x(t,a,"sourcemap",Fg),u=x(t,a,"bundle",Ne),f=x(t,a,"splitting",Ne),d=x(t,a,"preserveSymlinks",Ne),h=x(t,a,"metafile",Ne),g=x(t,a,"outfile",H),y=x(t,a,"outdir",H),w=x(t,a,"outbase",H),R=x(t,a,"tsconfig",H),E=x(t,a,"resolveExtensions",De),b=x(t,a,"nodePaths",De),k=x(t,a,"mainFields",De),v=x(t,a,"conditions",De),L=x(t,a,"external",De),C=x(t,a,"packages",H),O=x(t,a,"alias",Ft),S=x(t,a,"loader",Ft),T=x(t,a,"outExtension",Ft),P=x(t,a,"publicPath",H),_=x(t,a,"entryNames",H),M=x(t,a,"chunkNames",H),I=x(t,a,"assetNames",H),F=x(t,a,"inject",De),D=x(t,a,"banner",Ft),q=x(t,a,"footer",Ft),j=x(t,a,"entryPoints",RS),z=x(t,a,"absWorkingDir",H),G=x(t,a,"stdin",Ft),se=x(t,a,"write",Ne)??o,Q=x(t,a,"allowOverwrite",Ne),rt=x(t,a,"mangleCache",Ft);if(a.plugins=!0,tt(t,a,in ${e}() call),p&&s.push(--sourcemap${p===!0?"":=${p}}),u&&s.push("--bundle"),Q&&s.push("--allow-overwrite"),f&&s.push("--splitting"),d&&s.push("--preserve-symlinks"),h&&s.push("--metafile"),g&&s.push(--outfile=${g}),y&&s.push(--outdir=${y}),w&&s.push(--outbase=${w}),R&&s.push(--tsconfig=${R}),C&&s.push(--packages=${C}),E){let $=[];for(let ye of E){if(st(ye,"resolve extension"),ye.indexOf(",")>=0)throw new Error(Invalid resolve extension: ${ye});$.push(ye)}s.push(--resolve-extensions=${$.join(",")})}if(P&&s.push(--public-path=${P}),_&&s.push(--entry-names=${_}),M&&s.push(--chunk-names=${M}),I&&s.push(--asset-names=${I}),k){let $=[];for(let ye of k){if(st(ye,"main field"),ye.indexOf(",")>=0)throw new Error(Invalid main field: ${ye});$.push(ye)}s.push(--main-fields=${$.join(",")})}if(v){let $=[];for(let ye of v){if(st(ye,"condition"),ye.indexOf(",")>=0)throw new Error(Invalid condition: ${ye});$.push(ye)}s.push(--conditions=${$.join(",")})}if(L)for(let $ of L)s.push(--external:${st($,"external")});if(O)for(let $ in O){if($.indexOf("=")>=0)throw new Error(Invalid package name in alias: ${$});s.push(--alias:${$}=${st(O$,"alias",$)})}if(D)for(let $ in D){if($.indexOf("=")>=0)throw new Error(Invalid banner file type: ${$});s.push(--banner:${$}=${st(D$,"banner",$)})}if(q)for(let $ in q){if($.indexOf("=")>=0)throw new Error(Invalid footer file type: ${$});s.push(--footer:${$}=${st(q$,"footer",$)})}if(F)for(let $ of F)s.push(--inject:${st($,"inject")});if(S)for(let $ in S){if($.indexOf("=")>=0)throw new Error(Invalid loader extension: ${$});s.push(--loader:${$}=${st(S$,"loader",$)})}if(T)for(let $ in T){if($.indexOf("=")>=0)throw new Error(Invalid out extension: ${$});s.push(--out-extension:${$}=${st(T$,"out extension",$)})}if(j)if(Array.isArray(j))for(let $=0,ye=j.length;$<ye;$++){let at=j[$];if(typeof at=="object"&&at!==null){let ir=Object.create(null),ar=x(at,ir,"in",H),Vt=x(at,ir,"out",H);if(tt(at,ir,"in entry point at index "+$),ar===void 0)throw new Error('Missing property "in" for entry point at index '+$);if(Vt===void 0)throw new Error('Missing property "out" for entry point at index '+$);i.push([Vt,ar])}else i.push(["",st(at,"entry point at index "+$)])}else for(let $ in j)i.push([$,st(j[$],"entry point",$)]);if(G){let $=Object.create(null),ye=x(G,$,"contents",jg),at=x(G,$,"resolveDir",H),ir=x(G,$,"sourcefile",H),ar=x(G,$,"loader",H);tt(G,$,'in "stdin" object'),ir&&s.push(--sourcefile=${ir}),ar&&s.push(--loader=${ar}),at&&(l=at),typeof ye=="string"?c=Kt(ye):ye instanceof Uint8Array&&(c=ye)}let Pe=[];if(b)for(let $ of b)$+="",Pe.push($);return{entries:i,flags:s,write:se,stdinContents:c,stdinResolveDir:l,absWorkingDir:z,nodePaths:Pe,mangleCache:Ug(rt)}}function CS(e,t,r,n){let o=[],s=Object.create(null);ji(o,t,s,r,n),Bg(o,t,s);let i=x(t,s,"sourcemap",Fg),a=x(t,s,"sourcefile",H),c=x(t,s,"loader",H),l=x(t,s,"banner",H),p=x(t,s,"footer",H),u=x(t,s,"mangleCache",Ft);return tt(t,s,in ${e}() call),i&&o.push(--sourcemap=${i===!0?"external":i}),a&&o.push(--sourcefile=${a}),c&&o.push(--loader=${c}),l&&o.push(--banner=${l}),p&&o.push(--footer=${p}),{flags:o,mangleCache:Ug(u)}}function Hg(e){let t={},r={didClose:!1,reason:""},n={},o=0,s=0,i=new Uint8Array(16*1024),a=0,c=E=>{let b=a+E.length;if(b>i.length){let v=new Uint8Array(b*2);v.set(i),i=v}i.set(E,a),a+=E.length;let k=0;for(;k+4<=a;){let v=Ol(i,k);if(k+4+v>a)break;k+=4,h(i.subarray(k,k+v)),k+=v}k>0&&(i.copyWithin(0,k,a),a-=k)},l=E=>{r.didClose=!0,E&&(r.reason=": "+(E.message||E));let b="The service was stopped"+r.reason;for(let k in n)n[k](b,null);n={}},p=(E,b,k)=>{if(r.didClose)return k("The service is no longer running"+r.reason,null);let v=o++;n[v]=(L,C)=>{try{k(L,C)}finally{E&&E.unref()}},E&&E.ref(),e.writeToStdin(Cl({id:v,isRequest:!0,value:b}))},u=(E,b)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(Cl({id:E,isRequest:!1,value:b}))},f=async(E,b)=>{try{if(b.command==="ping"){u(E,{});return}if(typeof b.key=="number"){let k=t[b.key];if(!k)return;let v=k[b.command];if(v){await v(E,b);return}}throw new Error("Invalid command: "+b.command)}catch(k){let v=[vn(k,e,null,void 0,"")];try{u(E,{errors:v})}catch{}}},d=!0,h=E=>{if(d){d=!1;let k=String.fromCharCode(...E);if(k!==qo)throw new Error(Cannot start service: Host version "${qo}" does not match binary version ${qe(k)});return}let b=Cg(E);if(b.isRequest)f(b.id,b.value);else{let k=n[b.id];delete n[b.id],b.value.error?k(b.value.error,{}):k(null,b.value)}};return{readFromStdout:c,afterClose:l,service:{buildOrContext:({callName:E,refs:b,options:k,isTTY:v,defaultWD:L,callback:C})=>{let O=0,S=s++,T={},P={ref(){++O===1&&b&&b.ref()},unref(){--O===0&&(delete t[S],b&&b.unref())}};t[S]=T,P.ref(),OS(E,S,p,u,P,e,T,k,v,L,(_,M)=>{try{C(_,M)}finally{P.unref()}})},transform:({callName:E,refs:b,input:k,options:v,isTTY:L,fs:C,callback:O})=>{let S=Wg(),T=P=>{try{if(typeof k!="string"&&!(k instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:_,mangleCache:M}=CS(E,v,L,Mg),I={command:"transform",flags:_,inputFS:P!==null,input:P!==null?Kt(P):typeof k=="string"?Kt(k):k};M&&(I.mangleCache=M),p(b,I,(F,D)=>{if(F)return O(new Error(F),null);let q=Zn(D.errors,S),j=Zn(D.warnings,S),z=1,G=()=>{if(--z===0){let se={warnings:j,code:D.code,map:D.map,mangleCache:void 0,legalComments:void 0};"legalComments"in D&&(se.legalComments=D?.legalComments),D.mangleCache&&(se.mangleCache=D?.mangleCache),O(null,se)}};if(q.length>0)return O(zo("Transform failed",q,j),null);D.codeFS&&(z++,C.readFile(D.code,(se,Q)=>{se!==null?O(se,null):(D.code=Q,G())})),D.mapFS&&(z++,C.readFile(D.map,(se,Q)=>{se!==null?O(se,null):(D.map=Q,G())})),G()})}catch(_){let M=[];try{ji(M,v,{},L,Mg)}catch{}let I=vn(_,e,S,void 0,"");p(b,{command:"error",flags:M,error:I},()=>{I.detail=S.load(I.detail),O(zo("Transform failed",[I],[]),null)})}};if((typeof k=="string"||k instanceof Uint8Array)&&k.length>1024*1024){let P=T;T=()=>C.writeFile(k,P)}T(null)},formatMessages:({callName:E,refs:b,messages:k,options:v,callback:L})=>{if(!v)throw new Error(Missing second argument in ${E}() call);let C={},O=x(v,C,"kind",H),S=x(v,C,"color",Ne),T=x(v,C,"terminalWidth",kn);if(tt(v,C,in ${E}() call),O===void 0)throw new Error(Missing "kind" in ${E}() call);if(O!=="error"&&O!=="warning")throw new Error(Expected "kind" to be "error" or "warning" in ${E}() call);let P={command:"format-msgs",messages:br(k,"messages",null,"",T),isWarning:O==="warning"};S!==void 0&&(P.color=S),T!==void 0&&(P.terminalWidth=T),p(b,P,(_,M)=>{if(_)return L(new Error(_),null);L(null,M.messages)})},analyzeMetafile:({callName:E,refs:b,metafile:k,options:v,callback:L})=>{v===void 0&&(v={});let C={},O=x(v,C,"color",Ne),S=x(v,C,"verbose",Ne);tt(v,C,in ${E}() call);let T={command:"analyze-metafile",metafile:k};O!==void 0&&(T.color=O),S!==void 0&&(T.verbose=S),p(b,T,(P,_)=>{if(P)return L(new Error(P),null);L(null,_.result)})}}}}function OS(e,t,r,n,o,s,i,a,c,l,p){let u=Wg(),f=e==="context",d=(y,w)=>{let R=[];try{ji(R,a,{},c,Ng)}catch{}let E=vn(y,s,u,void 0,w);r(o,{command:"error",flags:R,error:E},()=>{E.detail=u.load(E.detail),p(zo(f?"Context failed":"Build failed",[E],[]),null)})},h;if(typeof a=="object"){let y=a.plugins;if(y!==void 0){if(!Array.isArray(y))return d(new Error('"plugins" must be an array'),"");h=y}}if(h&&h.length>0){if(s.isSync)return d(new Error("Cannot use plugins in synchronous API calls"),"");NS(t,r,n,o,s,i,a,h,u).then(y=>{if(!y.ok)return d(y.error,y.pluginName);try{g(y.requestPlugins,y.runOnEndCallbacks,y.scheduleOnDisposeCallbacks)}catch(w){d(w,"")}},y=>d(y,""));return}try{g(null,(y,w)=>w([],[]),()=>{})}catch(y){d(y,"")}function g(y,w,R){let E=s.hasFS,{entries:b,flags:k,write:v,stdinContents:L,stdinResolveDir:C,absWorkingDir:O,nodePaths:S,mangleCache:T}=LS(e,a,c,Ng,E);if(v&&!s.hasFS)throw new Error('The "write" option is unavailable in this environment');let P={command:"build",key:t,entries:b,flags:k,write:v,stdinContents:L,stdinResolveDir:C,absWorkingDir:O||l,nodePaths:S,context:f};y&&(P.plugins=y),T&&(P.mangleCache=T);let _=(F,D)=>{let q={errors:Zn(F.errors,u),warnings:Zn(F.warnings,u),outputFiles:void 0,metafile:void 0,mangleCache:void 0},j=q.errors.slice(),z=q.warnings.slice();F.outputFiles&&(q.outputFiles=F.outputFiles.map(IS)),F.metafile&&(q.metafile=JSON.parse(F.metafile)),F.mangleCache&&(q.mangleCache=F.mangleCache),F.writeToStdout!==void 0&&console.log(Qn(F.writeToStdout).replace(/\n$/,"")),w(q,(G,se)=>{if(j.length>0||G.length>0){let Q=zo("Build failed",j.concat(G),z.concat(se));return D(Q,null,G,se)}D(null,q,G,se)})},M,I;f&&(i["on-end"]=(F,D)=>new Promise(q=>{_(D,(j,z,G,se)=>{let Q={errors:G,warnings:se};I&&I(j,z),M=void 0,I=void 0,n(F,Q),q()})})),r(o,P,(F,D)=>{if(F)return p(new Error(F),null);if(!f)return _(D,(z,G)=>(R(),p(z,G)));if(D.errors.length>0)return p(zo("Context failed",D.errors,D.warnings),null);let q=!1,j={rebuild:()=>(M||(M=new Promise((z,G)=>{let se;I=(rt,Pe)=>{se||(se=()=>rt?G(rt):z(Pe))};let Q=()=>{r(o,{command:"rebuild",key:t},(Pe,$)=>{Pe?G(new Error(Pe)):se?se():Q()})};Q()})),M),watch:(z={})=>new Promise((G,se)=>{if(!s.hasFS)throw new Error('Cannot use the "watch" API in this environment');tt(z,{},"in watch() call"),r(o,{command:"watch",key:t},Pe=>{Pe?se(new Error(Pe)):G(void 0)})}),serve:(z={})=>new Promise((G,se)=>{if(!s.hasFS)throw new Error('Cannot use the "serve" API in this environment');let Q={},rt=x(z,Q,"port",kn),Pe=x(z,Q,"host",H),$=x(z,Q,"servedir",H),ye=x(z,Q,"keyfile",H),at=x(z,Q,"certfile",H),ir=x(z,Q,"fallback",H),ar=x(z,Q,"onRequest",$g);tt(z,Q,"in serve() call");let Vt={command:"serve",key:t,onRequest:!!ar};rt!==void 0&&(Vt.port=rt),Pe!==void 0&&(Vt.host=Pe),$!==void 0&&(Vt.servedir=$),ye!==void 0&&(Vt.keyfile=ye),at!==void 0&&(Vt.certfile=at),ir!==void 0&&(Vt.fallback=ir),r(o,Vt,(mp,rk)=>{if(mp)return se(new Error(mp));ar&&(i["serve-request"]=(nk,ok)=>{ar(ok.args),n(nk,{})}),G(rk)})}),cancel:()=>new Promise(z=>{if(q)return z();r(o,{command:"cancel",key:t},()=>{z()})}),dispose:()=>new Promise(z=>{if(q)return z();q=!0,r(o,{command:"dispose",key:t},()=>{z(),R(),o.unref()})})};o.ref(),p(null,j)})}}var NS=async(e,t,r,n,o,s,i,a,c)=>{let l=[],p=[],u={},f={},d=[],h=0,g=0,y=[],w=!1;a=[...a];for(let b of a){let k={};if(typeof b!="object")throw new Error(Plugin at index ${g} must be an object);let v=x(b,k,"name",H);if(typeof v!="string"||v==="")throw new Error(Plugin at index ${g} is missing a name);try{let L=x(b,k,"setup",$g);if(typeof L!="function")throw new Error("Plugin is missing a setup function");tt(b,k,on plugin ${qe(v)});let C={name:v,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};g++;let S=L({initialOptions:i,resolve:(T,P={})=>{if(!w)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof T!="string")throw new Error("The path to resolve must be a string");let _=Object.create(null),M=x(P,_,"pluginName",H),I=x(P,_,"importer",H),F=x(P,_,"namespace",H),D=x(P,_,"resolveDir",H),q=x(P,_,"kind",H),j=x(P,_,"pluginData",$i),z=x(P,_,"with",Ft);return tt(P,_,"in resolve() call"),new Promise((G,se)=>{let Q={command:"resolve",path:T,key:e,pluginName:v};if(M!=null&&(Q.pluginName=M),I!=null&&(Q.importer=I),F!=null&&(Q.namespace=F),D!=null&&(Q.resolveDir=D),q!=null)Q.kind=q;else throw new Error('Must specify "kind" when calling "resolve"');j!=null&&(Q.pluginData=c.store(j)),z!=null&&(Q.with=MS(z,"with")),t(n,Q,(rt,Pe)=>{rt!==null?se(new Error(rt)):G({errors:Zn(Pe.errors,c),warnings:Zn(Pe.warnings,c),path:Pe.path,external:Pe.external,sideEffects:Pe.sideEffects,namespace:Pe.namespace,suffix:Pe.suffix,pluginData:c.load(Pe.pluginData)})})})},onStart(T){let P='This error came from the "onStart" callback registered here:',_=Di(new Error(P),o,"onStart");l.push({name:v,callback:T,note:_}),C.onStart=!0},onEnd(T){let P='This error came from the "onEnd" callback registered here:',_=Di(new Error(P),o,"onEnd");p.push({name:v,callback:T,note:_}),C.onEnd=!0},onResolve(T,P){let _='This error came from the "onResolve" callback registered here:',M=Di(new Error(_),o,"onResolve"),I={},F=x(T,I,"filter",Fi),D=x(T,I,"namespace",H);if(tt(T,I,in onResolve() call for plugin ${qe(v)}),F==null)throw new Error("onResolve() call is missing a filter");let q=h++;u[q]={name:v,callback:P,note:M},C.onResolve.push({id:q,filter:F.source,namespace:D||""})},onLoad(T,P){let _='This error came from the "onLoad" callback registered here:',M=Di(new Error(_),o,"onLoad"),I={},F=x(T,I,"filter",Fi),D=x(T,I,"namespace",H);if(tt(T,I,in onLoad() call for plugin ${qe(v)}),F==null)throw new Error("onLoad() call is missing a filter");let q=h++;f[q]={name:v,callback:P,note:M},C.onLoad.push({id:q,filter:F.source,namespace:D||""})},onDispose(T){d.push(T)},esbuild:o.esbuild});S&&await S,y.push(C)}catch(L){return{ok:!1,error:L,pluginName:v}}}s["on-start"]=async(b,k)=>{c.clear();let v={errors:[],warnings:[]};await Promise.all(l.map(async({name:L,callback:C,note:O})=>{try{let S=await C();if(S!=null){if(typeof S!="object")throw new Error(Expected onStart() callback in plugin ${qe(L)} to return an object);let T={},P=x(S,T,"errors",De),_=x(S,T,"warnings",De);tt(S,T,from onStart() callback in plugin ${qe(L)}),P!=null&&v.errors.push(...br(P,"errors",c,L,void 0)),_!=null&&v.warnings.push(...br(_,"warnings",c,L,void 0))}}catch(S){v.errors.push(vn(S,o,c,O&&O(),L))}})),r(b,v)},s["on-resolve"]=async(b,k)=>{let v={},L="",C,O;for(let S of k.ids)try{({name:L,callback:C,note:O}=u[S]);let T=await C({path:k.path,importer:k.importer,namespace:k.namespace,resolveDir:k.resolveDir,kind:k.kind,pluginData:c.load(k.pluginData),with:k.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onResolve() callback in plugin ${qe(L)} to return an object);let P={},_=x(T,P,"pluginName",H),M=x(T,P,"path",H),I=x(T,P,"namespace",H),F=x(T,P,"suffix",H),D=x(T,P,"external",Ne),q=x(T,P,"sideEffects",Ne),j=x(T,P,"pluginData",$i),z=x(T,P,"errors",De),G=x(T,P,"warnings",De),se=x(T,P,"watchFiles",De),Q=x(T,P,"watchDirs",De);tt(T,P,from onResolve() callback in plugin ${qe(L)}),v.id=S,_!=null&&(v.pluginName=_),M!=null&&(v.path=M),I!=null&&(v.namespace=I),F!=null&&(v.suffix=F),D!=null&&(v.external=D),q!=null&&(v.sideEffects=q),j!=null&&(v.pluginData=c.store(j)),z!=null&&(v.errors=br(z,"errors",c,L,void 0)),G!=null&&(v.warnings=br(G,"warnings",c,L,void 0)),se!=null&&(v.watchFiles=Ai(se,"watchFiles")),Q!=null&&(v.watchDirs=Ai(Q,"watchDirs"));break}}catch(T){v={id:S,errors:[vn(T,o,c,O&&O(),L)]};break}r(b,v)},s["on-load"]=async(b,k)=>{let v={},L="",C,O;for(let S of k.ids)try{({name:L,callback:C,note:O}=f[S]);let T=await C({path:k.path,namespace:k.namespace,suffix:k.suffix,pluginData:c.load(k.pluginData),with:k.with});if(T!=null){if(typeof T!="object")throw new Error(Expected onLoad() callback in plugin ${qe(L)} to return an object);let P={},_=x(T,P,"pluginName",H),M=x(T,P,"contents",jg),I=x(T,P,"resolveDir",H),F=x(T,P,"pluginData",$i),D=x(T,P,"loader",H),q=x(T,P,"errors",De),j=x(T,P,"warnings",De),z=x(T,P,"watchFiles",De),G=x(T,P,"watchDirs",De);tt(T,P,from onLoad() callback in plugin ${qe(L)}),v.id=S,_!=null&&(v.pluginName=_),M instanceof Uint8Array?v.contents=M:M!=null&&(v.contents=Kt(M)),I!=null&&(v.resolveDir=I),F!=null&&(v.pluginData=c.store(F)),D!=null&&(v.loader=D),q!=null&&(v.errors=br(q,"errors",c,L,void 0)),j!=null&&(v.warnings=br(j,"warnings",c,L,void 0)),z!=null&&(v.watchFiles=Ai(z,"watchFiles")),G!=null&&(v.watchDirs=Ai(G,"watchDirs"));break}}catch(T){v={id:S,errors:[vn(T,o,c,O&&O(),L)]};break}r(b,v)};let R=(b,k)=>k([],[]);p.length>0&&(R=(b,k)=>{(async()=>{let v=[],L=[];for(let{name:C,callback:O,note:S}of p){let T,P;try{let _=await O(b);if(_!=null){if(typeof _!="object")throw new Error(Expected onEnd() callback in plugin ${qe(C)} to return an object);let M={},I=x(_,M,"errors",De),F=x(_,M,"warnings",De);tt(_,M,from onEnd() callback in plugin ${qe(C)}),I!=null&&(T=br(I,"errors",c,C,void 0)),F!=null&&(P=br(F,"warnings",c,C,void 0))}}catch(_){T=[vn(_,o,c,S&&S(),C)]}if(T){v.push(...T);try{b.errors.push(...T)}catch{}}if(P){L.push(...P);try{b.warnings.push(...P)}catch{}}}k(v,L)})()});let E=()=>{for(let b of d)setTimeout(()=>b(),0)};return w=!0,{ok:!0,requestPlugins:y,runOnEndCallbacks:R,scheduleOnDisposeCallbacks:E}};function Wg(){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 n=t++;return e.set(n,r),n}}}function Di(e,t,r){let n,o=!1;return()=>{if(o)return n;o=!0;try{let s=(e.stack+"").split( );s.splice(1,1);let i=qg(t,s,r);if(i)return n={text:e.message,location:i},n}catch{}}}function vn(e,t,r,n,o){let s="Internal error",i=null;try{s=(e&&e.message||e)+""}catch{}try{i=qg(t,(e.stack+"").split(
),"")}catch{}return{id:"",pluginName:o,text:s,location:i,notes:n?[n]:[],detail:r?r.store(e):-1}}function qg(e,t,r){let n=" at ";if(e.readFileSync&&!t[0].startsWith(n)&&t[1].startsWith(n))for(let o=1;o<t.length;o++){let s=t[o];if(s.startsWith(n))for(s=s.slice(n.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,p=c.slice(l,l+r.length)===r?r.length:0;return{file:i[1],namespace:"file",line:+i[2],column:Kt(c.slice(0,l)).length,length:Kt(c.slice(l,l+p)).length,lineText:c+
+t.slice(1).join(
),suggestion:""}}break}}return null}function zo(e,t,r){let n=5;e+=t.length<1?"": with ${t.length} error${t.length<2?"":"s"}:+t.slice(0,n+1).map((s,i)=>{if(i===n)return
...;if(!s.location)return
${a}:${c}:${l}: ERROR: ${p}${s.text}}).join("");let o=new Error(e);for(let[s,i]of[["errors",t],["warnings",r]])Object.defineProperty(o,s,{configurable:!0,enumerable:!0,get:()=>i,set:a=>Object.defineProperty(o,s,{configurable:!0,enumerable:!0,value:a})});return o}function Zn(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Ag(e,t,r){if(e==null)return null;let n={},o=x(e,n,"file",H),s=x(e,n,"namespace",H),i=x(e,n,"line",kn),a=x(e,n,"column",kn),c=x(e,n,"length",kn),l=x(e,n,"lineText",H),p=x(e,n,"suggestion",H);if(tt(e,n,t),l){let u=l.slice(0,(a&&a>0?a:0)+(c&&c>0?c:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(u)&&!/\n/.test(l)&&(l=u)}return{file:o||"",namespace:s||"",line:i||0,column:a||0,length:c||0,lineText:l||"",suggestion:p||""}}function br(e,t,r,n,o){let s=[],i=0;for(let a of e){let c={},l=x(a,c,"id",H),p=x(a,c,"pluginName",H),u=x(a,c,"text",H),f=x(a,c,"location",Dg),d=x(a,c,"notes",De),h=x(a,c,"detail",$i),g=in element ${i} of "${t}";tt(a,c,g);let y=[];if(d)for(let w of d){let R={},E=x(w,R,"text",H),b=x(w,R,"location",Dg);tt(w,R,g),y.push({text:E||"",location:Ag(b,g,o)})}s.push({id:l||"",pluginName:p||n,text:u||"",location:Ag(f,g,o),notes:y,detail:r?r.store(h):-1}),i++}return s}function Ai(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(${qe(t)} must be an array of strings);r.push(n)}return r}function MS(e,t){let r=Object.create(null);for(let n in e){let o=e[n];if(typeof o!="string")throw new Error(key ${qe(n)} in object ${qe(t)} must be a string);r[n]=o}return r}function IS({path:e,contents:t,hash:r}){let n=null;return{path:e,contents:t,hash:r,get text(){let o=this.contents;return(n===null||o!==t)&&(t=o,n=Qn(o)),n}}}var Gg=qo,Bi=e=>Hi().build(e),Kg=(e,t)=>Hi().transform(e,t),Yg=(e,t)=>Hi().formatMessages(e,t),Vg=(e,t)=>Hi().analyzeMetafile(e,t);var En,zg,Ui,Hi=()=>{if(Ui)return Ui;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')},Wi=e=>{let t=e.wasm,r=e.worker;if(En)throw new Error('Cannot call "initialize" more than once');return En=DS(t,r),En.catch(()=>{En=void 0}),En},DS=async(e,t)=>{let r=new Worker(t.toString(),{type:"module"}),n,o,s=new Promise((c,l)=>{n=c,o=l});r.onmessage=({data:c})=>{r.onmessage=({data:l})=>i(l),c?o(c):n()},r.postMessage(e);let{readFromStdout:i,service:a}=Hg({writeToStdin(c){r.postMessage(c)},isSync:!1,hasFS:!1,esbuild:{build:Bi,transform:Kg,formatMessages:Yg,analyzeMetafile:Vg,version:Gg,initialize:Wi}});await s,zg=()=>{r.terminate(),En=void 0,zg=void 0,Ui=void 0},Ui={build:c=>new Promise((l,p)=>a.buildOrContext({callName:"build",refs:null,options:c,isTTY:!1,defaultWD:"/",callback:(u,f)=>u?p(u):l(f)})),transform:(c,l)=>new Promise((p,u)=>a.transform({callName:"transform",refs:null,input:c,options:l||{},isTTY:!1,fs:{readFile(f,d){d(new Error("Internal error"),null)},writeFile(f,d){d(null)}},callback:(f,d)=>f?u(f):p(d)})),formatMessages:(c,l)=>new Promise((p,u)=>a.formatMessages({callName:"formatMessages",refs:null,messages:c,options:l,callback:(f,d)=>f?u(f):p(d)})),analyzeMetafile:(c,l)=>new Promise((p,u)=>a.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof c=="string"?c:JSON.stringify(c),options:l,callback:(f,d)=>f?u(f):p(d)}))}};self.Deno||(self.Deno={build:{os:"linux"},errors:{AlreadyExists:Error},env:{get:()=>{}},permissions:{query:()=>Promise.resolve("denied")},cwd:()=>location.href});function ft(e){if(typeof e!="string")throw new TypeError(Path must be a string. Received ${JSON.stringify(e)})}function nr(e){return e===47||e===92}function xr(e){return e>=97&&e<=122||e>=65&&e<=90}function Gi(e){if(e=e instanceof URL?e:new URL(e),e.protocol!=="file:")throw new TypeError("Must be a file URL.");return e}function Xg(e){e=Gi(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}function Ml(e){ft(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return nr(r)?!0:!!(xr(r)&&t>2&&e.charCodeAt(1)===58&&nr(e.charCodeAt(2)))}var Ki=class extends Error{constructor(t){super(t),this.name="AssertionError"}};function Yi(e,t=""){if(!e)throw new Ki(t)}var YS={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function Vi(e){return e.replaceAll(/[\s]/g,t=>YS[t]??t)}function Zg(e){if(!Ml(e))throw new TypeError("Must be an absolute path.");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=Vi(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError("Invalid hostname.");return n}function wr(e){return e===47}function ty(e){return e=Gi(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function Dl(e){return ft(e),e.length>0&&wr(e.charCodeAt(0))}function ny(e){if(!Dl(e))throw new TypeError("Must be an absolute path.");let t=new URL("file:///");return t.pathname=Vi(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}var i_=(()=>{let{Deno:e}=globalThis;if(typeof e?.build?.os=="string")return e.build.os;let{navigator:t}=globalThis;return t?.appVersion?.includes?.("Win")?"windows":"linux"})(),Ue=i_==="windows";var eo=Ue?"\\":"/";function Xi(e){return Ue?Xg(e):ty(e)}function Ko(e){return Ue?Zg(e):ny(e)}function Ji(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function Qi(e){let t={},r=Object.keys(e).sort((n,o)=>o.length-n.length);for(let n of r)t[n]=e[n];return t}function oy(e){return Ji(e)&&(e.imports!==void 0?Al(e.imports):!0)&&(e.scopes!==void 0?$l(e.scopes):!0)}function Al(e){return Ji(e)}function $l(e){return Ji(e)&&Object.values(e).every(t=>Fl(t))}function Fl(e){return Ji(e)}function Zi(e){try{return new URL(e),!0}catch{return!1}}function iy(e,t){let r={};for(let[n,o]of Object.entries(e)){let s=c_(n,t);if(s===null)continue;if(typeof o!="string"){console.warn("addresses need to be strings."),r[s]=null;continue}let i=jl(o,t);if(i===null){console.warn("the address was invalid."),r[s]=null;continue}if(n.endsWith("/")&&!or(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]=or(i)}return Qi(r)}function or(e){return e.href}function a_(e,t){let r={};for(let[o,s]of Object.entries(e)){if(!Fl(s))throw new TypeError("the value of the scope with prefix scopePrefix needs to be an object.");let i;try{i=new URL(o,t)}catch{console.warn("the scope prefix URL was not parseable.");continue}let a=or(i);r[a]=iy(s,t)}let n={};for(let o of Object.keys(r))n[o]=Qi(r[o]);return Qi(n)}function c_(e,t){if(!e.length)return console.warn("specifier key cannot be an empty string."),null;let r=jl(e,t);return r!==null?or(r):e}function jl(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 l_=["ftp","file","http","https","ws","wss"];function u_(e){return l_.some(t=>or(e).startsWith(t))}function sy(e,t,r){for(let[n,o]of Object.entries(r))if(n===e){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Zi(o))throw new TypeError("resolutionResult must be an URL.");return o}else if(n.endsWith("/")&&e.startsWith(n)&&(t===null||u_(t))){if(o===null)throw new TypeError("resolution of specifierKey was blocked by a null entry.");if(!Zi(o))throw new TypeError("resolutionResult must be an URL.");let s=e.slice(n.length);if(!o.endsWith("/"))throw new TypeError('resolutionResult does not end with "/"');try{let i=new URL(s,o);if(!Zi(i))throw new TypeError("url must be an URL.");if(!or(i).startsWith(o))throw new TypeError("resolution of normalizedSpecifier was blocked due to it backtracking above its prefix specifierKey.");return or(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 Ul(e,t){let r={};if(!oy(e))throw new TypeError("the top-level value needs to be a JSON object.");let{imports:n,scopes:o}=e;if(n!==void 0){if(!Al(n))throw new TypeError('"imports" top-level key needs to be an object.');r=iy(n,t)}let s={};if(o!==void 0){if(!$l(o))throw new TypeError('"scopes" top-level key needs to be an object.');s=a_(o,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 ay(e,{imports:t={},scopes:r={}},n){let o=or(n),s=jl(e,n),i=s!==null?or(s):e;for(let[c,l]of Object.entries(r))if(c===o||c.endsWith("/")&&o.startsWith(c)){let p=sy(i,s,l);if(p!==null)return p}let a=sy(i,s,t);if(a!==null)return a;if(s!==null)return or(s);throw new TypeError("specifier was a bare specifier, but was not remapped to anything by importMap.")}function ly(e,{allowTrailingComma:t=!0}={}){if(new.target)throw new TypeError("parse is not a constructor");return new Bl(e,{allowTrailingComma:t}).parse()}var cy=globalThis.JSON.parse,Bl=class{#i=new Set( \r
);#n=new Set([..."[]{}:,/",...this.#i]);#t;#e;#s;#a;constructor(t,r){this.#t=${t},this.#e=this.#t.length,this.#s=this.#d(),this.#a=r}parse(){let t=this.#o(),r=this.#u(t),{done:n,value:o}=this.#s.next();if(!n)throw new SyntaxError(Ur(o));return r}#o(){let{done:t,value:r}=this.#s.next();if(t)throw new SyntaxError("Unexpected end of JSONC input");return r}*#d(){for(let t=0;t<this.#e;t++)if(!this.#i.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,n=!1;for(t++;t<this.#e&&!(this.#t[t]==='"'&&!n);t++)n=this.#t[t]==="\\"&&!n;yield{type:"String",sourceText:this.#t.substring(r,t+1),position:r};break}default:{let r=t;for(;t<this.#e&&!this.#n.has(this.#t[t]);t++);t--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#t.substring(r,t+1),position:r}}}}}#u(t){switch(t.type){case"BeginObject":return this.#f();case"BeginArray":return this.#r();case"NullOrTrueOrFalseOrNumber":return this.#g(t);case"String":return this.#h(t);default:throw new SyntaxError(Ur(t))}}#f(){let t={};for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndObject")return t;if(n.type!=="String")throw new SyntaxError(Ur(n));let o=this.#h(n),s=this.#o();if(s.type!=="NameSeparator")throw new SyntaxError(Ur(s));let i=this.#o();Object.defineProperty(t,o,{value:this.#u(i),writable:!0,enumerable:!0,configurable:!0});let a=this.#o();if(a.type==="EndObject")return t;if(a.type!=="ValueSeparator")throw new SyntaxError(Ur(a))}}#r(){let t=[];for(let r=!0;;r=!1){let n=this.#o();if((r||this.#a.allowTrailingComma)&&n.type==="EndArray")return t;t.push(this.#u(n));let o=this.#o();if(o.type==="EndArray")return t;if(o.type!=="ValueSeparator")throw new SyntaxError(Ur(o))}}#h(t){let r;try{r=cy(t.sourceText)}catch{throw new SyntaxError(Ur(t))}return Yi(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=cy(t.sourceText)}catch{throw new SyntaxError(Ur(t))}return Yi(typeof r=="number"),r}};function Ur({type:e,sourceText:t,position:r}){let n="";switch(e){case"BeginObject":n="{";break;case"EndObject":n="}";break;case"BeginArray":n="[";break;case"EndArray":n="]";break;case"NameSeparator":n=":";break;case"ValueSeparator":n=",";break;case"NullOrTrueOrFalseOrNumber":case"String":n=30<t.length?${t.slice(0,30)}...:t;break;default:throw new Error("unreachable")}returnUnexpected token ${n} in JSONC at position ${r}}function ta(e){if(e.protocol==="file:")return{path:Xi(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}}async function Hl(e){let t=await Deno.readTextFile(e),r=ly(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 uy(e){if(e.imports!==void 0){let t=[];for(let[r,n]of Object.entries(e.imports))if(t.push([r,n]),!r.endsWith("/")&&n&&(n.startsWith("jsr:")||n.startsWith("npm:"))&&!e.imports[r+"/"]){let o=r+"/",s=n.slice(0,4)+"/"+n.slice(n[4]==="/"?5:4)+"/";t.push([o,s])}e.imports=Object.fromEntries(t)}}var d_=${eo}node_modules${eo},f_=${eo}node_modules;function ea(e){return e.includes(d_)||e.endsWith(f_)}function Wl(e){return(e.namespace===""||e.namespace==="file")&&(ea(e.resolveDir)||ea(e.path)||ea(e.importer))}function ql(e={}){return{name:"deno-resolver",setup(t){let r=null,n=(t.initialOptions.external??[]).map(o=>new RegExp("^"+o.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$"));t.onStart(async function(){let s;if(e.importMapURL===void 0&&e.configPath!==void 0){let i=await Hl(e.configPath);if(i.imports!==void 0||i.scopes!==void 0){let a={imports:i.imports,scopes:i.scopes};uy(a),r=Ul(a,Ko(e.configPath))}else i.importMap!==void 0&&(s=new URL(i.importMap,Ko(e.configPath)).href)}else e.importMapURL!==void 0&&(s=e.importMapURL);if(s){let i=await fetch(s),a=await i.json();r=Ul(a,new URL(i.url))}}),t.onResolve({filter:/.*/},async function(s){if(Wl(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(${Ko(s.resolveDir).href}/);else return;let a;if(r!==null){let u=ay(s.path,r,new URL(i));a=new URL(u)}else a=new URL(s.path,i);for(let u of n)if(u.test(a.href))return{path:a.href,external:!0};let{path:c,namespace:l}=ta(a);return await t.resolve(c,{namespace:l,kind:s.kind})})}}}var Ote=new TextEncoder;var m_=[],h_=[],zl="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";for(let e=0,t=zl.length;e<t;++e)m_[e]=zl[e],h_[zl.charCodeAt(e)]=e;var Qte=Deno.env.get("DENO_REGISTRY_URL")??"https://jsr.io";var E_=await Deno.permissions.query({name:"run"}).then(e=>e.state!=="granted")?"portable":"native";var py=ql;var dy=e=>!!(T_.includes(e.hostname)||e.hostname.endsWith(".openai.azure.com")),T_=["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"];function Br(e){if(typeof e!="string")throw new TypeError(Path must be a string, received "${JSON.stringify(e)}")}function Tn(e){return e===47}function fy(e){Br(e);let t=-1,r=0,n=-1,o=!0,s=0;for(let i=e.length-1;i>=0;--i){let a=e.charCodeAt(i);if(Tn(a)){if(!o){r=i+1;break}continue}n===-1&&(o=!1,n=i+1),a===46?t===-1?t=i:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||n===-1||s===0||s===1&&t===n-1&&t===r+1?"":e.slice(t,n)}function my(e,t){if(t.length>=e.length)return e;let r=e.length-t.length;for(let n=t.length-1;n>=0;--n)if(e.charCodeAt(r+n)!==t.charCodeAt(n))return e;return e.slice(0,-t.length)}function hy(e,t,r=0){let n=!1,o=e.length;for(let s=e.length-1;s>=r;--s)if(t(e.charCodeAt(s))){if(n){r=s+1;break}}else n||(n=!0,o=s+1);return e.slice(r,o)}function gy(e,t){if(Br(e),e.length===0)return e;if(typeof t!="string")throw new TypeError(Suffix must be a string, received "${JSON.stringify(t)}")}function yy(e,t){if(e.length<=1)return e;let r=e.length;for(let n=e.length-1;n>0&&t(e.charCodeAt(n));n--)r=n;return e.slice(0,r)}function by(e,t=""){gy(e,t);let r=hy(e,Tn),n=yy(r,Tn);return t?my(n,t):n}var ra=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function na(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 xy(e){return e=na(e),decodeURIComponent(e.pathname.replace(/%(?![0-9A-Fa-f]{2})/g,"%25"))}function wy(e){e=na(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}function vy(e){return ra?wy(e):xy(e)}var R_={" ":"%09","\n":"%0A","\v":"%0B","\f":"%0C","\r":"%0D"," ":"%20"};function oa(e){return e.replaceAll(/[\s]/g,t=>R_[t]??t)}function ky(e){return Br(e),e.length>0&&Tn(e.charCodeAt(0))}function Ey(e){if(!ky(e))throw new TypeError(Path must be absolute: received "${e}");let t=new URL("file:///");return t.pathname=oa(e.replace(/%/g,"%25").replace(/\\/g,"%5C")),t}function Kl(e){return e===47||e===92}function Ty(e){return e>=97&&e<=122||e>=65&&e<=90}function Py(e){Br(e);let t=e.length;if(t===0)return!1;let r=e.charCodeAt(0);return Kl(r)?!0:!!(Ty(r)&&t>2&&e.charCodeAt(1)===58&&Kl(e.charCodeAt(2)))}function Ry(e){if(!Py(e))throw new TypeError(Path must be absolute: received "${e}");let[,t,r]=e.match(/^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/),n=new URL("file:///");if(n.pathname=oa(r.replace(/%/g,"%25")),t!==void 0&&t!=="localhost"&&(n.hostname=t,!n.hostname))throw new TypeError(Invalid hostname: "${n.hostname}");return n}function Sy(e){return ra?Ry(e):Ey(e)}var _y=e=>{if(e.protocol==="file:")return{path:vy(e),namespace:"file"};let t=e.protocol.slice(0,-1);return{path:e.href.slice(t.length+1),namespace:t}},Yl=e=>e.namespace==="file"?Sy(e.path):new URL(${e.namespace}:${e.path});var Ly=(e,t)=>{let r=Zp(M_(e),()=>({name:"NotFoundError",message:"Source map URL is not found"}));if(W(r))return r;let{url:n,start:o,end:s}=B(r);return URL.canParse(n,t)?we({url:new URL(n,t),start:o,end:s}):Z({name:"InvalidURLError",message:Invalid URL: ${n}})},M_=e=>{for(let t of e.matchAll(/\/([*/])[#@] *sourceMappingURL=/g)){let r=t.index+t[0].length,n=e.length,o=r;for(;o<n&&e.charCodeAt(o)>32;)o++;if(o!==r&&(t[1]==="/"||e.indexOf("*/",o)>0))return{url:e.slice(r,o),start:r,end:o}}};var I_=["base64","binary","copy","css","dataurl","default","empty","file","js","json","jsx","local-css","text","ts","tsx"],Cy=e=>I_.includes(e),Oy=e=>/^js|^ts|css$/.test(e),Ny=e=>{let t=e.url,r=by(t);if(Cy(r))return r;if(r==="mjs")return"js";let n=new URL(t);n.search="",n.hash="";let o=fy(n.href).slice(1);if(Cy(o))return o;if(o==="mjs")return"js";let i=(e.headers.get("Content-Type")??"text/plain").split(";")[0]?.trim?.()??"text/plain";return D_(i)},D_=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 sa(e,t){if(isNaN(e)||isNaN(t))throw new Error("Cannot compare against non-numbers");return e===t?0:e<t?-1:1}function Dy(e=[],t=[]){return e.length&&!t.length?-1:!e.length&&t.length?1:0}function Xl(e=[],t=[]){let r=Math.max(e.length,t.length);for(let n=0;n<r;n++){let o=e[n],s=t[n];if(o===void 0&&s===void 0)return 0;if(s===void 0)return 1;if(o===void 0)return-1;if(typeof o=="string"&&typeof s=="number")return 1;if(typeof o=="number"&&typeof s=="string"||o<s)return-1;if(o>s)return 1}return 0}var to="0|[1-9]\\d*",A_="\\d*[a-zA-Z-][a-zA-Z0-9-]*",$_=(?<major>${to})\\.(?<minor>${to})\\.(?<patch>${to}),My=(?:${to}|${A_}),Ay=(?:-(?<prerelease>${My}(?:\\.${My})*)),Iy="[0-9A-Za-z-]+",$y=(?:\\+(?<buildmetadata>${Iy}(?:\\.${Iy})*)),Fy=v?${$_}${Ay}?${$y}?,jy=new RegExp(^${Fy}$),Uy="(?:<|>)?=?",F_="x|X|\\*",Vl=${to}|${F_},ia=v=\\s*(?<major>${Vl})(?:\\.(?<minor>${Vl})(?:\\.(?<patch>${Vl})${Ay}?${$y}?)?)?,By=new RegExp(^(?<operator>~>?|\\^|${Uy})\\s*${ia}$),Hy=new RegExp(^(?<operator>${Uy})\\s*(${Fy})$|^$);function Jl(e){return typeof e=="number"&&!Number.isNaN(e)&&(!Number.isFinite(e)||0<=e&&e<=Number.MAX_SAFE_INTEGER)}var Ql=256;var j_=new RegExp(^${to}$);function vt(e){return e.split(".").filter(Boolean).map(t=>{if(j_.test(t)){let r=Number(t);if(Jl(r))return r}return t})}function sr(e){return e.split(".").filter(Boolean)}function Hr(e,t){let r=Number(e);if(!Jl(r))throw new TypeError(t);return r}function Pn(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 jt(e,t){return e===t?0:sa(e.major,t.major)||sa(e.minor,t.minor)||sa(e.patch,t.patch)||Dy(e.prerelease,t.prerelease)||Xl(e.prerelease,t.prerelease)}function Zl(e){return e.toFixed(0)}function Rn(e){let t=Zl(e.major),r=Zl(e.minor),n=Zl(e.patch),o=e.prerelease?.join(".")??"",s=e.build?.join(".")??"";return[[${t}.${r}.${n},o].filter(c=>c).join("-"),s].filter(c=>c).join("+")}function U_(e,t){if(Pn(t))return!0;let r=jt(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 aa(e,t){for(let r of t)if(!U_(e,r))return!1;if(e.prerelease&&e.prerelease.length>0){for(let r of t){if(Pn(r))continue;let{major:n,minor:o,patch:s,prerelease:i}=r;if(i&&i.length>0&&e.major===n&&e.minor===o&&e.patch===s)return!0}return!1}return!0}function ca(e,t){return t.some(r=>aa(e,r))}var la={major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]},ro={operator:void 0,...la};function Wy(e,t){return jt(e,t)>0}function Yo(e,t){let r;for(let n of e)ca(n,t)&&(r=r&&Wy(r,n)?r:n);return r}function B_(e){let r=e.match(Hy)?.groups;if(!r)return null;let{operator:n,prerelease:o,buildmetadata:s}=r,i=r.major?{major:Hr(r.major,Cannot parse comparator ${e}: invalid major version),minor:Hr(r.minor,Cannot parse comparator ${e}: invalid minor version),patch:Hr(r.patch,Cannot parse comparator ${e}: invalid patch version),prerelease:o?vt(o):[],build:s?sr(s):[]}:la;return{operator:n||void 0,...i}}function Te(e){return!e||e.toLowerCase()==="x"||e==="*"}function H_(e){if(!Te(e.major))return Te(e.minor)?{operator:">=",major:+e.major,minor:0,patch:0,prerelease:[],build:[]}:Te(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 W_(e){if(!Te(e.major))return Te(e.minor)?{operator:"<",major:+e.major+1,minor:0,patch:0,prerelease:[],build:[]}:Te(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:e.prerelease?vt(e.prerelease):[],build:[]}}function q_(e){let t=e.match(new RegExp(^${ia})),r=t?.groups;if(!r)return;let n=t[0].length,o=e.slice(n).match(/^\s+-\s+/);if(!o)return;let s=o[0].length,a=e.slice(n+s).match(new RegExp(^${ia}\\s*$))?.groups;if(!a)return;let c=H_(r),l=W_(a);return[c,l].filter(Boolean)}function z_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[ro];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return o===0?[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];let a=vt(e.prerelease??"");return o===0?s===0?[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s,patch:i+1}]:[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s+1,patch:0}]:[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o+1,minor:0,patch:0}]}function G_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[ro];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let a=vt(e.prerelease??"");return[{operator:">=",major:o,minor:s,patch:i,prerelease:a},{operator:"<",major:o,minor:s+1,patch:0}]}function K_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return n?[{operator:"<",major:o,minor:0,patch:0}]:[{operator:"<",major:o,minor:s,patch:0}];if(n)return[{operator:"<",major:o,minor:s,patch:0}];let a=vt(e.prerelease??""),c=sr(e.build??"");return[{operator:"<",major:o,minor:s,patch:i,prerelease:a,build:c}]}function Y_(e){let t=Te(e.minor),r=Te(e.patch),n=+e.major,o=+e.minor,s=+e.patch;if(t)return r?[{operator:"<",major:n+1,minor:0,patch:0}]:[{operator:"<",major:n,minor:o+1,patch:0}];if(r)return[{operator:"<",major:n,minor:o+1,patch:0}];let i=vt(e.prerelease??""),a=sr(e.build??"");return[{operator:"<=",major:n,minor:o,patch:s,prerelease:i,build:a}]}function V_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[{operator:"<",major:0,minor:0,patch:0}];if(r)return[{operator:">=",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s+1,patch:0}];let a=vt(e.prerelease??""),c=sr(e.build??"");return[{operator:">",major:o,minor:s,patch:i,prerelease:a,build:c}]}function X_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[ro];if(r)return n?[{operator:">=",major:o,minor:0,patch:0}]:[{operator:">=",major:o,minor:s,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0}];let a=vt(e.prerelease??""),c=sr(e.build??"");return[{operator:">=",major:o,minor:s,patch:i,prerelease:a,build:c}]}function J_(e){let t=Te(e.major),r=Te(e.minor),n=Te(e.patch),o=+e.major,s=+e.minor,i=+e.patch;if(t)return[ro];if(r)return[{operator:">=",major:o,minor:0,patch:0},{operator:"<",major:o+1,minor:0,patch:0}];if(n)return[{operator:">=",major:o,minor:s,patch:0},{operator:"<",major:o,minor:s+1,patch:0}];let a=vt(e.prerelease??""),c=sr(e.build??"");return[{operator:void 0,major:o,minor:s,patch:i,prerelease:a,build:c}]}function Q_(e){let t=e.match(By)?.groups;if(!t)return B_(e);switch(t.operator){case"^":return z_(t);case"~":case"~>":return G_(t);case"<":return K_(t);case"<=":return Y_(t);case">":return V_(t);case">=":return X_(t);case"=":case"":return J_(t);default:throw new Error(Cannot parse version range: '${t.operator}' is not a valid operator)}}function Z_(e){return e.split(/\s+/).flatMap(Q_)}function qy(e){let t=e.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g,"").split(/\s*\|\|\s*/).map(r=>q_(r)||Z_(r));if(t.some(r=>r.includes(null)))throw new TypeError(Cannot parse version range: range "${e}" is invalid);return t}function eu(e){if(typeof e!="string")throw new TypeError(Cannot parse version as version must be a string: received ${typeof e});if(e.length>Ql)throw new TypeError(Cannot parse version as version length is too long: length is ${e.length}, max length is ${Ql});e=e.trim();let t=e.match(jy)?.groups;if(!t)throw new TypeError(Cannot parse version: ${e});let r=Hr(t.major,Cannot parse version ${e}: invalid major version),n=Hr(t.minor,Cannot parse version ${e}: invalid minor version),o=Hr(t.patch,Cannot parse version ${e}: invalid patch version),s=t.prerelease?vt(t.prerelease):[],i=t.buildmetadata?sr(t.buildmetadata):[];return{major:r,minor:n,patch:o,prerelease:s,build:i}}function tu(e){try{return qy(e)}catch{return}}function ru(e){try{return eu(e)}catch{return}}var Vo={operator:void 0,major:Number.NaN,minor:Number.NaN,patch:Number.NaN,prerelease:[],build:[]};var Wr=async e=>{try{let t=await fetch(e);return t.ok?we([t,!1]):Z({name:"HTTPError",message:${t.status} ${t.statusText},response:t})}catch(t){if(t instanceof TypeError)return Z({name:"NetworkError",message:t.message,request:e});if(t instanceof DOMException)return Z({name:"AbortError",message:t.message,request:e});throw t}};var nu="https://jsr.io",zy=async(e,t)=>{let r=await(t?.fetch??Wr)(new Request(${t?.endpoint??nu}/${e}/meta.json),t?.cacheFirst);return Mt(r,([n])=>n.json())};var Gy=async(e,t,r)=>{let n=await(r?.fetch??Wr)(new Request(${r?.endpoint??nu}/${e}/${t}_meta.json),r?.cacheFirst);return Mt(n,([o])=>o.json())};var Ky=async(e,t)=>{let r=await(t?.fetch??Wr)(new Request(${t?.endpoint??"https://registry.npmjs.org"}/${e}),t?.cacheFirst);return Mt(r,([n])=>n.json())};var Xy=(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}),ua=(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}),Jy=async(e,t)=>{if(t?.resolvedVersions){let c=new Map(t.resolvedVersions.get(e.name)??[]),l=Yo([...c.keys()],e.range);if(l){let p=c.get(l)??Xo,u=p[e.entryPoint];return typeof u!="string"&&console.log(u),u?we(Yy(e.name,Rn(l),u)):Z(ua(e,Object.keys(p)))}}let r=await Ky(e.name,t);if(W(r))return r;let n=B(r),o=new Map(Object.entries(n.versions).flatMap(([c,{exports:l}])=>{let p=ru(c);return p?[[p,l??Xo]]:[]})),s=Yo([...o.keys()],e.range);if(!s)return Z(Xy(e,Object.keys(n.versions)));let i={...Xo};for(let c of Object.keys(o.get(s)??Xo))i[c]=c;let a=i[e.entryPoint];return a?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[s,i]]),we(Yy(e.name,Rn(s),a))):Z(ua(e,Object.keys(i)))},Yy=(e,t,r)=>new URL(r,https://esm.sh/${e}@${t}/),Qy=async(e,t)=>{if(t?.resolvedVersions){let a=new Map(t.resolvedVersions.get(e.name)??[]),c=Yo([...a.keys()],e.range);if(c){let l=a.get(c)??Xo,p=l[e.entryPoint];return p?we(Vy(e.name,Rn(c),p)):Z(ua(e,Object.keys(l)))}}let r=await e1(e,t);if(W(r))return r;let n=B(r),o=await Gy(e.name,Rn(n),t);if(W(o))return o;let s=B(o).exports,i=s[e.entryPoint];return i?(t?.resolvedVersions?.set(e.name,[...t.resolvedVersions.get(e.name)??[],[n,s]]),we(Vy(e.name,Rn(n),i))):Z(ua(e,Object.keys(B(o).exports)))},Vy=(e,t,r)=>new URL(r,https://jsr.io/${e}/${t}/),e1=async(e,t)=>{let r=await zy(e.name,t);if(W(r))return r;let n=B(r),o=Object.keys(n.versions).flatMap(i=>{let a=ru(i);return a?[a]:[]}),s=Yo(o,e.range);return s?we(s):Z(Xy(e,Object.keys(n.versions)))},Xo={".":"./"};var t1=e=>({name:"OnlyScopeProvidedError",specifier:e}),Zy=e=>({name:"PackageNotFoundError",specifier:e}),eb=e=>{if(e.protocol!=="npm:")return Z({name:"NotNpmProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0,n,o;if(t[r]==="@"){let u=t.indexOf("/",r);if(u===-1)return Z(t1(e));n=t.indexOf("/",u+1),o=t.indexOf("@",u+1)}else n=t.indexOf("/",r),o=t.indexOf("@",r);if(n===-1&&(n=t.length),o===-1&&(o=t.length),o=Math.min(o,n),r===o)return Z(Zy(e));let s=t.slice(r,o),i=decodeURIComponent(t.slice(o+1,n)),a=i?tu(i)??[[Vo]]:[[Vo]],c=t.slice(n+1),l=c?./${c}:".",p={name:s,range:a,entryPoint:l};return i&&(p.tag=i),we(p)},tb=e=>{if(e.protocol!=="jsr:")return Z({name:"NotJsrProtocolError",specifier:e});let t=e.pathname,r=t[0]==="/"?1:0;if(t[r]!=="@")return Z({name:"ScopeNotFoundError",specifier:e});let n=t.indexOf("/",r);if(n===-1)return Z(Zy(e));let o=t.indexOf("/",n+1),s=t.indexOf("@",n+1);o===-1&&(o=t.length),s===-1&&(s=t.length),s=Math.min(s,o);let i=t.slice(r,s),a=decodeURIComponent(t.slice(s+1,o)),c=a?tu(a)??[[Vo]]:[[Vo]],l=t.slice(o+1),p=l?./${l}:".",u={name:i,range:c,entryPoint:p};return a&&(u.tag=a),we(u)};var rb=e=>new Promise((t,r)=>{let n=new FileReader;n.addEventListener("load",()=>{let o=n.result,s=o.indexOf(";");o.startsWith("; charset=utf-8",s)?t(${o.slice(0,s)}${o.slice(s+15)}):t(o)}),n.addEventListener("error",()=>r(n.error)),n.readAsDataURL(e)});var sb=e=>{let t=new Map,r=async n=>{let o=n.namespace==="npm",s=(o?eb:tb)(Yl(n));if(W(s)){let a=ee(s);return{errors:[{text:a.name,detail:a}]}}let i=await(o?Jy:Qy)(B(s),{resolvedVersions:t,...e});if(W(i)){let a=ee(i);return{errors:[{text:${a.name} ${a.message},detail:a}]}}return _y(B(i))};return{name:"remote-loader",setup({onLoad:n,onResolve:o,initialOptions:s}){for(let i of[...nb,...ob])o({filter:/.*/,namespace:i.slice(0,-1)},r1);o({filter:/.*/,namespace:"npm"},r),o({filter:/.*/,namespace:"jsr"},r);for(let i of nb)n({filter:/.*/,namespace:i.slice(0,-1)},a=>n1(Yl(a),{...e,sourcemap:s.sourcemap!==!1&&s.sourcemap!==void 0}));for(let i of ob)n({filter:/.*/,namespace:i.slice(0,-1)},()=>{throw new Error(${i} import is not supported yet.)})}}},r1=e=>({path:e.path,namespace:e.namespace}),nb=["http:","https:","data:"],ob=["node:"],n1=async(e,t)=>{let r=t.reload?t.reload===!0?!1:!t.reload.some(l=>l.test(e)):!0,n=t.fetch??Wr,o=await n(new Request(e),r);if(W(o))return{errors:[{text:${ee(o).message} Failed to fetch ${e},detail:ee(o)}]};let[s,i]=B(o),a=Ny(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&&Oy(a)){let l=await c.text(),p=Ly(l,e);if(Pr(p)){let{url:u,start:f,end:d}=B(p);if(u.protocol!=="data:"){let h=await n(new Request(u),r);if(W(h))return{contents:l,loader:a,warnings:[{text:${ee(h).message} Failed to fetch the source map URL,notes:[{text:Source map URL: ${u}},{text:Original URL: ${e}}],detail:ee(h)}]};let g=await B(h)[0].blob().then(rb);return{contents:l.slice(0,f)+g+l.slice(d),loader:a}}}}return{contents:new Uint8Array(await c.arrayBuffer()),loader:a}};var Zo=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor(e,t,r,n,o,s){this.type=e,this.name=t,this.prefix=r,this.value=n,this.suffix=o,this.modifier=s}hasCustomName(){return this.name!==""&&typeof this.name!="number"}},o1=/[$_\p{ID_Start}]/u,s1=/[$_\u200C\u200D\p{ID_Continue}]/u,su=".*";function i1(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}function cb(e,t=!1){let r=[],n=0;for(;n<e.length;){let o=e[n],s=function(i){if(!t)throw new TypeError(i);r.push({type:"INVALID_CHAR",index:n,value:e[n++]})};if(o==="*"){r.push({type:"ASTERISK",index:n,value:e[n++]});continue}if(o==="+"||o==="?"){r.push({type:"OTHER_MODIFIER",index:n,value:e[n++]});continue}if(o==="\\"){r.push({type:"ESCAPED_CHAR",index:n++,value:e[n++]});continue}if(o==="{"){r.push({type:"OPEN",index:n,value:e[n++]});continue}if(o==="}"){r.push({type:"CLOSE",index:n,value:e[n++]});continue}if(o===":"){let i="",a=n+1;for(;a<e.length;){let c=e.substr(a,1);if(a===n+1&&o1.test(c)||a!==n+1&&s1.test(c)){i+=e[a++];continue}break}if(!i){s(Missing parameter name at ${n});continue}r.push({type:"NAME",index:n,value:i}),n=a;continue}if(o==="("){let i=1,a="",c=n+1,l=!1;if(e[c]==="?"){s(Pattern cannot start with "?" at ${c});continue}for(;c<e.length;){if(!i1(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 ${n});continue}if(!a){s(Missing pattern at ${n});continue}r.push({type:"REGEX",index:n,value:a}),n=c;continue}r.push({type:"CHAR",index:n,value:e[n++]})}return r.push({type:"END",index:n,value:""}),r}function lb(e,t={}){let r=cb(e);t.delimiter??="/#?",t.prefixes??="./";let n=^${Ut(t.delimiter)}+?,o=[],s=0,i=0,a="",c=new Set,l=E=>{if(i<r.length&&r[i].type===E)return r[i++].value},p=()=>l("OTHER_MODIFIER")??l("ASTERISK"),u=E=>{let b=l(E);if(b!==void 0)return b;let{type:k,index:v}=r[i];throw new TypeError(Unexpected ${k} at ${v}, expected ${E})},f=()=>{let E="",b;for(;b=l("CHAR")??l("ESCAPED_CHAR");)E+=b;return E},d=E=>E,h=t.encodePart||d,g="",y=E=>{g+=E},w=()=>{g.length&&(o.push(new Zo(3,"","",h(g),"",3)),g="")},R=(E,b,k,v,L)=>{let C=3;switch(L){case"?":C=1;break;case"*":C=0;break;case"+":C=2;break}if(!b&&!k&&C===3){y(E);return}if(w(),!b&&!k){if(!E)return;o.push(new Zo(3,"","",h(E),"",C));return}let O;k?k==="*"?O=su:O=k:O=n;let S=2;O===n?(S=1,O=""):O===su&&(S=0,O="");let T;if(b?T=b:k&&(T=s++),c.has(T))throw new TypeError(Duplicate name '${T}'.);c.add(T),o.push(new Zo(S,T,h(E),O,h(v),C))};for(;i<r.length;){let E=l("CHAR"),b=l("NAME"),k=l("REGEX");if(!b&&!k&&(k=l("ASTERISK")),b||k){let L=E??"";t.prefixes.indexOf(L)===-1&&(y(L),L=""),w();let C=p();R(L,b,k,"",C);continue}let v=E??l("ESCAPED_CHAR");if(v){y(v);continue}if(l("OPEN")){let L=f(),C=l("NAME"),O=l("REGEX");!C&&!O&&(O=l("ASTERISK"));let S=f();u("CLOSE");let T=p();R(L,C,O,S,T);continue}w(),u("END")}return o}function Ut(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function ib(e){return e&&e.ignoreCase?"ui":"u"}function a1(e,t,r){return ub(lb(e,r),t,r)}function no(e){switch(e){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}function ub(e,t,r={}){r.delimiter??="/#?",r.prefixes??="./",r.sensitive??=!1,r.strict??=!1,r.end??=!0,r.start??=!0,r.endsWith="";let n=r.start?"^":"";for(let a of e){if(a.type===3){a.modifier===3?n+=Ut(a.value):n+=(?:${Ut(a.value)})${no(a.modifier)};continue}t&&t.push(a.name);let c=^${Ut(r.delimiter)}+?,l=a.value;if(a.type===1?l=c:a.type===0&&(l=su),!a.prefix.length&&!a.suffix.length){a.modifier===3||a.modifier===1?n+=(${l})${no(a.modifier)}:n+=((?:${l})${no(a.modifier)});continue}if(a.modifier===3||a.modifier===1){n+=(?:${Ut(a.prefix)}(${l})${Ut(a.suffix)}),n+=no(a.modifier);continue}n+=(?:${Ut(a.prefix)},n+=((?:${l})(?:,n+=Ut(a.suffix),n+=Ut(a.prefix),n+=(?:${l}))*)${Ut(a.suffix)}),a.modifier===0&&(n+="?")}let o=${Ut(r.endsWith)}|$,s=${Ut(r.delimiter)};if(r.end)return r.strict||(n+=${s}?),r.endsWith.length?n+=(?=${o}):n+="$",new RegExp(n,ib(r));r.strict||(n+=(?:${s}(?=${o}))?);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||(n+=(?=${s}|${o})),new RegExp(n,ib(r))}var zr={delimiter:"",prefixes:"",sensitive:!0,strict:!0},c1={delimiter:".",prefixes:"",sensitive:!0,strict:!0},l1={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function u1(e,t){return e.length?e[0]==="/"?!0:!t||e.length<2?!1:(e[0]=="\\"||e[0]=="{")&&e[1]=="/":!1}function pb(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}function p1(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}function db(e){return!e||e.length<2?!1:e[0]==="["||(e[0]==="\\"||e[0]==="{")&&e[1]==="["}var fb=["ftp","file","http","https","ws","wss"];function mb(e){if(!e)return!0;for(let t of fb)if(e.test(t))return!0;return!1}function d1(e,t){if(e=pb(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 f1(e,t){if(e=pb(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 m1(e,t){return t||e===""?e:db(e)?yb(e):gb(e)}function h1(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.password=e,r.password}function g1(e,t){if(t||e==="")return e;let r=new URL("https://example.com");return r.username=e,r.username}function y1(e,t,r){if(r||e==="")return e;if(t&&!fb.includes(t))return new URL(${t}:${e}).pathname;let n=e[0]=="/";return e=new URL(n?e:"/-"+e,"https://example.com").pathname,n||(e=e.substring(2,e.length)),e}function b1(e,t,r){return hb(t)===e&&(e=""),r||e===""?e:bb(e)}function x1(e,t){return e=p1(e,":"),t||e===""?e:iu(e)}function hb(e){switch(e){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}function iu(e){if(e==="")return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw new TypeError(Invalid protocol '${e}'.)}function w1(e){if(e==="")return e;let t=new URL("https://example.com");return t.username=e,t.username}function v1(e){if(e==="")return e;let t=new URL("https://example.com");return t.password=e,t.password}function gb(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 yb(e){if(e==="")return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw new TypeError(Invalid IPv6 hostname '${e}');return e.toLowerCase()}function bb(e){if(e===""||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw new TypeError(Invalid port '${e}'.)}function k1(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 E1(e){return e===""?e:new URL(data:${e}).pathname}function T1(e){if(e==="")return e;let t=new URL("https://example.com");return t.search=e,t.search.substring(1,t.search.length)}function P1(e){if(e==="")return e;let t=new URL("https://example.com");return t.hash=e,t.hash.substring(1,t.hash.length)}var R1=class{#i;#n=[];#t={};#e=0;#s=1;#a=0;#o=0;#d=0;#u=0;#f=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=cb(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type==="END"){if(this.#o===0){this.#g(),this.#p()?this.#r(9,1):this.#m()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#y(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#R())this.#d-=1;else continue;if(this.#P()){this.#d+=1;continue}switch(this.#o){case 0:this.#v()&&this.#y(1);break;case 1:if(this.#v()){this.#L();let e=7,t=1;this.#k()?(e=2,t=3):this.#f&&(e=2),this.#r(e,t)}break;case 2:this.#x()?this.#y(3):(this.#w()||this.#m()||this.#p())&&this.#y(5);break;case 3:this.#E()?this.#r(4,1):this.#x()&&this.#r(5,1);break;case 4:this.#x()&&this.#r(5,1);break;case 5:this.#S()?this.#u+=1:this.#_()&&(this.#u-=1),this.#T()&&!this.#u?this.#r(6,1):this.#w()?this.#r(7,0):this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 6:this.#w()?this.#r(7,0):this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 7:this.#m()?this.#r(8,1):this.#p()&&this.#r(9,1);break;case 8:this.#p()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port="")}#r(e,t){switch(this.#o){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.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=""),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#f?"/":""),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??="")),this.#h(e,t)}#h(e,t){this.#o=e,this.#a=this.#e+t,this.#e+=t,this.#s=0}#g(){this.#e=this.#a,this.#s=0}#y(e){this.#g(),this.#o=e}#b(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#c(e,t){let r=this.#b(e);return r.value===t&&(r.type==="CHAR"||r.type==="ESCAPED_CHAR"||r.type==="INVALID_CHAR")}#v(){return this.#c(this.#e,":")}#k(){return this.#c(this.#e+1,"/")&&this.#c(this.#e+2,"/")}#x(){return this.#c(this.#e,"@")}#E(){return this.#c(this.#e,":")}#T(){return this.#c(this.#e,":")}#w(){return this.#c(this.#e,"/")}#m(){if(this.#c(this.#e,"?"))return!0;if(this.#n[this.#e].value!=="?")return!1;let e=this.#b(this.#e-1);return e.type!=="NAME"&&e.type!=="REGEX"&&e.type!=="CLOSE"&&e.type!=="ASTERISK"}#p(){return this.#c(this.#e,"#")}#P(){return this.#n[this.#e].type=="OPEN"}#R(){return this.#n[this.#e].type=="CLOSE"}#S(){return this.#c(this.#e,"[")}#_(){return this.#c(this.#e,"]")}#l(){let e=this.#n[this.#e],t=this.#b(this.#a).index;return this.#i.substring(t,e.index)}#L(){let e={};Object.assign(e,zr),e.encodePart=iu;let t=a1(this.#l(),void 0,e);this.#f=mb(t)}},ou=["protocol","username","password","hostname","port","pathname","search","hash"],qr="*";function ab(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 vr(e,t){return t?Qo(e):e}function Jo(e,t,r){let n;if(typeof t.baseURL=="string")try{n=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=vr(n.protocol.substring(0,n.protocol.length-1),r)),!r&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=vr(n.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=vr(n.password,r)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=vr(n.hostname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=vr(n.port,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=vr(n.pathname,r)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=vr(n.search.substring(1,n.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=vr(n.hash.substring(1,n.hash.length),r))}catch{throw new TypeError(invalid baseURL '${t.baseURL}'.)}if(typeof t.protocol=="string"&&(e.protocol=x1(t.protocol,r)),typeof t.username=="string"&&(e.username=g1(t.username,r)),typeof t.password=="string"&&(e.password=h1(t.password,r)),typeof t.hostname=="string"&&(e.hostname=m1(t.hostname,r)),typeof t.port=="string"&&(e.port=b1(t.port,e.protocol,r)),typeof t.pathname=="string"){if(e.pathname=t.pathname,n&&!u1(e.pathname,r)){let o=n.pathname.lastIndexOf("/");o>=0&&(e.pathname=vr(n.pathname.substring(0,o+1),r)+e.pathname)}e.pathname=y1(e.pathname,e.protocol,r)}return typeof t.search=="string"&&(e.search=f1(t.search,r)),typeof t.hash=="string"&&(e.hash=d1(t.hash,r)),e}function Qo(e){return e.replace(/([+*?:{}()\\])/g,"\\$1")}function S1(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}function _1(e,t){t.delimiter??="/#?",t.prefixes??="./",t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith="";let r=".*",n=^${S1(t.delimiter)}+?,o=/[$_\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+=Qo(a.value);continue}s+={${Qo(a.value)}}${no(a.modifier)};continue}let c=a.hasCustomName(),l=!!a.suffix.length||!!a.prefix.length&&(a.prefix.length!==1||!t.prefixes.includes(a.prefix)),p=i>0?e[i-1]:null,u=i<e.length-1?e[i+1]:null;if(!l&&c&&a.type===1&&a.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let f=u.value.length>0?u.value[0]:"";l=o.test(f)}else l=!u.hasCustomName();if(!l&&!a.prefix.length&&p&&p.type===3){let f=p.value[p.value.length-1];l=t.prefixes.includes(f)}l&&(s+="{"),s+=Qo(a.prefix),c&&(s+=:${a.name}),a.type===2?s+=(${a.value}):a.type===1?c||(s+=(${n})):a.type===0&&(!c&&(!p||p.type===3||p.modifier!==3||l||a.prefix!=="")?s+="*":s+=(${r})),a.type===1&&c&&a.suffix.length&&o.test(a.suffix[0])&&(s+="\\"),s+=Qo(a.suffix),l&&(s+="}"),a.modifier!==3&&(s+=no(a.modifier))}return s}var xb=class{#i;#n={};#t={};#e={};#s={};#a=!1;constructor(e={},t,r){try{let n;if(typeof t=="string"?n=t:r=t,typeof e=="string"){let a=new R1(e);if(a.parse(),e=a.result,n===void 0&&typeof e.protocol!="string")throw new TypeError("A base URL must be provided for a relative constructor string.");e.baseURL=n}else{if(!e||typeof e!="object")throw new TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(n)throw new TypeError("parameter 1 is not of type 'string'.")}typeof r>"u"&&(r={ignoreCase:!1});let o={ignoreCase:r.ignoreCase===!0},s={pathname:qr,protocol:qr,username:qr,password:qr,hostname:qr,port:qr,search:qr,hash:qr};this.#i=Jo(s,e,!0),hb(this.#i.protocol)===this.#i.port&&(this.#i.port="");let i;for(i of ou){if(!(i in this.#i))continue;let a={},c=this.#i[i];switch(this.#t[i]=[],i){case"protocol":Object.assign(a,zr),a.encodePart=iu;break;case"username":Object.assign(a,zr),a.encodePart=w1;break;case"password":Object.assign(a,zr),a.encodePart=v1;break;case"hostname":Object.assign(a,c1),db(c)?a.encodePart=yb:a.encodePart=gb;break;case"port":Object.assign(a,zr),a.encodePart=bb;break;case"pathname":mb(this.#n.protocol)?(Object.assign(a,l1,o),a.encodePart=k1):(Object.assign(a,zr,o),a.encodePart=E1);break;case"search":Object.assign(a,zr,o),a.encodePart=T1;break;case"hash":Object.assign(a,zr,o),a.encodePart=P1;break}try{this.#s[i]=lb(c,a),this.#n[i]=ub(this.#s[i],this.#t[i],a),this.#e[i]=_1(this.#s[i],a),this.#a=this.#a||this.#s[i].some(l=>l.type===2)}catch{throw new TypeError(invalid ${i} pattern '${this.#ii}'.)}}}catch(n){throw new TypeError(Failed to construct 'URLPattern': ${n.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=Jo(r,e,!1):r=Jo(r,ab(e,t),!1)}catch{return!1}let n;for(n of ou)if(!this.#n[n].exec(r[n]))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=Jo(r,e,!1):r=Jo(r,ab(e,t),!1)}catch{return null}let n={};t?n.inputs=[e,t]:n.inputs=[e];let o;for(o of ou){let s=this.#n[o].exec(r[o]);if(!s)return null;let i={};for(let[a,c]of this.#t[o].entries())if(typeof c=="string"||typeof c=="number"){let l=s[a+1];i[c]=l}n[o]={input:r[o]??"",groups:i}}return n}static compareComponent(e,t,r){let n=(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},o=new Zo(3,"","","","",3),s=new Zo(0,"","","","",3),i=(a,c)=>{let l=0;for(;l<Math.min(a.length,c.length);++l){let p=n(a[l],c[l]);if(p)return p}return a.length===c.length?0:n(a[l]??o,c[l]??o)};return!t.#e[e]&&!r.#e[e]?0:t.#e[e]&&!r.#e[e]?i(t.#s[e],[s]):!t.#e[e]&&r.#e[e]?i([s],r.#s[e]):i(t.#s[e],r.#s[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=xb);var wb,vb=async(e,t)=>(wb??=Wi({wasm:e,worker:t}),await wb,async r=>{let{outputFiles:n}=await Bi({entryPoints:[r],format:"esm",bundle:!0,minify:!0,charset:"utf8",plugins:[py(),sb({fetch:L1,reload:[new URLPattern({hostname:location.hostname}),new URLPattern({hostname:"scrapbox.io"})]})],write:!1});return{contents:n[0].text}}),L1=async(e,t)=>{let r=dy(new URL(e.url))||!GM_fetch?globalThis.fetch:GM_fetch;if(t){let n=await au(e);if(n)return n}try{let n=await r(e);return n.ok?(r===GM_fetch&&!e.url.startsWith("data:")&&await ti(e,n),we([n,!1])):await au(e)??Z({name:"HTTPError",message:${n.status} ${n.statusText},response:n})}catch(n){let o=await au(e);if(o)return o;if(n instanceof TypeError)return Z({name:"NetworkError",message:n.message,request:e});if(n instanceof DOMException)return Z({name:"AbortError",message:n.message,request:e});throw n}},au=async e=>{if(e.url.startsWith("data:"))return;let t=await Fn(e);if(t)return t.url||Object.defineProperty(t,"url",{value:e.url}),we([t,!0])};var kb=e=>["ts","js","tsx","jsx","mjs","javascript","typescript"].includes(e);var Eb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-check-circle-fill"),e.style.color="hsl(133, 46.1%, 47.3%)",e},Tb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-cross-circle"),e.style.color="hsl(1.7, 64.5%, 58%)",e},Pb=()=>{let e=document.createElement("i");return e.classList.add("i","fa","fa-spinner"),e},Rb=()=>{let e=document.createElement("i");return e.classList.add("kamon","kamon-play"),e};var Sb=()=>{let e;return{show:(n,{x:o,y:s})=>{e=C1(),e.append(O1(n)),e.style.visibility="hidden",document.body.append(e);let{height:i}=e.getBoundingClientRect();e.style.top=${s-i}px,e.style.left=${o}px,e.style.removeProperty("visibility")},hide:async()=>{e?.classList?.remove?.("in"),await new Promise(n=>setTimeout(n,150)),e?.remove?.()}}},C1=()=>{let e=document.createElement("div");return e.setAttribute("role","tooltip"),e.classList.add("fade","in","tooltip","top"),e},O1=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 _b=()=>{let e=document.createElement("a");e.classList.add("tool-btn"),e.type="button",e.setAttribute("aria-haspopup","true");let t=!1,{show:r,hide:n}=Sb();return{component:e,setStatus:async(s,i)=>{switch(e.textContent="",await n(),s){case"loading":e.append(Pb());break;case"pass":e.append(Eb());break;case"fail":e.append(Tb());break;case"none":break}i!==void 0&&s!=="none"?(e.style.removeProperty("pointer-events"),e.onclick=async()=>{if(t)await n();else{let{top:a,left:c}=e.getBoundingClientRect();r(i,{y:a+globalThis.scrollY,x:c})}t=!t}):e.style.pointerEvents="none"}}};var Lb=e=>{let t=document.createElement("a");return t.classList.add("tool-btn"),t.type="button",t.setAttribute("aria-haspopup","true"),t.append(Rb()),t.addEventListener("click",e),t};var Cb=e=>{let{component:t,setStatus:r}=_b(),n=document.createElement("div");return n.style.position="absolute",n.style.left="-2em",n.style.zIndex="1",n.style.display="flex",n.style.flexFlow="column",n.append(Lb(e),t),{menu:n,setStatus:r}};function Ob(e){return new Promise(t=>setTimeout(t,e))}function Nb(e,t){let{trailing:r=!1,interval:n=0}=t??{},o,s=!1,i=l=>{o?.resolve?.({executed:!1}),o=l},a=()=>{let{...l}=o;return o=void 0,l},c=async()=>{if(s||!o)return;s=!0,n>0&&await Ob(n);let{parameters:l,resolve:p,reject:u}=a();try{let f=await e(...l);s=!1,p({result:f,executed:!0})}catch(f){s=!1,u(f)}finally{r?await c():(i(),await Promise.resolve())}};return(...l)=>new Promise((p,u)=>{i({parameters:l,resolve:p,reject:u}),c()})}var Mb,Ib=async(e,t)=>{let r=[],o=Nb(async()=>{r.forEach(({menu:i,setStatus:a})=>{a("none"),i.remove()});let s=Lg(scrapbox.Project.name,scrapbox.Page.title??"",xt());for(let i of s){let a=i.lang.toLowerCase();if(kb(a))for(let c of i.startIds){let l=document.getElementById(L${c}),{menu:p,setStatus:u}=Cb(async()=>{await u("loading");try{Mb??=await vb(e,t);let{contents:f}=await Mb(i.path);console.debug("execute:",f),await Function(return (async()=>{${f}})())(),await u("pass")}catch(f){console.error(f),await u("fail",${f})}});r.push({menu:p,setStatus:u}),l?.insertBefore?.(p,l?.firstElementChild)}}await Promise.resolve()},{interval:100,trailing:!0});return await o(),scrapbox.addListener("lines:changed",o),()=>{scrapbox.removeListener("lines:changed",o),r.forEach(({menu:s,setStatus:i})=>{i("none"),s.remove()})}};function M1(e,t){for(var r in t)e[r]=t[r];return e}function Db(e,t){for(var r in e)if(r!=="__source"&&!(r in t))return!0;for(var n in t)if(n!=="__source"&&e[n]!==t[n])return!0;return!1}function oo(e,t){var r=t(),n=X({t:{__:r,u:t}}),o=n[0].t,s=n[1];return Hs(function(){o.__=r,o.u=t,cu(o)&&s({t:o})},[e,r,t]),te(function(){return cu(o)&&s({t:o}),e(function(){cu(o)&&s({t:o})})},[e]),r}function cu(e){var t,r,n=e.u,o=e.__;try{var s=n();return!((t=o)===(r=s)&&(t!==0||1/t==1/r)||t!=t&&r!=r)}catch{return!0}}function Ab(e,t){this.props=e,this.context=t}(Ab.prototype=new qt).isPureReactComponent=!0,Ab.prototype.shouldComponentUpdate=function(e,t){return Db(this.props,e)||Db(this.state,t)};var $b=J.__b;J.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),$b&&$b(e)};var Tae=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;var I1=J.__e;J.__e=function(e,t,r,n){if(e.then){for(var o,s=t;s=s.__;)if((o=s.__c)&&o.__c)return t.__e==null&&(t.__e=r.__e,t.__k=r.__k),o.__c(e,t)}I1(e,t,r,n)};var Fb=J.unmount;function qb(e,t,r){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),e.__c.__H=null),(e=M1({},e)).__c!=null&&(e.__c.__P===r&&(e.__c.__P=t),e.__c=null),e.__k=e.__k&&e.__k.map(function(n){return qb(n,t,r)})),e}function zb(e,t,r){return e&&r&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(n){return zb(n,t,r)}),e.__c&&e.__c.__P===t&&(e.__e&&r.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=r)),e}function lu(){this.__u=0,this.o=null,this.__b=null}function Gb(e){var t=e.__.__c;return t&&t.__a&&t.__a(e)}function pa(){this.i=null,this.l=null}J.unmount=function(e){var t=e.__c;t&&t.__R&&t.__R(),t&&32&e.__u&&(e.type=null),Fb&&Fb(e)},(lu.prototype=new qt).__c=function(e,t){var r=t.__c,n=this;n.o==null&&(n.o=[]),n.o.push(r);var o=Gb(n.__v),s=!1,i=function(){s||(s=!0,r.__R=null,o?o(a):a())};r.__R=i;var a=function(){if(!--n.__u){if(n.state.__a){var c=n.state.__a;n.__v.__k[0]=zb(c,c.__c.__P,c.__c.__O)}var l;for(n.setState({__a:n.__b=null});l=n.o.pop();)l.forceUpdate()}};n.__u++||32&t.__u||n.setState({__a:n.__b=n.__v.__k[0]}),e.then(i,i)},lu.prototype.componentWillUnmount=function(){this.o=[]},lu.prototype.render=function(e,t){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=qb(this.__b,r,n.__O=n.__P)}this.__b=null}var o=t.__a&&ur(Y,null,e.fallback);return o&&(o.__u&=-33),[ur(Y,null,t.__a?null:e.children),o]};var jb=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]}};(pa.prototype=new qt).__a=function(e){var t=this,r=Gb(t.__v),n=t.l.get(e);return n[0]++,function(o){var s=function(){t.props.revealOrder?(n.push(o),jb(t,e,n)):o()};r?r(s):s()}},pa.prototype.render=function(e){this.i=null,this.l=new Map;var t=Sr(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},pa.prototype.componentDidUpdate=pa.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(t,r){jb(e,r,t)})};var D1=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,A1=/^(?: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]/,$1=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,F1=/[A-Z0-9]/g,j1=typeof document<"u",U1=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};qt.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(qt.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:t})}})});var Ub=J.event;function B1(){}function H1(){return this.cancelBubble}function W1(){return this.defaultPrevented}J.event=function(e){return Ub&&(e=Ub(e)),e.persist=B1,e.isPropagationStopped=H1,e.isDefaultPrevented=W1,e.nativeEvent=e};var Kb,q1={enumerable:!1,configurable:!0,get:function(){return this.class}},Bb=J.vnode;J.vnode=function(e){typeof e.type=="string"&&function(t){var r=t.props,n=t.type,o={},s=n.indexOf("-")===-1;for(var i in r){var a=r[i];if(!(i==="value"&&"defaultValue"in r&&a==null||j1&&i==="children"&&n==="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"||n!=="input"&&n!=="textarea"||U1(r.type)?c==="onfocus"?i="onfocusin":c==="onblur"?i="onfocusout":$1.test(i)&&(i=c):c=i="oninput":s&&A1.test(i)?i=i.replace(F1,"-$&").toLowerCase():a===null&&(a=void 0),c==="oninput"&&o[i=c]&&(i="oninputCapture"),o[i]=a}}n=="select"&&o.multiple&&Array.isArray(o.value)&&(o.value=Sr(r.children).forEach(function(l){l.props.selected=o.value.indexOf(l.props.value)!=-1})),n=="select"&&o.defaultValue!=null&&(o.value=Sr(r.children).forEach(function(l){l.props.selected=o.multiple?o.defaultValue.indexOf(l.props.value)!=-1:o.defaultValue==l.props.value})),r.class&&!r.className?(o.class=r.class,Object.defineProperty(o,"className",q1)):(r.className&&!r.class||r.class&&r.className)&&(o.class=o.className=r.className),t.props=o}(e),e.$$typeof=D1,Bb&&Bb(e)};var Hb=J.__r;J.__r=function(e){Hb&&Hb(e),Kb=e.__c};var Wb=J.diffed;J.diffed=function(e){Wb&&Wb(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),Kb=null};var es=e=>e.replaceAll(" ","_").toLowerCase(),Yb=e=>e.replaceAll("_"," "),da=e=>[...e].map((t,r)=>t===" "?"_":!z1.includes(t)||r===e.length-1&&G1.includes(t)?encodeURIComponent(t):t).join(""),z1='@$&+=:;",',G1=':;",';var Vb=({title:e,projects:t,selected:r,confirm:n})=>m("div",{className:candidate${r?" selected":""},children:[m(K1,{title:e,confirm:n}),t.map(o=>m(Y1,{project:o.name,title:e,mark:o.mark,confirm:o.confirm}))]}),K1=({title:e,confirm:t})=>m("a",{className:"button",tabIndex:0,role:"menuitem",href:./${da(e)},onClick:Xb(t),children:e}),Y1=({project:e,title:t,mark:r,confirm:n})=>r===""?m(Y,{}):m("a",{className:"mark",tabIndex:0,href:../${e}/${da(t)},onClick:Xb(n),title:/${e}/${da(t)},children:r instanceof URL?m("img",{src:r.href}):${r}}),Xb=e=>A(t=>{t.metaKey||t.ctrlKey||t.altKey||t.shiftKey||(t.preventDefault(),t.stopPropagation(),e())},[e]);var Jb=(e,t)=>{let[r,n]=X(null),o=A(c=>n(l=>{if(e.length===0)return null;if(l===null)return t(e[0]);let p=e.findIndex(u=>t(u)===l);return t(c?.cyclic?e[(p+1)%e.length]:e.at(p+1)??e[0])}),[e,t]),s=A(c=>n(l=>{if(e.length===0)return null;if(l===null)return t(e[e.length-1]);let p=e.findIndex(u=>t(u)===l);return p<0?t(e[e.length-1]):t(c?.cyclic?e[(p-1+e.length)%e.length]:e.at(p-1)??e[e.length-1])}),[e,t]),i=A(()=>n(e.length===0?null:t(e[0])),[e,t]),a=A(()=>n(e.length===0?null:t(e[e.length-1])),[e,t]);return{selectedId:r,next:o,prev:s,selectFirst:i,selectLast:a}};var Qb=e=>{let[t,r]=X(null),n=N(()=>{let o=t?.getBoundingClientRect?.(),i=Ro(e.line,e.char)?.getBoundingClientRect?.();return!i||!o?{}:{top:${i.bottom-o.top}px,left:${i?.left??0-o.left}px,right:${o.right-(i?.left??0)}px}},[t,e.line,e.char]);return{updateStandardElement:r,...n}};var pu="enableProjectsOnSuggestion",Zb=(e,t)=>{let[r,n]=X(fa([...e],t)),o=A((s,i)=>{V1(s,i,e,t),n(fa([...e],t))},[e,t.enableSelfProjectOnStart]);return te(()=>{let s=i=>{i.key===pu&&n(fa([...e],t))};return addEventListener("storage",s),()=>removeEventListener("storage",s)},[e,t.enableSelfProjectOnStart]),{projects:r,set:o}},uu=!0,fa=(e,t)=>{try{let r=localStorage.getItem(pu);if(r===null)return ma(e),e;let n=JSON.parse(r);return Array.isArray(n)&&n.every(o=>typeof o=="string")?!t.enableSelfProjectOnStart||!e.includes(scrapbox.Project.name)?n:n.includes(scrapbox.Project.name)?uu?n:n.filter(o=>o!==scrapbox.Project.name):uu?[...n,scrapbox.Project.name]:n:(ma(e),e)}catch(r){if(!(r instanceof TypeError))throw r;return ma(e),e}},V1=(e,t,r,n)=>{let o=fa([...r],n);n.enableSelfProjectOnStart&&e===scrapbox.Project.name&&(uu=t),ma(t?[...o,e]:o.filter(s=>s!==e))},ma=e=>localStorage.setItem(pu,JSON.stringify(e));var ex=()=>N(()=>document.documentElement.dataset.os??"",[]);var ts=(e,t)=>{if(e instanceof URL)return e;try{return new URL(e)}catch(r){if(!(r instanceof TypeError))throw r;if(!t||!/^\.\/|^\.\.\/|^\//.test(e))return e;try{return new URL(e,t)}catch(n){if(!(n instanceof TypeError))throw n;return e}}};var tx=({progress:e})=>m("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 nx=({position:e,start:t,enableSelfProjectOnStart:r,projects:n,...o})=>{let{projects:s,set:i}=Zb(n,{enableSelfProjectOnStart:r}),{updateStandardElement:a,top:c,left:l,right:p}=Qb({line:e.line,char:t}),u=ex();return m(Y,{children:[m(J1,{itemCount:o.items.length,enableProjects:s,projects:n,top:c,right:p,set:i,os:u,...o}),m(X1,{updateStandardElement:a,start:t,enableProjects:s,projects:n,top:c,left:l,os:u,...o})]})},X1=({start:e,updateStandardElement:t,confirmAfter:r,cancel:n,query:o,enableProjects:s,projects:i,items:a,top:c,left:l,progress:p,callback:u,limit:f,mark:d,os:h})=>{let g=A((S,T,P)=>{let _=[${T?/${T}/${S}:S}${P?.icon?".icon":""}];r((M,{line:I})=>[${...M.slice(0,e).join("")}${_}${...M.slice(e+...o.length).join("")},{line:I,char:e+[..._].length}])},[e,o]),y=N(()=>i.size>1||!i.has(scrapbox.Project.name),[i]),w=N(()=>{let S=[];for(let T of a){if(S.length===f)break;T.projects.some(P=>s.includes(P))&&S.push({title:T.title,projects:T.projects.flatMap(P=>s.includes(P)?[{name:P,mark:y?ts(d[P]??"",import.meta.url)||P[0]:"",confirm:_=>g(T.title,P,_)}]:[]),confirm:P=>g(T.title,void 0,P)})}return S},[s,y,a,f,d,g]),{selectedId:R,next:E,prev:b,selectLast:k,selectFirst:v}=Jb(w,rx),L=A(S=>R===null?!1:(w.find(T=>rx(T)===R)?.confirm?.(S),!0),[R,w]);te(()=>u(w.length===0?void 0:{selectNext:S=>(E(S),!0),selectPrev:S=>(b(S),!0),selectFirst:()=>(v(),!0),selectLast:()=>(k(),!0),confirm:L,cancel:()=>(n(),!0)}),[u,w.length,E,b,v,k,L]);let C=N(()=>w.length>0&&c!=null&&l!=null?{top:c,left:l}:{display:"none"},[w.length,c,l]),O=A(S=>{if(!S){t(S);return}let T=S.parentNode;if(!(T instanceof ShadowRoot))throw Error('The parent of "div.container" must be ShadowRoot');t(T.host.parentElement)},[t]);return m("div",{ref:O,className:"container candidates","data-os":h,style:C,children:[w.map(S=>m(Vb,{...S,selected:R===S.title},S.title)),a.length>f&&m("div",{className:"counter",children:${a.length-f} more links}),m(tx,{progress:p})]})},J1=({enableProjects:e,projects:t,projectScore:r,mark:n,itemCount:o,top:s,right:i,set:a,os:c,freezeUntil:l})=>{let p=N(()=>[...t].sort((f,d)=>(r.get(d)??0)-(r.get(f)??0)).flatMap(f=>r.has(f)?[{name:f,enable:e.includes(f),mark:ts(n[f]??"",import.meta.url)||f[0],score:r.get(f),onClick:()=>l(()=>{a(f,!e.includes(f)),Xe().focus()})}]:[]),[t,r,e,n]),u=N(()=>o>0&&s!=null&&i!=null&&t.size>1?{top:s,right:i}:{display:"none"},[s,i,o,t.size]);return m("div",{className:"container projects","data-os":c,style:u,children:p.map(f=>m(Q1,{...f},f.name))})},Q1=e=>m("div",{className:e.enable?"mark":"mark disabled","data-score":e.score.toPrecision(3),onClick:e.onClick,title:e.name,children:e.mark instanceof URL?m("img",{src:e.mark.href}):${e.mark}}),rx=e=>e.title;var _t=!1,ox=e=>{_t=typeof e=="boolean"?e:new Set(e)},Bt=e=>Object.fromEntries([...Object.entries(console)].map(([t,r])=>{if(typeof r!="function")return[t,r];switch(t){case"warn":case"error":return[t,(...n)=>r(%c${e},du,...n)];case"log":case"info":case"debug":return[t,(...n)=>{_t!==!0&&(!_t||!_t.has(e))||r(%c${e},du,...n)}];case"assert":return[t,(n,...o)=>{_t!==!0&&(!_t||!_t.has(e))||r(n,%c${e},du,...o)}];case"time":case"timeEnd":return[t,n=>{_t!==!0&&(!_t||!_t.has(e))||r(${e} ${n})}];default:return[t,(...n)=>{if(!(_t!==!0&&(!_t||!_t.has(e))))return r(...n)}]}})),du="color: gray";async function*sx(e){let t=[],r=[],n=new Map,o=[];for(let s of e)s.isValid&&(s.id?s.isMember||t.push(s.id):r.push(s.name),o.push(s.name),n.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 Ns(i);if(K(a)){r=o;break}for(let c of V(a).projects)n.has(c.name)&&(yield ce({...c,checked:n.get(c.name)??0}))}for(let s of r){let i=await lr(s);yield Kr(i)?ce({...V(i),checked:n.get(s)??0}):Ae({...Tr(i),project:s})}}var hu=(e,t)=>t.some(r=>e instanceof r),ix,ax;function Z1(){return ix||(ix=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function eL(){return ax||(ax=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var gu=new WeakMap,fu=new WeakMap,ha=new WeakMap;function tL(e){let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("success",s),e.removeEventListener("error",i)},s=()=>{r(Gr(e.result)),o()},i=()=>{n(e.error),o()};e.addEventListener("success",s),e.addEventListener("error",i)});return ha.set(t,e),t}function rL(e){if(gu.has(e))return;let t=new Promise((r,n)=>{let o=()=>{e.removeEventListener("complete",s),e.removeEventListener("error",i),e.removeEventListener("abort",i)},s=()=>{r(),o()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),o()};e.addEventListener("complete",s),e.addEventListener("error",i),e.addEventListener("abort",i)});gu.set(e,t)}var yu={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return gu.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Gr(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 px(e){yu=e(yu)}function nL(e){return eL().includes(e)?function(...t){return e.apply(bu(this),t),Gr(this.request)}:function(...t){return Gr(e.apply(bu(this),t))}}function oL(e){return typeof e=="function"?nL(e):(e instanceof IDBTransaction&&rL(e),hu(e,Z1())?new Proxy(e,yu):e)}function Gr(e){if(e instanceof IDBRequest)return tL(e);if(fu.has(e))return fu.get(e);let t=oL(e);return t!==e&&(fu.set(e,t),ha.set(t,e)),t}var bu=e=>ha.get(e);function dx(e,t,{blocked:r,upgrade:n,blocking:o,terminated:s}={}){let i=indexedDB.open(e,t),a=Gr(i);return n&&i.addEventListener("upgradeneeded",c=>{n(Gr(i.result),c.oldVersion,c.newVersion,Gr(i.transaction),c)}),r&&i.addEventListener("blocked",c=>r(c.oldVersion,c.newVersion,c)),a.then(c=>{s&&c.addEventListener("close",()=>s()),o&&c.addEventListener("versionchange",l=>o(l.oldVersion,l.newVersion,l))}).catch(()=>{}),a}function fx(e,{blocked:t}={}){let r=indexedDB.deleteDatabase(e);return t&&r.addEventListener("blocked",n=>t(n.oldVersion,n)),Gr(r).then(()=>{})}var sL=["get","getKey","getAll","getAllKeys","count"],iL=["put","add","delete","clear"],mu=new Map;function cx(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(mu.get(t))return mu.get(t);let r=t.replace(/FromIndex$/,""),n=t!==r,o=iL.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||sL.includes(r)))return;let s=async function(i,...a){let c=this.transaction(i,o?"readwrite":"readonly"),l=c.store;return n&&(l=l.index(a.shift())),(await Promise.all([l[r](...a),o&&c.done]))[0]};return mu.set(t,s),s}px(e=>({...e,get:(t,r,n)=>cx(t,r)||e.get(t,r,n),has:(t,r)=>!!cx(t,r)||e.has(t,r)}));var aL=["continue","continuePrimaryKey","advance"],lx={},xu=new WeakMap,mx=new WeakMap,cL={get(e,t){if(!aL.includes(t))return e[t];let r=lx[t];return r||(r=lx[t]=function(...n){xu.set(this,mx.get(this)[t](...n))}),r}};async function*lL(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;let r=new Proxy(t,cL);for(mx.set(r,t),ha.set(r,bu(t));t;)yield r,t=await(xu.get(r)||t.continue()),xu.delete(r)}function ux(e,t){return t===Symbol.asyncIterator&&hu(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&hu(e,[IDBIndex,IDBObjectStore])}px(e=>({...e,get(t,r,n){return ux(t,r)?lL:e.get(t,r,n)},has(t,r){return ux(t,r)||e.has(t,r)}}));var ga=Bt("scrapbox-storage:db.ts"),hx,wu=async()=>(hx??=await dx("scrapbox-storage",4,{upgrade(e){ga.time("update DB");for(let n of e.objectStoreNames)e.deleteObjectStore(n);e.createObjectStore("titles",{keyPath:"id"}).createIndex("project","project");let r=e.createObjectStore("projects",{keyPath:"id"});r.createIndex("checked","checked"),r.createIndex("name","name"),ga.timeEnd("update DB")},blocked(e,t){let r=The database "@takker/cosense-storage"(v${t}) is blocked because the older one (v${e}) is opened in other tabs. Please close the other tabs and reload this page.;ga.error(r),alert(r)},blocking(e,t){let r=The database "@takker/cosense-storage"(v${e}) is blocking the newer one (v${t}) opened.
Please close this page.;ga.error(r),alert(r)}}),hx);var ba=(e,t)=>(vu||(vu=new BroadcastChannel(yx),vu.addEventListener("message",r=>gx(r.data))),ya.set(t,new Set(e).union(ya.get(t)??new Set)),()=>ya.delete(t)),ku=(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};gx(r);let n=new BroadcastChannel(yx);n.postMessage(r),n.close()},gx=e=>{for(let[t,r]of ya)r.has(e.project)&&t(e)},yx="scrapbox-storage-notify",vu,ya=new Map;var uL=Math.pow(10,8)*24*60*60*1e3,Lce=-uL,pL=3600,xx=pL*24,Cce=xx*7,dL=xx*365.2425,fL=dL/12,Oce=fL*3,bx=Symbol.for("constructDateFrom");function mL(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&bx in e?e[bx](t):e instanceof Date?new e.constructor(t):new Date(t)}function hL(e,t){return mL(t||e,e)}function Eu(e){return Math.trunc(+hL(e)/1e3)}var Lt=Bt("scrapbox-storage:mod.ts"),xa=async(e,t)=>{let r=await wu(),n=new Map;try{{Lt.debug("check updates of links...");let s=new Set,i=r.transaction("projects","readwrite"),a=Eu(new Date),c=a-600;for await(let u of i.store.index("checked").iterate(IDBKeyRange.lowerBound(c,!0))){let f=u.value;if(f.isValid===!1){s.add(f.id);continue}s.add(f.name);let d=f.checked;if(d+t>a||f?.updating&&d>c)continue;let h=structuredClone(f);h.updating=!0,n.set(f.id,h),u.update(h)}let l=[],p=i.store.index("name");for(let u of e)s.has(u)||l.push(p.get(u).then(f=>{n.set(u,f??gL(u))}));if(await Promise.all(l),await i.done,n.size===0){Lt.debug("checked. No project needs upgrade.");return}Lt.debug(checked. ${n.size} projects maybe need upgrade.)}let o=Eu(new Date);for await(let s of sx(n.values())){if(K(s)){let{project:h,name:g}=Tr(s);switch(g){default:continue;case"NotFoundError":Lt.warn("${h}" is not found.);break;case"NotMemberError":Lt.warn(You are not a member of "${h}".);break;case"NotLoggedInError":Lt.warn(You are not a member of "${h}" or You are not logged in yet.);break}n.set(h,{id:h,name:h,checked:o,updating:!1,isValid:!1,reason:g});continue}let{checked:i,...a}=V(s);if(a.updated<i){Lt.debug(no updates in "${a.name}"),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1});continue}let c=download and store links of "${a.name}";Lt.time(c);let l=new Set(await r.getAllKeysFromIndex("titles","project",a.name)),p=0,u=0;for await(let h of Kd(a.name)){if(K(h)){let{name:R,message:E}=Tr(h);Lt.error(Failed to get links of "${a.name}" with ${R}: ${E});break}let g=V(h),y={},w=r.transaction("titles","readwrite");await Promise.all(g.map(async R=>{let E={...R,project:a.name};if(!l.has(R.id))return y.added?.set?.(R.id,E)??(y.added=new Map([[R.id,E]])),w.store.add(E);l.delete(R.id);let b=await w.store.get(R.id);if(!b)return y.added?.set?.(R.id,E)??(y.added=new Map([[R.id,E]])),w.store.add(E);if(!(b.updated>=E.updated))return y.updated?.set?.(R.id,[b,E])??(y.updated=new Map([[R.id,[b,E]]])),w.store.put(E)})),await w.done,p+=y.added?.size??0,u+=y.updated?.size??0,Lt.debug(Updating "/${a.name}": +${p} pages, ~${u} pages),ku(a.name,y)}let f=r.transaction("titles","readwrite"),d=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,Lt.timeEnd(c),Lt.debug(Update "/${a.name}": +${p} pages, ~${u} pages, -${d.size} pages),n.set(a.name,{...a,isValid:!0,checked:o,updating:!1}),ku(a.name,{deleted:d})}}finally{let o=r.transaction("projects","readwrite");await Promise.all([...n].map(([,s])=>(s.updating=!1,o.store.put({...s})))),await o.done}},so=async e=>{let t=[...new Set(e)];if(t.length===0)return[];let r=Date.now(),o=(await wu()).transaction("titles","readonly"),s=o.store.index("project"),i=(await Promise.all(t.map(a=>s.getAll(a)))).flat();return await o.done,Lt.debug(Read ${i.length} links from ${t.length} projects in ${Date.now()-r}ms),i},gL=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});fx("userscript-links").catch(e=>console.error(e));var yL=Bt("scrapbox-select-suggestion:useSource.ts"),vx=e=>oo(...N(()=>{let t=[];return[o=>{let s=so(e).then(i=>{let a=bL(i);return t=[...a.values()],o(),a});return xa(e,600),ba(e,({diff:i})=>s=s.then(a=>(yL.debug(Update: +${i.added?.size??0} pages, ~${i.updated?.size??0} pages, -${i.deleted?.size??0} pages),a=xL(a,i),t=[...a.values()],o(),a)))},()=>t]},[e])),bL=e=>{let t=new Map;for(let r of e)Tu(t,r);return t},xL=(e,t)=>{let r=new Map(e);if(t.added)for(let[,n]of t.added)Tu(r,n);if(t.updated)for(let[,[n,o]]of t.updated)wx(r,n),Tu(r,o);if(t.deleted)for(let[,n]of t.deleted)wx(r,n);return r},Tu=(e,t)=>{let r=es(t.title),n=e.get(r);if((n?.updated??0)>t.updated)return;let o=n?.metadata??new Map;o.set(t.project,{image:t.image}),e.set(r,{title:t.title,titleLc:r,updated:t.updated,linked:n?.linked??0,metadata:o});for(let s of t.links){let i=es(s),a=e.get(i),c=a?.metadata??new Map;c.set(t.project,c.get(t.project)??{image:t.image}),e.set(i,{title:a?.title??s,titleLc:i,updated:a?.updated??0,linked:(a?.linked??0)+1,metadata:c})}},wx=(e,t)=>{let r=es(t.title),n=e.get(r);if(!n||(n.updated??0)>t.updated)return;let o=n.metadata;o.delete(t.project),o.size<=0?e.delete(r):e.set(r,{title:n.title,titleLc:r,updated:t.updated,linked:n.linked,metadata:o});for(let s of t.links){let i=es(s),a=e.get(i);if(!a)continue;let c=a.metadata;c.delete(t.project),c.size<=0?e.delete(i):e.set(i,{title:a.title,titleLc:i,updated:t.updated,linked:a.linked-1,metadata:c})}};var kx=e=>{let t=N(()=>ts(e.style,import.meta.url),[e.style]);return m(Y,{children:t!==""&&(t instanceof URL?m("link",{rel:"stylesheet",href:t.href}):m("style",{children:t}))})};var Ex=()=>m("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;
}
font-size:11px;
}
.projects {
margin-right: 4px;
display: grid;
grid-template-rows: repeat(4, min-content);
grid-auto-flow: column;
direction: rtl;
}
padding: 6px;
}
.candidates > :not(:first-child) {
border-top: 1px solid var(--select-suggest-border-color, #eee); }
.candidates > *{
line-height: 1.2em;
padding: 0.5em 10px;
}
.candidate {
display: flex;
}
a {
display: block;
text-decoration: none;
color: inherit;
}
a:not(.mark) {
width: 100%;
}
.selected a {
background-color: var(--select-suggest-selected-bg, #222); text-decoration: underline
}
img {
height: 1.3em;
width: 1.3em;
position: relative;
object-fit: cover;
object-position: 0% 0%;
}
.disabled {
filter: grayscale(1.0) opacity(0.5);
}
.counter {
color: var(--select-suggest-information-text-color, #aaa); font-size: 80%;
font-style: italic;
}
padding: unset;
border: unset;
height: 0.5px;
transition: background 0.1s;
}});function*Tx(e){if(!("nodes"in e))return;let t=0;function*r(n){for(let o of Array.isArray(n)?n:[n]){if(typeof o=="string"){t+=[...o].length;continue}switch(o.type){case"link":yield{whole:o.unit.whole,start:t},t+=[...o.unit.whole].length;break;case"indent":case"quote":t+=[...o.unit.tag].length,yield*r(o.children);break;case"deco":t+=[...o.unit.deco].length+2,yield*r(o.children),t++;break;case"strong":t+=2,yield*r(o.children),t+=2;break;default:t+=[...o.unit.whole].length;break}}}yield*r(e.nodes)}var Px=(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),n=Math.max(t.range.start.char,t.range.end.char),o=t.lines?t.range.start.line!==t.range.end.line?
:[...t.lines[t.range.start.line].text].slice(r,n).join(""):"";if(vL(t.lines[t.position.line],o)&&e.type!=="cancelled")return{type:"completion",context:"selection",query:o,start:r,position:t.position};if(o!=="")return e.type==="completion"?{type:"ready"}:e;let s=wL(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"}},wL=(e,t)=>{for(let{whole:r,start:n}of Tx(e))if(!(t<=n||n+[...r].length<=t))return{whole:r,start:n}},vL=(e,t)=>!(t.trim()===""||t.includes(
)||"codeBlock"in e||"title"in e||"tableBlock"in e&&e.tableBlock.start);var Rx=()=>{let e=Ye(scrapbox.Page.lines),t=Ye(!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)}},[]),A(()=>(t.current&&(e.current=scrapbox.Page.lines,t.current=!1),e.current??void 0),[])};var kL=Bt("scrapbox-select-suggestion:useLifecycle.ts"),Sx=()=>{let[e,t]=_r(Px,{type:"ready"}),r=Rx(),n=N(()=>{let i;return a=>{i!==void 0&&clearTimeout(i),i=setTimeout(()=>{let{cursor:c,selection:l}=Pt();t({type:a,lines:r(),range:l.getRange({normalizeOrder:!0}),position:c.getPosition()})},a==="cursor:changed"?100:void 0)}},[]);te(()=>{let i=()=>{n("lines:changed")};scrapbox.addListener("lines:changed",i),scrapbox.addListener("layout:changed",i);let a=()=>{n("selection:changed")},c=ri();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=()=>{n("cursor:changed")},a=Lr();return a.addChangeListener(i),()=>a.removeChangeListener(i)},[e.context]);let[o,s]=X(e);return o!==e&&(s(e),kL.debug("Detect changes",e)),{state:e,setEnable:A(i=>t({type:i?"enable":"disable"}),[]),cancel:A(()=>t({type:"cancel"}),[]),freezeUntil:A(i=>{t({type:"lock"});let a=i();if(a instanceof Promise)return a.then(()=>{t({type:"unlock"})});t({type:"unlock"})},[]),confirmAfter:A(async i=>{let a=r();if(!a)return;t({type:"lock"});let{cursor:c,selection:l}=Pt(),p=c.getPosition().line,u=a[p].text,[f,d]=i(u,c.getPosition());l.setRange({start:{line:p,char:0},end:{line:p,char:[...u].length}}),await Qe(f),c.setPosition(d),c.focus(),t({type:"unlock"}),t({type:"cancel"})},[])}};var _x=(e,t)=>{let r=e.dist-t.dist;if(r!==0)return r;let n=e.matches.map(([i])=>i).sort(),o=t.matches.map(([i])=>i).sort();for(let i=0;i<n.length;i++){let a=n[i]-(o[i]??o.length);if(a!==0)return a}let s=e.title.length-t.title.length;return s!==0?s:t.updated-e.updated};var Lx=e=>{let t=new Map,r=[...e].reverse();{let i=1;for(let a of r){t.set(a,(t.get(a)??0)|i);let c=a.toLowerCase();t.set(c,(t.get(c)??0)|i);let l=a.toUpperCase();t.set(l,(t.get(l)??0)|i),i<<=1}}let n=r.length,o=~(-1<<n),s=1<<n-1;return i=>{let a=0,c=o,l=[...i].reverse(),p=[],u=l.length;p[u]=n;for(let f of l){let d=t.get(f)??0,h=d|a,g=(d&c)+c^c|d,y=a|~(g|c),w=c&g;p[u-1]=p[u]+(y&s?1:w&s?-1:0),c=w<<1|~(h|y<<1),a=y<<1&h,u--}return p}};var EL=[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],Cx=e=>{let t=Yb(e.trim()).split(/\s+/).sort((r,n)=>n.length-r.length);if(!(t.length===0||t.every(r=>r==="")))return r=>{let n=[...r];for(let o of t)n=TL(o,n);return n}},TL=(e,t)=>{let r=[...e].length,n=EL[r],o=Lx(e);return t.flatMap(({title:s,dist:i,matches:a,...c})=>{a??=[],i??=0;let l=o(s).flatMap((u,f)=>u<=n&&a.every(([d,h])=>f+r<=d||h<f)?[[f,u]]:[]);if(l.length===0)return[];let p=l.reduce((u,[f,d])=>(u.dist<=d||(u.dist=d,u.start=f),u),{dist:r,start:0});return a.push([p.start,p.start+r-1]),[{title:s,dist:p.dist+i,matches:a,...c}]})};var PL=Bt("scrapbox-select-suggestion:cancelableSearch.ts");async function*Ox(e,t,r){let n=Cx(e);if(!n)return;let o=r?.chunk??1e3,s=Math.floor(t.length/o)+1,i=0,a=new Date;try{for(;i<s;i++)await new Promise(c=>requestAnimationFrame(c)),yield[n(t.slice(i*o,(i+1)*o)),(i+1)/s]}finally{let l=new Date().getTime()-a.getTime();PL.debug(search ${(i/s*100).toPrecision(3)}% of the source for "${e}" in ${l}ms)}}var Nx=(e,t)=>{let r=t?.interval??0,n=t?.maxQueued??1/0,o,s=[],i=(...a)=>{if(!o)return o=(async()=>{do{await new Promise(f=>setTimeout(f,r));let u=s.pop();if(!u)break;u("delayed")}while(s.length>0);o=void 0})(),new Promise(u=>u(e.call(i,...a,"immediate")));for(;s.length>Math.max(n,0);)s.shift()("discarded");let{promise:c,resolve:l,reject:p}=Promise.withResolvers();return s.push(u=>{try{l(e.call(i,...a,u))}catch(f){p(f)}}),c};return Object.defineProperty(i,"ready",{get:()=>o}),i};var Sn=e=>"query"in e,Mx=e=>(t,r)=>{if("query"in r){let i=Sn(t)?t.query:"";if(r.query===i)return t;let a=Sn(t)?t.job:void 0;if(!r.query)return a?.abort?.(),{source:t.source};let{run:c,abort:l}=e(r.query,t.source,!1),p=a?.abort?.()?.then?.(c)??c();return{query:r.query,source:t.source,job:{done:p,abort:()=>(l(),p)},progress:0,candidates:!i||!Sn(t)?[]:t.candidates}}if("source"in r){if(!Sn(t))return r.source===t.source?t:r;let{source:i,job:a,...c}=t;if(r.source===i)return t;let{run:l,abort:p}=e(c.query,r.source,!0),u=a.done.then(l);return{source:r.source,job:{done:u,abort:()=>a.abort().then(()=>(p(),u))},...c}}if(!Sn(t))return t;if(!r.candidates){let{progress:i,...a}=t;return i===r.progress?t:{progress:r.progress,...a}}let{candidates:n,progress:o,...s}=t;return n===r.candidates&&o===r.progress?t:{candidates:r.candidates??n,progress:r.progress,...s}};var RL=Bt("scrapbox-select-suggestion:useSearch.ts"),Ix=e=>{let t=A((o,s,i)=>{let a=!1,c=Ox(o,s,{chunk:5e3});return{run:async()=>{if(i){let u=[];for await(let[f]of c){if(a)return;u.push(...f)}n({progress:1,candidates:u});return}let l=Nx((u,f)=>{f!=="discarded"&&(a||n(u))},{interval:500,maxQueued:0}),p=[];for await(let[u,f]of c){if(a)return;p=[...p,...u],n({progress:f}),u.length!==0&&l({progress:f,candidates:p})}l({progress:1,candidates:p})},abort:()=>a=!0}},[]),[r,n]=_r(N(()=>Mx(t),[t]),{source:e});return[N(()=>{if(!Sn(r))return;let[o,s]=SL(r.candidates);return RL.debug("Detect changes",{progress:r.progress,items:s}),{progress:r.progress,projectScore:o,items:s}},[r]),{search:A(o=>n({query:o}),[]),update:A(o=>n({source:o}),[])}]},SL=e=>{let t=new Map,r=[];for(let n of e.sort(_x)){let o=[...n.metadata.keys()];for(let s of o)t.set(s,(t.get(s)??0)+.5**n.dist);r.push({title:n.title,dist:n.dist,projects:o})}return[t,r]};var Dx=(e,t)=>{let r=Ye({...t});te(()=>(Object.assign(r.current,t),()=>{for(let n of Object.keys(t))delete r.current[n]}),[...Object.keys(t)].sort().map(n=>t[n])),te(()=>{e(r.current)},[e])};var _L={selectNext:()=>!1,selectPrev:()=>!1,selectFirst:()=>!1,selectLast:()=>!1,confirm:()=>!1,cancel:()=>!1},Ax=e=>{let t=vx(e.projects),[r,{update:n,search:o}]=Ix(t),{state:s,setEnable:i,...a}=Sx();n(t),o(s.type==="completion"?s.context==="input"?s.query.slice(1,-1):s.query:"");let[c,l]=X(),{callback:p,style:u,...f}=e;return Dx(p,{enable:A(()=>i(!0),[]),disable:A(()=>i(!1),[]),...s.type!=="completion"||!c?_L:c}),m(Y,{children:[m(Ex,{}),m(kx,{style:u}),s.type==="completion"&&r&&m(nx,{callback:l,...r,...s,...a,...f})]})};var $x=e=>{let t=document.createElement("div");t.dataset.userscriptName="scrapbox-select-suggestion";let r=t.attachShadow({mode:"open"});document.body.append(t);let{limit:n=5,debug:o=!1,mark:s={},style:i="",enableSelfProjectOnStart:a=!0}=e??{},c=new Set([...a?[scrapbox.Project.name]:[],...e?.projects??[scrapbox.Project.name]]);return ox(o),new Promise(l=>ut(m(Ax,{limit:n,projects:c,mark:s,style:i,callback:l,enableSelfProjectOnStart:a}),r))};var Ct=e=>e.flatMap(t=>{let r=t.slice(1),n=Math.min(...r.map(o=>o.text.length-o.text.trimStart().length));return r.map(o=>o.text.slice(n))}).join(
).trim();function*Fx(e,t){for(let[r,n]of t.entries()){let o=e.get(r);if(o&&Ct(o.blocks)===Ct(n)){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 io={};On(io,{getTitle:()=>Fd,parse:()=>Be});var jx=e=>{let t=new Map;if(e.length===0)return t;let r=Be(e.map(o=>o.text).join(
),{hasTitle:!0}),n=0;for(let o of r)switch(o.type){case"title":case"line":n++;break;case"table":n+=o.cells.length+1;break;case"codeBlock":{let s=t.get(o.fileName)??[],i=o.content.split(
).length+1;s.push(e.slice(n,n+i)),t.set(o.fileName,s),n+=i;break}}return t};var Ux=e=>{let t,r,n=async()=>{for(;t;){let[o,s]=t;t=void 0;try{let i=await e(...o);s({type:"resolve",value:i})}catch(i){s({type:"reject",value:i})}}r=void 0};return(...o)=>{let{resolve:s,promise:i}=Promise.withResolvers();return t?.[1]?.({type:"cancel"}),t=[o,s],r??=n(),i}};var wa=class{constructor(t,r){this._filename=t;this._preview=Ux(async(n,o,s)=>(this._dispose=await r(s?{filename:this.filename,before:n,after:o,render:(...i)=>{s.textContent="",s.append(...i)}}:{filename:this.filename,before:n}),!1))}get filename(){return this._filename}get blocks(){return this._blocks??[]}async update(t){if(await this._dispose?.(),!t||Ct(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 n=this.makeArea(),o=t.at(0)?.at?.(-1)?.id,s=Zr(o);if(!s)throw new Error("div.lines#L${o}" could not be found.);s.insertAdjacentElement("afterend",n);let i=()=>{let a=s.getElementsByClassName("indent")[0];a instanceof HTMLElement&&(n.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,n)}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(n=>n.slice(1).map(({id:o})=>#L${o})),r=this.blocks.flatMap(n=>n.map(({id:o})=>#L${o}));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 Bx=({previewers:e})=>{let t=new Map,r=()=>{let s=jx(xt());for(let{changed:i,filename:a}of Fx(t,s)){if(!i)continue;let c=s.get(a),l=t.get(a);if(!l){if(!c)continue;let p=e.find(({when:u})=>u.test(a))?.preview;if(!p)continue;l=new wa(a,p),t.set(a,l)}l.update(c).then(p=>{switch(p.type){case"resolve":p.value&&t.delete(a);return;case"reject":throw p.value;case"cancel":return}})}},n=()=>{if(scrapbox.Layout!=="page"){scrapbox.off("lines:changed",r);return}r(),scrapbox.on("lines:changed",r)};n(),scrapbox.on("page:changed",n);let o=document.createElement("style");return o.textContent=".scrap-run{display:block;width:95%}",document.head.append(o),()=>{scrapbox.off("page:changed",n),o.remove()}};var rs=e=>{let t=new FileReader,r=new Promise(n=>t.onload=()=>n(t.result));return t.readAsDataURL(e),r};var Hx=async e=>{if(!("after"in e))return;let t=Ct(e.after),n=new DOMParser().parseFromString(t,"image/svg+xml").querySelector("parsererror");if(n){let i=document.createElement("pre"),a=document.createElement("code");a.innerText=n.innerHTML,i.append(a),e.render(i);return}let o=await rs(new Blob([t],{type:"image/svg+xml"})),s=document.createElement("img");s.src=o,e.render(s)};var Su={};On(Su,{default:()=>Yx});var Wx=globalThis||(typeof window<"u"?window:self),oC=Object.create,Ru=Object.defineProperty,sC=Object.getOwnPropertyDescriptor,iC=Object.getOwnPropertyNames,aC=Object.getPrototypeOf,cC=Object.prototype.hasOwnProperty,lC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),uC=(e,t)=>{for(var r in t)Ru(e,r,{get:t[r],enumerable:!0})},Pu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of iC(t))!cC.call(e,o)&&o!==r&&Ru(e,o,{get:()=>t[o],enumerable:!(n=sC(t,o))||n.enumerable});return e},pC=(e,t,r)=>(Pu(e,t,"default"),r&&Pu(r,t,"default")),zx=(e,t,r)=>(r=e!=null?oC(aC(e)):{},Pu(t||!e||!e.__esModule?Ru(r,"default",{value:e,enumerable:!0}):r,e)),Gx=lC((e,t)=>{var r;typeof window<"u"?r=window:typeof Wx<"u"?r=Wx:typeof self<"u"?r=self:r={},t.exports=r}),Kx={};uC(Kx,{default:()=>Yx});var dC=zx(Gx());pC(Kx,zx(Gx()));var{default:qx,...fC}=dC,Yx=qx!==void 0?qx:fC;var Cu={};On(Cu,{default:()=>Zx});var mC=Object.create,Lu=Object.defineProperty,hC=Object.getOwnPropertyDescriptor,gC=Object.getOwnPropertyNames,yC=Object.getPrototypeOf,bC=Object.prototype.hasOwnProperty,xC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),wC=(e,t)=>{for(var r in t)Lu(e,r,{get:t[r],enumerable:!0})},_u=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of gC(t))!bC.call(e,o)&&o!==r&&Lu(e,o,{get:()=>t[o],enumerable:!(n=hC(t,o))||n.enumerable});return e},vC=(e,t,r)=>(_u(e,t,"default"),r&&_u(r,t,"default")),Xx=(e,t,r)=>(r=e!=null?mC(yC(e)):{},_u(t||!e||!e.__esModule?Lu(r,"default",{value:e,enumerable:!0}):r,e)),Jx=xC((e,t)=>{t.exports=n;var r=Object.prototype.toString;function n(o){if(!o)return!1;var s=r.call(o);return s==="[object Function]"||typeof o=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(o===window.setTimeout||o===window.alert||o===window.confirm||o===window.prompt)}}),Qx={};wC(Qx,{default:()=>Zx});var kC=Xx(Jx());vC(Qx,Xx(Jx()));var{default:Vx,...EC}=kC,Zx=Vx!==void 0?Vx:EC;var Mu={};On(Mu,{default:()=>ow});var TC=Object.create,Nu=Object.defineProperty,PC=Object.getOwnPropertyDescriptor,RC=Object.getOwnPropertyNames,SC=Object.getPrototypeOf,_C=Object.prototype.hasOwnProperty,LC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),CC=(e,t)=>{for(var r in t)Nu(e,r,{get:t[r],enumerable:!0})},Ou=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of RC(t))!_C.call(e,o)&&o!==r&&Nu(e,o,{get:()=>t[o],enumerable:!(n=PC(t,o))||n.enumerable});return e},OC=(e,t,r)=>(Ou(e,t,"default"),r&&Ou(r,t,"default")),tw=(e,t,r)=>(r=e!=null?TC(SC(e)):{},Ou(t||!e||!e.__esModule?Nu(r,"default",{value:e,enumerable:!0}):r,e)),rw=LC((e,t)=>{var r=function(o){return o.replace(/^\s+|\s+$/g,"")},n=function(o){return Object.prototype.toString.call(o)==="[object Array]"};t.exports=function(o){if(!o)return{};for(var s={},i=r(o).split( ),a=0;a<i.length;a++){var c=i[a],l=c.indexOf(":"),p=r(c.slice(0,l)).toLowerCase(),u=r(c.slice(l+1));typeof s[p]>"u"?s[p]=u:n(s[p])?s[p].push(u):s[p]=[s[p],u]}return s}}),nw={};CC(nw,{default:()=>ow});var NC=tw(rw());OC(nw,tw(rw()));var{default:ew,...MC}=NC,ow=ew!==void 0?ew:MC;var Au={};On(Au,{default:()=>lw});var IC=Object.create,Du=Object.defineProperty,DC=Object.getOwnPropertyDescriptor,AC=Object.getOwnPropertyNames,$C=Object.getPrototypeOf,FC=Object.prototype.hasOwnProperty,jC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),UC=(e,t)=>{for(var r in t)Du(e,r,{get:t[r],enumerable:!0})},Iu=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of AC(t))!FC.call(e,o)&&o!==r&&Du(e,o,{get:()=>t[o],enumerable:!(n=DC(t,o))||n.enumerable});return e},BC=(e,t,r)=>(Iu(e,t,"default"),r&&Iu(r,t,"default")),iw=(e,t,r)=>(r=e!=null?IC($C(e)):{},Iu(t||!e||!e.__esModule?Du(r,"default",{value:e,enumerable:!0}):r,e)),aw=jC((e,t)=>{t.exports=n;var r=Object.prototype.hasOwnProperty;function n(){for(var o={},s=0;s<arguments.length;s++){var i=arguments[s];for(var a in i)r.call(i,a)&&(o[a]=i[a])}return o}}),cw={};UC(cw,{default:()=>lw});var HC=iw(aw());BC(cw,iw(aw()));var{default:sw,...WC}=HC,lw=sw!==void 0?sw:WC;var ao=e=>{let t=n=>typeof n.default<"u"?n.default:n,r=n=>Object.assign({},n);switch(e){case"global/window":return t(Su);case"is-function":return t(Cu);case"parse-headers":return t(Mu);case"xtend":return t(Au);default:throw new Error('module "'+e+'" not found')}},qC=Object.create,Fu=Object.defineProperty,zC=Object.getOwnPropertyDescriptor,GC=Object.getOwnPropertyNames,KC=Object.getPrototypeOf,YC=Object.prototype.hasOwnProperty,va=(e=>typeof ao<"u"?ao:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof ao<"u"?ao:t)[r]}):e)(function(e){if(typeof ao<"u")return ao.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),VC=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),XC=(e,t)=>{for(var r in t)Fu(e,r,{get:t[r],enumerable:!0})},$u=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of GC(t))!YC.call(e,o)&&o!==r&&Fu(e,o,{get:()=>t[o],enumerable:!(n=zC(t,o))||n.enumerable});return e},JC=(e,t,r)=>($u(e,t,"default"),r&&$u(r,t,"default")),pw=(e,t,r)=>(r=e!=null?qC(KC(e)):{},$u(t||!e||!e.__esModule?Fu(r,"default",{value:e,enumerable:!0}):r,e)),dw=VC((e,t)=>{"use strict";var r=va("global/window"),n=va("is-function"),o=va("parse-headers"),s=va("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(d){l[d==="delete"?"del":d]=function(h,g,y){return g=c(h,g,y),g.method=d.toUpperCase(),p(g)}});function i(d,h){for(var g=0;g<d.length;g++)h(d[g])}function a(d){for(var h in d)if(d.hasOwnProperty(h))return!1;return!0}function c(d,h,g){var y=d;return n(h)?(g=h,typeof d=="string"&&(y={uri:d})):y=s(h,{uri:d}),y.callback=g,y}function l(d,h,g){return h=c(d,h,g),p(h)}function p(d){if(typeof d.callback>"u")throw new Error("callback argument missing");var h=!1,g=function(I,F,D){h||(h=!0,d.callback(I,F,D))};function y(){b.readyState===4&&setTimeout(E,0)}function w(){var I=void 0;if(b.response?I=b.response:I=b.responseText||u(b),P)try{I=JSON.parse(I)}catch{}return I}function R(I){return clearTimeout(_),I instanceof Error||(I=new Error(""+(I||"Unknown XMLHttpRequest Error"))),I.statusCode=0,g(I,M)}function E(){if(!v){var I;clearTimeout(_),d.useXDR&&b.status===void 0?I=200:I=b.status===1223?204:b.status;var F=M,D=null;return I!==0?(F={body:w(),statusCode:I,method:C,headers:{},url:L,rawRequest:b},b.getAllResponseHeaders&&(F.headers=o(b.getAllResponseHeaders()))):D=new Error("Internal XMLHttpRequest Error"),g(D,F,F.body)}}var b=d.xhr||null;b||(d.cors||d.useXDR?b=new l.XDomainRequest:b=new l.XMLHttpRequest);var k,v,L=b.url=d.uri||d.url,C=b.method=d.method||"GET",O=d.body||d.data,S=b.headers=d.headers||{},T=!!d.sync,P=!1,_,M={body:void 0,headers:{},statusCode:0,method:C,url:L,rawRequest:b};if("json"in d&&d.json!==!1&&(P=!0,S.accept||S.Accept||(S.Accept="application/json"),C!=="GET"&&C!=="HEAD"&&(S["content-type"]||S["Content-Type"]||(S["Content-Type"]="application/json"),O=JSON.stringify(d.json===!0?O:d.json))),b.onreadystatechange=y,b.onload=E,b.onerror=R,b.onprogress=function(){},b.onabort=function(){v=!0},b.ontimeout=R,b.open(C,L,!T,d.username,d.password),T||(b.withCredentials=!!d.withCredentials),!T&&d.timeout>0&&(_=setTimeout(function(){if(!v){v=!0,b.abort("timeout");var I=new Error("XMLHttpRequest timeout");I.code="ETIMEDOUT",R(I)}},d.timeout)),b.setRequestHeader)for(k in S)S.hasOwnProperty(k)&&b.setRequestHeader(k,S[k]);else if(d.headers&&!a(d.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in d&&(b.responseType=d.responseType),"beforeSend"in d&&typeof d.beforeSend=="function"&&d.beforeSend(b),b.send(O||null),b}function u(d){try{if(d.responseType==="document")return d.responseXML;var h=d.responseXML&&d.responseXML.documentElement.nodeName==="parsererror";if(d.responseType===""&&!h)return d.responseXML}catch{}return null}function f(){}}),fw={};XC(fw,{default:()=>ka});var QC=pw(dw());JC(fw,pw(dw()));var{default:uw,...ZC}=QC,ka=uw!==void 0?uw:ZC;var Ea=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},fde=function(){function e(r){this.value=r}function t(r){var n,o;function s(c,l){return new Promise(function(p,u){var f={key:c,arg:l,resolve:p,reject:u,next:null};o?o=o.next=f:(n=o=f,i(c,l))})}function i(c,l){try{var p=r[c](l),u=p.value;u instanceof e?Promise.resolve(u.value).then(function(f){i("next",f)},function(f){i("throw",f)}):a(p.done?"return":"normal",p.value)}catch(f){a("throw",f)}}function a(c,l){switch(c){case"return":n.resolve({value:l,done:!0});break;case"throw":n.reject(l);break;default:n.resolve({value:l,done:!1});break}n=n.next,n?i(n.key,n.arg):o=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)}}}(),gw=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},yw=function(){function e(t,r){for(var n=0;n<r.length;n++){var o=r[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),ju=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)},ns="";function eO(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 tO=
This page requires a browser that supports WebGL.<br/>
,rO=
It does not appear your computer can support WebGL.<br/>
,nO=1,oO=2;function sO(e,t,r){function n(i){var a=e.parentNode;a&&(a.innerHTML=eO(i))}function o(i,a){typeof r=="function"?r(i):n(a)}if(!window.WebGLRenderingContext)return o(nO,tO),null;var s=iO(e,t);return s?s.getExtension("OES_standard_derivatives"):o(oO,rO),s}function iO(e,t){for(var r=["webgl","experimental-webgl"],n=null,o=0;o<r.length;++o)try{n=e.getContext(r[o],t)}catch{if(n)break}return n}function co(e,t,r,n){var o=e.gl,s=o.createShader(r);o.shaderSource(s,t),o.compileShader(s);var i=o.getShaderParameter(s,o.COMPILE_STATUS);return i?s:(ns=o.getShaderInfoLog(s),console.error("*** Error compiling shader "+s+":"+ns),e.trigger("error",{shader:s,source:t,type:r,error:ns,offset:n||0}),o.deleteShader(s),null)}function mw(e,t,r,n){for(var o=e.gl,s=o.createProgram(),i=0;i<t.length;++i)o.attachShader(s,t[i]);if(r)for(var a=0;a<r.length;++a)o.bindAttribLocation(s,n?n[a]:a,r[a]);o.linkProgram(s);var c=o.getProgramParameter(s,o.LINK_STATUS);return c?s:(ns=o.getProgramInfoLog(s),console.log("Error in program linking:"+ns),o.deleteProgram(s),null)}function Uu(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=[];for(var n in e){var o=e[n],s=void 0;if(t&&(n=t+"."+n),typeof o=="number")r.push({type:"float",method:"1f",name:n,value:o});else if(Array.isArray(o)){if(typeof o[0]=="number")o.length===1?r.push({type:"float",method:"1f",name:n,value:o}):o.length>=2&&o.length<=4?r.push({type:"vec"+o.length,method:o.length+"fv",name:n,value:o}):o.length>4&&r.push({type:"float[]",method:"1fv",name:n+"[0]",value:o});else if(typeof o[0]=="string")r.push({type:"sampler2D",method:"1i",name:n,value:o});else if(Array.isArray(o[0])&&typeof o[0][0]=="number"){if(o[0].length>=2&&o[0].length<=4)for(s=0;s<o.length;s++)r.push({type:"vec"+o[0].length,method:o[s].length+"fv",name:n+"["+s+"]",value:o[s]})}else if(Ea(o[0])==="object")for(s=0;s<o.length;s++)r.push.apply(r,ju(Uu(o[s],n+"["+s+"]")))}else typeof o=="boolean"?r.push({type:"bool",method:"1i",name:n,value:o}):typeof o=="string"?r.push({type:"sampler2D",method:"1i",name:n,value:o}):(typeof o>"u"?"undefined":Ea(o))==="object"&&r.push.apply(r,ju(Uu(o,n)))}return r}function aO(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 cO(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function lO(e,t){return e&&t?e.toString()!==t.toString():!1}function uO(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(),t.status==200?t.responseText:""}function bw(e){var t=new Set;return Object.assign(e,{on:function(r,n){var o={};o[r]=n,t.add(o)},off:function(r,n){if(n){var o={};o[r]=n,t.delete(o)}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 p=l.value,u=!0,f=!1,d=void 0;try{for(var h=Object.keys(p)[Symbol.iterator](),g;!(u=(g=h.next()).done);u=!0){var y=g.value;if(y===r){t.delete(p);return}}}catch(w){f=!0,d=w}finally{try{!u&&h.return&&h.return()}finally{if(f)throw d}}}}catch(w){i=!0,a=w}finally{try{!s&&c.return&&c.return()}finally{if(i)throw a}}}},listSubscriptions:function(){var r=!0,n=!1,o=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){n=!0,o=c}finally{try{!r&&s.return&&s.return()}finally{if(n)throw o}}},subscribe:function(r){t.add(r)},unsubscribe:function(r){t.delete(r)},unsubscribeAll:function(){t.clear()},trigger:function(r){for(var n=arguments.length,o=Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];var i=!0,a=!1,c=void 0;try{for(var l=t[Symbol.iterator](),p;!(i=(p=l.next()).done);i=!0){var u=p.value;typeof u[r]=="function"&&u[r].apply(u,ju(o))}}catch(f){a=!0,c=f}finally{try{!i&&l.return&&l.return()}finally{if(a)throw c}}}})}var Bu=function(){function e(t,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};gw(this,e),bw(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(n.filtering),this.load(n)}return yw(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,n=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(o,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),n.filtering="nearest"):c=new Image,c.onload=function(){try{r.setElement(c,n)}catch(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,n)}o(r)},c.onerror=function(l){console.log("Texture '"+r.name+"': failed to load url: '"+r.source+"'",l,n),o(r)},cO()&&r.source.slice(0,5)==="data:"||(c.crossOrigin="anonymous"),c.src=r.source,a&&r.setElement(c,n)}),this.loading}},{key:"setData",value:function(t,r,n){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.width=t,this.height=r,this.source=n,this.sourceType="data",this.update(o),this.setFiltering(o),this.loading=Promise.resolve(this),this.loading}},{key:"setElement",value:function(t,r){var n=this,o=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(){n.intervalID=setInterval(function(){n.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(o)+") 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}();Bu.getMaxTextureSize=function(e){return e.getParameter(e.MAX_TEXTURE_SIZE)};Bu.activeUnit=-1;var xw=function(){function e(t,r,n){var o=this;gw(this,e),bw(this),r=r||{},n=n||{},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||
precision mediump float;
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||
precision mediump float;
varying vec2 v_texcoord;
void main(){
gl_FragColor = vec4(0.0);
}
;var s=sO(t,r,n.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");ka.get(i,function(g,y,w){o.load(w,o.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");ka.get(a,function(g,y,w){o.load(o.fragmentString,w)})}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 p=t.getAttribute("data-textures").split(",");for(var u in p)this.setUniform("u_tex"+u,p[u])}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 d=this;function h(){d.nMouse>1&&d.setMouse(f),d.resize()&&(d.forceRender=!0),d.render(),d.animationFrameRequest=window.requestAnimationFrame(h)}return this.setMouse({x:0,y:0}),h(),this}return yw(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 n in this.buffers){var o=this.buffers[n];this.gl.deleteProgram(o.program)}this.program=null,this.gl=null}},{key:"load",value:function(t,r){var n=this;r&&(this.vertexString=r),t&&(this.fragmentString=t);var o=this.fragmentString.split(/\r?\n/);this.fragmentString=#define PLATFORM_WEBGL ,o.forEach(function(g,y){var w=g.trim();if(w.startsWith('#include "lygia')){var R=w.substring(15).replace(/\'|\"|\;|\s/g,"");if(R.endsWith("glsl")){if(n.deps[R]===void 0){var E="https://lygia.xyz"+R;n.deps[R]=uO(E)}n.fragmentString+=n.deps[R]+
}}else n.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 p=i[a].match(/\s*void\s*main\s*/g);if(p)break}var u=co(this,this.vertexString,this.gl.VERTEX_SHADER),f=co(this,this.fragmentString,this.gl.FRAGMENT_SHADER);f?this.isValid=!0:(f=co(this,void main(){
gl_FragColor = vec4(1.0);
},this.gl.FRAGMENT_SHADER),this.isValid=!1);var d=mw(this,[u,f]);this.gl.useProgram(d),this.gl.deleteShader(u),this.gl.deleteShader(f),this.program=d,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,n){var o=this.vertexString,s=this.fragmentString,i=this.paused,a=this.gl.getExtension("EXT_disjoint_timer_query"),c=a.createQueryEXT(),l=this.isValid;(r||n)&&(this.load(r,n),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 p=this;function u(){p.paused=i,(r||n)&&p.load(s,o)}function f(){p.forceRender=!0,p.render();var d=a.getQueryObjectEXT(c,a.QUERY_RESULT_AVAILABLE_EXT),h=p.gl.getParameter(a.GPU_DISJOINT_EXT);if(d&&!h){var g={wasValid:l,frag:r||p.fragmentString,vert:n||p.vertexString,timeElapsedMs:a.getQueryObjectEXT(c,a.QUERY_RESULT_EXT)/1e6};u(),t(g)}else window.requestAnimationFrame(f)}f()}},{key:"loadTexture",value:function(t,r,n){var o=this;n||(n={}),typeof r=="string"?n.url=r:(typeof r>"u"?"undefined":Ea(r))==="object"&&r.data&&r.width&&r.height?(n.data=r.data,n.width=r.width,n.height=r.height):(typeof r>"u"?"undefined":Ea(r))==="object"&&(n.element=r),this.textures[t]?this.textures[t]&&(this.textures[t].load(n),this.textures[t].on("loaded",function(s){o.forceRender=!0})):(this.textures[t]=new Bu(this.gl,t,n),this.textures[t].on("loaded",function(s){o.forceRender=!0}))}},{key:"refreshUniforms",value:function(){this.uniforms={}}},{key:"setUniform",value:function(t){for(var r={},n=arguments.length,o=Array(n>1?n-1:0),s=1;s<n;s++)o[s-1]=arguments[s];r[t]=o,this.setUniforms(r)}},{key:"setUniforms",value:function(t){var r=Uu(t);for(var n in r)r[n].type==="sampler2D"?this.loadTexture(r[n].name,r[n].value[0]):this.uniform(r[n].method,r[n].type,r[n].name,r[n].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 n=(t.x-r.left)*this.realToCSSPixels,o=this.canvas.height-(t.y-r.top)*this.realToCSSPixels;this.uniform("2f","vec2","u_mouse",n,o)}}},{key:"uniform",value:function(t,r,n){this.uniforms[n]=this.uniforms[n]||{};for(var o=this.uniforms[n],s=arguments.length,i=Array(s>3?s-3:0),a=3;a<s;a++)i[a-3]=arguments[a];var c=lO(o.value,i);if(c||this.change||!o.location||!o.value){o.name=n,o.type=r,o.value=i,o.method="uniform"+t,this.gl.useProgram(this.program),o.location=this.gl.getUniformLocation(this.program,n),this.gl[o.method].apply(this.gl,[o.location].concat(o.value));for(var l in this.buffers){var p=this.buffers[l];this.gl.useProgram(p.program);var u=this.gl.getUniformLocation(p.program,n);this.gl[o.method].apply(this.gl,[u].concat(o.value))}}}},{key:"uniformTexture",value:function(t,r,n){if(this.textures[t]===void 0)this.loadTexture(t,r,n);else{this.uniform("1i","sampler2D",t,this.texureIndex);for(var o in this.buffers){var s=this.buffers[o];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=aO(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 n in this.buffers){var o=this.buffers[n];this.uniform("1i","sampler2D",o.name,o.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,n=t.canvas.height;t.viewport(0,0,r,n);for(var o in this.buffers){var s=this.buffers[o];s.bundle.render(r,n,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 n=arguments[3]||arguments[4];r["u_buffer"+n]={fragment:"#define BUFFER_"+n+
+t}}),r}},{key:"loadPrograms",value:function(t){var r=this,n=this.gl,o=co(r,r.vertexString,n.VERTEX_SHADER);for(var s in t){var i=t[s],a=co(r,i.fragment,n.FRAGMENT_SHADER,1);a?r.isValid=!0:(a=co(r,void main(){
gl_FragColor = vec4(1.0);
},n.FRAGMENT_SHADER),r.isValid=!1);var c=mw(r,[o,a]);i.name=s,i.program=c,i.bundle=r.createSwappableBuffer(r.canvas.width,r.canvas.height,c),n.deleteShader(a)}n.deleteShader(o)}},{key:"createSwappableBuffer",value:function(t,r,n){var o=this.createBuffer(t,r,n),s=this.createBuffer(t,r,n),i=this.gl;return{input:o,output:s,swap:function(){var a=o;o=s,s=a,this.input=o,this.output=s},render:function(a,c,l,p){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,p){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,n){var o=this.gl,s=this.BUFFER_COUNT;this.BUFFER_COUNT+=2,o.getExtension("OES_texture_float");var i=o.createTexture();o.activeTexture(o.TEXTURE0+s),o.bindTexture(o.TEXTURE_2D,i),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,t,r,0,o.RGBA,o.FLOAT,null),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);var a=o.createFramebuffer();return{index:s,texture:i,buffer:a,W:t,H:r,resize:function(c,l){o.bindFramebuffer(o.FRAMEBUFFER,a);var p=Math.min(c,this.W),u=Math.min(l,this.H),f=new Float32Array(p*u*4);o.readPixels(0,0,p,u,o.RGBA,o.FLOAT,f),o.bindFramebuffer(o.FRAMEBUFFER,null);var d=s+1,h=o.createTexture();o.activeTexture(o.TEXTURE0+d),o.bindTexture(o.TEXTURE_2D,h),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,c,l,0,o.RGBA,o.FLOAT,null),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.NEAREST),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,p,u,o.RGBA,o.FLOAT,f);var g=o.createFramebuffer();o.bindFramebuffer(o.FRAMEBUFFER,null),o.deleteTexture(i),o.activeTexture(o.TEXTURE0+s),o.bindTexture(o.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,n=t.canvas.height;t.viewport(0,0,r,n);for(var o in this.buffers){var s=this.buffers[o];s.bundle.resize(r,n,s.program,s.name)}t.useProgram(this.program)}},{key:"version",value:function(){return"0.1.7"}}]),e}();function pO(){var e=document.getElementsByClassName("glslCanvas");if(e.length>0){window.glslCanvases=[];for(var t=0;t<e.length;t++){var r=new xw(e[t]);r.isValid&&window.glslCanvases.push(r)}}}window.addEventListener("load",function(){pO()});var Ta=xw;var ww=e=>{if(!("after"in e))return Promise.resolve(void 0);let t=document.createElement("canvas");return new Ta(t).load(Ct(e.after)),e.render(t),Promise.resolve(void 0)};var vw=e=>{let t="";for(let r=0;r<e.length;r+=3)r+2===e.length?t+=Hu(e[r],e[r+1],0):r+1===e.length?t+=Hu(e[r],0,0):t+=Hu(e[r],e[r+1],e[r+2]);return t},Pa=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?"_":"?"))),Hu=(e,t,r)=>{let n=e>>2,o=(e&3)<<4|t>>4,s=(t&15)<<2|r>>6,i=r&63;return Pa(n&63)+Pa(o&63)+Pa(s&63)+Pa(i&63)};var kw=async(e,t="svg")=>{let r=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream("deflate")),n=new Uint8Array(await new Response(r).arrayBuffer());returnhttps://www.plantuml.com/plantuml/${t}/~1${vw(n)}};var Ew=async e=>{if(!("after"in e))return;let t=document.createElement("img"),r=await kw(Ct(e.after));t.src=r,e.render(t)};var Wu=Promise.resolve({log:new Uint8Array(0)}),Ra,Tw=(e,t,r,n)=>(Wu=(async()=>{await Wu,Ra??=await dO(t,r);let o=new Promise(i=>{let a=c=>{if(c.data.type==="stdout"){n(c.data.message);return}c.data.type==="compile"&&(i(c.data),Ra.removeEventListener("message",a))};Ra.addEventListener("message",a)}),s={type:"compile",input:e};return Ra.postMessage(s),o})(),Wu),dO=async(e,t)=>{let r=new Worker(e,{type:"module"}),n=new Promise(s=>{let i=a=>{a.data.type==="asset-url"&&(s(),r.removeEventListener("message",i))};r.addEventListener("message",i)}),o={type:"asset-url",url:${t}};return r.postMessage(o),await n,r};var Pw=(e,t)=>async r=>{if(!("after"in r))return;let n=fO(),o="Compile is not started yet. Please wait...",s=l=>{o=[...o.split( ),l].join(
),n.log(o)},i=document.createElement("img"),a=setTimeout(()=>{r.render(n.div),n.log(o)},2e3),{svg:c}=await Tw(Ct(r.after),e,t,s);if(clearTimeout(a),!c){r.render(n.div),n.log(o);return}i.src=await rs(new Blob([c],{type:"image/svg+xml"})),r.render(i)},fO=()=>{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 n=document.createElement("pre"),o=document.createElement("code");return n.append(o),t.append(n),{div:e,log:s=>{o.textContent=s,n.scroll(0,n.scrollHeight)}}};var kr=()=>/mobile/i.test(navigator.userAgent);var Rw="Cannot complete the mapping as an error was thrown from an item";function qu(e,t,r){let n=new TransformStream({async transform(o,s){try{let i=await o;s.enqueue(i)}catch(i){i instanceof AggregateError&&i.message===Rw&&s.error(i)}}});return(async()=>{let o=n.writable.getWriter(),s=[];try{for await(let i of t){let a=Promise.resolve().then(()=>r(i));o.write(a);let c=a.then(()=>s.splice(s.indexOf(c),1));s.push(c),s.length>=e&&await Promise.race(s)}await Promise.all(s),o.close()}catch{let i=[];for(let a of await Promise.allSettled(s))a.status==="rejected"&&i.push(a.reason);o.write(Promise.reject(new AggregateError(i,Rw))).catch(()=>{})}})(),Symbol.asyncIterator in n.readable&&typeof n.readable[Symbol.asyncIterator]=="function"?n.readable[Symbol.asyncIterator]():async function*(){let o=n.readable.getReader();for(;;){let{done:s,value:i}=await o.read();if(s)break;yield i}o.releaseLock()}()}async function*Sw(e,t){if(e.length===0||e.every(({before:n,after:o})=>n===o))return;let r=en(await ze());try{let{readable:n,writable:o}=new TransformStream(void 0),s=o.getWriter(),i=qu(5,e,async l=>{let p=0,u=0;l.before===l.after&&(await s.ready,await s.write({link:l,projectCount:0,replaced:0,done:!0}));let f=qu(2,new Set(t),async d=>{let h=await mO(l,d,r);if(Lo(h))throw hO(hm(h));p++,u+=en(h),await s.ready,await s.write({link:l,projectCount:p,replaced:u,done:!1})});await Array.fromAsync(f),await s.ready,await s.write({link:l,projectCount:p,replaced:u,done:!0})}),a=Array.fromAsync(i).then(async()=>{await s.ready,await s.close()}),c=n.getReader();for(;;){let{done:l,value:p}=await c.read();if(l)return;yield p}await a}finally{await nt(r)}}var mO=async(e,t,r)=>{let[n]=await Promise.all([Is(t,e.before,e.after),me(t,e.before,(o,{persistent:s})=>{if(s)return[e.after,...o.map(i=>i.text).slice(1)]},{socket:r})]);return n},Er=e=>e.split(
).flatMap(t=>[...t.matchAll(/\[((?:[^\[!"#%&'()\*\+,\-\.\/\{\|\}<>_~] |.[^ ]*)[^\[\]]*)\]/g)]).map(([,t])=>t),hO=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var _w=e=>Be(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return gO(r);case"table":return yO(r);case"line":return bO(r)}}).map(r=>r).join(
),gO=({fileName:e,content:t,indent:r})=>{let n=" ".repeat(r);return[${n}code:${e},...t.split(
).map(o=>${n} ${o})]},yO=({fileName:e,cells:t,indent:r})=>{let n=" ".repeat(r);return[${n}table:${e},...t.map(o=>${n} ${o.map(s=>s.map(i=>os(i)).join("")).join(" ")})]},bO=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${os(r)}).join("")}],os=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>os(t)).join("")};case"strong":return${e.nodes.map(t=>os(t)).join("")};case"decoration":{let t=e.decos.map(r=>{let n=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return n>0?"*".repeat(n):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>os(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=>Er(e).length>0?"":"",onClick:e=>{let t=_w(e);if(e!=t)return t}});var Lw=e=>!e.includes(
)&&/\[[^\]]+\]/.test(e);scrapbox.PopupMenu.addButton({title:e=>Lw(e)?"[][]":"",onClick:e=>{if(!Lw(e))return;let t=e.replaceAll("[","").replaceAll("]","");return(async()=>{let{render:r,dispose:n}=Re();try{let o=scrapbox.Project.name;r({type:"spinner"},{type:"text",text:create /${o}/${t}}),await me(o,t,([{text:s}],{persistent:i})=>{if(!i)return[s,e]}),r({type:"check-circle"},{type:"text",text:create /${o}/${t}})}catch(o){if(console.error(o),!(o instanceof Error))throw o;r({type:"exclamation-triangle"},{type:"text",text:${o.name} ${o.message}})}finally{await Ee(2e3),n()}})(),${t}}});var Ow=(e,t)=>{switch(e.type){case"title":return"";case"codeBlock":return[e.fileName, \\`\`${PO(e.fileName)},e.content,"\n"].join(
);case"table":return xO(e);case"line":return vO(e,t)}},xO=e=>{let t=[e.fileName],r=Math.max(...e.cells.map(n=>n.length));return e.cells.forEach((n,o)=>{t.push(| ${n.map(s=>s.map(i=>lo(i)).join("")).join(" | ")} |),o===0&&t.push(|${" -- |".repeat(r)})}),t.join(
)},wO=" ",vO=(e,t)=>{let r=e.nodes.map(o=>lo(o,{section:e.indent===t})).join("").trim();if(r==="")return"";if(e.indent===t)return r;let n=wO.repeat(e.indent-t-1);return/^\d+\. /.test(r)||(n+="- "),n+r},lo=(e,t)=>{let{section:r=!1}=t??{};switch(e.type){case"quote":return> ${e.nodes.map(n=>lo(n)).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(n=>lo(n)).join("")}**;case"formula":return$${e.formula}$;case"decoration":{let n=e.nodes.map(o=>lo(o)).join("");return e.decos.includes("/")&&(n=*${n}*),r?(e.decos.includes("*-3")&&(n=`# ${n} ),e.decos.includes("*-2")&&(n=## ${n}
),e.decos.includes("*-1")&&(n=### ${n}
)):e.decos.some(o=>/\*-/.test(o[0]))&&(n=**${n}**),e.decos.includes("~")&&(n=~~${n}~~),n}case"code":return\${e.text}\`;case"commandLine":return\`${e.symbol} ${e.text}\`;case"link":switch(e.pathType){case"root":{let,n,...o=e.href.split("/");return[${e.href}](https://scrapbox.io/${n}/${Cw(o.join("/"))})}case"relative":return[${e.href}](https://scrapbox.io/${scrapbox.Project.name}/${Cw(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(n=>lo(n)).join("")};case"blank":case"plain":return e.text}},Cw=e=>...e.map((t,r)=>t===" "?"_":!kO.includes(t)||r===e.length-1&&EO.includes(t)?encodeURIComponent(t):t).join(""),kO='@$&+=:;",',EO=':;",',TO=[{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"}],PO=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return TO.find(r=>r.extensions.includes(t))?.fileType??""};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{(async()=>{try{let t=io.parse(e,{hasTitle:!1}),r=Math.min(...t.map(n=>n.indent));await navigator.clipboard.writeText(t.map(n=>Ow(n,r)).join(` ))}catch(t){alert(Failed to copy:
${JSON.stringify(t)})}})()}});var zu=(e,...t)=>{let r=t.reduce((n,o)=>Ke(n)?n:n instanceof Promise?n.then(s=>Ke(s)?s:o(s)):o(n),e);return r instanceof Promise?r.then(n=>${n}):${e}};var uo=e=>e.ok?we(e):Z({name:"HTTPError",message:${e.status} ${e.statusText},response:e});var Nw=e=>window.GM_fetch?.(https://cdn.syndication.twimg.com/tweet-result?id=${e}&token=x)?.then?.(t=>Mt(uo(t),r=>r.json()));var Sa=e=>{let{fetch:t=globalThis.fetch,...r}=e;return{fetch:t,...r}},Mw=e=>typeof e=="object"&&e!==null;var ss=class e extends Error{name="UnexpectedResponseError";status;statusText;body;path;constructor(t){super(${t.status} ${t.statusText} when fetching ${t.path.toString()}),this.status=t.status,this.statusText=t.statusText,this.body=t.body,this.path=t.path,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};var _a=async e=>{let t=await e.text();if(e.ok)return we(t);if(e.status===400)return Z({name:"BadRequestError",message:t});try{let r=JSON.parse(t);if(!Mw(r)||typeof r.message!="string")throw new ss({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)});switch(e.status){case 401:return Z({name:"UnauthorizedError",message:r.message});case 403:return Z({name:"NotPrivilegeError",message:r.message});case 404:return Z({name:"NotFoundError",message:r.message});case 422:return Z({name:"InvalidParameterError",message:r.message});case 429:return Z({name:"RateLimitError",message:r.message});default:throw new ss({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)})}}catch(r){throw r instanceof SyntaxError?new ss({status:e.status,statusText:e.statusText,body:t,path:new URL(e.url)}):r}};var Iw=async(e,t)=>{let{title:r,description:n,metadataIsPublic:o,collectionId:s,refererURL:i,accessToken:a,created:c,app:l,fetch:p}=Sa(t),u=new FormData;u.append("imagedata",e),u.append("access_token",a),i&&u.append("referer_url",i.toString()),l!==void 0&&u.append("app",l),r!==void 0&&u.append("title",r),n!=null&&u.append("desc",n),s&&u.append("collection_id",s),o&&u.append("metadata_is_public","true"),c!==void 0&&u.append("created_at",${c});let f=await p("https://upload.gyazo.com/api/upload",{method:"POST",mode:"cors",credentials:"omit",body:u}),d=await _a(f);return W(d)?d:we(JSON.parse(B(d)))};var Dw=(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 La="",Aw=!1,Ca=new Map,$w=async(e,t,r,n)=>{let o=Ca.get(e.href);if(o)return o;if(e.hostname==="video.twimg.com"||${e}.endsWith(".svg")){let c=await GM_fetch(e);if(!c.ok)return;let l=c.headers.get("content-type")?.split?.(";")?.[0]??${e}.endsWith(".mp4")?"video/mp4":"video/webm",p=new File([await c.blob()],n||${t},{type:l});if(l==="video/mp4"){let d=await Dw(p);if(d.ok){let h=new URL(await d.text());return Ca.set(e.href,h),h}}let u=await af(p,r);if(W(u))throw Error(ee(u).name);let f=new URL(B(u).embedUrl);return Ca.set(e.href,f),f}if(e.hostname!=="pbs.twimg.com"||!e.pathname.startsWith("/media"))return;if(Aw){if(!La)return}else{let c=await Jd();if(Aw=!0,W(c)){alert("You haven't logged in Gyazo yet, so you can only upload images to scrapbox.io.");return}if(La=B(c)||"",!La){alert("You haven't connect Gyazo to scrapbox.io yet.");return}}let s=await GM_fetch(e);if(!s.ok)return;let i=await Iw(await s.blob(),{accessToken:La,refererURL:t,description:n});if(W(i))throw Error(ee(i).name);let a=new URL(B(i).permalink_url);return Ca.set(e.href,a),a};var Uw=[["&","&"],["<","<"],[">",">"],['"',"""],["'","'"]],RO=Object.fromEntries([...Uw.map(([e,t])=>[t,e]),["'","'"],[" "," "]]),SO=new Map(Uw),wme=new RegExp([${...SO.keys().join("")}],"g");var _O={entityList:RO},LO=1114111,CO=/&#([0-9]+);/g,OO=/&#x(\p{AHex}+);/gu,Fw=new WeakMap;function Gu(e,t={}){let{entityList:r}={..._O,...t},n=Fw.get(r);return n||(n=new RegExp((${Object.keys(r).sort((o,s)=>s.length-o.length).join("|")}),"g"),Fw.set(r,n)),e.replaceAll(n,o=>r[o]).replaceAll(CO,(o,s)=>jw(s,10)).replaceAll(OO,(o,s)=>jw(s,16))}function jw(e,t){let r=parseInt(e,t);return r>LO?"�":String.fromCodePoint(r)}var Oa=e=>{let t={name:e.user.name,screenName:e.user.screen_name},r=new Date(e.created_at),n=[...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,p="STRING";c?.type===p&&(a.description=c.string_value),l?.type===p&&(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]),o=[];{let i=0,a=e.text;for(let{indices:c,...l}of n){let p=[...a].slice(0,c[0]-i).join("");o.push({type:"plain",text:Gu(p)}),o.push(l),a=[...a].slice(c[1]-i).join(""),i=c[1]}a&&o.push({type:"plain",text:Gu(a)})}let s={id:e.id_str,content:o,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=Oa(e.parent)),e.quoted_tweet&&(s.quote=Oa(e.quoted_tweet)),s};var NO=["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"],Na=(e=scrapbox.Project.name,t=location.host)=>r=>{if(r.host!==t)return r;let[,n,o]=r.pathname.match(/^\/([\w\d][\w\d-]{0,22}[\w\d])(?:\/?|\/(.+))$/)??[];return!n||NO.includes(n)?r:o?n===e?${decodeURIComponent(o)}:/${n}/${decodeURIComponent(o)}:/${n}};var Bw=(e=MO)=>t=>{let[,r]=t.href.match(/^https:\/\/(?:(?:www\.|mobile\.|m\.)?twitter|x)\.com\/[\w\d_]+\/(?:status|statuses)\/(\d+)/)??[];return r?(async()=>{let n=await(Nw(r)??Xd(t.href));if(W(n))throw ee(n);let o=B(n);return e("images"in o?{...o,id:r}:o,t)})():t},MO=async e=>{if("images"in e)return is(e);let{quote:t,replyTo:r,...n}=Oa(e);return[...r?[...(await is(r)).split( ).map(o=> > ${o}),...r.quote?(await is(r.quote)).split(
).map(o=> > ${o}):[]]:[],...(await is(n)).split(
).map(o=>> ${o}),...t?(await is(t)).split(
).map(o=>> > ${o}):[]].join(
)?.map?.(o=>> ${Yu(o)})??["> [/ no description provided]"],...e.images.length>0?[> ${e.images.map(o=>[${o}])}]:[]].join(
);let r=e.content,n=e.author.screenName;return[@${Yu(n)} ${t},...(await Promise.all(r.map(async o=>{switch(o.type){case"plain":return o.text;case"hashtag":return #${o.text} ;case"symbol":return #$${o.text} ;case"mention":return@${o.screenName};case"media":{let s=[],i=1;for(;i<o.media.length;i+=2)s.push([${await Ku(o.mediai-1,t)}] [${await Ku(o.mediai,t)}]);return i===o.media.length&&s.push([${await Ku(o.mediai-1,t)}]), ${s.join(`
`)}
}case"url":return${Na()(o.url)} }}))).join("").split(
)].join(
)},Ma="",IO=async()=>{if(Ma)return Ma;let e=await lr(scrapbox.Project.name);if(W(e))throw new Error(ee(e).name);return Ma=B(e).id,Ma},Ku=async(e,t)=>await $w(e.url,t,await IO(),"")??e.url,Yu=e=>e.replace(/\b/gm,"").replace(/[\s\r\n\u2028\u2029]+/gm," ").replace(/\s*[[\]]\s*/g," ").trim();var Hw=e=>window.GM_fetch?.(https://t.co/${e})?.then?.(t=>Mt(uo(t),async r=>{let n=new DOMParser().parseFromString(await r.text(),"text/html");try{return new URL(n.title)}catch(o){if(o instanceof TypeError)return;throw o}}));var Ww=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(n=>n.ok?new URL(n.url):e);if(e.hostname!=="t.co")return e;let r=Hw(e.pathname.slice(1));return r?r.then(n=>df(n,()=>e,o=>o??e)):e};var qw=e=>{if(!e.pathname.startsWith("/wiki/"))return e;if(!/^\w+\.wikipedia\.org$/.test(e.hostname)){let,o=e.hostname.match(/^(\w+)\.m\.wikipedia\.org$/)??[];if(!o)return e;e.hostname=${o}.wikipedia.org}let t=decodeURIComponent(e.pathname.slice(6)),r=e.hash?decodeURIComponent(e.hash.slice(1)):"",n=${e.origin}/wiki/${t};return r?[${r} | ${t} - Wikipedia ${n}#${r}]:[${t} - Wikipedia ${n}]};var zw=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 Vu=e=>{if(!e.hostname.startsWith("www.google."))return e;let t=e.searchParams.get("url");return t?new URL(decodeURIComponent(t)):e};var Gw=/charset=(^;+)/,Kw=e=>window.GM_fetch?.(${e})?.then?.(t=>Mt(uo(t),async r=>{let n=r.headers.get("content-type")?.match?.(Gw)?.1??await DO(r.clone());return new TextDecoder(n).decode(await r.arrayBuffer())})),DO=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?.(Gw)?.1??"utf-8"};var Yw=(e=AO)=>async t=>e(await $O(t),t),AO=(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}},$O=async e=>{let t=Kw(e);if(!t){let n=await Vd(e);if(W(n))throw ee(n);return B(n)}let r=await t;if(W(r))throw ee(r);return new DOMParser().parseFromString(B(r),"text/html")};var Vw=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 Xw=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 Jw=(e,...t)=>{if(e instanceof URL)return zu(new URL(e),...t);let r=0,n=0,o=0,s=!1,i=e.split(/(https?:\/\/\S+)/g).map(p=>{if(!/^https?:\/\/\S+$/.test(p))return p;r++;try{let u=zu(new URL(p),...t);return Ke(u)?(n++,u):(s=!0,u,p)}catch(u){return console.error(u),o++,p}});if(!s)return i.join("");let{render:a,dispose:c}=Re(),l=()=>a({type:"spinner"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed});return l(),Promise.all(i.map(async p=>{if(Ke(p))return p;try{let u=await p0;return n++,u}catch(u){return console.error(u),o++,p1}finally{l()}})).then(p=>(a({type:"check-circle"},{type:"text",text:URL: ${n}/${r} converted, ${o} failed}),p.join(""))).finally(()=>{setTimeout(c,1e3)})};var Qw=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 Zw=e=>Be(e,{hasTitle:!1}).flatMap(r=>{switch(r.type){case"title":return[];case"codeBlock":return FO(r);case"table":return jO(r);case"line":return UO(r)}}).map(r=>r).join(` ),FO=({fileName:e,content:t,indent:r})=>{let n=" ".repeat(r);return[${n}code:${e},...t.split(
).map(o=>${n} ${o})]},jO=({fileName:e,cells:t,indent:r})=>{let n=" ".repeat(r);return[${n}table:${e},...t.map(o=>${n} ${o.map(s=>s.map(i=>i.raw).join("")).join(" ")})]},UO=({nodes:e,indent:t})=>[${" ".repeat(t)}${e.map(r=>${as(r)}).join("")}],as=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>as(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=>as(t)).join("")};case"decoration":{e.decos.includes("-")||e.decos.push("-");let t=e.decos.map(r=>{let n=parseInt(r.match(/\*-(\d)/)?.[1]??"0");return n>0?"*".repeat(n):r}).join("");return[${t?${t} :""}${e.nodes.map(r=>as(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=>as(t)).join("")};case"blank":case"plain":return${e.text}}};scrapbox.PopupMenu.addButton({title:"",onClick:e=>{let t=Zw(e);if(e!==t)return t}});var Xu=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 n=e.slice(t+2).split(
);if(n.length===0)return;for(let[s,i]of r){let a=s.match(/^\/(.*?)\/([gimy]*)$/);if(a){let c=new RegExp(a[1],a[2]);n=n.map(l=>l.replace(c,i.replaceAll("\\n",
)))}else n=n.map(c=>c.replaceAll(s,i.replaceAll("\\n",
)))}let o=${e.slice(0,t+2)}${n.join(`
)};if(e!==o)return o};scrapbox.PopupMenu.addButton({title:e=>Xu(e)?"replace":"",onClick:e=>{let t=Xu(e);if(t!==void 0)return t}});var ev=e=>{let t=document.createElement("div"),r=t.attachShadow({mode:"open"}),n=document.createElement("style");n.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(n);let o=document.createElement("dialog");o.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(o);let s=o.querySelector(".editor");s.rows=e.length,s.value=e.join(
);let i=()=>{o.style.minWidth=${Math.max(...s.value.split(`
).map(p=>[...p].length))+6}em};i(),s.addEventListener("input",i);let a=o.querySelector(".cancel"),c=o.querySelector(".replace"),l=new Promise(p=>{let u=()=>{p({convert:!1}),t.remove()};o.addEventListener("close",u),o.addEventListener("click",u),a.addEventListener("click",u),c.addEventListener("click",()=>{let f=s.value.split(`
);p({convert:!0,links:e.flatMap((d,h)=>d===f[h]||d===""||!f[h]?[]:[{before:d,after:f[h]??d}])}),t.remove()}),o.querySelector(".container").addEventListener("click",f=>{f.stopPropagation()})});return document.body.append(t),o.showModal(),l};var tv=async(e,t)=>{let r=Er(e),n=await ev([...new Set(r)]);if(!n.convert||n.links.length===0)return;let o=new Map(n.links.map(s=>[s.before,Re()]));for await(let{link:s,projectCount:i,replaced:a,done:c}of Sw(n.links,t)){let l=o.get(s.before);if(!l)return;if(c){l.render({type:"check-circle"},{type:"text",text:"${s.after}", ${a}l. ${i}p.}),setTimeout(()=>l.dispose(),1e3);return}l.render({type:"spinner"},{type:"text",text:"${s.after}", ${a}l. ${i}p.})}};var rv=async(e,t)=>{let r=Er(e)[0];if(!r)return;let n=window.prompt(Replace "${r}" to this in ${t.map(a=>"/${a}").join(", ")},r)?.replace?.(/[\[\]\n]/g," ")??"";if(n==="")return;let{render:o,dispose:s}=Re(),i=B(await ze());try{o({type:"spinner"},{type:"text",text:Replacing links in ${t.length} projects...});let a=0,l=(await Promise.all(t.map(async p=>{let[u]=await Promise.all([Is(p,r,n),me(p,r,(f,{persistent:d})=>{if(d)return[n,...f.map(h=>h.text).slice(1)]},{socket:i})]);if(W(u))throw o({type:"exclamation-triangle"},{type:"text",text:${ee(u).name} ${ee(u).message}}),BO(ee(u));return a++,o({type:"spinner"},{type:"text",text:Replacing links in ${t.length-a} projects...}),B(u)}))).reduce((p,u)=>p+u,0);o({type:"check-circle"},{type:"text",text:Successfully replaced ${l} links.})}finally{await nt(i),setTimeout(s,1e3)}},BO=e=>{let t=new Error;return t.name=e.name,t.message=e.message,t};var nv=e=>{let t=[scrapbox.Project.name,...e];scrapbox.PopupMenu.addButton({title:r=>{let n=Er(r).length;return n>1?"update links":n===1?"update a link":""},onClick:r=>{let n=Er(r).length;n>1?tv(r,t):n===1&&rv(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 n=(await(await GM_fetch(https://gyazo.com/${t}.json)).json()).metadata?.ocr?.description;if(n)try{await navigator.clipboard.writeText(n)}catch(o){console.error(o),alert(${o.name} ${o.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 ov=e=>{let t="",r=0;for(let n of e)if(n.type!=="title"){if(n.indent>r)for(let o=r;o<n.indent;o++)t+=cs(${o!==r?"\\item":""}\\begin{itemize},o*2)+ ;if(n.indent<r)for(let o=r;o>n.indent;o--)t+=cs("\\end{itemize}",(o-1)*2)+
;r=n.indent,t+=cs(${r>0?"\\item ":""}${HO(n)},r*2)+
}for(let n=r;n>0;n--)t+=cs("\\end{itemize}",(n-1)*2)+
${e.content}
\\end{lstlisting},qO=e=>{let t=\\caption{${kt(e.fileName)}}\\label{table:${kt(e.fileName)}},r=Math.max(...e.cells.map(o=>o.length)),n=e.cells.map(o=> ${o.map(s=>s.map(i=>po(i)).join("")).join(" & ")}\\\\);return\\begin{table}htbp ${t}
\\centering
\\begin{tabular}{${"c".repeat(r)}}
${n.length===0?"":n.length===1?` \\toprule
${n.join(`
`)}
\\bottomrule: \\toprule
\\midrule
${n.slice(1).join(`
`)}
\\bottomrule`}
\\end{tabular}
\\end{table}},zO=e=>e.nodes.map(t=>po(t)).join(""),po=e=>{switch(e.type){case"quote":return\\begin{quote}
${cs(e.nodes.map(t=>po(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{${kt(e.path)}};case"strong":return\\textbf{${e.nodes.map(t=>po(t)).join("")}};case"formula":return$${e.formula}$;case"decoration":{let t=e.nodes.map(r=>po(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=>po(t)).join("")};case"helpfeel":return\\lstinline!? ${kt(e.text)}!;case"code":return\\lstinline!${kt(e.text)}!;case"commandLine":return\\lstinline!${kt(e.symbol)} ${kt(e.text)}!;case"link":return e.pathType==="absolute"?e.content===""?\\url{${e.href}}:\\href{${e.href}}{${kt(e.content)}}:kt(e.href);case"googleMap":return\\href{${e.url}}{${kt(e.place)}};case"hashTag":return kt(#${e.href});case"blank":case"plain":return kt(e.text)}},GO=[{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"}],KO=e=>{let t=e.replace(/^.*\.(\w+)$/,"$1");return GO.find(r=>r.extensions.includes(t))?.fileType??""},kt=e=>e.replaceAll("\\","\\textbackslash ").replaceAll("#","\\#").replaceAll("%","\\%").replaceAll("$","\\$").replaceAll("&","\\&").replaceAll("~","\\textasciitilde ").replaceAll("^","\\textasciicircum ").replaceAll("_","\\_").replaceAll("{","\\{").replaceAll("}","\\}").replaceAll("|","\\textbar ").replaceAll("<","\\textless ").replaceAll(">","\\textgreater "),cs=(e,t)=>e.split( ).map(r=>${" ".repeat(t)}${r}).join(
);scrapbox.PopupMenu.addButton({title:"TeX",onClick:e=>{navigator.clipboard.writeText(ov(Be(e))).catch(t=>{console.error(t),alert(${t.name} ${t.message}
${t.stack})})}});var Ia="https://keicho.herokuapp.com/api/";var sv=async(e,t)=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let r=await window.GM_fetch(${Ia}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 n=await r.json();return{ok:!0,value:{text:n.text,buttons:n.buttons,canInput:n.can_input}}};var iv=()=>{let{popupMenu:e,render:t}=YO();qf()?.append?.(e);let r=Lr(),n=()=>{requestAnimationFrame(()=>{let o=document.getElementsByClassName("cursor")[0];e.style.top=${parseInt(o.style.top)+parseInt(o.style.height)+4}px})};return r.addChangeListener(n),{render:t,visible:()=>!e.hidden,open:()=>e.hidden=!1,close:()=>e.hidden=!0,toggle:()=>e.hidden=!e.hidden,dispose:()=>{e.remove(),r.removeChangeListener(n)}}},YO=()=>{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
}
max-width:90vw
}
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
}
font-size:13px;
padding:6px;
min-width:12vw
}
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:(...n)=>{r.textContent="",r.append(...n.map(({text:o,onClick:s})=>{let i=document.createElement("div");return i.classList.add("button"),i.textContent=o,s&&i.addEventListener("click",()=>s()),i}))}}};var av=async(e="normal")=>{if(!window.GM_fetch)return{ok:!1,value:{name:"GMFetchNotAvailableError"}};let t=await window.GM_fetch(${Ia}web/create/?mode=${e},{mode:"cors"});return t.ok?{ok:!0,value:await t.text()}:{ok:!1,value:{name:"ResponseError",res:t}}};var cv=e=>https://keicho.netlify.app/#talk=${e};var lv=e=>{let t=e.split( ),r=t[1]??t[0],n=e===t[0]?"":t[0];return n?[n.trim(),r].join(
):r};var Da=async(e,t,r)=>{let n=Lr(),o=n.lines.findIndex(i=>i.id===t.id);o<0&&(o=n.lines.findIndex(i=>i.text===t.text)),o<0&&(o=Math.min(r,Math.max(0,n.lines.length-1)));let s=n.lines[o].text;return ri().clear(),n.setPosition({line:o,char:[...s].length}),await Qe(
${e}),n.getPosition().line};var uv=e=>Be(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(n=>${r} ${n})].join(
).trimEnd();case"table":return[${r}${t.fileName},...t.cells.map(n=>${r} ${n.flatMap(o=>o.map(s=>Aa(s))).join(" ")})].join(
).trimEnd();case"line":return${r}${t.nodes.map(n=>Aa(n)).join("")}.trimEnd()}}).join(
),Aa=e=>{switch(e.type){case"quote":return> ${e.nodes.map(t=>Aa(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=>Aa(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 fo=e=>/^[((]/.test(e);var dv=async e=>{let t=scrapbox.Page.lines;if(!t)return;let{cursor:r,selection:n}=Pt(),o=e?.entire||n.hasSelectionAll(),s=o?t.map(P=>P.text).join(
):n.getSelectedText(),i=e?.botIcon??"[/nishio/nisbot.icon]",{render:a,visible:c,open:l,close:p,dispose:u}=iv();p();let f=new Set,d=()=>{u();for(let P of f)P()},h=P=>f.add(P),g={text:"Exit",onClick:d},y=e?.talkId||pv(s)||(o?"":pv(t.slice(0,1+r.getPosition().line).map(P=>P.text).join(
))),w=!y;if(!y){let P=av(e?.mode),_=setTimeout(()=>{a({text:"Start talking..."}),l();let I=0;_=setInterval(()=>{a({text:Start talking${".".repeat(I%3)}}),I++},1e3)},1e3),M=await P;if(clearTimeout(_),!M.ok){if(M.value.name==="GMFetchNotAvailableError"){alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc.");return}if(M.value.name==="ResponseError"){a({text:Error: ${M.value.res.status} ${M.value.res.statusText}},g),l(),console.error(Error: ${M.value.res.status} ${M.value.res.statusText},await M.value.res.text());return}return}y=M.value}let R=y,E=n.normalizeOrder(n.getRange()),b=o?t.length-1:E.end.line,k=t[b],v=o?"":" ".repeat(Math.min(...t.slice(E.start.line,E.end.line+1).map(P=>dr(P.text)))),L=async P=>{let _=await sv(P,R);if(!_.ok)switch(_.value.name){case"ResponseError":return a({text:Error: ${_.value.res.status} ${_.value.res.statusText}},g),l(),console.error(Error: ${_.value.res.status} ${_.value.res.statusText},await _.value.res.text()),_;case"GMFetchNotAvailableError":return alert("GM_fetch is not available. Please use Tampermonkey and install GM_fethc."),_}return _},C="",O=async P=>{let _=uv(P).split(
).map(D=>D.trim()).join(
).trim();_.startsWith(C)&&(_=_.slice(C.length));let M=_.split(
);if(M.length===0)return;if(M.every(D=>fo(D))&&(C=_),M.filter(D=>!fo(D)).length<2){let D,q;for(let j of M){if(q=await L(j),!q.ok)return q;fo(j)||(D=q)}return D??q}let F=0;{let D;for(;F<M.length&&fo(M[F]);F++)if(D=await L(M[F]),!D.ok)return D}{let D=await L("まず聞いて");if(!D.ok)return D}for(;F<M.length&&!fo(M[F]);F++){let D=await L(M[F]);if(!D.ok)return D}return await L("おしまい")},S=async P=>{if(scrapbox.Layout!=="page"||P==="")return;let _=O(P),M=setTimeout(()=>{a({text:"Asking..."}),l();let j=0;M=setInterval(()=>{a({text:Asking${".".repeat(j%3)}}),j++},1e3)},1e3),I=await _;if(clearTimeout(M),!I||!I.ok)return;let{text:F,buttons:D}=I.value,q=lv(F);if(q.trim()){let j=${v}${i}${q.includes(`
)?
${q.split(`
).map(z=> ${v}${z}).join(
)}:q}
${v};b=await Da(j,k,b),k=t[b]}a({text:"Send",onClick:T},{text:"🙂",onClick:()=>Qe("🙂")},{text:"🙁",onClick:()=>Qe("🙁")},...D.map(j=>({text:j,onClick:async()=>{b=await Da(j,k,b),k=t[b],await S(j)}})),g),l()},T=async()=>{if(scrapbox.Layout!=="page")return;let P=scrapbox.Page.lines,_=r.getPosition().line,[M,I,F]=VO(P,_,i);M!==""&&(b=F,k=P[b],v=" ".repeat(Math.min(...P.slice(I,F+1).map(D=>dr(D.text)))),await S(M))};return w&&(b=await Da(cv(R),k,b),k=t[b]),await S(s),{ask:T,open:l,close:p,visible:c,exit:d,onExit:h}},pv=e=>{for(let t of e.split(
).reverse()){let r=t.match(/https?:\/\/keicho\.netlify\.app\/#talk=(\w+)/)?.[1];if(r)return r}},VO=(e,t,r)=>{let n=Math.max(e.findLastIndex((s,i)=>i<t&&s.text.trim().startsWith(r)),1),o=n+Qr(n,e)+1;return[e.slice(o,t+1).map(s=>s.text.trim()).join(
).trim(),o,t]};scrapbox.PopupMenu.addButton({title:"",onClick:e=>${e}});scrapbox.PopupMenu.addButton({title:"",onClick:e=>$ ${e}});var fv=[fn,mn,hn];scrapbox.PopupMenu.addButton({title:e=>{let t=fr({project:scrapbox.Project.name,mode:"noopen",hooks:fv});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&&fr({project:e,mode:"noopen",hooks:fv})?.()}});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( );if(e!=t)return t}});var XO=[Vu,Ww,Vu,zw,Vw,Na(),Xw,Bw(),qw,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"),n=e.searchParams.get("sr"),o=new URL(e);return o.search="",t&&o.searchParams.append("dt",t),o.pathname.startsWith("/transit/route/")&&(r&&o.searchParams.append("tm",r),n&&o.searchParams.append("sr",n)),o},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,n]=e.pathname.match(/^\/([^\\]+)\/([^\\]+)\/blob\/(.+)$/)?.slice?.(1)??[];if(!t||!r||!n)return e;let[,o,s]=e.hash.match(/L(\d+)-L(\d+)/)??e.hash.match(/L(\d+)/)??[];return[https://code2svg.vercel.app/svg/${o&&s?L${o}-${s}/:o?L${o}/:""}https://raw.githubusercontent.com/${t}/${r}/${n}#.svg ${e}]},e=>e.hostname==="github.com"?${e}:e,Qw,Yw()];scrapbox.PopupMenu.addButton({title:e=>/https?:\/\/\S+/.test(e)?"URL":"",onClick:e=>{let t=Jw(e,...XO);if(typeof t=="string")return e===t?void 0:t;t.then(r=>{if(e!==r)return Qe(r)})}});nv(["takker","takker-memex","takker-private","takker-books"]);if(!/mobile/i.test(navigator.userAgent)){let e=(t,r)=>{t.trim()!==""&&dv({mode:r}).then(n=>{if(!n)return;let{ask:o,visible:s,onExit:i}=n,a=c=>{!s()||c.key!=="Enter"||!c.ctrlKey||c.altKey||c.shiftKey||(c.preventDefault(),c.stopPropagation(),o())};Xe().addEventListener("keydown",a),i(()=>Xe().removeEventListener("keydown",a))})};scrapbox.PopupMenu.addButton({title:()=>"🤖",onClick:t=>e(t)})}var ls=(e,t)=>t.map(r=>r.replace(/@yyyy-MM-dd HH:mm:ss@/g,wt(e,"yyyy-MM-dd HH:mm:ss")).replace(/@yyyy-MM-dd@/g,wt(e,"yyyy-MM-dd")).replace(/@yyyy-MM-dd(?:([+-])(\d+)(w?))?(?:\((Sun|Mon|Tue|Wed|Thu|Fri|Sat)\))?@/g,(n,o,s,i,a)=>{let c=o?o==="+"?We(e,parseInt(s)*(i==="w"?7:1)):mr(e,parseInt(s)*(i==="w"?7:1)):e;return wt(a?We(pt(c),JO(a)):c,"yyyy-MM-dd")}).replace(/@yyyy-ww@/g,${Xc(e)}-w${${Bn(e)}.padStart(2,"0")}).replace(/@yyyy-ww([+-])(\d+)(w?)@/g,(n,o,s,i)=>{let a=o==="+"?We(e,parseInt(s)*(i==="w"?7:1)):mr(e,parseInt(s)*(i==="w"?7:1));return${Xc(a)}-w${${Bn(a)}.padStart(2,"0")}})),JO=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 hv=async(e,t,r)=>{if(scrapbox.Project.name!==e)return()=>{};let n=scrapbox.Project.pages;await new Promise(l=>{let p=setInterval(()=>{if(n.length===0){n=scrapbox.Project.pages;return}clearInterval(p),l()},2e3)});let o=new Date(2023,1,3),s=async()=>{let l=new Date,p={start:o,end:We(l,1)},{render:u,dispose:f}=Re(),d;try{let h=await mv(t),g=await mv(r),y=di(p).filter(b=>{let k=ls(b,h)[0],v=n.find(L=>L.title===k);return!v||!v.exists}),w=Ym(p).filter(b=>{let k=ls(b,g)[0],v=n.find(L=>L.title===k);return!v||!v.exists});if(y.length===0&&w.length===0)return;let R=y.length+w.length;u({type:"spinner"},{type:"text",text:create ${R} review pages...});let E=await ze();if(W(E))throw ee(E);d=B(E);for(let b of[...y.map(k=>ls(k,h)),...w.map(k=>ls(k,g))])await me(e,b[0],(k,v)=>v.persistent?void 0:b,d?{socket:d}:{}),R--,u({type:"spinner"},{type:"text",text:create ${R} review pages...});u({type:"check-circle"},{type:"text",text:created ${y.length+w.length} review pages.}),o=l}catch(h){u({type:"exclamation-triangle"},{type:"text",text:h instanceof Error?${h.name} ${h.message}:"Unknown error! (see developper console)"}),console.error(h)}finally{d&&await nt(d),await Ee(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)},mv=async e=>{let t=await Ds(e[0],e[1],e[2]);if(W(t)){let n=new Error;throw n.name=ee(t).name,n.message=${ee(t).message} at fetching /${e0}/${e1}/${e2},n}let r=B(t).split( );if(r.length===0)throw new Error(template "/${e0}/${e1}/${e2}" is empty!);return r};var Qu=(...e)=>{let t=e.flatMap(n=>{if(typeof n=="string")return[$a(n)];if(Array.isArray(n.type))return[gv(n.type)];switch(n.type){case"text":return[$a(n.text)];case"group":{let o=Qu(...n.items);return o?[o]:[]}default:return[gv(n.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},$a=e=>{let t=document.createElement("span");return t.classList.add("item"),t.append(e),t},gv=e=>{if(Array.isArray(e)){let t=document.createElement("span");t.classList.add("fa-stack");let r=Ju(e[0]);r.classList.add("fa-stack-1x");let n=Ju(e[1]);return n.classList.add("fa-stack-1x"),t.append(r,n),$a(t)}return $a(Ju(e))},Ju=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:Zu,selection:ep}=Pt(),bv=e=>{let{className:t,display:r,onClick:n,context:o="page"}=e,s=document.createElement("div");t&&s.classList.add(t),yv(o)||(s.style.display="none");let i=(...l)=>{if(l.length===1&&l[0]===""){s.style.display="none";return}s.textContent="";let p=Qu(...l);p&&s.append(p)},a=typeof r=="function"?r({cursor:Zu,selection:ep}):r;return i(...Array.isArray(a)?a:[a]),s.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),n({cursor:Zu,selection:ep,setDisplay:i})}),{status:s,context:o,update:()=>{if(yv(o)?s.removeAttribute("style"):s.style.display="none",typeof r=="function"){let l=r({cursor:Zu,selection:ep});i(...Array.isArray(l)?l:[l])}}}},yv=e=>e!=="stream"?scrapbox.Layout===e:scrapbox.Layout==="list"&&location.pathname.startsWith("/stream");var xv=()=>{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 tp=new Set,{cursor:QO,selection:ZO}=Pt(),eN=xv();var Ht=e=>{let t=bv(e);return tp.add(t),eN.append(t.status),()=>{t.status.remove(),tp.delete(t)}},rp=()=>{for(let{update:e}of tp)e()};QO.addChangeListener(()=>rp());ZO.addChangeListener(()=>rp());scrapbox.addListener("layout:changed",rp);var wv=async(e,t)=>{try{let r=t.getSelectedText()||Je(e.getPosition().line);if(!r)return;await navigator.clipboard.writeText(r)}catch(r){console.error(r),alert(Faild to copy:
${JSON.stringify(r)})}},vv=async(e,t)=>{try{let r=t.hasSelection(),n=r?t.getRange().start.line:e.getPosition().line,o=r?t.getSelectedText():Je(n);if(!o)return;await navigator.clipboard.writeText(o),r||t.setRange({start:{line:n,char:0},end:{line:n,char:o.length}}),e.focus(),He("Delete")}catch(r){console.error(r),alert(Faild to cut:
${JSON.stringify(r)})}},kv=async e=>{try{let t=await navigator.clipboard.readText();if(!t)return;e.focus(),await Qe(t)}catch(t){console.error(t),alert(Faild to paste:
${JSON.stringify(t)})}},Ev=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=Lr();t.hasFocus||(e.preventDefault(),t.focus())});var np=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")}},Tv=new np;var Pv=e=>new Promise(t=>setTimeout(t,e));async function Yt(e,{wait:t=1}={}){let r=Tv.textInput;r.focus(),r.value=e;let n=document.createEvent("UIEvent");n.initEvent("input",!0,!1),r.dispatchEvent(n),await Pv(t)}if(kr()){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:()=>Yt(ht(new Date,"#yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD HH:mm:ss ",onClick:()=>Yt(ht(new Date,"yyyy-MM-dd HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"YYYY-MM-DD",onClick:()=>Yt(ht(new Date,"yyyy-MM-dd"))}),scrapbox.PageMenu(e).addItem({title:"HH:mm:ss ",onClick:()=>Yt(ht(new Date,"HH:mm:ss "))}),scrapbox.PageMenu(e).addItem({title:"⬜",onClick:()=>Yt("⬜")}),scrapbox.PageMenu(e).addItem({title:"🚧",onClick:()=>Yt("🚧")}),scrapbox.PageMenu(e).addItem({title:"⌛",onClick:()=>Yt("⌛")}),scrapbox.PageMenu(e).addItem({title:"📝",onClick:()=>Yt("📝")}),scrapbox.PageMenu(e).addItem({title:"✅",onClick:()=>Yt("✅")}),scrapbox.PageMenu(e).addItem({title:"❌",onClick:()=>Yt("❌")})}scrapbox.PageMenu.addItem({title:"Open kakeru",image:"https://i.kakeru.app/15c3b1a40b6b3c2ebd68f33f4c86b3f6-opaque.png",onClick:()=>window.open("https://kakeru.app")});async function Rv(e,{from:t,to:r,merge:n}){if(t===r)return{success:!0,dup:!1};let o=await Nt(t,e);if(W(o))return{success:!1,at:"from",name:ee(o).name,message:ee(o).message};let s=B(o);if(!s.persistent)return{success:!1,at:"from",name:"EmptyPageError",message:"The request page is empty."};let i=await Nt(r,e);if(W(i))return{success:!1,at:"to",name:ee(i).name,message:ee(i).message};let a=B(o);return a.persistent&&!n?{success:!1,at:"to",name:"NoEmptyPageError",message:The same page already exists in "/${r}"}:(await me(r,e,c=>[...c,...s.lines.slice(1)].map(l=>l.text)),await qd(t,e),{success:!0,dup:a.persistent})}var op=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:n,dispose:o}=Re();n({type:"spinner"},{type:"text",text:/${t}/${e} → /${r}/${e}});try{let s=await Rv(e,{from:t,to:r,merge:!0});if(!s.success){n({type:"exclamation-triangle"},{type:"text",text:${s.name} ${s.message}});return}return n({type:"check-circle"},{type:"text",text:Moved ${s.dup?"and merged ":""}to "/${r}/${e}".}),https://scrapbox.io/${r}/${ue(e)}}catch(s){n({type:"exclamation-triangle"},{type:"text",text:s instanceof Error?${s.name} ${s.message}:"Unknown error! (see developper console)"}),console.error(s)}finally{setTimeout(()=>o(),1e3)}};scrapbox.PageMenu.addItem({title:"Transport",onClick:async()=>{await op()}});scrapbox.PageMenu.addItem({title:"Transport and Open",onClick:async()=>{let e=await op();e&&window.open(e)}});var sp=e=>e.replace(/[\[\]]/g,"").replace(/\s/g," "),_n=e=>${e}.padStart(2,"0"),Sv=e=>${e.getFullYear()}-${_n(e.getMonth()+1)}-${_n(e.getDate())} ${_n(e.getHours())}:${_n(e.getMinutes())}:${_n(e.getSeconds())},ip=e=>${e.getFullYear()}-${_n(e.getMonth()+1)}-${_n(e.getDate())};var _v=async(e,t,r,n)=>{let{render:o,dispose:s}=Re(),i=[],a=[];for(let l of tN(r)){if(l.type==="line"){i.push(${sp(l.text)}~@${ip(new Date)});continue}let p=${sp(l.lines0)}~@${ip(new Date)};a.push([p,...l.lines.slice(1),"",#${Sv(new Date)}]),i.push(${p})}let c=B(await ze(n?.socket));try{o({type:"spinner"},{type:"text",text:Adding ${i.length} items...}),await me(e,t,l=>{let p=l.map(f=>f.text),u=p.flatMap((f,d)=>f.trim()==="[/icons/hr.icon]"?[d]:[]).pop()??-1;return u<0?[...p,...i]:[...p.slice(0,u),...i,...p.slice(u)]},{socket:c}),o({type:"spinner"},{type:"text",text:Create ${a.length} pages...}),await Promise.all(a.map(l=>me(e,l[0],p=>[p[0].text,...p.slice(1).map(u=>u.text),...l.slice(1)],{socket:c}))),o({type:"check-circle"},{type:"text",text:"Added to the inbox."})}catch(l){o({type:"exclamation-triangle"},{type:"text",text:"Failed to add (see console). Write directory instead."}),console.error(l),So(e,t,[...i,...a].join( ))}finally{let l=Ee(1e3);n?.socket&&await nt(c),await l,s()}};function*tN(e){let t=0;for(;t<e.length;){let r=lh(t,e);if(r===0){yield{type:"line",text:e[t].trim()},t++;continue}let n=Dr(e[t]);yield{type:"block",lines:e.slice(t,t+r+1).map(o=>o.slice(n))},t+=r+1}}var Lv=async(e,t)=>{let r=window.prompt("Type all you think of","");if(!r||r.trim()==="")return;let n=r.trim().split(/\s+/);await _v(e,t,n)};var rN="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)}/${rN},{execute:n}=await import(r);n()}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}))}});var us=e=>oo(...N(()=>{let t={tasks:[],errors:[],load:async()=>{},loading:!1},r=Promise.resolve();return[n=>{t.load=()=>(r=(async()=>{await r,t={...t,loading:!0},n(),await xa(e,60),t={...t,loading:!1},n()})(),r);let o=()=>{r=(async()=>{await r,t={...t,loading:!0},n();let[s,i]=nN(await so(e));t={...t,tasks:s,errors:i,loading:!1},n()})()};return o(),ba(e,o)},()=>t]},e)),nN=e=>{let t=new Set,r=[],n=[];for(let{title:o,links:s,project:i}of e)for(let a of[o,...s]){let c=re(a);if(t.has(c))continue;t.add(c);let l=At(a);if(l){if(W(l)){n.push({project:i,title:a,...ee(l)});continue}r.push({project:i,title:a,...B(l)})}}return[r,n]};var Fa=()=>{let[e,t]=_r(oN,{isOpen:!1,prevOverflowY:""}),r=Ye(null),n=A(()=>{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}})},[]),o=A(()=>{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=N(()=>{let i;return a=>{if(!a){i?.(),r.current=null;return}let c=new AbortController;a.addEventListener("cancel",o,{signal:c.signal}),a.addEventListener("click",l=>{if(l.target!==l.currentTarget){l.stopPropagation();return}o()},{signal:c.signal}),i=()=>{c.abort()},r.current=a}},[o]);return{isOpen:e.isOpen,open:n,close:o,ref:s}},oN=(e,t)=>{let r=t(e);return e.isOpen===r.isOpen&&e.prevOverflowY===r.prevOverflowY?e:r.isOpen?r:{isOpen:!1}};var ps=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 mo=({text:e,title:t})=>{let[r,n]=X(""),o=A(async s=>{s.preventDefault(),s.stopPropagation();try{await navigator.clipboard.writeText(e),n("Copied"),await Ee(1e3),n("")}catch(i){alert(Failed to copy the code block
Error:${i instanceof Error?i.message:i}),console.error(i)}},[e]);return m("button",{className:"copy",title:t??"Copy",onClick:o,children:r})};var sN=60*60*24*1e3,Cv=(e,t)=>{let r=de(e.refDate),n=(t.getTime()-r.getTime())/sN;switch(r.setHours(0),r.setMinutes(0),e.status){case"done":return-1/0;case"deadline":return n/(e.speed??1);case"todo":return Math.min(n/(e.speed??1),0);case"note":return t.getTime()<r.getTime()?-1/0:-n/(e.speed??1);case"up-down":{let o=e.speed??30;return o*(-1+Math.cos(Math.PI*2*n/o))}}};var Nv=(e,t)=>{if(t.score!==e.score)return t.score-e.score;let r=Ov(e.freshness),n=Ov(t.freshness);return r!==n?n-r:Dt(rr(e),rr(t))?-1:1},Ov=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 bt=e=>${e.getFullYear()}-${Gt(e.getMonth()+1)}-${Gt(e.getDate())},ds=e=>{let[t,r,n]=e.split("-").map(o=>parseInt(o,10));return{year:t,month:r,date:n}},fs=e=>${fi(e)}-w${Gt(Bn(e))},ja=e=>{let[t,r]=e.split("-w").map(n=>parseInt(n,10));return pt(Qc(new Date(t,0,1),r))};var ms=({loading:e,onClick:t})=>e?m("div",{children:m("i",{className:"fa fa-spinner"})}):m("button",{className:"navi reload",onClick:t,children:""});var ho=()=>{let[e,t]=X(new Date);return te(()=>{let r=setInterval(()=>t(new Date),6e4);return()=>{clearInterval(r)}},[]),e};var Mv=e=>{switch(e){case"todo":return"ToDo";case"note":return"覚書";case"deadline":return"締切";case"up-down":return"浮遊";case"done":return"完了"}};var Iv=(e,t)=>new URL(/${e.project}/${ue(e.title)},t??location.href);var Ua=({children:e,project:t,title:r,className:n,...o})=>m("a",{...o,className:[n??"","page-link"].join(" "),type:"link",href:Iv({project:t,title:r}).pathname,...t===scrapbox.Project.name?{rel:"route"}:{rel:"noopener noreferrer",target:"_blank"},children:e});var Dv=({action:e,pActions:t})=>{let r=N(()=>Mv(e.freshness.status),[e.freshness.status]),n=N(()=>er(rr(e)).slice(11)||" ",[rr(e)]),o=N(()=>jo(e),[e]),s=Math.floor(Math.round(e.score)/7),i=ho(),a=N(()=>e.executed!==void 0&&nn(Nr(de(e.executed.start),e.executed.duration),i),[e.executed?.start,e.executed?.duration,i]),c=N(()=>[...t,e].map(l=>${l.raw}).join( ),[t,e]);return m("li",{"data-type":e.freshness.status,"data-freshness":e.score.toFixed(0),"data-level":s,...s<0?{style:{opacity:iN(e).toFixed(2)}}:{},children:[m(mo,{text:c,title:"ここまでコピー"}),m("span",{className:"label type",children:r}),m("i",{className:label far fa-fw${a?" fa-bookmark":""}}),m("span",{className:"label freshness",children:e.score.toFixed(0)}),m("time",{className:"label start",children:n}),m("span",{className:"label duration",children:[o,"m"]}),m(Ua,{project:e.project,title:e.raw,children:e.name})]})},iN=e=>Math.max(.8*Math.exp(Math.log(8/7)/7*e.score),.05);var Av=(e=bt(new Date))=>{let[t,r]=X(e),n=A(()=>{r(s=>{switch(s){case"errors":return"expired";case"expired":return bt(new Date);default:{let i=de(ds(s));return i.setDate(i.getDate()+1),bt(i)}}})},[]),o=A(()=>{r(s=>{let i=bt(new Date);switch(s){case"errors":return"errors";case"expired":return"errors";case i:return"expired";default:{let a=de(ds(s));return a.setDate(a.getDate()-1),bt(a)}}})},[]);return{pageNo:t,next:n,prev:o}};var Ba=(e,t)=>te(()=>(scrapbox.on(e,t),()=>scrapbox.off(e,t)),[]);var hs=(e,t)=>{let r=Ye({...t});te(()=>(Object.assign(r.current,t),()=>{for(let n of Object.keys(t))delete r.current[n]}),[...Object.keys(t)].sort().map(n=>t[n])),te(()=>{e(r.current)},[e])};var $v=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(n=>ut(m(aN,{getController:n,projects:e}),r))},aN=({getController:e,projects:t})=>{let{tasks:r,errors:n,load:o,loading:s}=us(t),{pageNo:i,next:a,prev:c}=Av(),l=N(()=>{if(i==="errors")return n.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=>!tr(y)&&Dt(yh(y),yt(g))&&y.freshness===void 0&&y.recurrence===void 0?[{...y,score:0,freshness:{refDate:y.executed.start,status:"todo"}}]:[]).sort((y,w)=>Dt(rr(y),rr(w))?-1:0)}let h=de(ds(i));return r.flatMap(g=>{if(!g.freshness)return[];if(Ar(g))return[];let y=Cv(g.freshness,h);return y>-999?[{...g,score:y}]:[]}).sort(Nv)},[r,n,i]),{ref:p,open:u,close:f}=Fa();hs(e,{open:u,close:f});let d=N(()=>[i,...l.map(h=> ${h.raw})].join( ),[l,i]);return Ba("page:changed",f),m(Y,{children:[m("style",{children:ps}),m("dialog",{ref:p,children:[m("div",{className:"controller",children:[m(mo,{text:d,title:"Copy All Tasks"}),m("span",{children:i}),m("button",{className:"navi left",onClick:c,children:""}),m("button",{className:"navi right",onClick:a,children:""}),m(ms,{loading:s,onClick:o}),m("button",{className:"close",onClick:f,children:""})]}),m("ul",{className:"result task-list","data-page-no":i,children:l.map((h,g)=>m(Dv,{action:h,pActions:l.slice(0,g)},h.raw))})]})]})};var Wa=(e,t)=>/${e}/${re(t)},gs=new Map,ap=new Map,Fv=(e,t)=>{gs.set(e,t);for(let r of ap.get(e)??[])r(t)},Ha=()=>{Ln!==void 0&&(clearInterval(Ln),Ln=void 0);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Wa(e,t);if(!gs.has(r))return;let n=xt().map(o=>o.text);Ln=setInterval(()=>{re(t)===re(n[0])&&(Fv(r,n),Ln!==void 0&&(clearInterval(Ln),Ln=void 0))},1e3)},Ln;scrapbox.on("page:changed",()=>{scrapbox.off("lines:changed",Ha);let e=scrapbox.Project.name,t=scrapbox.Page.title??"",r=Wa(e,t);gs.has(r)&&scrapbox.on("lines:changed",Ha)});var cN=(e,t)=>{let r=Wa(e,t),n=gs.get(r);return n||(gs.set(r,[]),Nt(e,t).then(o=>{if(W(o))return[];let s=B(o).lines.map(i=>i.text);Fv(r,s),t===scrapbox.Page.title&&!scrapbox.listeners("lines:changed").includes(Ha)&&scrapbox.on("lines:changed",Ha)})),n??[]},jv=(e,t)=>{let[r,n]=X(cN(e,t));return te(()=>{let o=Wa(e,t),s=ap.get(o)??new Set;return s.add(n),ap.set(o,s),()=>{s.delete(n)}},[e,t]),r};var cp=e=>e.duration===void 0?void 0:yt(Nr(de(e.start),e.duration)),lp=(e,t)=>{let r=de(e.start),n=t.getTime(),o=Math.round((n-r.getTime())/(60*1e3));if(o<=0)return[void 0,e];if(e.duration<=o)return[e,void 0];let s={start:e.start,duration:o};return[s,{start:cp(s),duration:e.duration-o}]};var Cn=e=>"title"in e,lN=e=>e.record?.duration!==void 0,Uv=(e,t)=>Cn(e)&&e.status==="done"?e.status:lN(e)?Cn(e)&&e.executed?Dt(yt(t),e.executed.start)?"moved":"expired":"done":Dt(cp(e.plan),yt(t))?Cn(e)?"expired":"done":"undone";var Bv=(e,t)=>{let r=At(e.title.slice(1,-1));if(!e.plan.start)return;let n={name:r&&Pr(r)?B(r).name:e.title,plan:{start:yt(e.plan.start),duration:(e.plan.duration??0)/60}};if(e.record.start&&(n.record={start:yt(e.record.start)},e.record.end&&(n.record.duration=Vc(e.record.end,e.record.start))),!r||W(r))return n;let o=B(r),s={...n,title:o.raw,project:t};return o.freshness&&(s.status=o.freshness.status),tr(o)||(s.executed=o.executed),s},up=(e,t)=>{let r=gi(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 Hv=(e,t,r)=>{let n=[pp(e,mr(t,1),r),pp(e,t,r),pp(e,We(t,1),r)],o=N(()=>n.flat(),n);return N(()=>{let s=Un(t),i=Gm(t);return o.flatMap(a=>{let[,c]=lp(a.plan,s);if(!c)return[];let[l]=lp(c,i);if(!l)return[];let{plan:p,...u}=a;return[{plan:l,...u}]}).sort((a,c)=>Dt(a.plan.start,c.plan.start)?-1:0)},[o,t])},pp=(e,t,r)=>{let n=jv(e,Ir(t)),o=N(()=>pN(n,e),[n,e]);return N(()=>o.length!==0?o:uN(t,r),[o,t,r])},uN=(e,t)=>t.flatMap(r=>{if(r.freshness?.status==="done")return[];if(tr(r))return[];if(Ar(r)){let o=hi(r,e);return o?[up(o,r.project)]:[]}let n=de(r.executed.start);return gt(n,e)?[up(r,r.project)]:[]}),pN=(e,t)=>{let r=[];for(let n of on(e)){if(Mr(n))continue;let o=Bv(n,t);o&&r.push(o)}return r};var Wv=({event:e})=>{let t=N(()=>e.plan.start.hours+e.plan.start.minutes/60,[e.plan.start]),r=N(()=>--start: ${t}; --duration: ${e.plan.duration};,[t,e.plan.duration]),n=ho(),o=N(()=>Uv(e,n),[e,n]);return Cn(e)?m(Ua,{className:"event","data-status":o,style:r,title:e.title,project:e.project,children:e.name}):m("div",{className:"event","data-status":o,title:e.name,style:r,children:e.name})};var qv=({project:e,date:t,tasks:r})=>{let n=Hv(e,t,r),o=N(()=>n.flatMap(a=>Cn(a)?[${a.title}]:[]).join( ),[n]),s=ho(),i=N(()=>gt(s,t)?m("div",{className:"indicator",style:--start: ${Xm(s)+Jm(s)/60}}):m(Y,{}),[s,t]);return m("div",{className:"timeline",role:"gridcell",children:[n.map(a=>m(Wv,{event:a},a.name)),i,m(mo,{text:o})]})};var dp=({dateList:e,tasks:t,project:r,hasColumn:n})=>m("div",{className:"timeline-wrap",role:"grid",children:[(n??!0)&&m("div",{className:"column-header",role:"row",children:e.map(o=>m("div",{className:"cell",role:"columnheader",children:m("h2",{children:Vm(o)})},bt(o)))}),m("div",{className:"week-container",role:"presentation",children:m("div",{className:"week",role:"presentation",children:[m("div",{className:"borders",children:[...Array(24).keys()].map(o=>m("div",{className:"border","data-time":${Gt(o)}:00},o))}),e.map(o=>m(qv,{project:r,date:o,tasks:t},bt(o)))]})})]});var fp=(e,t,r)=>{let[n,o]=X(e),s=A(()=>o(t),[t]),i=A(()=>o(r),[t]),a=A(c=>o(c),[]);return{pageNo:n,next:s,prev:i,jump:a}};var zv=e=>{let t=Ye(new Set),[r,n]=X(e),o=A(()=>{for(let l of t.current)l()},[]),s=A(()=>{n(!0),o()},[]),i=A(()=>n(!1),[]),a=A(()=>n(l=>(l||o(),!l)),[]),c=A(l=>(t.current.add(l),()=>t.current.delete(l)),[]);return{isOpen:r,open:s,close:i,toggle:a,onOpen:c}};var Yv=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(n=>ut(m(dN,{getController:n,projects:e,mainProject:e[0]}),r))},Vv=(e,t)=>{let r=document.createElement("div");r.dataset.userscriptName="takker-scheduler/timeline-wedget";let n=r.attachShadow({mode:"open"});return document.body.append(r),new Promise(o=>ut(m(fN,{getController:o,projects:e,mainProject:e[0],open:t}),n))},Gv=!1,dN=({getController:e,projects:t,mainProject:r})=>{let{tasks:n,load:o,loading:s}=us(t),{pageNo:i,next:a,prev:c,jump:l}=fp(fs(new Date),mN,hN),p=N(()=>{let y=ja(i);return[0,1,2,3,4,5,6].map(w=>We(y,w))},[i]),{ref:u,open:f,close:d,isOpen:h}=Fa();Gv||=h,hs(e,{open:f,close:d,isOpen:h}),Ba("page:changed",d);let g=A(()=>l(fs(new Date)),[l]);return m(Y,{children:[m("style",{children:ps}),m("dialog",{ref:u,children:[m("div",{className:"controller",children:[m("span",{children:i}),m("button",{className:"navi left",onClick:c,children:""}),m("button",{className:"navi right",onClick:a,children:""}),m("button",{className:"today",onClick:g,children:""}),m(ms,{loading:s,onClick:o}),m("button",{className:"close",onClick:d,children:""})]}),Gv&&m("div",{ref:Xv,className:"result scheduler","data-page-no":i,children:m(dp,{dateList:p,tasks:n,project:r})})]})]})},Kv=!1,fN=({projects:e,mainProject:t,getController:r,open:n})=>{let{tasks:o,load:s,loading:i}=us(e),{pageNo:a,next:c,prev:l,jump:p}=fp(new Date,gN,yN),u=N(()=>[a],[a]),f=A(()=>p(new Date),[p]),{isOpen:d,open:h,close:g}=zv(n);return Kv||=d,hs(r,{open:h,close:g,isOpen:d}),m(Y,{children:[m("style",{children:ps}),Kv&&m("div",{className:wedget${d?" open":""},ref:Xv,children:[m("div",{className:"controller",children:[m("span",{children:bt(a)}),m("button",{className:"navi left",onClick:l,children:""}),m("button",{className:"navi right",onClick:c,children:""}),m("button",{className:"today",onClick:f,children:""}),m(ms,{loading:i,onClick:s})]}),m(dp,{dateList:u,tasks:o,project:t,hasColumn:!1})]})]})},mN=e=>fs(pi(ja(e),1)),hN=e=>fs(rh(ja(e),1)),gN=e=>We(e,1),yN=e=>mr(e,1),Xv=e=>{let t=e?.getElementsByClassName?.("indicator")?.[0];if(!t)return;let r=globalThis.scrollY;t.scrollIntoView({block:"center"}),globalThis.scroll(0,r)};ff({project:"takker-dist"});xm().then(e=>{scrapbox.PageMenu.addItem({title:"Fulltext Search",onClick:()=>{e.toggle()}})});var bN="https://scrapbox.io/files/67344295032adf96d1e4c276.wasm",xN="/api/code/takker-dist/for-any-project-min/esbuild-worker.js";(async()=>{let e=new Request(bN),t=await Fn(e);t||(t=await fetch(e),await ti(e,t)),await Ib(await WebAssembly.compileStreaming(t),xN)})();(async()=>{let e=[scrapbox.Project.name,"takker","takker-memex","takker-books","takker-private","villagepump","hub","arpla","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"],t=await $x({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","概要と参加方法"]].map(([o,s])=>[o,https://scrapbox.io/api/pages/${o}/${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":"⿻"},enableSelfProjectOnStart:!0}),r=o=>{o.preventDefault(),o.stopPropagation()},n=()=>document.querySelector(".line .popup-menu")!==null;cl.bind({"<Tab>":o=>{n()||t.selectNext?.({cyclic:!0})&&r(o)},"<S-Tab>":o=>{n()||t.selectPrev?.({cyclic:!0})&&r(o)},"<Enter>":o=>{n()||t.confirm?.()&&r(o)},"<Esc>":o=>{n()||t.cancel?.()&&r(o)}})})();Bx({previewers:[{when:/(?:^|\.)svg$/,preview:Hx},{when:/(?:^|\.)glsl$/,preview:ww},{when:/(?:^|\.)(?:plantuml|puml|pu)$/,preview:Ew},{when:/(?:^|\.)tikz\(tex\)$/,preview:Pw("/api/code/takker-dist/for-any-project-min/tex-worker.js","https://scrapbox.io/files/65d1645c19cd8e002433c3df")}]});hv("takker",["takker","振り返り(takker-workflow@0.0.1)のtemplate","txt"],["takker","1週間の振り返り(takker-workflow@0.0.1)のtemplate","txt"]);kr()&&(Ht({display:{type:"caret-left"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Js():Ks()}}),Ht({display:{type:"caret-right"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Xs():Gs()}}),Ht({display:{type:"caret-up"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Qs():Ys()}}),Ht({display:{type:"caret-down"},onClick:({cursor:e,selection:t})=>{e.focus(),t.getSelectedText()===""?Zs():Vs()}}),Ht({display:{type:"copy"},onClick:async({cursor:e,selection:t})=>await wv(e,t)}),Ht({display:{type:"cut"},onClick:async({cursor:e,selection:t})=>await vv(e,t)}),Ht({display:{type:"clipboard"},onClick:async({cursor:e})=>await kv(e)}),Ht({display:{type:"undo"},onClick:()=>rm()}),Ht({display:{type:"redo"},onClick:()=>nm()}),Ht({display:({cursor:e})=>e.getVisible()&&e.hasFocus&&e.visiblePopupMenu?{type:["i-cursor","slash"]}:{type:"i-cursor"},onClick:({cursor:e})=>Ev(e)}));if(kr()&&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:cn}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>un({from:{project:scrapbox.Project.name,title:scrapbox.Page.title},to:"takker-memex"})})}if(kr()){let e="New Page",t=[fn,mn,hn];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&&fr({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&&fr({project:r,mode:"self",hooks:t})?.()}})}scrapbox.PageMenu.addMenu({title:"Add to inbox",image:"https://img.icons8.com/ios/180/FFFFFF/inbox.png",onClick:()=>Lv("takker-memex","メモ帳")});(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= 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;
}
opacity: 0;
},document.head.append(r);let n=["takker-memex","takker"],{open:o}=await $v(n);scrapbox.PageMenu.addMenu({title:e,image:"/assets/img/favicon/apple-touch-icon.png",onClick:o});let s=await Yv(n);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 Vv(n,a[c]),p=()=>{a[c]=!l.isOpen,l.isOpen?l.close():l.open?.(),localStorage.setItem(i,JSON.stringify(a))};kr()?Ht({display:{type:"calendar"},onClick:p}):scrapbox.PageMenu.addItem({title:"toggle wedget",onClick:p})}})();var Jv=e=>String(e).padStart(2,"0"),Qv=e=>${e.getFullYear()}-${Jv(e.getMonth()+1)}-${Jv(e.getDate())};for(let e of document.getElementsByClassName("new-button")){let t=#${Qv(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=io.parse(e,{hasTitle:!1});if(console.log("Parserd text:"),console.log(t),navigator.clipboard){let r=wN(t).join(`
);console.log(r),navigator.clipboard.writeText(r).catch(n=>console.log(n)),console.log("Copied.")}}});function wN(e){let t=Math.min(...e.map(o=>o.indent)),r=t,n=["<p>"];for(let o of e.filter(s=>s.type==="line")){let s=o.indent-r;s<0&&n.push(...[...Array(-s)].map(a=>"</ul>")),s>0&&n.push(...[...Array(s)].map(a=>'<ul style="margin-top: 5px;margin-bottom: 5px;">'));let i=o.nodes.map(a=>qa(a)).join("");o.indent>t?n.push(<li>${i}</li>):n.push(${i}<br/>),r=o.indent}return n.push(...[...Array(r-t)].map(o=>"</ul>")),n.push("</p>"),n}function qa(e){switch(e.type){case"quote":return<span style="
font-style: italic;
background-color: rgba(128,128,128,0.1);
display: block;
height: 1.3em;
vertical-align: top;" src="${t}" alt="${n}" /></a>;case"strongIcon":return"";case"formula":return\\( ${e.formula} \\);case"helpfeel":return"";case"decoration":let o=e.nodes.map(s=>qa(s)).join("");return e.decos.includes("*-4")&&(o=<h4>${o}</h4>),e.decos.includes("*-3")&&(o=<h5>${o}</h5>),e.decos.includes("*-2")&&(o=<h6>${o}</h6>),e.decos.includes("*-1")&&(o=<strong>${o}</strong>),e.decos.includes("/")&&(o=<i>${o}</i>),e.decos.includes("-")&&(o=<strike>${o}</strike>),e.decos.includes("!")&&(o=<pre>${o}</pre>),o;case"strong":return<strong>${e.nodes.map(s=>qa(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(kr()){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:el}),scrapbox.PageMenu(e).addItem({title:"Add task",image:"https://img.icons8.com/ios/180/FFFFFF/plus-math.png",onClick:No}),scrapbox.PageMenu(e).addItem({title:"Start task",image:"https://img.icons8.com/ios/180/FFFFFF/start--v1.png",onClick:sn}),scrapbox.PageMenu(e).addItem({title:"End task",image:"https://img.icons8.com/ios/180/FFFFFF/stop-squared.png",onClick:hr}),scrapbox.PageMenu(e).addItem({title:"Posteriori end task",image:"https://img.icons8.com/ios/180/FFFFFF/end--v1.png",onClick:Mo}),scrapbox.PageMenu(e).addItem({title:"Book starting",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:async()=>{let[t,r]=vN(),n=zt().slice(t,r+1).map(o=>{let s=o.text,i=o.text.match(/\[([^\]]+)\]/)?.[1];if(!i)return s;let a=At(i);if(!a||!a.ok)return s;let c=a.value;if(c.freshness?.status==="done")return s;let l=dn(c);return l.title=${i},l?he(l):s}).join( );await it(t,r,n),await cn()}}),scrapbox.PageMenu(e).addItem({title:"Walk a day",image:"https://img.icons8.com/ios/180/FFFFFF/plus-1day.png",onClick:()=>Io()}),scrapbox.PageMenu(e).addItem({title:"Move today",image:"https://img.icons8.com/ios/180/FFFFFF/date-to.png",onClick:()=>Do()}),scrapbox.PageMenu(e).addItem({title:"Format",image:"https://img.icons8.com/ios/180/FFFFFF/sort-by-start-date.png",onClick:()=>$o(scrapbox.Project.name,scrapbox.Page.title)}),scrapbox.PageMenu(e).addItem({title:"Transport",onClick:()=>un({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 vN=()=>{let{selectionRange:{start:e,end:t},selectedText:r,position:n}=Le();return r===""?[n.line,n.line]:e.line>t.line?[t.line,e.line]:[e.line,t.line]};var Zv="scrapbox-episopass",za=!1;scrapbox.PopupMenu.addButton({title:e=>za?"remove EP":/https:\/\/scrapbox\.io\/files\/\w+\.html/.test(e)?"run EP":"",onClick:async e=>{if(document.getElementById(Zv)?.remove(),za){za=!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 n=await(await fetch(t)).text();if(!n.includes("<title>EpisoPass</title>"))return;let o=new Blob([n],{type:"text/html"}),s=URL.createObjectURL(o);document.getElementsByClassName("cursor-line")[0].insertAdjacentHTML("beforeend",<iframe id="${Zv}" src="${s}" width="800" height="400"></iframe>),za=!0;return}catch(r){console.error("Failed to load an EpisoPass html: ",r)}}});var ek="takker-memex",tk=async()=>{if(scrapbox.Project.name!==ek)return()=>{};let e=scrapbox.Project.pages;await new Promise(i=>{let a=setInterval(()=>{if(e.length===0){e=scrapbox.Project.pages;return}clearInterval(a),i()},2e3)});let t=new Date(2023,0,24),r=async()=>{let i=new Date,c=di({start:t,end:i}).filter(f=>{let d=Ir(f),h=e.find(g=>g.title===d);return!h||!h.exists});if(c.length===0)return;let{render:l,dispose:p}=Re(),u;try{l({type:"spinner"},{type:"text",text:load tasks for ${c.length} diary pages});let f=new Map,d=new Set,h=c.map(w=>bt(w));for(let{title:w,links:R,project:E}of await so(["takker","takker-memex"]))for(let b of[w,...R]){let k=At(b);if(!k)continue;if(W(k)){let{name:C,message:O}=ee(k);console.error(/${E}/${b}: ${C} ${O});continue}let v=re(b);if(d.has(v))continue;d.add(v);let L=B(k);if(L.freshness?.status!=="done")for(let C of c){let O=dn(L,C);if(!O)continue;let S=bt(O.base);h.includes(S)&&(f.set(S,[...f.get(S)??[],O]),Ar(L))}}let g=await ze();if(W(g))throw ee(g);u=B(g);let y=0;l({type:"spinner"},{type:"text",text:create 0/${c.length} diary pages...});for(let w of c){let R=Ir(w),E=f.get(bt(w))?.map?.(v=>he(v))??[],b=#${wt(w,"yyyy-MM-dd")},k=#${wt(w,"yyyy-MM-dd HH:mm:ss")};await me(ek,R,(v,{persistent:L})=>{if(L)return;let C=[...v.map(O=>O.text),...E];return C.some(O=>O.includes(b))?ln(C):ln([...C,k])},{socket:u}),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.}),t=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{u&&await nt(u),await Ee(1e3),p()}},n=r(),o=new Date,s=setInterval(()=>{let i=new Date;gt(o,i)||(o=i,n.then(()=>n=r()))},1e4);return()=>(clearTimeout(s),n)};tk();export{Ht as addButton,Qe as insertText,cl 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.
*/
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: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)}.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:"⬜"}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}}.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){.page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}.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}}.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){.page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}.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}}.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){.page-column{--page-column-columns: minmax(200px, 960px) min-content;--page-column-areas: "page menu"}}.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}