rmapi-js 3.1.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [4.0.0] - 2024-04-03
12
+
13
+ ### Added
14
+
15
+ - `verify` option to some calls to disable verifying that requests follow the
16
+ expected format. Note that disabling verification will break typescripts
17
+ guarantees, and so it's only recommend if you know what you're doing.
18
+
19
+ ### Modified
20
+
21
+ - `lastModified` is now optional. This might break some code that replied on it
22
+ to be present.
23
+
11
24
  ## [3.1.0] - 2023-12-05
12
25
 
13
26
  ### Added
@@ -1,12 +1,12 @@
1
- "use strict";var Jr=Object.create;var pe=Object.defineProperty;var Gr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var zr=Object.getPrototypeOf,Vr=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Wr=(t,e)=>{for(var r in e)pe(t,r,{get:e[r],enumerable:!0})},rt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qr(e))!Vr.call(t,o)&&o!==r&&pe(t,o,{get:()=>e[o],enumerable:!(n=Gr(e,o))||n.enumerable});return t};var ne=(t,e,r)=>(r=t!=null?Jr(zr(t)):{},rt(e||!t||!t.__esModule?pe(r,"default",{value:t,enumerable:!0}):r,t)),Yr=t=>rt(pe({},"__esModule",{value:!0}),t);var it=m(ce=>{"use strict";ce.byteLength=Xr;ce.toByteArray=Qr;ce.fromByteArray=rn;var I=[],F=[],Kr=typeof Uint8Array<"u"?Uint8Array:Array,$e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(N=0,nt=$e.length;N<nt;++N)I[N]=$e[N],F[$e.charCodeAt(N)]=N;var N,nt;F[45]=62;F[95]=63;function ot(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Xr(t){var e=ot(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Zr(t,e,r){return(e+r)*3/4-r}function Qr(t){var e,r=ot(t),n=r[0],o=r[1],i=new Kr(Zr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function en(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function tn(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(en(n));return o.join("")}function rn(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(tn(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var lt=m((xo,ut)=>{"use strict";var ye,l,at={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "},Me;function R(t){throw{name:"SyntaxError",message:t,at:ye,text:Me}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Me.charAt(ye),ye+=1,l}function st(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function ft(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof at[l]=="string")r+=at[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function nn(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function on(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(de()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function an(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=ft(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=de(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function de(){switch($(),l){case"{":return an();case"[":return on();case'"':return ft();case"-":return st();default:return l>="0"&&l<="9"?st():nn()}}ut.exports=function(t,e){var r;return Me=t,ye=0,l=" ",r=de(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in de)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var ct=m((Ao,pt)=>{"use strict";var Re=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ge,sn={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},U;function Be(t){return Re.lastIndex=0,Re.test(t)?'"'+t.replace(Re,function(e){var r=sn[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function me(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof U=="function"&&(s=U.call(e,t,s)),typeof s){case"string":return Be(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ge,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=me(r,s)||"null";return o=f.length===0?"[]":T?`[
1
+ "use strict";var pn=Object.create;var ue=Object.defineProperty;var cn=Object.getOwnPropertyDescriptor;var yn=Object.getOwnPropertyNames;var dn=Object.getPrototypeOf,gn=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),mn=(t,e)=>{for(var r in e)ue(t,r,{get:e[r],enumerable:!0})},nt=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of yn(e))!gn.call(t,o)&&o!==r&&ue(t,o,{get:()=>e[o],enumerable:!(n=cn(e,o))||n.enumerable});return t};var re=(t,e,r)=>(r=t!=null?pn(dn(t)):{},nt(e||!t||!t.__esModule?ue(r,"default",{value:t,enumerable:!0}):r,t)),hn=t=>nt(ue({},"__esModule",{value:!0}),t);var at=d(le=>{"use strict";le.byteLength=bn;le.toByteArray=Pn;le.fromByteArray=En;var I=[],F=[],vn=typeof Uint8Array<"u"?Uint8Array:Array,Me="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,ot=Me.length;U<ot;++U)I[U]=Me[U],F[Me.charCodeAt(U)]=U;var U,ot;F[45]=62;F[95]=63;function it(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function bn(t){var e=it(t),r=e[0],n=e[1];return(r+n)*3/4-n}function wn(t,e,r){return(e+r)*3/4-r}function Pn(t){var e,r=it(t),n=r[0],o=r[1],i=new vn(wn(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function xn(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function An(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(xn(n));return o.join("")}function En(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(An(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var pt=d((Yo,lt)=>{"use strict";var pe,l,st={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},Re;function R(t){throw{name:"SyntaxError",message:t,at:pe,text:Re}}function g(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Re.charAt(pe),pe+=1,l}function ft(){var t,e="";for(l==="-"&&(e="-",g("-"));l>="0"&&l<="9";)e+=l,g();if(l===".")for(e+=".";g()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,g(),(l==="-"||l==="+")&&(e+=l,g());l>="0"&&l<="9";)e+=l,g();return t=Number(e),isFinite(t)||R("Bad number"),t}function ut(){var t,e,r="",n;if(l==='"')for(;g();){if(l==='"')return g(),r;if(l==="\\")if(g(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(g(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof st[l]=="string")r+=st[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)g()}function Sn(){switch(l){case"t":return g("t"),g("r"),g("u"),g("e"),!0;case"f":return g("f"),g("a"),g("l"),g("s"),g("e"),!1;case"n":return g("n"),g("u"),g("l"),g("l"),null;default:R("Unexpected '"+l+"'")}}function On(){var t=[];if(l==="["){if(g("["),$(),l==="]")return g("]"),t;for(;l;){if(t.push(ce()),$(),l==="]")return g("]"),t;g(","),$()}}R("Bad array")}function Tn(){var t,e={};if(l==="{"){if(g("{"),$(),l==="}")return g("}"),e;for(;l;){if(t=ut(),$(),g(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=ce(),$(),l==="}")return g("}"),e;g(","),$()}}R("Bad object")}function ce(){switch($(),l){case"{":return Tn();case"[":return On();case'"':return ut();case"-":return ft();default:return l>="0"&&l<="9"?ft():Sn()}}lt.exports=function(t,e){var r;return Re=t,pe=0,l=" ",r=ce(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in ce)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var yt=d((Ko,ct)=>{"use strict";var Be=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ye,Fn={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function Ce(t){return Be.lastIndex=0,Be.test(t)?'"'+t.replace(Be,function(e){var r=Fn[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function de(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return Ce(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ye,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=de(r,s)||"null";return o=f.length===0?"[]":T?`[
3
3
  `+T+f.join(`,
4
4
  `+T)+`
5
- `+a+"]":"["+f.join(",")+"]",T=a,o}if(U&&typeof U=="object")for(i=U.length,r=0;r<i;r+=1)n=U[r],typeof n=="string"&&(o=me(n,s),o&&f.push(Be(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=me(n,s),o&&f.push(Be(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
5
+ `+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=de(n,s),o&&f.push(Ce(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=de(n,s),o&&f.push(Ce(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
6
6
  `+T+f.join(`,
7
7
  `+T)+`
8
- `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}pt.exports=function(t,e,r){var n;if(T="",ge="",typeof r=="number")for(n=0;n<r;n+=1)ge+=" ";else typeof r=="string"&&(ge=r);if(U=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return me("",{"":t})}});var yt=m(Ce=>{"use strict";Ce.parse=lt();Ce.stringify=ct()});var gt=m((So,dt)=>{var fn={}.toString;dt.exports=Array.isArray||function(t){return fn.call(t)=="[object Array]"}});var _e=m((Oo,ht)=>{"use strict";var mt=Object.prototype.toString;ht.exports=function(e){var r=mt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&mt.call(e.callee)==="[object Function]"),n}});var Ot=m((To,St)=>{"use strict";var Et;Object.keys||(oe=Object.prototype.hasOwnProperty,Ne=Object.prototype.toString,vt=_e(),Ue=Object.prototype.propertyIsEnumerable,bt=!Ue.call({toString:null},"toString"),wt=Ue.call(function(){},"prototype"),ie=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],he=function(t){var e=t.constructor;return e&&e.prototype===t},Pt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},xt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!Pt["$"+t]&&oe.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{he(window[t])}catch{return!0}}catch{return!0}return!1}(),At=function(t){if(typeof window>"u"||!xt)return he(t);try{return he(t)}catch{return!1}},Et=function(e){var r=e!==null&&typeof e=="object",n=Ne.call(e)==="[object Function]",o=vt(e),i=r&&Ne.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=wt&&n;if(i&&e.length>0&&!oe.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&oe.call(e,p)&&a.push(String(p));if(bt)for(var g=At(e),u=0;u<ie.length;++u)!(g&&ie[u]==="constructor")&&oe.call(e,ie[u])&&a.push(ie[u]);return a});var oe,Ne,vt,Ue,bt,wt,ie,he,Pt,xt,At;St.exports=Et});var It=m((Fo,kt)=>{"use strict";var un=Array.prototype.slice,ln=_e(),Tt=Object.keys,ve=Tt?function(e){return Tt(e)}:Ot(),Ft=Object.keys;ve.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return ln(n)?Ft(un.call(n)):Ft(n)})}else Object.keys=ve;return Object.keys||ve};kt.exports=ve});var Mt=m((ko,$t)=>{"use strict";var pn="Function.prototype.bind called on incompatible ",cn=Object.prototype.toString,yn=Math.max,dn="[object Function]",jt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},gn=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},mn=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};$t.exports=function(e){var r=this;if(typeof r!="function"||cn.apply(r)!==dn)throw new TypeError(pn+r);for(var n=gn(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,jt(n,arguments));return Object(p)===p?p:this}return r.apply(e,jt(n,arguments))},a=yn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+mn(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var be=m((Io,Rt)=>{"use strict";var hn=Mt();Rt.exports=Function.prototype.bind||hn});var Ct=m((jo,Bt)=>{"use strict";Bt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var Ut=m(($o,Nt)=>{"use strict";var _t=typeof Symbol<"u"&&Symbol,vn=Ct();Nt.exports=function(){return typeof _t!="function"||typeof Symbol!="function"||typeof _t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:vn()}});var Ht=m((Mo,Lt)=>{"use strict";var Dt={foo:{}},bn=Object;Lt.exports=function(){return{__proto__:Dt}.foo===Dt.foo&&!({__proto__:null}instanceof bn)}});var Gt=m((Ro,Jt)=>{"use strict";var wn=Function.prototype.call,Pn=Object.prototype.hasOwnProperty,xn=be();Jt.exports=xn.call(wn,Pn)});var Q=m((Bo,Yt)=>{"use strict";var c,Z=SyntaxError,Wt=Function,X=TypeError,De=function(t){try{return Wt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Le=function(){throw new X},An=D?function(){try{return arguments.callee,Le}catch{try{return D(arguments,"callee").get}catch{return Le}}}():Le,Y=Ut()(),En=Ht()(),w=Object.getPrototypeOf||(En?function(t){return t.__proto__}:null),K={},Sn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":Y&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":K,"%AsyncGenerator%":K,"%AsyncGeneratorFunction%":K,"%AsyncIteratorPrototype%":K,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Wt,"%GeneratorFunction%":K,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Y&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Y||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Y||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Y&&w?w(""[Symbol.iterator]()):c,"%Symbol%":Y?Symbol:c,"%SyntaxError%":Z,"%ThrowTypeError%":An,"%TypedArray%":Sn,"%TypeError%":X,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){qt=w(w(t)),L["%Error.prototype%"]=qt}var qt,On=function t(e){var r;if(e==="%AsyncFunction%")r=De("async function () {}");else if(e==="%GeneratorFunction%")r=De("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=De("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},zt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=be(),we=Gt(),Tn=ae.call(Function.call,Array.prototype.concat),Fn=ae.call(Function.apply,Array.prototype.splice),Vt=ae.call(Function.call,String.prototype.replace),Pe=ae.call(Function.call,String.prototype.slice),kn=ae.call(Function.call,RegExp.prototype.exec),In=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,jn=/\\(\\)?/g,$n=function(e){var r=Pe(e,0,1),n=Pe(e,-1);if(r==="%"&&n!=="%")throw new Z("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Z("invalid intrinsic syntax, expected opening `%`");var o=[];return Vt(e,In,function(i,a,f,s){o[o.length]=f?Vt(s,jn,"$1"):a||i}),o},Mn=function(e,r){var n=e,o;if(we(zt,n)&&(o=zt[n],n="%"+o[0]+"%"),we(L,n)){var i=L[n];if(i===K&&(i=On(n)),typeof i>"u"&&!r)throw new X("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new Z("intrinsic "+e+" does not exist!")};Yt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new X("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new X('"allowMissing" argument must be a boolean');if(kn(/^%?[^%]*%?$/,e)===null)throw new Z("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=$n(e),o=n.length>0?n[0]:"",i=Mn("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],Fn(n,Tn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=Pe(u,0,1),b=Pe(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new Z("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",we(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new X("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=we(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Ge=m((Co,Kt)=>{"use strict";var Rn=Q(),He=Rn("%Object.defineProperty%",!0),Je=function(){if(He)try{return He({},"a",{value:1}),!0}catch{return!1}return!1};Je.hasArrayLengthDefineBug=function(){if(!Je())return null;try{return He([],"length",{value:1}).length!==1}catch{return!0}};Kt.exports=Je});var qe=m((_o,Xt)=>{"use strict";var Bn=Q(),xe=Bn("%Object.getOwnPropertyDescriptor%",!0);if(xe)try{xe([],"length")}catch{xe=null}Xt.exports=xe});var er=m((No,Qt)=>{"use strict";var Cn=Ge()(),ze=Q(),se=Cn&&ze("%Object.defineProperty%",!0);if(se)try{se({},"a",{value:1})}catch{se=!1}var _n=ze("%SyntaxError%"),ee=ze("%TypeError%"),Zt=qe();Qt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new ee("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new ee("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ee("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ee("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ee("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ee("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Zt&&Zt(e,r);if(se)se(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new _n("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var ar=m((Uo,ir)=>{"use strict";var or=Q(),tr=er(),Nn=Ge()(),rr=qe(),nr=or("%TypeError%"),Un=or("%Math.floor%");ir.exports=function(e,r){if(typeof e!="function")throw new nr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||Un(r)!==r)throw new nr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&rr){var a=rr(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Nn?tr(e,"length",r,!0,!0):tr(e,"length",r)),e}});var pr=m((Do,Ae)=>{"use strict";var Ve=be(),te=Q(),Dn=ar(),Ln=te("%TypeError%"),fr=te("%Function.prototype.apply%"),ur=te("%Function.prototype.call%"),lr=te("%Reflect.apply%",!0)||Ve.call(ur,fr),fe=te("%Object.defineProperty%",!0),Hn=te("%Math.max%");if(fe)try{fe({},"a",{value:1})}catch{fe=null}Ae.exports=function(e){if(typeof e!="function")throw new Ln("a function is required");var r=lr(Ve,ur,arguments);return Dn(r,1+Hn(0,e.length-(arguments.length-1)),!0)};var sr=function(){return lr(Ve,fr,arguments)};fe?fe(Ae.exports,"apply",{value:sr}):Ae.exports.apply=sr});var dr=m((Lo,yr)=>{"use strict";var Ee=(typeof JSON<"u"?JSON:yt()).stringify,Jn=gt(),Gn=It(),qn=pr(),cr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},zn=function(t,e,r){return r};yr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=cr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?qn(r.replacer):zn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
9
- `+cr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return Ee(u);if(Jn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||Ee(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return Ee("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Gn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],tt=y(u,g,u[g],S+1);if(tt){var Hr=Ee(g)+k+tt;j+=(M?",":"")+b+n+Hr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ze=m(h=>{"use strict";var wr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Wn(t){let{definitions:e,nullable:r,metadata:n}=t,o=wr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Wn;function Pr(t){return"ref"in t}h.isRefForm=Pr;function Yn(t){return"type"in t}h.isTypeForm=Yn;function xr(t){return"enum"in t}h.isEnumForm=xr;function Ar(t){return"elements"in t}h.isElementsForm=Ar;function Xe(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=Xe;function Er(t){return"values"in t}h.isValuesForm=Er;function Sr(t){return"discriminator"in t}h.isDiscriminatorForm=Sr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(Pr(t)&&!(t.ref in(e.definitions||{}))||xr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(Ar(t))return H(t.elements,e);if(Xe(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(Er(t))return H(t.values,e);if(Sr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!Xe(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Kn=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Xn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=wr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Kn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Xn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var Or=m(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});var Zn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function Qn(t){let e=t.match(Zn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>eo(r,n)||i>23||a>59||f>60)}Qe.default=Qn;function eo(t,e){return e===2?to(t)?29:28:ro[e]}function to(t){return t%4===0&&(t%100!==0||t%400===0)}var ro=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Tr=m(B=>{"use strict";var no=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var oo=no(Or()),G=Ze(),Te=class extends Error{};B.MaxDepthExceededError=Te;var Fe=class extends Error{};function io(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{V(n,t,e)}catch(o){if(!(o instanceof Fe))throw o}return n.errors}B.validate=io;function V(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Te;t.schemaTokens.push(["definitions",e.ref]),V(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":re(t,r,-128,127);break;case"uint8":re(t,r,0,255);break;case"int16":re(t,r,-32768,32767);break;case"uint16":re(t,r,0,65535);break;case"int32":re(t,r,-2147483648,2147483647);break;case"uint32":re(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):oo.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),V(t,e.elements,i),z(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),V(t,i,r[o]),z(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),V(t,i,r[o]),z(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),z(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),V(t,e.values,i),z(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),V(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),z(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),z(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function re(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function z(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Fe}});var kr=m(C=>{"use strict";var ao=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Fr=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&ao(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Fr(Ze(),C);Fr(Tr(),C)});var bo={};Wr(bo,{GenerationError:()=>je,ResponseError:()=>W,builtinFontNames:()=>po,builtinLineHeights:()=>Ur,builtinMargins:()=>Nr,builtinTextScales:()=>_r,builtinTools:()=>lo,formatEntry:()=>Dr,parseEntry:()=>Lr,register:()=>ho,remarkable:()=>vo});module.exports=Yr(bo);var Rr=ne(it()),Br=ne(dr());var gr=ne(require("crypto")),Oe=new Uint8Array(256),Se=Oe.length;function We(){return Se>Oe.length-16&&(gr.default.randomFillSync(Oe),Se=0),Oe.slice(Se,Se+=16)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function mr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var hr=ne(require("crypto")),Ye={randomUUID:hr.default.randomUUID};function Vn(t,e,r){if(Ye.randomUUID&&!e&&!t)return Ye.randomUUID();t=t||{};let n=t.random||(t.rng||We)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return mr(n)}var ue=Vn;function Ke(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function vr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function br(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Ir=ne(kr());function le(t,e){if((0,Ir.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var jr="3",Cr="https://webapp-prod.cloud.remarkable.engineering",so="https://internal.cloud.remarkable.com",$r="x-goog-generation",fo="x-goog-if-generation-match",uo="x-goog-content-length-range",lo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],po=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],_r={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},Nr={sm:50,md:125,rr:180,lg:200},Ur={df:-1,md:100,lg:150,xl:200},co={properties:{docID:{type:"string"},hash:{type:"string"}}},yo={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},ke={visibleName:{type:"string"},lastModified:{type:"string"}},Ie={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},go={discriminator:"type",mapping:{CollectionType:{properties:ke,optionalProperties:Ie,additionalProperties:!0},DocumentType:{properties:ke,optionalProperties:{...Ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},Mr={id:{type:"string"},hash:{type:"string"}},mo={discriminator:"type",mapping:{CollectionType:{properties:{...ke,...Mr},optionalProperties:Ie,additionalProperties:!0},DocumentType:{properties:{...ke,...Mr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Ie,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},W=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},je=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function ho(t,{deviceDesc:e="browser-chrome",uuid:r=ue(),authHost:n=Cr,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new W(i.status,i.statusText,"couldn't register api")}function Dr({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
- `}function Lr(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var et=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new W(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[uo]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new W(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return le(yo,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get($r);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[fo]:`${r}`})}catch(f){throw f instanceof W&&f.status===412?(this.#t=null,new je):f}let i=o.headers.get($r);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return le(go,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
- `);if(n!==jr)throw new Error(`got unexpected schema version: ${n}`);return o.map(Lr)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=br(r.map(p=>vr(p.hash))),i=await this.#f.digest("SHA-256",o),a=Ke(i),f=r.map(Dr).join(""),s=`${jr}
12
- ${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=Ke(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,Br.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=ue(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=ue(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?Ur[s]:s,margins:typeof o=="string"?Nr[o]:o,textScale:typeof f=="string"?_r[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return le({elements:mo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Rr.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return le(co,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function vo(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=Cr,syncHost:o=so,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new et(s,e,r,o,i,a)}0&&(module.exports={GenerationError,ResponseError,builtinFontNames,builtinLineHeights,builtinMargins,builtinTextScales,builtinTools,formatEntry,parseEntry,register,remarkable});
8
+ `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}ct.exports=function(t,e,r){var n;if(T="",ye="",typeof r=="number")for(n=0;n<r;n+=1)ye+=" ";else typeof r=="string"&&(ye=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return de("",{"":t})}});var dt=d(_e=>{"use strict";_e.parse=pt();_e.stringify=yt()});var mt=d((Zo,gt)=>{var kn={}.toString;gt.exports=Array.isArray||function(t){return kn.call(t)=="[object Array]"}});var Ue=d((Qo,vt)=>{"use strict";var ht=Object.prototype.toString;vt.exports=function(e){var r=ht.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&ht.call(e.callee)==="[object Function]"),n}});var Tt=d((ei,Ot)=>{"use strict";var St;Object.keys||(ne=Object.prototype.hasOwnProperty,Ne=Object.prototype.toString,bt=Ue(),De=Object.prototype.propertyIsEnumerable,wt=!De.call({toString:null},"toString"),Pt=De.call(function(){},"prototype"),oe=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ge=function(t){var e=t.constructor;return e&&e.prototype===t},xt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},At=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!xt["$"+t]&&ne.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ge(window[t])}catch{return!0}}catch{return!0}return!1}(),Et=function(t){if(typeof window>"u"||!At)return ge(t);try{return ge(t)}catch{return!1}},St=function(e){var r=e!==null&&typeof e=="object",n=Ne.call(e)==="[object Function]",o=bt(e),i=r&&Ne.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=Pt&&n;if(i&&e.length>0&&!ne.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var c=0;c<e.length;++c)a.push(String(c));else for(var p in e)!(f&&p==="prototype")&&ne.call(e,p)&&a.push(String(p));if(wt)for(var m=Et(e),u=0;u<oe.length;++u)!(m&&oe[u]==="constructor")&&ne.call(e,oe[u])&&a.push(oe[u]);return a});var ne,Ne,bt,De,wt,Pt,oe,ge,xt,At,Et;Ot.exports=St});var $t=d((ti,It)=>{"use strict";var In=Array.prototype.slice,$n=Ue(),Ft=Object.keys,me=Ft?function(e){return Ft(e)}:Tt(),kt=Object.keys;me.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return $n(n)?kt(In.call(n)):kt(n)})}else Object.keys=me;return Object.keys||me};It.exports=me});var Rt=d((ri,Mt)=>{"use strict";var jn="Function.prototype.bind called on incompatible ",Mn=Object.prototype.toString,Rn=Math.max,Bn="[object Function]",jt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},Cn=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},_n=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};Mt.exports=function(e){var r=this;if(typeof r!="function"||Mn.apply(r)!==Bn)throw new TypeError(jn+r);for(var n=Cn(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,jt(n,arguments));return Object(p)===p?p:this}return r.apply(e,jt(n,arguments))},a=Rn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+_n(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var c=function(){};c.prototype=r.prototype,o.prototype=new c,c.prototype=null}return o}});var he=d((ni,Bt)=>{"use strict";var Un=Rt();Bt.exports=Function.prototype.bind||Un});var _t=d((oi,Ct)=>{"use strict";Ct.exports=Error});var Nt=d((ii,Ut)=>{"use strict";Ut.exports=EvalError});var Lt=d((ai,Dt)=>{"use strict";Dt.exports=RangeError});var Ht=d((si,qt)=>{"use strict";qt.exports=ReferenceError});var Le=d((fi,Jt)=>{"use strict";Jt.exports=SyntaxError});var ie=d((ui,Gt)=>{"use strict";Gt.exports=TypeError});var Vt=d((li,zt)=>{"use strict";zt.exports=URIError});var Yt=d((pi,Wt)=>{"use strict";Wt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var Zt=d((ci,Xt)=>{"use strict";var Kt=typeof Symbol<"u"&&Symbol,Nn=Yt();Xt.exports=function(){return typeof Kt!="function"||typeof Symbol!="function"||typeof Kt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:Nn()}});var er=d((yi,Qt)=>{"use strict";var qe={__proto__:null,foo:{}},Dn=Object;Qt.exports=function(){return{__proto__:qe}.foo===qe.foo&&!(qe instanceof Dn)}});var rr=d((di,tr)=>{"use strict";var Ln=Function.prototype.call,qn=Object.prototype.hasOwnProperty,Hn=he();tr.exports=Hn.call(Ln,qn)});var Q=d((gi,sr)=>{"use strict";var y,Jn=_t(),Gn=Nt(),zn=Lt(),Vn=Ht(),Z=Le(),X=ie(),Wn=Vt(),ar=Function,He=function(t){try{return ar('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Je=function(){throw new X},Yn=D?function(){try{return arguments.callee,Je}catch{try{return D(arguments,"callee").get}catch{return Je}}}():Je,Y=Zt()(),Kn=er()(),w=Object.getPrototypeOf||(Kn?function(t){return t.__proto__}:null),K={},Xn=typeof Uint8Array>"u"||!w?y:w(Uint8Array),L={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?y:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?y:ArrayBuffer,"%ArrayIteratorPrototype%":Y&&w?w([][Symbol.iterator]()):y,"%AsyncFromSyncIteratorPrototype%":y,"%AsyncFunction%":K,"%AsyncGenerator%":K,"%AsyncGeneratorFunction%":K,"%AsyncIteratorPrototype%":K,"%Atomics%":typeof Atomics>"u"?y:Atomics,"%BigInt%":typeof BigInt>"u"?y:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?y:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Jn,"%eval%":eval,"%EvalError%":Gn,"%Float32Array%":typeof Float32Array>"u"?y:Float32Array,"%Float64Array%":typeof Float64Array>"u"?y:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?y:FinalizationRegistry,"%Function%":ar,"%GeneratorFunction%":K,"%Int8Array%":typeof Int8Array>"u"?y:Int8Array,"%Int16Array%":typeof Int16Array>"u"?y:Int16Array,"%Int32Array%":typeof Int32Array>"u"?y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":Y&&w?w(w([][Symbol.iterator]())):y,"%JSON%":typeof JSON=="object"?JSON:y,"%Map%":typeof Map>"u"?y:Map,"%MapIteratorPrototype%":typeof Map>"u"||!Y||!w?y:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?y:Promise,"%Proxy%":typeof Proxy>"u"?y:Proxy,"%RangeError%":zn,"%ReferenceError%":Vn,"%Reflect%":typeof Reflect>"u"?y:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?y:Set,"%SetIteratorPrototype%":typeof Set>"u"||!Y||!w?y:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":Y&&w?w(""[Symbol.iterator]()):y,"%Symbol%":Y?Symbol:y,"%SyntaxError%":Z,"%ThrowTypeError%":Yn,"%TypedArray%":Xn,"%TypeError%":X,"%Uint8Array%":typeof Uint8Array>"u"?y:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?y:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?y:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?y:Uint32Array,"%URIError%":Wn,"%WeakMap%":typeof WeakMap>"u"?y:WeakMap,"%WeakRef%":typeof WeakRef>"u"?y:WeakRef,"%WeakSet%":typeof WeakSet>"u"?y:WeakSet};if(w)try{null.error}catch(t){nr=w(w(t)),L["%Error.prototype%"]=nr}var nr,Zn=function t(e){var r;if(e==="%AsyncFunction%")r=He("async function () {}");else if(e==="%GeneratorFunction%")r=He("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=He("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},or={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ae=he(),ve=rr(),Qn=ae.call(Function.call,Array.prototype.concat),eo=ae.call(Function.apply,Array.prototype.splice),ir=ae.call(Function.call,String.prototype.replace),be=ae.call(Function.call,String.prototype.slice),to=ae.call(Function.call,RegExp.prototype.exec),ro=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,no=/\\(\\)?/g,oo=function(e){var r=be(e,0,1),n=be(e,-1);if(r==="%"&&n!=="%")throw new Z("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new Z("invalid intrinsic syntax, expected opening `%`");var o=[];return ir(e,ro,function(i,a,f,s){o[o.length]=f?ir(s,no,"$1"):a||i}),o},io=function(e,r){var n=e,o;if(ve(or,n)&&(o=or[n],n="%"+o[0]+"%"),ve(L,n)){var i=L[n];if(i===K&&(i=Zn(n)),typeof i>"u"&&!r)throw new X("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new Z("intrinsic "+e+" does not exist!")};sr.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new X("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new X('"allowMissing" argument must be a boolean');if(to(/^%?[^%]*%?$/,e)===null)throw new Z("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=oo(e),o=n.length>0?n[0]:"",i=io("%"+o+"%",r),a=i.name,f=i.value,s=!1,c=i.alias;c&&(o=c[0],eo(n,Qn([0,1],c)));for(var p=1,m=!0;p<n.length;p+=1){var u=n[p],S=be(u,0,1),v=be(u,-1);if((S==='"'||S==="'"||S==="`"||v==='"'||v==="'"||v==="`")&&S!==v)throw new Z("property names with quotes must have matching quotes");if((u==="constructor"||!m)&&(s=!0),o+="."+u,a="%"+o+"%",ve(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new X("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);m=!!k,m&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else m=ve(f,u),f=f[u];m&&!s&&(L[a]=f)}}return f}});var Pe=d((mi,fr)=>{"use strict";var ao=Q(),we=ao("%Object.defineProperty%",!0)||!1;if(we)try{we({},"a",{value:1})}catch{we=!1}fr.exports=we});var Ge=d((hi,ur)=>{"use strict";var so=Q(),xe=so("%Object.getOwnPropertyDescriptor%",!0);if(xe)try{xe([],"length")}catch{xe=null}ur.exports=xe});var yr=d((vi,cr)=>{"use strict";var lr=Pe(),fo=Le(),ee=ie(),pr=Ge();cr.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new ee("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new ee("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new ee("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new ee("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new ee("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new ee("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!pr&&pr(e,r);if(lr)lr(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new fo("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var mr=d((bi,gr)=>{"use strict";var ze=Pe(),dr=function(){return!!ze};dr.hasArrayLengthDefineBug=function(){if(!ze)return null;try{return ze([],"length",{value:1}).length!==1}catch{return!0}};gr.exports=dr});var Pr=d((wi,wr)=>{"use strict";var uo=Q(),hr=yr(),lo=mr()(),vr=Ge(),br=ie(),po=uo("%Math.floor%");wr.exports=function(e,r){if(typeof e!="function")throw new br("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||po(r)!==r)throw new br("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&vr){var a=vr(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(lo?hr(e,"length",r,!0,!0):hr(e,"length",r)),e}});var We=d((Pi,Ae)=>{"use strict";var Ve=he(),Ee=Q(),co=Pr(),yo=ie(),Er=Ee("%Function.prototype.apply%"),Sr=Ee("%Function.prototype.call%"),Or=Ee("%Reflect.apply%",!0)||Ve.call(Sr,Er),xr=Pe(),go=Ee("%Math.max%");Ae.exports=function(e){if(typeof e!="function")throw new yo("a function is required");var r=Or(Ve,Sr,arguments);return co(r,1+go(0,e.length-(arguments.length-1)),!0)};var Ar=function(){return Or(Ve,Er,arguments)};xr?xr(Ae.exports,"apply",{value:Ar}):Ae.exports.apply=Ar});var Ir=d((xi,kr)=>{"use strict";var Tr=Q(),Fr=We(),mo=Fr(Tr("String.prototype.indexOf"));kr.exports=function(e,r){var n=Tr(e,!!r);return typeof n=="function"&&mo(e,".prototype.")>-1?Fr(n):n}});var Br=d((Ai,Rr)=>{"use strict";var Se=(typeof JSON<"u"?JSON:dt()).stringify,ho=mt(),vo=$t(),bo=We(),Mr=Ir(),$r=Mr("Array.prototype.join"),Ye=Mr("Array.prototype.push"),jr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},wo=function(t,e,r){return r};Rr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=jr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?bo(r.replacer):wo,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(c){var p=a.length>2&&function(u){return c[u]};return function(m,u){return a({key:m,value:c[m]},{key:u,value:c[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function c(p,m,u,S){var v=n?`
9
+ `+jr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,m,u),u!==void 0){if(typeof u!="object"||u===null)return Se(u);if(ho(u)){for(var j=[],b=0;b<u.length;b++){var _=c(u,b,u[b],S+1)||Se(null);Ye(j,v+n+_)}return"["+$r(j,",")+v+"]"}if(s.indexOf(u)!==-1){if(o)return Se("__cycle__");throw new TypeError("Converting circular structure to JSON")}else Ye(s,u);for(var P=vo(u).sort(f&&f(u)),j=[],b=0;b<P.length;b++){var m=P[b],M=c(u,m,u[m],S+1);if(M){var ln=Se(m)+k+M;Ye(j,v+n+ln)}}return s.splice(s.indexOf(u),1),"{"+$r(j,",")+v+"}"}}({"":e},"",e,0)}});var et=d(h=>{"use strict";var Lr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function xo(t){let{definitions:e,nullable:r,metadata:n}=t,o=Lr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=xo;function qr(t){return"ref"in t}h.isRefForm=qr;function Ao(t){return"type"in t}h.isTypeForm=Ao;function Hr(t){return"enum"in t}h.isEnumForm=Hr;function Jr(t){return"elements"in t}h.isElementsForm=Jr;function Qe(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=Qe;function Gr(t){return"values"in t}h.isValuesForm=Gr;function zr(t){return"discriminator"in t}h.isDiscriminatorForm=zr;function q(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!q(r,e))return!1}if(qr(t)&&!(t.ref in(e.definitions||{}))||Hr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(Jr(t))return q(t.elements,e);if(Qe(t)){for(let r of Object.values(t.properties||{}))if(!q(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!q(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(Gr(t))return q(t.values,e);if(zr(t)){for(let r of Object.values(t.mapping))if(!q(r,e)||!Qe(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=q;var Eo=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],So=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function H(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:c=void 0,optionalProperties:p=void 0,additionalProperties:m=void 0,values:u=void 0,discriminator:S=void 0,mapping:v=void 0}=e,k=Lr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),b=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,c!==void 0,p!==void 0,m!==void 0,u!==void 0,S!==void 0,v!==void 0],_=!1;for(let P of Eo)_=_||P.every((j,M)=>j===b[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!H(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!So.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!H(s))return!1;if(c!==void 0){if(typeof c!="object"||Array.isArray(c)||c===null)return!1;for(let P of Object.values(c))if(!H(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!H(P))return!1}if(m!==void 0&&typeof m!="boolean"||u!==void 0&&!H(u)||S!==void 0&&typeof S!="string")return!1;if(v!==void 0){if(typeof v!="object"||Array.isArray(v)||v===null)return!1;for(let P of Object.values(v))if(!H(P))return!1}return Object.keys(k).length===0}h.isSchema=H});var Vr=d(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});var Oo=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function To(t){let e=t.match(Oo);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>Fo(r,n)||i>23||a>59||f>60)}tt.default=To;function Fo(t,e){return e===2?ko(t)?29:28:Io[e]}function ko(t){return t%4===0&&(t%100!==0||t%400===0)}var Io=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Wr=d(B=>{"use strict";var $o=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var jo=$o(Vr()),J=et(),Fe=class extends Error{};B.MaxDepthExceededError=Fe;var ke=class extends Error{};function Mo(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{V(n,t,e)}catch(o){if(!(o instanceof ke))throw o}return n.errors}B.validate=Mo;function V(t,e,r,n){if(!(e.nullable&&r===null)){if(J.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Fe;t.schemaTokens.push(["definitions",e.ref]),V(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(J.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":te(t,r,-128,127);break;case"uint8":te(t,r,0,255);break;case"int16":te(t,r,-32768,32767);break;case"uint16":te(t,r,0,65535);break;case"int32":te(t,r,-2147483648,2147483647);break;case"uint32":te(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):jo.default(r)||E(t);break}O(t)}else if(J.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(J.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())G(t,o.toString()),V(t,e.elements,i),z(t);else E(t);O(t)}else if(J.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(G(t,o),V(t,i,r[o]),z(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(G(t,o),V(t,i,r[o]),z(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(G(t,o),E(t),z(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(J.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))G(t,o),V(t,e.values,i),z(t);else E(t);O(t)}else if(J.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),V(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),G(t,e.discriminator),E(t),z(t),O(t)):(A(t,"discriminator"),G(t,e.discriminator),E(t),z(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function te(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function G(t,e){t.instanceTokens.push(e)}function z(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new ke}});var Kr=d(C=>{"use strict";var Ro=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Yr=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Ro(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Yr(et(),C);Yr(Wr(),C)});var zo={};mn(zo,{GenerationError:()=>je,ResponseError:()=>W,builtinFontNames:()=>No,builtinLineHeights:()=>sn,builtinMargins:()=>an,builtinTextScales:()=>on,builtinTools:()=>Uo,formatEntry:()=>fn,parseEntry:()=>un,register:()=>Jo,remarkable:()=>Go});module.exports=hn(zo);var tn=re(at()),rn=re(Br());var Cr=re(require("crypto")),Te=new Uint8Array(256),Oe=Te.length;function Ke(){return Oe>Te.length-16&&(Cr.default.randomFillSync(Te),Oe=0),Te.slice(Oe,Oe+=16)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function _r(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var Ur=re(require("crypto")),Xe={randomUUID:Ur.default.randomUUID};function Po(t,e,r){if(Xe.randomUUID&&!e&&!t)return Xe.randomUUID();t=t||{};let n=t.random||(t.rng||Ke)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return _r(n)}var se=Po;function Ze(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Nr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function Dr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Xr=re(Kr());function fe(t,e,r=!0){if((r?(0,Xr.validate)(t,e):[]).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Zr="3",nn="https://webapp-prod.cloud.remarkable.engineering",Bo="https://internal.cloud.remarkable.com",Qr="x-goog-generation",Co="x-goog-if-generation-match",_o="x-goog-content-length-range",Uo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],No=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],on={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},an={sm:50,md:125,rr:180,lg:200},sn={df:-1,md:100,lg:150,xl:200},Do={properties:{docID:{type:"string"},hash:{type:"string"}}},Lo={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},Ie={visibleName:{type:"string"}},$e={lastModified:{type:"string"},version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},qo={discriminator:"type",mapping:{CollectionType:{properties:Ie,optionalProperties:$e,additionalProperties:!0},DocumentType:{properties:Ie,optionalProperties:{...$e,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},en={id:{type:"string"},hash:{type:"string"}},Ho={discriminator:"type",mapping:{CollectionType:{properties:{...Ie,...en},optionalProperties:$e,additionalProperties:!0},DocumentType:{properties:{...Ie,...en,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...$e,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},W=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},je=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function Jo(t,{deviceDesc:e="browser-chrome",uuid:r=se(),authHost:n=nn,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new W(i.status,i.statusText,"couldn't register api")}function fn({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
+ `}function un(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var rt=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new W(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[_o]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new W(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return fe(Lo,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Qr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[Co]:`${r}`})}catch(f){throw f instanceof W&&f.status===412?(this.#t=null,new je):f}let i=o.headers.get(Qr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e,{verify:r=!0}={}){let n=await this.getJson(e);return fe(qo,n,r),n}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
+ `);if(n!==Zr)throw new Error(`got unexpected schema version: ${n}`);return o.map(un)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,m)=>p.documentId.localeCompare(m.documentId));let o=Dr(r.map(p=>Nr(p.hash))),i=await this.#f.digest("SHA-256",o),a=Ze(i),f=r.map(fn).join(""),s=`${Zr}
12
+ ${f}`,c=n.encode(s);return await this.#p(a,c),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=Ze(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,rn.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=se(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=se(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let c={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,c)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:c="",cover:p="visited",lastTool:m}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:m},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?sn[s]:s,margins:typeof o=="string"?an[o]:o,textScale:typeof f=="string"?on[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:c};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let b=f.find(M=>M.documentId===r);if(b){if(b.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(b.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(b=>b.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[c]=f.splice(s,1);if(c.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(c.hash),m=p.findIndex(b=>b.documentId===`${e}.metadata`);if(m===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(m,1),S=await this.getMetadata(u.hash);S.parent=r;let v=await this.putMetadata(e,S);p.push(v);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata({verify:e=!0}={}){let n=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),o=JSON.parse(n);return fe({elements:Ho},o,e),o}async#d(e,r,n,o){let a=new TextEncoder().encode(JSON.stringify({file_name:e})),s=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,tn.fromByteArray)(a),"rm-source":"RoR-Browser"}})).text(),c=JSON.parse(s);return fe(Do,c,o),c}async uploadEpub(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/epub+zip",n)}async uploadPdf(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/pdf",n)}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function Go(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=nn,syncHost:o=Bo,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new rt(s,e,r,o,i,a)}0&&(module.exports={GenerationError,ResponseError,builtinFontNames,builtinLineHeights,builtinMargins,builtinTextScales,builtinTools,formatEntry,parseEntry,register,remarkable});
@@ -1,12 +1,12 @@
1
- var Rr=Object.create;var et=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Cr(e))!Ur.call(t,o)&&o!==r&&et(t,o,{get:()=>e[o],enumerable:!(n=Br(e,o))||n.enumerable});return t};var Fe=(t,e,r)=>(r=t!=null?Rr(_r(t)):{},Nr(e||!t||!t.__esModule?et(r,"default",{value:t,enumerable:!0}):r,t));var nt=m(le=>{"use strict";le.byteLength=Lr;le.toByteArray=Jr;le.fromByteArray=Vr;var I=[],F=[],Dr=typeof Uint8Array<"u"?Uint8Array:Array,ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,tt=ke.length;U<tt;++U)I[U]=ke[U],F[ke.charCodeAt(U)]=U;var U,tt;F[45]=62;F[95]=63;function rt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lr(t){var e=rt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Hr(t,e,r){return(e+r)*3/4-r}function Jr(t){var e,r=rt(t),n=r[0],o=r[1],i=new Dr(Hr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Gr(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function qr(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Gr(n));return o.join("")}function Vr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(qr(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ft=m((yo,st)=>{"use strict";var pe,l,ot={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "},Ie;function R(t){throw{name:"SyntaxError",message:t,at:pe,text:Ie}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Ie.charAt(pe),pe+=1,l}function it(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function at(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof ot[l]=="string")r+=ot[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function zr(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function Wr(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(ce()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function Yr(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=at(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=ce(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function ce(){switch($(),l){case"{":return Yr();case"[":return Wr();case'"':return at();case"-":return it();default:return l>="0"&&l<="9"?it():zr()}}st.exports=function(t,e){var r;return Ie=t,pe=0,l=" ",r=ce(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in ce)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var lt=m((go,ut)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ye,Kr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function $e(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=Kr[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function de(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return $e(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ye,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=de(r,s)||"null";return o=f.length===0?"[]":T?`[
1
+ var tn=Object.create;var tt=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var on=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var sn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nn(e))!an.call(t,o)&&o!==r&&tt(t,o,{get:()=>e[o],enumerable:!(n=rn(e,o))||n.enumerable});return t};var ke=(t,e,r)=>(r=t!=null?tn(on(t)):{},sn(e||!t||!t.__esModule?tt(r,"default",{value:t,enumerable:!0}):r,t));var ot=d(fe=>{"use strict";fe.byteLength=un;fe.toByteArray=pn;fe.fromByteArray=dn;var I=[],F=[],fn=typeof Uint8Array<"u"?Uint8Array:Array,Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,rt=Ie.length;U<rt;++U)I[U]=Ie[U],F[Ie.charCodeAt(U)]=U;var U,rt;F[45]=62;F[95]=63;function nt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function un(t){var e=nt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ln(t,e,r){return(e+r)*3/4-r}function pn(t){var e,r=nt(t),n=r[0],o=r[1],i=new fn(ln(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function cn(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function yn(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(cn(n));return o.join("")}function dn(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(yn(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ut=d((Lo,ft)=>{"use strict";var ue,l,it={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},$e;function M(t){throw{name:"SyntaxError",message:t,at:ue,text:$e}}function g(t){return t&&t!==l&&M("Expected '"+t+"' instead of '"+l+"'"),l=$e.charAt(ue),ue+=1,l}function at(){var t,e="";for(l==="-"&&(e="-",g("-"));l>="0"&&l<="9";)e+=l,g();if(l===".")for(e+=".";g()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,g(),(l==="-"||l==="+")&&(e+=l,g());l>="0"&&l<="9";)e+=l,g();return t=Number(e),isFinite(t)||M("Bad number"),t}function st(){var t,e,r="",n;if(l==='"')for(;g();){if(l==='"')return g(),r;if(l==="\\")if(g(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(g(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof it[l]=="string")r+=it[l];else break;else r+=l}M("Bad string")}function $(){for(;l&&l<=" ";)g()}function gn(){switch(l){case"t":return g("t"),g("r"),g("u"),g("e"),!0;case"f":return g("f"),g("a"),g("l"),g("s"),g("e"),!1;case"n":return g("n"),g("u"),g("l"),g("l"),null;default:M("Unexpected '"+l+"'")}}function mn(){var t=[];if(l==="["){if(g("["),$(),l==="]")return g("]"),t;for(;l;){if(t.push(le()),$(),l==="]")return g("]"),t;g(","),$()}}M("Bad array")}function hn(){var t,e={};if(l==="{"){if(g("{"),$(),l==="}")return g("}"),e;for(;l;){if(t=st(),$(),g(":"),Object.prototype.hasOwnProperty.call(e,t)&&M('Duplicate key "'+t+'"'),e[t]=le(),$(),l==="}")return g("}"),e;g(","),$()}}M("Bad object")}function le(){switch($(),l){case"{":return hn();case"[":return mn();case'"':return st();case"-":return at();default:return l>="0"&&l<="9"?at():gn()}}ft.exports=function(t,e){var r;return $e=t,ue=0,l=" ",r=le(),$(),l&&M("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in le)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var pt=d((qo,lt)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,pe,vn={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function Re(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=vn[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function ce(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return Re(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=pe,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=ce(r,s)||"null";return o=f.length===0?"[]":T?`[
3
3
  `+T+f.join(`,
4
4
  `+T)+`
5
- `+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
5
+ `+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=ce(n,s),o&&f.push(Re(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=ce(n,s),o&&f.push(Re(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
6
6
  `+T+f.join(`,
7
7
  `+T)+`
8
- `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}ut.exports=function(t,e,r){var n;if(T="",ye="",typeof r=="number")for(n=0;n<r;n+=1)ye+=" ";else typeof r=="string"&&(ye=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return de("",{"":t})}});var pt=m(Me=>{"use strict";Me.parse=ft();Me.stringify=lt()});var yt=m((ho,ct)=>{var Xr={}.toString;ct.exports=Array.isArray||function(t){return Xr.call(t)=="[object Array]"}});var Re=m((vo,gt)=>{"use strict";var dt=Object.prototype.toString;gt.exports=function(e){var r=dt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&dt.call(e.callee)==="[object Function]"),n}});var Et=m((bo,At)=>{"use strict";var xt;Object.keys||(ne=Object.prototype.hasOwnProperty,Be=Object.prototype.toString,mt=Re(),Ce=Object.prototype.propertyIsEnumerable,ht=!Ce.call({toString:null},"toString"),vt=Ce.call(function(){},"prototype"),oe=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ge=function(t){var e=t.constructor;return e&&e.prototype===t},bt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},wt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!bt["$"+t]&&ne.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ge(window[t])}catch{return!0}}catch{return!0}return!1}(),Pt=function(t){if(typeof window>"u"||!wt)return ge(t);try{return ge(t)}catch{return!1}},xt=function(e){var r=e!==null&&typeof e=="object",n=Be.call(e)==="[object Function]",o=mt(e),i=r&&Be.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=vt&&n;if(i&&e.length>0&&!ne.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&ne.call(e,p)&&a.push(String(p));if(ht)for(var g=Pt(e),u=0;u<oe.length;++u)!(g&&oe[u]==="constructor")&&ne.call(e,oe[u])&&a.push(oe[u]);return a});var ne,Be,mt,Ce,ht,vt,oe,ge,bt,wt,Pt;At.exports=xt});var Ft=m((wo,Tt)=>{"use strict";var Zr=Array.prototype.slice,Qr=Re(),St=Object.keys,me=St?function(e){return St(e)}:Et(),Ot=Object.keys;me.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Qr(n)?Ot(Zr.call(n)):Ot(n)})}else Object.keys=me;return Object.keys||me};Tt.exports=me});var jt=m((Po,It)=>{"use strict";var en="Function.prototype.bind called on incompatible ",tn=Object.prototype.toString,rn=Math.max,nn="[object Function]",kt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},on=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},an=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};It.exports=function(e){var r=this;if(typeof r!="function"||tn.apply(r)!==nn)throw new TypeError(en+r);for(var n=on(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,kt(n,arguments));return Object(p)===p?p:this}return r.apply(e,kt(n,arguments))},a=rn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+an(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var he=m((xo,$t)=>{"use strict";var sn=jt();$t.exports=Function.prototype.bind||sn});var Rt=m((Ao,Mt)=>{"use strict";Mt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var _t=m((Eo,Ct)=>{"use strict";var Bt=typeof Symbol<"u"&&Symbol,fn=Rt();Ct.exports=function(){return typeof Bt!="function"||typeof Symbol!="function"||typeof Bt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fn()}});var Dt=m((So,Nt)=>{"use strict";var Ut={foo:{}},un=Object;Nt.exports=function(){return{__proto__:Ut}.foo===Ut.foo&&!({__proto__:null}instanceof un)}});var Ht=m((Oo,Lt)=>{"use strict";var ln=Function.prototype.call,pn=Object.prototype.hasOwnProperty,cn=he();Lt.exports=cn.call(ln,pn)});var Z=m((To,zt)=>{"use strict";var c,X=SyntaxError,Vt=Function,K=TypeError,_e=function(t){try{return Vt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Ue=function(){throw new K},yn=D?function(){try{return arguments.callee,Ue}catch{try{return D(arguments,"callee").get}catch{return Ue}}}():Ue,W=_t()(),dn=Dt()(),w=Object.getPrototypeOf||(dn?function(t){return t.__proto__}:null),Y={},gn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Vt,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):c,"%Symbol%":W?Symbol:c,"%SyntaxError%":X,"%ThrowTypeError%":yn,"%TypedArray%":gn,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){Jt=w(w(t)),L["%Error.prototype%"]=Jt}var Jt,mn=function t(e){var r;if(e==="%AsyncFunction%")r=_e("async function () {}");else if(e==="%GeneratorFunction%")r=_e("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=_e("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},Gt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=he(),ve=Ht(),hn=ie.call(Function.call,Array.prototype.concat),vn=ie.call(Function.apply,Array.prototype.splice),qt=ie.call(Function.call,String.prototype.replace),be=ie.call(Function.call,String.prototype.slice),bn=ie.call(Function.call,RegExp.prototype.exec),wn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Pn=/\\(\\)?/g,xn=function(e){var r=be(e,0,1),n=be(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return qt(e,wn,function(i,a,f,s){o[o.length]=f?qt(s,Pn,"$1"):a||i}),o},An=function(e,r){var n=e,o;if(ve(Gt,n)&&(o=Gt[n],n="%"+o[0]+"%"),ve(L,n)){var i=L[n];if(i===Y&&(i=mn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};zt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(bn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=xn(e),o=n.length>0?n[0]:"",i=An("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],vn(n,hn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=be(u,0,1),b=be(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",ve(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=ve(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Le=m((Fo,Wt)=>{"use strict";var En=Z(),Ne=En("%Object.defineProperty%",!0),De=function(){if(Ne)try{return Ne({},"a",{value:1}),!0}catch{return!1}return!1};De.hasArrayLengthDefineBug=function(){if(!De())return null;try{return Ne([],"length",{value:1}).length!==1}catch{return!0}};Wt.exports=De});var He=m((ko,Yt)=>{"use strict";var Sn=Z(),we=Sn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}Yt.exports=we});var Zt=m((Io,Xt)=>{"use strict";var On=Le()(),Je=Z(),ae=On&&Je("%Object.defineProperty%",!0);if(ae)try{ae({},"a",{value:1})}catch{ae=!1}var Tn=Je("%SyntaxError%"),Q=Je("%TypeError%"),Kt=He();Xt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Kt&&Kt(e,r);if(ae)ae(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Tn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var or=m((jo,nr)=>{"use strict";var rr=Z(),Qt=Zt(),Fn=Le()(),er=He(),tr=rr("%TypeError%"),kn=rr("%Math.floor%");nr.exports=function(e,r){if(typeof e!="function")throw new tr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||kn(r)!==r)throw new tr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&er){var a=er(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Fn?Qt(e,"length",r,!0,!0):Qt(e,"length",r)),e}});var ur=m(($o,Pe)=>{"use strict";var Ge=he(),ee=Z(),In=or(),jn=ee("%TypeError%"),ar=ee("%Function.prototype.apply%"),sr=ee("%Function.prototype.call%"),fr=ee("%Reflect.apply%",!0)||Ge.call(sr,ar),se=ee("%Object.defineProperty%",!0),$n=ee("%Math.max%");if(se)try{se({},"a",{value:1})}catch{se=null}Pe.exports=function(e){if(typeof e!="function")throw new jn("a function is required");var r=fr(Ge,sr,arguments);return In(r,1+$n(0,e.length-(arguments.length-1)),!0)};var ir=function(){return fr(Ge,ar,arguments)};se?se(Pe.exports,"apply",{value:ir}):Pe.exports.apply=ir});var cr=m((Mo,pr)=>{"use strict";var xe=(typeof JSON<"u"?JSON:pt()).stringify,Mn=yt(),Rn=Ft(),Bn=ur(),lr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},Cn=function(t,e,r){return r};pr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=lr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?Bn(r.replacer):Cn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
9
- `+lr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return xe(u);if(Mn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||xe(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return xe("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Rn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],Qe=y(u,g,u[g],S+1);if(Qe){var Mr=xe(g)+k+Qe;j+=(M?",":"")+b+n+Mr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ye=m(h=>{"use strict";var mr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Dn(t){let{definitions:e,nullable:r,metadata:n}=t,o=mr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Dn;function hr(t){return"ref"in t}h.isRefForm=hr;function Ln(t){return"type"in t}h.isTypeForm=Ln;function vr(t){return"enum"in t}h.isEnumForm=vr;function br(t){return"elements"in t}h.isElementsForm=br;function We(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=We;function wr(t){return"values"in t}h.isValuesForm=wr;function Pr(t){return"discriminator"in t}h.isDiscriminatorForm=Pr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(hr(t)&&!(t.ref in(e.definitions||{}))||vr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(br(t))return H(t.elements,e);if(We(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(wr(t))return H(t.values,e);if(Pr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!We(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Hn=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Jn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=mr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Hn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Jn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var xr=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Gn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function qn(t){let e=t.match(Gn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>Vn(r,n)||i>23||a>59||f>60)}Ke.default=qn;function Vn(t,e){return e===2?zn(t)?29:28:Wn[e]}function zn(t){return t%4===0&&(t%100!==0||t%400===0)}var Wn=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ar=m(B=>{"use strict";var Yn=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Kn=Yn(xr()),G=Ye(),Ee=class extends Error{};B.MaxDepthExceededError=Ee;var Se=class extends Error{};function Xn(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Se))throw o}return n.errors}B.validate=Xn;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Ee;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":te(t,r,-128,127);break;case"uint8":te(t,r,0,255);break;case"int16":te(t,r,-32768,32767);break;case"uint16":te(t,r,0,65535);break;case"int32":te(t,r,-2147483648,2147483647);break;case"uint32":te(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Kn.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function te(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Se}});var Sr=m(C=>{"use strict";var Zn=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Er=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Zn(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Er(Ye(),C);Er(Ar(),C)});var Ir=Fe(nt()),jr=Fe(cr());var Ae,_n=new Uint8Array(16);function qe(){if(!Ae&&(Ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ae))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ae(_n)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function yr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var Un=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ve={randomUUID:Un};function Nn(t,e,r){if(Ve.randomUUID&&!e&&!t)return Ve.randomUUID();t=t||{};let n=t.random||(t.rng||qe)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return yr(n)}var fe=Nn;function ze(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function dr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function gr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Or=Fe(Sr());function ue(t,e){if((0,Or.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Tr="3",$r="https://webapp-prod.cloud.remarkable.engineering",Qn="https://internal.cloud.remarkable.com",Fr="x-goog-generation",eo="x-goog-if-generation-match",to="x-goog-content-length-range",Qo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],ei=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],ro={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},no={sm:50,md:125,rr:180,lg:200},oo={df:-1,md:100,lg:150,xl:200},io={properties:{docID:{type:"string"},hash:{type:"string"}}},ao={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},Oe={visibleName:{type:"string"},lastModified:{type:"string"}},Te={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},so={discriminator:"type",mapping:{CollectionType:{properties:Oe,optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:Oe,optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},kr={id:{type:"string"},hash:{type:"string"}},fo={discriminator:"type",mapping:{CollectionType:{properties:{...Oe,...kr},optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:{...Oe,...kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},re=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Xe=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function ti(t,{deviceDesc:e="browser-chrome",uuid:r=fe(),authHost:n=$r,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new re(i.status,i.statusText,"couldn't register api")}function uo({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
- `}function lo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Ze=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new re(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[to]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new re(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return ue(ao,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Fr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[eo]:`${r}`})}catch(f){throw f instanceof re&&f.status===412?(this.#t=null,new Xe):f}let i=o.headers.get(Fr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return ue(so,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
- `);if(n!==Tr)throw new Error(`got unexpected schema version: ${n}`);return o.map(lo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=gr(r.map(p=>dr(p.hash))),i=await this.#f.digest("SHA-256",o),a=ze(i),f=r.map(uo).join(""),s=`${Tr}
12
- ${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=ze(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,jr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=fe(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=fe(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?oo[s]:s,margins:typeof o=="string"?no[o]:o,textScale:typeof f=="string"?ro[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return ue({elements:fo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Ir.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return ue(io,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function ri(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=$r,syncHost:o=Qn,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new Ze(s,e,r,o,i,a)}export{Xe as GenerationError,re as ResponseError,ei as builtinFontNames,oo as builtinLineHeights,no as builtinMargins,ro as builtinTextScales,Qo as builtinTools,uo as formatEntry,lo as parseEntry,ti as register,ri as remarkable};
8
+ `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}lt.exports=function(t,e,r){var n;if(T="",pe="",typeof r=="number")for(n=0;n<r;n+=1)pe+=" ";else typeof r=="string"&&(pe=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return ce("",{"":t})}});var ct=d(Me=>{"use strict";Me.parse=ut();Me.stringify=pt()});var dt=d((Jo,yt)=>{var bn={}.toString;yt.exports=Array.isArray||function(t){return bn.call(t)=="[object Array]"}});var Be=d((Go,mt)=>{"use strict";var gt=Object.prototype.toString;mt.exports=function(e){var r=gt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&gt.call(e.callee)==="[object Function]"),n}});var St=d((Vo,Et)=>{"use strict";var At;Object.keys||(re=Object.prototype.hasOwnProperty,Ce=Object.prototype.toString,ht=Be(),_e=Object.prototype.propertyIsEnumerable,vt=!_e.call({toString:null},"toString"),bt=_e.call(function(){},"prototype"),ne=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ye=function(t){var e=t.constructor;return e&&e.prototype===t},wt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},Pt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!wt["$"+t]&&re.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ye(window[t])}catch{return!0}}catch{return!0}return!1}(),xt=function(t){if(typeof window>"u"||!Pt)return ye(t);try{return ye(t)}catch{return!1}},At=function(e){var r=e!==null&&typeof e=="object",n=Ce.call(e)==="[object Function]",o=ht(e),i=r&&Ce.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=bt&&n;if(i&&e.length>0&&!re.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var c=0;c<e.length;++c)a.push(String(c));else for(var p in e)!(f&&p==="prototype")&&re.call(e,p)&&a.push(String(p));if(vt)for(var m=xt(e),u=0;u<ne.length;++u)!(m&&ne[u]==="constructor")&&re.call(e,ne[u])&&a.push(ne[u]);return a});var re,Ce,ht,_e,vt,bt,ne,ye,wt,Pt,xt;Et.exports=At});var kt=d((zo,Ft)=>{"use strict";var wn=Array.prototype.slice,Pn=Be(),Ot=Object.keys,de=Ot?function(e){return Ot(e)}:St(),Tt=Object.keys;de.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Pn(n)?Tt(wn.call(n)):Tt(n)})}else Object.keys=de;return Object.keys||de};Ft.exports=de});var jt=d((Wo,$t)=>{"use strict";var xn="Function.prototype.bind called on incompatible ",An=Object.prototype.toString,En=Math.max,Sn="[object Function]",It=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},On=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},Tn=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};$t.exports=function(e){var r=this;if(typeof r!="function"||An.apply(r)!==Sn)throw new TypeError(xn+r);for(var n=On(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,It(n,arguments));return Object(p)===p?p:this}return r.apply(e,It(n,arguments))},a=En(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+Tn(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var c=function(){};c.prototype=r.prototype,o.prototype=new c,c.prototype=null}return o}});var ge=d((Yo,Rt)=>{"use strict";var Fn=jt();Rt.exports=Function.prototype.bind||Fn});var Bt=d((Ko,Mt)=>{"use strict";Mt.exports=Error});var _t=d((Xo,Ct)=>{"use strict";Ct.exports=EvalError});var Nt=d((Zo,Ut)=>{"use strict";Ut.exports=RangeError});var Lt=d((Qo,Dt)=>{"use strict";Dt.exports=ReferenceError});var Ue=d((ei,qt)=>{"use strict";qt.exports=SyntaxError});var oe=d((ti,Ht)=>{"use strict";Ht.exports=TypeError});var Gt=d((ri,Jt)=>{"use strict";Jt.exports=URIError});var zt=d((ni,Vt)=>{"use strict";Vt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var Kt=d((oi,Yt)=>{"use strict";var Wt=typeof Symbol<"u"&&Symbol,kn=zt();Yt.exports=function(){return typeof Wt!="function"||typeof Symbol!="function"||typeof Wt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:kn()}});var Zt=d((ii,Xt)=>{"use strict";var Ne={__proto__:null,foo:{}},In=Object;Xt.exports=function(){return{__proto__:Ne}.foo===Ne.foo&&!(Ne instanceof In)}});var er=d((ai,Qt)=>{"use strict";var $n=Function.prototype.call,jn=Object.prototype.hasOwnProperty,Rn=ge();Qt.exports=Rn.call($n,jn)});var Z=d((si,ir)=>{"use strict";var y,Mn=Bt(),Bn=_t(),Cn=Nt(),_n=Lt(),X=Ue(),K=oe(),Un=Gt(),or=Function,De=function(t){try{return or('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Le=function(){throw new K},Nn=D?function(){try{return arguments.callee,Le}catch{try{return D(arguments,"callee").get}catch{return Le}}}():Le,W=Kt()(),Dn=Zt()(),w=Object.getPrototypeOf||(Dn?function(t){return t.__proto__}:null),Y={},Ln=typeof Uint8Array>"u"||!w?y:w(Uint8Array),L={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?y:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?y:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):y,"%AsyncFromSyncIteratorPrototype%":y,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?y:Atomics,"%BigInt%":typeof BigInt>"u"?y:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?y:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Mn,"%eval%":eval,"%EvalError%":Bn,"%Float32Array%":typeof Float32Array>"u"?y:Float32Array,"%Float64Array%":typeof Float64Array>"u"?y:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?y:FinalizationRegistry,"%Function%":or,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?y:Int8Array,"%Int16Array%":typeof Int16Array>"u"?y:Int16Array,"%Int32Array%":typeof Int32Array>"u"?y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):y,"%JSON%":typeof JSON=="object"?JSON:y,"%Map%":typeof Map>"u"?y:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?y:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?y:Promise,"%Proxy%":typeof Proxy>"u"?y:Proxy,"%RangeError%":Cn,"%ReferenceError%":_n,"%Reflect%":typeof Reflect>"u"?y:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?y:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?y:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):y,"%Symbol%":W?Symbol:y,"%SyntaxError%":X,"%ThrowTypeError%":Nn,"%TypedArray%":Ln,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?y:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?y:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?y:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?y:Uint32Array,"%URIError%":Un,"%WeakMap%":typeof WeakMap>"u"?y:WeakMap,"%WeakRef%":typeof WeakRef>"u"?y:WeakRef,"%WeakSet%":typeof WeakSet>"u"?y:WeakSet};if(w)try{null.error}catch(t){tr=w(w(t)),L["%Error.prototype%"]=tr}var tr,qn=function t(e){var r;if(e==="%AsyncFunction%")r=De("async function () {}");else if(e==="%GeneratorFunction%")r=De("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=De("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},rr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=ge(),me=er(),Hn=ie.call(Function.call,Array.prototype.concat),Jn=ie.call(Function.apply,Array.prototype.splice),nr=ie.call(Function.call,String.prototype.replace),he=ie.call(Function.call,String.prototype.slice),Gn=ie.call(Function.call,RegExp.prototype.exec),Vn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,zn=/\\(\\)?/g,Wn=function(e){var r=he(e,0,1),n=he(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return nr(e,Vn,function(i,a,f,s){o[o.length]=f?nr(s,zn,"$1"):a||i}),o},Yn=function(e,r){var n=e,o;if(me(rr,n)&&(o=rr[n],n="%"+o[0]+"%"),me(L,n)){var i=L[n];if(i===Y&&(i=qn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};ir.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(Gn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Wn(e),o=n.length>0?n[0]:"",i=Yn("%"+o+"%",r),a=i.name,f=i.value,s=!1,c=i.alias;c&&(o=c[0],Jn(n,Hn([0,1],c)));for(var p=1,m=!0;p<n.length;p+=1){var u=n[p],S=he(u,0,1),v=he(u,-1);if((S==='"'||S==="'"||S==="`"||v==='"'||v==="'"||v==="`")&&S!==v)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!m)&&(s=!0),o+="."+u,a="%"+o+"%",me(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);m=!!k,m&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else m=me(f,u),f=f[u];m&&!s&&(L[a]=f)}}return f}});var be=d((fi,ar)=>{"use strict";var Kn=Z(),ve=Kn("%Object.defineProperty%",!0)||!1;if(ve)try{ve({},"a",{value:1})}catch{ve=!1}ar.exports=ve});var qe=d((ui,sr)=>{"use strict";var Xn=Z(),we=Xn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}sr.exports=we});var pr=d((li,lr)=>{"use strict";var fr=be(),Zn=Ue(),Q=oe(),ur=qe();lr.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!ur&&ur(e,r);if(fr)fr(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Zn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var dr=d((pi,yr)=>{"use strict";var He=be(),cr=function(){return!!He};cr.hasArrayLengthDefineBug=function(){if(!He)return null;try{return He([],"length",{value:1}).length!==1}catch{return!0}};yr.exports=cr});var br=d((ci,vr)=>{"use strict";var Qn=Z(),gr=pr(),eo=dr()(),mr=qe(),hr=oe(),to=Qn("%Math.floor%");vr.exports=function(e,r){if(typeof e!="function")throw new hr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||to(r)!==r)throw new hr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&mr){var a=mr(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(eo?gr(e,"length",r,!0,!0):gr(e,"length",r)),e}});var Ge=d((yi,Pe)=>{"use strict";var Je=ge(),xe=Z(),ro=br(),no=oe(),xr=xe("%Function.prototype.apply%"),Ar=xe("%Function.prototype.call%"),Er=xe("%Reflect.apply%",!0)||Je.call(Ar,xr),wr=be(),oo=xe("%Math.max%");Pe.exports=function(e){if(typeof e!="function")throw new no("a function is required");var r=Er(Je,Ar,arguments);return ro(r,1+oo(0,e.length-(arguments.length-1)),!0)};var Pr=function(){return Er(Je,xr,arguments)};wr?wr(Pe.exports,"apply",{value:Pr}):Pe.exports.apply=Pr});var Fr=d((di,Tr)=>{"use strict";var Sr=Z(),Or=Ge(),io=Or(Sr("String.prototype.indexOf"));Tr.exports=function(e,r){var n=Sr(e,!!r);return typeof n=="function"&&io(e,".prototype.")>-1?Or(n):n}});var Rr=d((gi,jr)=>{"use strict";var Ae=(typeof JSON<"u"?JSON:ct()).stringify,ao=dt(),so=kt(),fo=Ge(),$r=Fr(),kr=$r("Array.prototype.join"),Ve=$r("Array.prototype.push"),Ir=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},uo=function(t,e,r){return r};jr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=Ir(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?fo(r.replacer):uo,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(c){var p=a.length>2&&function(u){return c[u]};return function(m,u){return a({key:m,value:c[m]},{key:u,value:c[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function c(p,m,u,S){var v=n?`
9
+ `+Ir(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,m,u),u!==void 0){if(typeof u!="object"||u===null)return Ae(u);if(ao(u)){for(var j=[],b=0;b<u.length;b++){var _=c(u,b,u[b],S+1)||Ae(null);Ve(j,v+n+_)}return"["+kr(j,",")+v+"]"}if(s.indexOf(u)!==-1){if(o)return Ae("__cycle__");throw new TypeError("Converting circular structure to JSON")}else Ve(s,u);for(var P=so(u).sort(f&&f(u)),j=[],b=0;b<P.length;b++){var m=P[b],R=c(u,m,u[m],S+1);if(R){var en=Ae(m)+k+R;Ve(j,v+n+en)}}return s.splice(s.indexOf(u),1),"{"+kr(j,",")+v+"}"}}({"":e},"",e,0)}});var Xe=d(h=>{"use strict";var _r=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function yo(t){let{definitions:e,nullable:r,metadata:n}=t,o=_r(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=yo;function Ur(t){return"ref"in t}h.isRefForm=Ur;function go(t){return"type"in t}h.isTypeForm=go;function Nr(t){return"enum"in t}h.isEnumForm=Nr;function Dr(t){return"elements"in t}h.isElementsForm=Dr;function Ke(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=Ke;function Lr(t){return"values"in t}h.isValuesForm=Lr;function qr(t){return"discriminator"in t}h.isDiscriminatorForm=qr;function q(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!q(r,e))return!1}if(Ur(t)&&!(t.ref in(e.definitions||{}))||Nr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(Dr(t))return q(t.elements,e);if(Ke(t)){for(let r of Object.values(t.properties||{}))if(!q(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!q(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(Lr(t))return q(t.values,e);if(qr(t)){for(let r of Object.values(t.mapping))if(!q(r,e)||!Ke(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=q;var mo=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],ho=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function H(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:c=void 0,optionalProperties:p=void 0,additionalProperties:m=void 0,values:u=void 0,discriminator:S=void 0,mapping:v=void 0}=e,k=_r(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),b=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,c!==void 0,p!==void 0,m!==void 0,u!==void 0,S!==void 0,v!==void 0],_=!1;for(let P of mo)_=_||P.every((j,R)=>j===b[R]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!H(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!ho.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!H(s))return!1;if(c!==void 0){if(typeof c!="object"||Array.isArray(c)||c===null)return!1;for(let P of Object.values(c))if(!H(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!H(P))return!1}if(m!==void 0&&typeof m!="boolean"||u!==void 0&&!H(u)||S!==void 0&&typeof S!="string")return!1;if(v!==void 0){if(typeof v!="object"||Array.isArray(v)||v===null)return!1;for(let P of Object.values(v))if(!H(P))return!1}return Object.keys(k).length===0}h.isSchema=H});var Hr=d(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});var vo=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function bo(t){let e=t.match(vo);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>wo(r,n)||i>23||a>59||f>60)}Ze.default=bo;function wo(t,e){return e===2?Po(t)?29:28:xo[e]}function Po(t){return t%4===0&&(t%100!==0||t%400===0)}var xo=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Jr=d(B=>{"use strict";var Ao=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Eo=Ao(Hr()),J=Xe(),Se=class extends Error{};B.MaxDepthExceededError=Se;var Oe=class extends Error{};function So(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Oe))throw o}return n.errors}B.validate=So;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(J.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Se;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(J.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":ee(t,r,-128,127);break;case"uint8":ee(t,r,0,255);break;case"int16":ee(t,r,-32768,32767);break;case"uint16":ee(t,r,0,65535);break;case"int32":ee(t,r,-2147483648,2147483647);break;case"uint32":ee(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Eo.default(r)||E(t);break}O(t)}else if(J.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(J.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())G(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(J.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(G(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(G(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(G(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(J.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))G(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(J.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),G(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),G(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function ee(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function G(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Oe}});var Vr=d(C=>{"use strict";var Oo=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Gr=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Oo(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Gr(Xe(),C);Gr(Jr(),C)});var Xr=ke(ot()),Zr=ke(Rr());var Ee,lo=new Uint8Array(16);function ze(){if(!Ee&&(Ee=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ee))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ee(lo)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function Mr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var po=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),We={randomUUID:po};function co(t,e,r){if(We.randomUUID&&!e&&!t)return We.randomUUID();t=t||{};let n=t.random||(t.rng||ze)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return Mr(n)}var ae=co;function Ye(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Br(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function Cr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var zr=ke(Vr());function se(t,e,r=!0){if((r?(0,zr.validate)(t,e):[]).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Wr="3",Qr="https://webapp-prod.cloud.remarkable.engineering",To="https://internal.cloud.remarkable.com",Yr="x-goog-generation",Fo="x-goog-if-generation-match",ko="x-goog-content-length-range",Bi=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Ci=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Io={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},$o={sm:50,md:125,rr:180,lg:200},jo={df:-1,md:100,lg:150,xl:200},Ro={properties:{docID:{type:"string"},hash:{type:"string"}}},Mo={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},Te={visibleName:{type:"string"}},Fe={lastModified:{type:"string"},version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Bo={discriminator:"type",mapping:{CollectionType:{properties:Te,optionalProperties:Fe,additionalProperties:!0},DocumentType:{properties:Te,optionalProperties:{...Fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},Kr={id:{type:"string"},hash:{type:"string"}},Co={discriminator:"type",mapping:{CollectionType:{properties:{...Te,...Kr},optionalProperties:Fe,additionalProperties:!0},DocumentType:{properties:{...Te,...Kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},te=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Qe=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function _i(t,{deviceDesc:e="browser-chrome",uuid:r=ae(),authHost:n=Qr,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new te(i.status,i.statusText,"couldn't register api")}function _o({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
+ `}function Uo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var et=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new te(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[ko]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new te(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return se(Mo,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Yr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[Fo]:`${r}`})}catch(f){throw f instanceof te&&f.status===412?(this.#t=null,new Qe):f}let i=o.headers.get(Yr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e,{verify:r=!0}={}){let n=await this.getJson(e);return se(Bo,n,r),n}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
+ `);if(n!==Wr)throw new Error(`got unexpected schema version: ${n}`);return o.map(Uo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,m)=>p.documentId.localeCompare(m.documentId));let o=Cr(r.map(p=>Br(p.hash))),i=await this.#f.digest("SHA-256",o),a=Ye(i),f=r.map(_o).join(""),s=`${Wr}
12
+ ${f}`,c=n.encode(s);return await this.#p(a,c),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=Ye(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,Zr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=ae(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=ae(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let c={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,c)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:c="",cover:p="visited",lastTool:m}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:m},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?jo[s]:s,margins:typeof o=="string"?$o[o]:o,textScale:typeof f=="string"?Io[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:c};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let b=f.find(R=>R.documentId===r);if(b){if(b.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(b.hash),[P]=_.filter(R=>R.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(b=>b.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[c]=f.splice(s,1);if(c.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(c.hash),m=p.findIndex(b=>b.documentId===`${e}.metadata`);if(m===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(m,1),S=await this.getMetadata(u.hash);S.parent=r;let v=await this.putMetadata(e,S);p.push(v);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata({verify:e=!0}={}){let n=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),o=JSON.parse(n);return se({elements:Co},o,e),o}async#d(e,r,n,o){let a=new TextEncoder().encode(JSON.stringify({file_name:e})),s=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Xr.fromByteArray)(a),"rm-source":"RoR-Browser"}})).text(),c=JSON.parse(s);return se(Ro,c,o),c}async uploadEpub(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/epub+zip",n)}async uploadPdf(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/pdf",n)}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function Ui(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=Qr,syncHost:o=To,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new et(s,e,r,o,i,a)}export{Qe as GenerationError,te as ResponseError,Ci as builtinFontNames,jo as builtinLineHeights,$o as builtinMargins,Io as builtinTextScales,Bi as builtinTools,_o as formatEntry,Uo as parseEntry,_i as register,Ui as remarkable};
@@ -1,12 +1,12 @@
1
- "use strict";(()=>{var Rr=Object.create;var et=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Cr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Ur=Object.prototype.hasOwnProperty;var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Cr(e))!Ur.call(t,o)&&o!==r&&et(t,o,{get:()=>e[o],enumerable:!(n=Br(e,o))||n.enumerable});return t};var Fe=(t,e,r)=>(r=t!=null?Rr(_r(t)):{},Nr(e||!t||!t.__esModule?et(r,"default",{value:t,enumerable:!0}):r,t));var nt=m(le=>{"use strict";le.byteLength=Lr;le.toByteArray=Jr;le.fromByteArray=Vr;var I=[],F=[],Dr=typeof Uint8Array<"u"?Uint8Array:Array,ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,tt=ke.length;U<tt;++U)I[U]=ke[U],F[ke.charCodeAt(U)]=U;var U,tt;F[45]=62;F[95]=63;function rt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function Lr(t){var e=rt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function Hr(t,e,r){return(e+r)*3/4-r}function Jr(t){var e,r=rt(t),n=r[0],o=r[1],i=new Dr(Hr(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function Gr(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function qr(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(Gr(n));return o.join("")}function Vr(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(qr(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ft=m((yo,st)=>{"use strict";var pe,l,ot={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
- `,r:"\r",t:" "},Ie;function R(t){throw{name:"SyntaxError",message:t,at:pe,text:Ie}}function d(t){return t&&t!==l&&R("Expected '"+t+"' instead of '"+l+"'"),l=Ie.charAt(pe),pe+=1,l}function it(){var t,e="";for(l==="-"&&(e="-",d("-"));l>="0"&&l<="9";)e+=l,d();if(l===".")for(e+=".";d()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,d(),(l==="-"||l==="+")&&(e+=l,d());l>="0"&&l<="9";)e+=l,d();return t=Number(e),isFinite(t)||R("Bad number"),t}function at(){var t,e,r="",n;if(l==='"')for(;d();){if(l==='"')return d(),r;if(l==="\\")if(d(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(d(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof ot[l]=="string")r+=ot[l];else break;else r+=l}R("Bad string")}function $(){for(;l&&l<=" ";)d()}function zr(){switch(l){case"t":return d("t"),d("r"),d("u"),d("e"),!0;case"f":return d("f"),d("a"),d("l"),d("s"),d("e"),!1;case"n":return d("n"),d("u"),d("l"),d("l"),null;default:R("Unexpected '"+l+"'")}}function Wr(){var t=[];if(l==="["){if(d("["),$(),l==="]")return d("]"),t;for(;l;){if(t.push(ce()),$(),l==="]")return d("]"),t;d(","),$()}}R("Bad array")}function Yr(){var t,e={};if(l==="{"){if(d("{"),$(),l==="}")return d("}"),e;for(;l;){if(t=at(),$(),d(":"),Object.prototype.hasOwnProperty.call(e,t)&&R('Duplicate key "'+t+'"'),e[t]=ce(),$(),l==="}")return d("}"),e;d(","),$()}}R("Bad object")}function ce(){switch($(),l){case"{":return Yr();case"[":return Wr();case'"':return at();case"-":return it();default:return l>="0"&&l<="9"?it():zr()}}st.exports=function(t,e){var r;return Ie=t,pe=0,l=" ",r=ce(),$(),l&&R("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in ce)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var lt=m((go,ut)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,ye,Kr={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function $e(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=Kr[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function de(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return $e(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=ye,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=de(r,s)||"null";return o=f.length===0?"[]":T?`[
1
+ "use strict";(()=>{var tn=Object.create;var tt=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var on=Object.getPrototypeOf,an=Object.prototype.hasOwnProperty;var d=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var sn=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nn(e))!an.call(t,o)&&o!==r&&tt(t,o,{get:()=>e[o],enumerable:!(n=rn(e,o))||n.enumerable});return t};var ke=(t,e,r)=>(r=t!=null?tn(on(t)):{},sn(e||!t||!t.__esModule?tt(r,"default",{value:t,enumerable:!0}):r,t));var ot=d(fe=>{"use strict";fe.byteLength=un;fe.toByteArray=pn;fe.fromByteArray=dn;var I=[],F=[],fn=typeof Uint8Array<"u"?Uint8Array:Array,Ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(U=0,rt=Ie.length;U<rt;++U)I[U]=Ie[U],F[Ie.charCodeAt(U)]=U;var U,rt;F[45]=62;F[95]=63;function nt(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var n=r===e?0:4-r%4;return[r,n]}function un(t){var e=nt(t),r=e[0],n=e[1];return(r+n)*3/4-n}function ln(t,e,r){return(e+r)*3/4-r}function pn(t){var e,r=nt(t),n=r[0],o=r[1],i=new fn(ln(t,n,o)),a=0,f=o>0?n-4:n,s;for(s=0;s<f;s+=4)e=F[t.charCodeAt(s)]<<18|F[t.charCodeAt(s+1)]<<12|F[t.charCodeAt(s+2)]<<6|F[t.charCodeAt(s+3)],i[a++]=e>>16&255,i[a++]=e>>8&255,i[a++]=e&255;return o===2&&(e=F[t.charCodeAt(s)]<<2|F[t.charCodeAt(s+1)]>>4,i[a++]=e&255),o===1&&(e=F[t.charCodeAt(s)]<<10|F[t.charCodeAt(s+1)]<<4|F[t.charCodeAt(s+2)]>>2,i[a++]=e>>8&255,i[a++]=e&255),i}function cn(t){return I[t>>18&63]+I[t>>12&63]+I[t>>6&63]+I[t&63]}function yn(t,e,r){for(var n,o=[],i=e;i<r;i+=3)n=(t[i]<<16&16711680)+(t[i+1]<<8&65280)+(t[i+2]&255),o.push(cn(n));return o.join("")}function dn(t){for(var e,r=t.length,n=r%3,o=[],i=16383,a=0,f=r-n;a<f;a+=i)o.push(yn(t,a,a+i>f?f:a+i));return n===1?(e=t[r-1],o.push(I[e>>2]+I[e<<4&63]+"==")):n===2&&(e=(t[r-2]<<8)+t[r-1],o.push(I[e>>10]+I[e>>4&63]+I[e<<2&63]+"=")),o.join("")}});var ut=d((Lo,ft)=>{"use strict";var ue,l,it={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
2
+ `,r:"\r",t:" "},$e;function M(t){throw{name:"SyntaxError",message:t,at:ue,text:$e}}function g(t){return t&&t!==l&&M("Expected '"+t+"' instead of '"+l+"'"),l=$e.charAt(ue),ue+=1,l}function at(){var t,e="";for(l==="-"&&(e="-",g("-"));l>="0"&&l<="9";)e+=l,g();if(l===".")for(e+=".";g()&&l>="0"&&l<="9";)e+=l;if(l==="e"||l==="E")for(e+=l,g(),(l==="-"||l==="+")&&(e+=l,g());l>="0"&&l<="9";)e+=l,g();return t=Number(e),isFinite(t)||M("Bad number"),t}function st(){var t,e,r="",n;if(l==='"')for(;g();){if(l==='"')return g(),r;if(l==="\\")if(g(),l==="u"){for(n=0,e=0;e<4&&(t=parseInt(g(),16),!!isFinite(t));e+=1)n=n*16+t;r+=String.fromCharCode(n)}else if(typeof it[l]=="string")r+=it[l];else break;else r+=l}M("Bad string")}function $(){for(;l&&l<=" ";)g()}function gn(){switch(l){case"t":return g("t"),g("r"),g("u"),g("e"),!0;case"f":return g("f"),g("a"),g("l"),g("s"),g("e"),!1;case"n":return g("n"),g("u"),g("l"),g("l"),null;default:M("Unexpected '"+l+"'")}}function mn(){var t=[];if(l==="["){if(g("["),$(),l==="]")return g("]"),t;for(;l;){if(t.push(le()),$(),l==="]")return g("]"),t;g(","),$()}}M("Bad array")}function hn(){var t,e={};if(l==="{"){if(g("{"),$(),l==="}")return g("}"),e;for(;l;){if(t=st(),$(),g(":"),Object.prototype.hasOwnProperty.call(e,t)&&M('Duplicate key "'+t+'"'),e[t]=le(),$(),l==="}")return g("}"),e;g(","),$()}}M("Bad object")}function le(){switch($(),l){case"{":return hn();case"[":return mn();case'"':return st();case"-":return at();default:return l>="0"&&l<="9"?at():gn()}}ft.exports=function(t,e){var r;return $e=t,ue=0,l=" ",r=le(),$(),l&&M("Syntax error"),typeof e=="function"?function n(o,i){var a,f,s=o[i];if(s&&typeof s=="object")for(a in le)Object.prototype.hasOwnProperty.call(s,a)&&(f=n(s,a),typeof f>"u"?delete s[a]:s[a]=f);return e.call(o,i,s)}({"":r},""):r}});var pt=d((qo,lt)=>{"use strict";var je=/[\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,T,pe,vn={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},N;function Re(t){return je.lastIndex=0,je.test(t)?'"'+t.replace(je,function(e){var r=vn[e];return typeof r=="string"?r:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+t+'"'}function ce(t,e){var r,n,o,i,a=T,f,s=e[t];switch(s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON(t)),typeof N=="function"&&(s=N.call(e,t,s)),typeof s){case"string":return Re(s);case"number":return isFinite(s)?String(s):"null";case"boolean":case"null":return String(s);case"object":if(!s)return"null";if(T+=pe,f=[],Object.prototype.toString.apply(s)==="[object Array]"){for(i=s.length,r=0;r<i;r+=1)f[r]=ce(r,s)||"null";return o=f.length===0?"[]":T?`[
3
3
  `+T+f.join(`,
4
4
  `+T)+`
5
- `+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=de(n,s),o&&f.push($e(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
5
+ `+a+"]":"["+f.join(",")+"]",T=a,o}if(N&&typeof N=="object")for(i=N.length,r=0;r<i;r+=1)n=N[r],typeof n=="string"&&(o=ce(n,s),o&&f.push(Re(n)+(T?": ":":")+o));else for(n in s)Object.prototype.hasOwnProperty.call(s,n)&&(o=ce(n,s),o&&f.push(Re(n)+(T?": ":":")+o));return o=f.length===0?"{}":T?`{
6
6
  `+T+f.join(`,
7
7
  `+T)+`
8
- `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}ut.exports=function(t,e,r){var n;if(T="",ye="",typeof r=="number")for(n=0;n<r;n+=1)ye+=" ";else typeof r=="string"&&(ye=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return de("",{"":t})}});var pt=m(Me=>{"use strict";Me.parse=ft();Me.stringify=lt()});var yt=m((ho,ct)=>{var Xr={}.toString;ct.exports=Array.isArray||function(t){return Xr.call(t)=="[object Array]"}});var Re=m((vo,gt)=>{"use strict";var dt=Object.prototype.toString;gt.exports=function(e){var r=dt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&dt.call(e.callee)==="[object Function]"),n}});var Et=m((bo,At)=>{"use strict";var xt;Object.keys||(ne=Object.prototype.hasOwnProperty,Be=Object.prototype.toString,mt=Re(),Ce=Object.prototype.propertyIsEnumerable,ht=!Ce.call({toString:null},"toString"),vt=Ce.call(function(){},"prototype"),oe=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ge=function(t){var e=t.constructor;return e&&e.prototype===t},bt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},wt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!bt["$"+t]&&ne.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ge(window[t])}catch{return!0}}catch{return!0}return!1}(),Pt=function(t){if(typeof window>"u"||!wt)return ge(t);try{return ge(t)}catch{return!1}},xt=function(e){var r=e!==null&&typeof e=="object",n=Be.call(e)==="[object Function]",o=mt(e),i=r&&Be.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=vt&&n;if(i&&e.length>0&&!ne.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var y=0;y<e.length;++y)a.push(String(y));else for(var p in e)!(f&&p==="prototype")&&ne.call(e,p)&&a.push(String(p));if(ht)for(var g=Pt(e),u=0;u<oe.length;++u)!(g&&oe[u]==="constructor")&&ne.call(e,oe[u])&&a.push(oe[u]);return a});var ne,Be,mt,Ce,ht,vt,oe,ge,bt,wt,Pt;At.exports=xt});var Ft=m((wo,Tt)=>{"use strict";var Zr=Array.prototype.slice,Qr=Re(),St=Object.keys,me=St?function(e){return St(e)}:Et(),Ot=Object.keys;me.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Qr(n)?Ot(Zr.call(n)):Ot(n)})}else Object.keys=me;return Object.keys||me};Tt.exports=me});var jt=m((Po,It)=>{"use strict";var en="Function.prototype.bind called on incompatible ",tn=Object.prototype.toString,rn=Math.max,nn="[object Function]",kt=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},on=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},an=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};It.exports=function(e){var r=this;if(typeof r!="function"||tn.apply(r)!==nn)throw new TypeError(en+r);for(var n=on(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,kt(n,arguments));return Object(p)===p?p:this}return r.apply(e,kt(n,arguments))},a=rn(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+an(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var y=function(){};y.prototype=r.prototype,o.prototype=new y,y.prototype=null}return o}});var he=m((xo,$t)=>{"use strict";var sn=jt();$t.exports=Function.prototype.bind||sn});var Rt=m((Ao,Mt)=>{"use strict";Mt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var _t=m((Eo,Ct)=>{"use strict";var Bt=typeof Symbol<"u"&&Symbol,fn=Rt();Ct.exports=function(){return typeof Bt!="function"||typeof Symbol!="function"||typeof Bt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:fn()}});var Dt=m((So,Nt)=>{"use strict";var Ut={foo:{}},un=Object;Nt.exports=function(){return{__proto__:Ut}.foo===Ut.foo&&!({__proto__:null}instanceof un)}});var Ht=m((Oo,Lt)=>{"use strict";var ln=Function.prototype.call,pn=Object.prototype.hasOwnProperty,cn=he();Lt.exports=cn.call(ln,pn)});var Z=m((To,zt)=>{"use strict";var c,X=SyntaxError,Vt=Function,K=TypeError,_e=function(t){try{return Vt('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Ue=function(){throw new K},yn=D?function(){try{return arguments.callee,Ue}catch{try{return D(arguments,"callee").get}catch{return Ue}}}():Ue,W=_t()(),dn=Dt()(),w=Object.getPrototypeOf||(dn?function(t){return t.__proto__}:null),Y={},gn=typeof Uint8Array>"u"||!w?c:w(Uint8Array),L={"%AggregateError%":typeof AggregateError>"u"?c:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?c:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):c,"%AsyncFromSyncIteratorPrototype%":c,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?c:Atomics,"%BigInt%":typeof BigInt>"u"?c:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?c:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?c:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?c:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array>"u"?c:Float32Array,"%Float64Array%":typeof Float64Array>"u"?c:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?c:FinalizationRegistry,"%Function%":Vt,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?c:Int8Array,"%Int16Array%":typeof Int16Array>"u"?c:Int16Array,"%Int32Array%":typeof Int32Array>"u"?c:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):c,"%JSON%":typeof JSON=="object"?JSON:c,"%Map%":typeof Map>"u"?c:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?c:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?c:Promise,"%Proxy%":typeof Proxy>"u"?c:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect>"u"?c:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?c:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?c:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?c:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):c,"%Symbol%":W?Symbol:c,"%SyntaxError%":X,"%ThrowTypeError%":yn,"%TypedArray%":gn,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?c:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?c:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?c:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?c:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap>"u"?c:WeakMap,"%WeakRef%":typeof WeakRef>"u"?c:WeakRef,"%WeakSet%":typeof WeakSet>"u"?c:WeakSet};if(w)try{null.error}catch(t){Jt=w(w(t)),L["%Error.prototype%"]=Jt}var Jt,mn=function t(e){var r;if(e==="%AsyncFunction%")r=_e("async function () {}");else if(e==="%GeneratorFunction%")r=_e("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=_e("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},Gt={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=he(),ve=Ht(),hn=ie.call(Function.call,Array.prototype.concat),vn=ie.call(Function.apply,Array.prototype.splice),qt=ie.call(Function.call,String.prototype.replace),be=ie.call(Function.call,String.prototype.slice),bn=ie.call(Function.call,RegExp.prototype.exec),wn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,Pn=/\\(\\)?/g,xn=function(e){var r=be(e,0,1),n=be(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return qt(e,wn,function(i,a,f,s){o[o.length]=f?qt(s,Pn,"$1"):a||i}),o},An=function(e,r){var n=e,o;if(ve(Gt,n)&&(o=Gt[n],n="%"+o[0]+"%"),ve(L,n)){var i=L[n];if(i===Y&&(i=mn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};zt.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(bn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=xn(e),o=n.length>0?n[0]:"",i=An("%"+o+"%",r),a=i.name,f=i.value,s=!1,y=i.alias;y&&(o=y[0],vn(n,hn([0,1],y)));for(var p=1,g=!0;p<n.length;p+=1){var u=n[p],S=be(u,0,1),b=be(u,-1);if((S==='"'||S==="'"||S==="`"||b==='"'||b==="'"||b==="`")&&S!==b)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!g)&&(s=!0),o+="."+u,a="%"+o+"%",ve(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);g=!!k,g&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else g=ve(f,u),f=f[u];g&&!s&&(L[a]=f)}}return f}});var Le=m((Fo,Wt)=>{"use strict";var En=Z(),Ne=En("%Object.defineProperty%",!0),De=function(){if(Ne)try{return Ne({},"a",{value:1}),!0}catch{return!1}return!1};De.hasArrayLengthDefineBug=function(){if(!De())return null;try{return Ne([],"length",{value:1}).length!==1}catch{return!0}};Wt.exports=De});var He=m((ko,Yt)=>{"use strict";var Sn=Z(),we=Sn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}Yt.exports=we});var Zt=m((Io,Xt)=>{"use strict";var On=Le()(),Je=Z(),ae=On&&Je("%Object.defineProperty%",!0);if(ae)try{ae({},"a",{value:1})}catch{ae=!1}var Tn=Je("%SyntaxError%"),Q=Je("%TypeError%"),Kt=He();Xt.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!Kt&&Kt(e,r);if(ae)ae(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Tn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var or=m((jo,nr)=>{"use strict";var rr=Z(),Qt=Zt(),Fn=Le()(),er=He(),tr=rr("%TypeError%"),kn=rr("%Math.floor%");nr.exports=function(e,r){if(typeof e!="function")throw new tr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||kn(r)!==r)throw new tr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&er){var a=er(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(Fn?Qt(e,"length",r,!0,!0):Qt(e,"length",r)),e}});var ur=m(($o,Pe)=>{"use strict";var Ge=he(),ee=Z(),In=or(),jn=ee("%TypeError%"),ar=ee("%Function.prototype.apply%"),sr=ee("%Function.prototype.call%"),fr=ee("%Reflect.apply%",!0)||Ge.call(sr,ar),se=ee("%Object.defineProperty%",!0),$n=ee("%Math.max%");if(se)try{se({},"a",{value:1})}catch{se=null}Pe.exports=function(e){if(typeof e!="function")throw new jn("a function is required");var r=fr(Ge,sr,arguments);return In(r,1+$n(0,e.length-(arguments.length-1)),!0)};var ir=function(){return fr(Ge,ar,arguments)};se?se(Pe.exports,"apply",{value:ir}):Pe.exports.apply=ir});var cr=m((Mo,pr)=>{"use strict";var xe=(typeof JSON<"u"?JSON:pt()).stringify,Mn=yt(),Rn=Ft(),Bn=ur(),lr=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},Cn=function(t,e,r){return r};pr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=lr(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?Bn(r.replacer):Cn,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(y){var p=a.length>2&&function(u){return y[u]};return function(g,u){return a({key:g,value:y[g]},{key:u,value:y[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function y(p,g,u,S){var b=n?`
9
- `+lr(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,g,u),u!==void 0){if(typeof u!="object"||u===null)return xe(u);if(Mn(u)){for(var j="",v=0;v<u.length;v++){var _=y(u,v,u[v],S+1)||xe(null);j+=b+n+_,v+1<u.length&&(j+=",")}return"["+j+b+"]"}if(s.indexOf(u)!==-1){if(o)return xe("__cycle__");throw new TypeError("Converting circular structure to JSON")}else s.push(u);for(var P=Rn(u).sort(f&&f(u)),j="",M=!1,v=0;v<P.length;v++){var g=P[v],Qe=y(u,g,u[g],S+1);if(Qe){var Mr=xe(g)+k+Qe;j+=(M?",":"")+b+n+Mr,M=!0}}return s.splice(s.indexOf(u),1),"{"+j+b+"}"}}({"":e},"",e,0)}});var Ye=m(h=>{"use strict";var mr=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function Dn(t){let{definitions:e,nullable:r,metadata:n}=t,o=mr(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=Dn;function hr(t){return"ref"in t}h.isRefForm=hr;function Ln(t){return"type"in t}h.isTypeForm=Ln;function vr(t){return"enum"in t}h.isEnumForm=vr;function br(t){return"elements"in t}h.isElementsForm=br;function We(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=We;function wr(t){return"values"in t}h.isValuesForm=wr;function Pr(t){return"discriminator"in t}h.isDiscriminatorForm=Pr;function H(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!H(r,e))return!1}if(hr(t)&&!(t.ref in(e.definitions||{}))||vr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(br(t))return H(t.elements,e);if(We(t)){for(let r of Object.values(t.properties||{}))if(!H(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!H(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(wr(t))return H(t.values,e);if(Pr(t)){for(let r of Object.values(t.mapping))if(!H(r,e)||!We(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=H;var Hn=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],Jn=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function J(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:y=void 0,optionalProperties:p=void 0,additionalProperties:g=void 0,values:u=void 0,discriminator:S=void 0,mapping:b=void 0}=e,k=mr(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),v=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,y!==void 0,p!==void 0,g!==void 0,u!==void 0,S!==void 0,b!==void 0],_=!1;for(let P of Hn)_=_||P.every((j,M)=>j===v[M]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!J(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!Jn.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!J(s))return!1;if(y!==void 0){if(typeof y!="object"||Array.isArray(y)||y===null)return!1;for(let P of Object.values(y))if(!J(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!J(P))return!1}if(g!==void 0&&typeof g!="boolean"||u!==void 0&&!J(u)||S!==void 0&&typeof S!="string")return!1;if(b!==void 0){if(typeof b!="object"||Array.isArray(b)||b===null)return!1;for(let P of Object.values(b))if(!J(P))return!1}return Object.keys(k).length===0}h.isSchema=J});var xr=m(Ke=>{"use strict";Object.defineProperty(Ke,"__esModule",{value:!0});var Gn=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function qn(t){let e=t.match(Gn);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>Vn(r,n)||i>23||a>59||f>60)}Ke.default=qn;function Vn(t,e){return e===2?zn(t)?29:28:Wn[e]}function zn(t){return t%4===0&&(t%100!==0||t%400===0)}var Wn=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Ar=m(B=>{"use strict";var Yn=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Kn=Yn(xr()),G=Ye(),Ee=class extends Error{};B.MaxDepthExceededError=Ee;var Se=class extends Error{};function Xn(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Se))throw o}return n.errors}B.validate=Xn;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(G.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Ee;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(G.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":te(t,r,-128,127);break;case"uint8":te(t,r,0,255);break;case"int16":te(t,r,-32768,32767);break;case"uint16":te(t,r,0,65535);break;case"int32":te(t,r,-2147483648,2147483647);break;case"uint32":te(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Kn.default(r)||E(t);break}O(t)}else if(G.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(G.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())q(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(G.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(q(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(q(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(q(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(G.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))q(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(G.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),q(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),q(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function te(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function q(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Se}});var Sr=m(C=>{"use strict";var Zn=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Er=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Zn(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Er(Ye(),C);Er(Ar(),C)});var Ir=Fe(nt()),jr=Fe(cr());var Ae,_n=new Uint8Array(16);function qe(){if(!Ae&&(Ae=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ae))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ae(_n)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function yr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var Un=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ve={randomUUID:Un};function Nn(t,e,r){if(Ve.randomUUID&&!e&&!t)return Ve.randomUUID();t=t||{};let n=t.random||(t.rng||qe)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return yr(n)}var fe=Nn;function ze(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function dr(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function gr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var Or=Fe(Sr());function ue(t,e){if((0,Or.validate)(t,e).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Tr="3",$r="https://webapp-prod.cloud.remarkable.engineering",Qn="https://internal.cloud.remarkable.com",Fr="x-goog-generation",eo="x-goog-if-generation-match",to="x-goog-content-length-range",Qo=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],ei=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],ro={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},no={sm:50,md:125,rr:180,lg:200},oo={df:-1,md:100,lg:150,xl:200},io={properties:{docID:{type:"string"},hash:{type:"string"}}},ao={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},Oe={visibleName:{type:"string"},lastModified:{type:"string"}},Te={version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},so={discriminator:"type",mapping:{CollectionType:{properties:Oe,optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:Oe,optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},kr={id:{type:"string"},hash:{type:"string"}},fo={discriminator:"type",mapping:{CollectionType:{properties:{...Oe,...kr},optionalProperties:Te,additionalProperties:!0},DocumentType:{properties:{...Oe,...kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Te,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},re=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Xe=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function ti(t,{deviceDesc:e="browser-chrome",uuid:r=fe(),authHost:n=$r,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new re(i.status,i.statusText,"couldn't register api")}function uo({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
- `}function lo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var Ze=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new re(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[to]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new re(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return ue(ao,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Fr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[eo]:`${r}`})}catch(f){throw f instanceof re&&f.status===412?(this.#t=null,new Xe):f}let i=o.headers.get(Fr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e){let r=await this.getJson(e);return ue(so,r),r}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
- `);if(n!==Tr)throw new Error(`got unexpected schema version: ${n}`);return o.map(lo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,g)=>p.documentId.localeCompare(g.documentId));let o=gr(r.map(p=>dr(p.hash))),i=await this.#f.digest("SHA-256",o),a=ze(i),f=r.map(uo).join(""),s=`${Tr}
12
- ${f}`,y=n.encode(s);return await this.#p(a,y),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=ze(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,jr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=fe(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=fe(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let y={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,y)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:y="",cover:p="visited",lastTool:g}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:g},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?oo[s]:s,margins:typeof o=="string"?no[o]:o,textScale:typeof f=="string"?ro[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:y};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let v=f.find(M=>M.documentId===r);if(v){if(v.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(v.hash),[P]=_.filter(M=>M.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(v=>v.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[y]=f.splice(s,1);if(y.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(y.hash),g=p.findIndex(v=>v.documentId===`${e}.metadata`);if(g===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(g,1),S=await this.getMetadata(u.hash);S.parent=r;let b=await this.putMetadata(e,S);p.push(b);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata(){let r=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),n=JSON.parse(r);return ue({elements:fo},n),n}async#d(e,r,n){let i=new TextEncoder().encode(JSON.stringify({file_name:e})),f=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Ir.fromByteArray)(i),"rm-source":"RoR-Browser"}})).text(),s=JSON.parse(f);return ue(io,s),s}async uploadEpub(e,r){return await this.#d(e,r,"application/epub+zip")}async uploadPdf(e,r){return await this.#d(e,r,"application/pdf")}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function ri(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=$r,syncHost:o=Qn,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new Ze(s,e,r,o,i,a)}})();
8
+ `+a+"}":"{"+f.join(",")+"}",T=a,o;default:}}lt.exports=function(t,e,r){var n;if(T="",pe="",typeof r=="number")for(n=0;n<r;n+=1)pe+=" ";else typeof r=="string"&&(pe=r);if(N=e,e&&typeof e!="function"&&(typeof e!="object"||typeof e.length!="number"))throw new Error("JSON.stringify");return ce("",{"":t})}});var ct=d(Me=>{"use strict";Me.parse=ut();Me.stringify=pt()});var dt=d((Jo,yt)=>{var bn={}.toString;yt.exports=Array.isArray||function(t){return bn.call(t)=="[object Array]"}});var Be=d((Go,mt)=>{"use strict";var gt=Object.prototype.toString;mt.exports=function(e){var r=gt.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&gt.call(e.callee)==="[object Function]"),n}});var St=d((Vo,Et)=>{"use strict";var At;Object.keys||(re=Object.prototype.hasOwnProperty,Ce=Object.prototype.toString,ht=Be(),_e=Object.prototype.propertyIsEnumerable,vt=!_e.call({toString:null},"toString"),bt=_e.call(function(){},"prototype"),ne=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],ye=function(t){var e=t.constructor;return e&&e.prototype===t},wt={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},Pt=function(){if(typeof window>"u")return!1;for(var t in window)try{if(!wt["$"+t]&&re.call(window,t)&&window[t]!==null&&typeof window[t]=="object")try{ye(window[t])}catch{return!0}}catch{return!0}return!1}(),xt=function(t){if(typeof window>"u"||!Pt)return ye(t);try{return ye(t)}catch{return!1}},At=function(e){var r=e!==null&&typeof e=="object",n=Ce.call(e)==="[object Function]",o=ht(e),i=r&&Ce.call(e)==="[object String]",a=[];if(!r&&!n&&!o)throw new TypeError("Object.keys called on a non-object");var f=bt&&n;if(i&&e.length>0&&!re.call(e,0))for(var s=0;s<e.length;++s)a.push(String(s));if(o&&e.length>0)for(var c=0;c<e.length;++c)a.push(String(c));else for(var p in e)!(f&&p==="prototype")&&re.call(e,p)&&a.push(String(p));if(vt)for(var m=xt(e),u=0;u<ne.length;++u)!(m&&ne[u]==="constructor")&&re.call(e,ne[u])&&a.push(ne[u]);return a});var re,Ce,ht,_e,vt,bt,ne,ye,wt,Pt,xt;Et.exports=At});var kt=d((zo,Ft)=>{"use strict";var wn=Array.prototype.slice,Pn=Be(),Ot=Object.keys,de=Ot?function(e){return Ot(e)}:St(),Tt=Object.keys;de.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return Pn(n)?Tt(wn.call(n)):Tt(n)})}else Object.keys=de;return Object.keys||de};Ft.exports=de});var jt=d((Wo,$t)=>{"use strict";var xn="Function.prototype.bind called on incompatible ",An=Object.prototype.toString,En=Math.max,Sn="[object Function]",It=function(e,r){for(var n=[],o=0;o<e.length;o+=1)n[o]=e[o];for(var i=0;i<r.length;i+=1)n[i+e.length]=r[i];return n},On=function(e,r){for(var n=[],o=r||0,i=0;o<e.length;o+=1,i+=1)n[i]=e[o];return n},Tn=function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r};$t.exports=function(e){var r=this;if(typeof r!="function"||An.apply(r)!==Sn)throw new TypeError(xn+r);for(var n=On(arguments,1),o,i=function(){if(this instanceof o){var p=r.apply(this,It(n,arguments));return Object(p)===p?p:this}return r.apply(e,It(n,arguments))},a=En(0,r.length-n.length),f=[],s=0;s<a;s++)f[s]="$"+s;if(o=Function("binder","return function ("+Tn(f,",")+"){ return binder.apply(this,arguments); }")(i),r.prototype){var c=function(){};c.prototype=r.prototype,o.prototype=new c,c.prototype=null}return o}});var ge=d((Yo,Rt)=>{"use strict";var Fn=jt();Rt.exports=Function.prototype.bind||Fn});var Bt=d((Ko,Mt)=>{"use strict";Mt.exports=Error});var _t=d((Xo,Ct)=>{"use strict";Ct.exports=EvalError});var Nt=d((Zo,Ut)=>{"use strict";Ut.exports=RangeError});var Lt=d((Qo,Dt)=>{"use strict";Dt.exports=ReferenceError});var Ue=d((ei,qt)=>{"use strict";qt.exports=SyntaxError});var oe=d((ti,Ht)=>{"use strict";Ht.exports=TypeError});var Gt=d((ri,Jt)=>{"use strict";Jt.exports=URIError});var zt=d((ni,Vt)=>{"use strict";Vt.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var o=42;e[r]=o;for(r in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var i=Object.getOwnPropertySymbols(e);if(i.length!==1||i[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==o||a.enumerable!==!0)return!1}return!0}});var Kt=d((oi,Yt)=>{"use strict";var Wt=typeof Symbol<"u"&&Symbol,kn=zt();Yt.exports=function(){return typeof Wt!="function"||typeof Symbol!="function"||typeof Wt("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:kn()}});var Zt=d((ii,Xt)=>{"use strict";var Ne={__proto__:null,foo:{}},In=Object;Xt.exports=function(){return{__proto__:Ne}.foo===Ne.foo&&!(Ne instanceof In)}});var er=d((ai,Qt)=>{"use strict";var $n=Function.prototype.call,jn=Object.prototype.hasOwnProperty,Rn=ge();Qt.exports=Rn.call($n,jn)});var Z=d((si,ir)=>{"use strict";var y,Mn=Bt(),Bn=_t(),Cn=Nt(),_n=Lt(),X=Ue(),K=oe(),Un=Gt(),or=Function,De=function(t){try{return or('"use strict"; return ('+t+").constructor;")()}catch{}},D=Object.getOwnPropertyDescriptor;if(D)try{D({},"")}catch{D=null}var Le=function(){throw new K},Nn=D?function(){try{return arguments.callee,Le}catch{try{return D(arguments,"callee").get}catch{return Le}}}():Le,W=Kt()(),Dn=Zt()(),w=Object.getPrototypeOf||(Dn?function(t){return t.__proto__}:null),Y={},Ln=typeof Uint8Array>"u"||!w?y:w(Uint8Array),L={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?y:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?y:ArrayBuffer,"%ArrayIteratorPrototype%":W&&w?w([][Symbol.iterator]()):y,"%AsyncFromSyncIteratorPrototype%":y,"%AsyncFunction%":Y,"%AsyncGenerator%":Y,"%AsyncGeneratorFunction%":Y,"%AsyncIteratorPrototype%":Y,"%Atomics%":typeof Atomics>"u"?y:Atomics,"%BigInt%":typeof BigInt>"u"?y:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?y:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Mn,"%eval%":eval,"%EvalError%":Bn,"%Float32Array%":typeof Float32Array>"u"?y:Float32Array,"%Float64Array%":typeof Float64Array>"u"?y:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?y:FinalizationRegistry,"%Function%":or,"%GeneratorFunction%":Y,"%Int8Array%":typeof Int8Array>"u"?y:Int8Array,"%Int16Array%":typeof Int16Array>"u"?y:Int16Array,"%Int32Array%":typeof Int32Array>"u"?y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":W&&w?w(w([][Symbol.iterator]())):y,"%JSON%":typeof JSON=="object"?JSON:y,"%Map%":typeof Map>"u"?y:Map,"%MapIteratorPrototype%":typeof Map>"u"||!W||!w?y:w(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?y:Promise,"%Proxy%":typeof Proxy>"u"?y:Proxy,"%RangeError%":Cn,"%ReferenceError%":_n,"%Reflect%":typeof Reflect>"u"?y:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?y:Set,"%SetIteratorPrototype%":typeof Set>"u"||!W||!w?y:w(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":W&&w?w(""[Symbol.iterator]()):y,"%Symbol%":W?Symbol:y,"%SyntaxError%":X,"%ThrowTypeError%":Nn,"%TypedArray%":Ln,"%TypeError%":K,"%Uint8Array%":typeof Uint8Array>"u"?y:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?y:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?y:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?y:Uint32Array,"%URIError%":Un,"%WeakMap%":typeof WeakMap>"u"?y:WeakMap,"%WeakRef%":typeof WeakRef>"u"?y:WeakRef,"%WeakSet%":typeof WeakSet>"u"?y:WeakSet};if(w)try{null.error}catch(t){tr=w(w(t)),L["%Error.prototype%"]=tr}var tr,qn=function t(e){var r;if(e==="%AsyncFunction%")r=De("async function () {}");else if(e==="%GeneratorFunction%")r=De("function* () {}");else if(e==="%AsyncGeneratorFunction%")r=De("async function* () {}");else if(e==="%AsyncGenerator%"){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(e==="%AsyncIteratorPrototype%"){var o=t("%AsyncGenerator%");o&&w&&(r=w(o.prototype))}return L[e]=r,r},rr={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},ie=ge(),me=er(),Hn=ie.call(Function.call,Array.prototype.concat),Jn=ie.call(Function.apply,Array.prototype.splice),nr=ie.call(Function.call,String.prototype.replace),he=ie.call(Function.call,String.prototype.slice),Gn=ie.call(Function.call,RegExp.prototype.exec),Vn=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,zn=/\\(\\)?/g,Wn=function(e){var r=he(e,0,1),n=he(e,-1);if(r==="%"&&n!=="%")throw new X("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new X("invalid intrinsic syntax, expected opening `%`");var o=[];return nr(e,Vn,function(i,a,f,s){o[o.length]=f?nr(s,zn,"$1"):a||i}),o},Yn=function(e,r){var n=e,o;if(me(rr,n)&&(o=rr[n],n="%"+o[0]+"%"),me(L,n)){var i=L[n];if(i===Y&&(i=qn(n)),typeof i>"u"&&!r)throw new K("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:o,name:n,value:i}}throw new X("intrinsic "+e+" does not exist!")};ir.exports=function(e,r){if(typeof e!="string"||e.length===0)throw new K("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new K('"allowMissing" argument must be a boolean');if(Gn(/^%?[^%]*%?$/,e)===null)throw new X("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=Wn(e),o=n.length>0?n[0]:"",i=Yn("%"+o+"%",r),a=i.name,f=i.value,s=!1,c=i.alias;c&&(o=c[0],Jn(n,Hn([0,1],c)));for(var p=1,m=!0;p<n.length;p+=1){var u=n[p],S=he(u,0,1),v=he(u,-1);if((S==='"'||S==="'"||S==="`"||v==='"'||v==="'"||v==="`")&&S!==v)throw new X("property names with quotes must have matching quotes");if((u==="constructor"||!m)&&(s=!0),o+="."+u,a="%"+o+"%",me(L,a))f=L[a];else if(f!=null){if(!(u in f)){if(!r)throw new K("base intrinsic for "+e+" exists, but the property is not available.");return}if(D&&p+1>=n.length){var k=D(f,u);m=!!k,m&&"get"in k&&!("originalValue"in k.get)?f=k.get:f=f[u]}else m=me(f,u),f=f[u];m&&!s&&(L[a]=f)}}return f}});var be=d((fi,ar)=>{"use strict";var Kn=Z(),ve=Kn("%Object.defineProperty%",!0)||!1;if(ve)try{ve({},"a",{value:1})}catch{ve=!1}ar.exports=ve});var qe=d((ui,sr)=>{"use strict";var Xn=Z(),we=Xn("%Object.getOwnPropertyDescriptor%",!0);if(we)try{we([],"length")}catch{we=null}sr.exports=we});var pr=d((li,lr)=>{"use strict";var fr=be(),Zn=Ue(),Q=oe(),ur=qe();lr.exports=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Q("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Q("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Q("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Q("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Q("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Q("`loose`, if provided, must be a boolean");var o=arguments.length>3?arguments[3]:null,i=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,f=arguments.length>6?arguments[6]:!1,s=!!ur&&ur(e,r);if(fr)fr(e,r,{configurable:a===null&&s?s.configurable:!a,enumerable:o===null&&s?s.enumerable:!o,value:n,writable:i===null&&s?s.writable:!i});else if(f||!o&&!i&&!a)e[r]=n;else throw new Zn("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")}});var dr=d((pi,yr)=>{"use strict";var He=be(),cr=function(){return!!He};cr.hasArrayLengthDefineBug=function(){if(!He)return null;try{return He([],"length",{value:1}).length!==1}catch{return!0}};yr.exports=cr});var br=d((ci,vr)=>{"use strict";var Qn=Z(),gr=pr(),eo=dr()(),mr=qe(),hr=oe(),to=Qn("%Math.floor%");vr.exports=function(e,r){if(typeof e!="function")throw new hr("`fn` is not a function");if(typeof r!="number"||r<0||r>4294967295||to(r)!==r)throw new hr("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],o=!0,i=!0;if("length"in e&&mr){var a=mr(e,"length");a&&!a.configurable&&(o=!1),a&&!a.writable&&(i=!1)}return(o||i||!n)&&(eo?gr(e,"length",r,!0,!0):gr(e,"length",r)),e}});var Ge=d((yi,Pe)=>{"use strict";var Je=ge(),xe=Z(),ro=br(),no=oe(),xr=xe("%Function.prototype.apply%"),Ar=xe("%Function.prototype.call%"),Er=xe("%Reflect.apply%",!0)||Je.call(Ar,xr),wr=be(),oo=xe("%Math.max%");Pe.exports=function(e){if(typeof e!="function")throw new no("a function is required");var r=Er(Je,Ar,arguments);return ro(r,1+oo(0,e.length-(arguments.length-1)),!0)};var Pr=function(){return Er(Je,xr,arguments)};wr?wr(Pe.exports,"apply",{value:Pr}):Pe.exports.apply=Pr});var Fr=d((di,Tr)=>{"use strict";var Sr=Z(),Or=Ge(),io=Or(Sr("String.prototype.indexOf"));Tr.exports=function(e,r){var n=Sr(e,!!r);return typeof n=="function"&&io(e,".prototype.")>-1?Or(n):n}});var Rr=d((gi,jr)=>{"use strict";var Ae=(typeof JSON<"u"?JSON:ct()).stringify,ao=dt(),so=kt(),fo=Ge(),$r=Fr(),kr=$r("Array.prototype.join"),Ve=$r("Array.prototype.push"),Ir=function(e,r){for(var n="",o=0;o<e;o+=1)n+=r;return n},uo=function(t,e,r){return r};jr.exports=function(e){var r=arguments.length>1?arguments[1]:void 0,n=r&&r.space||"";typeof n=="number"&&(n=Ir(n," "));var o=!!r&&typeof r.cycles=="boolean"&&r.cycles,i=r&&r.replacer?fo(r.replacer):uo,a=typeof r=="function"?r:r&&r.cmp,f=a&&function(c){var p=a.length>2&&function(u){return c[u]};return function(m,u){return a({key:m,value:c[m]},{key:u,value:c[u]},p?{__proto__:null,get:p}:void 0)}},s=[];return function c(p,m,u,S){var v=n?`
9
+ `+Ir(S,n):"",k=n?": ":":";if(u&&u.toJSON&&typeof u.toJSON=="function"&&(u=u.toJSON()),u=i(p,m,u),u!==void 0){if(typeof u!="object"||u===null)return Ae(u);if(ao(u)){for(var j=[],b=0;b<u.length;b++){var _=c(u,b,u[b],S+1)||Ae(null);Ve(j,v+n+_)}return"["+kr(j,",")+v+"]"}if(s.indexOf(u)!==-1){if(o)return Ae("__cycle__");throw new TypeError("Converting circular structure to JSON")}else Ve(s,u);for(var P=so(u).sort(f&&f(u)),j=[],b=0;b<P.length;b++){var m=P[b],R=c(u,m,u[m],S+1);if(R){var en=Ae(m)+k+R;Ve(j,v+n+en)}}return s.splice(s.indexOf(u),1),"{"+kr(j,",")+v+"}"}}({"":e},"",e,0)}});var Xe=d(h=>{"use strict";var _r=h&&h.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r};Object.defineProperty(h,"__esModule",{value:!0});h.isSchema=h.isValidSchema=h.isDiscriminatorForm=h.isValuesForm=h.isPropertiesForm=h.isElementsForm=h.isEnumForm=h.isTypeForm=h.isRefForm=h.isEmptyForm=void 0;function yo(t){let{definitions:e,nullable:r,metadata:n}=t,o=_r(t,["definitions","nullable","metadata"]);return Object.keys(o).length===0}h.isEmptyForm=yo;function Ur(t){return"ref"in t}h.isRefForm=Ur;function go(t){return"type"in t}h.isTypeForm=go;function Nr(t){return"enum"in t}h.isEnumForm=Nr;function Dr(t){return"elements"in t}h.isElementsForm=Dr;function Ke(t){return"properties"in t||"optionalProperties"in t}h.isPropertiesForm=Ke;function Lr(t){return"values"in t}h.isValuesForm=Lr;function qr(t){return"discriminator"in t}h.isDiscriminatorForm=qr;function q(t,e){if(e===void 0&&(e=t),t.definitions!==void 0){if(e!==t)return!1;for(let r of Object.values(t.definitions))if(!q(r,e))return!1}if(Ur(t)&&!(t.ref in(e.definitions||{}))||Nr(t)&&(t.enum.length===0||t.enum.length!==new Set(t.enum).size))return!1;if(Dr(t))return q(t.elements,e);if(Ke(t)){for(let r of Object.values(t.properties||{}))if(!q(r,e))return!1;for(let r of Object.values(t.optionalProperties||{}))if(!q(r,e))return!1;for(let r of Object.keys(t.properties||{}))if(r in(t.optionalProperties||{}))return!1}if(Lr(t))return q(t.values,e);if(qr(t)){for(let r of Object.values(t.mapping))if(!q(r,e)||!Ke(r)||r.nullable||t.discriminator in(r.properties||{})||t.discriminator in(r.optionalProperties||{}))return!1}return!0}h.isValidSchema=q;var mo=[[!1,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!0,!1,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!0,!1,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!0,!1,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!0,!1,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!1,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!1,!1,!1,!1],[!1,!1,!1,!1,!0,!1,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!0,!0,!0,!1,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!0,!1,!1],[!1,!1,!1,!1,!1,!1,!1,!1,!0,!0]],ho=["boolean","float32","float64","int8","uint8","int16","uint16","int32","uint32","string","timestamp"];function H(t){if(typeof t!="object"||Array.isArray(t)||t===null)return!1;let e=t,{definitions:r=void 0,nullable:n=void 0,metadata:o=void 0,ref:i=void 0,type:a=void 0,enum:f=void 0,elements:s=void 0,properties:c=void 0,optionalProperties:p=void 0,additionalProperties:m=void 0,values:u=void 0,discriminator:S=void 0,mapping:v=void 0}=e,k=_r(e,["definitions","nullable","metadata","ref","type","enum","elements","properties","optionalProperties","additionalProperties","values","discriminator","mapping"]),b=[i!==void 0,a!==void 0,f!==void 0,s!==void 0,c!==void 0,p!==void 0,m!==void 0,u!==void 0,S!==void 0,v!==void 0],_=!1;for(let P of mo)_=_||P.every((j,R)=>j===b[R]);if(!_)return!1;if(r!==void 0){if(typeof r!="object"||Array.isArray(r)||r===null)return!1;for(let P of Object.values(r))if(!H(P))return!1}if(n!==void 0&&typeof n!="boolean"||o!==void 0&&(typeof o!="object"||Array.isArray(o)||o===null)||i!==void 0&&typeof i!="string"||a!==void 0&&(typeof a!="string"||!ho.includes(a))||f!==void 0&&(!Array.isArray(f)||!f.every(P=>typeof P=="string"))||s!==void 0&&!H(s))return!1;if(c!==void 0){if(typeof c!="object"||Array.isArray(c)||c===null)return!1;for(let P of Object.values(c))if(!H(P))return!1}if(p!==void 0){if(typeof p!="object"||Array.isArray(p)||p===null)return!1;for(let P of Object.values(p))if(!H(P))return!1}if(m!==void 0&&typeof m!="boolean"||u!==void 0&&!H(u)||S!==void 0&&typeof S!="string")return!1;if(v!==void 0){if(typeof v!="object"||Array.isArray(v)||v===null)return!1;for(let P of Object.values(v))if(!H(P))return!1}return Object.keys(k).length===0}h.isSchema=H});var Hr=d(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});var vo=/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(\.\d+)?([zZ]|((\+|-)(\d{2}):(\d{2})))$/;function bo(t){let e=t.match(vo);if(e===null)return!1;let r=parseInt(e[1],10),n=parseInt(e[2],10),o=parseInt(e[3],10),i=parseInt(e[4],10),a=parseInt(e[5],10),f=parseInt(e[6],10);return!(n>12||o>wo(r,n)||i>23||a>59||f>60)}Ze.default=bo;function wo(t,e){return e===2?Po(t)?29:28:xo[e]}function Po(t){return t%4===0&&(t%100!==0||t%400===0)}var xo=[0,31,0,31,30,31,30,31,31,30,31,30,31]});var Jr=d(B=>{"use strict";var Ao=B&&B.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(B,"__esModule",{value:!0});B.validate=B.MaxDepthExceededError=void 0;var Eo=Ao(Hr()),J=Xe(),Se=class extends Error{};B.MaxDepthExceededError=Se;var Oe=class extends Error{};function So(t,e,r){let n={errors:[],instanceTokens:[],schemaTokens:[[]],root:t,config:r||{maxDepth:0,maxErrors:0}};try{z(n,t,e)}catch(o){if(!(o instanceof Oe))throw o}return n.errors}B.validate=So;function z(t,e,r,n){if(!(e.nullable&&r===null)){if(J.isRefForm(e)){if(t.schemaTokens.length===t.config.maxDepth)throw new Se;t.schemaTokens.push(["definitions",e.ref]),z(t,t.root.definitions[e.ref],r),t.schemaTokens.pop()}else if(J.isTypeForm(e)){switch(A(t,"type"),e.type){case"boolean":typeof r!="boolean"&&E(t);break;case"float32":case"float64":typeof r!="number"&&E(t);break;case"int8":ee(t,r,-128,127);break;case"uint8":ee(t,r,0,255);break;case"int16":ee(t,r,-32768,32767);break;case"uint16":ee(t,r,0,65535);break;case"int32":ee(t,r,-2147483648,2147483647);break;case"uint32":ee(t,r,0,4294967295);break;case"string":typeof r!="string"&&E(t);break;case"timestamp":typeof r!="string"?E(t):Eo.default(r)||E(t);break}O(t)}else if(J.isEnumForm(e))A(t,"enum"),(typeof r!="string"||!e.enum.includes(r))&&E(t),O(t);else if(J.isElementsForm(e)){if(A(t,"elements"),Array.isArray(r))for(let[o,i]of r.entries())G(t,o.toString()),z(t,e.elements,i),V(t);else E(t);O(t)}else if(J.isPropertiesForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(e.properties!==void 0){A(t,"properties");for(let[o,i]of Object.entries(e.properties))A(t,o),r.hasOwnProperty(o)?(G(t,o),z(t,i,r[o]),V(t)):E(t),O(t);O(t)}if(e.optionalProperties!==void 0){A(t,"optionalProperties");for(let[o,i]of Object.entries(e.optionalProperties))A(t,o),r.hasOwnProperty(o)&&(G(t,o),z(t,i,r[o]),V(t)),O(t);O(t)}if(e.additionalProperties!==!0)for(let o of Object.keys(r)){let i=e.properties&&o in e.properties,a=e.optionalProperties&&o in e.optionalProperties;!i&&!a&&o!==n&&(G(t,o),E(t),V(t))}}else e.properties!==void 0?A(t,"properties"):A(t,"optionalProperties"),E(t),O(t);else if(J.isValuesForm(e)){if(A(t,"values"),typeof r=="object"&&r!==null&&!Array.isArray(r))for(let[o,i]of Object.entries(r))G(t,o),z(t,e.values,i),V(t);else E(t);O(t)}else if(J.isDiscriminatorForm(e))if(typeof r=="object"&&r!==null&&!Array.isArray(r))if(r.hasOwnProperty(e.discriminator)){let o=r[e.discriminator];typeof o=="string"?o in e.mapping?(A(t,"mapping"),A(t,o),z(t,e.mapping[o],r,e.discriminator),O(t),O(t)):(A(t,"mapping"),G(t,e.discriminator),E(t),V(t),O(t)):(A(t,"discriminator"),G(t,e.discriminator),E(t),V(t),O(t))}else A(t,"discriminator"),E(t),O(t);else A(t,"discriminator"),E(t),O(t)}}function ee(t,e,r,n){(typeof e!="number"||!Number.isInteger(e)||e<r||e>n)&&E(t)}function G(t,e){t.instanceTokens.push(e)}function V(t){t.instanceTokens.pop()}function A(t,e){t.schemaTokens[t.schemaTokens.length-1].push(e)}function O(t){t.schemaTokens[t.schemaTokens.length-1].pop()}function E(t){if(t.errors.push({instancePath:[...t.instanceTokens],schemaPath:[...t.schemaTokens[t.schemaTokens.length-1]]}),t.errors.length===t.config.maxErrors)throw new Oe}});var Vr=d(C=>{"use strict";var Oo=C&&C.__createBinding||(Object.create?function(t,e,r,n){n===void 0&&(n=r),Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[r]}})}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]}),Gr=C&&C.__exportStar||function(t,e){for(var r in t)r!=="default"&&!e.hasOwnProperty(r)&&Oo(e,t,r)};Object.defineProperty(C,"__esModule",{value:!0});Gr(Xe(),C);Gr(Jr(),C)});var Xr=ke(ot()),Zr=ke(Rr());var Ee,lo=new Uint8Array(16);function ze(){if(!Ee&&(Ee=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ee))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ee(lo)}var x=[];for(let t=0;t<256;++t)x.push((t+256).toString(16).slice(1));function Mr(t,e=0){return x[t[e+0]]+x[t[e+1]]+x[t[e+2]]+x[t[e+3]]+"-"+x[t[e+4]]+x[t[e+5]]+"-"+x[t[e+6]]+x[t[e+7]]+"-"+x[t[e+8]]+x[t[e+9]]+"-"+x[t[e+10]]+x[t[e+11]]+x[t[e+12]]+x[t[e+13]]+x[t[e+14]]+x[t[e+15]]}var po=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),We={randomUUID:po};function co(t,e,r){if(We.randomUUID&&!e&&!t)return We.randomUUID();t=t||{};let n=t.random||(t.rng||ze)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){r=r||0;for(let o=0;o<16;++o)e[r+o]=n[o];return e}return Mr(n)}var ae=co;function Ye(t){return[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,"0")).join("")}function Br(t){return new Uint8Array((t.match(/../g)??[]).map(e=>parseInt(e,16)))}function Cr(t){let e=0;for(let o of t)e+=o.length;let r=new Uint8Array(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return r}var zr=ke(Vr());function se(t,e,r=!0){if((r?(0,zr.validate)(t,e):[]).length)throw new Error(`couldn't validate schema: ${JSON.stringify(e)} didn't match schema ${JSON.stringify(t)}`)}var Wr="3",Qr="https://webapp-prod.cloud.remarkable.engineering",To="https://internal.cloud.remarkable.com",Yr="x-goog-generation",Fo="x-goog-if-generation-match",ko="x-goog-content-length-range",Bi=["Ballpoint","Ballpointv2","Brush","Calligraphy","ClearPage","EraseSection","Eraser","Fineliner","Finelinerv2","Highlighter","Highlighterv2","Marker","Markerv2","Paintbrush","Paintbrushv2","Pencilv2","SharpPencil","SharpPencilv2","SolidPen","ZoomTool"],Ci=["Maison Neue","EB Garamond","Noto Sans","Noto Serif","Noto Mono","Noto Sans UI"],Io={xs:.7,sm:.8,md:1,lg:1.2,xl:1.5,xx:2},$o={sm:50,md:125,rr:180,lg:200},jo={df:-1,md:100,lg:150,xl:200},Ro={properties:{docID:{type:"string"},hash:{type:"string"}}},Mo={properties:{relative_path:{type:"string"},url:{type:"string"},expires:{type:"timestamp"},method:{enum:["POST","GET","PUT","DELETE"]}},optionalProperties:{maxuploadsize_bytes:{type:"float64"}}},Te={visibleName:{type:"string"}},Fe={lastModified:{type:"string"},version:{type:"int32"},pinned:{type:"boolean"},synced:{type:"boolean"},modified:{type:"boolean"},deleted:{type:"boolean"},metadatamodified:{type:"boolean"},parent:{type:"string"}},Bo={discriminator:"type",mapping:{CollectionType:{properties:Te,optionalProperties:Fe,additionalProperties:!0},DocumentType:{properties:Te,optionalProperties:{...Fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},Kr={id:{type:"string"},hash:{type:"string"}},Co={discriminator:"type",mapping:{CollectionType:{properties:{...Te,...Kr},optionalProperties:Fe,additionalProperties:!0},DocumentType:{properties:{...Te,...Kr,fileType:{enum:["notebook","epub","pdf",""]}},optionalProperties:{...Fe,lastOpened:{type:"string"},lastOpenedPage:{type:"int32"},createdTime:{type:"string"}},additionalProperties:!0}}},te=class extends Error{status;statusText;constructor(e,r,n){super(n),this.status=e,this.statusText=r}},Qe=class extends Error{constructor(){super("Generation preconditions failed. This means the current state is out of date with the cloud and needs to be re-synced.")}};async function _i(t,{deviceDesc:e="browser-chrome",uuid:r=ae(),authHost:n=Qr,fetch:o=globalThis.fetch}={}){if(t.length!==8)throw new Error(`code should be length 8, but was ${t.length}`);let i=await o(`${n}/token/json/2/device/new`,{method:"POST",headers:{Authorization:"Bearer"},body:JSON.stringify({code:t,deviceDesc:e,deviceID:r})});if(i.ok)return await i.text();throw new te(i.status,i.statusText,"couldn't register api")}function _o({hash:t,type:e,documentId:r,subfiles:n,size:o}){return`${t}:${e}:${r}:${n}:${o}
10
+ `}function Uo(t){let[e,r,n,o,i]=t.split(":");if(e===void 0||r===void 0||n===void 0||o===void 0||i===void 0)throw new Error(`entries line didn't contain five fields: '${t}'`);if(r==="80000000")return{hash:e,type:r,documentId:n,subfiles:parseInt(o),size:BigInt(i)};if(r==="0"){if(o!=="0")throw new Error(`file type entry had nonzero number of subfiles: ${o}`);return{hash:e,type:r,documentId:n,subfiles:0,size:BigInt(i)}}else throw new Error(`entries line contained invalid type: ${r}`)}var et=class{#u;#s;#f;#r;#n;#e=new Map;#t=null;constructor(e,r,n,o,i,a){this.#u=e,this.#s=r,this.#f=n,this.#r=o,this.#n=i;for(let[f,s]of a)this.#e.set(f,Promise.resolve(s))}async#o(e,{body:r,method:n="POST",headers:o={}}){let i=await this.#s(e,{method:n,headers:{Authorization:`Bearer ${this.#u}`,...o},body:r});if(i.ok)return i;{let a=await i.text();throw new te(i.status,i.statusText,`failed reMarkable request: ${a}`)}}async#i({url:e,method:r,maxuploadsize_bytes:n},o,i={}){let a=n?{...i,[ko]:`0,${n}`}:i,f=await this.#s(e,{method:r,body:o,headers:a});if(f.ok)return f;{let s=await f.text();throw new te(f.status,f.statusText,s)}}async#a(e,r,n){let o=r===void 0?"downloads":"uploads",i=n&&r!==null&&r!==void 0?`{ "http_method": "PUT", "relative_path": "${e}", "root_schema": "${n}", "generation": ${r} }`:JSON.stringify({http_method:"GET",relative_path:e}),f=await(await this.#o(`${this.#r}/sync/v2/signed-urls/${o}`,{body:i})).text(),s=JSON.parse(f);return se(Mo,s),s}async getRootHash({cache:e=!0}={}){if(e)for(;this.#t;)try{let[i,a]=await this.#t;return[i,a]}catch{}let r=(async()=>{try{let i=await this.#a("root"),a=await this.#i(i),f=a.headers.get(Yr);if(f)return[await a.text(),BigInt(f)];throw new Error("no generation header in root hash")}catch(i){throw this.#t=null,i}})();this.#t=r;let[n,o]=await r;return[n,o]}async putRootHash(e,r){let n=await this.#a("root",r,e),o;try{o=await this.#i(n,e,{[Fo]:`${r}`})}catch(f){throw f instanceof te&&f.status===412?(this.#t=null,new Qe):f}let i=o.headers.get(Yr);if(!i)throw new Error("no generation header in root hash");let a=BigInt(i);return this.#t=Promise.resolve([e,a]),a}async#l(e){let r=this.#e.get(e);for(;r;)try{let o=await r;if(o)return o;r=void 0}catch{r=this.#e.get(e)}let n=(async()=>{let o=await this.#a(e);return await(await this.#i(o)).arrayBuffer()})();return this.#e.set(e,n.then(o=>o.byteLength<this.#n?o:null,o=>{throw this.#e.delete(e),o})),await n}async getBuffer(e){let r=await this.#l(e);return r.byteLength<this.#n?r.slice(0):r}async getText(e){let r=await this.#l(e);return new TextDecoder().decode(r)}async getJson(e){let r=await this.getText(e);return JSON.parse(r)}async getMetadata(e,{verify:r=!0}={}){let n=await this.getJson(e);return se(Bo,n,r),n}async getEntries(e){if(e===void 0){let[i]=await this.getRootHash({cache:!0});e=i}let r=await this.getText(e),[n,...o]=r.slice(0,-1).split(`
11
+ `);if(n!==Wr)throw new Error(`got unexpected schema version: ${n}`);return o.map(Uo)}async#p(e,r){let n=this.#e.get(e);if(n)try{await n;return}catch{}let o=(async()=>{try{let i=await this.#a(e,null);return await this.#i(i,r),r.byteLength<this.#n?r:null}catch(i){throw this.#e.delete(e),i}})();this.#e.set(e,o),await o}async putEntries(e,r){let n=new TextEncoder;r.sort((p,m)=>p.documentId.localeCompare(m.documentId));let o=Cr(r.map(p=>Br(p.hash))),i=await this.#f.digest("SHA-256",o),a=Ye(i),f=r.map(_o).join(""),s=`${Wr}
12
+ ${f}`,c=n.encode(s);return await this.#p(a,c),{hash:a,type:"80000000",documentId:e,subfiles:r.length,size:0n}}async putBuffer(e,r){let n=await this.#f.digest("SHA-256",r),o=Ye(n);return await this.#p(o,r),{hash:o,type:"0",documentId:e,subfiles:0,size:BigInt(r.byteLength)}}async putText(e,r){let n=new TextEncoder;return await this.putBuffer(e,n.encode(r))}async putJson(e,r){return await this.putText(e,(0,Zr.default)(r))}async putMetadata(e,r){return await this.putJson(`${e}.metadata`,r)}async putCollection(e,r=""){let n=ae(),o=`${new Date().valueOf()}`,i=[],a={type:"CollectionType",visibleName:e,version:0,parent:r,synced:!0,lastModified:o};i.push(this.putMetadata(n,a)),i.push(this.putText(`${n}.content`,"{}"));let f=await Promise.all(i);return await this.putEntries(n,f)}async#c(e,r,n,o,i){if(i.fileType!==n)throw new Error(`internal error: fileTypes don't match: ${n}, ${i.fileType}`);let a=ae(),f=`${new Date().valueOf()}`,s=[];s.push(this.putBuffer(`${a}.${n}`,r));let c={type:"DocumentType",visibleName:e,version:0,parent:o,synced:!0,lastModified:f};s.push(this.putMetadata(a,c)),s.push(this.putText(`${a}.content`,JSON.stringify(i)));let p=await Promise.all(s);return await this.putEntries(a,p)}async putEpub(e,r,{parent:n="",margins:o=125,orientation:i,textAlignment:a,textScale:f=1,lineHeight:s=-1,fontName:c="",cover:p="visited",lastTool:m}={}){let u={dummyDocument:!1,extraMetadata:{LastTool:m},fileType:"epub",pageCount:0,lastOpenedPage:0,lineHeight:typeof s=="string"?jo[s]:s,margins:typeof o=="string"?$o[o]:o,textScale:typeof f=="string"?Io[f]:f,pages:[],coverPageNumber:p==="first"?0:-1,formatVersion:1,orientation:i,textAlignment:a,fontName:c};return await this.#c(e,r,"epub",n,u)}async putPdf(e,r,{parent:n="",orientation:o,cover:i="first",lastTool:a}={}){let f={dummyDocument:!1,extraMetadata:{LastTool:a},fileType:"pdf",pageCount:0,lastOpenedPage:0,lineHeight:-1,margins:125,textScale:1,pages:[],coverPageNumber:i==="first"?0:-1,formatVersion:1,orientation:o};return await this.#c(e,r,"pdf",n,f)}async syncComplete(e){let r=`{ "generation": ${e} }`;await this.#o(`${this.#r}/sync/v2/sync-complete`,{body:r})}async#y(e,r,n){let{hash:o}=await this.putEntries("",r),i=await this.putRootHash(o,e);if(n)try{return await this.syncComplete(i),!0}catch{return!1}else return!1}async create(e,{cache:r=!0,sync:n=!0}={}){let[o,i]=await this.getRootHash({cache:r}),a=await this.getEntries(o);return a.push(e),await this.#y(i,a,n)}async move(e,r,{cache:n=!0,sync:o=!0}={}){let[i,a]=await this.getRootHash({cache:n}),f=await this.getEntries(i);if(!(!r||r==="trash")){let b=f.find(R=>R.documentId===r);if(b){if(b.type!=="80000000")throw new Error(`destination id was a raw file: ${r}`)}else throw new Error(`destination id not found: ${r}`);let _=await this.getEntries(b.hash),[P]=_.filter(R=>R.documentId===`${r}.metadata`);if(!P)throw new Error(`destination id didn't have metadata: ${r}`);if((await this.getMetadata(P.hash)).type!=="CollectionType")throw new Error(`destination id wasn't a collection: ${r}`)}let s=f.findIndex(b=>b.documentId===e);if(s===-1)throw new Error(`document not found: ${e}`);let[c]=f.splice(s,1);if(c.type!=="80000000")throw new Error(`document was a raw file: ${e}`);let p=await this.getEntries(c.hash),m=p.findIndex(b=>b.documentId===`${e}.metadata`);if(m===-1)throw new Error(`document didn't have metadata: ${e}`);let[u]=p.splice(m,1),S=await this.getMetadata(u.hash);S.parent=r;let v=await this.putMetadata(e,S);p.push(v);let k=await this.putEntries(e,p);return f.push(k),await this.#y(a,f,o)}async getEntriesMetadata({verify:e=!0}={}){let n=await(await this.#o(`${this.#r}/doc/v2/files`,{method:"GET",headers:{"rm-source":"RoR-Browser"}})).text(),o=JSON.parse(n);return se({elements:Co},o,e),o}async#d(e,r,n,o){let a=new TextEncoder().encode(JSON.stringify({file_name:e})),s=await(await this.#o(`${this.#r}/doc/v2/files`,{body:r,headers:{"content-type":n,"rm-meta":(0,Xr.fromByteArray)(a),"rm-source":"RoR-Browser"}})).text(),c=JSON.parse(s);return se(Ro,c,o),c}async uploadEpub(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/epub+zip",n)}async uploadPdf(e,r,{verify:n=!0}={}){return await this.#d(e,r,"application/pdf",n)}async getCache(){let e=[];for(let[o,i]of this.#e)e.push(i.then(a=>[o,a],()=>[o,null]));let r=await Promise.all(e),n=new Map;for(let[o,i]of r)i&&n.set(o,i);return n}};async function Ui(t,{fetch:e=globalThis.fetch,subtle:r=globalThis.crypto?.subtle,authHost:n=Qr,syncHost:o=To,cacheLimitBytes:i=1048576,initCache:a=[]}={}){if(!r)throw new Error("subtle was missing, try specifying it manually");let f=await e(`${n}/token/json/2/user/new`,{method:"POST",headers:{Authorization:`Bearer ${t}`}});if(!f.ok)throw new Error(`couldn't fetch auth token: ${f.statusText}`);let s=await f.text();return new et(s,e,r,o,i,a)}})();
package/dist/index.d.ts CHANGED
@@ -85,7 +85,7 @@ export interface CommonMetadata {
85
85
  /** parent uuid (documentId) or "" for root or "trash" */
86
86
  parent?: string;
87
87
  /** last modified time */
88
- lastModified: string;
88
+ lastModified?: string;
89
89
  /** unknown significance */
90
90
  version?: number;
91
91
  /** unknown significance */
@@ -434,7 +434,7 @@ export interface RemarkableApi {
434
434
  /**
435
435
  * create a new collection (folder)
436
436
  *
437
- * @param documentId - the name of the new folder
437
+ * @param visibleName - the name of the new folder
438
438
  * @param parent - the documentId of the parent collection (folder)
439
439
  */
440
440
  putCollection(visibleName: string, parent?: string): Promise<CollectionEntry>;
@@ -521,7 +521,7 @@ export interface RemarkableApi {
521
521
  * ```
522
522
  *
523
523
  * @param entry - and entry, usually created by a `put*` method
524
- * @param sync - whether to notify apps of a change (default: true)
524
+ * @param options - any extra options for creation
525
525
  * @returns synced - if sync was successful
526
526
  * @throws error - if any error occurred, in this case, nothing will be
527
527
  * changed
@@ -557,7 +557,7 @@ export interface RemarkableApi {
557
557
  * @param dest - the new parent of this collection or document; this should
558
558
  * be the document id of an existing collection, an empty string for root,
559
559
  * or the string `"trash"` to move to the trash
560
- * @param sync - whether to notify apps of a change (default: true)
560
+ * @param opts - any extra options for moving
561
561
  * @returns synced - true if synced successfully
562
562
  * @throws error - if any error occurred, in this case, nothing will be
563
563
  * changed
package/dist/index.js CHANGED
@@ -139,9 +139,9 @@ const urlResponseSchema = {
139
139
  };
140
140
  const commonProperties = {
141
141
  visibleName: { type: "string" },
142
- lastModified: { type: "string" },
143
142
  };
144
143
  const commonOptionalProperties = {
144
+ lastModified: { type: "string" },
145
145
  version: { type: "int32" },
146
146
  pinned: { type: "boolean" },
147
147
  synced: { type: "boolean" },
@@ -491,10 +491,12 @@ class Remarkable {
491
491
  }
492
492
  /**
493
493
  * get metadata from hash
494
+ *
495
+ * Call with `verify: false` to disable checking the response.
494
496
  */
495
- async getMetadata(hash) {
497
+ async getMetadata(hash, { verify = true } = {}) {
496
498
  const raw = await this.getJson(hash);
497
- validate(metadataSchema, raw);
499
+ validate(metadataSchema, raw, verify);
498
500
  return raw;
499
501
  }
500
502
  /**
@@ -768,7 +770,7 @@ class Remarkable {
768
770
  return await this.#tryPutRootEntries(gen, rootEntries, sync);
769
771
  }
770
772
  /** get entries and metadata for all files */
771
- async getEntriesMetadata() {
773
+ async getEntriesMetadata({ verify = true, } = {}) {
772
774
  const resp = await this.#authedFetch(`${this.#syncHost}/doc/v2/files`, {
773
775
  method: "GET",
774
776
  headers: {
@@ -780,11 +782,11 @@ class Remarkable {
780
782
  const schema = {
781
783
  elements: metadataEntrySchema,
782
784
  };
783
- validate(schema, res);
785
+ validate(schema, res, verify);
784
786
  return res;
785
787
  }
786
788
  /** upload a file */
787
- async #uploadFile(visibleName, buffer, contentType) {
789
+ async #uploadFile(visibleName, buffer, contentType, verify) {
788
790
  const encoder = new TextEncoder();
789
791
  const meta = encoder.encode(JSON.stringify({ file_name: visibleName }));
790
792
  const resp = await this.#authedFetch(`${this.#syncHost}/doc/v2/files`, {
@@ -797,17 +799,17 @@ class Remarkable {
797
799
  });
798
800
  const raw = await resp.text();
799
801
  const res = JSON.parse(raw);
800
- validate(uploadEntrySchema, res);
802
+ validate(uploadEntrySchema, res, verify);
801
803
  return res;
802
804
  }
803
805
  /** upload an epub */
804
- async uploadEpub(visibleName, buffer) {
805
- return await this.#uploadFile(visibleName, buffer, "application/epub+zip");
806
+ async uploadEpub(visibleName, buffer, { verify = true } = {}) {
807
+ return await this.#uploadFile(visibleName, buffer, "application/epub+zip", verify);
806
808
  }
807
809
  /** upload a pdf */
808
- async uploadPdf(visibleName, buffer) {
810
+ async uploadPdf(visibleName, buffer, { verify = true } = {}) {
809
811
  // TODO why doesn't this work
810
- return await this.#uploadFile(visibleName, buffer, "application/pdf");
812
+ return await this.#uploadFile(visibleName, buffer, "application/pdf", verify);
811
813
  }
812
814
  async getCache() {
813
815
  const promises = [];
@@ -1,3 +1,3 @@
1
1
  import { JTDSchemaType as JtdSchema } from "ajv/dist/jtd";
2
2
  export type { JtdSchema };
3
- export declare function validate<T>(schema: JtdSchema<T>, obj: unknown): asserts obj is T;
3
+ export declare function validate<T>(schema: JtdSchema<T>, obj: unknown, verify?: boolean): asserts obj is T;
package/dist/validate.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { validate as jtdValidate } from "jtd";
2
- export function validate(schema, obj) {
3
- const errors = jtdValidate(schema, obj);
2
+ export function validate(schema, obj, verify = true) {
3
+ const errors = verify ? jtdValidate(schema, obj) : [];
4
4
  if (errors.length) {
5
5
  // TODO better errors
6
6
  throw new Error(`couldn't validate schema: ${JSON.stringify(obj)} didn't match schema ${JSON.stringify(schema)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rmapi-js",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "description": "JavaScript implementation of the reMarkable 1.5 api",
5
5
  "repository": "git@github.com:erikbrinkman/rmapi-js.git",
6
6
  "author": "Erik Brinkman <erik.brinkman@gmail.com>",
@@ -17,7 +17,7 @@
17
17
  "./dist/**/*.js",
18
18
  "./dist/**/*.d.ts"
19
19
  ],
20
- "packageManager": "yarn@3.6.1",
20
+ "packageManager": "yarn@4.1.1",
21
21
  "scripts": {
22
22
  "doc": "pnpify typedoc",
23
23
  "fmt": "pnpify prettier --cache --write 'src/*.ts' '*.json'",
@@ -31,35 +31,35 @@
31
31
  "dependencies": {
32
32
  "ajv": "^8.12.0",
33
33
  "base64-js": "^1.5.1",
34
- "json-stable-stringify": "^1.1.0",
34
+ "json-stable-stringify": "^1.1.1",
35
35
  "jtd": "^0.1.1",
36
36
  "uuid": "^9.0.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "^7.23.5",
40
- "@babel/preset-env": "^7.23.5",
41
- "@babel/preset-typescript": "^7.23.3",
39
+ "@babel/core": "^7.24.4",
40
+ "@babel/preset-env": "^7.24.4",
41
+ "@babel/preset-typescript": "^7.24.1",
42
42
  "@types/babel__core": "^7.20.5",
43
43
  "@types/babel__preset-env": "^7.9.6",
44
- "@types/jest": "^29.5.10",
44
+ "@types/jest": "^29.5.12",
45
45
  "@types/json-stable-stringify": "^1.0.36",
46
- "@types/node": "^20.10.3",
47
- "@types/uuid": "^9.0.7",
48
- "@typescript-eslint/eslint-plugin": "^6.13.2",
49
- "@typescript-eslint/parser": "^6.13.2",
46
+ "@types/node": "^20.12.4",
47
+ "@types/uuid": "^9.0.8",
48
+ "@typescript-eslint/eslint-plugin": "^7.5.0",
49
+ "@typescript-eslint/parser": "^7.5.0",
50
50
  "@yarnpkg/pnpify": "^4.0.1",
51
51
  "babel-jest": "^29.7.0",
52
- "esbuild": "^0.19.8",
53
- "eslint": "^8.55.0",
52
+ "esbuild": "^0.20.2",
53
+ "eslint": "^8.57.0",
54
54
  "eslint-config-prettier": "^9.1.0",
55
- "eslint-plugin-jest": "^27.6.0",
55
+ "eslint-plugin-jest": "^27.9.0",
56
56
  "eslint-plugin-spellcheck": "^0.0.20",
57
57
  "eslint-plugin-tsdoc": "^0.2.17",
58
58
  "jest": "^29.7.0",
59
- "prettier": "^3.1.0",
59
+ "prettier": "^3.2.5",
60
60
  "prettier-plugin-organize-imports": "^3.2.4",
61
- "typedoc": "^0.25.4",
62
- "typescript": "^5.3.2"
61
+ "typedoc": "^0.25.12",
62
+ "typescript": "^5.4.3"
63
63
  },
64
64
  "prettier": {
65
65
  "plugins": [