import-dev
code:script.js
await import("../../takker-dist/import-devにbackgroundでテストコードを貼り付けるUserScript/script.js");
await import("./mod.js");
code:mod.js
var Fr=Object.defineProperty;var vr=(e,t)=>{for(var r in t)Fr(e,r,{get:tr,enumerable:!0})};function de(e){return typeof e=="number"}function Y(e){return typeof e=="string"}function ie(e){return typeof e>"u"}var Et=(e,t)=>{if(!(e instanceof HTMLDivElement))throw new TypeError("${t}" must be HTMLDivElememt but actual is "${e}")};var je=()=>Sr(document.getElementsByClassName("lines").item(0),"div.lines");var Sr=(e,t)=>{if(e)return Et(e,t),e};var ae=()=>{let e=je();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 et.return.stateNode.props.lines};var Tt=e=>{if(ie(e))return;if(de(e))return Ur(e)?.id;if(Y(e))return e.startsWith("L")?e.slice(1):e;if(e.classList.contains("line"))return e.id.slice(1);let t=e.closest(".line");if(t)return t.id.slice(1)};var Ur=e=>{if(ie(e))return;if(de(e))return ae()e;let t=Tt(e);return t?ae().find(r=>r.id===t):void 0},We=e=>{if(Dr(e))return e;let t=Tt(e);if(ie(t))return t;let r=document.getElementById(L${t});if(!ie(r))return r},Dr=e=>e instanceof HTMLDivElement&&e.classList.contains("line");var qr=Math.pow(10,8)*24*60*60*1e3,va=-qr;var qe=6e4;var Gr=3600;var bt=Gr*24,Sa=bt*7,Vr=bt*365.2425,Kr=Vr/12,Ma=Kr*3,Ge=Symbol.for("constructDateFrom");function b(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Ge in e?eGe(t):e instanceof Date?new e.constructor(t):new Date(t)}function m(e,t){return b(t||e,e)}function _t(e){return t=>{let r=(e?Mathe:Math.trunc)(t);return r===0?0:r}}function kt(e,t){return+m(e)-+m(t)}function Ke(e,t,r){let o=kt(e,t)/qe;return _t(r?.roundingMethod)(o)}function ge(e,t){return+m(e)>+m(t)}var Ot=" must not return ",Zr="transformer",eo="recoverer",to="defaultValue",J=Zr+Ot,j="called with ",X=to+" must not be ",Z=eo+Ot;var ro="Ok",Pt="Err",oo=j+Pt,no=j+ro,so="Carrying E in "+Pt+" instead of throwing it directly. See .cause",Qe="an instance of Error of the current realm.",sd="The thrown value is not "+Qe,id="The contained E should be "+Qe,io="This .cause is not "+Qe;var ye="null",Eh=J+ye,co=j+ye,xh=X+ye,Rh=Z+ye;var Ee="undefined",kh=J+Ee,uo=j+Ee,wh=X+Ee,Oh=Z+Ee;var xe="null or undefined",ee=J+xe,Eo=j+xe,Xe=X+xe,Re=Z+xe;var No=new TextEncoder().encode("0123456789abcdef"),It=new Uint8Array(128).fill(16);No.forEach((e,t)=>Ite=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Ite=t+10);var bo=new TextEncoder().encode("0123456789abcdef"),At=new Uint8Array(128).fill(16);bo.forEach((e,t)=>Ate=t);new TextEncoder().encode("ABCDEF").forEach((e,t)=>Ate=t+10);var G=e=>{let t=e.match(/^(\d{4})-(\d{2})-(\d{2}) (?: {5}|(\d{2}):(\d{2})) (?: {4}|(\d{4})) (?: {8}|(\d{2}):(\d{2}):(\d{2})) (?: {8}|(\d{2}):(\d{2}):(\d{2}))(^\n*)$/);if(!t)return;let,r,o,n,s,i,u,a,h,y,U,Ir,Ar,Cr=t,D={title:Cr,base:new Date(parseInt(r),parseInt(o)-1,parseInt(n)),plan:{},record:{}};if(s){let x=new Date(D.base);x.setHours(parseInt(s)),x.setMinutes(parseInt(i)),D.plan.start=x}if(u&&(D.plan.duration=parseInt(u)*60),a){let x=new Date(D.base);x.setHours(parseInt(a)),x.setMinutes(parseInt(h)),x.setSeconds(parseInt(y)),D.record.start=x}if(U){let x=new Date(D.base);x.setHours(parseInt(U)),x.setMinutes(parseInt(Ir)),x.setSeconds(parseInt(Ar)),D.record.start&&ge(D.record.start,x)&&x.setDate(x.getDate()+1),D.record.end=x}return D};var sb=5*60;function f(e){if(e)return Co(e)}function Co(e){for(var t in f.prototype)et=f.prototypet;return e}f.prototype.on=f.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks"$"+e=this._callbacks"$"+e||[]).push(t),this};f.prototype.once=function(e,t){function r(){this.off(e,r),t.apply(this,arguments)}return r.fn=t,this.on(e,r),this};f.prototype.off=f.prototype.removeListener=f.prototype.removeAllListeners=f.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var r=this._callbacks"$"+e;if(!r)return this;if(arguments.length==1)return delete this._callbacks"$"+e,this;for(var o,n=0;n<r.length;n++)if(o=rn,o===t||o.fn===t){r.splice(n,1);break}return r.length===0&&delete this._callbacks"$"+e,this};f.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),r=this._callbacks"$"+e,o=1;o<arguments.length;o++)to-1=argumentso;if(r){r=r.slice(0);for(var o=0,n=r.length;o<n;++o)ro.apply(this,t)}return this};f.prototype.emitReserved=f.prototype.emit;f.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks"$"+e||[]};f.prototype.hasListeners=function(e){return!!this.listeners(e).length};var H=Object.create(null);H.open="0";H.close="1";H.ping="2";H.pong="3";H.message="4";H.upgrade="5";H.noop="6";var _e=Object.create(null);Object.keys(H).forEach(e=>{_e[He]=e});var rt={type:"error",data:"parser error"},Dt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="object BlobConstructor",Bt=typeof ArrayBuffer=="function",Ht=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ke=({type:e,data:t},r,o)=>Dt&&t instanceof Blob?r?o(t):St(t,o):Bt&&(t instanceof ArrayBuffer||Ht(t))?r?o(t):St(new Blob(t),o):o(He+(t||"")),St=(e,t)=>{let r=new FileReader;return r.onload=function(){let o=r.result.split(",")1;t("b"+(o||""))},r.readAsDataURL(e)};function Mt(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var et;function Fo(e,t){if(Dt&&e.data instanceof Blob)return e.data.arrayBuffer().then(Mt).then(t);if(Bt&&(e.data instanceof ArrayBuffer||Ht(e.data)))return t(Mt(e.data));ke(e,!1,r=>{et||(et=new TextEncoder),t(et.encode(r))})}var Ut="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",pe=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Ut.length;e++)peUt.charCodeAt(e)=e;var vo=e=>{let t=e.length*.75,r=e.length,o,n=0,s,i,u,a;ee.length-1==="="&&(t--,ee.length-2==="="&&t--);let h=new ArrayBuffer(t),y=new Uint8Array(h);for(o=0;o<r;o+=4)s=pee.charCodeAt(o),i=pee.charCodeAt(o+1),u=pee.charCodeAt(o+2),a=pee.charCodeAt(o+3),yn++=s<<2|i>>4,yn++=(i&15)<<4|u>>2,yn++=(u&3)<<6|a&63;return h},So=typeof ArrayBuffer=="function",we=(e,t)=>{if(typeof e!="string")return{type:"message",data:jt(e,t)};let r=e.charAt(0);return r==="b"?{type:"message",data:Mo(e.substring(1),t)}:_er?e.length>1?{type:_er,data:e.substring(1)}:{type:_er}:rt},Mo=(e,t)=>{if(So){let r=vo(e);return jt(r,t)}else return{base64:!0,data:e}},jt=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob(e);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},Wt="",$t=(e,t)=>{let r=e.length,o=new Array(r),n=0;e.forEach((s,i)=>{ke(s,!1,u=>{oi=u,++n===r&&t(o.join(Wt))})})},qt=(e,t)=>{let r=e.split(Wt),o=[];for(let n=0;n<r.length;n++){let s=we(rn,t);if(o.push(s),s.type==="error")break}return o};function Gt(){return new TransformStream({transform(e,t){Fo(e,r=>{let o=r.length,n;if(o<126)n=new Uint8Array(1),new DataView(n.buffer).setUint8(0,o);else if(o<65536){n=new Uint8Array(3);let s=new DataView(n.buffer);s.setUint8(0,126),s.setUint16(1,o)}else{n=new Uint8Array(9);let s=new DataView(n.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(o))}e.data&&typeof e.data!="string"&&(n0|=128),t.enqueue(n),t.enqueue(r)})}})}var tt;function Ne(e){return e.reduce((t,r)=>t+r.length,0)}function be(e,t){if(e0.length===t)return e.shift();let r=new Uint8Array(t),o=0;for(let n=0;n<t;n++)rn=e0o++,o===e0.length&&(e.shift(),o=0);return e.length&&o<e0.length&&(e0=e0.slice(o)),r}function Vt(e,t){tt||(tt=new TextDecoder);let r=[],o=0,n=-1,s=!1;return new TransformStream({transform(i,u){for(r.push(i);;){if(o===0){if(Ne(r)<1)break;let a=be(r,1);s=(a0&128)===128,n=a0&127,n<126?o=3:n===126?o=1:o=2}else if(o===1){if(Ne(r)<2)break;let a=be(r,2);n=new DataView(a.buffer,a.byteOffset,a.length).getUint16(0),o=3}else if(o===2){if(Ne(r)<8)break;let a=be(r,8),h=new DataView(a.buffer,a.byteOffset,a.length),y=h.getUint32(0);if(y>Math.pow(2,21)-1){u.enqueue(rt);break}n=y*Math.pow(2,32)+h.getUint32(4),o=3}else{if(Ne(r)<n)break;let a=be(r,n);u.enqueue(we(s?a:tt.decode(a),t)),o=0}if(n===0||n>e){u.enqueue(rt);break}}}})}var ot=4;var ce=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),F=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Uo="arraybuffer";function Yt(e,...t){return t.reduce((r,o)=>(e.hasOwnProperty(o)&&(ro=eo),r),{})}var Do=F.setTimeout,Bo=F.clearTimeout;function ue(e,t){t.useNativeTimers?(e.setTimeoutFn=Do.bind(F),e.clearTimeoutFn=Bo.bind(F)):(e.setTimeoutFn=F.setTimeout.bind(F),e.clearTimeoutFn=F.clearTimeout.bind(F))}var Ho=1.33;function jo(e){return typeof e=="string"?Wo(e):Math.ceil((e.byteLength||e.size)*Ho)}function Wo(e){let t=0,r=0;for(let o=0,n=e.length;o<n;o++)t=e.charCodeAt(o),t<128?r+=1:t<2048?r+=2:t<55296||t>=57344?r+=3:(o++,r+=4);return r}function zt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function $o(e){let t="";for(let r in e)e.hasOwnProperty(r)&&(t.length&&(t+="&"),t+=encodeURIComponent(r)+"="+encodeURIComponent(er));return t}function qo(e){let t={},r=e.split("&");for(let o=0,n=r.length;o<n;o++){let s=ro.split("=");t[decodeURIComponent(s0)]=decodeURIComponent(s1)}return t}var Go=class extends Error{constructor(e,t,r){super(e),this.description=t,this.context=r,this.type="TransportError"}},it=class extends f{constructor(e){super(),this.writable=!1,ue(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 Go(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=we(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=$o(e);return t.length?"?"+t:""}},Vo=class extends it{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)};qt(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,$t(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=zt()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Qt=!1;try{Qt=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}var Ko=Qt;function Yo(){}var zo=class extends Vo{constructor(e){if(super(e),typeof location<"u"){let t=location.protocol==="https:",r=location.port;r||(r=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||r!==e.port}}doWrite(e,t){let r=this.request({method:"POST",data:e});r.on("success",t),r.on("error",(o,n)=>{this.onError("xhr post error",o,n)})}doPoll(){let e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,r)=>{this.onError("xhr poll error",t,r)}),this.pollXhr=e}},re=class Oe extends f{constructor(t,r,o){super(),this.createRequest=t,ue(this,o),this._opts=o,this._method=o.method||"GET",this._uri=r,this._data=o.data!==void 0?o.data:null,this._create()}_create(){var t;let r=Yt(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");r.xdomain=!!this._opts.xd;let o=this._xhr=this.createRequest(r);try{o.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){o.setDisableHeaderCheck&&o.setDisableHeaderCheck(!0);for(let n in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(n)&&o.setRequestHeader(n,this._opts.extraHeadersn)}}catch{}if(this._method==="POST")try{o.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{o.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(o),"withCredentials"in o&&(o.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(o.timeout=this._opts.requestTimeout),o.onreadystatechange=()=>{var n;o.readyState===3&&((n=this._opts.cookieJar)===null||n===void 0||n.parseCookies(o.getResponseHeader("set-cookie"))),o.readyState===4&&(o.status===200||o.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof o.status=="number"?o.status:0)},0))},o.send(this._data)}catch(n){this.setTimeoutFn(()=>{this._onError(n)},0);return}typeof document<"u"&&(this._index=Oe.requestsCount++,Oe.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=Yo,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete Oe.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()}};re.requestsCount=0;re.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Kt);else if(typeof addEventListener=="function"){let e="onpagehide"in F?"pagehide":"unload";addEventListener(e,Kt,!1)}}function Kt(){for(let e in re.requests)re.requests.hasOwnProperty(e)&&re.requestse.abort()}var Qo=function(){let e=Jt({xdomain:!1});return e&&e.responseType!==null}(),at=class extends zo{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=Qo&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new re(Jt,this.uri(),e)}};function Jt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Ko))return new XMLHttpRequest}catch{}if(!t)try{return new F["Active".concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}var Xt=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative",Jo=class extends it{get name(){return"websocket"}doOpen(){let e=this.uri(),t=this.opts.protocols,r=Xt?{}:Yt(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,r)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;ke(r,this.supportsBinary,n=>{try{this.doWrite(r,n)}catch{}o&&ce(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(tthis.opts.timestampParam=zt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},nt=F.WebSocket||F.MozWebSocket,pt=class extends Jo{createSocket(e,t,r){return Xt?new nt(e,t,r):t?new nt(e,t):new nt(e)}doWrite(e,t){this.ws.send(t)}},Zt=class extends it{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=Vt(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=e.readable.pipeThrough(t).getReader(),o=Gt();o.readable.pipeTo(e.writable),this._writer=o.writable.getWriter();let n=()=>{r.read().then(({done:i,value:u})=>{i||(this.onPacket(u),n())}).catch(i=>{})};n();let s={type:"open"};this.query.sid&&(s.data={"sid":"${this.query.sid}"}),this._writer.write(s).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let r=et,o=t===e.length-1;this._writer.write(r).then(()=>{o&&ce(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}},Xo={websocket:pt,webtransport:Zt,polling:at},Zo=/^(?:(?!^:@\/?#+:^:@\/*@)(http|https|ws|wss):\/\/)?((?:((^:@\/?#*)(?::(^:@\/?#*))?)?@)?((?:a-f0-9{0,4}:){2,7}a-f0-9{0,4}|^:\/?#*)(?::(\d*))?)(((\/(?:^?#(?!^?#\/*\.^?#\/.+(?:?#|$)))*\/?)?(^?#\/*))(?:\?(^#*))?(?:#(.*))?)/,en="source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor";function Ae(e){if(e.length>8e3)throw"URI too long";let t=e,r=e.indexOf(""),o=e.indexOf("");r!=-1&&o!=-1&&(e=e.substring(0,r)+e.substring(r,o).replace(/:/g,";")+e.substring(o,e.length));let n=Zo.exec(e||""),s={},i=14;for(;i--;)s[eni]=ni||"";return r!=-1&&o!=-1&&(s.source=t,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("","").replace("","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=tn(s,s.path),s.queryKey=rn(s,s.query),s}function tn(e,t){let r=/\/{2,9}/g,o=t.replace(r,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&o.splice(0,1),t.slice(-1)=="/"&&o.splice(o.length-1,1),o}function rn(e,t){let r={};return t.replace(/(?:^|&)(^&=*)=?(^&*)/g,function(o,n,s){n&&(rn=s)}),r}var st=typeof addEventListener=="function"&&typeof removeEventListener=="function",Pe=[];st&&addEventListener("offline",()=>{Pe.forEach(e=>e())},!1);var Le=class Ie extends f{constructor(t,r){if(super(),this.binaryType=Uo,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(r=t,t=null),t){let o=Ae(t);r.hostname=o.host,r.secure=o.protocol==="https"||o.protocol==="wss",r.port=o.port,o.query&&(r.query=o.query)}else r.host&&(r.hostname=Ae(r.host).host);ue(this,r),this.secure=r.secure!=null?r.secure:typeof location<"u"&&location.protocol==="https:",r.hostname&&!r.port&&(r.port=this.secure?"443":"80"),this.hostname=r.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=r.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},r.transports.forEach(o=>{let n=o.prototype.name;this.transports.push(n),this._transportsByNamen=o}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},r),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=qo(this.opts.query)),st&&(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"})},Pe.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){let r=Object.assign({},this.opts.query);r.EIO=ot,r.transport=t,this.id&&(r.sid=this.id);let o=Object.assign({},this.opts,{query:r,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptionst);return new this._transportsByNamet(o)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}let t=this.opts.rememberUpgrade&&Ie.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",Ie.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":let r=new Error("server error");r.code=t.data,this._onError(r);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let r=0;r<this.writeBuffer.length;r++){let o=this.writeBufferr.data;if(o&&(t+=jo(o)),r>0&&t>this._maxPayload)return this.writeBuffer.slice(0,r);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ce(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,r,o){return this._sendPacket("message",t,r,o),this}send(t,r,o){return this._sendPacket("message",t,r,o),this}_sendPacket(t,r,o,n){if(typeof r=="function"&&(n=r,r=void 0),typeof o=="function"&&(n=o,o=null),this.readyState==="closing"||this.readyState==="closed")return;o=o||{},o.compress=o.compress!==!1;let s={type:t,data:r,options:o};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){let t=()=>{this._onClose("forced close"),this.transport.close()},r=()=>{this.off("upgrade",r),this.off("upgradeError",r),t()},o=()=>{this.once("upgrade",r),this.once("upgradeError",r)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?o():t()}):this.upgrading?o():t()),this}_onError(t){if(Ie.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(),st&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){let o=Pe.indexOf(this._offlineEventListener);o!==-1&&Pe.splice(o,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,r),this.writeBuffer=[],this._prevBufferLen=0}}};Le.protocol=ot;var on=class extends Le{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;Le.priorWebsocketSuccess=!1;let o=()=>{r||(t.send({type:"ping",data:"probe"}),t.once("packet",y=>{if(!r)if(y.type==="pong"&&y.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;Le.priorWebsocketSuccess=t.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(h(),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 n(){r||(r=!0,h(),t.close(),t=null)}let s=y=>{let U=new Error("probe error: "+y);U.transport=t.name,n(),this.emitReserved("upgradeError",U)};function i(){s("transport closed")}function u(){s("socket closed")}function a(y){t&&y.name!==t.name&&n()}let h=()=>{t.removeListener("open",o),t.removeListener("error",s),t.removeListener("close",i),this.off("close",u),this.off("upgrading",a)};t.once("open",o),t.once("error",s),t.once("close",i),this.once("close",u),this.once("upgrading",a),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}},ct=class extends on{constructor(e,t={}){let r=typeof e=="object"?e:t;(!r.transports||r.transports&&typeof r.transports0=="string")&&(r.transports=(r.transports||"polling","websocket","webtransport").map(o=>Xoo).filter(o=>!!o)),super(e,r)}};var g_=ct.protocol;var ft={};vr(ft,{Decoder:()=>fn,Encoder:()=>mn,PacketType:()=>p,protocol:()=>rr});var nn=typeof ArrayBuffer=="function",sn=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,tr=Object.prototype.toString,an=typeof Blob=="function"||typeof Blob<"u"&&tr.call(Blob)==="object BlobConstructor",pn=typeof File=="function"||typeof File<"u"&&tr.call(File)==="object FileConstructor";function mt(e){return nn&&(e instanceof ArrayBuffer||sn(e))||an&&e instanceof Blob||pn&&e instanceof File}function Ce(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let r=0,o=e.length;r<o;r++)if(Ce(er))return!0;return!1}if(mt(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return Ce(e.toJSON(),!0);for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&Ce(er))return!0;return!1}function cn(e){let t=[],r=e.data,o=e;return o.data=ut(r,t),o.attachments=t.length,{packet:o,buffers:t}}function ut(e,t){if(!e)return e;if(mt(e)){let r={_placeholder:!0,num:t.length};return t.push(e),r}else if(Array.isArray(e)){let r=new Array(e.length);for(let o=0;o<e.length;o++)ro=ut(eo,t);return r}else if(typeof e=="object"&&!(e instanceof Date)){let r={};for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&(ro=ut(eo,t));return r}return e}function un(e,t){return e.data=lt(e.data,t),delete e.attachments,e}function lt(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=lt(er,t);else if(typeof e=="object")for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(er=lt(er,t));return e}var ln="connect","connect_error","disconnect","disconnecting","newListener","removeListener",rr=5,p;(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"})(p||(p={}));var mn=class{constructor(e){this.replacer=e}encode(e){return(e.type===p.EVENT||e.type===p.ACK)&&Ce(e)?this.encodeAsBinary({type:e.type===p.EVENT?p.BINARY_EVENT:p.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):this.encodeAsString(e)}encodeAsString(e){let t=""+e.type;return(e.type===p.BINARY_EVENT||e.type===p.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=cn(e),r=this.encodeAsString(t.packet),o=t.buffers;return o.unshift(r),o}};function er(e){return Object.prototype.toString.call(e)==="object Object"}var fn=class or extends f{constructor(t){super(),this.reviver=t}add(t){let r;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");r=this.decodeString(t);let o=r.type===p.BINARY_EVENT;o||r.type===p.BINARY_ACK?(r.type=o?p.EVENT:p.ACK,this.reconstructor=new dn(r),r.attachments===0&&super.emitReserved("decoded",r)):super.emitReserved("decoded",r)}else if(mt(t)||t.base64)if(this.reconstructor)r=this.reconstructor.takeBinaryData(t),r&&(this.reconstructor=null,super.emitReserved("decoded",r));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let r=0,o={type:Number(t.charAt(0))};if(po.type===void 0)throw new Error("unknown packet type "+o.type);if(o.type===p.BINARY_EVENT||o.type===p.BINARY_ACK){let s=r+1;for(;t.charAt(++r)!=="-"&&r!=t.length;);let i=t.substring(s,r);if(i!=Number(i)||t.charAt(r)!=="-")throw new Error("Illegal attachments");o.attachments=Number(i)}if(t.charAt(r+1)==="/"){let s=r+1;for(;++r&&!(t.charAt(r)===","||r===t.length););o.nsp=t.substring(s,r)}else o.nsp="/";let n=t.charAt(r+1);if(n!==""&&Number(n)==n){let s=r+1;for(;++r;){let i=t.charAt(r);if(i==null||Number(i)!=i){--r;break}if(r===t.length)break}o.id=Number(t.substring(s,r+1))}if(t.charAt(++r)){let s=this.tryParse(t.substr(r));if(or.isPayloadValid(o.type,s))o.data=s;else throw new Error("invalid payload")}return o}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,r){switch(t){case p.CONNECT:return er(r);case p.DISCONNECT:return r===void 0;case p.CONNECT_ERROR:return typeof r=="string"||er(r);case p.EVENT:case p.BINARY_EVENT:return Array.isArray(r)&&(typeof r0=="number"||typeof r0=="string"&&ln.indexOf(r0)===-1);case p.ACK:case p.BINARY_ACK:return Array.isArray(r)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}},dn=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=un(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function hn(e,t="",r){let o=e;r=r||typeof location<"u"&&location,e==null&&(e=r.protocol+"//"+r.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=r.protocol+e:e=r.host+e),/^(https?|wss?):\/\//.test(e)||(typeof r<"u"?e=r.protocol+"//"+e:e="https://"+e),o=Ae(e)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";let n=o.host.indexOf(":")!==-1?""+o.host+"":o.host;return o.id=o.protocol+"://"+n+":"+o.port+t,o.href=o.protocol+"://"+n+(r&&r.port===o.port?"":":"+o.port),o}function M(e,t,r){return e.on(t,r),function(){e.off(t,r)}}var gn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),nr=class extends f{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=M(e,"open",this.onopen.bind(this)),M(e,"packet",this.onpacket.bind(this)),M(e,"error",this.onerror.bind(this)),M(e,"close",this.onclose.bind(this))}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var r,o,n;if(gn.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:p.EVENT,data:t};if(s.options={},s.options.compress=this.flags.compress!==!1,typeof tt.length-1=="function"){let a=this.ids++,h=t.pop();this._registerAckCallback(a,h),s.id=a}let i=(o=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||o===void 0?void 0:o.writable,u=this.connected&&!(!((n=this.io.engine)===null||n===void 0)&&n._hasPingExpired());return this.flags.volatile&&!i||(u?(this.notifyOutgoingListeners(s),this.packet(s)):this.sendBuffer.push(s)),this.flags={},this}_registerAckCallback(e,t){var r;let o=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(o===void 0){this.ackse=t;return}let n=this.io.setTimeoutFn(()=>{delete this.ackse;for(let i=0;i<this.sendBuffer.length;i++)this.sendBufferi.id===e&&this.sendBuffer.splice(i,1);t.call(this,new Error("operation has timed out"))},o),s=(...i)=>{this.io.clearTimeoutFn(n),t.apply(this,i)};s.withError=!0,this.ackse=s}emitWithAck(e,...t){return new Promise((r,o)=>{let n=(s,i)=>s?o(s):r(i);n.withError=!0,t.push(n),this.emit(e,...t)})}_addToQueue(e){let t;typeof ee.length-1=="function"&&(t=e.pop());let r={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((o,...n)=>r!==this._queue0?void 0:(o!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(o)):(this._queue.shift(),t&&t(null,...n)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue0;t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth=="function"?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:p.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 p.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 p.EVENT:case p.BINARY_EVENT:this.onevent(e);break;case p.ACK:case p.BINARY_ACK:this.onack(e);break;case p.DISCONNECT:this.ondisconnect();break;case p.CONNECT_ERROR:this.destroy();let t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let r of t)r.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof ee.length-1=="string"&&(this._lastOffset=ee.length-1)}ack(e){let t=this,r=!1;return function(...o){r||(r=!0,t.packet({type:p.ACK,id:e,data:o}))}}onack(e){let t=this.ackse.id;typeof t=="function"&&(delete this.ackse.id,t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:p.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 oe(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}oe.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};oe.prototype.reset=function(){this.attempts=0};oe.prototype.setMin=function(e){this.ms=e};oe.prototype.setMax=function(e){this.max=e};oe.prototype.setJitter=function(e){this.jitter=e};var dt=class extends f{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,ue(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 oe({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState="closed",this.uri=e;let o=t.parser||ft;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)===null||t===void 0||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)===null||t===void 0||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)===null||t===void 0||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new ct(this.uri,this.opts);let t=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;let o=M(t,"open",function(){r.onopen(),e&&e()}),n=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),e?e(i):this.maybeReconnectOnOpen()},s=M(t,"error",n);if(this._timeout!==!1){let i=this._timeout,u=this.setTimeoutFn(()=>{o(),n(new Error("timeout")),t.close()},i);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(o),this.subs.push(s),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");let e=this.engine;this.subs.push(M(e,"ping",this.onping.bind(this)),M(e,"data",this.ondata.bind(this)),M(e,"error",this.onerror.bind(this)),M(e,"close",this.onclose.bind(this)),M(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){ce(()=>{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 nr(this,e,t),this.nspse=r),r}_destroy(e){let t=Object.keys(this.nsps);for(let r of t)if(this.nspsr.active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let r=0;r<t.length;r++)this.engine.write(tr,e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let r=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),!e.skipReconnect&&e.open(o=>{o?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",o)):e.onreconnect()}))},t);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}},le={};function me(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};let r=hn(e,t.path||"/socket.io"),o=r.source,n=r.id,s=r.path,i=len&&s in len.nsps,u=t.forceNew||t"force new connection"||t.multiplex===!1||i,a;return u?a=new dt(o,t):(len||(len=new dt(o,t)),a=len),r.query&&!t.query&&(t.query=r.queryKey),a.socket(r.path,t)}Object.assign(me,{Manager:dt,Socket:nr,io:me,connect:me});var c=(e,{parseOnNested:t,parseOnQuoted:r,patterns:o})=>(n,s,i)=>{if(!t&&s.nested)return i?.()??[];if(!r&&s.quoted)return i?.()??[];for(let u of o){let a=u.exec(n);if(a===null)continue;let h=n.substring(0,a.index),y=n.substring(a.index+(a0?.length??0)),U=e(a0??"",s);return...A(h,s),...U,...A(y,s)}return i?.()??[]};var l=e=>{type:"plain",raw:e,text:e},ar=c(l,{parseOnNested:!0,parseOnQuoted:!0,patterns:/^()(.*)()$/});var Tn=/\\s+\/,Nn=(e,t)=>t.context==="table"?l(e,t):{type:"blank",raw:e,text:e.substring(1,e.length-1)},pr=c(Nn,{parseOnNested:!1,parseOnQuoted:!0,patterns:Tn});var bn=/.*?/,_n=(e,t)=>t.context==="table"?l(e,t):{type:"code",raw:e,text:e.substring(1,e.length-1)},cr=c(_n,{parseOnNested:!1,parseOnQuoted:!0,patterns:bn});var kn=/^$% .+$/,wn=(e,t)=>{if(t.context==="table")return l(e,t);let r=e0??"",o=e.substring(2);return{type:"commandLine",raw:e,symbol:r,text:o}},ur=c(wn,{parseOnNested:!1,parseOnQuoted:!1,patterns:kn});var On=/\!"#%&'()*+,\-./{|}<>_~]+ (?:\[[^[\+\]|^\])+\]/,Pn=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.indexOf(" "),o=e.substring(1,r),n=e.substring(r+1,e.length-1),s=new Set(o);if(s.has("*")){let i=o.split("*").length-1;s.delete("*"),s.add(*-${Math.min(i,10)})}return{type:"decoration",raw:e,rawDecos:o,decos:Array.from(s),nodes:A(n,{...t,nested:!0})}},lr=c(Pn,{parseOnNested:!1,parseOnQuoted:!0,patterns:On});var Ln=/\[https?:\/\/^\s\]+\s+^\]*^\s\]/,In=/\^[\*^\s\s+https?:\/\/^\s\]+\]/,An=/\[https?:\/\/^\s\]+\]/,Cn=/https?:\/\/^\s+/,Fn=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.startsWith("")&&e.endsWith("")?e.substring(1,e.length-1):e,o=/^https?:\/\/^\s\]/.test(r),n=(o?/^https?:\/\/^\s\]+/:/https?:\/\/^\s\]+$/).exec(r);if(n?.0===void 0)return[];let s=o?r.substring(n0.length):r.substring(0,n.index-1);return[{type:"link",raw:e,pathType:"absolute",href:n0,content:s.trim()}]},mr=c(Fn,{parseOnNested:!0,parseOnQuoted:!0,patterns:Ln,In,An,Cn});var vn=/\\$ .+? \/,Sn=/\[\$ ^\]+\]/,Mn=(e,t)=>t.context==="table"?l(e,t):{type:"formula",raw:e,formula:e.substring(3,e.length-(e.endsWith(" ")?2:1))}],fr=c(Mn,{parseOnNested:!1,parseOnQuoted:!0,patterns:vn,Sn});var dr=/\[(^\]*^\s)\s+(NS\d+(?:\.\d+)?,EW\d+(?:\.\d+)?(?:,Z\d+)?)\]/,hr=/\[(NS\d+(?:\.\d+)?,EW\d+(?:\.\d+)?(?:,Z\d+)?)(?:\s+(^\]*^\s))?\]/,Un=e=>{lett="",r="",o=""=e.split(","),n=Number.parseFloat(t.replace(/^N/,"").replace(/^S/,"-")),s=Number.parseFloat(r.replace(/^E/,"").replace(/^W/,"-")),i=/^Z\d+$/.test(o)?Number.parseInt(o.replace(/^Z/,""),10):14;return{latitude:n,longitude:s,zoom:i}},Dn=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.match(dr)??e.match(hr);if(r===null)return[];let o=e.startsWith("[N")||e.startsWith("[S"),,n="",s=""=o?r:[r0,r2,r1],{latitude:i,longitude:u,zoom:a}=Un(n),h=s!==""?https://www.google.com/maps/place/${encodeURIComponent(s)}/@${i},${u},${a}z:https://www.google.com/maps/@${i},${u},${a}z;return{type:"googleMap",raw:e,latitude:i,longitude:u,zoom:a,place:s,url:h}},gr=c(Dn,{parseOnNested:!1,parseOnQuoted:!0,patterns:dr,hr});var Bn=/(?:^|\s)#\S+/,Hn=(e,t)=>{if(t.context==="table")return l(e,t);if(e.startsWith("#"))return{type:"hashTag",raw:e,href:e.substring(1)};let r=e.substring(0,1),o=e.substring(1);return...l(r,t),{type:"hashTag",raw:o,href:o.substring(1)}},yr=c(Hn,{parseOnNested:!0,parseOnQuoted:!0,patterns:Bn});var jn=/^\? .+$/,Wn=(e,t)=>t.context==="table"?l(e,t):{type:"helpfeel",raw:e,text:e.substring(2)},Er=c(Wn,{parseOnNested:!1,parseOnQuoted:!1,patterns:jn});var $n=/\^[\*\.icon(?:\*1-9\d*)?\]/,qn=e=>{let t=e.substring(1,e.length-1),r=t.lastIndexOf(".icon"),o=t.substring(0,r),n=o.startsWith("/")?"root":"relative",s=t.substring(r+5,t.length),i=s.startsWith("*")?Number.parseInt(s.substring(1),10):1;return new Array(i).fill({}).map(()=>({path:o,pathType:n,type:"icon",raw:e}))},xr=c(qn,{parseOnNested:!0,parseOnQuoted:!0,patterns:$n});var Gn=/\[https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)(?:\?^\\s]+)?(?:\s+https?:\/\/^\s\]+)?\]/i,Vn=/\[https?:\/\/^\s\]+\s+https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)(?:\?^\\s]+)?\]/i,Kn=/\[https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}(?:\/raw)?(?:\s+https?:\/\/^\s\]+)?\]/,Yn=/\[https?:\/\/^\s\]+\s+https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}(?:\/raw)?\]/,zn=e=>/^https?:\/\/^\s\]+\.(png|jpe?g|gif|svg|webp)(\?^\\s]+)?$/i.test(e)||Qn(e),Qn=e=>/^https?:\/\/(0-9a-z-\.)?gyazo\.com\/0-9a-f{32}(\/raw)?$/.test(e),Jn=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.search(/\s/),o=r!==-1?e.substring(1,r):e.substring(1,e.length-1),n=r!==-1?e.substring(r,e.length-1).replace(/^\s+/,""):"",s,i=zn(n)?n,o:o,n;return[{type:"image",raw:e,src:/^https?:\/\/(0-9a-z-\.)?gyazo\.com\/0-9a-f{32}$/.test(s)?${s}/thumb/1000:s,link:i}]},Rr=c(Jn,{parseOnNested:!0,parseOnQuoted:!0,patterns:Gn,Vn,Kn,Yn});var Xn=/\[\/?[^\]+\]/,Zn=e=>{let t=e.substring(1,e.length-1);return{type:"link",raw:e,pathType:t.startsWith("/")?"root":"relative",href:t,content:""}},Tr=c(Zn,{parseOnNested:!0,parseOnQuoted:!0,patterns:Xn});var es=/^0-9+\. .*$/,ts=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.indexOf(" "),o=e.substring(0,r-1),n=Number.parseInt(o,10),s=e.substring(r+1,e.length);return{type:"numberList",raw:e,rawNumber:o,number:n,nodes:A(s,{...t,nested:!1})}},Nr=c(ts,{parseOnNested:!1,parseOnQuoted:!1,patterns:es});var rs=/^>.*$/,os=(e,t)=>t.context==="table"?l(e,t):{type:"quote",raw:e,nodes:A(e.substring(1),{...t,quoted:!0})},br=c(os,{parseOnNested:!1,parseOnQuoted:!1,patterns:rs});var ns=/\[\^[\*\.icon(?:\*\d+)?\]\]/,ss=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.substring(2,e.length-2),o=r.lastIndexOf(".icon"),n=r.substring(0,o),s=n.startsWith("/")?"root":"relative",i=r.substring(o+5,r.length),u=i.startsWith("*")?Number.parseInt(i.substring(1),10):1;return new Array(u).fill({}).map(()=>({path:n,pathType:s,type:"strongIcon",raw:e}))},_r=c(ss,{parseOnNested:!1,parseOnQuoted:!0,patterns:ns});var is=/\[\[https?:\/\/^\s\]+\.(?:png|jpe?g|gif|svg|webp)\]\]/i,as=/\[\[https?:\/\/(?:0-9a-z-+\.)?gyazo\.com\/0-9a-f{32}\]\]/,ps=(e,t)=>{if(t.context==="table")return l(e,t);let r=e.substring(2,e.length-2),o=/^https?:\/\/(0-9a-z-\.)?gyazo\.com\/0-9a-f{32}$/.test(r);return[{type:"strongImage",raw:e,src:o?${r}/thumb/1000:r}]},kr=c(ps,{parseOnNested:!1,parseOnQuoted:!0,patterns:is,as});var cs=/\[\[(?:[^[]|\[[^[]).*?\]*\]\]/,us=(e,t)=>t.context==="table"?l(e,t):{type:"strong",raw:e,nodes:A(e.substring(2,e.length-2),{...t,nested:!0})},wr=c(us,{parseOnNested:!1,parseOnQuoted:!0,patterns:cs});var ls=(e,t,r)=>e===""?[]:r?.()??[],ms=(...e)=>(t,r)=>e.reduceRight((o,n)=>()=>n(t,r,o),()=>ar(t,r))(),A=ms(ls,br,Er,Nr,cr,ur,fr,pr,lr,kr,_r,wr,Rr,mr,xr,gr,Tr,yr);var Or=" must not return ",Es="transformer",xs="recoverer",Rs="defaultValue",ve=Es+Or,K="called with ",Se=Rs+" must not be ",Me=xs+Or;var Ts="Ok",Pr="Err",Ns=K+Pr,bs=K+Ts,_s="Carrying E in "+Pr+" instead of throwing it directly. See .cause",gt="an instance of Error of the current realm.",Q0="The thrown value is not "+gt,J0="The contained E should be "+gt,ks="This .cause is not "+gt;var Ue="null",oL=ve+Ue,Ps=K+Ue,nL=Se+Ue,sL=Me+Ue;var De="undefined",uL=ve+De,Ls=K+De,lL=Se+De,mL=Me+De;var vs=()=>{let e=document.createElement("div");return e.style.position="absolute",e.style.top="0",e.style.right="0",e.style.textAlign="right",e},se=new Map,Be,yt=()=>{for(let e of se.values())e.remove();if(se.clear(),scrapbox.Layout!=="page"||scrapbox.Project.name!=="takker-memex"){if(scrapbox.removeListener("lines:changed",He),!Be)return;clearInterval(Be),Be=void 0;return}He(),scrapbox.addListener("lines:changed",He),Be=setInterval(He,60*1e3)},He=()=>{let e=ae();for(let t of e){let r=G(t.text);if(!r?.record?.start){se.get(t.id)?.remove?.(),se.delete(t.id);continue}let o=Ke(r.record.end??new Date,r.record.start),n=Math.round(o/5),s=Math.floor(n/6),i=Math.floor((n-s*6)/3),u=n-s*6-i*3,a=${s>20?🍅x${(o/30).toFixed(1)}:"🍅".repeat(s)}${"🍊".repeat(i)}${"🍓".repeat(u)},h=se.get(t.id)??vs();We(t.id)?.append?.(h),se.set(t.id,h),h.textContent=a}};yt();scrapbox.addListener("page:changed",yt);scrapbox.addListener("lines:changed",yt);