@banou/stub 0.0.80 → 0.0.82
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/build/assets/lib-ar-BKUhWtqq-DyNWz5dG.js +1 -0
- package/build/assets/lib-ar-CgLEvHKh.js +1 -0
- package/build/assets/{lib-base-text-Bo_k1rfI.js → lib-base-text-C_3yUTN5.js} +1 -1
- package/build/assets/lib-cs-BvLBholA-v7VWUFBw.js +1 -0
- package/build/assets/lib-cs-z6-m52XC.js +1 -0
- package/build/assets/lib-de-DRvwZR3H.js +1 -0
- package/build/assets/lib-de-y1Sfuomd-B5yqed8F.js +1 -0
- package/build/assets/lib-el-BLXQWVlC-BbqKa0Qt.js +1 -0
- package/build/assets/lib-el-PAakHtET.js +1 -0
- package/build/assets/lib-embed-FacF8Mrb.js +606 -0
- package/build/assets/lib-es-419-B-wTNdBw-CIHYjte5.js +1 -0
- package/build/assets/lib-es-419-BJv0wjV_.js +1 -0
- package/build/assets/lib-fr-OiId2v-H.js +1 -0
- package/build/assets/lib-fr-Or4IAkAC-CoSsHVTP.js +1 -0
- package/build/assets/lib-he-B2_LeVeD.js +1 -0
- package/build/assets/lib-he-nl-tnFbO-CrVPcK44.js +1 -0
- package/build/assets/lib-hi-CS7-TL4I-DXVM9mvo.js +1 -0
- package/build/assets/lib-hi-DPwXz8H3.js +1 -0
- package/build/assets/lib-hu-BdzB_JPB.js +1 -0
- package/build/assets/lib-hu-hHWv9XJW-D4zUhWWj.js +1 -0
- package/build/assets/lib-id-BW-jdZEK.js +1 -0
- package/build/assets/lib-id-DcmwFGDL-BqAElgpH.js +1 -0
- package/build/assets/lib-it-BBrmPXkE.js +1 -0
- package/build/assets/lib-it-CaynDCNV-B4RtVfBK.js +1 -0
- package/build/assets/lib-ja-DNCIfzoN-uAOwevd_.js +1 -0
- package/build/assets/lib-ja-fXiouS2g.js +1 -0
- package/build/assets/lib-ko-DaEt-p_G-BSgWWdAD.js +1 -0
- package/build/assets/lib-ko-KBHBgIBH.js +1 -0
- package/build/assets/lib-left-to-right-Ce-9FhLm.js +1584 -0
- package/build/assets/lib-ms-CxfGSa1W.js +1 -0
- package/build/assets/lib-ms-Dy-ViAEc-D9_JmqU6.js +1 -0
- package/build/assets/lib-nl-BqeZiqBt-DwWIdtOm.js +1 -0
- package/build/assets/lib-nl-DkimY56E.js +1 -0
- package/build/assets/lib-pl-BFtE2Ebj-Da9qOxNl.js +1 -0
- package/build/assets/lib-pl-DYs8R_wN.js +1 -0
- package/build/assets/lib-pt-BR-DuYtxBnz-t3tpOOJi.js +1 -0
- package/build/assets/lib-pt-BR-rY35hakH.js +1 -0
- package/build/assets/lib-ro-C-PksuHO-v24t6U9f.js +1 -0
- package/build/assets/lib-ro-kvvaEZ3M.js +1 -0
- package/build/assets/lib-ru-02Njkw2V.js +1 -0
- package/build/assets/lib-ru-B97_Te6U-C7ntRCX3.js +1 -0
- package/build/assets/lib-sv-CIevMFTp.js +1 -0
- package/build/assets/lib-sv-nGptBIL3-DFWsCrcj.js +1 -0
- package/build/assets/lib-th-B7YM4s_R-C6R_r94-.js +1 -0
- package/build/assets/lib-th-CmBMfZ3-.js +1 -0
- package/build/assets/{lib-theme-player-CeKtHxlc.js → lib-theme-player-BMCvFC2l.js} +1 -1
- package/build/assets/lib-tr-BfUJOedF.js +1 -0
- package/build/assets/lib-tr-kIYMqKkp-B16Yg592.js +1 -0
- package/build/assets/{lib-track-languages-DeHLRrle.js → lib-track-languages-DnB3w_Os.js} +7 -7
- package/build/assets/lib-uk-BiGFd-3R.js +1 -0
- package/build/assets/lib-uk-ChVF02Su-CYS6qr8h.js +1 -0
- package/build/assets/lib-vi-DtAr1nx5.js +1 -0
- package/build/assets/lib-vi-ZzVwjykl-Be8iqd5A.js +1 -0
- package/build/assets/{lib-worker-55Gx-_nW.js → lib-worker-B8D_q-h5.js} +1 -1
- package/build/assets/{lib-worker-jxI_-TqL.js → lib-worker-Bpyf8gMQ.js} +1 -1
- package/build/assets/lib-worker-anime-seasons-D-lgFwx4.js +1 -0
- package/build/assets/lib-worker-index-DKTkKE9g.js +2906 -0
- package/build/assets/lib-zh-Hans-BvGYI5EK-I-yg4Oq0.js +1 -0
- package/build/assets/lib-zh-Hans-h0aj_oyp.js +1 -0
- package/build/assets/lib-zh-Hant-CPR3PIcu.js +1 -0
- package/build/assets/lib-zh-Hant-gIYpODUQ-D7AzGx7J.js +1 -0
- package/build/embed.html +5 -5
- package/build/index.html +3 -3
- package/build/index.js +6 -6
- package/fkn.json +1 -1
- package/package.json +3 -3
- package/build/assets/lib-ar-BTkxNQDY-Cq2XvKz7.js +0 -1
- package/build/assets/lib-ar-CzLUnuMZ.js +0 -1
- package/build/assets/lib-cs-BiLoeGy--l4Bdulxu.js +0 -1
- package/build/assets/lib-cs-eYXUrvXa.js +0 -1
- package/build/assets/lib-de-DjLIQ1c0.js +0 -1
- package/build/assets/lib-de-DyhgPm3R-DGeMNo_U.js +0 -1
- package/build/assets/lib-el-CVS9LZc2-gByIELC4.js +0 -1
- package/build/assets/lib-el-CySC6LJg.js +0 -1
- package/build/assets/lib-embed-N48Y-n0C.js +0 -441
- package/build/assets/lib-es-419-BldBGmAI-CFk7KyRN.js +0 -1
- package/build/assets/lib-es-419-D98yuFKK.js +0 -1
- package/build/assets/lib-fr-CJbNFyKA.js +0 -1
- package/build/assets/lib-fr-Dr9L85w5-B81_xpP8.js +0 -1
- package/build/assets/lib-he-8WQRky_v.js +0 -1
- package/build/assets/lib-he-CGziLNEO-BnSw7_pO.js +0 -1
- package/build/assets/lib-hi-BGJb0LCz-D5VUYbW5.js +0 -1
- package/build/assets/lib-hi-CdQl1Kmu.js +0 -1
- package/build/assets/lib-hu-DFEC1-6S.js +0 -1
- package/build/assets/lib-hu-hFDCZ6w3-DCStgYkA.js +0 -1
- package/build/assets/lib-id-C73V2jGE-Bw4detuC.js +0 -1
- package/build/assets/lib-id-CfTLrhaG.js +0 -1
- package/build/assets/lib-it-Cr9A6SQy-aLXUb80G.js +0 -1
- package/build/assets/lib-it-gXK5REWR.js +0 -1
- package/build/assets/lib-ja-CZ2XwiKV-D5e-dH6P.js +0 -1
- package/build/assets/lib-ja-E8phOYwY.js +0 -1
- package/build/assets/lib-ko-AcuzUEVd.js +0 -1
- package/build/assets/lib-ko-jI_tU0qA-CdEx4zHq.js +0 -1
- package/build/assets/lib-left-to-right-ClAJFzDF.js +0 -1405
- package/build/assets/lib-ms-BRDesLhz.js +0 -1
- package/build/assets/lib-ms-D5zk4lg1-CWuQcmxG.js +0 -1
- package/build/assets/lib-nl-CZGoStk6-DG_39MHV.js +0 -1
- package/build/assets/lib-nl-GRX6NYvr.js +0 -1
- package/build/assets/lib-pl-BH8_921S-_USjE-Zo.js +0 -1
- package/build/assets/lib-pl-D6XpJ6-B.js +0 -1
- package/build/assets/lib-pt-BR-B1_quo0--Bbe4-Y96.js +0 -1
- package/build/assets/lib-pt-BR-CHRbNRzd.js +0 -1
- package/build/assets/lib-ro-CyrebrBz-DOeGix3v.js +0 -1
- package/build/assets/lib-ro-D565U23q.js +0 -1
- package/build/assets/lib-ru-ChUuyeBf-D-oVstYB.js +0 -1
- package/build/assets/lib-ru-yhr1BhlZ.js +0 -1
- package/build/assets/lib-sv-DTfGPFQ0.js +0 -1
- package/build/assets/lib-sv-hA5iqV_h-MFwolEYg.js +0 -1
- package/build/assets/lib-th-CUGw6-hb-Ct96NUAG.js +0 -1
- package/build/assets/lib-th-DUpovW2I.js +0 -1
- package/build/assets/lib-tr-CNYhEEX2.js +0 -1
- package/build/assets/lib-tr-UxaS1La9-B2DVdFFr.js +0 -1
- package/build/assets/lib-uk-BG06kJ0--BVBmxXDG.js +0 -1
- package/build/assets/lib-uk-BZPMKMpZ.js +0 -1
- package/build/assets/lib-vi-BZ0swL2E-ByMC84Pv.js +0 -1
- package/build/assets/lib-vi-terKCAEL.js +0 -1
- package/build/assets/lib-worker-anime-seasons-DrX8B6Us.js +0 -1
- package/build/assets/lib-worker-index-C3t1LR22.js +0 -2906
- package/build/assets/lib-zh-Hans-DWcC6Npa-CM5RQlmW.js +0 -1
- package/build/assets/lib-zh-Hans-x7oNfHHn.js +0 -1
- package/build/assets/lib-zh-Hant-CGbboh5i.js +0 -1
- package/build/assets/lib-zh-Hant-t-KZEzIO-D6h_q0SN.js +0 -1
|
@@ -50,9 +50,9 @@ import{c as e,d as t,l as n,o as r,s as i,u as a}from"./lib-language-CNKEEyke.js
|
|
|
50
50
|
`)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}declaration(e){return this.compress?this.emit(`${e.property}:${e.value}`,e.position)+this.emit(`;`):e.property===`grid-template-areas`?this.emit(this.indent())+this.emit(e.property+`: `+e.value.split(`
|
|
51
51
|
`).join(`
|
|
52
52
|
`.padEnd(22)+this.indent()),e.position)+this.emit(`;`):this.emit(this.indent())+this.emit(`${e.property}: ${e.value}`,e.position)+this.emit(`;`)}},Mt=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new Et(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new Tt(t?.source||``,i,n,r,e);if(!t?.silent)throw o;a.push(o)}function s(){let t=/^{\s*/.exec(e);return!!t&&(l(t),!0)}function c(){let t=/^}/.exec(e);return!!t&&(l(t),!0)}function l(t){let i=t[0];return function(e){let t=e.match(/\n/g);t&&(n+=t.length);let i=e.lastIndexOf(`
|
|
53
|
-
`);r=~i?e.length-i:r+e.length}(i),e=e.slice(i.length),t}function u(){let t=/^\s*/.exec(e);t&&l(t)}function d(e){e||=[];let t=f();for(;t;)e.push(t),t=f();return e}function f(){let t=i();if(e.charAt(0)!==`/`||e.charAt(1)!==`*`)return;let n=/^\/\*[^]*?\*\//.exec(e);return n?(l(n),t({type:z.comment,comment:n[0].slice(2,-2)})):o(`End of comment missing`)}function p(){let t=Ot(e,[`{`]);if(t===-1||t===0)return;let n=e.substring(0,t);return l([n]),((e,t)=>{let n=[],r=0;for(;r<e.length;){let i=Ot(e,t,r);if(i===-1)return n.push(e.substring(r)),n;n.push(e.substring(r,i)),r=i+1}return n})(B(n).replace(kt,``),[`,`]).map(e=>B(e))}function m(){let t=i(),n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!n)return;l(n);let r=B(n[0]),a=/^:\s*/.exec(e);if(!a)return o(`property missing ':'`);l(a);let s=``,c=Ot(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=B(s).replace(kt,``));let u=t({type:z.declaration,property:r.replace(kt,``),value:s}),d=/^[;\s]*/.exec(e);return d&&l(d),u}function h(){let n=[];if(!s())return o(`missing '{'`);d(n);let r=m();for(;r;)n.push(r),d(n),r=m();for(;t?.silent&&e.length&&e.charAt(0)!==`}`;){let t=e.indexOf(`;`),i=e.indexOf(`}`);if(t===-1||!(i===-1||t<i))break;for(l([e.substring(0,t+1)]),u(),d(n),r=m();r;)n.push(r),d(n),r=m()}return c()?n:o(`missing '}'`)}function g(){let t=Ot(e,[`{`]);if(t===-1)return!1;let n=Ot(e,[`;`]),r=Ot(e,[`}`]);return!(n!==-1&&n<t)&&!(r!==-1&&r<t)}function _(){let n=[];if(!s())return o(`missing '{'`);for(d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return c()?n:o(`missing '}'`)}function v(){let n=[];for(u(),d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return n}function y(){let t=[],n=i(),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);for(;r;){let n=l(r);t.push(n[1]);let i=/^,\s*/.exec(e);i&&l(i),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e)}if(t.length)return n({type:z.keyframe,values:t,declarations:h()||[]})}let b=/* @__PURE__ */ RegExp(`^@(top-left-corner|top-left|top-center|top-right|top-right-corner|bottom-left-corner|bottom-left|bottom-center|bottom-right|bottom-right-corner|left-top|left-middle|left-bottom|right-top|right-middle|right-bottom)(?![\\w-])\\s*`),x=w(`import`),S=w(`charset`),C=w(`namespace`);function w(t){let n=RegExp(`^@`+t+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return()=>{let r=i(),a=n.exec(e);if(!a)return;let o=l(a),s={type:t};return s[t]=o[1].trim(),r(s)}}function T(){if(e[0]===`@`)return function(){let t=i(),n=/^@([-\w]+)?keyframes\s*/.exec(e);if(!n)return;let r=l(n)[1],a=/^([-\w]+)\s*/.exec(e);if(!a)return o(`@keyframes missing name`);let u=l(a)[1];if(!s())return o(`@keyframes missing '{'`);let f=d(),p=y();for(;p;)f.push(p),f=f.concat(d()),p=y();return c()?t({type:z.keyframes,name:u,vendor:r,keyframes:f}):o(`@keyframes missing '}'`)}()||function(){let t=i(),n=/^@media *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@media missing '{'`);let a=v();return c()?t({type:z.media,media:r,rules:a}):o(`@media missing '}'`)}()||function(){let t=i(),n=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!n)return;let r=l(n);return t({type:z.customMedia,name:B(r[1]),media:B(r[2])})}()||function(){let t=i(),n=/^@supports *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@supports missing '{'`);let a=v();return c()?t({type:z.supports,supports:r,rules:a}):o(`@supports missing '}'`)}()||x()||S()||C()||function(){let t=i(),n=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!n)return;let r=l(n),a=B(r[1]),u=B(r[2]);if(!s())return o(`@document missing '{'`);let d=v();return c()?t({type:z.document,document:u,vendor:a,rules:d}):o(`@document missing '}'`)}()||function(){let t=i(),n=/^@page */.exec(e);if(!n)return;l(n);let r=p()||[];if(!s())return o(`@page missing '{'`);let a=[];for(d(a);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){a.push(e),d(a);continue}}let t=m();if(!t)break;a.push(t),d(a)}return c()?t({type:z.page,selectors:r,declarations:a}):o(`@page missing '}'`)}()||function(){let t=i(),n=/^@host\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@host missing '{'`);let r=v();return c()?t({type:z.host,rules:r}):o(`@host missing '}'`)}()||function(){let t=i(),n=/^@font-face\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@font-face missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:z.fontFace,declarations:r}):o(`@font-face missing '}'`)}()||function(){let t=i(),n=/^@font-feature-values\s+([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@font-feature-values missing '{'`);let a=v();return c()?t({type:z.fontFeatureValues,fontFamily:r,rules:a}):o(`@font-feature-values missing '}'`)}()||function(){let t=i(),n=/^@container *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@container missing '{'`);let a=v();return c()?t({type:z.container,container:r,rules:a}):o(`@container missing '}'`)}()||function(){let t=i(),n=/^@starting-style\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@starting-style missing '{'`);let r=v();return c()?t({type:z.startingStyle,rules:r}):o(`@starting-style missing '}'`)}()||function(){let t=i(),n=/^@layer *([^{;@]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s()){let n=/^[;\s]*/.exec(e);return n&&l(n),t({type:z.layer,layer:r})}let a=v();return c()?t({type:z.layer,layer:r,rules:a}):o(`@layer missing '}'`)}()||function(){let t=i(),n=/^@property\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@property missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.property,name:r,declarations:a}):o(`@property missing '}'`)}()||function(){let t=i(),n=/^@counter-style\s+([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@counter-style missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.counterStyle,name:r,declarations:a}):o(`@counter-style missing '}'`)}()||function(){let t=i(),n=/^@scope\s*([^{]*)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@scope missing '{'`);let a=v();return c()?t({type:z.scope,scope:r,rules:a}):o(`@scope missing '}'`)}()||function(){let t=i(),n=/^@view-transition\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@view-transition missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:z.viewTransition,declarations:r}):o(`@view-transition missing '}'`)}()||function(){let t=i(),n=/^@position-try\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@position-try missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.positionTry,name:r,declarations:a}):o(`@position-try missing '}'`)}()||function(){let t=i(),n=b.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@${r} missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.pageMarginBox,name:r,declarations:a}):o(`@${r} missing '}'`)}()||function(){let t=i(),n=/^@([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1],a=``,u=Ot(e,[`{`,`;`]);if(u!==-1&&u>0&&(a=B(e.substring(0,u)),l([e.substring(0,u)])),s()){let e=v();return c()?t({type:z.atRule,name:r,prelude:a,rules:e}):o(`@${r} missing '}'`)}let d=/^[;\s]*/.exec(e);return d&&l(d),t({type:z.atRule,name:r,prelude:a})}()}function E(){let e=i(),t=p();return t?(d(),e({type:z.rule,selectors:t,declarations:_()||[]})):o(`selector missing`)}return At(function(){let n=function(){let n,r=[];for(u(),d(r);e.length;){if(e.charAt(0)===`}`){if(t?.silent){o(`extra '}'`),l([`}`]),u(),d(r);continue}break}if(n=T()||E(),!n){if(t?.silent){l([e.charAt(0)]),u(),d(r);continue}break}r.push(n),d(r)}return r}();return{type:z.stylesheet,stylesheet:{source:t?.source,rules:n,parsingErrors:a}}}())},Nt=(e,t)=>new jt(t||{}).compile(e),Pt=Object.defineProperty,Ft=(e,t)=>{let n={};for(var r in e)Pt(n,r,{get:e[r],enumerable:!0});return t||Pt(n,Symbol.toStringTag,{value:`Module`}),n},It=`LocatorError`,Lt=`LocatorUnsupportedError`,Rt=`LocatorDeniedError`,zt=`LocatorInvalidError`,Bt=e=>typeof e==`object`&&e?e.name:void 0,Vt=e=>Object.assign(Error(e),{name:It}),Ht=(e,t=``,n)=>Object.assign(Error(e),{name:Lt,operation:t,backend:n}),Ut=(e,t)=>Ht(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),V=(e,t)=>Object.assign(Error(e),{name:Rt,operation:t}),Wt=(e,t)=>Object.assign(Error(e),{name:zt,operation:t}),Gt=class extends Error{name=`TimeoutError`;constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause})}},Kt=e=>Bt(e)===Lt,qt=e=>Bt(e)===Rt,Jt=e=>Bt(e)===zt,Yt=e=>qt(e)||Kt(e)||Jt(e),Xt=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw Vt(`the resolved element belongs to a document with no window`);return t},Zt=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},Qt=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return Zt(Xt(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=Zt(globalThis,t);return r&&e instanceof r?r:null},$t=(e,t)=>Qt(e,t)!==null,en=e=>{if(e.length===0)throw Vt(`No elements found`);if(e.length>1)throw Vt(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},tn=(e,t)=>{if(!$t(e,t))throw Vt(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},nn=e=>e.tagName.toLowerCase(),rn=/* @__PURE__ */ new Set,an=e=>{rn.add(e)},on=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,sn=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),cn=e=>!on.test(sn(e.value)),ln=/* @__PURE__ */ new Set([z.import,z.fontFace,z.namespace,z.charset,z.document,z.comment]),un=e=>{if(ln.has(e.type))return null;if(e.type===z.declaration)return cn(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=dn(r))}return n},dn=e=>e.map(e=>un(e)).filter(e=>e!==null),fn=e=>{let t;try{t=Mt(e,{silent:!0})}catch{return``}return t.stylesheet.rules=dn(t.stylesheet.rules),Nt(t)},pn=(e,t)=>{let n=()=>{t.parentNode||(e.head??e.documentElement).appendChild(t)};if(n(),e.readyState===`complete`)return;let r=new MutationObserver(e=>{for(let r of e)for(let e of r.removedNodes)if(e===t||e.contains?.(t)){n();return}});r.observe(e.documentElement,{childList:!0,subtree:!0});let i=()=>r.disconnect(),a=e.defaultView;a?a.addEventListener(`load`,i,{once:!0}):setTimeout(i,3e4)},mn={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:fn(t.content);try{pn(e.document,n)}catch(e){console.error(e)}an(n)}},hn=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},gn={kind:`frame`,ensureArgs:e=>[void 0,e],resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw Wt(`fetch: url must be a string`,`fetch`);let r=Xt(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw Wt(`fetch: not a valid url: ${t}`,`fetch`)}let a=await r.fetch(i,{method:n.method??`GET`,headers:n.headers,body:n.body??null,redirect:n.redirect??`follow`,credentials:n.credentials??`include`});return{status:a.status,statusText:a.statusText,ok:a.ok,url:a.url,redirected:a.redirected,type:a.type,headers:hn(a.headers),body:await a.arrayBuffer()}}},_n=/* @__PURE__ */ Ft({click:()=>bn,clickAsInput:()=>xn,count:()=>kn,exists:()=>An,fill:()=>Tn,getAttribute:()=>Dn,hover:()=>Sn,isVisible:()=>On,textContent:()=>En}),vn=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},yn=(e,t,n,r)=>{let i=en(e.elements),a=Xt(i),o={bubbles:!0,cancelable:!0,composed:!0,...vn(i,t.position),button:0},s={...o,pointerType:`mouse`,pointerId:1,isPrimary:!0},c=n?{detail:1}:{},l=r(i,new a.PointerEvent(`pointerdown`,{...s,buttons:1}))||!n;l&&r(i,new a.MouseEvent(`mousedown`,{...o,...c,buttons:1})),r(i,new a.PointerEvent(`pointerup`,{...s,buttons:0})),l&&r(i,new a.MouseEvent(`mouseup`,{...o,...c,buttons:0})),r(i,n?new a.PointerEvent(`click`,{...s,...c,buttons:0}):new a.MouseEvent(`click`,{...o,buttons:0}))},bn={resolve:(e,t={})=>yn(e,t,!1,(e,t)=>e.dispatchEvent(t))},xn=(e,t={},n)=>yn(e,t,!0,n),Sn={resolve:(e,t={})=>{let n=en(e.elements),r=Xt(n),i={bubbles:!0,cancelable:!0,composed:!0,...vn(n,t.position)},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerover`,a)),n.dispatchEvent(new r.PointerEvent(`pointerenter`,{...a,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseenter`,{...i,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseover`,i)),n.dispatchEvent(new r.PointerEvent(`pointermove`,a)),n.dispatchEvent(new r.MouseEvent(`mousemove`,i))}},Cn=(e,t)=>{e._valueTracker?.setValue(``);let n=(Qt(e,`HTMLTextAreaElement`)??Qt(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},wn=(e,t)=>{if(e.type!==`range`)return null;let n=Number(e.min||0),r=Number(e.max||100);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=Number(t);if(!Number.isFinite(i))return null;let a=Math.max(0,Math.min(1,(i-n)/(r-n))),o=e.getBoundingClientRect(),s={bubbles:!0,cancelable:!0,composed:!0,clientX:o.left+o.width*a,clientY:o.top+o.height/2,button:0},c={...s,pointerType:`mouse`,pointerId:1,isPrimary:!0};return{pointerDown:{...c,buttons:1},pointerUp:{...c,buttons:0},mouseDown:{...s,buttons:1},mouseUp:{...s,buttons:0}}},Tn={resolve:(e,t,n={})=>{let r=en(e.elements),i=Xt(r),a=$t(r,`HTMLInputElement`);if(a||$t(r,`HTMLTextAreaElement`)){let e=r,n=a?wn(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),Cn(e,t),r.dispatchEvent(new i.Event(`input`,{bubbles:!0})),n&&(r.dispatchEvent(new i.PointerEvent(`pointerup`,n.pointerUp)),r.dispatchEvent(new i.MouseEvent(`mouseup`,n.mouseUp))),r.dispatchEvent(new i.Event(`change`,{bubbles:!0}))}else if($t(r,`HTMLElement`)&&r.isContentEditable)r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));else throw Error(`fill: element <${nn(r)}> is not fillable`)}},En={resolve:(e,t={})=>en(e.elements).textContent},Dn={resolve:(e,t,n={})=>en(e.elements).getAttribute(t)},On={resolve:(e,t={})=>{let n=en(e.elements);if(!$t(n,`HTMLElement`))return!0;let r=Xt(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},kn={resolve:(e,t={})=>e.elements.length},An={resolve:(e,t={})=>e.elements.length>0},jn=(e,t)=>(e.topLevel?[e.document]:e.elements).flatMap(e=>[...e.querySelectorAll(t)]),Mn=e=>e.replaceAll(`"`,`\\"`),Nn={to:`element`,css:!0,resolve:(e,t)=>jn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},Pn={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>jn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},Fn={element:{selectors:{locator:Nn,frameLocator:Pn,getByRole:{to:`element`,resolve:(e,t)=>jn(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${Mn(e)}"]`:`[role]`})},getByText:{to:`element`,resolve:(e,t)=>e.elements.flatMap(e=>[e,...e.querySelectorAll(`*`)]).filter(e=>e.textContent?.includes(t)),render:e=>({fragment:typeof e==`string`?`:has-text("${Mn(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>jn(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${Mn(e)}"]`:`[data-testid]`})},first:{to:`element`,resolve:e=>e.elements.slice(0,1),render:()=>({fragment:`:first`})},nth:{to:`element`,resolve:(e,t)=>{let n=e.elements.at(t);return n?[n]:[]},render:e=>({fragment:typeof e==`number`?`:nth(${e})`:`:nth(?)`})}},operations:{click:bn,fill:Tn,hover:Sn,textContent:En,getAttribute:Dn,isVisible:On,count:kn,exists:An}},frame:{selectors:{locator:Nn,frameLocator:Pn,owner:{to:`frame`,barrier:`up`,resolve:e=>{throw Error(`owner: must be processed by the executor as an upward pivot`)},render:()=>({fragment:``,separator:`up`})}},operations:{addStyleTag:mn,fetch:gn}}},In=(e,t=Fn)=>({element:{selectors:{...t.element.selectors,...e.element?.selectors},operations:{...t.element.operations,...e.element?.operations}},frame:{selectors:{...t.frame.selectors,...e.frame?.selectors},operations:{...t.frame.operations,...e.frame?.operations}}}),Ln=3e4,Rn=50,zn=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},Bn=e=>{let t=zn(e)?.timeout;return typeof t==`number`?t:Ln},Vn=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),Hn=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,Vn(e))},Un=(e,t)=>{if(t!==void 0&&typeof t==`number`&&!(Number.isFinite(t)&&t>0))throw TypeError(`${e}: timeout must be a positive number of milliseconds, not ${t}; every call ends at its deadline, so 0 does not turn it off`)},Wn=e=>typeof e==`object`&&e&&typeof e.message==`string`?e.message:String(e),Gn=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;Un(i,zn(a)?.timeout),n&&await n({parts:r,operation:i,args:a,phase:`execute`},Vn(e));let o=Bn(a),s=Date.now()+o,c=/* @__PURE__ */ Error(`Locator timeout (${o}ms): ${i}`),{promise:l,reject:u}=Promise.withResolvers();l.catch(()=>{});let d=setTimeout(()=>u(c),o),f=c;try{do try{return await Promise.race([t.execute(r,i,a),l])}catch(e){if(e===c)break;if(Yt(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(Rn,t)))}while(Date.now()<s)}finally{clearTimeout(d)}throw f===c?new Gt(c.message):new Gt(Wn(f),{cause:f})},Kn=(e,t,n,r,i)=>{let a={};for(let[o,s]of Object.entries(t[r].selectors))a[o]=(...a)=>Kn(e,t,n,s.to,[...i,{kind:r,name:o,args:a}]);for(let[n,o]of Object.entries(t[r].operations))a[n]=async(...t)=>Gn({...e,parts:i,operation:n,args:o.send?o.send(...t):t});for(let[o,{to:s,rewrite:c}]of Object.entries(n[r]??{}))a[o]=(...r)=>Kn(e,t,n,s,c(i,...r));return a.ensure=(n,a={})=>{let o=t[r].operations[n]?.ensureArgs;return Hn({...e,parts:i,operation:n,args:o?.(a)??[a]})},a},qn=e=>Kn(e,e.modules??Fn,e.rewrites??{},`frame`,[]),Jn=()=>{let e=Ze();return e.status===`ok`&&e.abi>=2},Yn=async()=>{await et();let e=Ze();if(e.status===`ok`&&e.abi<2)throw new Ke(e.abi,2)},Xn=e=>`Read the text, links and details ${e} shows.`,Zn=e=>`Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`,Qn=[{id:`interaction`,heading:`Interaction`,summary:`Allow the app to interact with the website (clicks, type in text, etc.)`,title:e=>`Interact with ${e}`,description:(e,t)=>t?`Click, type and hover on ${e} for you. If you are signed in there, this happens as you.`:`Click, type and hover on ${e} for you, in a signed-out view.`,cloudTitle:e=>`Click and type on ${e}`,cloudDescription:e=>`Clicks, types and scrolls on ${e} for you.`},{id:`storage`,heading:`Site data`,summary:`Can read the website's data`,title:e=>`Read data from ${e}`,description:Xn,cloudTitle:e=>`Read what's on ${e}`,cloudDescription:Xn},{id:`network`,heading:`Network`,summary:`Make requests on behalf of the website (using your cookies, etc.)`,title:e=>`Make requests to ${e} as you`,description:e=>`Load pages and data from ${e} and send changes there with your signed-in session.`,cloudTitle:e=>`Load and send data on ${e}`,cloudDescription:e=>`Loads pages and data from ${e} and sends changes there.`},{id:`evaluation`,heading:`Evaluation`,summary:`Can execute arbitrary code on the website`,title:e=>`Run code on ${e}`,description:Zn,cloudTitle:e=>`Run its own code on ${e}`,cloudDescription:Zn}],$n=e=>t=>{if(typeof t!=`object`||!t)return t===void 0?[]:[t];if(t.position!==void 0)throw TypeError(`${e}: position is Playwright's offset in pixels, which no backend serves yet; pass relativePosition, a 0..1 fraction of the box`);let{relativePosition:n,...r}=t;return[n===void 0?r:{...r,position:n}]},er=async(e,t,n)=>{try{return await gn.resolve(e,t,n)}catch(e){throw Yt(e)?e:V(`frame.fetch: ${e instanceof Error?`${e.name}: ${e.message}`:String(e)}; not retried, since the request may already have been sent`,`fetch`)}},tr=In({element:{operations:{click:{resolve:(e,t={})=>_n.click.resolve(e,t),send:$n(`click`)},hover:{resolve:(e,t={})=>_n.hover.resolve(e,t),send:$n(`hover`)},fill:{resolve:(e,t,n={})=>_n.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>_n.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>_n.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>_n.isVisible.resolve(e)},count:{resolve:(e,t={})=>_n.count.resolve(e)},exists:{resolve:(e,t={})=>_n.exists.resolve(e)},videoElement:{resolve:(e,t={})=>De(tn(en(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>mn.resolve(e,t)},fetch:{resolve:(e,t,n={})=>er(e,t,n),kind:gn.kind,ensureArgs:gn.ensureArgs},evaluate:{kind:`frame`,typed:!1,resolve:(e,t,n)=>{throw Ut(`evaluate`,`this realm`)}}}}}),nr=e=>e[e.length-1],rr={element:{last:{to:`element`,rewrite:e=>[...e,{kind:`element`,name:`nth`,args:[-1]}]},contentFrame:{to:`frame`,rewrite:e=>{let t=nr(e);if(t?.name!==`locator`)throw TypeError(`locator.contentFrame: only a locator that ends in locator(selector) can enter its frame; use frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`frameLocator`}]}}},frame:{owner:{to:`element`,rewrite:e=>{let t=nr(e);if(t?.name!==`frameLocator`)throw TypeError(`frameLocator.owner: this frame was not entered through frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`locator`}]}},getByTestId:{to:`element`,rewrite:(e,t)=>[...e,{kind:`element`,name:`getByTestId`,args:[t]}]}}},ir=e=>{if(!e||e===`about:blank`)return!1;let t;try{t=new URL(e,location.href)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`||t.protocol!==`about:`&&ct(t.hostname)},ar=e=>{if(ir(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},or=({src:e,domains:t,lockdown:n})=>{if(n&&!t.length&&e&&e!==`about:blank`)throw Error(`attachFrame: lockdown needs domains when the frame already has a src; pass domains or load it via goto`)},sr={scope:`embed.iframe`,category:`interaction`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},cr={scope:`embed.open`,category:`interaction`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},lr=[`load`,`commit`],ur=e=>{if(`timeoutMs`in e)throw TypeError(`frame.goto: pass timeout, in milliseconds; timeoutMs is not an option`);let{waitUntil:t,timeout:n}=e;if(t!==void 0&&!lr.includes(t))throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);if(n!==void 0&&typeof n!=`number`)throw TypeError(`frame.goto: timeout must be a number of milliseconds`);Un(`frame.goto`,n)},dr=class extends Error{name=`FrameWindowBlockedError`;constructor(){super(`attachFrame: the browser did not open the window. Call attachFrame directly in a click or key handler, and allow popups for this page`)}},fr=/* @__PURE__ */ new Set([`jar-unreachable`,`bad-url`,`opaque-opener`]),pr=class extends Error{name=`FrameWindowRefusedError`;reason;constructor(e){let t=fr.has(e)?e:`unknown`;super(t===`opaque-opener`?`attachFrame: this page has an opaque origin, which a window can never answer, so no window was opened`:`attachFrame: the window refused to attach (${t}), and loaded nothing`),this.reason=t}},mr=[`message`,`document`],hr=e=>{if(e===`*`)return`*`;let t=()=>/* @__PURE__ */ TypeError(`frame.postMessage: targetOrigin must be '*' or an origin, not ${JSON.stringify(e)}`);if(typeof e!=`string`)throw t();let n;try{n=new URL(e).origin}catch{throw t()}if(n===`null`)throw t();return n},gr=(e,t)=>{let n=typeof e==`object`&&!!e;if(n&&t!==void 0)throw TypeError(`frame.postMessage: pass transfer inside the options object, not after it`);let r=n?e.targetOrigin??`*`:e??`*`,i=n?e.transfer:t;if(i!==void 0&&!Array.isArray(i))throw TypeError(`frame.postMessage: transfer must be an array`);return{targetOrigin:hr(r),transfer:i===void 0?[]:[...i]}},_r=[`url`,`path`,`type`],vr=[`content`,`sourceUrl`],yr=/[\n\r\u2028\u2029]/,br=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`frame.addScriptTag: options must be an object { content }`);let t=Object.keys(e),n=t.find(e=>_r.includes(e));if(n!==void 0)throw TypeError(`frame.addScriptTag: "${n}" is not served; it runs content as a classic inline script`);let r=t.find(e=>!vr.includes(e));if(r!==void 0)throw TypeError(`frame.addScriptTag: unknown option "${r}"`);let{content:i,sourceUrl:a}=e;if(typeof i!=`string`)throw TypeError(`frame.addScriptTag: content must be a string`);if(a!==void 0&&(typeof a!=`string`||a===``||yr.test(a)))throw TypeError(`frame.addScriptTag: sourceUrl must be a non-empty string with no line break`);return a===void 0?{content:i}:{content:i,sourceUrl:a}},xr=[`name`,`domain`,`path`],Sr=e=>e instanceof RegExp||Object.prototype.toString.call(e)===`[object RegExp]`,Cr=e=>{if(e===void 0)return{};if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`frame.clearCookies: options must be an object`);let t=e,n=Object.keys(t).find(e=>!xr.includes(e));if(n!==void 0)throw TypeError(`frame.clearCookies: unknown option "${n}"`);let r=xr.flatMap(e=>{let n=t[e];return n===void 0?[]:[{key:e,value:n}]}),i=r.find(({value:e})=>Sr(e));if(i!==void 0)throw TypeError(`frame.clearCookies: ${i.key} is a RegExp, and clearCookies takes strings for name, domain and path for now`);let a=r.find(({value:e})=>typeof e!=`string`);if(a!==void 0)throw TypeError(`frame.clearCookies: ${a.key} must be a string`);let o=r.find(({value:e})=>e===``);if(o!==void 0)throw TypeError(`frame.clearCookies: ${o.key} must not be empty; leave it out to match every ${o.key}`);let s={};for(let{key:e,value:t}of r)s[e]={equals:t};return s},wr=e=>{typeof globalThis.reportError==`function`?globalThis.reportError(e):console.error(e)},Tr=e=>{let{owner:t,...n}=qn({executor:e.executor,modules:tr,rewrites:rr,gate:async(t,n)=>{ut(t.operation,zn(t.args)?.reason),await e.gate?.(t,n)}}),r=async(t,n={})=>(ar(t),ur(n),e.goto(t,n)),i=()=>e.url(),a=async t=>{for(let e of t)ut(`frame.requestPermissions`,e?.reason);let n=e.requestPermissions;if(!n)throw Error(`frame.requestPermissions: this backend cannot ask for permission categories`);return n(t)},o=async(t,n)=>{let r=e.evaluate;if(!r)throw Error(`frame.evaluate: this backend cannot run code in the attached frame`);let i=typeof t==`function`?t.toString():t;if(typeof i!=`string`)throw TypeError(`frame.evaluate: pass a function or a source string`);return r(i,structuredClone(n))},s=async t=>{let{content:n,...r}=br(t),i=e.addScriptTag;if(!i)throw Error(`frame.addScriptTag: this backend cannot run scripts in the attached frame`);await i(n,r)},c=async t=>{let n=Cr(t),r=e.clearCookies;if(!r)throw Error(`frame.clearCookies: this backend cannot clear cookies`);await r(n)},l=((t,n,r)=>{try{let i=e.postMessage;if(!i)throw Error(`frame.postMessage: this backend cannot message the attached frame`);let a=gr(n,r);return i(t,a.targetOrigin,a.transfer)}catch(e){return Promise.reject(e)}}),u={message:/* @__PURE__ */ new Set,document:/* @__PURE__ */ new Set},d=null,f=(e,t)=>{if(!mr.includes(e))throw TypeError(`frame.${t}: the event type must be ${mr.map(e=>`'${e}'`).join(` or `)}, not ${JSON.stringify(e)}`);return u[e]},p=e=>{let t=e.type===`message`?Object.freeze({type:`message`,data:e.data,origin:e.origin,ports:Object.freeze([...e.ports]),source:_}):Object.freeze({type:`document`,origin:e.origin});for(let n of[...u[e.type]])try{n(t)}catch(e){wr(e)}},m=(e,t)=>{if(f(e,`off`).delete(t),d!==null&&!u.message.size&&!u.document.size){let e=d;d=null,e()}},h=(t,n,r={})=>{let i=f(t,`on`);if(typeof n!=`function`)throw TypeError(`frame.on: the listener must be a function`);let{signal:a}=r;if(!(a?.aborted||i.has(n))){if(d===null){let t=e.listen;if(!t)throw Error(`frame.on: this backend cannot relay the page's messages`);d=t(p)}i.add(n),a?.addEventListener(`abort`,()=>m(t,n),{once:!0})}},g=()=>e.backend,_={...n,goto:r,url:i,backend:g,requestPermissions:a,evaluate:o,addScriptTag:s,clearCookies:c,postMessage:l,on:h,off:m};return _},Er=[y,b,x,S,C,w,T,E,D,O,k,A,j,sr,cr,N,ee,dt,ft,pt,Ct,wt],Dr=Qn.map(e=>e.id),Or={interaction:`act.click`,storage:`read.text`,network:`network.fetchCredentialed`,evaluation:`media.appearU`},kr=e=>e===0?`auto`:e===4?`critical`:`bundled`,Ar=Er,jr=/* @__PURE__ */ new Map;(()=>{jr=new Map(Ar.map(e=>[e.scope,e])),Object.fromEntries(jr),Ar.filter(e=>e.severity===4).map(e=>e.scope);let e=e=>Ar.filter(t=>t.category===e&&kr(t.severity)===`bundled`);Object.fromEntries(Dr.map(t=>[t,Math.max(0,...e(t).map(e=>e.severity))])),Object.fromEntries(Dr.map(t=>[t,e(t).some(e=>e.unsafe===!0)]))})();var Mr=e=>jr.get(e)?.category,Nr=e=>{let t=jr.get(e);return t&&kr(t.severity)},Pr=e=>{let t=jr.get(e);if(t)return kr(t.severity)===`critical`?t.scope:t.category},Fr=e=>Or[e],Ir=({category:e,key:t})=>{let n=t??(e&&Fr(e));return n!==void 0&&Mr(n)!==void 0?n:void 0},Lr=(e,t)=>{for(let{category:n,key:r}of t)if(Ir({category:n,key:r})===void 0)throw TypeError(r===void 0?n===void 0?`${e}: name a category or a permission key`:`${e}: unknown permission category "${n}"`:`${e}: unknown permission key "${r}"`)},Rr=e=>typeof e==`object`&&!!e,zr=typeof chrome<`u`&&!!chrome.runtime?.id,Br=e=>Rr(e)&&e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY===!0&&typeof e.frameId==`string`&&typeof e.document==`string`,Vr=/* @__PURE__ */ new WeakMap,Hr=/* @__PURE__ */ new WeakMap,Ur=/* @__PURE__ */ new WeakMap,Wr=/* @__PURE__ */ new Set;typeof window<`u`&&zr&&window.addEventListener(`message`,e=>{if(!Br(e.data))return;e.stopImmediatePropagation();let t=e.source;if(!t||typeof t!=`object`)return;let n=t,r=Vr.get(n),i=e.data.frameId,a=e.data.document;if(Vr.set(n,i),Hr.set(n,a),r)for(let e of Wr)e(r);let o=Ur.get(n);if(o){for(let e of[...o])(e.notDocument===void 0||e.notDocument!==a)&&(o.delete(e),e.resolve(i));o.size||Ur.delete(n)}},{capture:!0});var Gr=3e4,Kr=`frame.evaluate: the code did not settle within ${Gr}ms`,qr=()=>new Gt(Kr),Jr=e=>Jt(e)&&e.message===Kr?qr():e,Yr=[/^frame load timed out after \d+ms for /,/^frame goto: documentstart timed out$/,/^navigation to .+ did not commit a document within \d+ms$/s],Xr=e=>{if(e instanceof Gt)return e;let t=typeof e?.message==`string`?e.message:``;return Yr.some(e=>e.test(t))?new Gt(t):e},Zr=e=>{let t=e;if(t.window===void 0)return`iframe`;if(t.iframe!==void 0)throw TypeError(`attachFrame: pass either iframe or window, not both`);if(t.lockdown)throw TypeError(`attachFrame: lockdown applies to an iframe, never to a window`);if(t.blank!==void 0)throw TypeError(`attachFrame: blank does not apply to a window`);if(typeof t.window!=`object`||t.window===null)throw TypeError(`attachFrame: window must be an object`);return`window`},Qr=(e,t,n)=>{if(e===void 0)return t;if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw TypeError(`attachFrame: window.${n} must be a positive number of CSS pixels`);return Math.round(e)},$r=({url:e,width:t,height:n})=>{let r=(()=>{if(e===void 0||e===``||e===`about:blank`)return``;if(typeof e!=`string`)throw TypeError(`attachFrame: window.url must be a string`);let t=(()=>{try{return new URL(e,location.href)}catch{throw TypeError(`attachFrame: window.url is not a valid URL: ${e}`)}})();if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`attachFrame: window.url must be an http or https address`);return t.href})();return r&&ar(r),{url:r,width:Qr(t,500,`width`),height:Qr(n,700,`height`)}},ei=`attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'`,ti=1e11,ni=[`name`,`value`,`domain`,`path`,`expires`,`httpOnly`,`secure`,`sameSite`],ri=[`Strict`,`Lax`,`None`],ii=/[;\x00-\x1f\x7f]/,H=(e,t)=>/* @__PURE__ */ TypeError(`attachFrame: storageState${e} ${t}`),ai=e=>Object.prototype.toString.call(e)===`[object Object]`,oi=e=>{let t=e.startsWith(`.`)?e.slice(1):e;if(t===``)return null;try{return new URL(`http://${t}/`).hostname===t.toLowerCase()?t.toLowerCase():null}catch{return null}},si=(e,t)=>{if(!ai(e))throw H(t,`must be an object`);let n=Object.keys(e).find(e=>!ni.includes(e));if(n!==void 0)throw H(`${t}.${n}`,`is not a cookie field`);let{name:r,value:i,domain:a,path:o,expires:s,httpOnly:c,secure:l,sameSite:u}=e;if(typeof r!=`string`||r===``||r.includes(`=`)||ii.test(r))throw H(`${t}.name`,`must be a non-empty string with no "=", ";" or control character`);if(typeof i!=`string`||ii.test(i))throw H(`${t}.value`,`must be a string with no ";" or control character`);if(typeof a!=`string`||oi(a)===null)throw H(`${t}.domain`,`must be a host: ".youtube.com" for a cookie its subdomains also receive, "www.youtube.com" for a host-only one`);if(o!==void 0&&(typeof o!=`string`||!o.startsWith(`/`)||ii.test(o)))throw H(`${t}.path`,`must be a string starting with "/"`);if(s!==void 0&&(typeof s!=`number`||!Number.isFinite(s)||s<=0&&s!==-1))throw H(`${t}.expires`,`must be -1 for a session cookie, or milliseconds since the epoch`);if(c!==void 0&&typeof c!=`boolean`)throw H(`${t}.httpOnly`,`must be a boolean`);if(l!==void 0&&typeof l!=`boolean`)throw H(`${t}.secure`,`must be a boolean`);if(u!==void 0&&!ri.includes(u))throw H(`${t}.sameSite`,`must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);let d=r.toLowerCase();if(u===`None`&&l!==!0)throw H(t,`is SameSite=None, which needs secure: true`);if(d.startsWith(`__secure-`)&&l!==!0)throw H(t,`is a __Secure- cookie, which needs secure: true`);if(d.startsWith(`__host-`)&&(l!==!0||a.startsWith(`.`)||(o??`/`)!==`/`))throw H(t,`is a __Host- cookie, which needs secure: true, a host-only domain and path "/"`);let f={name:r,value:i,domain:a};return o!==void 0&&(f.path=o),s!==void 0&&(f.expires=s),c!==void 0&&(f.httpOnly=c),l!==void 0&&(f.secure=l),u!==void 0&&(f.sameSite=u),f},ci=(e,t)=>{if(!ai(e))throw H(t,`must be an object { origin, localStorage }`);let n=Object.keys(e).find(e=>e!==`origin`&&e!==`localStorage`);if(n!==void 0)throw H(`${t}.${n}`,`is not an origin field`);let{origin:r,localStorage:i}=e,a=(()=>{try{return typeof r==`string`?new URL(r):null}catch{return null}})();if(a===null||a.protocol!==`http:`&&a.protocol!==`https:`||a.origin!==r)throw H(`${t}.origin`,`must be an absolute http or https origin, not ${JSON.stringify(r)}`);if(!Array.isArray(i))throw H(`${t}.localStorage`,`must be an array`);return{origin:r,localStorage:i.map((e,n)=>{let{name:r,value:i}=ai(e)&&Object.keys(e).every(e=>e===`name`||e===`value`)?e:{};if(typeof r!=`string`||typeof i!=`string`)throw H(`${t}.localStorage[${n}]`,`must be { name, value } strings`);return{name:r,value:i}})}},li=e=>{if(!ai(e))throw H(``,`must be an object { cookies?, origins? }`);let t=Object.keys(e).find(e=>e!==`cookies`&&e!==`origins`);if(t!==void 0)throw H(`.${t}`,`is not a storageState key; it takes cookies and origins`);let{cookies:n=[],origins:r=[]}=e;if(!Array.isArray(n))throw H(`.cookies`,`must be an array`);if(!Array.isArray(r))throw H(`.origins`,`must be an array`);let i=n.map((e,t)=>si(e,`.cookies[${t}]`)),a=r.map((e,t)=>ci(e,`.origins[${t}]`));return i.forEach(({expires:e},t)=>{if(e!==void 0&&e>0&&e<ti)throw H(`.cookies[${t}].expires`,`is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`)}),{cookies:i,origins:a}},ui=[`persistent`,`ephemeral`,`native`],di=`attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'`,fi=e=>{if(`syncCookies`in e)throw TypeError(di);let{cookies:t=`persistent`}=e;if(!ui.includes(t))throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);if(e.storageState!==void 0&&t!==`ephemeral`)throw TypeError(ei);let n=e.storageState===void 0?void 0:li(e.storageState),r=Zr(e);if(r===`iframe`&&e.lockdown&&t!==`native`)throw TypeError(`attachFrame: lockdown runs on the extension, which serves only cookies: 'native'`);if(Array.isArray(e.permissions))for(let t of e.permissions)ut(`attachFrame`,t?.reason);return n===void 0?{kind:r,cookies:t}:{kind:r,cookies:t,storageState:n}},pi=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,mi=!1,hi=()=>{mi||(mi=!0,console.warn(`[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this.`))},gi=`frame: this frame no longer holds the document the app attached it to`,_i=`frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin`,vi=()=>{let e=Ze();if(e.status===`ok`&&e.abi>=1)return;let t=e.status===`absent`?0:e.abi;throw new qe(`lockdown`,t,`attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`)},yi=e=>{try{return new URL(e,location.href).hostname}catch{return``}},bi=()=>{let e=Ze();return e.status===`absent`?0:e.abi},xi=`attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame`,Si=`frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame`,Ci=`click: isTrusted is served by the cloud render proxy only; attach with cloud.attachFrame`,wi=`frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar`,Ti=({executeLocator:e,highlightLocator:t,ensureLocatorPermission:n,requestCategories:r,evaluateFrame:i,goto:a},{hosts:o,url:s,page:c,unreachable:l,documents:u,navigated:d})=>{let f=new Set(R(o,{ipv6:!0})),p=e=>f.has(R([xt(e)],{ipv6:!0})[0]??``);return Tr({backend:`extension`,executor:{execute:e,highlight:t},gate:e=>{if(e.operation===`click`&&zn(e.args)?.isTrusted===!0)throw new qe(`click`,bi(),Ci);return n(e.parts,e.operation,e.args)},requestPermissions:async e=>(Lr(`frame.requestPermissions`,e),await Yn(),r(e)),evaluate:async(e,t)=>{if(!Ge(Ze(),`evaluate`)){let e=Ze();throw new qe(`evaluate`,e.status===`ok`?e.abi:0)}return i({source:e,arg:t}).catch(e=>{throw Jr(e)})},addScriptTag:async()=>{throw new qe(`addScriptTag`,bi(),Si)},clearCookies:async()=>{throw new qe(`clearCookies`,bi(),wi)},postMessage:(e,t,n)=>{if(t===`*`)throw Ht(_i,`postMessage`,`extension`);if(!p(t))throw V(gi,`postMessage`);let r=l();if(r)throw r;return c().postMessage(e,t,n),Promise.resolve()},listen:e=>{let t=t=>{t.source!==null&&t.source===c()&&!Br(t.data)&&p(t.origin)&&e({type:`message`,data:t.data,origin:t.origin,ports:t.ports})};window.addEventListener(`message`,t);let n=u(()=>e({type:`document`,origin:``}));return()=>{window.removeEventListener(`message`,t),n()}},goto:(e,{waitUntil:t,timeout:n,...r}={})=>{St(`frame.goto`,[yi(e),...r.domains??[]]);for(let t of R([yi(e)],{ipv6:!0}))f.add(t);return d?.(e),a({url:e,...r,...t===void 0?{}:{waitUntil:t===`commit`?`documentstart`:t},...n===void 0?{}:{timeoutMs:n}}).catch(e=>{throw Xr(e)})},url:s})},Ei=async({iframe:e,domains:t=[],lockdown:n=!1,permissions:r,blank:i})=>{if(i!==void 0)throw new qe(`blank`,bi(),xi);let a=crypto.randomUUID();if(ar(e.src),or({src:e.src,domains:t,lockdown:n}),St(`attachFrame`,t),await et(),n&&vi(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(pi,{detail:a}));let o=Ti(await nt.attachFrame({marker:a,domains:t,syncCookies:!0,lockdown:n}),{hosts:[...t,yi(e.src)],url:()=>e.src,page:()=>e.contentWindow,unreachable:()=>e.contentWindow===null?V(`frame: navigate the frame before postMessage`,`postMessage`):void 0,documents:t=>(e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t))});return r?.length&&(Jn()?await o.requestPermissions(r):hi()),o},Di=`attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page`,Oi=`frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it`,ki=`extension.attachFrame: the attached window closed; attach a fresh window`,Ai=e=>`attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`,ji=async e=>{let{domains:t=[],permissions:n}=e,{url:r,width:i,height:a}=$r(e.window);St(`attachFrame`,t);let o=Ze();if(!Ge(o,`attachWindow`))throw o.status===`absent`?new qe(`attachWindow`,0,Di):new qe(`attachWindow`,o.abi);let s=window.open(r||`about:blank`,`_blank`,`popup,width=${i},height=${a}`);if(!s)throw new dr;let c;try{c=await nt.attachWindow({url:r,domains:t})}catch(e){try{s.close()}catch{}throw e}let l=new Promise(e=>window.addEventListener(`pagehide`,()=>e(),{once:!0})),u=!1,d=Promise.race([c.closed,l]).then(()=>{u=!0},()=>{u=!0}),f=r,p=Ti(c,{hosts:r?[...t,yi(r)]:t,url:()=>f,page:()=>s,unreachable:()=>u?Ht(ki,`postMessage`,`extension`):s.closed?V(Oi,`postMessage`):void 0,documents:e=>{let t=!0;return(async()=>{let n=await c.documentsAfter(-1);for(;t;){let r=await c.documentsAfter(n);for(;t&&n<r;n++)e()}})().catch(()=>{}),()=>{t=!1}},navigated:e=>{try{f=new URL(e,location.href).href}catch{}}}),m,h=()=>m??=c.close().then(()=>d,()=>{}).then(()=>{u=!0;try{s.close()}catch{}}),g=Object.assign(p,{close:h,closed:d});try{n?.length&&await g.requestPermissions(n)}catch(e){throw await h(),e}return g},Mi=(async e=>{let{kind:t,cookies:n}=fi(e);if(n!==`native`)throw new qe(`cookies`,bi(),Ai(n));return t===`window`?ji(e):Ei(e)}),Ni=`PermissionDeniedError`,Pi=e=>e instanceof Error?e.name===Ni:Rr(e)&&e.name===`PermissionDeniedError`,Fi=/* @__PURE__ */ `fkn.app,fkn.dev,sdbx.app,horionsoftware.com,webvpn.dev,fknmail.app,clairv.app,fkn.cloudflareaccess.com,me-62e.workers.dev,62e9d4fbf21d90ebd4342e54b4babbd3.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.eu.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.fedramp.r2.cloudflarestorage.com,pub-8a3dc68041874c7e9c9a54bde972605a.r2.dev,pub-26b534eb9aa04cffbe1cdbb3be3fb1d2.r2.dev,pub-3d97d79220b94243812e60b0e742f2c5.r2.dev,pub-f8bd4876cc3c4b4a951715da5958e49c.r2.dev,web-b3z.pages.dev,fkn-console.pages.dev,dev-dms.pages.dev,fkn-www.pages.dev,fkn-homepage.pages.dev,fkn-sandbox.pages.dev,internal-3ar.pages.dev,stub-ben.pages.dev,ripple-3t3.pages.dev,media-player-e3s.pages.dev,youtube-3c4.pages.dev,horionsoftware.pages.dev,container-ckf.pages.dev,stub-plugin.pages.dev,social-3n2.pages.dev,plugins.banou.dev`.split(`,`),Ii=e=>e.toLowerCase().replace(/\.+$/,``),Li=[`79.127.204.69`,`152.233.49.59`],Ri=e=>{let t;try{t=new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}/`).hostname}catch{return}let n=/^\[(?:::ffff:|64:ff9b::)([0-9a-f]{1,4}):([0-9a-f]{1,4})\]$/.exec(t);if(n){let e=parseInt(n[1],16),t=parseInt(n[2],16);return[e>>8,e&255,t>>8,t&255].join(`.`)}return/^\d+\.\d+\.\d+\.\d+$/.test(t)?t:void 0},zi=e=>{let t=Ii(e);return Fi.some(e=>t===e||t.endsWith(`.${e}`))},Bi=e=>{if(zi(e))return!0;let t=Ri(Ii(e));return t!==void 0&&Li.includes(t)},Vi=e=>{let t=typeof e==`string`?e:e instanceof URL?e.href:e.url,n;try{n=new URL(t)}catch{return}if(Bi(n.hostname))throw Error(`fetch refuses FKN platform domains (${n.hostname})`)},Hi=/* @__PURE__ */ `autoplay.fullscreen.picture-in-picture.encrypted-media.screen-wake-lock.speaker-selection.captured-surface-control.camera.microphone.display-capture.geolocation.midi.usb.serial.hid.bluetooth.gamepad.keyboard-map.xr-spatial-tracking.accelerometer.gyroscope.magnetometer.ambient-light-sensor.compute-pressure.clipboard-read.clipboard-write.storage-access.window-management.local-fonts.idle-detection.web-share.sync-xhr.unload.payment.publickey-credentials-get.publickey-credentials-create.otp-credentials.identity-credentials-get.digital-credentials-get.local-network.local-network-access.loopback-network`.split(`.`),Ui=()=>{try{let e=globalThis.document?.featurePolicy?.features?.();return e===void 0?void 0:new Set(e)}catch{return}},Wi=(e=!0,t=Ui())=>[...Hi,...e?[`cross-origin-isolated`]:[]].filter(e=>t===void 0||t.has(e)).join(`; `),Gi=`https://fkn.app`,Ki=e=>`${Gi}/api${e?`?coi=1`:``}`;`${JSON.stringify(Hi)}${JSON.stringify(Ki(!0))}${JSON.stringify(Ki(!1))}`;var qi=((e,t,n,r)=>{if(r?.signal?.aborted)return()=>{};let i=()=>e.addEventListener(t,n,r);i();let a=typeof MutationObserver>`u`?void 0:new MutationObserver(i);return a?.observe(e.window===e?e.document:e,{childList:!0}),r?.signal?.addEventListener(`abort`,()=>a?.disconnect(),{once:!0}),()=>{a?.disconnect(),e.removeEventListener(t,n,r)}}),Ji=typeof window<`u`||typeof self<`u`,Yi=1e4,Xi=16,Zi=e=>{let t;try{t=e.contentWindow}catch{return!0}if(!t)return!0;try{let e=t.location.href;return e!==``&&e!==`about:blank`}catch{return!0}},Qi=(e,t=Yi)=>new Promise(n=>{if(Zi(e))return n();let r=()=>{clearInterval(i),clearTimeout(a),e.removeEventListener(`load`,r),n()},i=setInterval(()=>{Zi(e)&&r()},Xi),a=setTimeout(r,t);e.addEventListener(`load`,r)}),$i=5e3,ea=9e4,ta=(e,t,n)=>{let r=1,i,a=e.ownerDocument.defaultView,o=()=>{clearTimeout(i),u?.(),e.removeEventListener(`load`,l)},s=()=>{if(e.isConnected){if(r>=4)return o(),console.error(`FKN @fkn/lib: ${t} did not load in ${r} tries; reload the page`);r+=1,e.contentWindow?.location.replace(t),c(ea)}},c=e=>{clearTimeout(i),i=setTimeout(s,e)},l=()=>c($i),u=a?qi(a,`message`,t=>{t.source===e.contentWindow&&t.origin===n&&o()}):void 0;if(e.addEventListener(`load`,l),Zi(e))return c($i);i=setTimeout(()=>Zi(e)?c(8e4):s(),Yi)},na=(e,t)=>({receive:n=>qi(e.ownerDocument.defaultView,`message`,e=>{e.origin===t&&n(e.data,{source:e.source,origin:t})}),emit:(n,r)=>e.contentWindow?.postMessage(n,t,r)}),ra=32,ia=8,aa=120,oa=typeof CSS<`u`&&CSS.supports(`clip-path`,`path('M0 0H1V1H0Z')`),sa=typeof CSS<`u`&&CSS.supports(`clip-path`,`polygon(nonzero, 0px 0px, 1px 0px, 1px 1px)`),ca=`light dark`,la=e=>{let t=e.style;t.setProperty(`display`,`block`,`important`),t.setProperty(`position`,`fixed`,`important`),t.setProperty(`top`,`0`,`important`),t.setProperty(`left`,`0`,`important`),t.setProperty(`width`,`100%`,`important`),t.setProperty(`height`,`100%`,`important`),t.setProperty(`border`,`none`,`important`),t.setProperty(`padding`,`0`,`important`),t.setProperty(`box-sizing`,`border-box`,`important`),t.setProperty(`clip-path`,`inset(100%)`,`important`),t.setProperty(`background`,`transparent`),t.setProperty(`color-scheme`,ca),t.setProperty(`z-index`,`2147483647`),e.setAttribute(`title`,`FKN`)},ua=({x:e,y:t,width:n,height:r,radius:i})=>{if(!i)return`M${e} ${t}h${n}v${r}h${-n}Z`;let a=Math.min(n,r)/2,[o,s,c,l]=i.map(e=>Math.max(0,Math.min(e,a)));return`M${e+o} ${t}h${n-o-s}a${s} ${s} 0 0 1 ${s} ${s}v${r-s-c}a${c} ${c} 0 0 1 ${-c} ${c}h${-(n-c-l)}a${l} ${l} 0 0 1 ${-l} ${-l}v${-(r-l-o)}a${o} ${o} 0 0 1 ${o} ${-o}Z`},da=()=>oa&&sa,fa=({x:e,y:t,width:n,height:r})=>[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],pa=e=>{let t=e[0];if(!t)return[];let n=fa(t)[0],r=[];return e.forEach((t,i)=>{r.push(...fa(t)),i>0&&i<e.length-1&&r.push(n)}),r},ma=e=>`polygon(nonzero, ${pa(e).map(([e,t])=>`${e}px ${t}px`).join(`, `)})`,ha=({x:e,y:t,width:n,height:r,radius:i},a)=>{let o=`${t}px ${a.width-e-n}px ${a.height-t-r}px ${e}px`;return i?`inset(${o} round ${i.map(e=>`${e}px`).join(` `)})`:`inset(${o})`},ga=(e,t,n)=>{if(t)return`none`;if(e.length===0)return`inset(100%)`;let r=e.length===1?e[0]:void 0;return r?ha(r,n):sa&&e.length<=5&&!e.some(e=>e.radius)?ma(e):`path('${e.map(ua).join(``)}')`},_a=e=>{if(e.length<2)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}},va=(e,t,n)=>t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height,ya=16,ba=(e,t,n)=>t===1?e*ya:t===2?e*n:e,xa=(e,t,n,r,i)=>{let a=t?r:0,o=n?i:0;return a||o?{target:e,left:a,top:o}:null},Sa=(e,t,n)=>{let r=document.documentElement,i=getComputedStyle(r),a=i.overflowX===`visible`&&i.overflowY===`visible`&&document.body?document.body:r;for(let r of e){if(r===a)break;if(!(r instanceof Element))continue;let e=getComputedStyle(r),i=xa(r,/auto|scroll/.test(e.overflowX)&&r.scrollWidth>r.clientWidth,/auto|scroll/.test(e.overflowY)&&r.scrollHeight>r.clientHeight,t,n);if(i)return i;if(e.position===`fixed`&&!r.offsetParent)break}let o=document.scrollingElement,s=a===r?i:getComputedStyle(a);return o&&xa(o,!/hidden|clip/.test(s.overflowX),!/hidden|clip/.test(s.overflowY),t,n)},Ca=null,wa=null,Ta=e=>({width:e.offsetWidth||window.innerWidth,height:e.offsetHeight||window.innerHeight}),Ea=e=>{if(!wa||!Ca||!va(wa,e.clientX,e.clientY))return;let t=document.fullscreenElement;if(t&&!t.contains(Ca))return;let n=e.composedPath(),r=n.find(e=>e instanceof Element&&e.matches(`:is(:modal, :popover-open)`));if(r&&!r.contains(Ca))return;let i=Sa(n,ba(e.deltaX,e.deltaMode,window.innerWidth),ba(e.deltaY,e.deltaMode,window.innerHeight));i&&(i.target.scrollBy({left:i.left,top:i.top,behavior:`instant`}),e.cancelable&&e.preventDefault())},Da,Oa=e=>{wa=e,e?Da??=qi(window,`wheel`,Ea,{capture:!0,passive:!1}):(Da?.(),Da=void 0)},ka=0,Aa=null,ja=e=>{let t=document.documentElement;if(!t||e===ka&&(e===0||t===Aa))return;ka=e,Aa=t;let n=t.style;e>0?(n.setProperty(`margin-top`,`${e}px`,`important`),n.setProperty(`--fkn-inset-top`,`${e}px`)):(n.removeProperty(`margin-top`),n.removeProperty(`--fkn-inset-top`))},Ma=(e,t)=>{t?(e.removeAttribute(`tabindex`),e.removeAttribute(`aria-hidden`)):(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-hidden`,`true`))},Na=(e,{modal:t,rects:n,inset:r},i)=>{if(ja(r),!oa){let r=t||n.length>0;Ma(e,r),e.style.setProperty(`pointer-events`,r?`auto`:`none`,`important`),e.style.setProperty(`visibility`,r?`visible`:`hidden`,`important`);return}let a=ga(n,t,i),o=a===`none`||CSS.supports(`clip-path`,a)?a:`inset(100%)`;e.style.setProperty(`clip-path`,o,`important`),Ma(e,o!==`inset(100%)`),Oa(t||o!==a?null:_a(n))},Pa=e=>{if(typeof e!=`object`||!e)return 0;let{top:t}=e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?0:Math.min(Math.round(t),aa)},Fa=e=>{if(Array.isArray(e)&&e.length===4&&e.every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))return e.some(e=>e>0)?e:void 0},Ia=(e,t)=>{if(typeof e!=`object`||!e)return null;let{x:n,y:r,width:i,height:a}=e;if(![n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let o=t.width,s=t.height,c=Math.max(0,Math.min(Math.round(n),o)),l=Math.max(0,Math.min(Math.round(r),s)),u=Math.max(c,Math.min(Math.round(n+i),o)),d=Math.max(l,Math.min(Math.round(r+a),s)),f=Fa(e.radius);return{x:c,y:l,width:u-c,height:d-l,...f?{radius:f}:{}}},La={"not-rendered":`this page is not painting it at all, so it or an ancestor is display:none, or the frame was moved out of the layout`,clipped:`it is clipped away or positioned outside the viewport`,"not-shown":`it is rendered but would not be seen, so either something is drawn over it, or it or an ancestor has opacity below 1, visibility:hidden, or a filter`},Ra=e=>Array.isArray(e)?e.slice(0,ia).flatMap(e=>{if(typeof e!=`object`||!e)return[];let{kind:t,cause:n,level:r}=e;return typeof t!=`string`||t.length>40||typeof n!=`string`||!(n in La)||r!==`full`&&r!==`liveness`?[]:[{kind:t,cause:n,level:r}]}):[],za=/* @__PURE__ */ new Set,Ba=e=>{for(let{kind:t,cause:n,level:r}of e)za.has(t)||(za.add(t),console.error(`[FKN] The FKN ${JSON.stringify(t)} is not visible on this page: ${La[n]}. Nobody using this page can see or answer it.
|
|
53
|
+
`);r=~i?e.length-i:r+e.length}(i),e=e.slice(i.length),t}function u(){let t=/^\s*/.exec(e);t&&l(t)}function d(e){e||=[];let t=f();for(;t;)e.push(t),t=f();return e}function f(){let t=i();if(e.charAt(0)!==`/`||e.charAt(1)!==`*`)return;let n=/^\/\*[^]*?\*\//.exec(e);return n?(l(n),t({type:z.comment,comment:n[0].slice(2,-2)})):o(`End of comment missing`)}function p(){let t=Ot(e,[`{`]);if(t===-1||t===0)return;let n=e.substring(0,t);return l([n]),((e,t)=>{let n=[],r=0;for(;r<e.length;){let i=Ot(e,t,r);if(i===-1)return n.push(e.substring(r)),n;n.push(e.substring(r,i)),r=i+1}return n})(B(n).replace(kt,``),[`,`]).map(e=>B(e))}function m(){let t=i(),n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/.exec(e);if(!n)return;l(n);let r=B(n[0]),a=/^:\s*/.exec(e);if(!a)return o(`property missing ':'`);l(a);let s=``,c=Ot(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=B(s).replace(kt,``));let u=t({type:z.declaration,property:r.replace(kt,``),value:s}),d=/^[;\s]*/.exec(e);return d&&l(d),u}function h(){let n=[];if(!s())return o(`missing '{'`);d(n);let r=m();for(;r;)n.push(r),d(n),r=m();for(;t?.silent&&e.length&&e.charAt(0)!==`}`;){let t=e.indexOf(`;`),i=e.indexOf(`}`);if(t===-1||!(i===-1||t<i))break;for(l([e.substring(0,t+1)]),u(),d(n),r=m();r;)n.push(r),d(n),r=m()}return c()?n:o(`missing '}'`)}function g(){let t=Ot(e,[`{`]);if(t===-1)return!1;let n=Ot(e,[`;`]),r=Ot(e,[`}`]);return!(n!==-1&&n<t)&&!(r!==-1&&r<t)}function _(){let n=[];if(!s())return o(`missing '{'`);for(d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return c()?n:o(`missing '}'`)}function v(){let n=[];for(u(),d(n);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){n.push(e),d(n);continue}}if(g()){let e=E();if(e){n.push(e),d(n);continue}}let r=m();if(!r){if(t?.silent){let t=e.indexOf(`;`),r=e.indexOf(`}`);if(t!==-1&&(r===-1||t<r)){l([e.substring(0,t+1)]),u(),d(n);continue}}break}n.push(r),d(n)}return n}function y(){let t=[],n=i(),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e);for(;r;){let n=l(r);t.push(n[1]);let i=/^,\s*/.exec(e);i&&l(i),r=/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/.exec(e)}if(t.length)return n({type:z.keyframe,values:t,declarations:h()||[]})}let b=/* @__PURE__ */ RegExp(`^@(top-left-corner|top-left|top-center|top-right|top-right-corner|bottom-left-corner|bottom-left|bottom-center|bottom-right|bottom-right-corner|left-top|left-middle|left-bottom|right-top|right-middle|right-bottom)(?![\\w-])\\s*`),x=w(`import`),S=w(`charset`),C=w(`namespace`);function w(t){let n=RegExp(`^@`+t+`\\s*((?::?[^;'"]|"(?:\\\\"|[^"])*?"|'(?:\\\\'|[^'])*?')+)(?:;|$)`);return()=>{let r=i(),a=n.exec(e);if(!a)return;let o=l(a),s={type:t};return s[t]=o[1].trim(),r(s)}}function T(){if(e[0]===`@`)return function(){let t=i(),n=/^@([-\w]+)?keyframes\s*/.exec(e);if(!n)return;let r=l(n)[1],a=/^([-\w]+)\s*/.exec(e);if(!a)return o(`@keyframes missing name`);let u=l(a)[1];if(!s())return o(`@keyframes missing '{'`);let f=d(),p=y();for(;p;)f.push(p),f=f.concat(d()),p=y();return c()?t({type:z.keyframes,name:u,vendor:r,keyframes:f}):o(`@keyframes missing '}'`)}()||function(){let t=i(),n=/^@media *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@media missing '{'`);let a=v();return c()?t({type:z.media,media:r,rules:a}):o(`@media missing '}'`)}()||function(){let t=i(),n=/^@custom-media\s+(--\S+)\s+([^{;\s][^{;]*);/.exec(e);if(!n)return;let r=l(n);return t({type:z.customMedia,name:B(r[1]),media:B(r[2])})}()||function(){let t=i(),n=/^@supports *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@supports missing '{'`);let a=v();return c()?t({type:z.supports,supports:r,rules:a}):o(`@supports missing '}'`)}()||x()||S()||C()||function(){let t=i(),n=/^@([-\w]+)?document *([^{]+)/.exec(e);if(!n)return;let r=l(n),a=B(r[1]),u=B(r[2]);if(!s())return o(`@document missing '{'`);let d=v();return c()?t({type:z.document,document:u,vendor:a,rules:d}):o(`@document missing '}'`)}()||function(){let t=i(),n=/^@page */.exec(e);if(!n)return;l(n);let r=p()||[];if(!s())return o(`@page missing '{'`);let a=[];for(d(a);e.length&&e.charAt(0)!==`}`;){if(e.charAt(0)===`@`){let e=T();if(e){a.push(e),d(a);continue}}let t=m();if(!t)break;a.push(t),d(a)}return c()?t({type:z.page,selectors:r,declarations:a}):o(`@page missing '}'`)}()||function(){let t=i(),n=/^@host\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@host missing '{'`);let r=v();return c()?t({type:z.host,rules:r}):o(`@host missing '}'`)}()||function(){let t=i(),n=/^@font-face\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@font-face missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:z.fontFace,declarations:r}):o(`@font-face missing '}'`)}()||function(){let t=i(),n=/^@font-feature-values\s+([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@font-feature-values missing '{'`);let a=v();return c()?t({type:z.fontFeatureValues,fontFamily:r,rules:a}):o(`@font-feature-values missing '}'`)}()||function(){let t=i(),n=/^@container *([^{]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@container missing '{'`);let a=v();return c()?t({type:z.container,container:r,rules:a}):o(`@container missing '}'`)}()||function(){let t=i(),n=/^@starting-style\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@starting-style missing '{'`);let r=v();return c()?t({type:z.startingStyle,rules:r}):o(`@starting-style missing '}'`)}()||function(){let t=i(),n=/^@layer *([^{;@]+)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s()){let n=/^[;\s]*/.exec(e);return n&&l(n),t({type:z.layer,layer:r})}let a=v();return c()?t({type:z.layer,layer:r,rules:a}):o(`@layer missing '}'`)}()||function(){let t=i(),n=/^@property\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@property missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.property,name:r,declarations:a}):o(`@property missing '}'`)}()||function(){let t=i(),n=/^@counter-style\s+([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@counter-style missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.counterStyle,name:r,declarations:a}):o(`@counter-style missing '}'`)}()||function(){let t=i(),n=/^@scope\s*([^{]*)/.exec(e);if(!n)return;let r=B(l(n)[1]);if(!s())return o(`@scope missing '{'`);let a=v();return c()?t({type:z.scope,scope:r,rules:a}):o(`@scope missing '}'`)}()||function(){let t=i(),n=/^@view-transition\s*/.exec(e);if(!n)return;if(l(n),!s())return o(`@view-transition missing '{'`);let r=d(),a=m();for(;a;)r.push(a),r=r.concat(d()),a=m();return c()?t({type:z.viewTransition,declarations:r}):o(`@view-transition missing '}'`)}()||function(){let t=i(),n=/^@position-try\s+(--[-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@position-try missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.positionTry,name:r,declarations:a}):o(`@position-try missing '}'`)}()||function(){let t=i(),n=b.exec(e);if(!n)return;let r=l(n)[1];if(!s())return o(`@${r} missing '{'`);let a=d(),u=m();for(;u;)a.push(u),a=a.concat(d()),u=m();return c()?t({type:z.pageMarginBox,name:r,declarations:a}):o(`@${r} missing '}'`)}()||function(){let t=i(),n=/^@([-\w]+)\s*/.exec(e);if(!n)return;let r=l(n)[1],a=``,u=Ot(e,[`{`,`;`]);if(u!==-1&&u>0&&(a=B(e.substring(0,u)),l([e.substring(0,u)])),s()){let e=v();return c()?t({type:z.atRule,name:r,prelude:a,rules:e}):o(`@${r} missing '}'`)}let d=/^[;\s]*/.exec(e);return d&&l(d),t({type:z.atRule,name:r,prelude:a})}()}function E(){let e=i(),t=p();return t?(d(),e({type:z.rule,selectors:t,declarations:_()||[]})):o(`selector missing`)}return At(function(){let n=function(){let n,r=[];for(u(),d(r);e.length;){if(e.charAt(0)===`}`){if(t?.silent){o(`extra '}'`),l([`}`]),u(),d(r);continue}break}if(n=T()||E(),!n){if(t?.silent){l([e.charAt(0)]),u(),d(r);continue}break}r.push(n),d(r)}return r}();return{type:z.stylesheet,stylesheet:{source:t?.source,rules:n,parsingErrors:a}}}())},Nt=(e,t)=>new jt(t||{}).compile(e),Pt=Object.defineProperty,Ft=(e,t)=>{let n={};for(var r in e)Pt(n,r,{get:e[r],enumerable:!0});return t||Pt(n,Symbol.toStringTag,{value:`Module`}),n},It=`LocatorError`,Lt=`LocatorUnsupportedError`,Rt=`LocatorDeniedError`,zt=`LocatorInvalidError`,Bt=e=>typeof e==`object`&&e?e.name:void 0,Vt=e=>Object.assign(Error(e),{name:It}),Ht=(e,t=``,n)=>Object.assign(Error(e),{name:Lt,operation:t,backend:n}),Ut=(e,t)=>Ht(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),V=(e,t)=>Object.assign(Error(e),{name:Rt,operation:t}),Wt=(e,t)=>Object.assign(Error(e),{name:zt,operation:t}),Gt=class extends Error{name=`TimeoutError`;constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause})}},Kt=e=>Bt(e)===Lt,qt=e=>Bt(e)===Rt,Jt=e=>Bt(e)===zt,Yt=e=>qt(e)||Kt(e)||Jt(e),Xt=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw Vt(`the resolved element belongs to a document with no window`);return t},Zt=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},Qt=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return Zt(Xt(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=Zt(globalThis,t);return r&&e instanceof r?r:null},$t=(e,t)=>Qt(e,t)!==null,en=e=>{if(e.length===0)throw Vt(`No elements found`);if(e.length>1)throw Vt(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},tn=(e,t)=>{if(!$t(e,t))throw Vt(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},nn=e=>e.tagName.toLowerCase(),rn=/* @__PURE__ */ new Set,an=e=>{rn.add(e)},on=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,sn=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),cn=e=>!on.test(sn(e.value)),ln=/* @__PURE__ */ new Set([z.import,z.fontFace,z.namespace,z.charset,z.document,z.comment]),un=e=>{if(ln.has(e.type))return null;if(e.type===z.declaration)return cn(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=dn(r))}return n},dn=e=>e.map(e=>un(e)).filter(e=>e!==null),fn=e=>{let t;try{t=Mt(e,{silent:!0})}catch{return``}return t.stylesheet.rules=dn(t.stylesheet.rules),Nt(t)},pn=(e,t)=>{let n=()=>{t.parentNode||(e.head??e.documentElement).appendChild(t)};if(n(),e.readyState===`complete`)return;let r=new MutationObserver(e=>{for(let r of e)for(let e of r.removedNodes)if(e===t||e.contains?.(t)){n();return}});r.observe(e.documentElement,{childList:!0,subtree:!0});let i=()=>r.disconnect(),a=e.defaultView;a?a.addEventListener(`load`,i,{once:!0}):setTimeout(i,3e4)},mn={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:fn(t.content);try{pn(e.document,n)}catch(e){console.error(e)}an(n)}},hn=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},gn={kind:`frame`,ensureArgs:e=>[void 0,e],resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw Wt(`fetch: url must be a string`,`fetch`);let r=Xt(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw Wt(`fetch: not a valid url: ${t}`,`fetch`)}let a=await r.fetch(i,{method:n.method??`GET`,headers:n.headers,body:n.body??null,redirect:n.redirect??`follow`,credentials:n.credentials??`include`});return{status:a.status,statusText:a.statusText,ok:a.ok,url:a.url,redirected:a.redirected,type:a.type,headers:hn(a.headers),body:await a.arrayBuffer()}}},_n=/* @__PURE__ */ Ft({click:()=>bn,clickAsInput:()=>xn,count:()=>kn,exists:()=>An,fill:()=>Tn,getAttribute:()=>Dn,hover:()=>Sn,isVisible:()=>On,textContent:()=>En}),vn=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},yn=(e,t,n,r)=>{let i=en(e.elements),a=Xt(i),o={bubbles:!0,cancelable:!0,composed:!0,...vn(i,t.position),button:0},s={...o,pointerType:`mouse`,pointerId:1,isPrimary:!0},c=n?{detail:1}:{},l=r(i,new a.PointerEvent(`pointerdown`,{...s,buttons:1}))||!n;l&&r(i,new a.MouseEvent(`mousedown`,{...o,...c,buttons:1})),r(i,new a.PointerEvent(`pointerup`,{...s,buttons:0})),l&&r(i,new a.MouseEvent(`mouseup`,{...o,...c,buttons:0})),r(i,n?new a.PointerEvent(`click`,{...s,...c,buttons:0}):new a.MouseEvent(`click`,{...o,buttons:0}))},bn={resolve:(e,t={})=>yn(e,t,!1,(e,t)=>e.dispatchEvent(t))},xn=(e,t={},n)=>yn(e,t,!0,n),Sn={resolve:(e,t={})=>{let n=en(e.elements),r=Xt(n),i={bubbles:!0,cancelable:!0,composed:!0,...vn(n,t.position)},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerover`,a)),n.dispatchEvent(new r.PointerEvent(`pointerenter`,{...a,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseenter`,{...i,bubbles:!1})),n.dispatchEvent(new r.MouseEvent(`mouseover`,i)),n.dispatchEvent(new r.PointerEvent(`pointermove`,a)),n.dispatchEvent(new r.MouseEvent(`mousemove`,i))}},Cn=(e,t)=>{e._valueTracker?.setValue(``);let n=(Qt(e,`HTMLTextAreaElement`)??Qt(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},wn=(e,t)=>{if(e.type!==`range`)return null;let n=Number(e.min||0),r=Number(e.max||100);if(!Number.isFinite(n)||!Number.isFinite(r)||r<=n)return null;let i=Number(t);if(!Number.isFinite(i))return null;let a=Math.max(0,Math.min(1,(i-n)/(r-n))),o=e.getBoundingClientRect(),s={bubbles:!0,cancelable:!0,composed:!0,clientX:o.left+o.width*a,clientY:o.top+o.height/2,button:0},c={...s,pointerType:`mouse`,pointerId:1,isPrimary:!0};return{pointerDown:{...c,buttons:1},pointerUp:{...c,buttons:0},mouseDown:{...s,buttons:1},mouseUp:{...s,buttons:0}}},Tn={resolve:(e,t,n={})=>{let r=en(e.elements),i=Xt(r),a=$t(r,`HTMLInputElement`);if(a||$t(r,`HTMLTextAreaElement`)){let e=r,n=a?wn(e,t):null;n&&(r.dispatchEvent(new i.PointerEvent(`pointerdown`,n.pointerDown)),r.dispatchEvent(new i.MouseEvent(`mousedown`,n.mouseDown))),Cn(e,t),r.dispatchEvent(new i.Event(`input`,{bubbles:!0})),n&&(r.dispatchEvent(new i.PointerEvent(`pointerup`,n.pointerUp)),r.dispatchEvent(new i.MouseEvent(`mouseup`,n.mouseUp))),r.dispatchEvent(new i.Event(`change`,{bubbles:!0}))}else if($t(r,`HTMLElement`)&&r.isContentEditable)r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));else throw Error(`fill: element <${nn(r)}> is not fillable`)}},En={resolve:(e,t={})=>en(e.elements).textContent},Dn={resolve:(e,t,n={})=>en(e.elements).getAttribute(t)},On={resolve:(e,t={})=>{let n=en(e.elements);if(!$t(n,`HTMLElement`))return!0;let r=Xt(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},kn={resolve:(e,t={})=>e.elements.length},An={resolve:(e,t={})=>e.elements.length>0},jn=(e,t)=>(e.topLevel?[e.document]:e.elements).flatMap(e=>[...e.querySelectorAll(t)]),Mn=e=>e.replaceAll(`"`,`\\"`),Nn={to:`element`,css:!0,resolve:(e,t)=>jn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},Pn={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>jn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},Fn={element:{selectors:{locator:Nn,frameLocator:Pn,getByRole:{to:`element`,resolve:(e,t)=>jn(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${Mn(e)}"]`:`[role]`})},getByText:{to:`element`,resolve:(e,t)=>e.elements.flatMap(e=>[e,...e.querySelectorAll(`*`)]).filter(e=>e.textContent?.includes(t)),render:e=>({fragment:typeof e==`string`?`:has-text("${Mn(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>jn(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${Mn(e)}"]`:`[data-testid]`})},first:{to:`element`,resolve:e=>e.elements.slice(0,1),render:()=>({fragment:`:first`})},nth:{to:`element`,resolve:(e,t)=>{let n=e.elements.at(t);return n?[n]:[]},render:e=>({fragment:typeof e==`number`?`:nth(${e})`:`:nth(?)`})}},operations:{click:bn,fill:Tn,hover:Sn,textContent:En,getAttribute:Dn,isVisible:On,count:kn,exists:An}},frame:{selectors:{locator:Nn,frameLocator:Pn,owner:{to:`frame`,barrier:`up`,resolve:e=>{throw Error(`owner: must be processed by the executor as an upward pivot`)},render:()=>({fragment:``,separator:`up`})}},operations:{addStyleTag:mn,fetch:gn}}},In=(e,t=Fn)=>({element:{selectors:{...t.element.selectors,...e.element?.selectors},operations:{...t.element.operations,...e.element?.operations}},frame:{selectors:{...t.frame.selectors,...e.frame?.selectors},operations:{...t.frame.operations,...e.frame?.operations}}}),Ln=3e4,Rn=50,zn=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},Bn=e=>{let t=zn(e)?.timeout;return typeof t==`number`?t:Ln},Vn=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),Hn=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,Vn(e))},Un=(e,t)=>{if(t!==void 0&&typeof t==`number`&&!(Number.isFinite(t)&&t>0))throw TypeError(`${e}: timeout must be a positive number of milliseconds, not ${t}; every call ends at its deadline, so 0 does not turn it off`)},Wn=e=>typeof e==`object`&&e&&typeof e.message==`string`?e.message:String(e),Gn=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;Un(i,zn(a)?.timeout),n&&await n({parts:r,operation:i,args:a,phase:`execute`},Vn(e));let o=Bn(a),s=Date.now()+o,c=/* @__PURE__ */ Error(`Locator timeout (${o}ms): ${i}`),{promise:l,reject:u}=Promise.withResolvers();l.catch(()=>{});let d=setTimeout(()=>u(c),o),f=c;try{do try{return await Promise.race([t.execute(r,i,a),l])}catch(e){if(e===c)break;if(Yt(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(Rn,t)))}while(Date.now()<s)}finally{clearTimeout(d)}throw f===c?new Gt(c.message):new Gt(Wn(f),{cause:f})},Kn=(e,t,n,r,i)=>{let a={};for(let[o,s]of Object.entries(t[r].selectors))a[o]=(...a)=>Kn(e,t,n,s.to,[...i,{kind:r,name:o,args:a}]);for(let[n,o]of Object.entries(t[r].operations))a[n]=async(...t)=>Gn({...e,parts:i,operation:n,args:o.send?o.send(...t):t});for(let[o,{to:s,rewrite:c}]of Object.entries(n[r]??{}))a[o]=(...r)=>Kn(e,t,n,s,c(i,...r));return a.ensure=(n,a={})=>{let o=t[r].operations[n]?.ensureArgs;return Hn({...e,parts:i,operation:n,args:o?.(a)??[a]})},a},qn=e=>Kn(e,e.modules??Fn,e.rewrites??{},`frame`,[]),Jn=()=>{let e=Ze();return e.status===`ok`&&e.abi>=2},Yn=async()=>{await et();let e=Ze();if(e.status===`ok`&&e.abi<2)throw new Ke(e.abi,2)},Xn=e=>`Read the text, links and details ${e} shows.`,Zn=e=>`Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`,Qn=[{id:`interaction`,heading:`Interaction`,summary:`Allow the app to interact with the website (clicks, type in text, etc.)`,title:e=>`Interact with ${e}`,description:(e,t)=>t?`Click, type and hover on ${e} for you. If you are signed in there, this happens as you.`:`Click, type and hover on ${e} for you, in a signed-out view.`,cloudTitle:e=>`Click and type on ${e}`,cloudDescription:e=>`Clicks, types and scrolls on ${e} for you.`},{id:`storage`,heading:`Site data`,summary:`Can read the website's data`,title:e=>`Read data from ${e}`,description:Xn,cloudTitle:e=>`Read what's on ${e}`,cloudDescription:Xn},{id:`network`,heading:`Network`,summary:`Make requests on behalf of the website (using your cookies, etc.)`,title:e=>`Make requests to ${e} as you`,description:e=>`Load pages and data from ${e} and send changes there with your signed-in session.`,cloudTitle:e=>`Load and send data on ${e}`,cloudDescription:e=>`Loads pages and data from ${e} and sends changes there.`},{id:`evaluation`,heading:`Evaluation`,summary:`Can execute arbitrary code on the website`,title:e=>`Run code on ${e}`,description:Zn,cloudTitle:e=>`Run its own code on ${e}`,cloudDescription:Zn}],$n=e=>t=>{if(typeof t!=`object`||!t)return t===void 0?[]:[t];if(t.position!==void 0)throw TypeError(`${e}: position is Playwright's offset in pixels, which no backend serves yet; pass relativePosition, a 0..1 fraction of the box`);let{relativePosition:n,...r}=t;return[n===void 0?r:{...r,position:n}]},er=async(e,t,n)=>{try{return await gn.resolve(e,t,n)}catch(e){throw Yt(e)?e:V(`frame.fetch: ${e instanceof Error?`${e.name}: ${e.message}`:String(e)}; not retried, since the request may already have been sent`,`fetch`)}},tr=In({element:{operations:{click:{resolve:(e,t={})=>_n.click.resolve(e,t),send:$n(`click`)},hover:{resolve:(e,t={})=>_n.hover.resolve(e,t),send:$n(`hover`)},fill:{resolve:(e,t,n={})=>_n.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>_n.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>_n.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>_n.isVisible.resolve(e)},count:{resolve:(e,t={})=>_n.count.resolve(e)},exists:{resolve:(e,t={})=>_n.exists.resolve(e)},videoElement:{resolve:(e,t={})=>De(tn(en(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>mn.resolve(e,t)},fetch:{resolve:(e,t,n={})=>er(e,t,n),kind:gn.kind,ensureArgs:gn.ensureArgs},evaluate:{kind:`frame`,typed:!1,resolve:(e,t,n)=>{throw Ut(`evaluate`,`this realm`)}}}}}),nr=e=>e[e.length-1],rr={element:{last:{to:`element`,rewrite:e=>[...e,{kind:`element`,name:`nth`,args:[-1]}]},contentFrame:{to:`frame`,rewrite:e=>{let t=nr(e);if(t?.name!==`locator`)throw TypeError(`locator.contentFrame: only a locator that ends in locator(selector) can enter its frame; use frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`frameLocator`}]}}},frame:{owner:{to:`element`,rewrite:e=>{let t=nr(e);if(t?.name!==`frameLocator`)throw TypeError(`frameLocator.owner: this frame was not entered through frameLocator(selector)`);return[...e.slice(0,-1),{...t,name:`locator`}]}},getByTestId:{to:`element`,rewrite:(e,t)=>[...e,{kind:`element`,name:`getByTestId`,args:[t]}]}}},ir=e=>{if(!e||e===`about:blank`)return!1;let t;try{t=new URL(e,location.href)}catch{return!1}return t.protocol===`chrome-extension:`||t.protocol===`moz-extension:`||t.protocol!==`about:`&&ct(t.hostname)},ar=e=>{if(ir(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},or=({src:e,domains:t,lockdown:n})=>{if(n&&!t.length&&e&&e!==`about:blank`)throw Error(`attachFrame: lockdown needs domains when the frame already has a src; pass domains or load it via goto`)},sr={scope:`embed.iframe`,category:`interaction`,severity:0,title:`Load another website inside this app`,description:`Lets the app embed external pages directly inside its own view.`},cr={scope:`embed.open`,category:`interaction`,severity:0,title:`Open a website inside this app`,description:`Lets the app navigate to another site without leaving its window.`},lr=[`load`,`commit`],ur=e=>{if(`timeoutMs`in e)throw TypeError(`frame.goto: pass timeout, in milliseconds; timeoutMs is not an option`);let{waitUntil:t,timeout:n}=e;if(t!==void 0&&!lr.includes(t))throw TypeError(`frame.goto: waitUntil must be 'load' or 'commit', not ${JSON.stringify(t)}`);if(n!==void 0&&typeof n!=`number`)throw TypeError(`frame.goto: timeout must be a number of milliseconds`);Un(`frame.goto`,n)},dr=class extends Error{name=`FrameWindowBlockedError`;constructor(){super(`attachFrame: the browser did not open the window. Call attachFrame directly in a click or key handler, and allow popups for this page`)}},fr=/* @__PURE__ */ new Set([`jar-unreachable`,`bad-url`,`opaque-opener`]),pr=class extends Error{name=`FrameWindowRefusedError`;reason;constructor(e){let t=fr.has(e)?e:`unknown`;super(t===`opaque-opener`?`attachFrame: this page has an opaque origin, which a window can never answer, so no window was opened`:`attachFrame: the window refused to attach (${t}), and loaded nothing`),this.reason=t}},mr=[`message`,`document`],hr=e=>{if(e===`*`)return`*`;let t=()=>/* @__PURE__ */ TypeError(`frame.postMessage: targetOrigin must be '*' or an origin, not ${JSON.stringify(e)}`);if(typeof e!=`string`)throw t();let n;try{n=new URL(e).origin}catch{throw t()}if(n===`null`)throw t();return n},gr=(e,t)=>{let n=typeof e==`object`&&!!e;if(n&&t!==void 0)throw TypeError(`frame.postMessage: pass transfer inside the options object, not after it`);let r=n?e.targetOrigin??`*`:e??`*`,i=n?e.transfer:t;if(i!==void 0&&!Array.isArray(i))throw TypeError(`frame.postMessage: transfer must be an array`);return{targetOrigin:hr(r),transfer:i===void 0?[]:[...i]}},_r=[`url`,`path`,`type`],vr=[`content`,`sourceUrl`],yr=/[\n\r\u2028\u2029]/,br=e=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`frame.addScriptTag: options must be an object { content }`);let t=Object.keys(e),n=t.find(e=>_r.includes(e));if(n!==void 0)throw TypeError(`frame.addScriptTag: "${n}" is not served; it runs content as a classic inline script`);let r=t.find(e=>!vr.includes(e));if(r!==void 0)throw TypeError(`frame.addScriptTag: unknown option "${r}"`);let{content:i,sourceUrl:a}=e;if(typeof i!=`string`)throw TypeError(`frame.addScriptTag: content must be a string`);if(a!==void 0&&(typeof a!=`string`||a===``||yr.test(a)))throw TypeError(`frame.addScriptTag: sourceUrl must be a non-empty string with no line break`);return a===void 0?{content:i}:{content:i,sourceUrl:a}},xr=[`name`,`domain`,`path`],Sr=e=>e instanceof RegExp||Object.prototype.toString.call(e)===`[object RegExp]`,Cr=e=>{if(e===void 0)return{};if(Object.prototype.toString.call(e)!==`[object Object]`)throw TypeError(`frame.clearCookies: options must be an object`);let t=e,n=Object.keys(t).find(e=>!xr.includes(e));if(n!==void 0)throw TypeError(`frame.clearCookies: unknown option "${n}"`);let r=xr.flatMap(e=>{let n=t[e];return n===void 0?[]:[{key:e,value:n}]}),i=r.find(({value:e})=>Sr(e));if(i!==void 0)throw TypeError(`frame.clearCookies: ${i.key} is a RegExp, and clearCookies takes strings for name, domain and path for now`);let a=r.find(({value:e})=>typeof e!=`string`);if(a!==void 0)throw TypeError(`frame.clearCookies: ${a.key} must be a string`);let o=r.find(({value:e})=>e===``);if(o!==void 0)throw TypeError(`frame.clearCookies: ${o.key} must not be empty; leave it out to match every ${o.key}`);let s={};for(let{key:e,value:t}of r)s[e]={equals:t};return s},wr=e=>{typeof globalThis.reportError==`function`?globalThis.reportError(e):console.error(e)},Tr=e=>{let{owner:t,...n}=qn({executor:e.executor,modules:tr,rewrites:rr,gate:async(t,n)=>{ut(t.operation,zn(t.args)?.reason),await e.gate?.(t,n)}}),r=async(t,n={})=>(ar(t),ur(n),e.goto(t,n)),i=()=>e.url(),a=async t=>{for(let e of t)ut(`frame.requestPermissions`,e?.reason);let n=e.requestPermissions;if(!n)throw Error(`frame.requestPermissions: this backend cannot ask for permission categories`);return n(t)},o=async(t,n)=>{let r=e.evaluate;if(!r)throw Error(`frame.evaluate: this backend cannot run code in the attached frame`);let i=typeof t==`function`?t.toString():t;if(typeof i!=`string`)throw TypeError(`frame.evaluate: pass a function or a source string`);return r(i,structuredClone(n))},s=async t=>{let{content:n,...r}=br(t),i=e.addScriptTag;if(!i)throw Error(`frame.addScriptTag: this backend cannot run scripts in the attached frame`);await i(n,r)},c=async t=>{let n=Cr(t),r=e.clearCookies;if(!r)throw Error(`frame.clearCookies: this backend cannot clear cookies`);await r(n)},l=((t,n,r)=>{try{let i=e.postMessage;if(!i)throw Error(`frame.postMessage: this backend cannot message the attached frame`);let a=gr(n,r);return i(t,a.targetOrigin,a.transfer)}catch(e){return Promise.reject(e)}}),u={message:/* @__PURE__ */ new Set,document:/* @__PURE__ */ new Set},d=null,f=(e,t)=>{if(!mr.includes(e))throw TypeError(`frame.${t}: the event type must be ${mr.map(e=>`'${e}'`).join(` or `)}, not ${JSON.stringify(e)}`);return u[e]},p=e=>{let t=e.type===`message`?Object.freeze({type:`message`,data:e.data,origin:e.origin,ports:Object.freeze([...e.ports]),source:_}):Object.freeze({type:`document`,origin:e.origin});for(let n of[...u[e.type]])try{n(t)}catch(e){wr(e)}},m=(e,t)=>{if(f(e,`off`).delete(t),d!==null&&!u.message.size&&!u.document.size){let e=d;d=null,e()}},h=(t,n,r={})=>{let i=f(t,`on`);if(typeof n!=`function`)throw TypeError(`frame.on: the listener must be a function`);let{signal:a}=r;if(!(a?.aborted||i.has(n))){if(d===null){let t=e.listen;if(!t)throw Error(`frame.on: this backend cannot relay the page's messages`);d=t(p)}i.add(n),a?.addEventListener(`abort`,()=>m(t,n),{once:!0})}},g=()=>e.backend,_={...n,goto:r,url:i,backend:g,requestPermissions:a,evaluate:o,addScriptTag:s,clearCookies:c,postMessage:l,on:h,off:m};return _},Er=[y,b,x,S,C,w,T,E,D,O,k,A,j,sr,cr,N,ee,dt,ft,pt,Ct,wt],Dr=Qn.map(e=>e.id),Or={interaction:`act.click`,storage:`read.text`,network:`network.fetchCredentialed`,evaluation:`media.appearU`},kr=e=>e===0?`auto`:e===4?`critical`:`bundled`,Ar=Er,jr=/* @__PURE__ */ new Map;(()=>{jr=new Map(Ar.map(e=>[e.scope,e])),Object.fromEntries(jr),Ar.filter(e=>e.severity===4).map(e=>e.scope);let e=e=>Ar.filter(t=>t.category===e&&kr(t.severity)===`bundled`);Object.fromEntries(Dr.map(t=>[t,Math.max(0,...e(t).map(e=>e.severity))])),Object.fromEntries(Dr.map(t=>[t,e(t).some(e=>e.unsafe===!0)]))})();var Mr=e=>jr.get(e)?.category,Nr=e=>{let t=jr.get(e);return t&&kr(t.severity)},Pr=e=>{let t=jr.get(e);if(t)return kr(t.severity)===`critical`?t.scope:t.category},Fr=e=>Or[e],Ir=({category:e,key:t})=>{let n=t??(e&&Fr(e));return n!==void 0&&Mr(n)!==void 0?n:void 0},Lr=(e,t)=>{for(let{category:n,key:r}of t)if(Ir({category:n,key:r})===void 0)throw TypeError(r===void 0?n===void 0?`${e}: name a category or a permission key`:`${e}: unknown permission category "${n}"`:`${e}: unknown permission key "${r}"`)},Rr=e=>typeof e==`object`&&!!e,zr=typeof chrome<`u`&&!!chrome.runtime?.id,Br=e=>Rr(e)&&e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY===!0&&typeof e.frameId==`string`&&typeof e.document==`string`,Vr=/* @__PURE__ */ new WeakMap,Hr=/* @__PURE__ */ new WeakMap,Ur=/* @__PURE__ */ new WeakMap,Wr=/* @__PURE__ */ new Set;typeof window<`u`&&zr&&window.addEventListener(`message`,e=>{if(!Br(e.data))return;e.stopImmediatePropagation();let t=e.source;if(!t||typeof t!=`object`)return;let n=t,r=Vr.get(n),i=e.data.frameId,a=e.data.document;if(Vr.set(n,i),Hr.set(n,a),r)for(let e of Wr)e(r);let o=Ur.get(n);if(o){for(let e of[...o])(e.notDocument===void 0||e.notDocument!==a)&&(o.delete(e),e.resolve(i));o.size||Ur.delete(n)}},{capture:!0});var Gr=3e4,Kr=`frame.evaluate: the code did not settle within ${Gr}ms`,qr=()=>new Gt(Kr),Jr=e=>Jt(e)&&e.message===Kr?qr():e,Yr=[/^frame load timed out after \d+ms for /,/^frame goto: documentstart timed out$/,/^navigation to .+ did not commit a document within \d+ms$/s],Xr=e=>{if(e instanceof Gt)return e;let t=typeof e?.message==`string`?e.message:``;return Yr.some(e=>e.test(t))?new Gt(t):e},Zr=e=>{let t=e;if(t.window===void 0)return`iframe`;if(t.iframe!==void 0)throw TypeError(`attachFrame: pass either iframe or window, not both`);if(t.lockdown)throw TypeError(`attachFrame: lockdown applies to an iframe, never to a window`);if(t.blank!==void 0)throw TypeError(`attachFrame: blank does not apply to a window`);if(typeof t.window!=`object`||t.window===null)throw TypeError(`attachFrame: window must be an object`);return`window`},Qr=(e,t,n)=>{if(e===void 0)return t;if(typeof e!=`number`||!Number.isFinite(e)||e<=0)throw TypeError(`attachFrame: window.${n} must be a positive number of CSS pixels`);return Math.round(e)},$r=({url:e,width:t,height:n})=>{let r=(()=>{if(e===void 0||e===``||e===`about:blank`)return``;if(typeof e!=`string`)throw TypeError(`attachFrame: window.url must be a string`);let t=(()=>{try{return new URL(e,location.href)}catch{throw TypeError(`attachFrame: window.url is not a valid URL: ${e}`)}})();if(t.protocol!==`http:`&&t.protocol!==`https:`)throw TypeError(`attachFrame: window.url must be an http or https address`);return t.href})();return r&&ar(r),{url:r,width:Qr(t,500,`width`),height:Qr(n,700,`height`)}},ei=`attachFrame: storageState seeds a fresh jar, so it needs cookies: 'ephemeral'`,ti=1e11,ni=[`name`,`value`,`domain`,`path`,`expires`,`httpOnly`,`secure`,`sameSite`],ri=[`Strict`,`Lax`,`None`],ii=/[;\x00-\x1f\x7f]/,H=(e,t)=>/* @__PURE__ */ TypeError(`attachFrame: storageState${e} ${t}`),ai=e=>Object.prototype.toString.call(e)===`[object Object]`,oi=e=>{let t=e.startsWith(`.`)?e.slice(1):e;if(t===``)return null;try{return new URL(`http://${t}/`).hostname===t.toLowerCase()?t.toLowerCase():null}catch{return null}},si=(e,t)=>{if(!ai(e))throw H(t,`must be an object`);let n=Object.keys(e).find(e=>!ni.includes(e));if(n!==void 0)throw H(`${t}.${n}`,`is not a cookie field`);let{name:r,value:i,domain:a,path:o,expires:s,httpOnly:c,secure:l,sameSite:u}=e;if(typeof r!=`string`||r===``||r.includes(`=`)||ii.test(r))throw H(`${t}.name`,`must be a non-empty string with no "=", ";" or control character`);if(typeof i!=`string`||ii.test(i))throw H(`${t}.value`,`must be a string with no ";" or control character`);if(typeof a!=`string`||oi(a)===null)throw H(`${t}.domain`,`must be a host: ".youtube.com" for a cookie its subdomains also receive, "www.youtube.com" for a host-only one`);if(o!==void 0&&(typeof o!=`string`||!o.startsWith(`/`)||ii.test(o)))throw H(`${t}.path`,`must be a string starting with "/"`);if(s!==void 0&&(typeof s!=`number`||!Number.isFinite(s)||s<=0&&s!==-1))throw H(`${t}.expires`,`must be -1 for a session cookie, or milliseconds since the epoch`);if(c!==void 0&&typeof c!=`boolean`)throw H(`${t}.httpOnly`,`must be a boolean`);if(l!==void 0&&typeof l!=`boolean`)throw H(`${t}.secure`,`must be a boolean`);if(u!==void 0&&!ri.includes(u))throw H(`${t}.sameSite`,`must be 'Strict', 'Lax' or 'None', not ${JSON.stringify(u)}`);let d=r.toLowerCase();if(u===`None`&&l!==!0)throw H(t,`is SameSite=None, which needs secure: true`);if(d.startsWith(`__secure-`)&&l!==!0)throw H(t,`is a __Secure- cookie, which needs secure: true`);if(d.startsWith(`__host-`)&&(l!==!0||a.startsWith(`.`)||(o??`/`)!==`/`))throw H(t,`is a __Host- cookie, which needs secure: true, a host-only domain and path "/"`);let f={name:r,value:i,domain:a};return o!==void 0&&(f.path=o),s!==void 0&&(f.expires=s),c!==void 0&&(f.httpOnly=c),l!==void 0&&(f.secure=l),u!==void 0&&(f.sameSite=u),f},ci=(e,t)=>{if(!ai(e))throw H(t,`must be an object { origin, localStorage }`);let n=Object.keys(e).find(e=>e!==`origin`&&e!==`localStorage`);if(n!==void 0)throw H(`${t}.${n}`,`is not an origin field`);let{origin:r,localStorage:i}=e,a=(()=>{try{return typeof r==`string`?new URL(r):null}catch{return null}})();if(a===null||a.protocol!==`http:`&&a.protocol!==`https:`||a.origin!==r)throw H(`${t}.origin`,`must be an absolute http or https origin, not ${JSON.stringify(r)}`);if(!Array.isArray(i))throw H(`${t}.localStorage`,`must be an array`);return{origin:r,localStorage:i.map((e,n)=>{let{name:r,value:i}=ai(e)&&Object.keys(e).every(e=>e===`name`||e===`value`)?e:{};if(typeof r!=`string`||typeof i!=`string`)throw H(`${t}.localStorage[${n}]`,`must be { name, value } strings`);return{name:r,value:i}})}},li=e=>{if(!ai(e))throw H(``,`must be an object { cookies?, origins? }`);let t=Object.keys(e).find(e=>e!==`cookies`&&e!==`origins`);if(t!==void 0)throw H(`.${t}`,`is not a storageState key; it takes cookies and origins`);let{cookies:n=[],origins:r=[]}=e;if(!Array.isArray(n))throw H(`.cookies`,`must be an array`);if(!Array.isArray(r))throw H(`.origins`,`must be an array`);let i=n.map((e,t)=>si(e,`.cookies[${t}]`)),a=r.map((e,t)=>ci(e,`.origins[${t}]`));return i.forEach(({expires:e},t)=>{if(e!==void 0&&e>0&&e<ti)throw H(`.cookies[${t}].expires`,`is milliseconds since the epoch, and ${e} reads as a date before 1974; a Playwright storageState gives seconds, so multiply it by 1000`)}),{cookies:i,origins:a}},ui=[`persistent`,`ephemeral`,`native`],di=`attachFrame: syncCookies was replaced by cookies. true is cookies: 'persistent', or 'native' for the person's own browser cookies on the extension; false is cookies: 'ephemeral'`,fi=e=>{if(`syncCookies`in e)throw TypeError(di);let{cookies:t=`persistent`}=e;if(!ui.includes(t))throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);if(e.storageState!==void 0&&t!==`ephemeral`)throw TypeError(ei);let n=e.storageState===void 0?void 0:li(e.storageState),r=Zr(e);if(r===`iframe`&&e.lockdown&&t!==`native`)throw TypeError(`attachFrame: lockdown runs on the extension, which serves only cookies: 'native'`);if(Array.isArray(e.permissions))for(let t of e.permissions)ut(`attachFrame`,t?.reason);return n===void 0?{kind:r,cookies:t}:{kind:r,cookies:t,storageState:n}},pi=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,mi=!1,hi=()=>{mi||(mi=!0,console.warn(`[fkn-frame] the installed FKN WebExtension is too old to ask for permission categories upfront, so each capability will be asked for as it is first used. Updating the extension fixes this.`))},gi=`frame: this frame no longer holds the document the app attached it to`,_i=`frame.postMessage: '*' is not served on the extension yet, since this extension does not report the frame's origin; pass the page's origin as targetOrigin`,vi=()=>{let e=Ze();if(e.status===`ok`&&e.abi>=1)return;let t=e.status===`absent`?0:e.abi;throw new qe(`lockdown`,t,`attachFrame: the installed FKN WebExtension (ABI ${t}) may predate lockdown, and one that does attaches the frame with its CSP removed rather than locked down. Updating the extension fixes this.`)},yi=e=>{try{return new URL(e,location.href).hostname}catch{return``}},bi=()=>{let e=Ze();return e.status===`absent`?0:e.abi},xi=`attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame`,Si=`frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame`,Ci=`click: isTrusted is served by the cloud render proxy only; attach with cloud.attachFrame`,wi=`frame.clearCookies: an extension frame runs on the browser's own cookies (cookies: 'native'), which FKN does not clear; attach with cookies: 'persistent' to clear the app's jar`,Ti=({executeLocator:e,highlightLocator:t,ensureLocatorPermission:n,requestCategories:r,evaluateFrame:i,goto:a},{hosts:o,url:s,page:c,unreachable:l,documents:u,navigated:d})=>{let f=new Set(R(o,{ipv6:!0})),p=e=>f.has(R([xt(e)],{ipv6:!0})[0]??``);return Tr({backend:`extension`,executor:{execute:e,highlight:t},gate:e=>{if(e.operation===`click`&&zn(e.args)?.isTrusted===!0)throw new qe(`click`,bi(),Ci);return n(e.parts,e.operation,e.args)},requestPermissions:async e=>(Lr(`frame.requestPermissions`,e),await Yn(),r(e)),evaluate:async(e,t)=>{if(!Ge(Ze(),`evaluate`)){let e=Ze();throw new qe(`evaluate`,e.status===`ok`?e.abi:0)}return i({source:e,arg:t}).catch(e=>{throw Jr(e)})},addScriptTag:async()=>{throw new qe(`addScriptTag`,bi(),Si)},clearCookies:async()=>{throw new qe(`clearCookies`,bi(),wi)},postMessage:(e,t,n)=>{if(t===`*`)throw Ht(_i,`postMessage`,`extension`);if(!p(t))throw V(gi,`postMessage`);let r=l();if(r)throw r;return c().postMessage(e,t,n),Promise.resolve()},listen:e=>{let t=t=>{t.source!==null&&t.source===c()&&!Br(t.data)&&p(t.origin)&&e({type:`message`,data:t.data,origin:t.origin,ports:t.ports})};window.addEventListener(`message`,t);let n=u(()=>e({type:`document`,origin:``}));return()=>{window.removeEventListener(`message`,t),n()}},goto:(e,{waitUntil:t,timeout:n,...r}={})=>{St(`frame.goto`,[yi(e),...r.domains??[]]);for(let t of R([yi(e)],{ipv6:!0}))f.add(t);return d?.(e),a({url:e,...r,...t===void 0?{}:{waitUntil:t===`commit`?`documentstart`:t},...n===void 0?{}:{timeoutMs:n}}).catch(e=>{throw Xr(e)})},url:s})},Ei=async({iframe:e,domains:t=[],lockdown:n=!1,permissions:r,blank:i})=>{if(i!==void 0)throw new qe(`blank`,bi(),xi);let a=crypto.randomUUID();if(ar(e.src),or({src:e.src,domains:t,lockdown:n}),St(`attachFrame`,t),await et(),n&&vi(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(pi,{detail:a}));let o=Ti(await nt.attachFrame({marker:a,domains:t,syncCookies:!0,lockdown:n}),{hosts:[...t,yi(e.src)],url:()=>e.src,page:()=>e.contentWindow,unreachable:()=>e.contentWindow===null?V(`frame: navigate the frame before postMessage`,`postMessage`):void 0,documents:t=>(e.addEventListener(`load`,t),()=>e.removeEventListener(`load`,t))});return r?.length&&(Jn()?await o.requestPermissions(r):hi()),o},Di=`attachFrame: a window on cookies: 'native' needs the FKN WebExtension, which is not on this page`,Oi=`frame.postMessage: this window's page no longer keeps a link to the app's page, so a message cannot reach it`,ki=`extension.attachFrame: the attached window closed; attach a fresh window`,Ai=e=>`attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`,ji=async e=>{let{domains:t=[],permissions:n}=e,{url:r,width:i,height:a}=$r(e.window);St(`attachFrame`,t);let o=Ze();if(!Ge(o,`attachWindow`))throw o.status===`absent`?new qe(`attachWindow`,0,Di):new qe(`attachWindow`,o.abi);let s=window.open(r||`about:blank`,`_blank`,`popup,width=${i},height=${a}`);if(!s)throw new dr;let c;try{c=await nt.attachWindow({url:r,domains:t})}catch(e){try{s.close()}catch{}throw e}let l=new Promise(e=>window.addEventListener(`pagehide`,()=>e(),{once:!0})),u=!1,d=Promise.race([c.closed,l]).then(()=>{u=!0},()=>{u=!0}),f=r,p=Ti(c,{hosts:r?[...t,yi(r)]:t,url:()=>f,page:()=>s,unreachable:()=>u?Ht(ki,`postMessage`,`extension`):s.closed?V(Oi,`postMessage`):void 0,documents:e=>{let t=!0;return(async()=>{let n=await c.documentsAfter(-1);for(;t;){let r=await c.documentsAfter(n);for(;t&&n<r;n++)e()}})().catch(()=>{}),()=>{t=!1}},navigated:e=>{try{f=new URL(e,location.href).href}catch{}}}),m,h=()=>m??=c.close().then(()=>d,()=>{}).then(()=>{u=!0;try{s.close()}catch{}}),g=Object.assign(p,{close:h,closed:d});try{n?.length&&await g.requestPermissions(n)}catch(e){throw await h(),e}return g},Mi=(async e=>{let{kind:t,cookies:n}=fi(e);if(n!==`native`)throw new qe(`cookies`,bi(),Ai(n));return t===`window`?ji(e):Ei(e)}),Ni=`PermissionDeniedError`,Pi=e=>e instanceof Error?e.name===Ni:Rr(e)&&e.name===`PermissionDeniedError`,Fi=/* @__PURE__ */ `fkn.app,fkn.dev,sdbx.app,horionsoftware.com,webvpn.dev,fknmail.app,clairv.app,fkn.cloudflareaccess.com,me-62e.workers.dev,62e9d4fbf21d90ebd4342e54b4babbd3.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.eu.r2.cloudflarestorage.com,62e9d4fbf21d90ebd4342e54b4babbd3.fedramp.r2.cloudflarestorage.com,pub-8a3dc68041874c7e9c9a54bde972605a.r2.dev,pub-26b534eb9aa04cffbe1cdbb3be3fb1d2.r2.dev,pub-3d97d79220b94243812e60b0e742f2c5.r2.dev,pub-f8bd4876cc3c4b4a951715da5958e49c.r2.dev,web-b3z.pages.dev,fkn-console.pages.dev,dev-dms.pages.dev,fkn-www.pages.dev,fkn-homepage.pages.dev,fkn-sandbox.pages.dev,internal-3ar.pages.dev,stub-ben.pages.dev,ripple-3t3.pages.dev,media-player-e3s.pages.dev,youtube-3c4.pages.dev,horionsoftware.pages.dev,container-ckf.pages.dev,stub-plugin.pages.dev,social-3n2.pages.dev,plugins.banou.dev`.split(`,`),Ii=e=>e.toLowerCase().replace(/\.+$/,``),Li=[`79.127.204.69`,`152.233.49.59`],Ri=e=>{let t;try{t=new URL(`http://${e.includes(`:`)&&!e.startsWith(`[`)?`[${e}]`:e}/`).hostname}catch{return}let n=/^\[(?:::ffff:|64:ff9b::)([0-9a-f]{1,4}):([0-9a-f]{1,4})\]$/.exec(t);if(n){let e=parseInt(n[1],16),t=parseInt(n[2],16);return[e>>8,e&255,t>>8,t&255].join(`.`)}return/^\d+\.\d+\.\d+\.\d+$/.test(t)?t:void 0},zi=e=>{let t=Ii(e);return Fi.some(e=>t===e||t.endsWith(`.${e}`))},Bi=e=>{if(zi(e))return!0;let t=Ri(Ii(e));return t!==void 0&&Li.includes(t)},Vi=e=>{let t=typeof e==`string`?e:e instanceof URL?e.href:e.url,n;try{n=new URL(t)}catch{return}if(Bi(n.hostname))throw Error(`fetch refuses FKN platform domains (${n.hostname})`)},Hi=/* @__PURE__ */ `autoplay.fullscreen.picture-in-picture.encrypted-media.screen-wake-lock.speaker-selection.captured-surface-control.camera.microphone.display-capture.geolocation.midi.usb.serial.hid.bluetooth.gamepad.keyboard-map.xr-spatial-tracking.accelerometer.gyroscope.magnetometer.ambient-light-sensor.compute-pressure.clipboard-read.clipboard-write.storage-access.window-management.local-fonts.idle-detection.web-share.sync-xhr.unload.payment.publickey-credentials-get.publickey-credentials-create.otp-credentials.identity-credentials-get.digital-credentials-get.local-network.local-network-access.loopback-network`.split(`.`),Ui=()=>{try{let e=globalThis.document?.featurePolicy?.features?.();return e===void 0?void 0:new Set(e)}catch{return}},Wi=(e=!0,t=Ui())=>[...Hi,...e?[`cross-origin-isolated`]:[]].filter(e=>t===void 0||t.has(e)).join(`; `),Gi=`https://fkn.app`,Ki=e=>`${Gi}/api${e?`?coi=1`:``}`;`${JSON.stringify(Hi)}${JSON.stringify(Ki(!0))}${JSON.stringify(Ki(!1))}`;var qi=((e,t,n,r)=>{if(r?.signal?.aborted)return()=>{};let i=()=>e.addEventListener(t,n,r);i();let a=typeof MutationObserver>`u`?void 0:new MutationObserver(i);return a?.observe(e.window===e?e.document:e,{childList:!0}),r?.signal?.addEventListener(`abort`,()=>a?.disconnect(),{once:!0}),()=>{a?.disconnect(),e.removeEventListener(t,n,r)}}),Ji=typeof window<`u`||typeof self<`u`,Yi=1e4,Xi=16,Zi=e=>{let t;try{t=e.contentWindow}catch{return!0}if(!t)return!0;try{let e=t.location.href;return e!==``&&e!==`about:blank`}catch{return!0}},Qi=(e,t=Yi)=>new Promise(n=>{if(Zi(e))return n();let r=()=>{clearInterval(i),clearTimeout(a),e.removeEventListener(`load`,r),n()},i=setInterval(()=>{Zi(e)&&r()},Xi),a=setTimeout(r,t);e.addEventListener(`load`,r)}),$i=5e3,ea=9e4,ta=(e,t,n)=>{let r=1,i,a=e.ownerDocument.defaultView,o=()=>{clearTimeout(i),u?.(),e.removeEventListener(`load`,l)},s=()=>{if(e.isConnected){if(r>=4)return o(),console.error(`FKN @fkn/lib: ${t} did not load in ${r} tries; reload the page`);r+=1,e.contentWindow?.location.replace(t),c(ea)}},c=e=>{clearTimeout(i),i=setTimeout(s,e)},l=()=>c($i),u=a?qi(a,`message`,t=>{t.source===e.contentWindow&&t.origin===n&&o()}):void 0;if(e.addEventListener(`load`,l),Zi(e))return c($i);i=setTimeout(()=>Zi(e)?c(8e4):s(),Yi)},na=(e,t)=>({receive:n=>qi(e.ownerDocument.defaultView,`message`,e=>{e.origin===t&&n(e.data,{source:e.source,origin:t})}),emit:(n,r)=>e.contentWindow?.postMessage(n,t,r)}),ra=32,ia=8,aa=120,oa=(e,t)=>typeof CSS<`u`&&typeof CSS?.supports==`function`&&CSS.supports(e,t),sa=oa(`clip-path`,`path('M0 0H1V1H0Z')`),ca=oa(`clip-path`,`polygon(nonzero, 0px 0px, 1px 0px, 1px 1px)`),la=`light dark`,ua=e=>{let t=e.style;t.setProperty(`display`,`block`,`important`),t.setProperty(`position`,`fixed`,`important`),t.setProperty(`top`,`0`,`important`),t.setProperty(`left`,`0`,`important`),t.setProperty(`width`,`100%`,`important`),t.setProperty(`height`,`100%`,`important`),t.setProperty(`border`,`none`,`important`),t.setProperty(`padding`,`0`,`important`),t.setProperty(`box-sizing`,`border-box`,`important`),t.setProperty(`clip-path`,`inset(100%)`,`important`),t.setProperty(`background`,`transparent`),t.setProperty(`color-scheme`,la),t.setProperty(`z-index`,`2147483647`),e.setAttribute(`title`,`FKN`)},da=({x:e,y:t,width:n,height:r,radius:i})=>{if(!i)return`M${e} ${t}h${n}v${r}h${-n}Z`;let a=Math.min(n,r)/2,[o,s,c,l]=i.map(e=>Math.max(0,Math.min(e,a)));return`M${e+o} ${t}h${n-o-s}a${s} ${s} 0 0 1 ${s} ${s}v${r-s-c}a${c} ${c} 0 0 1 ${-c} ${c}h${-(n-c-l)}a${l} ${l} 0 0 1 ${-l} ${-l}v${-(r-l-o)}a${o} ${o} 0 0 1 ${o} ${-o}Z`},fa=()=>sa&&ca,pa=({x:e,y:t,width:n,height:r})=>[[e,t],[e+n,t],[e+n,t+r],[e,t+r],[e,t]],ma=e=>{let t=e[0];if(!t)return[];let n=pa(t)[0],r=[];return e.forEach((t,i)=>{r.push(...pa(t)),i>0&&i<e.length-1&&r.push(n)}),r},ha=e=>`polygon(nonzero, ${ma(e).map(([e,t])=>`${e}px ${t}px`).join(`, `)})`,ga=({x:e,y:t,width:n,height:r,radius:i},a)=>{let o=`${t}px ${a.width-e-n}px ${a.height-t-r}px ${e}px`;return i?`inset(${o} round ${i.map(e=>`${e}px`).join(` `)})`:`inset(${o})`},_a=(e,t,n)=>{if(t)return`none`;if(e.length===0)return`inset(100%)`;let r=e.length===1?e[0]:void 0;return r?ga(r,n):ca&&e.length<=5&&!e.some(e=>e.radius)?ha(e):`path('${e.map(da).join(``)}')`},va=e=>{if(e.length<2)return null;let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:Math.max(...e.map(e=>e.x+e.width))-t,height:Math.max(...e.map(e=>e.y+e.height))-n}},ya=(e,t,n)=>t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height,ba=16,xa=(e,t,n)=>t===1?e*ba:t===2?e*n:e,Sa=(e,t,n,r,i)=>{let a=t?r:0,o=n?i:0;return a||o?{target:e,left:a,top:o}:null},Ca=(e,t,n)=>{let r=document.documentElement,i=getComputedStyle(r),a=i.overflowX===`visible`&&i.overflowY===`visible`&&document.body?document.body:r;for(let r of e){if(r===a)break;if(!(r instanceof Element))continue;let e=getComputedStyle(r),i=Sa(r,/auto|scroll/.test(e.overflowX)&&r.scrollWidth>r.clientWidth,/auto|scroll/.test(e.overflowY)&&r.scrollHeight>r.clientHeight,t,n);if(i)return i;if(e.position===`fixed`&&!r.offsetParent)break}let o=document.scrollingElement,s=a===r?i:getComputedStyle(a);return o&&Sa(o,!/hidden|clip/.test(s.overflowX),!/hidden|clip/.test(s.overflowY),t,n)},wa=null,Ta=null,Ea=e=>({width:e.offsetWidth||window.innerWidth,height:e.offsetHeight||window.innerHeight}),Da=e=>{if(!Ta||!wa||!ya(Ta,e.clientX,e.clientY))return;let t=document.fullscreenElement;if(t&&!t.contains(wa))return;let n=e.composedPath(),r=n.find(e=>e instanceof Element&&e.matches(`:is(:modal, :popover-open)`));if(r&&!r.contains(wa))return;let i=Ca(n,xa(e.deltaX,e.deltaMode,window.innerWidth),xa(e.deltaY,e.deltaMode,window.innerHeight));i&&(i.target.scrollBy({left:i.left,top:i.top,behavior:`instant`}),e.cancelable&&e.preventDefault())},Oa,ka=e=>{Ta=e,e?Oa??=qi(window,`wheel`,Da,{capture:!0,passive:!1}):(Oa?.(),Oa=void 0)},Aa=0,ja=null,Ma=e=>{let t=document.documentElement;if(!t||e===Aa&&(e===0||t===ja))return;Aa=e,ja=t;let n=t.style;e>0?(n.setProperty(`margin-top`,`${e}px`,`important`),n.setProperty(`--fkn-inset-top`,`${e}px`)):(n.removeProperty(`margin-top`),n.removeProperty(`--fkn-inset-top`))},Na=(e,t)=>{t?(e.removeAttribute(`tabindex`),e.removeAttribute(`aria-hidden`)):(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`aria-hidden`,`true`))},Pa=(e,{modal:t,rects:n,inset:r},i)=>{if(Ma(r),!sa){let r=t||n.length>0;Na(e,r),e.style.setProperty(`pointer-events`,r?`auto`:`none`,`important`),e.style.setProperty(`visibility`,r?`visible`:`hidden`,`important`);return}let a=_a(n,t,i),o=a===`none`||oa(`clip-path`,a)?a:`inset(100%)`;e.style.setProperty(`clip-path`,o,`important`),Na(e,o!==`inset(100%)`),ka(t||o!==a?null:va(n))},Fa=e=>{if(typeof e!=`object`||!e)return 0;let{top:t}=e;return typeof t!=`number`||!Number.isFinite(t)||t<=0?0:Math.min(Math.round(t),aa)},Ia=e=>{if(Array.isArray(e)&&e.length===4&&e.every(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0))return e.some(e=>e>0)?e:void 0},La=(e,t)=>{if(typeof e!=`object`||!e)return null;let{x:n,y:r,width:i,height:a}=e;if(![n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e)))return null;let o=t.width,s=t.height,c=Math.max(0,Math.min(Math.round(n),o)),l=Math.max(0,Math.min(Math.round(r),s)),u=Math.max(c,Math.min(Math.round(n+i),o)),d=Math.max(l,Math.min(Math.round(r+a),s)),f=Ia(e.radius);return{x:c,y:l,width:u-c,height:d-l,...f?{radius:f}:{}}},Ra={"not-rendered":`this page is not painting it at all, so it or an ancestor is display:none, or the frame was moved out of the layout`,clipped:`it is clipped away or positioned outside the viewport`,"not-shown":`it is rendered but would not be seen, so either something is drawn over it, or it or an ancestor has opacity below 1, visibility:hidden, or a filter`},za=e=>Array.isArray(e)?e.slice(0,ia).flatMap(e=>{if(typeof e!=`object`||!e)return[];let{kind:t,cause:n,level:r}=e;return typeof t!=`string`||t.length>40||typeof n!=`string`||!(n in Ra)||r!==`full`&&r!==`liveness`?[]:[{kind:t,cause:n,level:r}]}):[],Ba=/* @__PURE__ */ new Set,Va=e=>{for(let{kind:t,cause:n,level:r}of e)Ba.has(t)||(Ba.add(t),console.error(`[FKN] The FKN ${JSON.stringify(t)} is not visible on this page: ${Ra[n]}. Nobody using this page can see or answer it.
|
|
54
54
|
@fkn/lib draws its UI inside <iframe title="FKN"> and sets display, position, top, left, width, height, border, padding, box-sizing, clip-path and z-index on that element. Leave those as they are, then check for an ancestor with opacity, visibility, display or a clipping transform, and for an element stacked above it.`+(r===`liveness`?`
|
|
55
|
-
This browser reports limited detail, so the cause above is a best guess.`:``)))},Va=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=e,r=(Array.isArray(n.rects)?n.rects.slice(0,ra):[]).map(e=>Ia(e,t)).filter(e=>e!==null&&e.width>0&&e.height>0);return{modal:n.modal===!0,rects:r,hidden:Ra(n.hidden),inset:Pa(n.inset)}},Ha=()=>Ca!==null,Ua=null,Wa=null,Ga=()=>{if(!Ca||Ua===null)return;let e=Ta(Ca),t=Va(Ua,e);t&&Na(Ca,t,e)},Ka=e=>{typeof ResizeObserver<`u`&&(Wa??=new ResizeObserver(Ga),Wa.disconnect(),Wa.observe(e))},qa=e=>{la(e),Na(e,{modal:!1,rects:[],hidden:[],inset:0},Ta(e)),Ca=e,Ka(e)},Ja=e=>{if(!Ca)return;let t=Ta(Ca),n=Va(e,t);n&&(Ua=e,Na(Ca,n,t),Ba(n.hidden))},Ya=`https://fkn.app`,Xa=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,Za=typeof globalThis<`u`&&globalThis.crossOriginIsolated===!0,Qa=Ki(Za),$a=`fkn-api-port`,eo=`fkn-api-port-ack`,to=2e3,no=()=>{if(!Xa||typeof window>`u`||window.parent===window)return Promise.resolve(void 0);let e;try{e=window.parent}catch{return Promise.resolve(void 0)}let t=new MessageChannel;return new Promise(n=>{let r=e=>{if(clearTimeout(a),t.port1.removeEventListener(`message`,i),!e)try{t.port1.close()}catch{}n(e)},i=e=>{e.data?.type===eo&&r(t.port1)},a=setTimeout(()=>r(void 0),to);t.port1.addEventListener(`message`,i),t.port1.start();try{e.postMessage({type:$a},Ya,[t.port2])}catch{r(void 0)}})},ro,io=e=>e.querySelector(`iframe[src="${Qa}"]`),ao=async e=>{for(;!e.body;)await new Promise(t=>{let n=new MutationObserver(()=>{n.disconnect(),t()});n.observe(e,{childList:!0,subtree:!0})})},oo=async e=>{let t=io(e);if(t||=(await ao(e),io(e)),t)ro=t;else{let t=e.createElement(`iframe`);t.setAttribute(`allow`,Wi(Za)),t.src=Qa,e.body.appendChild(t),ro=t}return ta(ro,Qa,Ya),qa(ro),ro},so=(async()=>{if(!Xa)return;let e=await no();if(e)return{receive:e,emit:e};let t=await oo(Xa);return await Qi(t),t.contentWindow?na(t,Ya):void 0})(),co=(e,{boundRetired:t=e=>e}={})=>{let n,r=0,i=!1,a=()=>{},o=()=>new Promise(e=>{a=e}),s=o(),c=s,l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Set,d=0,f=0,p=()=>{let e=[...u];u.clear();let t=/* @__PURE__ */ Error(`FKN: the broker was replaced while this call was pending; retry it`);for(let n of e)try{n(t)}catch{}};(async()=>{for await(let t of e){let e=++r;n={remote:t,epoch:e};let i=a;s=o(),i(t),p();for(let n of[...l])try{n(t,e)}catch{}}})().catch(()=>{});let m=async(e,r)=>{let a=n?.remote??await(i?t(s):s);for(let t of e.slice(0,-1))a=a[t];let o=a[e[e.length-1]??``];d=Date.now(),f+=1;let c=()=>{},l=new Promise((e,t)=>{c=t});u.add(c);try{return await Promise.race([Promise.resolve(o.apply(a,r)),l])}finally{--f,u.delete(c),d=Date.now()}},h=/* @__PURE__ */ new Map,g=e=>{let t=e.join(`\0`),r=h.get(t);if(r)return r;let i=new Proxy(function(){},{get:(t,r)=>{if(typeof r!=`string`||r===`then`)return;let i=n;if(i){let t=i.remote;for(let n of e)t=t?.[n];if(t?.[r]===void 0)return}return g([...e,r])},apply:(t,n,r)=>m(e,r)});return h.set(t,i),i};return{facade:g([]),first:c.then(()=>{}),current:()=>n,onEpoch:e=>{if(l.add(e),n)try{e(n.remote,n.epoch)}catch{}return()=>{l.delete(e)}},lastCall:()=>d,inFlight:()=>f,routable:()=>n?Promise.resolve():s.then(()=>{}),retire:()=>{i=!0,n=void 0,p()}}},lo=!1,uo=/* @__PURE__ */ new Set,fo=()=>lo,po=()=>{if(!lo){lo=!0;for(let e of[...uo])try{e()}catch{}uo.clear()}},mo=e=>{lo?e():uo.add(e)},ho=`fkn-api`,go=e=>`fkn-relayed-worker-${e}`,_o=e=>new Promise(t=>{let n=globalThis.navigator?.locks;if(!n)return t();n.request(go(e),()=>(t(),new Promise(()=>{}))).catch(()=>t())}),vo=async(e,t,n)=>{let r=globalThis.navigator?.locks;if(!r)return;let i=go(e),{held:a}=await r.query().catch(()=>({held:void 0}));!n.aborted&&a?.some(e=>e.name===i)&&await r.request(i,{signal:n},()=>{t()}).catch(()=>{})},yo=(e,t,n)=>{let r=new AbortController;n?.aborted?r.abort():n?.addEventListener(`abort`,()=>r.abort(),{once:!0}),l(e,t,{key:ho,unregisterSignal:r.signal});let i=/* @__PURE__ */ new Map;d({transport:t,key:ho,unregisterSignal:r.signal,listener:e=>{let t=i.get(e.uuid);t||(i.set(e.uuid,t=/* @__PURE__ */ new Set),vo(e.uuid,()=>r.abort(),r.signal));let{remoteUuid:n}=e;n&&t.add(n)}});let a=(e,t)=>({[p]:ho,uuid:e,type:`close`,remoteUuid:t});return r.signal.addEventListener(`abort`,()=>{for(let[n,r]of i)for(let i of r)o(e,a(n,i)),o(t,a(i,n))},{once:!0}),r.signal},bo=async()=>{if(typeof window<`u`)return so;if(typeof self<`u`)return{receive:self,emit:self}},xo=`fkn-api`,So=`fkn-api-window`,Co={async*[Symbol.asyncIterator](){let e=await bo();if(!e)await new Promise(()=>{});else{if(!fo()){let t=new AbortController;mo(()=>t.abort());let n=crypto.randomUUID();typeof window>`u`&&await _o(n);for await(let r of s({},{key:xo,transport:e,unregisterSignal:t.signal,uuid:n})){if(t.signal.aborted)break;yield r}}yield*s({},{key:So,transport:e})}}},wo=!1,To=bo().then(e=>new Promise(t=>{if(!e)return;let n=new AbortController;d({transport:e,key:xo,unregisterSignal:n.signal,listener:()=>{n.abort(),wo=!0,t()}})})),Eo=co(Co,{boundRetired:e=>Promise.race([e,To.then(()=>No(e,()=>new jo))])});mo(()=>Eo.retire());var Do=class extends Error{constructor(e,t){super(t===void 0?`@fkn/lib: no FKN broker in this realm (it has no window and no self, as in Node.js), so ${e} could not be requested`:`@fkn/lib: no broker connection within ${t}ms, so ${e} could not be requested`),this.name=`BrokerUnreachableError`}},U=Ji?Promise.race([Eo.first,new Promise(e=>mo(e))]).then(()=>Eo.facade):Promise.reject(new Do(`a broker call`));U.catch(()=>{});var Oo=8e3,ko=1e3,Ao=!1,jo=class extends Error{constructor(){super(`FKN @fkn/lib: this page relays its FKN channel to a worker, and the FKN page it reached predates a channel of the page's own; reload`),this.name=`OwnChannelUnavailableError`}},Mo=e=>new Promise((t,n)=>setTimeout(()=>n(e))),No=(e,t)=>{if(Ao&&!wo)return Mo(t(Oo));let n=Ao?ko:Oo;return Promise.race([e,new Promise((e,r)=>setTimeout(()=>{Ao=!0,r(t(n))},n))])},Po=e=>Ji?fo()?No(Eo.routable().then(()=>Eo.facade),t=>wo?new jo:new Do(e,t)):No(U,t=>new Do(e,t)):Mo(new Do(e));mo(()=>{To.then(()=>{let e=setTimeout(()=>console.error(new jo),Oo);Eo.routable().then(()=>clearTimeout(e))})});var Fo=Eo.onEpoch,Io=Eo.current;Eo.lastCall,Eo.inFlight,Fo(e=>{Ha()&&e.overlay.setHost(Ja,{exactClips:da(),colorScheme:ca}).catch(()=>{})});var Lo=`fkn-attach-frame`,Ro=`fkn-attach-window`,zo={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},Bo=6e4,Vo={default:6048e5,min:6e4,max:31536e6},Ho={notAFile:{code:`invalid`,message:`storage: the data is not a Blob or a ReadableStream`},badSize:{code:`invalid`,message:`storage: a stream needs the size it will deliver, a whole number of bytes`},shortStream:{code:`invalid`,message:`storage: the stream did not deliver the size it declared`},tooLarge:{code:`invalid`,message:`storage: the file is too large to store`},badKey:{code:`invalid`,message:`storage: the key is not 32 bytes base64url`},badUrl:{code:`invalid`,message:`storage: the url does not name a stored object`},badLimit:{code:`invalid`,message:`storage: the limit is out of range`},badCursor:{code:`invalid`,message:`storage: the cursor is not one list answered`},notFound:{code:`not-found`,message:`storage: no object at this url`},integrity:{code:`integrity`,message:`storage: the object does not match its key`},needsAccount:{code:`denied`,message:`storage: storing needs an account`},notCreator:{code:`denied`,message:`storage: only the app that stored the object can delete it`},quota:{code:`quota`,message:`storage: storage quota exceeded`},tooMany:{code:`too-many`,message:`storage: too many stored objects`},tooManyThisHour:{code:`too-many`,message:`storage: too many objects stored this hour, try again later`},accountChanged:{code:`account-changed`,message:`storage: the signed-in account changed`},unavailable:{code:`unavailable`,message:`storage: storage is unavailable`}},Uo=`fkn-relay`,Wo=`RelayUnavailableError`,Go=`this FKN page cannot choose a relay; reload the app to load the current one`,Ko=/* @__PURE__ */ new Map,qo=/* @__PURE__ */ new Set,Jo=e=>{Ko.set(e,(Ko.get(e)??0)+1);let t=!1;return()=>{t||(t=!0,Ko.set(e,Math.max(0,(Ko.get(e)??1)-1)))}},Yo=(e,t)=>{let n=Jo(e);t?.aborted?n():t?.addEventListener(`abort`,n,{once:!0})},Xo=(e,t)=>{qo.add({kind:e,probe:t})},Zo=()=>{let e=/* @__PURE__ */ new Set;for(let[t,n]of Ko)n>0&&e.add(`${t} (${n})`);for(let{kind:t,probe:n}of qo)try{n()&&e.add(t)}catch{e.add(t)}return[...e]},Qo=e=>Object.assign(Error(e),{name:Wo}),$o=e=>typeof e==`object`&&!!e&&e.name===`RelayUnavailableError`,es=(e,t)=>{if(typeof e.relay?.resolve!=`function`)throw Qo(`${t}: ${Go}`)},ts=/* @__PURE__ */ new WeakMap,ns=(e,t)=>{t&&ts.set(e,t)},rs=e=>{let t=ts.get(e);if(t!==void 0)return t;let n=e.headers;return n instanceof Headers?n.get(`fkn-relay`)??void 0:e._relay},is=typeof FinalizationRegistry>`u`?void 0:new FinalizationRegistry(e=>e()),as=(e,t)=>{if(!e.body)return t(),e;let n=Jo(`streamed response`),r=()=>{n(),t()},i=v(e,r);return is?.register(i.body,r),i},os=async e=>{if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e:new Request(`https://body.invalid/`,{method:`POST`,body:e,duplex:`half`}).arrayBuffer()},ss=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},cs=(e,t)=>{let{signal:n,release:r}=_(t?.signal);return(t?.relay===void 0?U:Po(`a relay choice`)).then(r=>(t?.relay!==void 0&&es(r,`cloud.fetch`),r.cloud.fetch(e,t?.signal?{...t,signal:n}:t))).then(e=>as(e,r),e=>{throw r(),e})},ls=async(e,t)=>{if(Vi(e),typeof e==`object`&&e&&!(e instanceof URL)&&typeof e.url==`string`){let n=e,r={};n.headers.forEach((e,t)=>{r[t]=e});let i=await os(t?.body===void 0?await ss(n):t.body);return cs(n.url,{...t,method:t?.method??n.method,headers:t?.headers??r,body:i})}let n=e instanceof URL?e.href:e,r=await os(t?.body);return cs(n,t?.body===void 0?t:{...t,body:r})},us=()=>!1,ds=(e=>(...t)=>{throw Error(`The FKN desktop app is not connected, desktop.${e} is unavailable`)})(`fetch`),fs=async e=>{if(ut(`promptInstall`,e),typeof window>`u`)return!1;if(Xe())return!0;let t=await U,n=null,r=new Promise(e=>{n=()=>{Xe()&&e(!0)},Ye.addEventListener(`statuschange`,n)}),i=t.installPrompt.show(e).then(()=>!1),a=await Promise.race([r,i]);return n&&Ye.removeEventListener(`statuschange`,n),await t.installPrompt.hide().catch(()=>{}),a},ps=null;$e(()=>(ps||=fs().then(()=>void 0).finally(()=>{ps=null}),ps));var ms=e=>{try{e.headers.delete(Uo)}catch{}return e},hs=()=>typeof document<`u`&&Xe(),gs=async(e,t)=>{if(Vi(e),ut(`fetch`,t?.reason),t?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return _t(e,t).then(ms)}return hs()?_t(e,{...t,credentials:`omit`}).then(ms):us()?ds(e,t):ls(e,t)},_s=(e,t,{classifier:n=`no-base`}={})=>{if(!e.session)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs its own session: attach with cookies: 'ephemeral'`};if(typeof t!=`string`)return{kind:`refuse`,reason:`frame.fetch: url must be a string`};let r;try{r=new URL(t)}catch{return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`}}if(n===`fetchTarget`&&ie(t).kind!==`absolute`)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`};if(r.protocol!==`https:`&&r.protocol!==`http:`)return{kind:`refuse`,reason:`frame.fetch: only http(s) urls are supported`};if(!(e.declaredHosts.includes(r.hostname)||e.approvedOrigins.has(r.origin)))return{kind:`refuse`,reason:`frame.fetch: the target is outside the origins this attachment declared`};let i=e.declaredHosts.length?e.declaredHosts:[r.hostname];return{kind:`consent`,targetHost:r.hostname,promptHosts:i}},vs=/* @__PURE__ */ g({lookup:()=>ys}),ys=(e,t)=>U.then(n=>n.cloud.dns.lookup(e,t)),bs=/* @__PURE__ */ a({Blob:()=>Ls,BlobOptions:()=>Rs,Buffer:()=>G,File:()=>zs,FileOptions:()=>Bs,INSPECT_MAX_BYTES:()=>Vs,SlowBuffer:()=>Hs,TranscodeEncoding:()=>Us,atob:()=>Ws,btoa:()=>Gs,constants:()=>Ks,default:()=>Is,isAscii:()=>qs,isUtf8:()=>Js,kMaxLength:()=>Ys,kStringMaxLength:()=>Xs,resolveObjectURL:()=>Zs,transcode:()=>Qs});function xs(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Ss(e){var t=xs(e),n=t[0],r=t[1];return(n+r)*3/4-r}function Cs(e,t,n){return(t+n)*3/4-n}function ws(e){for(var t,n=xs(e),r=n[0],i=n[1],a=new js(Cs(e,r,i)),o=0,s=i>0?r-4:r,c=0;c<s;c+=4)t=As[e.charCodeAt(c)]<<18|As[e.charCodeAt(c+1)]<<12|As[e.charCodeAt(c+2)]<<6|As[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=As[e.charCodeAt(c)]<<2|As[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=As[e.charCodeAt(c)]<<10|As[e.charCodeAt(c+1)]<<4|As[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function Ts(e){return ks[e>>18&63]+ks[e>>12&63]+ks[e>>6&63]+ks[e&63]}function Es(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Ts(r));return i.join(``)}function Ds(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Es(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(ks[t>>2]+ks[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(ks[t>>10]+ks[t>>4&63]+ks[t<<2&63]+`=`)),i.join(``)}var W,Os,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,G,zs,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s=n((()=>{for(W={},Os={},Os.byteLength=Ss,Os.toByteArray=ws,Os.fromByteArray=Ds,ks=[],As=[],js=typeof Uint8Array<`u`?Uint8Array:Array,Ms=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ns=0,Ps=Ms.length;Ns<Ps;++Ns)ks[Ns]=Ms[Ns],As[Ms.charCodeAt(Ns)]=Ns;As[45]=62,As[95]=63,Fs={},Fs.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Fs.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=Os,n=Fs,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=x,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Se(e,o)||e&&Se(e.buffer,o)||s!==void 0&&(Se(e,s)||e&&Se(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=S(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Se(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Ce(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function x(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Se(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Se(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Se(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function S(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Se(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return _e(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return be(e).length;default:if(i)return r?-1:_e(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=S;function C(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return ne(this,t,n);case`utf8`:case`utf-8`:return N(this,t,n);case`ascii`:return P(this,t,n);case`latin1`:case`binary`:return F(this,t,n);case`base64`:return M(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return re(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function w(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)w(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?N(this,0,e):C.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e||u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Se(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function T(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ce(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(i)n=0;else return-1}if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:E(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function E(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return T(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return T(this,e,t,n,!1)};function D(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o=0;for(;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Ce(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return xe(_e(t,e.length-n),e,n,r)}function k(e,t,n,r){return xe(ve(t),e,n,r)}function A(e,t,n,r){return xe(be(t),e,n,r)}function j(e,t,n,r){return xe(ye(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return D(this,e,t,n);case`utf8`:case`utf-8`:return O(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return k(this,e,t,n);case`base64`:return A(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return j(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function N(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return te(r)}let ee=4096;function te(e){let t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ee));return n}function P(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function F(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function ne(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=we[e[r]];return i}function re(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function I(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t+this[++e]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||I(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||I(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=this[e+4]+this[e+5]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!1,52,8)};function L(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;L(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;L(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ie(e,t,n,r,i){fe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function ae(e,t,n,r,i){fe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=Te(function(e,t=0){return ie(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=Te(function(e,t=0){return ae(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);L(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a|0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);L(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a|0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=Te(function(e,t=0){return ie(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=Te(function(e,t=0){return ae(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function oe(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function se(e,t,r,i,a){return t=+t,r>>>=0,a||oe(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return se(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return se(this,e,t,!1,n)};function R(e,t,r,i,a){return t=+t,r>>>=0,a||oe(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return R(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return R(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let ce={};function le(e,t,n){ce[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}le(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),le(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),le(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=ue(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ue(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ue(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function de(e,t,n){pe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&me(t,e.length-(n+1))}function fe(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new ce.ERR_OUT_OF_RANGE(`value`,i,e)}de(r,i,a)}function pe(e,t){if(typeof e!=`number`)throw new ce.ERR_INVALID_ARG_TYPE(t,`number`,e)}function me(e,t,n){throw Math.floor(e)===e?t<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(pe(e,n),new ce.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let he=/[^+/0-9A-Za-z-_]/g;function ge(e){if(e=e.split(`=`)[0],e=e.trim().replace(he,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function _e(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319||o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ve(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ye(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function be(e){return t.toByteArray(ge(e))}function xe(e,t,n,r){let i=0;for(;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Se(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ce(e){return e!==e}let we=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Te(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})(W),Is=W.Buffer,Ls=W.Blob,Rs=W.BlobOptions,G=W.Buffer,zs=W.File,Bs=W.FileOptions,Vs=W.INSPECT_MAX_BYTES,Hs=W.SlowBuffer,Us=W.TranscodeEncoding,Ws=W.atob,Gs=W.btoa,Ks=W.constants,qs=W.isAscii,Js=W.isUtf8,Ys=W.kMaxLength,Xs=W.kStringMaxLength,Zs=W.resolveObjectURL,Qs=W.transcode}));$s();var ec={json:`application/json`,txt:`text/plain`,html:`text/html`,htm:`text/html`,css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,xml:`application/xml`,csv:`text/csv`,md:`text/markdown`,svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,pdf:`application/pdf`,wasm:`application/wasm`},tc=(e,t)=>{if(t)return t;let n=e.split(`/`).pop()??``,r=n.lastIndexOf(`.`);if(!(r<=0))return ec[n.slice(r+1).toLowerCase()]},nc=(e,t)=>({size:e,mtimeMs:t,mtime:new Date(t),atimeMs:t,ctimeMs:t,mode:420,isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}),rc=(e=0)=>({size:0,mtimeMs:e,mtime:new Date(e),atimeMs:e,ctimeMs:e,mode:493,isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1}),K=(e,t,n)=>{let r=/* @__PURE__ */ Error(`${e}: ${{ENOENT:`no such file or directory`,EEXIST:`file already exists`,ENOTDIR:`not a directory`,EISDIR:`illegal operation on a directory`,ENOTEMPTY:`directory not empty`,ERR_FS_EISDIR:`is a directory`,EROFS:`read-only file system, as @fkn/lib keeps no files in Node.js`}[e]??e}, ${n} '${t}'`);return r.code=e,r.path=t,r.syscall=n,r},q=e=>{let t=[];for(let n of e.split(`/`))n&&n!==`.`&&(n===`..`?t.pop():t.push(n));return t.join(`/`)},ic=e=>e.split(`/`).slice(0,-1).join(`/`),J=e=>typeof e==`string`?e:e instanceof URL?decodeURIComponent(e.pathname):e.toString(),ac=e=>typeof e==`string`?e:e?.encoding??void 0,oc=e=>typeof e==`object`?e?.contentType:void 0,sc=e=>typeof e==`object`&&!!e?.recursive,cc=(e,t)=>{let n=ac(t);return n?G.from(e).toString(n):G.from(e)},lc=(e,t)=>{if(typeof e==`string`)return new Uint8Array(G.from(e,ac(t)??`utf8`));if(e instanceof Uint8Array)return e.slice();if(e instanceof ArrayBuffer)return new Uint8Array(e).slice();if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice();throw TypeError(`The "data" argument must be of type string, Buffer, TypedArray, or DataView`)},uc=e=>{let t=/* @__PURE__ */ new Map([[``,{kind:`dir`,mtimeMs:0}]]),n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=()=>e.captureAccount?{pin:e.captureAccount()}:{};Xo(`unsaved files`,()=>n.size>0||r.size>0);let a=/* @__PURE__ */ new Set,o=()=>Date.now(),s=e=>{if(!e)return;let n=e.split(`/`),r=``;for(let e of n){r=r?`${r}/${e}`:e;let n=t.get(r);if(!n)t.set(r,{kind:`dir`,mtimeMs:o()});else if(n.kind===`file`)throw K(`ENOTDIR`,r,`mkdir`)}},c,l=0,u=async()=>{let c=i(),u=await e.list(c).catch(()=>[]),d=/* @__PURE__ */ new Set,f=!1;for(let i of u){let l=q(i.path);if(d.add(l),!r.has(l)&&(!n.has(l)||a.has(l)))try{let u=await(await e.readFile(i.path,c)).arrayBuffer();if(r.has(l)||n.has(l)&&!a.has(l))continue;s(ic(l));let d=Date.parse(i.updatedAt??``);t.set(l,{kind:`file`,data:new Uint8Array(u),mtimeMs:Number.isFinite(d)?d:o(),contentType:i.contentType??void 0}),a.delete(l),n.delete(l)}catch{f=!0,a.add(l)}}for(let e of a)d.has(e)||a.delete(e);l=f?Date.now():0},d=()=>(c&&(l===0||Date.now()-l<5e3)||(c=u()),c),f=async()=>{c=void 0,l=0,await d()},p=async()=>{let i=[...n].map(async([r,i])=>{if(a.has(r))return;let o=t.get(r);if(o?.kind!==`file`){n.delete(r);return}let s=o.data,c=tc(r,o.contentType);try{await e.writeFile(r,s,c?{contentType:c,...i}:i);let a=t.get(r);a?.kind===`file`&&a.data===s&&n.delete(r)}catch{}}),o=[...r].map(async([t,n])=>{try{await e.remove(t,n),r.get(t)===n&&r.delete(t)}catch{}});await Promise.all([...i,...o])},m,h=()=>{m||=setTimeout(()=>{m=void 0,p().catch(()=>{})},250)};typeof window<`u`&&(qi(window,`pagehide`,()=>{p().catch(()=>{})}),qi(document,`visibilitychange`,()=>{document.visibilityState===`hidden`&&p().catch(()=>{})}));let g=e=>e.kind===`file`?nc(e.data.byteLength,e.mtimeMs):rc(e.mtimeMs),_=e=>Object.assign(/* @__PURE__ */ Error(`storage: ${e} exists but could not be read, retry once its scope is available`),{code:`FKN_E2E_LOCKED`}),v=e=>{let n=q(e);return t.has(n)||a.has(n)},y=e=>{let n=q(e),r=t.get(n);if(!r)throw a.has(n)?_(e):K(`ENOENT`,e,`stat`);return g(r)},b=e=>{let n=q(e),r=t.get(n);if(!r)throw a.has(n)?_(e):K(`ENOENT`,e,`open`);if(r.kind===`dir`)throw K(`EISDIR`,e,`read`);return r.data},x=(e,t)=>{let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n},S=(e,c,l,u)=>{let d=q(e);if(!d)throw K(`EISDIR`,e,`open`);if(!Ji)throw K(`EROFS`,e,`open`);if(a.has(d))throw _(e);let f=t.get(d);if(f?.kind===`dir`)throw K(`EISDIR`,e,`open`);s(ic(d));let p=l&&f?.kind===`file`?x(f.data,c):c;t.set(d,{kind:`file`,data:p,mtimeMs:o(),contentType:u??(f?.kind===`file`?f.contentType:void 0)}),n.set(d,i()),r.delete(d),h()},C=(e,n)=>{let r=q(e);if(r){if(!Ji)throw K(`EROFS`,e,`mkdir`);if(t.has(r)){if(n)return;throw K(`EEXIST`,e,`mkdir`)}if(!n&&!t.has(ic(r)))throw K(`ENOENT`,e,`mkdir`);s(r)}},w=e=>{let n=q(e),r=t.get(n);if(!r)throw K(`ENOENT`,e,`scandir`);if(r.kind===`file`)throw K(`ENOTDIR`,e,`scandir`);let i=n?`${n}/`:``,o=/* @__PURE__ */ new Set;for(let e of[...t.keys(),...a]){if(!e||!e.startsWith(i))continue;let t=e.slice(i.length);t&&o.add(t.split(`/`)[0])}return[...o]},T=(e,{op:o,recursive:s,force:c})=>{let l=i(),u=q(e),d=t.get(u);if(!d&&a.has(u)){if(o===`rmdir`)throw K(`ENOTDIR`,e,`rmdir`);a.delete(u),n.delete(u),r.set(u,l),h();return}if(!d){if(c||o===`rmdir`&&s)return;throw K(`ENOENT`,e,o===`rmdir`?`rmdir`:`unlink`)}if(o===`unlink`&&d.kind===`dir`)throw K(`EISDIR`,e,`unlink`);if(o===`rmdir`&&d.kind===`file`)throw K(`ENOTDIR`,e,`rmdir`);if(o===`rm`&&d.kind===`dir`&&!s)throw K(`ERR_FS_EISDIR`,e,`rm`);let f=`${u}/`,p=[...t.keys()].filter(e=>e.startsWith(f));if(p.length&&!s)throw K(`ENOTEMPTY`,e,`rmdir`);for(let e of[u,...p]){let i=t.get(e);t.delete(e),i?.kind===`file`&&(n.delete(e),r.set(e,l))}h()};return{mount:d,remount:f,flush:p,exists:v,stat:y,readFile:b,writeFile:S,mkdir:C,readdir:w,remove:T,rename:(e,o)=>{let c=i(),l=q(e),u=q(o);if(!l)throw K(`EBUSY`,e,`rename`);if(u===l||u.startsWith(`${l}/`))throw K(`EINVAL`,e,`rename`);if(a.has(l))throw _(e);if(a.has(u))throw _(o);let d=t.get(l);if(!d)throw K(`ENOENT`,e,`rename`);let f=t.get(u);if(f){if(f.kind!==d.kind)throw K(d.kind===`dir`?`ENOTDIR`:`EISDIR`,o,`rename`);T(u,{op:`rm`,recursive:!0,force:!0})}s(ic(u));let p=`${l}/`,m=[l,...[...t.keys()].filter(e=>e.startsWith(p))];for(let e of m){let i=u+e.slice(l.length),a=t.get(e);t.set(i,a),t.delete(e),a.kind===`file`&&(n.set(i,c),r.delete(i),n.delete(e),r.set(e,c))}h()}}},dc=(e,t)=>typeof e==`function`?e:t,fc=e=>typeof e==`function`?void 0:e,pc=(e,t)=>{e.then(e=>t(null,e),e=>t(e))},mc=e=>{let t=uc(e),n=(e,n)=>cc(t.readFile(J(e)),n),r=(e,n,r)=>t.writeFile(J(e),lc(n,r),!1,oc(r)),i=(e,n,r)=>t.writeFile(J(e),lc(n,r),!0,oc(r)),a=e=>t.exists(J(e)),o=e=>t.stat(J(e)),s=e=>t.readdir(J(e)),c=(e,n)=>t.mkdir(J(e),sc(n)),l=(e,n)=>t.remove(J(e),{op:`rm`,...n}),u=(e,n)=>t.remove(J(e),{op:`rmdir`,...n}),d=e=>t.remove(J(e),{op:`unlink`}),f=(e,n)=>t.rename(J(e),J(n)),p=(e,n)=>{t.mount().finally(()=>{let t;try{t=e()}catch(e){n(e);return}n(null,t)})},m=e=>t.mount().then(()=>e());return{available:e.available,readFileSync:n,writeFileSync:r,appendFileSync:i,existsSync:a,statSync:o,lstatSync:o,readdirSync:s,mkdirSync:c,rmSync:l,rmdirSync:u,unlinkSync:d,renameSync:f,readFile:(e,n,r)=>p(()=>cc(t.readFile(J(e)),fc(n)),dc(n,r)),writeFile:(e,n,r,i)=>p(()=>t.writeFile(J(e),lc(n,fc(r)),!1,oc(fc(r))),dc(r,i)),appendFile:(e,n,r,i)=>p(()=>t.writeFile(J(e),lc(n,fc(r)),!0,oc(fc(r))),dc(r,i)),stat:(e,n)=>p(()=>t.stat(J(e)),n),readdir:(e,n,r)=>p(()=>t.readdir(J(e)),dc(n,r)),mkdir:(e,n,r)=>p(()=>t.mkdir(J(e),sc(fc(n))),dc(n,r)),rm:(e,n,r)=>p(()=>t.remove(J(e),{op:`rm`,...fc(n)}),dc(n,r)),unlink:(e,n)=>p(()=>t.remove(J(e),{op:`unlink`}),n),rename:(e,n,r)=>p(()=>t.rename(J(e),J(n)),r),exists:(e,n)=>{t.mount().finally(()=>n(t.exists(J(e))))},promises:{readFile:(e,n)=>m(()=>cc(t.readFile(J(e)),n)),writeFile:(e,n,r)=>m(()=>t.writeFile(J(e),lc(n,r),!1,oc(r))),appendFile:(e,n,r)=>m(()=>t.writeFile(J(e),lc(n,r),!0,oc(r))),stat:e=>m(()=>t.stat(J(e))),lstat:e=>m(()=>t.stat(J(e))),readdir:e=>m(()=>t.readdir(J(e))),mkdir:(e,n)=>m(()=>t.mkdir(J(e),sc(n))),rm:(e,n)=>m(()=>t.remove(J(e),{op:`rm`,...n})),rmdir:(e,n)=>m(()=>t.remove(J(e),{op:`rmdir`,...n})),unlink:e=>m(()=>t.remove(J(e),{op:`unlink`})),rename:(e,n)=>m(()=>t.rename(J(e),J(n))),access:e=>m(()=>{if(!t.exists(J(e)))throw K(`ENOENT`,J(e),`access`)})},mount:t.mount,flush:t.flush,remount:t.remount}},hc=e=>{let t=()=>e.captureAccount?{pin:e.captureAccount()}:{},n=async(t,n)=>{let r=await e.readFile(J(t));return cc(new Uint8Array(await r.arrayBuffer()),n)},r=async(t,n,r)=>{let i=J(t),a=tc(i,oc(r));await e.writeFile(i,lc(n,r),a?{contentType:a}:void 0)},i=t=>e.remove(J(t)),a=async(n,r)=>{let i=t(),a=q(J(n)),o=q(J(r));if(a===o)return;let s=await e.readFile(a,i);await e.writeFile(o,s,i),await e.remove(a,i)},o=async t=>{let n=q(J(t)),r=n?`${n}/`:``,i=/* @__PURE__ */ new Set;for(let t of await e.list()){let e=q(t.path);if(r&&!e.startsWith(r))continue;let n=e.slice(r.length);n&&i.add(n.split(`/`)[0])}return[...i]},s=async(e,t)=>{},c=async(n,r)=>{let i=t(),a=q(J(n));if(!r?.recursive){await e.remove(J(n),i);return}let o=`${a}/`,s=await e.list(i);await Promise.all(s.filter(e=>{let t=q(e.path);return t===a||t.startsWith(o)}).map(t=>e.remove(t.path,i).catch(()=>{})))},l=async t=>{let n=q(J(t)),r=await e.list(),i=r.find(e=>q(e.path)===n);if(i){let e=Date.parse(i.updatedAt??``);return nc(i.size,Number.isFinite(e)?e:0)}if(r.some(e=>q(e.path).startsWith(`${n}/`)))return rc();throw K(`ENOENT`,J(t),`stat`)},u={readFile:n,writeFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:c,stat:l,lstat:l,access:async e=>{await l(e)}};return{available:e.available,promises:u,readFile:(e,t,r)=>pc(n(e,fc(t)),dc(t,r)),writeFile:(e,t,n,i)=>pc(r(e,t,fc(n)),dc(n,i)),unlink:(e,t)=>pc(i(e),t),rename:(e,t,n)=>pc(a(e,t),n),readdir:(e,t,n)=>pc(o(e),dc(t,n)),mkdir:(e,t,n)=>pc(s(),dc(t,n)),rm:(e,t,n)=>pc(c(e,fc(t)),dc(t,n)),stat:(e,t)=>pc(l(e),t)}};function gc(e,t){return t.memfs?mc(e):hc(e)}var _c=`FKN_STORAGE_NOT_FOUND`,vc=`FKN_ACCOUNT_CHANGED`,yc=`FKN_ACCOUNT_PIN_UNSUPPORTED`,bc=0,xc=/* @__PURE__ */ new Set,Sc=2e3,Cc=null,wc=e=>{let t=e?.switched!==!1;t&&(bc+=1,Cc&&=(clearTimeout(Cc.timer),null));for(let e of[...xc])try{e({switched:t})}catch{}},Tc=!1,Ec=0,Dc=()=>{let e=Io();e&&Ec!==e.epoch&&(Ec=e.epoch,Promise.resolve(e.remote.account.onChange(wc)).catch(()=>{Ec===e.epoch&&(Ec=0)}))},Oc=()=>{!Tc&&Ji&&(Tc=!0,Fo(Dc))},kc=()=>bc,Ac=e=>(xc.add(e),Oc(),()=>{xc.delete(e)}),jc=e=>{if(e!==bc||Cc?.generation===e)return;let t=setTimeout(()=>{Cc?.timer===t&&(Cc=null,bc===e&&wc({switched:!0}))},Sc);Cc={generation:e,timer:t}},Mc=/* @__PURE__ */ g({StorageAccountChangedError:()=>Ic,StorageAccountPinUnsupportedError:()=>Lc,StorageLockedError:()=>Nc,StorageNotFoundError:()=>Pc,availability:()=>nl,available:()=>Zc,captureAccount:()=>Y,encryption:()=>ul,isAccountChanged:()=>Rc,isInvalidPin:()=>zc,isNotFound:()=>Fc,knownPin:()=>Kc,list:()=>rl,pinFor:()=>qc,quota:()=>il,readFile:()=>al,readFileSealed:()=>sl,remove:()=>ll,unlock:()=>dl,writeFile:()=>cl}),Nc=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},Pc=class extends Error{code=_c;constructor(e=`storage: no object at that path`){super(e)}},Fc=e=>e?.code===_c,Ic=class extends Error{code=vc;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},Lc=class extends Error{code=yc;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},Rc=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),zc=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),Bc=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new Nc:Fc(e)?new Pc(e.message):Rc(e)?new Ic:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new Lc:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new Pc(e.message):e},Y=()=>(Oc(),{generation:kc()}),Vc=/* @__PURE__ */ new Map,Hc=null,Uc=e=>typeof e?.accountPin==`function`,Wc=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return kc()===e&&Vc.set(e,t),t});return Hc={generation:e,pin:n},n.catch(()=>{Hc?.pin===n&&(Hc=null)}),n},Gc=async(e,t)=>{let n=Vc.get(e.generation);if(n!==void 0)return n;if(e.generation!==kc())throw new Ic;let r=await(Hc?.generation===e.generation?Hc.pin:Wc(e.generation,t)).catch(Bc);if(e.generation!==kc())throw new Ic;return r},Kc=e=>Vc.get(e.generation),qc=async e=>{let t=(await U).cloud.fs;if(!Uc(t))throw new Lc;return Gc(e,t)},Jc=e=>{for(let[t,n]of Vc)if(n===e)return t},Yc=e=>e?.pin??Y(),Xc=async(e,t)=>{let n=(await U).cloud.fs;if(!Uc(n))throw new Lc;let r=`pin`in e?e.pin:await Gc(e,n);if(!Uc(n))throw new Lc;return t(n,{accountPin:r}).catch(t=>{if(Rc(t)){let t=`generation`in e?e.generation:Jc(r);t!==void 0&&jc(t)}return Bc(t)})},Zc=()=>U.then(e=>e.cloud.fs.available()).catch(()=>!1),Qc=8e3,$c=1e3,el=!1,tl=async()=>{let e=(await U).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},nl=async()=>{let e=el?$c:Qc,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);tl().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(el=!0,`unknown`):(el=!1,t)},rl=e=>Xc(Yc(e),(e,t)=>e.list(t)),il=()=>U.then(e=>e.cloud.fs.quota()),al=async(e,t)=>{let n=await Xc(Yc(t),(t,n)=>t.readFile(e,n));return new Blob([n])},ol=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},sl=async(e,t)=>Xc(Yc(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:ol(i.sealedAt)}}),cl=async(e,t,n)=>{let r=Yc(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await Xc(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},ll=async(e,t)=>{await Xc(Yc(t),(t,n)=>t.remove(e,n))},ul=()=>U.then(e=>e.cloud.fs.encryption()),dl=()=>U.then(e=>e.cloud.fs.unlock()),fl=/* @__PURE__ */ g({STORAGE_ACCOUNT_CHANGED:()=>vc,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>yc,STORAGE_NOT_FOUND:()=>_c,StorageAccountChangedError:()=>Ic,StorageAccountPinUnsupportedError:()=>Lc,StorageLockedError:()=>Nc,StorageNotFoundError:()=>Pc,availability:()=>nl,available:()=>pl,encryption:()=>ul,isAccountChanged:()=>Rc,isNotFound:()=>Fc,list:()=>Cl,mkdir:()=>yl,promises:()=>Sl,quota:()=>il,readFile:()=>ml,readFileSealed:()=>wl,readdir:()=>vl,rename:()=>_l,rm:()=>bl,stat:()=>xl,unlink:()=>gl,unlock:()=>dl,writeFile:()=>hl}),{available:pl,readFile:ml,writeFile:hl,unlink:gl,rename:_l,readdir:vl,mkdir:yl,rm:bl,stat:xl,promises:Sl}=gc(Mc,{memfs:!1}),Cl=()=>rl(),wl=e=>sl(e),Tl=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AddressError=void 0,e.AddressError=class extends Error{constructor(e,t){super(e),this.name=`AddressError`,this.parseMessage=t}}})),El=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isInSubnet=n,e.isHostInSubnet=r,e.isGloballyReachable=i,e.offsetBigInt=a,e.isCorrect=o,e.prefixLengthFromMask=s,e.assertByteArray=c,e.numberToPaddedHex=l,e.stringToPaddedHex=u,e.testBit=d;var t=Tl();function n(e){return this.subnetMask<e.subnetMask?!1:r.call(this,e)}function r(e){return this.binaryZeroPad().length===e.binaryZeroPad().length&&this.mask(e.subnetMask)===e.mask()}function i(e){let t=null;for(let n=0;n<e.length;n++){let i=e[n];i.reachable!==null&&r.call(this,i.subnet)&&(t===null||i.subnet.subnetMask>t.subnet.subnetMask)&&(t=i)}return t===null||t.reachable}function a(e,n,r,i){if(typeof n==`number`&&!Number.isSafeInteger(n)||typeof n!=`number`&&typeof n!=`bigint`)throw new t.AddressError(`${i} offset must be an integer`);let a=e+BigInt(n);if(a<BigInt(0)||a>(BigInt(1)<<BigInt(r))-BigInt(1))throw new t.AddressError(`${i} offset leaves the address space`);return a}function o(e){return function(){return this.addressMinusSuffix===this.correctForm()?this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask):!1}}function s(e,n){let r=e.toString(2).padStart(n,`0`);if(r.length>n)throw new t.AddressError(`Invalid subnet mask.`);let i=r.indexOf(`0`);if(i===-1)return n;if(r.slice(i).includes(`1`))throw new t.AddressError(`Invalid subnet mask.`);return i}function c(e,n,r,i){if(e.length!==n)throw new t.AddressError(`${r} addresses require exactly ${n} bytes`);for(let n=0;n<e.length;n++)if(!Number.isInteger(e[n])||e[n]<i||e[n]>255)throw new t.AddressError(`All bytes must be integers between ${i} and 255`)}function l(e){return e.toString(16).padStart(2,`0`)}function u(e){return l(parseInt(e,10))}function d(e,t){let{length:n}=e;if(t>n)return!1;let r=n-t;return e.substring(r,r+1)===`1`}})),Dl=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_SUBNET_STRING=e.RE_ADDRESS=e.GROUPS=e.BITS=void 0,e.BITS=32,e.GROUPS=4,e.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g,e.RE_SUBNET_STRING=/\/\d{1,2}$/,e.SPECIAL_PURPOSE=[[`0.0.0.0/8`,`This network`,!1],[`0.0.0.0/32`,`This host on this network`,!1],[`10.0.0.0/8`,`Private-Use`,!1],[`100.64.0.0/10`,`Shared Address Space`,!1],[`127.0.0.0/8`,`Loopback`,!1],[`169.254.0.0/16`,`Link Local`,!1],[`172.16.0.0/12`,`Private-Use`,!1],[`192.0.0.0/24`,`IETF Protocol Assignments`,!1],[`192.0.0.0/29`,`IPv4 Service Continuity Prefix`,!1],[`192.0.0.8/32`,`IPv4 dummy address`,!1],[`192.0.0.9/32`,`Port Control Protocol Anycast`,!0],[`192.0.0.10/32`,`Traversal Using Relays around NAT Anycast`,!0],[`192.0.0.170/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.0.171/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.2.0/24`,`Documentation (TEST-NET-1)`,!1],[`192.31.196.0/24`,`AS112-v4`,!0],[`192.52.193.0/24`,`AMT`,!0],[`192.88.99.0/24`,`Deprecated (6to4 Relay Anycast)`,null],[`192.88.99.2/32`,`6a44-relay anycast address`,!1],[`192.168.0.0/16`,`Private-Use`,!1],[`192.175.48.0/24`,`Direct Delegation AS112 Service`,!0],[`198.18.0.0/15`,`Benchmarking`,!1],[`198.51.100.0/24`,`Documentation (TEST-NET-2)`,!1],[`203.0.113.0/24`,`Documentation (TEST-NET-3)`,!1],[`240.0.0.0/4`,`Reserved`,!1],[`255.255.255.255/32`,`Limited Broadcast`,!1]]})),Ol=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.Address4=void 0;var o=a(El()),s=a(Dl()),c=Tl(),l=o.isCorrect(s.BITS),u=class e{constructor(e){this.addressMinusSuffix=``,this.groups=s.GROUPS,this.parsedAddress=[],this.parsedSubnet=``,this.subnet=`/32`,this.subnetMask=32,this.v4=!0,this.isCorrect=l,this.isInSubnet=o.isInSubnet,this.isHostInSubnet=o.isHostInSubnet,this.address=e;let t=s.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>s.BITS)throw new c.AddressError(`Invalid subnet mask.`);e=e.replace(s.RE_SUBNET_STRING,``)}let n=s.GROUPS*4-1;if(e.length>n)throw new c.AddressError(`IPv4 addresses are at most ${n} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(e){let t=e.split(`.`);if(t.some(e=>/^0\d/.test(e)))throw new c.AddressError(`IPv4 addresses can't have leading zeroes.`);if(!e.match(s.RE_ADDRESS))throw new c.AddressError(`Invalid IPv4 address.`);return t}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(`.`)}static fromAddressAndMask(t,n){let r=o.prefixLengthFromMask(new e(n).bigInt(),s.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(s.BITS))-BigInt(1),i=o.prefixLengthFromMask(r,s.BITS);return new e(`${t}/${i}`)}static fromWildcard(t){let n=t.split(`.`);if(n.length!==s.GROUPS)throw new c.AddressError(`Wildcard pattern must have 4 octets`);let r=-1;for(let e=0;e<n.length;e++)if(n[e]===`*`)r===-1&&(r=e);else if(r!==-1)throw new c.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let i=r===-1?0:n.length-r,a=n.map(e=>e===`*`?`0`:e),o=s.BITS-i*8;return new e(`${a.join(`.`)}/${o}`)}static fromHex(t){let n=t.replace(/:/g,``);if(!/^[0-9a-fA-F]{8}$/.test(n))throw new c.AddressError(`IPv4 hex must be exactly 8 hex digits`);let r=[];for(let e=0;e<8;e+=2)r.push(parseInt(n.slice(e,e+2),16));return new e(r.join(`.`))}static fromInteger(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new c.AddressError(`IPv4 integer must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromArpa(t){let n=s.GROUPS*4-1+3+14;if(t.length>n)throw new c.AddressError(`in-addr.arpa names are at most ${n} characters.`);let r=t.replace(/(\.in-addr\.arpa)?\.?$/i,``).split(`.`).reverse().join(`.`);return new e(r)}toHex(){return this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(`:`)}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e=[],t=0;for(;t<s.GROUPS;t+=2)e.push(`${o.stringToPaddedHex(this.parsedAddress[t])}${o.stringToPaddedHex(this.parsedAddress[t+1])}`);return e.join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(``)}`)}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(s.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}offset(t){return e.fromBigInt(o.offsetBigInt(this.bigInt(),t,s.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(o.offsetBigInt(this._endAddress(),1,s.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(s.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(s.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(s.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt(t){if(t<BigInt(0)||t>BigInt(4294967295))throw new c.AddressError(`IPv4 BigInt must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromByteArray(e){return o.assertByteArray(e,4,`IPv4`,0),this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(t){if(t.length!==4)throw new c.AddressError(`IPv4 addresses require exactly 4 bytes`);let n=t.join(`.`);return new e(n)}mask(e){return e===void 0&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}reverseForm(e){e||={};let t=this.correctForm().split(`.`).reverse().join(`.`);return e.omitSuffix?t:`${t}.in-addr.arpa.`}isMulticast(){return this.isHostInSubnet(d)}isPrivate(){return f.some(e=>this.isHostInSubnet(e))}isLoopback(){return this.isHostInSubnet(p)}isLinkLocal(){return this.isHostInSubnet(m)}isUnspecified(){return this.isHostInSubnet(h)}isBroadcast(){return this.isHostInSubnet(g)}isCGNAT(){return this.isHostInSubnet(_)}isDocumentation(){return v.some(e=>this.isHostInSubnet(e))}isBenchmarking(){return this.isHostInSubnet(y)}isReserved(){return this.isHostInSubnet(b)}isGlobal(){return!this.isMulticast()&&o.isGloballyReachable.call(this,x)}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(s.BITS,`0`)),this._binaryZeroPad}groupForV6(){let e=this.parsedAddress;return this.correctForm().replace(s.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(`.`)}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(`.`)}</span>`)}};e.Address4=u;var d=new u(`224.0.0.0/4`),f=[new u(`10.0.0.0/8`),new u(`172.16.0.0/12`),new u(`192.168.0.0/16`)],p=new u(`127.0.0.0/8`),m=new u(`169.254.0.0/16`),h=new u(`0.0.0.0/32`),g=new u(`255.255.255.255/32`),_=new u(`100.64.0.0/10`),v=[new u(`192.0.2.0/24`),new u(`198.51.100.0/24`),new u(`203.0.113.0/24`)],y=new u(`198.18.0.0/15`),b=new u(`240.0.0.0/4`),x=s.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new u(e),reachable:t}))})),kl=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_URL_WITH_PORT=e.RE_URL=e.RE_ZONE_STRING=e.RE_SUBNET_STRING=e.RE_BAD_ADDRESS=e.RE_BAD_CHARACTERS=e.TYPES=e.SCOPES=e.GROUPS=e.BITS=void 0,e.BITS=128,e.GROUPS=8,e.SCOPES={0:`Reserved`,1:`Interface local`,2:`Link local`,4:`Admin local`,5:`Site local`,8:`Organization local`,14:`Global`,15:`Reserved`},e.TYPES={"ff01::1/128":`Multicast (All nodes on this interface)`,"ff01::2/128":`Multicast (All routers on this interface)`,"ff02::1/128":`Multicast (All nodes on this link)`,"ff02::2/128":`Multicast (All routers on this link)`,"ff05::2/128":`Multicast (All routers in this site)`,"ff02::5/128":`Multicast (OSPFv3 AllSPF routers)`,"ff02::6/128":`Multicast (OSPFv3 AllDR routers)`,"ff02::9/128":`Multicast (RIP routers)`,"ff02::a/128":`Multicast (EIGRP routers)`,"ff02::d/128":`Multicast (PIM routers)`,"ff02::16/128":`Multicast (MLDv2 reports)`,"ff01::fb/128":`Multicast (mDNSv6)`,"ff02::fb/128":`Multicast (mDNSv6)`,"ff05::fb/128":`Multicast (mDNSv6)`,"ff02::1:2/128":`Multicast (All DHCP servers and relay agents on this link)`,"ff05::1:2/128":`Multicast (All DHCP servers and relay agents in this site)`,"ff02::1:3/128":`Multicast (All DHCP servers on this link)`,"ff05::1:3/128":`Multicast (All DHCP servers in this site)`,"::/128":`Unspecified`,"::1/128":`Loopback`,"::ffff:0:0/96":`IPv4-mapped`,"ff00::/8":`Multicast`,"fe80::/10":`Link-local unicast`,"fc00::/7":`Unique local`,"2001::/32":`Teredo`,"2001:2::/48":`Benchmarking`,"2002::/16":`6to4`,"2001:db8::/32":`Documentation`,"3fff::/20":`Documentation`,"100::/64":`Discard-only`,"fec0::/10":`Site-local unicast (deprecated)`,"::/96":`IPv4-compatible (deprecated)`,"64:ff9b::/96":`NAT64 (well-known)`,"64:ff9b:1::/48":`NAT64 (local-use)`},e.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,e.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,e.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,e.RE_ZONE_STRING=/%.*$/,e.RE_URL=/^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i,e.RE_URL_WITH_PORT=/^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i,e.SPECIAL_PURPOSE=[[`::1/128`,`Loopback Address`,!1],[`::/128`,`Unspecified Address`,!1],[`::ffff:0:0/96`,`IPv4-mapped Address`,!1],[`64:ff9b::/96`,`IPv4-IPv6 Translat.`,!0],[`64:ff9b:1::/48`,`IPv4-IPv6 Translat.`,!1],[`100::/64`,`Discard-Only Address Block`,!1],[`100:0:0:1::/64`,`Dummy IPv6 Prefix`,!1],[`2001::/23`,`IETF Protocol Assignments`,!1],[`2001::/32`,`TEREDO`,!1],[`2001:1::1/128`,`Port Control Protocol Anycast`,!0],[`2001:1::2/128`,`Traversal Using Relays around NAT Anycast`,!0],[`2001:1::3/128`,`DNS-SD Service Registration Protocol Anycast`,!0],[`2001:2::/48`,`Benchmarking`,!1],[`2001:3::/32`,`AMT`,!0],[`2001:4:112::/48`,`AS112-v6`,!0],[`2001:10::/28`,`Deprecated (previously ORCHID)`,null],[`2001:20::/28`,`ORCHIDv2`,!0],[`2001:30::/28`,`Drone Remote ID Protocol Entity Tags (DETs) Prefix`,!0],[`2001:db8::/32`,`Documentation`,!1],[`2002::/16`,`6to4`,!1],[`2620:4f:8000::/48`,`Direct Delegation AS112 Service`,!0],[`3fff::/20`,`Documentation`,!1],[`5f00::/16`,`Segment Routing (SRv6) SIDs`,!1],[`fc00::/7`,`Unique-Local`,!1],[`fe80::/10`,`Link-Local Unicast`,!1]]})),Al=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.escapeHtml=t,e.spanAllZeroes=n,e.spanAll=r,e.spanLeadingZeroes=a,e.simpleGroup=o;function t(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function n(e){return t(e).replace(/(0+)/g,`<span class="zero">$1</span>`)}function r(e,r=0){return e.split(``).map((e,i)=>`<span class="digit value-${t(e)} position-${i+r}">${n(e)}</span>`).join(``)}function i(e){return t(e).replace(/^(0+)/,`<span class="zero">$1</span>`)}function a(e){return e.split(`:`).map(e=>i(e)).join(`:`)}function o(e,t=0){return e.split(`:`).map((e,n)=>/group-v4/.test(e)?e:`<span class="hover-group group-${n+t}">${i(e)}</span>`)}})),jl=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.ADDRESS_BOUNDARY=void 0,e.groupPossibilities=s,e.padGroup=c,e.simpleRegularExpression=l,e.possibleElisions=u;var o=a(kl());function s(e){return`(${e.join(`|`)})`}function c(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}e.ADDRESS_BOUNDARY=`[^A-Fa-f0-9:]`;function l(e){let t=[];e.forEach((e,n)=>{parseInt(e,16)===0&&t.push(n)});let n=t.map(t=>e.map((e,n)=>{if(n===t){let t=n===0||n===o.GROUPS-1?`:`:``;return s([c(e),t])}return c(e)}).join(`:`));return n.push(e.map(c).join(`:`)),s(n)}function u(e,t,n){let r=t?``:`:`,i=n?``:`:`,a=[];!t&&!n&&a.push(`::`),t&&n&&a.push(``),(n&&!t||!n&&t)&&a.push(`:`),a.push(`${r}(:0{1,4}){1,${e-1}}`),a.push(`(0{1,4}:){1,${e-1}}${i}`),a.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let t=1;t<e-1;t++)for(let n=1;n<e-t;n++)a.push(`(0{1,4}:){${n}}:(0{1,4}:){${e-n-t-1}}0{1,4}`);return s(a)}})),Ml=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.Address6=void 0;var o=a(El()),s=a(Dl()),c=a(kl()),l=a(Al()),u=Ol(),d=jl(),f=Tl(),p=El(),m=o.isCorrect(c.BITS);function h(e){if(!e)throw Error(`Assertion failed.`)}function g(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,`$1,$2`);return e}function _(e){return e=e.replace(/^(0{1,})([1-9]+)$/,`<span class="parse-error">$1</span>$2`),e=e.replace(/^(0{1,})(0)$/,`<span class="parse-error">$1</span>$2`),e}function v(e,t){let n=[],r=[],i=0;for(;i<e.length;i++)i<t[0]?n.push(e[i]):i>t[1]&&r.push(e[i]);return n.concat([`compact`]).concat(r)}function y(e){return parseInt(e,16).toString(16).padStart(4,`0`)}function b(e){return e&255}var x=class e{constructor(e,t){this.addressMinusSuffix=``,this.parsedSubnet=``,this.subnet=`/128`,this.subnetMask=128,this.v4=!1,this.zone=``,this.isInSubnet=o.isInSubnet,this.isHostInSubnet=o.isHostInSubnet,this.isCorrect=m,this.groups=t===void 0?c.GROUPS:t,this.address=e;let n=c.RE_SUBNET_STRING.exec(e);if(n){if(this.parsedSubnet=n[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>c.BITS)throw new f.AddressError(`Invalid subnet mask.`);e=e.replace(c.RE_SUBNET_STRING,``)}if(/\//.test(e))throw new f.AddressError(`Invalid subnet mask.`);let r=e.indexOf(`%`);r!==-1&&/^.*$/.test(e.slice(r))&&(this.zone=e.slice(r),e=e.slice(0,r));let i=this.groups*5+5;if(e.length>i)throw new f.AddressError(`IPv6 addresses are at most ${i} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInt(t){if(t<BigInt(0)||t>(BigInt(1)<<BigInt(c.BITS))-BigInt(1))throw new f.AddressError(`IPv6 BigInt must be in the range 0 to 2**128 - 1`);let n=t.toString(16).padStart(32,`0`),r=[];for(let e=0;e<c.GROUPS;e++)r.push(n.slice(e*4,(e+1)*4));return new e(r.join(`:`))}static fromURL(t){let n,r=null,i,a,o=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``);if(o.indexOf(`[`)!==-1&&o.indexOf(`]:`)!==-1){if(a=`failed to parse address with port`,i=c.RE_URL_WITH_PORT.exec(o),i===null)return{error:a,address:null,port:null};n=i[1],r=i[2]}else{if(a=`failed to parse address from URL`,i=c.RE_URL.exec(o),i===null)return{error:a,address:null,port:null};n=i[1]??i[2]}r?(r=parseInt(r,10),(r<0||r>65535)&&(r=null)):r=null;let s;try{s=new e(n)}catch{return{error:a,address:null,port:null}}return{address:s,port:r}}static fromAddressAndMask(t,n){let r=o.prefixLengthFromMask(new e(n).bigInt(),c.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(c.BITS))-BigInt(1),i=o.prefixLengthFromMask(r,c.BITS);return new e(`${t}/${i}`)}static fromWildcard(t){if(t.includes(`%`)||t.includes(`/`))throw new f.AddressError(`Wildcard pattern must not include a zone or CIDR suffix`);let n=t.split(`::`);if(n.length>2)throw new f.AddressError(`Wildcard pattern cannot contain more than one '::'`);let r;if(n.length===2){let e=n[0]===``?[]:n[0].split(`:`),t=n[1]===``?[]:n[1].split(`:`),i=c.GROUPS-e.length-t.length;if(i<1)throw new f.AddressError(`Wildcard pattern with '::' has too many groups`);r=[...e,...Array(i).fill(`0`),...t]}else r=t.split(`:`);if(r.length!==c.GROUPS)throw new f.AddressError(`Wildcard pattern must have 8 groups`);let i=-1;for(let e=0;e<r.length;e++)if(r[e]===`*`)i===-1&&(i=e);else if(i!==-1)throw new f.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let a=i===-1?0:r.length-i,o=r.map(e=>e===`*`?`0`:e),s=c.BITS-a*16;return new e(`${o.join(`:`)}/${s}`)}static fromAddress4(t){let n=new u.Address4(t),r=c.BITS-(s.BITS-n.subnetMask);return new e(`::ffff:${n.correctForm()}/${r}`)}static fromArpa(t){let n=t.replace(/(\.ip6\.arpa)?\.?$/i,``);if(!/^[0-9a-f](\.[0-9a-f]){0,31}$/i.test(n))throw new f.AddressError(`Invalid 'ip6.arpa' form.`);let r=n.split(`.`).reverse(),i=r.length*4,a=r.join(``).padEnd(32,`0`),o=[];for(let e=0;e<c.GROUPS;e++)o.push(a.slice(e*4,(e+1)*4));return new e(`${o.join(`:`)}/${i}`)}microsoftTranscription(){return`${this.correctForm().replace(/:/g,`-`)}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let t=c.BITS-this.subnetMask-Math.abs(e-c.BITS);return t<0?`0`:g((BigInt(`2`)**BigInt(t)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(c.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(c.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}offset(t){return e.fromBigInt(o.offsetBigInt(this.bigInt(),t,c.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(o.offsetBigInt(this._endAddress(),1,c.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(c.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(c.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let e=this.getType();return e===`Multicast`||e.startsWith(`Multicast `)?c.SCOPES[parseInt(this.getBits(12,16).toString(10),10)]||`Unknown`:e===`Link-local unicast`||e===`Loopback`?`Link local`:e===`Unspecified`?`Unknown`:`Global`}getType(){for(let e=0;e<S.length;e++){let t=S[e];if(this.isHostInSubnet(t[0]))return t[1]}return`Global unicast`}getBits(e,t){return BigInt(`0b${this.getBitsBase2(e,t)}`)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}getBitsBase16(e,t){let n=t-e;if(n%4!=0)throw Error(`Length of bits to retrieve must be divisible by four`);return this.getBits(e,t).toString(16).padStart(n/4,`0`)}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,c.BITS)}reverseForm(e){e||={};let t=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,``).split(``).slice(0,t).reverse().join(`.`);return t>0?e.omitSuffix?n:`${n}.ip6.arpa.`:e.omitSuffix?``:`ip6.arpa.`}correctForm(){let e,t=[],n=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let t=parseInt(this.parsedAddress[e],16);t===0&&n++,t!==0&&n>0&&(n>1&&r.push([e-n,e-1]),n=0)}n>1&&r.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=i.indexOf(Math.max(...i));t=v(this.parsedAddress,r[e])}else t=this.parsedAddress;for(e=0;e<t.length;e++)t[e]!==`compact`&&(t[e]=parseInt(t[e],16).toString(16));let a=t.join(`:`);return a=a.replace(/^compact$/,`::`),a=a.replace(/(^compact)|(compact$)/,`:`),a=a.replace(/compact/,``),a}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(c.BITS,`0`)),this._binaryZeroPad}parse4in6(e){if(e.indexOf(`.`)===-1)return e;let t=e.split(`:`),n=t.slice(-1)[0],r=n.split(`.`);if(r.length===s.GROUPS&&r.every(e=>/^\d{1,3}$/.test(e))&&r.some(e=>/^0\d/.test(e))){let e=r.map(_).join(`.`),n=t.slice(0,-1).map(l.escapeHtml).join(`:`),i=t.length>1?`:`:``;throw new f.AddressError(`IPv4 addresses can't have leading zeroes.`,`${n}${i}${e}`)}let i=n.match(s.RE_ADDRESS);if(i){this.parsedAddress4=i[0];let n=this.subnetMask>=96?`/${this.subnetMask-96}`:``;this.address4=new u.Address4(`${this.parsedAddress4}${n}`),this.v4=!0,t[t.length-1]=this.address4.toGroup6(),e=t.join(`:`)}return e}parse(e){e=this.parse4in6(e);let t=e.match(c.RE_BAD_CHARACTERS);if(t)throw new f.AddressError(`Bad character${t.length>1?`s`:``} detected in address: ${t.join(``)}`,e.replace(c.RE_BAD_CHARACTERS,`<span class="parse-error">$1</span>`));let n=e.match(c.RE_BAD_ADDRESS);if(n)throw new f.AddressError(`Address failed regex: ${n.join(``)}`,e.replace(c.RE_BAD_ADDRESS,`<span class="parse-error">$1</span>`));let r=[],i=e.split(`::`);if(i.length===2){let e=i[0].split(`:`),t=i[1].split(`:`);e.length===1&&e[0]===``&&(e=[]),t.length===1&&t[0]===``&&(t=[]);let n=this.groups-(e.length+t.length);if(!n)throw new f.AddressError(`Error parsing groups`);this.elidedGroups=n,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<n;e++)r.push(`0`);r=r.concat(t)}else if(i.length===1)r=e.split(`:`),this.elidedGroups=0;else throw new f.AddressError(`Too many :: groups found`);if(r=r.map(e=>parseInt(e,16).toString(16)),r.length!==this.groups)throw new f.AddressError(`Incorrect number of groups found`);return r}canonicalForm(){return this.parsedAddress.map(y).join(`:`)}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,`0`)).join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(y).join(``)}`)}to4(){let e=this.binaryZeroPad().split(``),t=BigInt(`0b${e.slice(96,128).join(``)}`).toString(16).padStart(8,`0`);if(this.subnetMask>=96){let e=this.subnetMask-96,n=[];for(let e=0;e<8;e+=2)n.push(parseInt(t.slice(e,e+2),16));return new u.Address4(`${n.join(`.`)}/${e}`)}return u.Address4.fromHex(t)}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(`:`),6).correctForm(),r=``;return/:$/.test(n)||(r=`:`),n+r+t.correctForm()}inspectTeredo(){let e=this.getBitsBase16(0,32),t=(this.getBits(80,96)^BigInt(`0xffff`)).toString(),n=u.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),i=u.Address4.fromHex((r^BigInt(`0xffffffff`)).toString(16).padStart(8,`0`)),a=this.getBitsBase2(64,80),o=(0,p.testBit)(a,15),s=(0,p.testBit)(a,14),c=(0,p.testBit)(a,8),l=(0,p.testBit)(a,9),d=BigInt(`0b${a.slice(2,6)+a.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:n.address,client4:i.address,flags:a,coneNat:o,microsoft:{reserved:s,universalLocal:l,groupIndividual:c,nonce:d},udpPort:t}}inspect6to4(){let e=this.getBitsBase16(0,16),t=u.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:t.address}}to6to4(){if(!this.is4())return null;let t=[`2002`,this.getBitsBase16(96,112),this.getBitsBase16(112,128),``,`/16`].join(`:`);return new e(t)}static fromAddress4Nat64(t,n=`64:ff9b::/96`){let r=new u.Address4(t),i=new e(n),a=i.subnetMask;if(a!==32&&a!==40&&a!==48&&a!==56&&a!==64&&a!==96)throw new f.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);let o=i.binaryZeroPad(),s=r.binaryZeroPad(),c;if(a===96)c=o.slice(0,96)+s;else{let e=64-a;c=[o.slice(0,a),s.slice(0,e),`00000000`,s.slice(e),`0`.repeat(56-(32-e))].join(``)}let l=BigInt(`0b${c}`).toString(16).padStart(32,`0`),d=[];for(let e=0;e<8;e++)d.push(l.slice(e*4,(e+1)*4));return new e(d.join(`:`))}toAddress4Nat64(t=`64:ff9b::/96`){let n=new e(t),r=n.subnetMask;if(r!==32&&r!==40&&r!==48&&r!==56&&r!==64&&r!==96)throw new f.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);if(!this.isHostInSubnet(n))return null;let i=this.binaryZeroPad(),a;if(r===96)a=i.slice(96,128);else{let e=64-r;a=i.slice(r,r+e)+i.slice(72,72+(32-e))}let o=[];for(let e=0;e<4;e++)o.push(parseInt(a.slice(e*8,(e+1)*8),2).toString());return new u.Address4(o.join(`.`))}toByteArray(){let e=this.bigInt().toString(16).padStart(c.BITS/4,`0`),t=[];for(let n=0,r=e.length;n<r;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}toUnsignedByteArray(){return this.toByteArray().map(b)}static fromByteArray(e){return o.assertByteArray(e,16,`IPv6`,-128),this.fromUnsignedByteArray(e.map(b))}static fromUnsignedByteArray(t){o.assertByteArray(t,16,`IPv6`,0);let n=BigInt(`256`),r=BigInt(`0`),i=BigInt(`1`);for(let e=t.length-1;e>=0;e--)r+=i*BigInt(t[e].toString(10)),i*=n;return e.fromBigInt(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let e=this.embeddedIPv4();return e?e.isLinkLocal():this.isHostInSubnet(E)}isMulticast(){let e=this.embeddedIPv4();if(e)return e.isMulticast();let t=this.getType();return t===`Multicast`||t.startsWith(`Multicast `)}is4(){return this.v4}isMapped4(){return this.isHostInSubnet(j)}embeddedIPv4(){return this.isMapped4()||this.isHostInSubnet(M)?this.to4():null}isTeredo(){return this.isHostInSubnet(C)}is6to4(){return this.isHostInSubnet(w)}isLoopback(){let e=this.embeddedIPv4();return e?e.isLoopback():this.getType()===`Loopback`}isULA(){return this.isHostInSubnet(T)}isPrivate(){let e=this.embeddedIPv4();return e?e.isPrivate():this.isULA()||this.isHostInSubnet(N)}isCGNAT(){let e=this.embeddedIPv4();return e?e.isCGNAT():!1}isBroadcast(){let e=this.embeddedIPv4();return e?e.isBroadcast():!1}isUnspecified(){let e=this.embeddedIPv4();return e?e.isUnspecified():this.getType()===`Unspecified`}isDocumentation(){return D.some(e=>this.isHostInSubnet(e))}isBenchmarking(){let e=this.embeddedIPv4();return e?e.isBenchmarking():this.isHostInSubnet(O)}isGlobal(){let e=this.embeddedIPv4();return e?e.isGlobal():this.isHostInSubnet(k)&&o.isGloballyReachable.call(this,A)}href(e){return e=e===void 0?``:`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||={},e.className===void 0&&(e.className=``),e.prefix===void 0&&(e.prefix=`/#address=`),e.v4===void 0&&(e.v4=!1);let t=this.correctForm;e.v4&&(t=this.to4in6);let n=t.call(this),r=l.escapeHtml(`${e.prefix}${n}`),i=l.escapeHtml(n);return e.className?`<a href="${r}" class="${l.escapeHtml(e.className)}">${i}</a>`:`<a href="${r}">${i}</a>`}group(){if(this.elidedGroups===0)return l.simpleGroup(this.addressMinusSuffix).join(`:`);h(typeof this.elidedGroups==`number`),h(typeof this.elisionBegin==`number`);let e=[],[t,n]=this.addressMinusSuffix.split(`::`);t.length?e.push(...l.simpleGroup(t)):e.push(``);let r=[`hover-group`];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(` `)}"></span>`),n.length?e.push(...l.simpleGroup(n,this.elisionEnd)):e.push(``),this.is4()&&(h(this.address4 instanceof u.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(`:`)}regularExpressionString(t=!1){let n=[],r=new e(this.correctForm());if(r.elidedGroups===0)n.push((0,d.simpleRegularExpression)(r.parsedAddress));else if(r.elidedGroups===c.GROUPS)n.push((0,d.possibleElisions)(c.GROUPS));else{let e=r.address.split(`::`);e[0].length&&n.push((0,d.simpleRegularExpression)(e[0].split(`:`))),h(typeof r.elidedGroups==`number`),n.push((0,d.possibleElisions)(r.elidedGroups,e[0].length!==0,e[1].length!==0)),e[1].length&&n.push((0,d.simpleRegularExpression)(e[1].split(`:`))),n=[n.join(`:`)]}return t||(n=[`(?=^|`,d.ADDRESS_BOUNDARY,`|[^\\w\\:])(`,...n,`)(?=[^\\w\\:]|`,d.ADDRESS_BOUNDARY,`|$)`]),n.join(``)}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),`i`)}};e.Address6=x;var S=Object.keys(c.TYPES).map(e=>[new x(e),c.TYPES[e]]),C=new x(`2001::/32`),w=new x(`2002::/16`),T=new x(`fc00::/7`),E=new x(`fe80::/10`),D=[new x(`2001:db8::/32`),new x(`3fff::/20`)],O=new x(`2001:2::/48`),k=new x(`2000::/3`),A=c.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new x(e),reachable:t})),j=new x(`::ffff:0:0/96`),M=new x(`64:ff9b::/96`),N=new x(`64:ff9b:1::/48`)})),Nl=(/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.v6=e.AddressError=e.Address6=e.Address4=void 0;var o=Ol();Object.defineProperty(e,"Address4",{enumerable:!0,get:function(){return o.Address4}});var s=Ml();Object.defineProperty(e,"Address6",{enumerable:!0,get:function(){return s.Address6}});var c=Tl();Object.defineProperty(e,"AddressError",{enumerable:!0,get:function(){return c.AddressError}}),e.v6={helpers:a(Al())}})))(),Pl=new TextEncoder,Fl=e=>Nl.Address4.isValid(e),Il=e=>Nl.Address6.isValid(e),Ll=e=>Fl(e)?4:Il(e)?6:0,Rl=(...e)=>{if(typeof e[0]==`string`)throw Error(`FKN WebVPN does not support IPC connections`);let t=typeof e.at(-1)==`function`?e.at(-1):void 0;return e[0]&&typeof e[0]==`object`?{...e[0],callback:t}:{port:typeof e[0]==`function`?0:e[0]??0,host:typeof e[1]==`string`?e[1]:void 0,callback:t}},zl=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=typeof e[0]==`function`?0:e[0]??0,r=typeof e[1]==`string`?e[1]:void 0;return typeof e[0]==`object`?{...e[0],address:e[0].address??r,port:e[0].port??0,callback:t}:{address:r,port:n,callback:t}},Bl=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0];if(typeof e[2]==`number`)return{message:n,hasRange:!0,offset:e[1],length:e[2],port:typeof e[3]==`number`?e[3]:0,address:typeof e[4]==`string`?e[4]:void 0,callback:t};{let r=typeof e[1]==`number`?e[1]:0,i=typeof e[2]==`string`?e[2]:void 0;return{message:n,hasRange:!1,offset:0,length:n.length,port:r,address:i,callback:t}}},Vl=`webvpn-udp-port-ack`,Hl=`read ECONNRESET`,Ul=()=>Object.assign(/* @__PURE__ */ Error(Hl),{code:`ECONNRESET`,errno:-104,syscall:`read`}),Wl={ECONNREFUSED:-111,ETIMEDOUT:-110,EHOSTUNREACH:-113,ENETUNREACH:-101},Gl=(e,t,n)=>{let r=e===`ENETUNREACH`?` - Local (${t.includes(`:`)?`::`:`0.0.0.0`}:0)`:``;return Object.assign(/* @__PURE__ */ Error(`connect ${e} ${t}:${n}${r}`),{errno:Wl[e],code:e,syscall:`connect`,address:t,port:n})},Kl=e=>Object.assign(/* @__PURE__ */ Error(`getaddrinfo ENOTFOUND ${e}`),{errno:-3008,code:`ENOTFOUND`,syscall:`getaddrinfo`,hostname:e}),ql=/^connect (ECONNREFUSED|ETIMEDOUT|EHOSTUNREACH|ENETUNREACH) (\S+):(\d+)(?: - Local \(\S+\))?$/,Jl=/^getaddrinfo ENOTFOUND (\S+)$/,Yl=e=>{let t=e?.message;if(typeof t!=`string`)return e;if(t===`read ECONNRESET`)return Ul();let n=ql.exec(t);if(n)return Gl(n[1],n[2],Number(n[3]));let r=Jl.exec(t);return r?Kl(r[1]):e},Xl=/* @__PURE__ */ e(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=/* @__PURE__ */ Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=/* @__PURE__ */ Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),Zl=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Object.create==`function`?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),Ql,$l=n((()=>{Ql=globalThis||self})),eu=/* @__PURE__ */ e(((e,t)=>{t.exports=Xl().EventEmitter})),tu=/* @__PURE__ */ e(((e,t)=>{t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,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 a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}})),nu=/* @__PURE__ */ e(((e,t)=>{var n=tu();t.exports=function(){return n()&&!!Symbol.toStringTag}})),ru=/* @__PURE__ */ e(((e,t)=>{t.exports=Object})),iu=/* @__PURE__ */ e(((e,t)=>{t.exports=Error})),au=/* @__PURE__ */ e(((e,t)=>{t.exports=EvalError})),ou=/* @__PURE__ */ e(((e,t)=>{t.exports=RangeError})),su=/* @__PURE__ */ e(((e,t)=>{t.exports=ReferenceError})),cu=/* @__PURE__ */ e(((e,t)=>{t.exports=SyntaxError})),lu=/* @__PURE__ */ e(((e,t)=>{t.exports=TypeError})),uu=/* @__PURE__ */ e(((e,t)=>{t.exports=URIError})),du=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.abs})),fu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.floor})),pu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.max})),mu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.min})),hu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.pow})),gu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.round})),_u=/* @__PURE__ */ e(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),vu=/* @__PURE__ */ e(((e,t)=>{var n=_u();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),yu=/* @__PURE__ */ e(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),bu=/* @__PURE__ */ e(((e,t)=>{var n=yu();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),xu=/* @__PURE__ */ e(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),Su=/* @__PURE__ */ e(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=tu();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),Cu=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),wu=/* @__PURE__ */ e(((e,t)=>{t.exports=ru().getPrototypeOf||null})),Tu=/* @__PURE__ */ e(((e,t)=>{var n=Object.prototype.toString,r=Math.max,i=`[object Function]`,a=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},o=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},s=function(e,t){for(var n=``,r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};t.exports=function(e){var t=this;if(typeof t!=`function`||n.apply(t)!==i)throw TypeError(`Function.prototype.bind called on incompatible `+t);for(var c=o(arguments,1),l,u=function(){if(this instanceof l){var n=t.apply(this,a(c,arguments));return Object(n)===n?n:this}return t.apply(e,a(c,arguments))},d=r(0,t.length-c.length),f=[],p=0;p<d;p++)f[p]=`$`+p;if(l=Function(`binder`,`return function (`+s(f,`,`)+`){ return binder.apply(this,arguments); }`)(u),t.prototype){var m=function(){};m.prototype=t.prototype,l.prototype=new m,m.prototype=null}return l}})),Eu=/* @__PURE__ */ e(((e,t)=>{var n=Tu();t.exports=Function.prototype.bind||n})),Du=/* @__PURE__ */ e(((e,t)=>{t.exports=Function.prototype.call})),Ou=/* @__PURE__ */ e(((e,t)=>{t.exports=Function.prototype.apply})),ku=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),Au=/* @__PURE__ */ e(((e,t)=>{var n=Eu(),r=Ou(),i=Du();t.exports=ku()||n.call(i,r)})),ju=/* @__PURE__ */ e(((e,t)=>{var n=Eu(),r=lu(),i=Du(),a=Au();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),Mu=/* @__PURE__ */ e(((e,t)=>{var n=ju(),r=bu(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`&&function(e){return s(e==null?e:o(e))}})),Nu=/* @__PURE__ */ e(((e,t)=>{var n=Cu(),r=wu(),i=Mu();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null})),Pu=/* @__PURE__ */ e(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=Eu().call(n,r)})),Fu=/* @__PURE__ */ e(((e,t)=>{var n,r=ru(),i=iu(),a=au(),o=ou(),s=su(),c=cu(),l=lu(),u=uu(),d=du(),f=fu(),p=pu(),m=mu(),h=hu(),g=gu(),_=vu(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=bu(),x=xu(),S=function(){throw new l},C=b?function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}}():S,w=Su()(),T=Nu(),E=wu(),D=Cu(),O=Ou(),k=Du(),A={},j=typeof Uint8Array>`u`||!T?n:T(Uint8Array),M={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":A,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T((/* @__PURE__ */ new Map())[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T((/* @__PURE__ */ new Set())[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":j,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":k,"%Function.prototype.apply%":O,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":E,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":D};if(T)try{null.error}catch(e){M[`%Error.prototype%`]=T(T(e))}var N=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return M[t]=n,n},ee={__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`]},te=Eu(),P=Pu(),F=te.call(k,Array.prototype.concat),ne=te.call(O,Array.prototype.splice),re=te.call(k,String.prototype.replace),I=te.call(k,String.prototype.slice),L=te.call(k,RegExp.prototype.exec),ie=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ae=/\\(\\)?/g,oe=function(e){var t=I(e,0,1),n=I(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return re(e,ie,function(e,t,n,i){r[r.length]=n?re(i,ae,`$1`):t||e}),r},se=function(e,t){var n=e,r;if(P(ee,n)&&(r=ee[n],n=`%`+r[0]+`%`),P(M,n)){var i=M[n];if(i===A&&(i=N(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(L(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=oe(e),r=n.length>0?n[0]:``,i=se(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],ne(n,F([0,1],u)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],m=I(p,0,1),h=I(p,-1);if((m===`"`||m===`'`||m==="`"||h===`"`||h===`'`||h==="`")&&m!==h)throw new c(`property names with quotes must have matching quotes`);if(p!==`constructor`&&f||(s=!0),r+=`.`+p,a=`%`+r+`%`,P(M,a))o=M[a];else if(o!=null){if(!(p in o)){if(!t)throw new l(`base intrinsic for `+e+` exists, but the property is not available.`);return}if(b&&d+1>=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=P(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),Iu=/* @__PURE__ */ e(((e,t)=>{var n=Fu(),r=ju(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}})),Lu=/* @__PURE__ */ e(((e,t)=>{var n=nu()(),r=Iu()(`Object.prototype.toString`),i=function(e){return n&&e&&typeof e==`object`&&Symbol.toStringTag in e?!1:r(e)===`[object Arguments]`},a=function(e){return i(e)?!0:typeof e==`object`&&!!e&&`length`in e&&typeof e.length==`number`&&e.length>=0&&r(e)!==`[object Array]`&&`callee`in e&&r(e.callee)===`[object Function]`},o=function(){return i(arguments)}();i.isLegacyArguments=a,t.exports=o?i:a})),Ru=/* @__PURE__ */ e(((e,t)=>{var n=Iu(),r=nu()(),i=Pu(),a=bu(),o;if(r){var s=n(`RegExp.prototype.exec`),c={},l=function(){throw c},u={toString:l,valueOf:l};typeof Symbol.toPrimitive==`symbol`&&(u[Symbol.toPrimitive]=l),o=function(e){if(!e||typeof e!=`object`)return!1;var t=a(e,`lastIndex`);if(!(t&&i(t,`value`)))return!1;try{s(e,u)}catch(e){return e===c}}}else{var d=n(`Object.prototype.toString`),f=`[object RegExp]`;o=function(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:d(e)===f}}t.exports=o})),zu=/* @__PURE__ */ e(((e,t)=>{var n=Iu(),r=Ru(),i=n(`RegExp.prototype.exec`),a=lu();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),Bu=/* @__PURE__ */ e(((e,t)=>{var n=Iu(),r=zu()(/^\s*(?:function)?\*/),i=nu()(),a=Nu(),o=n(`Object.prototype.toString`),s=n(`Function.prototype.toString`),c=function(){if(!i)return!1;try{return Function(`return function*() {}`)()}catch{}},l;t.exports=function(e){if(typeof e!=`function`)return!1;if(r(s(e)))return!0;if(!i)return o(e)===`[object GeneratorFunction]`;if(!a)return!1;if(l===void 0){var t=c();l=t?a(t):!1}return a(e)===l}})),Vu=/* @__PURE__ */ e(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},"length",{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return!s(e)&&(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Hu=/* @__PURE__ */ e(((e,t)=>{var n=Vu(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,a=function(e,t,n){for(var r=0,a=e.length;r<a;r++)i.call(e,r)&&(n==null?t(e[r],r,e):t.call(n,e[r],r,e))},o=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n==null?t(e.charAt(r),r,e):t.call(n,e.charAt(r),r,e)},s=function(e,t,n){for(var r in e)i.call(e,r)&&(n==null?t(e[r],r,e):t.call(n,e[r],r,e))};function c(e){return r.call(e)===`[object Array]`}t.exports=function(e,t,r){if(!n(t))throw TypeError(`iterator must be a function`);var i;arguments.length>=3&&(i=r),c(e)?a(e,t,i):typeof e==`string`?o(e,t,i):s(e,t,i)}})),Uu=/* @__PURE__ */ e(((e,t)=>{t.exports=[`Float16Array`,`Float32Array`,`Float64Array`,`Int8Array`,`Int16Array`,`Int32Array`,`Uint8Array`,`Uint8ClampedArray`,`Uint16Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`]})),Wu=/* @__PURE__ */ e(((e,t)=>{$l();var n=Uu(),r=typeof globalThis>`u`?Ql:globalThis;t.exports=function(){for(var e=[],t=0;t<n.length;t++)typeof r[n[t]]==`function`&&(e[e.length]=n[t]);return e}})),Gu=/* @__PURE__ */ e(((e,t)=>{var n=xu(),r=cu(),i=lu(),a=bu();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}})),Ku=/* @__PURE__ */ e(((e,t)=>{var n=xu(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r})),qu=/* @__PURE__ */ e(((e,t)=>{var n=Fu(),r=Gu(),i=Ku()(),a=bu(),o=lu(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}})),Ju=/* @__PURE__ */ e(((e,t)=>{var n=Eu(),r=Ou(),i=Au();t.exports=function(){return i(n,r,arguments)}})),Yu=/* @__PURE__ */ e(((e,t)=>{var n=qu(),r=xu(),i=ju(),a=Ju();t.exports=function(e){var t=i(arguments),r=e.length-(arguments.length-1);return n(t,1+(r>0?r:0),!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a})),Xu=/* @__PURE__ */ e(((e,t)=>{$l();var n=Hu(),r=Wu(),i=Yu(),a=Iu(),o=bu(),s=Nu(),c=a(`Object.prototype.toString`),l=nu()(),u=typeof globalThis>`u`?Ql:globalThis,d=r(),f=a(`String.prototype.slice`),p=a(`Array.prototype.indexOf`,!0)||function(e,t){for(var n=0;n<e.length;n+=1)if(e[n]===t)return n;return-1},m={__proto__:null};l&&o&&s?n(d,function(e){var t=new u[e];if(Symbol.toStringTag in t&&s){var n=s(t),r=o(n,Symbol.toStringTag);!r&&n&&(r=o(s(n),Symbol.toStringTag)),m[`$`+e]=i(r.get)}}):n(d,function(e){var t=new u[e],n=t.slice||t.set;n&&(m[`$`+e]=i(n))});var h=function(e){var t=!1;return n(m,function(n,r){if(!t)try{`$`+n(e)===r&&(t=f(r,1))}catch{}}),t},g=function(e){var t=!1;return n(m,function(n,r){if(!t)try{n(e),t=f(r,1)}catch{}}),t};t.exports=function(e){if(!e||typeof e!=`object`)return!1;if(!l){var t=f(c(e),8,-1);return p(d,t)>-1?t:t===`Object`&&g(e)}return o?h(e):null}})),Zu=/* @__PURE__ */ e(((e,t)=>{var n=Xu();t.exports=function(e){return!!n(e)}})),Qu=/* @__PURE__ */ e((e=>{var t=Lu(),n=Bu(),r=Xu(),i=Zu();function a(e){return e.call.bind(e)}var o=typeof BigInt<`u`,s=typeof Symbol<`u`,c=a(Object.prototype.toString),l=a(Number.prototype.valueOf),u=a(String.prototype.valueOf),d=a(Boolean.prototype.valueOf);if(o)var f=a(BigInt.prototype.valueOf);if(s)var p=a(Symbol.prototype.valueOf);function m(e,t){if(typeof e!=`object`)return!1;try{return t(e),!0}catch{return!1}}e.isArgumentsObject=t,e.isGeneratorFunction=n,e.isTypedArray=i;function h(e){return typeof Promise<`u`&&e instanceof Promise||typeof e==`object`&&!!e&&typeof e.then==`function`&&typeof e.catch==`function`}e.isPromise=h;function g(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):i(e)||re(e)}e.isArrayBufferView=g;function _(e){return r(e)===`Uint8Array`}e.isUint8Array=_;function v(e){return r(e)===`Uint8ClampedArray`}e.isUint8ClampedArray=v;function y(e){return r(e)===`Uint16Array`}e.isUint16Array=y;function b(e){return r(e)===`Uint32Array`}e.isUint32Array=b;function x(e){return r(e)===`Int8Array`}e.isInt8Array=x;function S(e){return r(e)===`Int16Array`}e.isInt16Array=S;function C(e){return r(e)===`Int32Array`}e.isInt32Array=C;function w(e){return r(e)===`Float32Array`}e.isFloat32Array=w;function T(e){return r(e)===`Float64Array`}e.isFloat64Array=T;function E(e){return r(e)===`BigInt64Array`}e.isBigInt64Array=E;function D(e){return r(e)===`BigUint64Array`}e.isBigUint64Array=D;function O(e){return c(e)===`[object Map]`}O.working=typeof Map<`u`&&O(/* @__PURE__ */ new Map);function k(e){return typeof Map>`u`?!1:O.working?O(e):e instanceof Map}e.isMap=k;function A(e){return c(e)===`[object Set]`}A.working=typeof Set<`u`&&A(/* @__PURE__ */ new Set);function j(e){return typeof Set>`u`?!1:A.working?A(e):e instanceof Set}e.isSet=j;function M(e){return c(e)===`[object WeakMap]`}M.working=typeof WeakMap<`u`&&M(/* @__PURE__ */ new WeakMap);function N(e){return typeof WeakMap>`u`?!1:M.working?M(e):e instanceof WeakMap}e.isWeakMap=N;function ee(e){return c(e)===`[object WeakSet]`}ee.working=typeof WeakSet<`u`&&ee(/* @__PURE__ */ new WeakSet);function te(e){return ee(e)}e.isWeakSet=te;function P(e){return c(e)===`[object ArrayBuffer]`}P.working=typeof ArrayBuffer<`u`&&P(/* @__PURE__ */ new ArrayBuffer);function F(e){return typeof ArrayBuffer>`u`?!1:P.working?P(e):e instanceof ArrayBuffer}e.isArrayBuffer=F;function ne(e){return c(e)===`[object DataView]`}ne.working=typeof ArrayBuffer<`u`&&typeof DataView<`u`&&ne(new DataView(/* @__PURE__ */ new ArrayBuffer(1),0,1));function re(e){return typeof DataView>`u`?!1:ne.working?ne(e):e instanceof DataView}e.isDataView=re;var I=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:void 0;function L(e){return c(e)===`[object SharedArrayBuffer]`}function ie(e){return I!==void 0&&(L.working===void 0&&(L.working=L(new I)),L.working?L(e):e instanceof I)}e.isSharedArrayBuffer=ie;function ae(e){return c(e)===`[object AsyncFunction]`}e.isAsyncFunction=ae;function oe(e){return c(e)===`[object Map Iterator]`}e.isMapIterator=oe;function se(e){return c(e)===`[object Set Iterator]`}e.isSetIterator=se;function R(e){return c(e)===`[object Generator]`}e.isGeneratorObject=R;function ce(e){return c(e)===`[object WebAssembly.Module]`}e.isWebAssemblyCompiledModule=ce;function le(e){return m(e,l)}e.isNumberObject=le;function ue(e){return m(e,u)}e.isStringObject=ue;function de(e){return m(e,d)}e.isBooleanObject=de;function fe(e){return o&&m(e,f)}e.isBigIntObject=fe;function pe(e){return s&&m(e,p)}e.isSymbolObject=pe;function me(e){return le(e)||ue(e)||de(e)||fe(e)||pe(e)}e.isBoxedPrimitive=me;function he(e){return typeof Uint8Array<`u`&&(F(e)||ie(e))}e.isAnyArrayBuffer=he,[`isProxy`,`isExternal`,`isModuleNamespaceObject`].forEach(function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw Error(t+` is not supported in userland`)}})})})),$u=/* @__PURE__ */ e(((e,t)=>{t.exports=function(e){return e&&typeof e==`object`&&typeof e.copy==`function`&&typeof e.fill==`function`&&typeof e.readUInt8==`function`}})),ed=/* @__PURE__ */ e((e=>{r();var t=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},n=/%[sdj%]/g;e.format=function(e){if(!C(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(c(arguments[r]));return t.join(` `)}for(var r=1,i=arguments,a=i.length,o=String(e).replace(n,function(e){if(e===`%%`)return`%`;if(r>=a)return e;switch(e){case`%s`:return String(i[r++]);case`%d`:return Number(i[r++]);case`%j`:try{return JSON.stringify(i[r++])}catch{return`[Circular]`}default:return e}}),s=i[r];r<a;s=i[++r])b(s)||!D(s)?o+=` `+s:o+=` `+c(s);return o},e.deprecate=function(t,n){if(i!==void 0&&i.noDeprecation===!0)return t;if(i===void 0)return function(){return e.deprecate(t,n).apply(this,arguments)};var r=!1;function a(){if(!r){if(i.throwDeprecation)throw Error(n);i.traceDeprecation?console.trace(n):console.error(n),r=!0}return t.apply(this,arguments)}return a};var a={},o=/^$/;if(i.env.NODE_DEBUG){var s=i.env.NODE_DEBUG;s=s.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`).replace(/,/g,`$|^`).toUpperCase(),o=RegExp(`^`+s+`$`,`i`)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t]){if(o.test(t)){var n=i.pid;a[t]=function(){var r=e.format.apply(e,arguments);console.error(`%s %d: %s`,t,n,r)}}else a[t]=function(){}}return a[t]};function c(t,n){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(n)?r.showHidden=n:n&&e._extend(r,n),T(r.showHidden)&&(r.showHidden=!1),T(r.depth)&&(r.depth=2),T(r.colors)&&(r.colors=!1),T(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),f(r,t,r.depth)}e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:`cyan`,number:`yellow`,boolean:`yellow`,undefined:`grey`,null:`bold`,string:`green`,date:`magenta`,regexp:`red`};function l(e,t){var n=c.styles[t];return n?`\x1B[`+c.colors[n][0]+`m`+e+`\x1B[`+c.colors[n][1]+`m`:e}function u(e,t){return e}function d(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function f(t,n,r){if(t.customInspect&&n&&A(n.inspect)&&n.inspect!==e.inspect&&!(n.constructor&&n.constructor.prototype===n)){var i=n.inspect(r,t);return C(i)||(i=f(t,i,r)),i}var a=p(t,n);if(a)return a;var o=Object.keys(n),s=d(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(n)),k(n)&&(o.indexOf(`message`)>=0||o.indexOf(`description`)>=0))return m(n);if(o.length===0){if(A(n)){var c=n.name?`: `+n.name:``;return t.stylize(`[Function`+c+`]`,`special`)}if(E(n))return t.stylize(RegExp.prototype.toString.call(n),`regexp`);if(O(n))return t.stylize(Date.prototype.toString.call(n),`date`);if(k(n))return m(n)}var l=``,u=!1,y=[`{`,`}`];if(v(n)&&(u=!0,y=[`[`,`]`]),A(n)&&(l=` [Function`+(n.name?`: `+n.name:``)+`]`),E(n)&&(l=` `+RegExp.prototype.toString.call(n)),O(n)&&(l=` `+Date.prototype.toUTCString.call(n)),k(n)&&(l=` `+m(n)),o.length===0&&(!u||n.length==0))return y[0]+l+y[1];if(r<0)return E(n)?t.stylize(RegExp.prototype.toString.call(n),`regexp`):t.stylize(`[Object]`,`special`);t.seen.push(n);var b=u?h(t,n,r,s,o):o.map(function(e){return g(t,n,r,s,e,u)});return t.seen.pop(),_(b,l,y)}function p(e,t){if(T(t))return e.stylize(`undefined`,`undefined`);if(C(t)){var n=`'`+JSON.stringify(t).replace(/^"|"$/g,``).replace(/'/g,`\\'`).replace(/\\"/g,`"`)+`'`;return e.stylize(n,`string`)}if(S(t))return e.stylize(``+t,`number`);if(y(t))return e.stylize(``+t,`boolean`);if(b(t))return e.stylize(`null`,`null`)}function m(e){return`[`+Error.prototype.toString.call(e)+`]`}function h(e,t,n,r,i){for(var a=[],o=0,s=t.length;o<s;++o)P(t,String(o))?a.push(g(e,t,n,r,String(o),!0)):a.push(``);return i.forEach(function(i){i.match(/^\d+$/)||a.push(g(e,t,n,r,i,!0))}),a}function g(e,t,n,r,i,a){var o,s,c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(c.get?s=c.set?e.stylize(`[Getter/Setter]`,`special`):e.stylize(`[Getter]`,`special`):c.set&&(s=e.stylize(`[Setter]`,`special`)),P(r,i)||(o=`[`+i+`]`),s||(e.seen.indexOf(c.value)<0?(s=b(n)?f(e,c.value,null):f(e,c.value,n-1),s.indexOf(`
|
|
55
|
+
This browser reports limited detail, so the cause above is a best guess.`:``)))},Ha=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=e,r=(Array.isArray(n.rects)?n.rects.slice(0,ra):[]).map(e=>La(e,t)).filter(e=>e!==null&&e.width>0&&e.height>0);return{modal:n.modal===!0,rects:r,hidden:za(n.hidden),inset:Fa(n.inset)}},Ua=()=>wa!==null,Wa=null,Ga=null,Ka=()=>{if(!wa||Wa===null)return;let e=Ea(wa),t=Ha(Wa,e);t&&Pa(wa,t,e)},qa=e=>{typeof ResizeObserver<`u`&&(Ga??=new ResizeObserver(Ka),Ga.disconnect(),Ga.observe(e))},Ja=e=>{ua(e),Pa(e,{modal:!1,rects:[],hidden:[],inset:0},Ea(e)),wa=e,qa(e)},Ya=e=>{if(!wa)return;let t=Ea(wa),n=Ha(e,t);n&&(Wa=e,Pa(wa,n,t),Va(n.hidden))},Xa=`https://fkn.app`,Za=typeof globalThis<`u`&&globalThis.document?globalThis.document:void 0,Qa=typeof globalThis<`u`&&globalThis.crossOriginIsolated===!0,$a=Ki(Qa),eo=`fkn-api-port`,to=`fkn-api-port-ack`,no=2e3,ro=()=>{if(!Za||typeof window>`u`||window.parent===window)return Promise.resolve(void 0);let e;try{e=window.parent}catch{return Promise.resolve(void 0)}let t=new MessageChannel;return new Promise(n=>{let r=e=>{if(clearTimeout(a),t.port1.removeEventListener(`message`,i),!e)try{t.port1.close()}catch{}n(e)},i=e=>{e.data?.type===to&&r(t.port1)},a=setTimeout(()=>r(void 0),no);t.port1.addEventListener(`message`,i),t.port1.start();try{e.postMessage({type:eo},Xa,[t.port2])}catch{r(void 0)}})},io,ao=e=>e.querySelector(`iframe[src="${$a}"]`),oo=async e=>{for(;!e.body;)await new Promise(t=>{let n=new MutationObserver(()=>{n.disconnect(),t()});n.observe(e,{childList:!0,subtree:!0})})},so=async e=>{let t=ao(e);if(t||=(await oo(e),ao(e)),t)io=t;else{let t=e.createElement(`iframe`);t.setAttribute(`allow`,Wi(Qa)),t.src=$a,e.body.appendChild(t),io=t}return ta(io,$a,Xa),Ja(io),io},co=(async()=>{if(!Za)return;let e=await ro();if(e)return{receive:e,emit:e};let t=await so(Za);return await Qi(t),t.contentWindow?na(t,Xa):void 0})(),lo=(e,{boundRetired:t=e=>e}={})=>{let n,r=0,i=!1,a=()=>{},o=()=>new Promise(e=>{a=e}),s=o(),c=s,l=/* @__PURE__ */ new Set,u=/* @__PURE__ */ new Set,d=0,f=0,p=()=>{let e=[...u];u.clear();let t=/* @__PURE__ */ Error(`FKN: the broker was replaced while this call was pending; retry it`);for(let n of e)try{n(t)}catch{}};(async()=>{for await(let t of e){let e=++r;n={remote:t,epoch:e};let i=a;s=o(),i(t),p();for(let n of[...l])try{n(t,e)}catch{}}})().catch(()=>{});let m=async(e,r)=>{let a=n?.remote??await(i?t(s):s);for(let t of e.slice(0,-1))a=a[t];let o=a[e[e.length-1]??``];d=Date.now(),f+=1;let c=()=>{},l=new Promise((e,t)=>{c=t});u.add(c);try{return await Promise.race([Promise.resolve(o.apply(a,r)),l])}finally{--f,u.delete(c),d=Date.now()}},h=/* @__PURE__ */ new Map,g=e=>{let t=e.join(`\0`),r=h.get(t);if(r)return r;let i=new Proxy(function(){},{get:(t,r)=>{if(typeof r!=`string`||r===`then`)return;let i=n;if(i){let t=i.remote;for(let n of e)t=t?.[n];if(t?.[r]===void 0)return}return g([...e,r])},apply:(t,n,r)=>m(e,r)});return h.set(t,i),i};return{facade:g([]),first:c.then(()=>{}),current:()=>n,onEpoch:e=>{if(l.add(e),n)try{e(n.remote,n.epoch)}catch{}return()=>{l.delete(e)}},lastCall:()=>d,inFlight:()=>f,routable:()=>n?Promise.resolve():s.then(()=>{}),retire:()=>{i=!0,n=void 0,p()}}},uo=!1,fo=/* @__PURE__ */ new Set,po=()=>uo,mo=()=>{if(!uo){uo=!0;for(let e of[...fo])try{e()}catch{}fo.clear()}},ho=e=>{uo?e():fo.add(e)},go=`fkn-api`,_o=e=>`fkn-relayed-worker-${e}`,vo=e=>new Promise(t=>{let n=globalThis.navigator?.locks;if(!n)return t();n.request(_o(e),()=>(t(),new Promise(()=>{}))).catch(()=>t())}),yo=async(e,t,n)=>{let r=globalThis.navigator?.locks;if(!r)return;let i=_o(e),{held:a}=await r.query().catch(()=>({held:void 0}));!n.aborted&&a?.some(e=>e.name===i)&&await r.request(i,{signal:n},()=>{t()}).catch(()=>{})},bo=(e,t,n)=>{let r=new AbortController;n?.aborted?r.abort():n?.addEventListener(`abort`,()=>r.abort(),{once:!0}),l(e,t,{key:go,unregisterSignal:r.signal});let i=/* @__PURE__ */ new Map;d({transport:t,key:go,unregisterSignal:r.signal,listener:e=>{let t=i.get(e.uuid);t||(i.set(e.uuid,t=/* @__PURE__ */ new Set),yo(e.uuid,()=>r.abort(),r.signal));let{remoteUuid:n}=e;n&&t.add(n)}});let a=(e,t)=>({[p]:go,uuid:e,type:`close`,remoteUuid:t});return r.signal.addEventListener(`abort`,()=>{for(let[n,r]of i)for(let i of r)o(e,a(n,i)),o(t,a(i,n))},{once:!0}),r.signal},xo=async()=>{if(typeof window<`u`)return co;if(typeof self<`u`)return{receive:self,emit:self}},So=`fkn-api`,Co=`fkn-api-window`,wo={async*[Symbol.asyncIterator](){let e=await xo();if(!e)await new Promise(()=>{});else{if(!po()){let t=new AbortController;ho(()=>t.abort());let n=crypto.randomUUID();typeof window>`u`&&await vo(n);for await(let r of s({},{key:So,transport:e,unregisterSignal:t.signal,uuid:n})){if(t.signal.aborted)break;yield r}}yield*s({},{key:Co,transport:e})}}},To=!1,Eo=xo().then(e=>new Promise(t=>{if(!e)return;let n=new AbortController;d({transport:e,key:So,unregisterSignal:n.signal,listener:()=>{n.abort(),To=!0,t()}})})),Do=lo(wo,{boundRetired:e=>Promise.race([e,Eo.then(()=>Po(e,()=>new Mo))])});ho(()=>Do.retire());var Oo=class extends Error{constructor(e,t){super(t===void 0?`@fkn/lib: no FKN broker in this realm (it has no window and no self, as in Node.js), so ${e} could not be requested`:`@fkn/lib: no broker connection within ${t}ms, so ${e} could not be requested`),this.name=`BrokerUnreachableError`}},U=Ji?Promise.race([Do.first,new Promise(e=>ho(e))]).then(()=>Do.facade):Promise.reject(new Oo(`a broker call`));U.catch(()=>{});var ko=8e3,Ao=1e3,jo=!1,Mo=class extends Error{constructor(){super(`FKN @fkn/lib: this page relays its FKN channel to a worker, and the FKN page it reached predates a channel of the page's own; reload`),this.name=`OwnChannelUnavailableError`}},No=e=>new Promise((t,n)=>setTimeout(()=>n(e))),Po=(e,t)=>{if(jo&&!To)return No(t(ko));let n=jo?Ao:ko;return Promise.race([e,new Promise((e,r)=>setTimeout(()=>{jo=!0,r(t(n))},n))])},Fo=e=>Ji?po()?Po(Do.routable().then(()=>Do.facade),t=>To?new Mo:new Oo(e,t)):Po(U,t=>new Oo(e,t)):No(new Oo(e));ho(()=>{Eo.then(()=>{let e=setTimeout(()=>console.error(new Mo),ko);Do.routable().then(()=>clearTimeout(e))})});var Io=Do.onEpoch,Lo=Do.current;Do.lastCall,Do.inFlight,Io(e=>{Ua()&&e.overlay.setHost(Ya,{exactClips:fa(),colorScheme:la}).catch(()=>{})});var Ro=`fkn-attach-frame`,zo=`fkn-attach-window`,Bo={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},Vo=6e4,Ho={default:6048e5,min:6e4,max:31536e6},Uo={notAFile:{code:`invalid`,message:`storage: the data is not a Blob or a ReadableStream`},badSize:{code:`invalid`,message:`storage: a stream needs the size it will deliver, a whole number of bytes`},shortStream:{code:`invalid`,message:`storage: the stream did not deliver the size it declared`},tooLarge:{code:`invalid`,message:`storage: the file is too large to store`},badKey:{code:`invalid`,message:`storage: the key is not 32 bytes base64url`},badUrl:{code:`invalid`,message:`storage: the url does not name a stored object`},badLimit:{code:`invalid`,message:`storage: the limit is out of range`},badCursor:{code:`invalid`,message:`storage: the cursor is not one list answered`},notFound:{code:`not-found`,message:`storage: no object at this url`},integrity:{code:`integrity`,message:`storage: the object does not match its key`},needsAccount:{code:`denied`,message:`storage: storing needs an account`},notCreator:{code:`denied`,message:`storage: only the app that stored the object can delete it`},quota:{code:`quota`,message:`storage: storage quota exceeded`},tooMany:{code:`too-many`,message:`storage: too many stored objects`},tooManyThisHour:{code:`too-many`,message:`storage: too many objects stored this hour, try again later`},accountChanged:{code:`account-changed`,message:`storage: the signed-in account changed`},unavailable:{code:`unavailable`,message:`storage: storage is unavailable`}},Wo=`fkn-relay`,Go=`RelayUnavailableError`,Ko=`this FKN page cannot choose a relay; reload the app to load the current one`,qo=/* @__PURE__ */ new Map,Jo=/* @__PURE__ */ new Set,Yo=e=>{qo.set(e,(qo.get(e)??0)+1);let t=!1;return()=>{t||(t=!0,qo.set(e,Math.max(0,(qo.get(e)??1)-1)))}},Xo=(e,t)=>{let n=Yo(e);t?.aborted?n():t?.addEventListener(`abort`,n,{once:!0})},Zo=(e,t)=>{Jo.add({kind:e,probe:t})},Qo=()=>{let e=/* @__PURE__ */ new Set;for(let[t,n]of qo)n>0&&e.add(`${t} (${n})`);for(let{kind:t,probe:n}of Jo)try{n()&&e.add(t)}catch{e.add(t)}return[...e]},$o=e=>Object.assign(Error(e),{name:Go}),es=e=>typeof e==`object`&&!!e&&e.name===`RelayUnavailableError`,ts=(e,t)=>{if(typeof e.relay?.resolve!=`function`)throw $o(`${t}: ${Ko}`)},ns=/* @__PURE__ */ new WeakMap,rs=(e,t)=>{t&&ns.set(e,t)},is=e=>{let t=ns.get(e);if(t!==void 0)return t;let n=e.headers;return n instanceof Headers?n.get(`fkn-relay`)??void 0:e._relay},as=typeof FinalizationRegistry>`u`?void 0:new FinalizationRegistry(e=>e()),os=(e,t)=>{if(!e.body)return t(),e;let n=Yo(`streamed response`),r=()=>{n(),t()},i=v(e,r);return as?.register(i.body,r),i},ss=async e=>{if(e!=null)return typeof e==`string`||e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e:new Request(`https://body.invalid/`,{method:`POST`,body:e,duplex:`half`}).arrayBuffer()},cs=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},ls=(e,t)=>{let{signal:n,release:r}=_(t?.signal);return(t?.relay===void 0?U:Fo(`a relay choice`)).then(r=>(t?.relay!==void 0&&ts(r,`cloud.fetch`),r.cloud.fetch(e,t?.signal?{...t,signal:n}:t))).then(e=>os(e,r),e=>{throw r(),e})},us=async(e,t)=>{if(Vi(e),typeof e==`object`&&e&&!(e instanceof URL)&&typeof e.url==`string`){let n=e,r={};n.headers.forEach((e,t)=>{r[t]=e});let i=await ss(t?.body===void 0?await cs(n):t.body);return ls(n.url,{...t,method:t?.method??n.method,headers:t?.headers??r,body:i})}let n=e instanceof URL?e.href:e,r=await ss(t?.body);return ls(n,t?.body===void 0?t:{...t,body:r})},ds=()=>!1,fs=(e=>(...t)=>{throw Error(`The FKN desktop app is not connected, desktop.${e} is unavailable`)})(`fetch`),ps=async e=>{if(ut(`promptInstall`,e),typeof window>`u`)return!1;if(Xe())return!0;let t=await U,n=null,r=new Promise(e=>{n=()=>{Xe()&&e(!0)},Ye.addEventListener(`statuschange`,n)}),i=t.installPrompt.show(e).then(()=>!1),a=await Promise.race([r,i]);return n&&Ye.removeEventListener(`statuschange`,n),await t.installPrompt.hide().catch(()=>{}),a},ms=null;$e(()=>(ms||=ps().then(()=>void 0).finally(()=>{ms=null}),ms));var hs=e=>{try{e.headers.delete(Wo)}catch{}return e},gs=()=>typeof document<`u`&&Xe(),_s=async(e,t)=>{if(Vi(e),ut(`fetch`,t?.reason),t?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return _t(e,t).then(hs)}return gs()?_t(e,{...t,credentials:`omit`}).then(hs):ds()?fs(e,t):us(e,t)},vs=(e,t,{classifier:n=`no-base`}={})=>{if(!e.session)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs its own session: attach with cookies: 'ephemeral'`};if(typeof t!=`string`)return{kind:`refuse`,reason:`frame.fetch: url must be a string`};let r;try{r=new URL(t)}catch{return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`}}if(n===`fetchTarget`&&ie(t).kind!==`absolute`)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`};if(r.protocol!==`https:`&&r.protocol!==`http:`)return{kind:`refuse`,reason:`frame.fetch: only http(s) urls are supported`};if(!(e.declaredHosts.includes(r.hostname)||e.approvedOrigins.has(r.origin)))return{kind:`refuse`,reason:`frame.fetch: the target is outside the origins this attachment declared`};let i=e.declaredHosts.length?e.declaredHosts:[r.hostname];return{kind:`consent`,targetHost:r.hostname,promptHosts:i}},ys=/* @__PURE__ */ g({lookup:()=>bs}),bs=(e,t)=>U.then(n=>n.cloud.dns.lookup(e,t)),xs=/* @__PURE__ */ a({Blob:()=>Rs,BlobOptions:()=>zs,Buffer:()=>G,File:()=>Bs,FileOptions:()=>Vs,INSPECT_MAX_BYTES:()=>Hs,SlowBuffer:()=>Us,TranscodeEncoding:()=>Ws,atob:()=>Gs,btoa:()=>Ks,constants:()=>qs,default:()=>Ls,isAscii:()=>Js,isUtf8:()=>Ys,kMaxLength:()=>Xs,kStringMaxLength:()=>Zs,resolveObjectURL:()=>Qs,transcode:()=>$s});function Ss(e){var t=e.length;if(t%4>0)throw Error(`Invalid string. Length must be a multiple of 4`);var n=e.indexOf(`=`);n===-1&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function Cs(e){var t=Ss(e),n=t[0],r=t[1];return(n+r)*3/4-r}function ws(e,t,n){return(t+n)*3/4-n}function Ts(e){for(var t,n=Ss(e),r=n[0],i=n[1],a=new Ms(ws(e,r,i)),o=0,s=i>0?r-4:r,c=0;c<s;c+=4)t=js[e.charCodeAt(c)]<<18|js[e.charCodeAt(c+1)]<<12|js[e.charCodeAt(c+2)]<<6|js[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=js[e.charCodeAt(c)]<<2|js[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=js[e.charCodeAt(c)]<<10|js[e.charCodeAt(c+1)]<<4|js[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function Es(e){return As[e>>18&63]+As[e>>12&63]+As[e>>6&63]+As[e&63]}function Ds(e,t,n){for(var r,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),i.push(Es(r));return i.join(``)}function Os(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Ds(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(As[t>>2]+As[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(As[t>>10]+As[t>>4&63]+As[t<<2&63]+`=`)),i.join(``)}var W,ks,As,js,Ms,Ns,Ps,Fs,Is,Ls,Rs,zs,G,Bs,Vs,Hs,Us,Ws,Gs,Ks,qs,Js,Ys,Xs,Zs,Qs,$s,ec=n((()=>{for(W={},ks={},ks.byteLength=Cs,ks.toByteArray=Ts,ks.fromByteArray=Os,As=[],js=[],Ms=typeof Uint8Array<`u`?Uint8Array:Array,Ns=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ps=0,Fs=Ns.length;Ps<Fs;++Ps)As[Ps]=Ns[Ps],js[Ns.charCodeAt(Ps)]=Ps;js[45]=62,js[95]=63,Is={},Is.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else if(a===c)return o?NaN:(p?-1:1)*(1/0);else o+=2**r,a-=l;return(p?-1:1)*o*2**(a-r)},Is.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=+(t<0||t===0&&1/t<0);for(t=Math.abs(t),isNaN(t)||t===1/0?(s=+!!isNaN(t),o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128},(function(e){let t=ks,n=Is,r=typeof Symbol==`function`&&typeof Symbol.for==`function`?Symbol.for(`nodejs.util.inspect.custom`):null;e.Buffer=u,e.SlowBuffer=x,e.INSPECT_MAX_BYTES=50;let i=2147483647;e.kMaxLength=i;let{Uint8Array:a,ArrayBuffer:o,SharedArrayBuffer:s}=globalThis;u.TYPED_ARRAY_SUPPORT=c(),!u.TYPED_ARRAY_SUPPORT&&typeof console<`u`&&typeof console.error==`function`&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function c(){try{let e=new a(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,a.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function l(e){if(e>i)throw RangeError(`The value "`+e+`" is invalid for option "size"`);let t=new a(e);return Object.setPrototypeOf(t,u.prototype),t}function u(e,t,n){if(typeof e==`number`){if(typeof t==`string`)throw TypeError(`The "string" argument must be of type string. Received type number`);return m(e)}return d(e,t,n)}u.poolSize=8192;function d(e,t,n){if(typeof e==`string`)return h(e,t);if(o.isView(e))return _(e);if(e==null)throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e);if(Se(e,o)||e&&Se(e.buffer,o)||s!==void 0&&(Se(e,s)||e&&Se(e.buffer,s)))return v(e,t,n);if(typeof e==`number`)throw TypeError(`The "value" argument must not be of type number. Received type number`);let r=e.valueOf&&e.valueOf();if(r!=null&&r!==e)return u.from(r,t,n);let i=y(e);if(i)return i;if(typeof Symbol<`u`&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]==`function`)return u.from(e[Symbol.toPrimitive](`string`),t,n);throw TypeError(`The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type `+typeof e)}u.from=function(e,t,n){return d(e,t,n)},Object.setPrototypeOf(u.prototype,a.prototype),Object.setPrototypeOf(u,a);function f(e){if(typeof e!=`number`)throw TypeError(`"size" argument must be of type number`);if(e<0)throw RangeError(`The value "`+e+`" is invalid for option "size"`)}function p(e,t,n){return f(e),e<=0||t===void 0?l(e):typeof n==`string`?l(e).fill(t,n):l(e).fill(t)}u.alloc=function(e,t,n){return p(e,t,n)};function m(e){return f(e),l(e<0?0:b(e)|0)}u.allocUnsafe=function(e){return m(e)},u.allocUnsafeSlow=function(e){return m(e)};function h(e,t){if((typeof t!=`string`||t===``)&&(t=`utf8`),!u.isEncoding(t))throw TypeError(`Unknown encoding: `+t);let n=S(e,t)|0,r=l(n),i=r.write(e,t);return i!==n&&(r=r.slice(0,i)),r}function g(e){let t=e.length<0?0:b(e.length)|0,n=l(t);for(let r=0;r<t;r+=1)n[r]=e[r]&255;return n}function _(e){if(Se(e,a)){let t=new a(e);return v(t.buffer,t.byteOffset,t.byteLength)}return g(e)}function v(e,t,n){if(t<0||e.byteLength<t)throw RangeError(`"offset" is outside of buffer bounds`);if(e.byteLength<t+(n||0))throw RangeError(`"length" is outside of buffer bounds`);let r;return r=t===void 0&&n===void 0?new a(e):n===void 0?new a(e,t):new a(e,t,n),Object.setPrototypeOf(r,u.prototype),r}function y(e){if(u.isBuffer(e)){let t=b(e.length)|0,n=l(t);return n.length===0||e.copy(n,0,0,t),n}if(e.length!==void 0)return typeof e.length!=`number`||Ce(e.length)?l(0):g(e);if(e.type===`Buffer`&&Array.isArray(e.data))return g(e.data)}function b(e){if(e>=i)throw RangeError(`Attempt to allocate Buffer larger than maximum size: 0x`+i.toString(16)+` bytes`);return e|0}function x(e){return+e!=e&&(e=0),u.alloc(+e)}u.isBuffer=function(e){return e!=null&&e._isBuffer===!0&&e!==u.prototype},u.compare=function(e,t){if(Se(e,a)&&(e=u.from(e,e.offset,e.byteLength)),Se(t,a)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(e)||!u.isBuffer(t))throw TypeError(`The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array`);if(e===t)return 0;let n=e.length,r=t.length;for(let i=0,a=Math.min(n,r);i<a;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:+(r<n)},u.isEncoding=function(e){switch(String(e).toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`latin1`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return!0;default:return!1}},u.concat=function(e,t){if(!Array.isArray(e))throw TypeError(`"list" argument must be an Array of Buffers`);if(e.length===0)return u.alloc(0);let n;if(t===void 0)for(t=0,n=0;n<e.length;++n)t+=e[n].length;let r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){let t=e[n];if(Se(t,a))i+t.length>r.length?(u.isBuffer(t)||(t=u.from(t)),t.copy(r,i)):a.prototype.set.call(r,t,i);else if(u.isBuffer(t))t.copy(r,i);else throw TypeError(`"list" argument must be an Array of Buffers`);i+=t.length}return r};function S(e,t){if(u.isBuffer(e))return e.length;if(o.isView(e)||Se(e,o))return e.byteLength;if(typeof e!=`string`)throw TypeError(`The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type `+typeof e);let n=e.length,r=arguments.length>2&&arguments[2]===!0;if(!r&&n===0)return 0;let i=!1;for(;;)switch(t){case`ascii`:case`latin1`:case`binary`:return n;case`utf8`:case`utf-8`:return _e(e).length;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return n*2;case`hex`:return n>>>1;case`base64`:return be(e).length;default:if(i)return r?-1:_e(e).length;t=(``+t).toLowerCase(),i=!0}}u.byteLength=S;function C(e,t,n){let r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return``;for(e||=`utf8`;;)switch(e){case`hex`:return ne(this,t,n);case`utf8`:case`utf-8`:return N(this,t,n);case`ascii`:return P(this,t,n);case`latin1`:case`binary`:return F(this,t,n);case`base64`:return M(this,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return re(this,t,n);default:if(r)throw TypeError(`Unknown encoding: `+e);e=(e+``).toLowerCase(),r=!0}}u.prototype._isBuffer=!0;function w(e,t,n){let r=e[t];e[t]=e[n],e[n]=r}u.prototype.swap16=function(){let e=this.length;if(e%2!=0)throw RangeError(`Buffer size must be a multiple of 16-bits`);for(let t=0;t<e;t+=2)w(this,t,t+1);return this},u.prototype.swap32=function(){let e=this.length;if(e%4!=0)throw RangeError(`Buffer size must be a multiple of 32-bits`);for(let t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},u.prototype.swap64=function(){let e=this.length;if(e%8!=0)throw RangeError(`Buffer size must be a multiple of 64-bits`);for(let t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},u.prototype.toString=function(){let e=this.length;return e===0?``:arguments.length===0?N(this,0,e):C.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(e){if(!u.isBuffer(e))throw TypeError(`Argument must be a Buffer`);return this===e||u.compare(this,e)===0},u.prototype.inspect=function(){let t=``,n=e.INSPECT_MAX_BYTES;return t=this.toString(`hex`,0,n).replace(/(.{2})/g,`$1 `).trim(),this.length>n&&(t+=` ... `),`<Buffer `+t+`>`},r&&(u.prototype[r]=u.prototype.inspect),u.prototype.compare=function(e,t,n,r,i){if(Se(e,a)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(e))throw TypeError(`The "target" argument must be one of type Buffer or Uint8Array. Received type `+typeof e);if(t===void 0&&(t=0),n===void 0&&(n=e?e.length:0),r===void 0&&(r=0),i===void 0&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw RangeError(`out of range index`);if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;let o=i-r,s=n-t,c=Math.min(o,s),l=this.slice(r,i),d=e.slice(t,n);for(let e=0;e<c;++e)if(l[e]!==d[e]){o=l[e],s=d[e];break}return o<s?-1:+(s<o)};function T(e,t,n,r,i){if(e.length===0)return-1;if(typeof n==`string`?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,Ce(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(i)n=0;else return-1}if(typeof t==`string`&&(t=u.from(t,r)),u.isBuffer(t))return t.length===0?-1:E(e,t,n,r,i);if(typeof t==`number`)return t&=255,typeof a.prototype.indexOf==`function`?i?a.prototype.indexOf.call(e,t,n):a.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,i);throw TypeError(`val must be string, number or Buffer`)}function E(e,t,n,r,i){let a=1,o=e.length,s=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r===`ucs2`||r===`ucs-2`||r===`utf16le`||r===`utf-16le`)){if(e.length<2||t.length<2)return-1;a=2,o/=2,s/=2,n/=2}function c(e,t){return a===1?e[t]:e.readUInt16BE(t*a)}let l;if(i){let r=-1;for(l=n;l<o;l++)if(c(e,l)===c(t,r===-1?0:l-r)){if(r===-1&&(r=l),l-r+1===s)return r*a}else r!==-1&&(l-=l-r),r=-1}else for(n+s>o&&(n=o-s),l=n;l>=0;l--){let n=!0;for(let r=0;r<s;r++)if(c(e,l+r)!==c(t,r)){n=!1;break}if(n)return l}return-1}u.prototype.includes=function(e,t,n){return this.indexOf(e,t,n)!==-1},u.prototype.indexOf=function(e,t,n){return T(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return T(this,e,t,n,!1)};function D(e,t,n,r){n=Number(n)||0;let i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;let a=t.length;r>a/2&&(r=a/2);let o=0;for(;o<r;++o){let r=parseInt(t.substr(o*2,2),16);if(Ce(r))return o;e[n+o]=r}return o}function O(e,t,n,r){return xe(_e(t,e.length-n),e,n,r)}function k(e,t,n,r){return xe(ve(t),e,n,r)}function A(e,t,n,r){return xe(be(t),e,n,r)}function j(e,t,n,r){return xe(ye(t,e.length-n),e,n,r)}u.prototype.write=function(e,t,n,r){if(t===void 0)r=`utf8`,n=this.length,t=0;else if(n===void 0&&typeof t==`string`)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,r===void 0&&(r=`utf8`)):(r=n,n=void 0);else throw Error(`Buffer.write(string, encoding, offset[, length]) is no longer supported`);let i=this.length-t;if((n===void 0||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError(`Attempt to write outside buffer bounds`);r||=`utf8`;let a=!1;for(;;)switch(r){case`hex`:return D(this,e,t,n);case`utf8`:case`utf-8`:return O(this,e,t,n);case`ascii`:case`latin1`:case`binary`:return k(this,e,t,n);case`base64`:return A(this,e,t,n);case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return j(this,e,t,n);default:if(a)throw TypeError(`Unknown encoding: `+r);r=(``+r).toLowerCase(),a=!0}},u.prototype.toJSON=function(){return{type:`Buffer`,data:Array.prototype.slice.call(this._arr||this,0)}};function M(e,n,r){return n===0&&r===e.length?t.fromByteArray(e):t.fromByteArray(e.slice(n,r))}function N(e,t,n){n=Math.min(e.length,n);let r=[],i=t;for(;i<n;){let t=e[i],a=null,o=t>239?4:t>223?3:t>191?2:1;if(i+o<=n){let n,r,s,c;switch(o){case 1:t<128&&(a=t);break;case 2:n=e[i+1],(n&192)==128&&(c=(t&31)<<6|n&63,c>127&&(a=c));break;case 3:n=e[i+1],r=e[i+2],(n&192)==128&&(r&192)==128&&(c=(t&15)<<12|(n&63)<<6|r&63,c>2047&&(c<55296||c>57343)&&(a=c));break;case 4:n=e[i+1],r=e[i+2],s=e[i+3],(n&192)==128&&(r&192)==128&&(s&192)==128&&(c=(t&15)<<18|(n&63)<<12|(r&63)<<6|s&63,c>65535&&c<1114112&&(a=c))}}a===null?(a=65533,o=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),i+=o}return te(r)}let ee=4096;function te(e){let t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=ee));return n}function P(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]&127);return r}function F(e,t,n){let r=``;n=Math.min(e.length,n);for(let i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function ne(e,t,n){let r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);let i=``;for(let r=t;r<n;++r)i+=we[e[r]];return i}function re(e,t,n){let r=e.slice(t,n),i=``;for(let e=0;e<r.length-1;e+=2)i+=String.fromCharCode(r[e]+r[e+1]*256);return i}u.prototype.slice=function(e,t){let n=this.length;e=~~e,t=t===void 0?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t<e&&(t=e);let r=this.subarray(e,t);return Object.setPrototypeOf(r,u.prototype),r};function I(e,t,n){if(e%1!=0||e<0)throw RangeError(`offset is not uint`);if(e+t>n)throw RangeError(`Trying to access beyond buffer length`)}u.prototype.readUintLE=u.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return r},u.prototype.readUintBE=u.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e+--t],i=1;for(;t>0&&(i*=256);)r+=this[e+--t]*i;return r},u.prototype.readUint8=u.prototype.readUInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(e,t){return e>>>=0,t||I(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readBigUInt64LE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t+this[++e]*256+this[++e]*2**16+this[++e]*2**24,i=this[++e]+this[++e]*256+this[++e]*2**16+n*2**24;return BigInt(r)+(BigInt(i)<<BigInt(32))}),u.prototype.readBigUInt64BE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=t*2**24+this[++e]*2**16+this[++e]*256+this[++e],i=this[++e]*2**24+this[++e]*2**16+this[++e]*256+n;return(BigInt(r)<<BigInt(32))+BigInt(i)}),u.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=this[e],i=1,a=0;for(;++a<t&&(i*=256);)r+=this[e+a]*i;return i*=128,r>=i&&(r-=2**(8*t)),r},u.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||I(e,t,this.length);let r=t,i=1,a=this[e+--r];for(;r>0&&(i*=256);)a+=this[e+--r]*i;return i*=128,a>=i&&(a-=2**(8*t)),a},u.prototype.readInt8=function(e,t){return e>>>=0,t||I(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]},u.prototype.readInt16LE=function(e,t){e>>>=0,t||I(e,2,this.length);let n=this[e]|this[e+1]<<8;return n&32768?n|4294901760:n},u.prototype.readInt16BE=function(e,t){e>>>=0,t||I(e,2,this.length);let n=this[e+1]|this[e]<<8;return n&32768?n|4294901760:n},u.prototype.readInt32LE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return e>>>=0,t||I(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readBigInt64LE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=this[e+4]+this[e+5]*256+this[e+6]*2**16+(n<<24);return(BigInt(r)<<BigInt(32))+BigInt(t+this[++e]*256+this[++e]*2**16+this[++e]*2**24)}),u.prototype.readBigInt64BE=Te(function(e){e>>>=0,pe(e,`offset`);let t=this[e],n=this[e+7];(t===void 0||n===void 0)&&me(e,this.length-8);let r=(t<<24)+this[++e]*2**16+this[++e]*256+this[++e];return(BigInt(r)<<BigInt(32))+BigInt(this[++e]*2**24+this[++e]*2**16+this[++e]*256+n)}),u.prototype.readFloatLE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return e>>>=0,t||I(e,4,this.length),n.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return e>>>=0,t||I(e,8,this.length),n.read(this,e,!1,52,8)};function L(e,t,n,r,i,a){if(!u.isBuffer(e))throw TypeError(`"buffer" argument must be a Buffer instance`);if(t>i||t<a)throw RangeError(`"value" argument is out of bounds`);if(n+r>e.length)throw RangeError(`Index out of range`)}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;L(this,e,t,n,r,0)}let i=1,a=0;for(this[t]=e&255;++a<n&&(i*=256);)this[t+a]=e/i&255;return t+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(e,t,n,r){if(e=+e,t>>>=0,n>>>=0,!r){let r=2**(8*n)-1;L(this,e,t,n,r,0)}let i=n-1,a=1;for(this[t+i]=e&255;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,255,0),this[t]=e&255,t+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255,t+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4};function ie(e,t,n,r,i){fe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a,a>>=8,e[n++]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,o>>=8,e[n++]=o,n}function ae(e,t,n,r,i){fe(t,r,i,e,n,7);let a=Number(t&BigInt(4294967295));e[n+7]=a,a>>=8,e[n+6]=a,a>>=8,e[n+5]=a,a>>=8,e[n+4]=a;let o=Number(t>>BigInt(32)&BigInt(4294967295));return e[n+3]=o,o>>=8,e[n+2]=o,o>>=8,e[n+1]=o,o>>=8,e[n]=o,n+8}u.prototype.writeBigUInt64LE=Te(function(e,t=0){return ie(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeBigUInt64BE=Te(function(e,t=0){return ae(this,e,t,BigInt(0),BigInt(`0xffffffffffffffff`))}),u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);L(this,e,t,n,r-1,-r)}let i=0,a=1,o=0;for(this[t]=e&255;++i<n&&(a*=256);)e<0&&o===0&&this[t+i-1]!==0&&(o=1),this[t+i]=(e/a|0)-o&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){let r=2**(8*n-1);L(this,e,t,n,r-1,-r)}let i=n-1,a=1,o=0;for(this[t+i]=e&255;--i>=0&&(a*=256);)e<0&&o===0&&this[t+i+1]!==0&&(o=1),this[t+i]=(e/a|0)-o&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=e&255,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=e&255,this[t+1]=e>>>8,t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=e&255,t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,2147483647,-2147483648),this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||L(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255,t+4},u.prototype.writeBigInt64LE=Te(function(e,t=0){return ie(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))}),u.prototype.writeBigInt64BE=Te(function(e,t=0){return ae(this,e,t,-BigInt(`0x8000000000000000`),BigInt(`0x7fffffffffffffff`))});function oe(e,t,n,r,i,a){if(n+r>e.length||n<0)throw RangeError(`Index out of range`)}function se(e,t,r,i,a){return t=+t,r>>>=0,a||oe(e,t,r,4),n.write(e,t,r,i,23,4),r+4}u.prototype.writeFloatLE=function(e,t,n){return se(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return se(this,e,t,!1,n)};function R(e,t,r,i,a){return t=+t,r>>>=0,a||oe(e,t,r,8),n.write(e,t,r,i,52,8),r+8}u.prototype.writeDoubleLE=function(e,t,n){return R(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return R(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(!u.isBuffer(e))throw TypeError(`argument should be a Buffer`);if(n||=0,!r&&r!==0&&(r=this.length),t>=e.length&&(t=e.length),t||=0,r>0&&r<n&&(r=n),r===n||e.length===0||this.length===0)return 0;if(t<0)throw RangeError(`targetStart out of bounds`);if(n<0||n>=this.length)throw RangeError(`Index out of range`);if(r<0)throw RangeError(`sourceEnd out of bounds`);r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);let i=r-n;return this===e&&typeof a.prototype.copyWithin==`function`?this.copyWithin(t,n,r):a.prototype.set.call(e,this.subarray(n,r),t),i},u.prototype.fill=function(e,t,n,r){if(typeof e==`string`){if(typeof t==`string`?(r=t,t=0,n=this.length):typeof n==`string`&&(r=n,n=this.length),r!==void 0&&typeof r!=`string`)throw TypeError(`encoding must be a string`);if(typeof r==`string`&&!u.isEncoding(r))throw TypeError(`Unknown encoding: `+r);if(e.length===1){let t=e.charCodeAt(0);(r===`utf8`&&t<128||r===`latin1`)&&(e=t)}}else typeof e==`number`?e&=255:typeof e==`boolean`&&(e=Number(e));if(t<0||this.length<t||this.length<n)throw RangeError(`Out of range index`);if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||=0;let i;if(typeof e==`number`)for(i=t;i<n;++i)this[i]=e;else{let a=u.isBuffer(e)?e:u.from(e,r),o=a.length;if(o===0)throw TypeError(`The value "`+e+`" is invalid for argument "value"`);for(i=0;i<n-t;++i)this[i+t]=a[i%o]}return this};let ce={};function le(e,t,n){ce[e]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${e}]`,this.stack,delete this.name}get code(){return e}set code(e){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:e,writable:!0})}toString(){return`${this.name} [${e}]: ${this.message}`}}}le(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),le(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),le(`ERR_OUT_OF_RANGE`,function(e,t,n){let r=`The value of "${e}" is out of range.`,i=n;return Number.isInteger(n)&&Math.abs(n)>2**32?i=ue(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=ue(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function ue(e){let t=``,n=e.length,r=+(e[0]===`-`);for(;n>=r+4;n-=3)t=`_${e.slice(n-3,n)}${t}`;return`${e.slice(0,n)}${t}`}function de(e,t,n){pe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&me(t,e.length-(n+1))}function fe(e,t,n,r,i,a){if(e>n||e<t){let r=typeof t==`bigint`?`n`:``,i;throw i=a>3?t===0||t===BigInt(0)?`>= 0${r} and < 2${r} ** ${(a+1)*8}${r}`:`>= -(2${r} ** ${(a+1)*8-1}${r}) and < 2 ** ${(a+1)*8-1}${r}`:`>= ${t}${r} and <= ${n}${r}`,new ce.ERR_OUT_OF_RANGE(`value`,i,e)}de(r,i,a)}function pe(e,t){if(typeof e!=`number`)throw new ce.ERR_INVALID_ARG_TYPE(t,`number`,e)}function me(e,t,n){throw Math.floor(e)===e?t<0?new ce.ERR_BUFFER_OUT_OF_BOUNDS:new ce.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(pe(e,n),new ce.ERR_OUT_OF_RANGE(n||`offset`,`an integer`,e))}let he=/[^+/0-9A-Za-z-_]/g;function ge(e){if(e=e.split(`=`)[0],e=e.trim().replace(he,``),e.length<2)return``;for(;e.length%4!=0;)e+=`=`;return e}function _e(e,t){t||=1/0;let n,r=e.length,i=null,a=[];for(let o=0;o<r;++o){if(n=e.charCodeAt(o),n>55295&&n<57344){if(!i){if(n>56319||o+1===r){(t-=3)>-1&&a.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&a.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,n<128){if(--t<0)break;a.push(n)}else if(n<2048){if((t-=2)<0)break;a.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;a.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;a.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw Error(`Invalid code point`)}return a}function ve(e){let t=[];for(let n=0;n<e.length;++n)t.push(e.charCodeAt(n)&255);return t}function ye(e,t){let n,r,i,a=[];for(let o=0;o<e.length&&!((t-=2)<0);++o)n=e.charCodeAt(o),r=n>>8,i=n%256,a.push(i),a.push(r);return a}function be(e){return t.toByteArray(ge(e))}function xe(e,t,n,r){let i=0;for(;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Se(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Ce(e){return e!==e}let we=(function(){let e=`0123456789abcdef`,t=Array(256);for(let n=0;n<16;++n){let r=n*16;for(let i=0;i<16;++i)t[r+i]=e[n]+e[i]}return t})();function Te(e){return typeof BigInt>`u`?Ee:e}function Ee(){throw Error(`BigInt not supported`)}})(W),Ls=W.Buffer,Rs=W.Blob,zs=W.BlobOptions,G=W.Buffer,Bs=W.File,Vs=W.FileOptions,Hs=W.INSPECT_MAX_BYTES,Us=W.SlowBuffer,Ws=W.TranscodeEncoding,Gs=W.atob,Ks=W.btoa,qs=W.constants,Js=W.isAscii,Ys=W.isUtf8,Xs=W.kMaxLength,Zs=W.kStringMaxLength,Qs=W.resolveObjectURL,$s=W.transcode}));ec();var tc={json:`application/json`,txt:`text/plain`,html:`text/html`,htm:`text/html`,css:`text/css`,js:`text/javascript`,mjs:`text/javascript`,xml:`application/xml`,csv:`text/csv`,md:`text/markdown`,svg:`image/svg+xml`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,pdf:`application/pdf`,wasm:`application/wasm`},nc=(e,t)=>{if(t)return t;let n=e.split(`/`).pop()??``,r=n.lastIndexOf(`.`);if(!(r<=0))return tc[n.slice(r+1).toLowerCase()]},rc=(e,t)=>({size:e,mtimeMs:t,mtime:new Date(t),atimeMs:t,ctimeMs:t,mode:420,isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}),ic=(e=0)=>({size:0,mtimeMs:e,mtime:new Date(e),atimeMs:e,ctimeMs:e,mode:493,isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1}),K=(e,t,n)=>{let r=/* @__PURE__ */ Error(`${e}: ${{ENOENT:`no such file or directory`,EEXIST:`file already exists`,ENOTDIR:`not a directory`,EISDIR:`illegal operation on a directory`,ENOTEMPTY:`directory not empty`,ERR_FS_EISDIR:`is a directory`,EROFS:`read-only file system, as @fkn/lib keeps no files in Node.js`}[e]??e}, ${n} '${t}'`);return r.code=e,r.path=t,r.syscall=n,r},q=e=>{let t=[];for(let n of e.split(`/`))n&&n!==`.`&&(n===`..`?t.pop():t.push(n));return t.join(`/`)},ac=e=>e.split(`/`).slice(0,-1).join(`/`),J=e=>typeof e==`string`?e:e instanceof URL?decodeURIComponent(e.pathname):e.toString(),oc=e=>typeof e==`string`?e:e?.encoding??void 0,sc=e=>typeof e==`object`?e?.contentType:void 0,cc=e=>typeof e==`object`&&!!e?.recursive,lc=(e,t)=>{let n=oc(t);return n?G.from(e).toString(n):G.from(e)},uc=(e,t)=>{if(typeof e==`string`)return new Uint8Array(G.from(e,oc(t)??`utf8`));if(e instanceof Uint8Array)return e.slice();if(e instanceof ArrayBuffer)return new Uint8Array(e).slice();if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice();throw TypeError(`The "data" argument must be of type string, Buffer, TypedArray, or DataView`)},dc=e=>{let t=/* @__PURE__ */ new Map([[``,{kind:`dir`,mtimeMs:0}]]),n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=()=>e.captureAccount?{pin:e.captureAccount()}:{};Zo(`unsaved files`,()=>n.size>0||r.size>0);let a=/* @__PURE__ */ new Set,o=()=>Date.now(),s=e=>{if(!e)return;let n=e.split(`/`),r=``;for(let e of n){r=r?`${r}/${e}`:e;let n=t.get(r);if(!n)t.set(r,{kind:`dir`,mtimeMs:o()});else if(n.kind===`file`)throw K(`ENOTDIR`,r,`mkdir`)}},c,l=0,u=async()=>{let c=i(),u=await e.list(c).catch(()=>[]),d=/* @__PURE__ */ new Set,f=!1;for(let i of u){let l=q(i.path);if(d.add(l),!r.has(l)&&(!n.has(l)||a.has(l)))try{let u=await(await e.readFile(i.path,c)).arrayBuffer();if(r.has(l)||n.has(l)&&!a.has(l))continue;s(ac(l));let d=Date.parse(i.updatedAt??``);t.set(l,{kind:`file`,data:new Uint8Array(u),mtimeMs:Number.isFinite(d)?d:o(),contentType:i.contentType??void 0}),a.delete(l),n.delete(l)}catch{f=!0,a.add(l)}}for(let e of a)d.has(e)||a.delete(e);l=f?Date.now():0},d=()=>(c&&(l===0||Date.now()-l<5e3)||(c=u()),c),f=async()=>{c=void 0,l=0,await d()},p=async()=>{let i=[...n].map(async([r,i])=>{if(a.has(r))return;let o=t.get(r);if(o?.kind!==`file`){n.delete(r);return}let s=o.data,c=nc(r,o.contentType);try{await e.writeFile(r,s,c?{contentType:c,...i}:i);let a=t.get(r);a?.kind===`file`&&a.data===s&&n.delete(r)}catch{}}),o=[...r].map(async([t,n])=>{try{await e.remove(t,n),r.get(t)===n&&r.delete(t)}catch{}});await Promise.all([...i,...o])},m,h=()=>{m||=setTimeout(()=>{m=void 0,p().catch(()=>{})},250)};typeof window<`u`&&(qi(window,`pagehide`,()=>{p().catch(()=>{})}),qi(document,`visibilitychange`,()=>{document.visibilityState===`hidden`&&p().catch(()=>{})}));let g=e=>e.kind===`file`?rc(e.data.byteLength,e.mtimeMs):ic(e.mtimeMs),_=e=>Object.assign(/* @__PURE__ */ Error(`storage: ${e} exists but could not be read, retry once its scope is available`),{code:`FKN_E2E_LOCKED`}),v=e=>{let n=q(e);return t.has(n)||a.has(n)},y=e=>{let n=q(e),r=t.get(n);if(!r)throw a.has(n)?_(e):K(`ENOENT`,e,`stat`);return g(r)},b=e=>{let n=q(e),r=t.get(n);if(!r)throw a.has(n)?_(e):K(`ENOENT`,e,`open`);if(r.kind===`dir`)throw K(`EISDIR`,e,`read`);return r.data},x=(e,t)=>{let n=new Uint8Array(e.byteLength+t.byteLength);return n.set(e,0),n.set(t,e.byteLength),n},S=(e,c,l,u)=>{let d=q(e);if(!d)throw K(`EISDIR`,e,`open`);if(!Ji)throw K(`EROFS`,e,`open`);if(a.has(d))throw _(e);let f=t.get(d);if(f?.kind===`dir`)throw K(`EISDIR`,e,`open`);s(ac(d));let p=l&&f?.kind===`file`?x(f.data,c):c;t.set(d,{kind:`file`,data:p,mtimeMs:o(),contentType:u??(f?.kind===`file`?f.contentType:void 0)}),n.set(d,i()),r.delete(d),h()},C=(e,n)=>{let r=q(e);if(r){if(!Ji)throw K(`EROFS`,e,`mkdir`);if(t.has(r)){if(n)return;throw K(`EEXIST`,e,`mkdir`)}if(!n&&!t.has(ac(r)))throw K(`ENOENT`,e,`mkdir`);s(r)}},w=e=>{let n=q(e),r=t.get(n);if(!r)throw K(`ENOENT`,e,`scandir`);if(r.kind===`file`)throw K(`ENOTDIR`,e,`scandir`);let i=n?`${n}/`:``,o=/* @__PURE__ */ new Set;for(let e of[...t.keys(),...a]){if(!e||!e.startsWith(i))continue;let t=e.slice(i.length);t&&o.add(t.split(`/`)[0])}return[...o]},T=(e,{op:o,recursive:s,force:c})=>{let l=i(),u=q(e),d=t.get(u);if(!d&&a.has(u)){if(o===`rmdir`)throw K(`ENOTDIR`,e,`rmdir`);a.delete(u),n.delete(u),r.set(u,l),h();return}if(!d){if(c||o===`rmdir`&&s)return;throw K(`ENOENT`,e,o===`rmdir`?`rmdir`:`unlink`)}if(o===`unlink`&&d.kind===`dir`)throw K(`EISDIR`,e,`unlink`);if(o===`rmdir`&&d.kind===`file`)throw K(`ENOTDIR`,e,`rmdir`);if(o===`rm`&&d.kind===`dir`&&!s)throw K(`ERR_FS_EISDIR`,e,`rm`);let f=`${u}/`,p=[...t.keys()].filter(e=>e.startsWith(f));if(p.length&&!s)throw K(`ENOTEMPTY`,e,`rmdir`);for(let e of[u,...p]){let i=t.get(e);t.delete(e),i?.kind===`file`&&(n.delete(e),r.set(e,l))}h()};return{mount:d,remount:f,flush:p,exists:v,stat:y,readFile:b,writeFile:S,mkdir:C,readdir:w,remove:T,rename:(e,o)=>{let c=i(),l=q(e),u=q(o);if(!l)throw K(`EBUSY`,e,`rename`);if(u===l||u.startsWith(`${l}/`))throw K(`EINVAL`,e,`rename`);if(a.has(l))throw _(e);if(a.has(u))throw _(o);let d=t.get(l);if(!d)throw K(`ENOENT`,e,`rename`);let f=t.get(u);if(f){if(f.kind!==d.kind)throw K(d.kind===`dir`?`ENOTDIR`:`EISDIR`,o,`rename`);T(u,{op:`rm`,recursive:!0,force:!0})}s(ac(u));let p=`${l}/`,m=[l,...[...t.keys()].filter(e=>e.startsWith(p))];for(let e of m){let i=u+e.slice(l.length),a=t.get(e);t.set(i,a),t.delete(e),a.kind===`file`&&(n.set(i,c),r.delete(i),n.delete(e),r.set(e,c))}h()}}},fc=(e,t)=>typeof e==`function`?e:t,pc=e=>typeof e==`function`?void 0:e,mc=(e,t)=>{e.then(e=>t(null,e),e=>t(e))},hc=e=>{let t=dc(e),n=(e,n)=>lc(t.readFile(J(e)),n),r=(e,n,r)=>t.writeFile(J(e),uc(n,r),!1,sc(r)),i=(e,n,r)=>t.writeFile(J(e),uc(n,r),!0,sc(r)),a=e=>t.exists(J(e)),o=e=>t.stat(J(e)),s=e=>t.readdir(J(e)),c=(e,n)=>t.mkdir(J(e),cc(n)),l=(e,n)=>t.remove(J(e),{op:`rm`,...n}),u=(e,n)=>t.remove(J(e),{op:`rmdir`,...n}),d=e=>t.remove(J(e),{op:`unlink`}),f=(e,n)=>t.rename(J(e),J(n)),p=(e,n)=>{t.mount().finally(()=>{let t;try{t=e()}catch(e){n(e);return}n(null,t)})},m=e=>t.mount().then(()=>e());return{available:e.available,readFileSync:n,writeFileSync:r,appendFileSync:i,existsSync:a,statSync:o,lstatSync:o,readdirSync:s,mkdirSync:c,rmSync:l,rmdirSync:u,unlinkSync:d,renameSync:f,readFile:(e,n,r)=>p(()=>lc(t.readFile(J(e)),pc(n)),fc(n,r)),writeFile:(e,n,r,i)=>p(()=>t.writeFile(J(e),uc(n,pc(r)),!1,sc(pc(r))),fc(r,i)),appendFile:(e,n,r,i)=>p(()=>t.writeFile(J(e),uc(n,pc(r)),!0,sc(pc(r))),fc(r,i)),stat:(e,n)=>p(()=>t.stat(J(e)),n),readdir:(e,n,r)=>p(()=>t.readdir(J(e)),fc(n,r)),mkdir:(e,n,r)=>p(()=>t.mkdir(J(e),cc(pc(n))),fc(n,r)),rm:(e,n,r)=>p(()=>t.remove(J(e),{op:`rm`,...pc(n)}),fc(n,r)),unlink:(e,n)=>p(()=>t.remove(J(e),{op:`unlink`}),n),rename:(e,n,r)=>p(()=>t.rename(J(e),J(n)),r),exists:(e,n)=>{t.mount().finally(()=>n(t.exists(J(e))))},promises:{readFile:(e,n)=>m(()=>lc(t.readFile(J(e)),n)),writeFile:(e,n,r)=>m(()=>t.writeFile(J(e),uc(n,r),!1,sc(r))),appendFile:(e,n,r)=>m(()=>t.writeFile(J(e),uc(n,r),!0,sc(r))),stat:e=>m(()=>t.stat(J(e))),lstat:e=>m(()=>t.stat(J(e))),readdir:e=>m(()=>t.readdir(J(e))),mkdir:(e,n)=>m(()=>t.mkdir(J(e),cc(n))),rm:(e,n)=>m(()=>t.remove(J(e),{op:`rm`,...n})),rmdir:(e,n)=>m(()=>t.remove(J(e),{op:`rmdir`,...n})),unlink:e=>m(()=>t.remove(J(e),{op:`unlink`})),rename:(e,n)=>m(()=>t.rename(J(e),J(n))),access:e=>m(()=>{if(!t.exists(J(e)))throw K(`ENOENT`,J(e),`access`)})},mount:t.mount,flush:t.flush,remount:t.remount}},gc=e=>{let t=()=>e.captureAccount?{pin:e.captureAccount()}:{},n=async(t,n)=>{let r=await e.readFile(J(t));return lc(new Uint8Array(await r.arrayBuffer()),n)},r=async(t,n,r)=>{let i=J(t),a=nc(i,sc(r));await e.writeFile(i,uc(n,r),a?{contentType:a}:void 0)},i=t=>e.remove(J(t)),a=async(n,r)=>{let i=t(),a=q(J(n)),o=q(J(r));if(a===o)return;let s=await e.readFile(a,i);await e.writeFile(o,s,i),await e.remove(a,i)},o=async t=>{let n=q(J(t)),r=n?`${n}/`:``,i=/* @__PURE__ */ new Set;for(let t of await e.list()){let e=q(t.path);if(r&&!e.startsWith(r))continue;let n=e.slice(r.length);n&&i.add(n.split(`/`)[0])}return[...i]},s=async(e,t)=>{},c=async(n,r)=>{let i=t(),a=q(J(n));if(!r?.recursive){await e.remove(J(n),i);return}let o=`${a}/`,s=await e.list(i);await Promise.all(s.filter(e=>{let t=q(e.path);return t===a||t.startsWith(o)}).map(t=>e.remove(t.path,i).catch(()=>{})))},l=async t=>{let n=q(J(t)),r=await e.list(),i=r.find(e=>q(e.path)===n);if(i){let e=Date.parse(i.updatedAt??``);return rc(i.size,Number.isFinite(e)?e:0)}if(r.some(e=>q(e.path).startsWith(`${n}/`)))return ic();throw K(`ENOENT`,J(t),`stat`)},u={readFile:n,writeFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:c,stat:l,lstat:l,access:async e=>{await l(e)}};return{available:e.available,promises:u,readFile:(e,t,r)=>mc(n(e,pc(t)),fc(t,r)),writeFile:(e,t,n,i)=>mc(r(e,t,pc(n)),fc(n,i)),unlink:(e,t)=>mc(i(e),t),rename:(e,t,n)=>mc(a(e,t),n),readdir:(e,t,n)=>mc(o(e),fc(t,n)),mkdir:(e,t,n)=>mc(s(),fc(t,n)),rm:(e,t,n)=>mc(c(e,pc(t)),fc(t,n)),stat:(e,t)=>mc(l(e),t)}};function _c(e,t){return t.memfs?hc(e):gc(e)}var vc=`FKN_STORAGE_NOT_FOUND`,yc=`FKN_ACCOUNT_CHANGED`,bc=`FKN_ACCOUNT_PIN_UNSUPPORTED`,xc=0,Sc=/* @__PURE__ */ new Set,Cc=2e3,wc=null,Tc=e=>{let t=e?.switched!==!1;t&&(xc+=1,wc&&=(clearTimeout(wc.timer),null));for(let e of[...Sc])try{e({switched:t})}catch{}},Ec=!1,Dc=0,Oc=()=>{let e=Lo();e&&Dc!==e.epoch&&(Dc=e.epoch,Promise.resolve(e.remote.account.onChange(Tc)).catch(()=>{Dc===e.epoch&&(Dc=0)}))},kc=()=>{!Ec&&Ji&&(Ec=!0,Io(Oc))},Ac=()=>xc,jc=e=>(Sc.add(e),kc(),()=>{Sc.delete(e)}),Mc=e=>{if(e!==xc||wc?.generation===e)return;let t=setTimeout(()=>{wc?.timer===t&&(wc=null,xc===e&&Tc({switched:!0}))},Cc);wc={generation:e,timer:t}},Nc=/* @__PURE__ */ g({StorageAccountChangedError:()=>Lc,StorageAccountPinUnsupportedError:()=>Rc,StorageLockedError:()=>Pc,StorageNotFoundError:()=>Fc,availability:()=>rl,available:()=>Qc,captureAccount:()=>Y,encryption:()=>dl,isAccountChanged:()=>zc,isInvalidPin:()=>Bc,isNotFound:()=>Ic,knownPin:()=>qc,list:()=>il,pinFor:()=>Jc,quota:()=>al,readFile:()=>ol,readFileSealed:()=>cl,remove:()=>ul,unlock:()=>fl,writeFile:()=>ll}),Pc=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},Fc=class extends Error{code=vc;constructor(e=`storage: no object at that path`){super(e)}},Ic=e=>e?.code===vc,Lc=class extends Error{code=yc;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},Rc=class extends Error{code=bc;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},zc=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),Bc=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),Vc=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new Pc:Ic(e)?new Fc(e.message):zc(e)?new Lc:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new Rc:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new Fc(e.message):e},Y=()=>(kc(),{generation:Ac()}),Hc=/* @__PURE__ */ new Map,Uc=null,Wc=e=>typeof e?.accountPin==`function`,Gc=(e,t)=>{let n=Promise.resolve(t.accountPin()).then(t=>{if(typeof t!=`string`||!t)throw Error(`storage: the broker answered no account pin`);return Ac()===e&&Hc.set(e,t),t});return Uc={generation:e,pin:n},n.catch(()=>{Uc?.pin===n&&(Uc=null)}),n},Kc=async(e,t)=>{let n=Hc.get(e.generation);if(n!==void 0)return n;if(e.generation!==Ac())throw new Lc;let r=await(Uc?.generation===e.generation?Uc.pin:Gc(e.generation,t)).catch(Vc);if(e.generation!==Ac())throw new Lc;return r},qc=e=>Hc.get(e.generation),Jc=async e=>{let t=(await U).cloud.fs;if(!Wc(t))throw new Rc;return Kc(e,t)},Yc=e=>{for(let[t,n]of Hc)if(n===e)return t},Xc=e=>e?.pin??Y(),Zc=async(e,t)=>{let n=(await U).cloud.fs;if(!Wc(n))throw new Rc;let r=`pin`in e?e.pin:await Kc(e,n);if(!Wc(n))throw new Rc;return t(n,{accountPin:r}).catch(t=>{if(zc(t)){let t=`generation`in e?e.generation:Yc(r);t!==void 0&&Mc(t)}return Vc(t)})},Qc=()=>U.then(e=>e.cloud.fs.available()).catch(()=>!1),$c=8e3,el=1e3,tl=!1,nl=async()=>{let e=(await U).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},rl=async()=>{let e=tl?el:$c,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);nl().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(tl=!0,`unknown`):(tl=!1,t)},il=e=>Zc(Xc(e),(e,t)=>e.list(t)),al=()=>U.then(e=>e.cloud.fs.quota()),ol=async(e,t)=>{let n=await Zc(Xc(t),(t,n)=>t.readFile(e,n));return new Blob([n])},sl=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},cl=async(e,t)=>Zc(Xc(t),async(t,n)=>{let r=t;if(typeof r.readFileSealed!=`function`)return{data:await t.readFile(e,n),sealedAt:null};let i=await r.readFileSealed(e,n);return{data:i.bytes,sealedAt:sl(i.sealedAt)}}),ll=async(e,t,n)=>{let r=Xc(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await Zc(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},ul=async(e,t)=>{await Zc(Xc(t),(t,n)=>t.remove(e,n))},dl=()=>U.then(e=>e.cloud.fs.encryption()),fl=()=>U.then(e=>e.cloud.fs.unlock()),pl=/* @__PURE__ */ g({STORAGE_ACCOUNT_CHANGED:()=>yc,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>bc,STORAGE_NOT_FOUND:()=>vc,StorageAccountChangedError:()=>Lc,StorageAccountPinUnsupportedError:()=>Rc,StorageLockedError:()=>Pc,StorageNotFoundError:()=>Fc,availability:()=>rl,available:()=>ml,encryption:()=>dl,isAccountChanged:()=>zc,isNotFound:()=>Ic,list:()=>wl,mkdir:()=>bl,promises:()=>Cl,quota:()=>al,readFile:()=>hl,readFileSealed:()=>Tl,readdir:()=>yl,rename:()=>vl,rm:()=>xl,stat:()=>Sl,unlink:()=>_l,unlock:()=>fl,writeFile:()=>gl}),{available:ml,readFile:hl,writeFile:gl,unlink:_l,rename:vl,readdir:yl,mkdir:bl,rm:xl,stat:Sl,promises:Cl}=_c(Nc,{memfs:!1}),wl=()=>il(),Tl=e=>cl(e),El=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AddressError=void 0,e.AddressError=class extends Error{constructor(e,t){super(e),this.name=`AddressError`,this.parseMessage=t}}})),Dl=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.isInSubnet=n,e.isHostInSubnet=r,e.isGloballyReachable=i,e.offsetBigInt=a,e.isCorrect=o,e.prefixLengthFromMask=s,e.assertByteArray=c,e.numberToPaddedHex=l,e.stringToPaddedHex=u,e.testBit=d;var t=El();function n(e){return this.subnetMask<e.subnetMask?!1:r.call(this,e)}function r(e){return this.binaryZeroPad().length===e.binaryZeroPad().length&&this.mask(e.subnetMask)===e.mask()}function i(e){let t=null;for(let n=0;n<e.length;n++){let i=e[n];i.reachable!==null&&r.call(this,i.subnet)&&(t===null||i.subnet.subnetMask>t.subnet.subnetMask)&&(t=i)}return t===null||t.reachable}function a(e,n,r,i){if(typeof n==`number`&&!Number.isSafeInteger(n)||typeof n!=`number`&&typeof n!=`bigint`)throw new t.AddressError(`${i} offset must be an integer`);let a=e+BigInt(n);if(a<BigInt(0)||a>(BigInt(1)<<BigInt(r))-BigInt(1))throw new t.AddressError(`${i} offset leaves the address space`);return a}function o(e){return function(){return this.addressMinusSuffix===this.correctForm()?this.subnetMask===e&&!this.parsedSubnet||this.parsedSubnet===String(this.subnetMask):!1}}function s(e,n){let r=e.toString(2).padStart(n,`0`);if(r.length>n)throw new t.AddressError(`Invalid subnet mask.`);let i=r.indexOf(`0`);if(i===-1)return n;if(r.slice(i).includes(`1`))throw new t.AddressError(`Invalid subnet mask.`);return i}function c(e,n,r,i){if(e.length!==n)throw new t.AddressError(`${r} addresses require exactly ${n} bytes`);for(let n=0;n<e.length;n++)if(!Number.isInteger(e[n])||e[n]<i||e[n]>255)throw new t.AddressError(`All bytes must be integers between ${i} and 255`)}function l(e){return e.toString(16).padStart(2,`0`)}function u(e){return l(parseInt(e,10))}function d(e,t){let{length:n}=e;if(t>n)return!1;let r=n-t;return e.substring(r,r+1)===`1`}})),Ol=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_SUBNET_STRING=e.RE_ADDRESS=e.GROUPS=e.BITS=void 0,e.BITS=32,e.GROUPS=4,e.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/g,e.RE_SUBNET_STRING=/\/\d{1,2}$/,e.SPECIAL_PURPOSE=[[`0.0.0.0/8`,`This network`,!1],[`0.0.0.0/32`,`This host on this network`,!1],[`10.0.0.0/8`,`Private-Use`,!1],[`100.64.0.0/10`,`Shared Address Space`,!1],[`127.0.0.0/8`,`Loopback`,!1],[`169.254.0.0/16`,`Link Local`,!1],[`172.16.0.0/12`,`Private-Use`,!1],[`192.0.0.0/24`,`IETF Protocol Assignments`,!1],[`192.0.0.0/29`,`IPv4 Service Continuity Prefix`,!1],[`192.0.0.8/32`,`IPv4 dummy address`,!1],[`192.0.0.9/32`,`Port Control Protocol Anycast`,!0],[`192.0.0.10/32`,`Traversal Using Relays around NAT Anycast`,!0],[`192.0.0.170/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.0.171/32`,`NAT64/DNS64 Discovery`,!1],[`192.0.2.0/24`,`Documentation (TEST-NET-1)`,!1],[`192.31.196.0/24`,`AS112-v4`,!0],[`192.52.193.0/24`,`AMT`,!0],[`192.88.99.0/24`,`Deprecated (6to4 Relay Anycast)`,null],[`192.88.99.2/32`,`6a44-relay anycast address`,!1],[`192.168.0.0/16`,`Private-Use`,!1],[`192.175.48.0/24`,`Direct Delegation AS112 Service`,!0],[`198.18.0.0/15`,`Benchmarking`,!1],[`198.51.100.0/24`,`Documentation (TEST-NET-2)`,!1],[`203.0.113.0/24`,`Documentation (TEST-NET-3)`,!1],[`240.0.0.0/4`,`Reserved`,!1],[`255.255.255.255/32`,`Limited Broadcast`,!1]]})),kl=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.Address4=void 0;var o=a(Dl()),s=a(Ol()),c=El(),l=o.isCorrect(s.BITS),u=class e{constructor(e){this.addressMinusSuffix=``,this.groups=s.GROUPS,this.parsedAddress=[],this.parsedSubnet=``,this.subnet=`/32`,this.subnetMask=32,this.v4=!0,this.isCorrect=l,this.isInSubnet=o.isInSubnet,this.isHostInSubnet=o.isHostInSubnet,this.address=e;let t=s.RE_SUBNET_STRING.exec(e);if(t){if(this.parsedSubnet=t[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>s.BITS)throw new c.AddressError(`Invalid subnet mask.`);e=e.replace(s.RE_SUBNET_STRING,``)}let n=s.GROUPS*4-1;if(e.length>n)throw new c.AddressError(`IPv4 addresses are at most ${n} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(e)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(e){let t=e.split(`.`);if(t.some(e=>/^0\d/.test(e)))throw new c.AddressError(`IPv4 addresses can't have leading zeroes.`);if(!e.match(s.RE_ADDRESS))throw new c.AddressError(`Invalid IPv4 address.`);return t}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(`.`)}static fromAddressAndMask(t,n){let r=o.prefixLengthFromMask(new e(n).bigInt(),s.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(s.BITS))-BigInt(1),i=o.prefixLengthFromMask(r,s.BITS);return new e(`${t}/${i}`)}static fromWildcard(t){let n=t.split(`.`);if(n.length!==s.GROUPS)throw new c.AddressError(`Wildcard pattern must have 4 octets`);let r=-1;for(let e=0;e<n.length;e++)if(n[e]===`*`)r===-1&&(r=e);else if(r!==-1)throw new c.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let i=r===-1?0:n.length-r,a=n.map(e=>e===`*`?`0`:e),o=s.BITS-i*8;return new e(`${a.join(`.`)}/${o}`)}static fromHex(t){let n=t.replace(/:/g,``);if(!/^[0-9a-fA-F]{8}$/.test(n))throw new c.AddressError(`IPv4 hex must be exactly 8 hex digits`);let r=[];for(let e=0;e<8;e+=2)r.push(parseInt(n.slice(e,e+2),16));return new e(r.join(`.`))}static fromInteger(t){if(!Number.isInteger(t)||t<0||t>4294967295)throw new c.AddressError(`IPv4 integer must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromArpa(t){let n=s.GROUPS*4-1+3+14;if(t.length>n)throw new c.AddressError(`in-addr.arpa names are at most ${n} characters.`);let r=t.replace(/(\.in-addr\.arpa)?\.?$/i,``).split(`.`).reverse().join(`.`);return new e(r)}toHex(){return this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(`:`)}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e=[],t=0;for(;t<s.GROUPS;t+=2)e.push(`${o.stringToPaddedHex(this.parsedAddress[t])}${o.stringToPaddedHex(this.parsedAddress[t+1])}`);return e.join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>o.stringToPaddedHex(e)).join(``)}`)}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(s.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}offset(t){return e.fromBigInt(o.offsetBigInt(this.bigInt(),t,s.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(o.offsetBigInt(this._endAddress(),1,s.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(s.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(s.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(s.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt(t){if(t<BigInt(0)||t>BigInt(4294967295))throw new c.AddressError(`IPv4 BigInt must be in the range 0 to 2**32 - 1`);return e.fromHex(t.toString(16).padStart(8,`0`))}static fromByteArray(e){return o.assertByteArray(e,4,`IPv4`,0),this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(t){if(t.length!==4)throw new c.AddressError(`IPv4 addresses require exactly 4 bytes`);let n=t.join(`.`);return new e(n)}mask(e){return e===void 0&&(e=this.subnetMask),this.getBitsBase2(0,e)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}reverseForm(e){e||={};let t=this.correctForm().split(`.`).reverse().join(`.`);return e.omitSuffix?t:`${t}.in-addr.arpa.`}isMulticast(){return this.isHostInSubnet(d)}isPrivate(){return f.some(e=>this.isHostInSubnet(e))}isLoopback(){return this.isHostInSubnet(p)}isLinkLocal(){return this.isHostInSubnet(m)}isUnspecified(){return this.isHostInSubnet(h)}isBroadcast(){return this.isHostInSubnet(g)}isCGNAT(){return this.isHostInSubnet(_)}isDocumentation(){return v.some(e=>this.isHostInSubnet(e))}isBenchmarking(){return this.isHostInSubnet(y)}isReserved(){return this.isHostInSubnet(b)}isGlobal(){return!this.isMulticast()&&o.isGloballyReachable.call(this,x)}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(s.BITS,`0`)),this._binaryZeroPad}groupForV6(){let e=this.parsedAddress;return this.correctForm().replace(s.RE_ADDRESS,`<span class="hover-group group-v4 group-6">${e.slice(0,2).join(`.`)}</span>.<span class="hover-group group-v4 group-7">${e.slice(2,4).join(`.`)}</span>`)}};e.Address4=u;var d=new u(`224.0.0.0/4`),f=[new u(`10.0.0.0/8`),new u(`172.16.0.0/12`),new u(`192.168.0.0/16`)],p=new u(`127.0.0.0/8`),m=new u(`169.254.0.0/16`),h=new u(`0.0.0.0/32`),g=new u(`255.255.255.255/32`),_=new u(`100.64.0.0/10`),v=[new u(`192.0.2.0/24`),new u(`198.51.100.0/24`),new u(`203.0.113.0/24`)],y=new u(`198.18.0.0/15`),b=new u(`240.0.0.0/4`),x=s.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new u(e),reachable:t}))})),Al=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SPECIAL_PURPOSE=e.RE_URL_WITH_PORT=e.RE_URL=e.RE_ZONE_STRING=e.RE_SUBNET_STRING=e.RE_BAD_ADDRESS=e.RE_BAD_CHARACTERS=e.TYPES=e.SCOPES=e.GROUPS=e.BITS=void 0,e.BITS=128,e.GROUPS=8,e.SCOPES={0:`Reserved`,1:`Interface local`,2:`Link local`,4:`Admin local`,5:`Site local`,8:`Organization local`,14:`Global`,15:`Reserved`},e.TYPES={"ff01::1/128":`Multicast (All nodes on this interface)`,"ff01::2/128":`Multicast (All routers on this interface)`,"ff02::1/128":`Multicast (All nodes on this link)`,"ff02::2/128":`Multicast (All routers on this link)`,"ff05::2/128":`Multicast (All routers in this site)`,"ff02::5/128":`Multicast (OSPFv3 AllSPF routers)`,"ff02::6/128":`Multicast (OSPFv3 AllDR routers)`,"ff02::9/128":`Multicast (RIP routers)`,"ff02::a/128":`Multicast (EIGRP routers)`,"ff02::d/128":`Multicast (PIM routers)`,"ff02::16/128":`Multicast (MLDv2 reports)`,"ff01::fb/128":`Multicast (mDNSv6)`,"ff02::fb/128":`Multicast (mDNSv6)`,"ff05::fb/128":`Multicast (mDNSv6)`,"ff02::1:2/128":`Multicast (All DHCP servers and relay agents on this link)`,"ff05::1:2/128":`Multicast (All DHCP servers and relay agents in this site)`,"ff02::1:3/128":`Multicast (All DHCP servers on this link)`,"ff05::1:3/128":`Multicast (All DHCP servers in this site)`,"::/128":`Unspecified`,"::1/128":`Loopback`,"::ffff:0:0/96":`IPv4-mapped`,"ff00::/8":`Multicast`,"fe80::/10":`Link-local unicast`,"fc00::/7":`Unique local`,"2001::/32":`Teredo`,"2001:2::/48":`Benchmarking`,"2002::/16":`6to4`,"2001:db8::/32":`Documentation`,"3fff::/20":`Documentation`,"100::/64":`Discard-only`,"fec0::/10":`Site-local unicast (deprecated)`,"::/96":`IPv4-compatible (deprecated)`,"64:ff9b::/96":`NAT64 (well-known)`,"64:ff9b:1::/48":`NAT64 (local-use)`},e.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi,e.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi,e.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/,e.RE_ZONE_STRING=/%.*$/,e.RE_URL=/^(?:\[([0-9a-f:.]+)\]|([0-9a-f:.]+))(?:[/?#].*)?$/i,e.RE_URL_WITH_PORT=/^\[([0-9a-f:.]+)\]:([0-9]{1,5})(?:[/?#].*)?$/i,e.SPECIAL_PURPOSE=[[`::1/128`,`Loopback Address`,!1],[`::/128`,`Unspecified Address`,!1],[`::ffff:0:0/96`,`IPv4-mapped Address`,!1],[`64:ff9b::/96`,`IPv4-IPv6 Translat.`,!0],[`64:ff9b:1::/48`,`IPv4-IPv6 Translat.`,!1],[`100::/64`,`Discard-Only Address Block`,!1],[`100:0:0:1::/64`,`Dummy IPv6 Prefix`,!1],[`2001::/23`,`IETF Protocol Assignments`,!1],[`2001::/32`,`TEREDO`,!1],[`2001:1::1/128`,`Port Control Protocol Anycast`,!0],[`2001:1::2/128`,`Traversal Using Relays around NAT Anycast`,!0],[`2001:1::3/128`,`DNS-SD Service Registration Protocol Anycast`,!0],[`2001:2::/48`,`Benchmarking`,!1],[`2001:3::/32`,`AMT`,!0],[`2001:4:112::/48`,`AS112-v6`,!0],[`2001:10::/28`,`Deprecated (previously ORCHID)`,null],[`2001:20::/28`,`ORCHIDv2`,!0],[`2001:30::/28`,`Drone Remote ID Protocol Entity Tags (DETs) Prefix`,!0],[`2001:db8::/32`,`Documentation`,!1],[`2002::/16`,`6to4`,!1],[`2620:4f:8000::/48`,`Direct Delegation AS112 Service`,!0],[`3fff::/20`,`Documentation`,!1],[`5f00::/16`,`Segment Routing (SRv6) SIDs`,!1],[`fc00::/7`,`Unique-Local`,!1],[`fe80::/10`,`Link-Local Unicast`,!1]]})),jl=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.escapeHtml=t,e.spanAllZeroes=n,e.spanAll=r,e.spanLeadingZeroes=a,e.simpleGroup=o;function t(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function n(e){return t(e).replace(/(0+)/g,`<span class="zero">$1</span>`)}function r(e,r=0){return e.split(``).map((e,i)=>`<span class="digit value-${t(e)} position-${i+r}">${n(e)}</span>`).join(``)}function i(e){return t(e).replace(/^(0+)/,`<span class="zero">$1</span>`)}function a(e){return e.split(`:`).map(e=>i(e)).join(`:`)}function o(e,t=0){return e.split(`:`).map((e,n)=>/group-v4/.test(e)?e:`<span class="hover-group group-${n+t}">${i(e)}</span>`)}})),Ml=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.ADDRESS_BOUNDARY=void 0,e.groupPossibilities=s,e.padGroup=c,e.simpleRegularExpression=l,e.possibleElisions=u;var o=a(Al());function s(e){return`(${e.join(`|`)})`}function c(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}e.ADDRESS_BOUNDARY=`[^A-Fa-f0-9:]`;function l(e){let t=[];e.forEach((e,n)=>{parseInt(e,16)===0&&t.push(n)});let n=t.map(t=>e.map((e,n)=>{if(n===t){let t=n===0||n===o.GROUPS-1?`:`:``;return s([c(e),t])}return c(e)}).join(`:`));return n.push(e.map(c).join(`:`)),s(n)}function u(e,t,n){let r=t?``:`:`,i=n?``:`:`,a=[];!t&&!n&&a.push(`::`),t&&n&&a.push(``),(n&&!t||!n&&t)&&a.push(`:`),a.push(`${r}(:0{1,4}){1,${e-1}}`),a.push(`(0{1,4}:){1,${e-1}}${i}`),a.push(`(0{1,4}:){${e-1}}0{1,4}`);for(let t=1;t<e-1;t++)for(let n=1;n<e-t;n++)a.push(`(0{1,4}:){${n}}:(0{1,4}:){${e-n-t-1}}0{1,4}`);return s(a)}})),Nl=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.Address6=void 0;var o=a(Dl()),s=a(Ol()),c=a(Al()),l=a(jl()),u=kl(),d=Ml(),f=El(),p=Dl(),m=o.isCorrect(c.BITS);function h(e){if(!e)throw Error(`Assertion failed.`)}function g(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,`$1,$2`);return e}function _(e){return e=e.replace(/^(0{1,})([1-9]+)$/,`<span class="parse-error">$1</span>$2`),e=e.replace(/^(0{1,})(0)$/,`<span class="parse-error">$1</span>$2`),e}function v(e,t){let n=[],r=[],i=0;for(;i<e.length;i++)i<t[0]?n.push(e[i]):i>t[1]&&r.push(e[i]);return n.concat([`compact`]).concat(r)}function y(e){return parseInt(e,16).toString(16).padStart(4,`0`)}function b(e){return e&255}var x=class e{constructor(e,t){this.addressMinusSuffix=``,this.parsedSubnet=``,this.subnet=`/128`,this.subnetMask=128,this.v4=!1,this.zone=``,this.isInSubnet=o.isInSubnet,this.isHostInSubnet=o.isHostInSubnet,this.isCorrect=m,this.groups=t===void 0?c.GROUPS:t,this.address=e;let n=c.RE_SUBNET_STRING.exec(e);if(n){if(this.parsedSubnet=n[0].replace(`/`,``),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>c.BITS)throw new f.AddressError(`Invalid subnet mask.`);e=e.replace(c.RE_SUBNET_STRING,``)}if(/\//.test(e))throw new f.AddressError(`Invalid subnet mask.`);let r=e.indexOf(`%`);r!==-1&&/^.*$/.test(e.slice(r))&&(this.zone=e.slice(r),e=e.slice(0,r));let i=this.groups*5+5;if(e.length>i)throw new f.AddressError(`IPv6 addresses are at most ${i} characters.`);this.addressMinusSuffix=e,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInt(t){if(t<BigInt(0)||t>(BigInt(1)<<BigInt(c.BITS))-BigInt(1))throw new f.AddressError(`IPv6 BigInt must be in the range 0 to 2**128 - 1`);let n=t.toString(16).padStart(32,`0`),r=[];for(let e=0;e<c.GROUPS;e++)r.push(n.slice(e*4,(e+1)*4));return new e(r.join(`:`))}static fromURL(t){let n,r=null,i,a,o=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``);if(o.indexOf(`[`)!==-1&&o.indexOf(`]:`)!==-1){if(a=`failed to parse address with port`,i=c.RE_URL_WITH_PORT.exec(o),i===null)return{error:a,address:null,port:null};n=i[1],r=i[2]}else{if(a=`failed to parse address from URL`,i=c.RE_URL.exec(o),i===null)return{error:a,address:null,port:null};n=i[1]??i[2]}r?(r=parseInt(r,10),(r<0||r>65535)&&(r=null)):r=null;let s;try{s=new e(n)}catch{return{error:a,address:null,port:null}}return{address:s,port:r}}static fromAddressAndMask(t,n){let r=o.prefixLengthFromMask(new e(n).bigInt(),c.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(c.BITS))-BigInt(1),i=o.prefixLengthFromMask(r,c.BITS);return new e(`${t}/${i}`)}static fromWildcard(t){if(t.includes(`%`)||t.includes(`/`))throw new f.AddressError(`Wildcard pattern must not include a zone or CIDR suffix`);let n=t.split(`::`);if(n.length>2)throw new f.AddressError(`Wildcard pattern cannot contain more than one '::'`);let r;if(n.length===2){let e=n[0]===``?[]:n[0].split(`:`),t=n[1]===``?[]:n[1].split(`:`),i=c.GROUPS-e.length-t.length;if(i<1)throw new f.AddressError(`Wildcard pattern with '::' has too many groups`);r=[...e,...Array(i).fill(`0`),...t]}else r=t.split(`:`);if(r.length!==c.GROUPS)throw new f.AddressError(`Wildcard pattern must have 8 groups`);let i=-1;for(let e=0;e<r.length;e++)if(r[e]===`*`)i===-1&&(i=e);else if(i!==-1)throw new f.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let a=i===-1?0:r.length-i,o=r.map(e=>e===`*`?`0`:e),s=c.BITS-a*16;return new e(`${o.join(`:`)}/${s}`)}static fromAddress4(t){let n=new u.Address4(t),r=c.BITS-(s.BITS-n.subnetMask);return new e(`::ffff:${n.correctForm()}/${r}`)}static fromArpa(t){let n=t.replace(/(\.ip6\.arpa)?\.?$/i,``);if(!/^[0-9a-f](\.[0-9a-f]){0,31}$/i.test(n))throw new f.AddressError(`Invalid 'ip6.arpa' form.`);let r=n.split(`.`).reverse(),i=r.length*4,a=r.join(``).padEnd(32,`0`),o=[];for(let e=0;e<c.GROUPS;e++)o.push(a.slice(e*4,(e+1)*4));return new e(`${o.join(`:`)}/${i}`)}microsoftTranscription(){return`${this.correctForm().replace(/:/g,`-`)}.ipv6-literal.net`}mask(e=this.subnetMask){return this.getBitsBase2(0,e)}possibleSubnets(e=128){let t=c.BITS-this.subnetMask-Math.abs(e-c.BITS);return t<0?`0`:g((BigInt(`2`)**BigInt(t)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(c.BITS-this.subnetMask)}`)}startAddress(){return e.fromBigInt(this._startAddress())}startAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._startAddress()+t)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(c.BITS-this.subnetMask)}`)}endAddress(){return e.fromBigInt(this._endAddress())}endAddressExclusive(){let t=BigInt(`1`);return e.fromBigInt(this._endAddress()-t)}offset(t){return e.fromBigInt(o.offsetBigInt(this.bigInt(),t,c.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(o.offsetBigInt(this._endAddress(),1,c.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}subnetMaskAddress(){return e.fromBigInt(BigInt(`0b${`1`.repeat(this.subnetMask)}${`0`.repeat(c.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(c.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let e=this.getType();return e===`Multicast`||e.startsWith(`Multicast `)?c.SCOPES[parseInt(this.getBits(12,16).toString(10),10)]||`Unknown`:e===`Link-local unicast`||e===`Loopback`?`Link local`:e===`Unspecified`?`Unknown`:`Global`}getType(){for(let e=0;e<S.length;e++){let t=S[e];if(this.isHostInSubnet(t[0]))return t[1]}return`Global unicast`}getBits(e,t){return BigInt(`0b${this.getBitsBase2(e,t)}`)}getBitsBase2(e,t){return this.binaryZeroPad().slice(e,t)}getBitsBase16(e,t){let n=t-e;if(n%4!=0)throw Error(`Length of bits to retrieve must be divisible by four`);return this.getBits(e,t).toString(16).padStart(n/4,`0`)}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,c.BITS)}reverseForm(e){e||={};let t=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,``).split(``).slice(0,t).reverse().join(`.`);return t>0?e.omitSuffix?n:`${n}.ip6.arpa.`:e.omitSuffix?``:`ip6.arpa.`}correctForm(){let e,t=[],n=0,r=[];for(e=0;e<this.parsedAddress.length;e++){let t=parseInt(this.parsedAddress[e],16);t===0&&n++,t!==0&&n>0&&(n>1&&r.push([e-n,e-1]),n=0)}n>1&&r.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let i=r.map(e=>e[1]-e[0]+1);if(r.length>0){let e=i.indexOf(Math.max(...i));t=v(this.parsedAddress,r[e])}else t=this.parsedAddress;for(e=0;e<t.length;e++)t[e]!==`compact`&&(t[e]=parseInt(t[e],16).toString(16));let a=t.join(`:`);return a=a.replace(/^compact$/,`::`),a=a.replace(/(^compact)|(compact$)/,`:`),a=a.replace(/compact/,``),a}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(c.BITS,`0`)),this._binaryZeroPad}parse4in6(e){if(e.indexOf(`.`)===-1)return e;let t=e.split(`:`),n=t.slice(-1)[0],r=n.split(`.`);if(r.length===s.GROUPS&&r.every(e=>/^\d{1,3}$/.test(e))&&r.some(e=>/^0\d/.test(e))){let e=r.map(_).join(`.`),n=t.slice(0,-1).map(l.escapeHtml).join(`:`),i=t.length>1?`:`:``;throw new f.AddressError(`IPv4 addresses can't have leading zeroes.`,`${n}${i}${e}`)}let i=n.match(s.RE_ADDRESS);if(i){this.parsedAddress4=i[0];let n=this.subnetMask>=96?`/${this.subnetMask-96}`:``;this.address4=new u.Address4(`${this.parsedAddress4}${n}`),this.v4=!0,t[t.length-1]=this.address4.toGroup6(),e=t.join(`:`)}return e}parse(e){e=this.parse4in6(e);let t=e.match(c.RE_BAD_CHARACTERS);if(t)throw new f.AddressError(`Bad character${t.length>1?`s`:``} detected in address: ${t.join(``)}`,e.replace(c.RE_BAD_CHARACTERS,`<span class="parse-error">$1</span>`));let n=e.match(c.RE_BAD_ADDRESS);if(n)throw new f.AddressError(`Address failed regex: ${n.join(``)}`,e.replace(c.RE_BAD_ADDRESS,`<span class="parse-error">$1</span>`));let r=[],i=e.split(`::`);if(i.length===2){let e=i[0].split(`:`),t=i[1].split(`:`);e.length===1&&e[0]===``&&(e=[]),t.length===1&&t[0]===``&&(t=[]);let n=this.groups-(e.length+t.length);if(!n)throw new f.AddressError(`Error parsing groups`);this.elidedGroups=n,this.elisionBegin=e.length,this.elisionEnd=e.length+this.elidedGroups,r=r.concat(e);for(let e=0;e<n;e++)r.push(`0`);r=r.concat(t)}else if(i.length===1)r=e.split(`:`),this.elidedGroups=0;else throw new f.AddressError(`Too many :: groups found`);if(r=r.map(e=>parseInt(e,16).toString(16)),r.length!==this.groups)throw new f.AddressError(`Incorrect number of groups found`);return r}canonicalForm(){return this.parsedAddress.map(y).join(`:`)}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,`0`)).join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(y).join(``)}`)}to4(){let e=this.binaryZeroPad().split(``),t=BigInt(`0b${e.slice(96,128).join(``)}`).toString(16).padStart(8,`0`);if(this.subnetMask>=96){let e=this.subnetMask-96,n=[];for(let e=0;e<8;e+=2)n.push(parseInt(t.slice(e,e+2),16));return new u.Address4(`${n.join(`.`)}/${e}`)}return u.Address4.fromHex(t)}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(`:`),6).correctForm(),r=``;return/:$/.test(n)||(r=`:`),n+r+t.correctForm()}inspectTeredo(){let e=this.getBitsBase16(0,32),t=(this.getBits(80,96)^BigInt(`0xffff`)).toString(),n=u.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),i=u.Address4.fromHex((r^BigInt(`0xffffffff`)).toString(16).padStart(8,`0`)),a=this.getBitsBase2(64,80),o=(0,p.testBit)(a,15),s=(0,p.testBit)(a,14),c=(0,p.testBit)(a,8),l=(0,p.testBit)(a,9),d=BigInt(`0b${a.slice(2,6)+a.slice(8,16)}`).toString(10);return{prefix:`${e.slice(0,4)}:${e.slice(4,8)}`,server4:n.address,client4:i.address,flags:a,coneNat:o,microsoft:{reserved:s,universalLocal:l,groupIndividual:c,nonce:d},udpPort:t}}inspect6to4(){let e=this.getBitsBase16(0,16),t=u.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:e.slice(0,4),gateway:t.address}}to6to4(){if(!this.is4())return null;let t=[`2002`,this.getBitsBase16(96,112),this.getBitsBase16(112,128),``,`/16`].join(`:`);return new e(t)}static fromAddress4Nat64(t,n=`64:ff9b::/96`){let r=new u.Address4(t),i=new e(n),a=i.subnetMask;if(a!==32&&a!==40&&a!==48&&a!==56&&a!==64&&a!==96)throw new f.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);let o=i.binaryZeroPad(),s=r.binaryZeroPad(),c;if(a===96)c=o.slice(0,96)+s;else{let e=64-a;c=[o.slice(0,a),s.slice(0,e),`00000000`,s.slice(e),`0`.repeat(56-(32-e))].join(``)}let l=BigInt(`0b${c}`).toString(16).padStart(32,`0`),d=[];for(let e=0;e<8;e++)d.push(l.slice(e*4,(e+1)*4));return new e(d.join(`:`))}toAddress4Nat64(t=`64:ff9b::/96`){let n=new e(t),r=n.subnetMask;if(r!==32&&r!==40&&r!==48&&r!==56&&r!==64&&r!==96)throw new f.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);if(!this.isHostInSubnet(n))return null;let i=this.binaryZeroPad(),a;if(r===96)a=i.slice(96,128);else{let e=64-r;a=i.slice(r,r+e)+i.slice(72,72+(32-e))}let o=[];for(let e=0;e<4;e++)o.push(parseInt(a.slice(e*8,(e+1)*8),2).toString());return new u.Address4(o.join(`.`))}toByteArray(){let e=this.bigInt().toString(16).padStart(c.BITS/4,`0`),t=[];for(let n=0,r=e.length;n<r;n+=2)t.push(parseInt(e.substring(n,n+2),16));return t}toUnsignedByteArray(){return this.toByteArray().map(b)}static fromByteArray(e){return o.assertByteArray(e,16,`IPv6`,-128),this.fromUnsignedByteArray(e.map(b))}static fromUnsignedByteArray(t){o.assertByteArray(t,16,`IPv6`,0);let n=BigInt(`256`),r=BigInt(`0`),i=BigInt(`1`);for(let e=t.length-1;e>=0;e--)r+=i*BigInt(t[e].toString(10)),i*=n;return e.fromBigInt(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let e=this.embeddedIPv4();return e?e.isLinkLocal():this.isHostInSubnet(E)}isMulticast(){let e=this.embeddedIPv4();if(e)return e.isMulticast();let t=this.getType();return t===`Multicast`||t.startsWith(`Multicast `)}is4(){return this.v4}isMapped4(){return this.isHostInSubnet(j)}embeddedIPv4(){return this.isMapped4()||this.isHostInSubnet(M)?this.to4():null}isTeredo(){return this.isHostInSubnet(C)}is6to4(){return this.isHostInSubnet(w)}isLoopback(){let e=this.embeddedIPv4();return e?e.isLoopback():this.getType()===`Loopback`}isULA(){return this.isHostInSubnet(T)}isPrivate(){let e=this.embeddedIPv4();return e?e.isPrivate():this.isULA()||this.isHostInSubnet(N)}isCGNAT(){let e=this.embeddedIPv4();return e?e.isCGNAT():!1}isBroadcast(){let e=this.embeddedIPv4();return e?e.isBroadcast():!1}isUnspecified(){let e=this.embeddedIPv4();return e?e.isUnspecified():this.getType()===`Unspecified`}isDocumentation(){return D.some(e=>this.isHostInSubnet(e))}isBenchmarking(){let e=this.embeddedIPv4();return e?e.isBenchmarking():this.isHostInSubnet(O)}isGlobal(){let e=this.embeddedIPv4();return e?e.isGlobal():this.isHostInSubnet(k)&&o.isGloballyReachable.call(this,A)}href(e){return e=e===void 0?``:`:${e}`,`http://[${this.correctForm()}]${e}/`}link(e){e||={},e.className===void 0&&(e.className=``),e.prefix===void 0&&(e.prefix=`/#address=`),e.v4===void 0&&(e.v4=!1);let t=this.correctForm;e.v4&&(t=this.to4in6);let n=t.call(this),r=l.escapeHtml(`${e.prefix}${n}`),i=l.escapeHtml(n);return e.className?`<a href="${r}" class="${l.escapeHtml(e.className)}">${i}</a>`:`<a href="${r}">${i}</a>`}group(){if(this.elidedGroups===0)return l.simpleGroup(this.addressMinusSuffix).join(`:`);h(typeof this.elidedGroups==`number`),h(typeof this.elisionBegin==`number`);let e=[],[t,n]=this.addressMinusSuffix.split(`::`);t.length?e.push(...l.simpleGroup(t)):e.push(``);let r=[`hover-group`];for(let e=this.elisionBegin;e<this.elisionBegin+this.elidedGroups;e++)r.push(`group-${e}`);return e.push(`<span class="${r.join(` `)}"></span>`),n.length?e.push(...l.simpleGroup(n,this.elisionEnd)):e.push(``),this.is4()&&(h(this.address4 instanceof u.Address4),e.pop(),e.push(this.address4.groupForV6())),e.join(`:`)}regularExpressionString(t=!1){let n=[],r=new e(this.correctForm());if(r.elidedGroups===0)n.push((0,d.simpleRegularExpression)(r.parsedAddress));else if(r.elidedGroups===c.GROUPS)n.push((0,d.possibleElisions)(c.GROUPS));else{let e=r.address.split(`::`);e[0].length&&n.push((0,d.simpleRegularExpression)(e[0].split(`:`))),h(typeof r.elidedGroups==`number`),n.push((0,d.possibleElisions)(r.elidedGroups,e[0].length!==0,e[1].length!==0)),e[1].length&&n.push((0,d.simpleRegularExpression)(e[1].split(`:`))),n=[n.join(`:`)]}return t||(n=[`(?=^|`,d.ADDRESS_BOUNDARY,`|[^\\w\\:])(`,...n,`)(?=[^\\w\\:]|`,d.ADDRESS_BOUNDARY,`|$)`]),n.join(``)}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),`i`)}};e.Address6=x;var S=Object.keys(c.TYPES).map(e=>[new x(e),c.TYPES[e]]),C=new x(`2001::/32`),w=new x(`2002::/16`),T=new x(`fc00::/7`),E=new x(`fe80::/10`),D=[new x(`2001:db8::/32`),new x(`3fff::/20`)],O=new x(`2001:2::/48`),k=new x(`2000::/3`),A=c.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new x(e),reachable:t})),j=new x(`::ffff:0:0/96`),M=new x(`64:ff9b::/96`),N=new x(`64:ff9b:1::/48`)})),Pl=(/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),a=n&&n.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)n!=="default"&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(e,"__esModule",{value:!0}),e.v6=e.AddressError=e.Address6=e.Address4=void 0;var o=kl();Object.defineProperty(e,"Address4",{enumerable:!0,get:function(){return o.Address4}});var s=Nl();Object.defineProperty(e,"Address6",{enumerable:!0,get:function(){return s.Address6}});var c=El();Object.defineProperty(e,"AddressError",{enumerable:!0,get:function(){return c.AddressError}}),e.v6={helpers:a(jl())}})))(),Fl=new TextEncoder,Il=e=>Pl.Address4.isValid(e),Ll=e=>Pl.Address6.isValid(e),Rl=e=>Il(e)?4:Ll(e)?6:0,zl=(...e)=>{if(typeof e[0]==`string`)throw Error(`FKN WebVPN does not support IPC connections`);let t=typeof e.at(-1)==`function`?e.at(-1):void 0;return e[0]&&typeof e[0]==`object`?{...e[0],callback:t}:{port:typeof e[0]==`function`?0:e[0]??0,host:typeof e[1]==`string`?e[1]:void 0,callback:t}},Bl=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=typeof e[0]==`function`?0:e[0]??0,r=typeof e[1]==`string`?e[1]:void 0;return typeof e[0]==`object`?{...e[0],address:e[0].address??r,port:e[0].port??0,callback:t}:{address:r,port:n,callback:t}},Vl=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=e[0];if(typeof e[2]==`number`)return{message:n,hasRange:!0,offset:e[1],length:e[2],port:typeof e[3]==`number`?e[3]:0,address:typeof e[4]==`string`?e[4]:void 0,callback:t};{let r=typeof e[1]==`number`?e[1]:0,i=typeof e[2]==`string`?e[2]:void 0;return{message:n,hasRange:!1,offset:0,length:n.length,port:r,address:i,callback:t}}},Hl=`webvpn-udp-port-ack`,Ul=`read ECONNRESET`,Wl=()=>Object.assign(/* @__PURE__ */ Error(Ul),{code:`ECONNRESET`,errno:-104,syscall:`read`}),Gl={ECONNREFUSED:-111,ETIMEDOUT:-110,EHOSTUNREACH:-113,ENETUNREACH:-101},Kl=(e,t,n)=>{let r=e===`ENETUNREACH`?` - Local (${t.includes(`:`)?`::`:`0.0.0.0`}:0)`:``;return Object.assign(/* @__PURE__ */ Error(`connect ${e} ${t}:${n}${r}`),{errno:Gl[e],code:e,syscall:`connect`,address:t,port:n})},ql=e=>Object.assign(/* @__PURE__ */ Error(`getaddrinfo ENOTFOUND ${e}`),{errno:-3008,code:`ENOTFOUND`,syscall:`getaddrinfo`,hostname:e}),Jl=/^connect (ECONNREFUSED|ETIMEDOUT|EHOSTUNREACH|ENETUNREACH) (\S+):(\d+)(?: - Local \(\S+\))?$/,Yl=/^getaddrinfo ENOTFOUND (\S+)$/,Xl=e=>{let t=e?.message;if(typeof t!=`string`)return e;if(t===`read ECONNRESET`)return Wl();let n=Jl.exec(t);if(n)return Kl(n[1],n[2],Number(n[3]));let r=Yl.exec(t);return r?ql(r[1]):e},Zl=/* @__PURE__ */ e(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=/* @__PURE__ */ Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=/* @__PURE__ */ Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})),Ql=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Object.create==`function`?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}})),$l,eu=n((()=>{$l=globalThis||self})),tu=/* @__PURE__ */ e(((e,t)=>{t.exports=Zl().EventEmitter})),nu=/* @__PURE__ */ e(((e,t)=>{t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,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 a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}})),ru=/* @__PURE__ */ e(((e,t)=>{var n=nu();t.exports=function(){return n()&&!!Symbol.toStringTag}})),iu=/* @__PURE__ */ e(((e,t)=>{t.exports=Object})),au=/* @__PURE__ */ e(((e,t)=>{t.exports=Error})),ou=/* @__PURE__ */ e(((e,t)=>{t.exports=EvalError})),su=/* @__PURE__ */ e(((e,t)=>{t.exports=RangeError})),cu=/* @__PURE__ */ e(((e,t)=>{t.exports=ReferenceError})),lu=/* @__PURE__ */ e(((e,t)=>{t.exports=SyntaxError})),uu=/* @__PURE__ */ e(((e,t)=>{t.exports=TypeError})),du=/* @__PURE__ */ e(((e,t)=>{t.exports=URIError})),fu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.abs})),pu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.floor})),mu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.max})),hu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.min})),gu=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.pow})),_u=/* @__PURE__ */ e(((e,t)=>{t.exports=Math.round})),vu=/* @__PURE__ */ e(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),yu=/* @__PURE__ */ e(((e,t)=>{var n=vu();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),bu=/* @__PURE__ */ e(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),xu=/* @__PURE__ */ e(((e,t)=>{var n=bu();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),Su=/* @__PURE__ */ e(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),Cu=/* @__PURE__ */ e(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=nu();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),wu=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),Tu=/* @__PURE__ */ e(((e,t)=>{t.exports=iu().getPrototypeOf||null})),Eu=/* @__PURE__ */ e(((e,t)=>{var n=Object.prototype.toString,r=Math.max,i=`[object Function]`,a=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},o=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},s=function(e,t){for(var n=``,r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};t.exports=function(e){var t=this;if(typeof t!=`function`||n.apply(t)!==i)throw TypeError(`Function.prototype.bind called on incompatible `+t);for(var c=o(arguments,1),l,u=function(){if(this instanceof l){var n=t.apply(this,a(c,arguments));return Object(n)===n?n:this}return t.apply(e,a(c,arguments))},d=r(0,t.length-c.length),f=[],p=0;p<d;p++)f[p]=`$`+p;if(l=Function(`binder`,`return function (`+s(f,`,`)+`){ return binder.apply(this,arguments); }`)(u),t.prototype){var m=function(){};m.prototype=t.prototype,l.prototype=new m,m.prototype=null}return l}})),Du=/* @__PURE__ */ e(((e,t)=>{var n=Eu();t.exports=Function.prototype.bind||n})),Ou=/* @__PURE__ */ e(((e,t)=>{t.exports=Function.prototype.call})),ku=/* @__PURE__ */ e(((e,t)=>{t.exports=Function.prototype.apply})),Au=/* @__PURE__ */ e(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),ju=/* @__PURE__ */ e(((e,t)=>{var n=Du(),r=ku(),i=Ou();t.exports=Au()||n.call(i,r)})),Mu=/* @__PURE__ */ e(((e,t)=>{var n=Du(),r=uu(),i=Ou(),a=ju();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),Nu=/* @__PURE__ */ e(((e,t)=>{var n=Mu(),r=xu(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`&&function(e){return s(e==null?e:o(e))}})),Pu=/* @__PURE__ */ e(((e,t)=>{var n=wu(),r=Tu(),i=Nu();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null})),Fu=/* @__PURE__ */ e(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=Du().call(n,r)})),Iu=/* @__PURE__ */ e(((e,t)=>{var n,r=iu(),i=au(),a=ou(),o=su(),s=cu(),c=lu(),l=uu(),u=du(),d=fu(),f=pu(),p=mu(),m=hu(),h=gu(),g=_u(),_=yu(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=xu(),x=Su(),S=function(){throw new l},C=b?function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}}():S,w=Cu()(),T=Pu(),E=Tu(),D=wu(),O=ku(),k=Ou(),A={},j=typeof Uint8Array>`u`||!T?n:T(Uint8Array),M={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":A,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T((/* @__PURE__ */ new Map())[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T((/* @__PURE__ */ new Set())[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":j,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":k,"%Function.prototype.apply%":O,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":E,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":D};if(T)try{null.error}catch(e){M[`%Error.prototype%`]=T(T(e))}var N=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return M[t]=n,n},ee={__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`]},te=Du(),P=Fu(),F=te.call(k,Array.prototype.concat),ne=te.call(O,Array.prototype.splice),re=te.call(k,String.prototype.replace),I=te.call(k,String.prototype.slice),L=te.call(k,RegExp.prototype.exec),ie=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ae=/\\(\\)?/g,oe=function(e){var t=I(e,0,1),n=I(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return re(e,ie,function(e,t,n,i){r[r.length]=n?re(i,ae,`$1`):t||e}),r},se=function(e,t){var n=e,r;if(P(ee,n)&&(r=ee[n],n=`%`+r[0]+`%`),P(M,n)){var i=M[n];if(i===A&&(i=N(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(L(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=oe(e),r=n.length>0?n[0]:``,i=se(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],ne(n,F([0,1],u)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],m=I(p,0,1),h=I(p,-1);if((m===`"`||m===`'`||m==="`"||h===`"`||h===`'`||h==="`")&&m!==h)throw new c(`property names with quotes must have matching quotes`);if(p!==`constructor`&&f||(s=!0),r+=`.`+p,a=`%`+r+`%`,P(M,a))o=M[a];else if(o!=null){if(!(p in o)){if(!t)throw new l(`base intrinsic for `+e+` exists, but the property is not available.`);return}if(b&&d+1>=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=P(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),Lu=/* @__PURE__ */ e(((e,t)=>{var n=Iu(),r=Mu(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}})),Ru=/* @__PURE__ */ e(((e,t)=>{var n=ru()(),r=Lu()(`Object.prototype.toString`),i=function(e){return n&&e&&typeof e==`object`&&Symbol.toStringTag in e?!1:r(e)===`[object Arguments]`},a=function(e){return i(e)?!0:typeof e==`object`&&!!e&&`length`in e&&typeof e.length==`number`&&e.length>=0&&r(e)!==`[object Array]`&&`callee`in e&&r(e.callee)===`[object Function]`},o=function(){return i(arguments)}();i.isLegacyArguments=a,t.exports=o?i:a})),zu=/* @__PURE__ */ e(((e,t)=>{var n=Lu(),r=ru()(),i=Fu(),a=xu(),o;if(r){var s=n(`RegExp.prototype.exec`),c={},l=function(){throw c},u={toString:l,valueOf:l};typeof Symbol.toPrimitive==`symbol`&&(u[Symbol.toPrimitive]=l),o=function(e){if(!e||typeof e!=`object`)return!1;var t=a(e,`lastIndex`);if(!(t&&i(t,`value`)))return!1;try{s(e,u)}catch(e){return e===c}}}else{var d=n(`Object.prototype.toString`),f=`[object RegExp]`;o=function(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:d(e)===f}}t.exports=o})),Bu=/* @__PURE__ */ e(((e,t)=>{var n=Lu(),r=zu(),i=n(`RegExp.prototype.exec`),a=uu();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),Vu=/* @__PURE__ */ e(((e,t)=>{var n=Lu(),r=Bu()(/^\s*(?:function)?\*/),i=ru()(),a=Pu(),o=n(`Object.prototype.toString`),s=n(`Function.prototype.toString`),c=function(){if(!i)return!1;try{return Function(`return function*() {}`)()}catch{}},l;t.exports=function(e){if(typeof e!=`function`)return!1;if(r(s(e)))return!0;if(!i)return o(e)===`[object GeneratorFunction]`;if(!a)return!1;if(l===void 0){var t=c();l=t?a(t):!1}return a(e)===l}})),Hu=/* @__PURE__ */ e(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},"length",{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return!s(e)&&(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Uu=/* @__PURE__ */ e(((e,t)=>{var n=Hu(),r=Object.prototype.toString,i=Object.prototype.hasOwnProperty,a=function(e,t,n){for(var r=0,a=e.length;r<a;r++)i.call(e,r)&&(n==null?t(e[r],r,e):t.call(n,e[r],r,e))},o=function(e,t,n){for(var r=0,i=e.length;r<i;r++)n==null?t(e.charAt(r),r,e):t.call(n,e.charAt(r),r,e)},s=function(e,t,n){for(var r in e)i.call(e,r)&&(n==null?t(e[r],r,e):t.call(n,e[r],r,e))};function c(e){return r.call(e)===`[object Array]`}t.exports=function(e,t,r){if(!n(t))throw TypeError(`iterator must be a function`);var i;arguments.length>=3&&(i=r),c(e)?a(e,t,i):typeof e==`string`?o(e,t,i):s(e,t,i)}})),Wu=/* @__PURE__ */ e(((e,t)=>{t.exports=[`Float16Array`,`Float32Array`,`Float64Array`,`Int8Array`,`Int16Array`,`Int32Array`,`Uint8Array`,`Uint8ClampedArray`,`Uint16Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`]})),Gu=/* @__PURE__ */ e(((e,t)=>{eu();var n=Wu(),r=typeof globalThis>`u`?$l:globalThis;t.exports=function(){for(var e=[],t=0;t<n.length;t++)typeof r[n[t]]==`function`&&(e[e.length]=n[t]);return e}})),Ku=/* @__PURE__ */ e(((e,t)=>{var n=Su(),r=lu(),i=uu(),a=xu();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6&&arguments[6],d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}})),qu=/* @__PURE__ */ e(((e,t)=>{var n=Su(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r})),Ju=/* @__PURE__ */ e(((e,t)=>{var n=Iu(),r=Ku(),i=qu()(),a=xu(),o=uu(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}})),Yu=/* @__PURE__ */ e(((e,t)=>{var n=Du(),r=ku(),i=ju();t.exports=function(){return i(n,r,arguments)}})),Xu=/* @__PURE__ */ e(((e,t)=>{var n=Ju(),r=Su(),i=Mu(),a=Yu();t.exports=function(e){var t=i(arguments),r=e.length-(arguments.length-1);return n(t,1+(r>0?r:0),!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a})),Zu=/* @__PURE__ */ e(((e,t)=>{eu();var n=Uu(),r=Gu(),i=Xu(),a=Lu(),o=xu(),s=Pu(),c=a(`Object.prototype.toString`),l=ru()(),u=typeof globalThis>`u`?$l:globalThis,d=r(),f=a(`String.prototype.slice`),p=a(`Array.prototype.indexOf`,!0)||function(e,t){for(var n=0;n<e.length;n+=1)if(e[n]===t)return n;return-1},m={__proto__:null};l&&o&&s?n(d,function(e){var t=new u[e];if(Symbol.toStringTag in t&&s){var n=s(t),r=o(n,Symbol.toStringTag);!r&&n&&(r=o(s(n),Symbol.toStringTag)),m[`$`+e]=i(r.get)}}):n(d,function(e){var t=new u[e],n=t.slice||t.set;n&&(m[`$`+e]=i(n))});var h=function(e){var t=!1;return n(m,function(n,r){if(!t)try{`$`+n(e)===r&&(t=f(r,1))}catch{}}),t},g=function(e){var t=!1;return n(m,function(n,r){if(!t)try{n(e),t=f(r,1)}catch{}}),t};t.exports=function(e){if(!e||typeof e!=`object`)return!1;if(!l){var t=f(c(e),8,-1);return p(d,t)>-1?t:t===`Object`&&g(e)}return o?h(e):null}})),Qu=/* @__PURE__ */ e(((e,t)=>{var n=Zu();t.exports=function(e){return!!n(e)}})),$u=/* @__PURE__ */ e((e=>{var t=Ru(),n=Vu(),r=Zu(),i=Qu();function a(e){return e.call.bind(e)}var o=typeof BigInt<`u`,s=typeof Symbol<`u`,c=a(Object.prototype.toString),l=a(Number.prototype.valueOf),u=a(String.prototype.valueOf),d=a(Boolean.prototype.valueOf);if(o)var f=a(BigInt.prototype.valueOf);if(s)var p=a(Symbol.prototype.valueOf);function m(e,t){if(typeof e!=`object`)return!1;try{return t(e),!0}catch{return!1}}e.isArgumentsObject=t,e.isGeneratorFunction=n,e.isTypedArray=i;function h(e){return typeof Promise<`u`&&e instanceof Promise||typeof e==`object`&&!!e&&typeof e.then==`function`&&typeof e.catch==`function`}e.isPromise=h;function g(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView?ArrayBuffer.isView(e):i(e)||re(e)}e.isArrayBufferView=g;function _(e){return r(e)===`Uint8Array`}e.isUint8Array=_;function v(e){return r(e)===`Uint8ClampedArray`}e.isUint8ClampedArray=v;function y(e){return r(e)===`Uint16Array`}e.isUint16Array=y;function b(e){return r(e)===`Uint32Array`}e.isUint32Array=b;function x(e){return r(e)===`Int8Array`}e.isInt8Array=x;function S(e){return r(e)===`Int16Array`}e.isInt16Array=S;function C(e){return r(e)===`Int32Array`}e.isInt32Array=C;function w(e){return r(e)===`Float32Array`}e.isFloat32Array=w;function T(e){return r(e)===`Float64Array`}e.isFloat64Array=T;function E(e){return r(e)===`BigInt64Array`}e.isBigInt64Array=E;function D(e){return r(e)===`BigUint64Array`}e.isBigUint64Array=D;function O(e){return c(e)===`[object Map]`}O.working=typeof Map<`u`&&O(/* @__PURE__ */ new Map);function k(e){return typeof Map>`u`?!1:O.working?O(e):e instanceof Map}e.isMap=k;function A(e){return c(e)===`[object Set]`}A.working=typeof Set<`u`&&A(/* @__PURE__ */ new Set);function j(e){return typeof Set>`u`?!1:A.working?A(e):e instanceof Set}e.isSet=j;function M(e){return c(e)===`[object WeakMap]`}M.working=typeof WeakMap<`u`&&M(/* @__PURE__ */ new WeakMap);function N(e){return typeof WeakMap>`u`?!1:M.working?M(e):e instanceof WeakMap}e.isWeakMap=N;function ee(e){return c(e)===`[object WeakSet]`}ee.working=typeof WeakSet<`u`&&ee(/* @__PURE__ */ new WeakSet);function te(e){return ee(e)}e.isWeakSet=te;function P(e){return c(e)===`[object ArrayBuffer]`}P.working=typeof ArrayBuffer<`u`&&P(/* @__PURE__ */ new ArrayBuffer);function F(e){return typeof ArrayBuffer>`u`?!1:P.working?P(e):e instanceof ArrayBuffer}e.isArrayBuffer=F;function ne(e){return c(e)===`[object DataView]`}ne.working=typeof ArrayBuffer<`u`&&typeof DataView<`u`&&ne(new DataView(/* @__PURE__ */ new ArrayBuffer(1),0,1));function re(e){return typeof DataView>`u`?!1:ne.working?ne(e):e instanceof DataView}e.isDataView=re;var I=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:void 0;function L(e){return c(e)===`[object SharedArrayBuffer]`}function ie(e){return I!==void 0&&(L.working===void 0&&(L.working=L(new I)),L.working?L(e):e instanceof I)}e.isSharedArrayBuffer=ie;function ae(e){return c(e)===`[object AsyncFunction]`}e.isAsyncFunction=ae;function oe(e){return c(e)===`[object Map Iterator]`}e.isMapIterator=oe;function se(e){return c(e)===`[object Set Iterator]`}e.isSetIterator=se;function R(e){return c(e)===`[object Generator]`}e.isGeneratorObject=R;function ce(e){return c(e)===`[object WebAssembly.Module]`}e.isWebAssemblyCompiledModule=ce;function le(e){return m(e,l)}e.isNumberObject=le;function ue(e){return m(e,u)}e.isStringObject=ue;function de(e){return m(e,d)}e.isBooleanObject=de;function fe(e){return o&&m(e,f)}e.isBigIntObject=fe;function pe(e){return s&&m(e,p)}e.isSymbolObject=pe;function me(e){return le(e)||ue(e)||de(e)||fe(e)||pe(e)}e.isBoxedPrimitive=me;function he(e){return typeof Uint8Array<`u`&&(F(e)||ie(e))}e.isAnyArrayBuffer=he,[`isProxy`,`isExternal`,`isModuleNamespaceObject`].forEach(function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw Error(t+` is not supported in userland`)}})})})),ed=/* @__PURE__ */ e(((e,t)=>{t.exports=function(e){return e&&typeof e==`object`&&typeof e.copy==`function`&&typeof e.fill==`function`&&typeof e.readUInt8==`function`}})),td=/* @__PURE__ */ e((e=>{r();var t=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},n=/%[sdj%]/g;e.format=function(e){if(!C(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(c(arguments[r]));return t.join(` `)}for(var r=1,i=arguments,a=i.length,o=String(e).replace(n,function(e){if(e===`%%`)return`%`;if(r>=a)return e;switch(e){case`%s`:return String(i[r++]);case`%d`:return Number(i[r++]);case`%j`:try{return JSON.stringify(i[r++])}catch{return`[Circular]`}default:return e}}),s=i[r];r<a;s=i[++r])b(s)||!D(s)?o+=` `+s:o+=` `+c(s);return o},e.deprecate=function(t,n){if(i!==void 0&&i.noDeprecation===!0)return t;if(i===void 0)return function(){return e.deprecate(t,n).apply(this,arguments)};var r=!1;function a(){if(!r){if(i.throwDeprecation)throw Error(n);i.traceDeprecation?console.trace(n):console.error(n),r=!0}return t.apply(this,arguments)}return a};var a={},o=/^$/;if(i.env.NODE_DEBUG){var s=i.env.NODE_DEBUG;s=s.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`).replace(/,/g,`$|^`).toUpperCase(),o=RegExp(`^`+s+`$`,`i`)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t]){if(o.test(t)){var n=i.pid;a[t]=function(){var r=e.format.apply(e,arguments);console.error(`%s %d: %s`,t,n,r)}}else a[t]=function(){}}return a[t]};function c(t,n){var r={seen:[],stylize:u};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),y(n)?r.showHidden=n:n&&e._extend(r,n),T(r.showHidden)&&(r.showHidden=!1),T(r.depth)&&(r.depth=2),T(r.colors)&&(r.colors=!1),T(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),f(r,t,r.depth)}e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:`cyan`,number:`yellow`,boolean:`yellow`,undefined:`grey`,null:`bold`,string:`green`,date:`magenta`,regexp:`red`};function l(e,t){var n=c.styles[t];return n?`\x1B[`+c.colors[n][0]+`m`+e+`\x1B[`+c.colors[n][1]+`m`:e}function u(e,t){return e}function d(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function f(t,n,r){if(t.customInspect&&n&&A(n.inspect)&&n.inspect!==e.inspect&&!(n.constructor&&n.constructor.prototype===n)){var i=n.inspect(r,t);return C(i)||(i=f(t,i,r)),i}var a=p(t,n);if(a)return a;var o=Object.keys(n),s=d(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(n)),k(n)&&(o.indexOf(`message`)>=0||o.indexOf(`description`)>=0))return m(n);if(o.length===0){if(A(n)){var c=n.name?`: `+n.name:``;return t.stylize(`[Function`+c+`]`,`special`)}if(E(n))return t.stylize(RegExp.prototype.toString.call(n),`regexp`);if(O(n))return t.stylize(Date.prototype.toString.call(n),`date`);if(k(n))return m(n)}var l=``,u=!1,y=[`{`,`}`];if(v(n)&&(u=!0,y=[`[`,`]`]),A(n)&&(l=` [Function`+(n.name?`: `+n.name:``)+`]`),E(n)&&(l=` `+RegExp.prototype.toString.call(n)),O(n)&&(l=` `+Date.prototype.toUTCString.call(n)),k(n)&&(l=` `+m(n)),o.length===0&&(!u||n.length==0))return y[0]+l+y[1];if(r<0)return E(n)?t.stylize(RegExp.prototype.toString.call(n),`regexp`):t.stylize(`[Object]`,`special`);t.seen.push(n);var b=u?h(t,n,r,s,o):o.map(function(e){return g(t,n,r,s,e,u)});return t.seen.pop(),_(b,l,y)}function p(e,t){if(T(t))return e.stylize(`undefined`,`undefined`);if(C(t)){var n=`'`+JSON.stringify(t).replace(/^"|"$/g,``).replace(/'/g,`\\'`).replace(/\\"/g,`"`)+`'`;return e.stylize(n,`string`)}if(S(t))return e.stylize(``+t,`number`);if(y(t))return e.stylize(``+t,`boolean`);if(b(t))return e.stylize(`null`,`null`)}function m(e){return`[`+Error.prototype.toString.call(e)+`]`}function h(e,t,n,r,i){for(var a=[],o=0,s=t.length;o<s;++o)P(t,String(o))?a.push(g(e,t,n,r,String(o),!0)):a.push(``);return i.forEach(function(i){i.match(/^\d+$/)||a.push(g(e,t,n,r,i,!0))}),a}function g(e,t,n,r,i,a){var o,s,c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(c.get?s=c.set?e.stylize(`[Getter/Setter]`,`special`):e.stylize(`[Getter]`,`special`):c.set&&(s=e.stylize(`[Setter]`,`special`)),P(r,i)||(o=`[`+i+`]`),s||(e.seen.indexOf(c.value)<0?(s=b(n)?f(e,c.value,null):f(e,c.value,n-1),s.indexOf(`
|
|
56
56
|
`)>-1&&(s=a?s.split(`
|
|
57
57
|
`).map(function(e){return` `+e}).join(`
|
|
58
58
|
`).slice(2):`
|
|
@@ -61,12 +61,12 @@ This browser reports limited detail, so the cause above is a best guess.`:``)))}
|
|
|
61
61
|
`))):s=e.stylize(`[Circular]`,`special`)),T(o)){if(a&&i.match(/^\d+$/))return s;o=JSON.stringify(``+i),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.slice(1,-1),o=e.stylize(o,`name`)):(o=o.replace(/'/g,`\\'`).replace(/\\"/g,`"`).replace(/(^"|"$)/g,`'`),o=e.stylize(o,`string`))}return o+`: `+s}function _(e,t,n){var r=0;return e.reduce(function(e,t){return r++,t.indexOf(`
|
|
62
62
|
`)>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,``).length+1},0)>60?n[0]+(t===``?``:t+`
|
|
63
63
|
`)+` `+e.join(`,
|
|
64
|
-
`)+` `+n[1]:n[0]+t+` `+e.join(`, `)+` `+n[1]}e.types=Qu();function v(e){return Array.isArray(e)}e.isArray=v;function y(e){return typeof e==`boolean`}e.isBoolean=y;function b(e){return e===null}e.isNull=b;function x(e){return e==null}e.isNullOrUndefined=x;function S(e){return typeof e==`number`}e.isNumber=S;function C(e){return typeof e==`string`}e.isString=C;function w(e){return typeof e==`symbol`}e.isSymbol=w;function T(e){return e===void 0}e.isUndefined=T;function E(e){return D(e)&&M(e)===`[object RegExp]`}e.isRegExp=E,e.types.isRegExp=E;function D(e){return typeof e==`object`&&!!e}e.isObject=D;function O(e){return D(e)&&M(e)===`[object Date]`}e.isDate=O,e.types.isDate=O;function k(e){return D(e)&&(M(e)===`[object Error]`||e instanceof Error)}e.isError=k,e.types.isNativeError=k;function A(e){return typeof e==`function`}e.isFunction=A;function j(e){return e===null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||typeof e==`symbol`||e===void 0}e.isPrimitive=j,e.isBuffer=$u();function M(e){return Object.prototype.toString.call(e)}function N(e){return e<10?`0`+e.toString(10):e.toString(10)}var ee=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function te(){var e=/* @__PURE__ */ new Date,t=[N(e.getHours()),N(e.getMinutes()),N(e.getSeconds())].join(`:`);return[e.getDate(),ee[e.getMonth()],t].join(` `)}e.log=function(){console.log(`%s - %s`,te(),e.format.apply(e,arguments))},e.inherits=Zl(),e._extend=function(e,t){if(!t||!D(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var F=typeof Symbol<`u`?Symbol(`util.promisify.custom`):void 0;e.promisify=function(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);if(F&&e[F]){var n=e[F];if(typeof n!=`function`)throw TypeError(`The "util.promisify.custom" argument must be of type Function`);return Object.defineProperty(n,F,{value:n,enumerable:!1,writable:!1,configurable:!0}),n}function n(){for(var t,n,r=new Promise(function(e,r){t=e,n=r}),i=[],a=0;a<arguments.length;a++)i.push(arguments[a]);i.push(function(e,r){e?n(e):t(r)});try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),F&&Object.defineProperty(n,F,{value:n,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(n,t(e))},e.promisify.custom=F;function ne(e,t){if(!e){var n=/* @__PURE__ */ Error(`Promise was rejected with a falsy value`);n.reason=e,e=n}return t(e)}function re(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);function n(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if(typeof r!=`function`)throw TypeError(`The last argument must be of type Function`);var a=this,o=function(){return r.apply(a,arguments)};e.apply(this,t).then(function(e){i.nextTick(o.bind(null,null,e))},function(e){i.nextTick(ne.bind(null,e,o))})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,t(e)),n}e.callbackify=re})),td=/* @__PURE__ */ e(((e,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return t=l(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var t=u(e,`string`);return typeof t==`symbol`?t:String(t)}function u(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var d=($s(),t(bs)).Buffer,f=ed().inspect,p=f&&f.custom||`inspect`;function m(e,t,n){d.prototype.copy.call(e,t,n)}n.exports=/*#__PURE__*/ function(){function e(){o(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return d.alloc(0);for(var t=d.allocUnsafe(e>>>0),n=this.head,r=0;n;)m(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=d.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,this.head=n.next?n.next:this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:p,value:function(e,t){return f(this,i(i({},t),{},{depth:0,customInspect:!1}))}}]),e}()})),nd=/* @__PURE__ */ e(((e,t)=>{r();function n(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return r||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(c,this,e)):i.nextTick(c,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?i.nextTick(o,n):(n._writableState.errorEmitted=!0,i.nextTick(a,n,e)):i.nextTick(a,n,e):t?(i.nextTick(o,n),t(e)):i.nextTick(o,n)}),this)}function a(e,t){c(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(e,t){e.emit(`error`,t)}function l(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:s,errorOrDestroy:l}})),rd=/* @__PURE__ */ e(((e,t)=>{function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var r={};function i(e,t,i){i||=Error;function a(e,n,r){return typeof t==`string`?t:t(e,n,r)}var o=/*#__PURE__*/ function(e){n(t,e);function t(t,n,r){return e.call(this,a(t,n,r))||this}return t}(i);o.prototype.name=i.name,o.prototype.code=e,r[e]=o}function a(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}return`of ${t} ${String(e)}`}function o(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function s(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function c(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}i(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),i(`ERR_INVALID_ARG_TYPE`,function(e,t,n){var r;typeof t==`string`&&o(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;var i=s(e,` argument`)?`The ${e} ${r} ${a(t,`type`)}`:`The "${e}" ${c(e,`.`)?`property`:`argument`} ${r} ${a(t,`type`)}`;return i+=`. Received type ${typeof n}`,i},TypeError),i(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),i(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),i(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),i(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),i(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),i(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),i(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),i(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),i(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),i(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=r})),id=/* @__PURE__ */ e(((e,t)=>{var n=rd().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}})),ad=/* @__PURE__ */ e(((e,t)=>{$l(),t.exports=n;function n(e,t){if(r(`noDeprecation`))return e;var n=!1;function i(){if(!n){if(r(`throwDeprecation`))throw Error(t);r(`traceDeprecation`)?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return i}function r(e){try{if(!Ql.localStorage)return!1}catch{return!1}var t=Ql.localStorage[e];return t!=null&&String(t).toLowerCase()===`true`}})),od=/* @__PURE__ */ e(((e,n)=>{$l(),r(),n.exports=O;function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){se(t,e)}}var o;O.WritableState=E;var s={deprecate:ad()},c=eu(),l=($s(),t(bs)).Buffer,u=(Ql===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:Ql).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=nd(),m=id().getHighWaterMark,h=rd().codes,g=h.ERR_INVALID_ARG_TYPE,_=h.ERR_METHOD_NOT_IMPLEMENTED,v=h.ERR_MULTIPLE_CALLBACK,y=h.ERR_STREAM_CANNOT_PIPE,b=h.ERR_STREAM_DESTROYED,x=h.ERR_STREAM_NULL_VALUES,S=h.ERR_STREAM_WRITE_AFTER_END,C=h.ERR_UNKNOWN_ENCODING,w=p.errorOrDestroy;Zl()(O,c);function T(){}function E(e,t,n){o||=sd(),e||={},typeof n!=`boolean`&&(n=t instanceof o),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=m(this,e,`writableHighWaterMark`,n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){P(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var D;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(D=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(e){return D.call(this,e)?!0:this===O&&e&&e._writableState instanceof E}})):D=function(e){return e instanceof this};function O(e){o||=sd();var t=this instanceof o;if(!t&&!D.call(O,this))return new O(e);this._writableState=new E(e,this,t),this.writable=!0,e&&(typeof e.write==`function`&&(this._write=e.write),typeof e.writev==`function`&&(this._writev=e.writev),typeof e.destroy==`function`&&(this._destroy=e.destroy),typeof e.final==`function`&&(this._final=e.final)),c.call(this)}O.prototype.pipe=function(){w(this,new y)};function k(e,t){var n=new S;w(e,n),i.nextTick(t,n)}function A(e,t,n,r){var a;return n===null?a=new x:typeof n!=`string`&&!t.objectMode&&(a=new g(`chunk`,[`string`,`Buffer`],n)),!a||(w(e,a),i.nextTick(r,a),!1)}O.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&f(e);return a&&!l.isBuffer(e)&&(e=d(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=T),r.ending?k(this,n):(a||A(this,r,e,n))&&(r.pendingcb++,i=M(this,r,a,e,t,n)),i},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&re(this,e))},O.prototype.setDefaultEncoding=function(e){if(typeof e==`string`&&(e=e.toLowerCase()),!([`hex`,`utf8`,`utf-8`,`ascii`,`binary`,`base64`,`ucs2`,`ucs-2`,`utf16le`,`utf-16le`,`raw`].indexOf((e+``).toLowerCase())>-1))throw new C(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function j(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function M(e,t,n,r,i,a){if(!n){var o=j(t,r,i);r!==o&&(n=!0,i=`buffer`,r=o)}var s=t.objectMode?1:r.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else N(e,t,!1,s,r,i,a);return c}function N(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new b(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function ee(e,t,n,r,a){--t.pendingcb,n?(i.nextTick(a,r),i.nextTick(ae,e,t),e._writableState.errorEmitted=!0,w(e,r)):(a(r),e._writableState.errorEmitted=!0,w(e,r),ae(e,t))}function te(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function P(e,t){var n=e._writableState,r=n.sync,a=n.writecb;if(typeof a!=`function`)throw new v;if(te(n),t)ee(e,n,r,t,a);else{var o=I(n)||e.destroyed;!o&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&re(e,n),r?i.nextTick(F,e,n,o,a):F(e,n,o,a)}}function F(e,t,n,r){n||ne(e,t),t.pendingcb--,r(),ae(e,t)}function ne(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function re(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=Array(r),o=t.corkedRequestsFree;o.entry=n;for(var s=0,c=!0;n;)i[s]=n,n.isBuf||(c=!1),n=n.next,s+=1;i.allBuffers=c,N(e,t,!0,t.length,i,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback;if(N(e,t,!1,t.objectMode?1:l.length,l,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}O.prototype._write=function(e,t,n){n(new _(`_write()`))},O.prototype._writev=null,O.prototype.end=function(e,t,n){var r=this._writableState;return typeof e==`function`?(n=e,e=null,t=null):typeof t==`function`&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||oe(this,r,n),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function I(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function L(e,t){e._final(function(n){t.pendingcb--,n&&w(e,n),t.prefinished=!0,e.emit(`prefinish`),ae(e,t)})}function ie(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,i.nextTick(L,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function ae(e,t){var n=I(t);if(n&&(ie(e,t),t.pendingcb===0&&(t.finished=!0,e.emit(`finish`),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function oe(e,t,n){t.ending=!0,ae(e,t),n&&(t.finished?i.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function se(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),O.prototype.destroy=p.destroy,O.prototype._undestroy=p.undestroy,O.prototype._destroy=function(e,t){t(e)}})),sd=/* @__PURE__ */ e(((e,t)=>{r();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=u;var a=pd(),o=od();Zl()(u,a);for(var s=n(o.prototype),c=0;c<s.length;c++){var l=s[c];u.prototype[l]||(u.prototype[l]=o.prototype[l])}function u(e){if(!(this instanceof u))return new u(e);a.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once(`end`,d)))}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function d(){this._writableState.ended||i.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})})),cd=/* @__PURE__ */ e(((e,n)=>{var r=($s(),t(bs)),i=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=r:(a(r,e),e.Buffer=o);function o(e,t,n){return i(e,t,n)}o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return i(e,t,n)},o.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var r=i(e);return t===void 0?r.fill(0):typeof n==`string`?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return i(e)},o.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r.SlowBuffer(e)}})),ld=/* @__PURE__ */ e((e=>{var t=cd().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:case`raw`:return!0;default:return!1}};function r(e){if(!e)return`utf8`;for(var t;;)switch(e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}e.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),ud=/* @__PURE__ */ e(((e,t)=>{var n=rd().codes.ERR_STREAM_PREMATURE_CLOSE;function r(e){var t=!1;return function(){if(!t){t=!0;var n=[...arguments];e.apply(this,n)}}}function i(){}function a(e){return e.setHeader&&typeof e.abort==`function`}function o(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=r(s||i);var c=t.readable||t.readable!==!1&&e.readable,l=t.writable||t.writable!==!1&&e.writable,u=function(){e.writable||f()},d=e._writableState&&e._writableState.finished,f=function(){l=!1,d=!0,c||s.call(e)},p=e._readableState&&e._readableState.endEmitted,m=function(){c=!1,p=!0,l||s.call(e)},h=function(t){s.call(e,t)},g=function(){var t;if(c&&!p)return e._readableState&&e._readableState.ended||(t=new n),s.call(e,t);if(l&&!d)return e._writableState&&e._writableState.ended||(t=new n),s.call(e,t)},_=function(){e.req.on(`finish`,f)};return a(e)?(e.on(`complete`,f),e.on(`abort`,g),e.req?_():e.on(`request`,_)):l&&!e._writableState&&(e.on(`end`,u),e.on(`close`,u)),e.on(`end`,m),e.on(`finish`,f),t.error!==!1&&e.on(`error`,h),e.on(`close`,g),function(){e.removeListener(`complete`,f),e.removeListener(`abort`,g),e.removeListener(`request`,_),e.req&&e.req.removeListener(`finish`,f),e.removeListener(`end`,u),e.removeListener(`close`,u),e.removeListener(`finish`,f),e.removeListener(`end`,m),e.removeListener(`error`,h),e.removeListener(`close`,g)}}t.exports=o})),dd=/* @__PURE__ */ e(((e,t)=>{r();var n;function a(e,t,n){return t=o(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=s(e,`string`);return typeof t==`symbol`?t:String(t)}function s(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var c=ud(),l=Symbol(`lastResolve`),u=Symbol(`lastReject`),d=Symbol(`error`),f=Symbol(`ended`),p=Symbol(`lastPromise`),m=Symbol(`handlePromise`),h=Symbol(`stream`);function g(e,t){return{value:e,done:t}}function _(e){var t=e[l];if(t!==null){var n=e[h].read();n!==null&&(e[p]=null,e[l]=null,e[u]=null,t(g(n,!1)))}}function v(e){i.nextTick(_,e)}function y(e,t){return function(n,r){e.then(function(){t[f]?n(g(void 0,!0)):t[m](n,r)},r)}}var b=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((n={get stream(){return this[h]},next:function(){var e=this,t=this[d];if(t!==null)return Promise.reject(t);if(this[f])return Promise.resolve(g(void 0,!0));if(this[h].destroyed)return new Promise(function(t,n){i.nextTick(function(){e[d]?n(e[d]):t(g(void 0,!0))})});var n=this[p],r;if(n)r=new Promise(y(n,this));else{var a=this[h].read();if(a!==null)return Promise.resolve(g(a,!1));r=new Promise(this[m])}return this[p]=r,r}},a(n,Symbol.asyncIterator,function(){return this}),a(n,`return`,function(){var e=this;return new Promise(function(t,n){e[h].destroy(null,function(e){e?n(e):t(g(void 0,!0))})})}),n),b);t.exports=function(e){var t,n=Object.create(x,(t={},a(t,h,{value:e,writable:!0}),a(t,l,{value:null,writable:!0}),a(t,u,{value:null,writable:!0}),a(t,d,{value:null,writable:!0}),a(t,f,{value:e._readableState.endEmitted,writable:!0}),a(t,m,{value:function(e,t){var r=n[h].read();r?(n[p]=null,n[l]=null,n[u]=null,e(g(r,!1))):(n[l]=e,n[u]=t)},writable:!0}),t));return n[p]=null,c(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[u];t!==null&&(n[p]=null,n[l]=null,n[u]=null,t(e)),n[d]=e}else{var r=n[l];r!==null&&(n[p]=null,n[l]=null,n[u]=null,r(g(void 0,!0))),n[f]=!0}}),e.on(`readable`,v.bind(null,n)),n}})),fd=/* @__PURE__ */ e(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),pd=/* @__PURE__ */ e(((e,n)=>{$l(),r(),n.exports=k;var a;k.ReadableState=O,Xl().EventEmitter;var o=function(e,t){return e.listeners(t).length},s=eu(),c=($s(),t(bs)).Buffer,l=(Ql===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:Ql).Uint8Array||function(){};function u(e){return c.from(e)}function d(e){return c.isBuffer(e)||e instanceof l}var f=ed(),p=f&&f.debuglog?f.debuglog(`stream`):function(){},m=td(),h=nd(),g=id().getHighWaterMark,_=rd().codes,v=_.ERR_INVALID_ARG_TYPE,y=_.ERR_STREAM_PUSH_AFTER_EOF,b=_.ERR_METHOD_NOT_IMPLEMENTED,x=_.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,S,C,w;Zl()(k,s);var T=h.errorOrDestroy,E=[`error`,`close`,`destroy`,`pause`,`resume`];function D(e,t,n){if(typeof e.prependListener==`function`)return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function O(e,t,n){a||=sd(),e||={},typeof n!=`boolean`&&(n=t instanceof a),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=g(this,e,`readableHighWaterMark`,n),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(S||=ld().StringDecoder,this.decoder=new S(e.encoding),this.encoding=e.encoding)}function k(e){if(a||=sd(),!(this instanceof k))return new k(e);var t=this instanceof a;this._readableState=new O(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),s.call(this)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),k.prototype.destroy=h.destroy,k.prototype._undestroy=h.undestroy,k.prototype._destroy=function(e,t){t(e)},k.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:typeof e==`string`&&(t||=n.defaultEncoding,t!==n.encoding&&(e=c.from(e,t),t=``),r=!0),A(this,e,t,!1,r)},k.prototype.unshift=function(e){return A(this,e,null,!0,!1)};function A(e,t,n,r,i){p(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,P(e,a);else{var o;if(i||(o=M(a,t)),o)T(e,o);else if(a.objectMode||t&&t.length>0){if(typeof t!=`string`&&!a.objectMode&&Object.getPrototypeOf(t)!==c.prototype&&(t=u(t)),r)a.endEmitted?T(e,new x):j(e,a,t,!0);else if(a.ended)T(e,new y);else if(a.destroyed)return!1;else a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||t.length!==0?j(e,a,t,!1):re(e,a)):j(e,a,t,!1)}else r||(a.reading=!1,re(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function j(e,t,n,r){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit(`data`,n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&F(e)),re(e,t)}function M(e,t){var n;return!d(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new v(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}k.prototype.isPaused=function(){return this._readableState.flowing===!1},k.prototype.setEncoding=function(e){S||=ld().StringDecoder;var t=new S(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r=``;n!==null;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),r!==``&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var N=1073741824;function ee(e){return e>=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function te(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=ee(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}k.prototype.read=function(e){p(`read`,e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark===0?t.length>0:t.length>=t.highWaterMark)||t.ended))return p(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?le(this):F(this),null;if(e=te(e,t),e===0&&t.ended)return t.length===0&&le(this),null;var r=t.needReadable;p(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,p(`length less than watermark`,r)),t.ended||t.reading?(r=!1,p(`reading or ended`,r)):r&&(p(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=te(n,t)));var i=e>0?ce(e,t):null;return i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&le(this)),i!==null&&this.emit(`data`,i),i};function P(e,t){if(p(`onEofChunk`),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?F(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,ne(e)))}}function F(e){var t=e._readableState;p(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(p(`emitReadable`,t.flowing),t.emittedReadable=!0,i.nextTick(ne,e))}function ne(e){var t=e._readableState;p(`emitReadable_`,t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit(`readable`),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,R(e)}function re(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(p(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}k.prototype._read=function(e){T(this,new b(`_read()`))},k.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,p(`pipe count=%d opts=%j`,r.pipesCount,t);var a=(!t||t.end!==!1)&&e!==i.stdout&&e!==i.stderr?c:_;r.endEmitted?i.nextTick(a):n.once(`end`,a),e.on(`unpipe`,s);function s(e,t){p(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,d())}function c(){p(`onend`),e.end()}var l=L(n);e.on(`drain`,l);var u=!1;function d(){p(`cleanup`),e.removeListener(`close`,h),e.removeListener(`finish`,g),e.removeListener(`drain`,l),e.removeListener(`error`,m),e.removeListener(`unpipe`,s),n.removeListener(`end`,c),n.removeListener(`end`,_),n.removeListener(`data`,f),u=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&l()}n.on(`data`,f);function f(t){p(`ondata`);var i=e.write(t);p(`dest.write`,i),i===!1&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&de(r.pipes,e)!==-1)&&!u&&(p(`false write response, pause`,r.awaitDrain),r.awaitDrain++),n.pause())}function m(t){p(`onerror`,t),_(),e.removeListener(`error`,m),o(e,`error`)===0&&T(e,t)}D(e,`error`,m);function h(){e.removeListener(`finish`,g),_()}e.once(`close`,h);function g(){p(`onfinish`),e.removeListener(`close`,h),_()}e.once(`finish`,g);function _(){p(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),r.flowing||(p(`pipe resume`),n.resume()),e};function L(e){return function(){var t=e._readableState;p(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&o(e,`data`)&&(t.flowing=!0,R(e))}}k.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes||(e||=t.pipes,t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit(`unpipe`,this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)r[a].emit(`unpipe`,this,{hasUnpiped:!1});return this}var o=de(t.pipes,e);return o===-1||(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n)),this},k.prototype.on=function(e,t){var n=s.prototype.on.call(this,e,t),r=this._readableState;return e===`data`?(r.readableListening=this.listenerCount(`readable`)>0,r.flowing!==!1&&this.resume()):e===`readable`&&!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,p(`on readable`,r.length,r.reading),r.length?F(this):r.reading||i.nextTick(ae,this)),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(e,t){var n=s.prototype.removeListener.call(this,e,t);return e===`readable`&&i.nextTick(ie,this),n},k.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&i.nextTick(ie,this),t};function ie(e){var t=e._readableState;t.readableListening=e.listenerCount(`readable`)>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(`data`)>0&&e.resume()}function ae(e){p(`readable nexttick read 0`),e.read(0)}k.prototype.resume=function(){var e=this._readableState;return e.flowing||(p(`resume`),e.flowing=!e.readableListening,oe(this,e)),e.paused=!1,this};function oe(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(se,e,t))}function se(e,t){p(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),R(e),t.flowing&&!t.reading&&e.read(0)}k.prototype.pause=function(){return p(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(p(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function R(e){var t=e._readableState;for(p(`flow`,t.flowing);t.flowing&&e.read()!==null;);}k.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(p(`wrapped end`),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on(`data`,function(i){p(`wrapped data`),n.decoder&&(i=n.decoder.write(i)),!(n.objectMode&&i==null)&&(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)this[i]===void 0&&typeof e[i]==`function`&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<E.length;a++)e.on(E[a],this.emit.bind(this,E[a]));return this._read=function(t){p(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(k.prototype[Symbol.asyncIterator]=function(){return C===void 0&&(C=dd()),C(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),k._fromList=ce,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function ce(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(``):t.buffer.length===1?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function le(e){var t=e._readableState;p(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,i.nextTick(ue,t,e))}function ue(e,t){if(p(`endReadableNT`,e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit(`end`),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}typeof Symbol==`function`&&(k.from=function(e,t){return w===void 0&&(w=fd()),w(k,e,t)});function de(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),md=/* @__PURE__ */ e(((e,t)=>{t.exports=l;var n=rd().codes,r=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=n.ERR_TRANSFORM_WITH_LENGTH_0,s=sd();Zl()(l,s);function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit(`error`,new i);n.writechunk=null,n.writecb=null,t!=null&&this.push(t),r(e);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform==`function`&&(this._transform=e.transform),typeof e.flush==`function`&&(this._flush=e.flush)),this.on(`prefinish`,u)}function u(){var e=this;typeof this._flush==`function`&&!this._readableState.destroyed?this._flush(function(t,n){d(e,t,n)}):d(this,null,null)}l.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new r(`_transform()`))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},l.prototype._destroy=function(e,t){s.prototype._destroy.call(this,e,function(e){t(e)})};function d(e,t,n){if(t)return e.emit(`error`,t);if(n!=null&&e.push(n),e._writableState.length)throw new o;if(e._transformState.transforming)throw new a;return e.push(null)}})),hd=/* @__PURE__ */ e(((e,t)=>{t.exports=r;var n=md();Zl()(r,n);function r(e){if(!(this instanceof r))return new r(e);n.call(this,e)}r.prototype._transform=function(e,t,n){n(null,e)}})),gd=/* @__PURE__ */ e(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=rd().codes,a=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function c(e){return e.setHeader&&typeof e.abort==`function`}function l(e,t,i,a){a=r(a);var s=!1;e.on(`close`,function(){s=!0}),n===void 0&&(n=ud()),n(e,{readable:t,writable:i},function(e){if(e)return a(e);s=!0,a()});var l=!1;return function(t){if(!s&&!l){if(l=!0,c(e))return e.abort();if(typeof e.destroy==`function`)return e.destroy();a(t||new o(`pipe`))}}}function u(e){e()}function d(e,t){return e.pipe(t)}function f(e){return!e.length||typeof e[e.length-1]!=`function`?s:e.pop()}function p(){var e=[...arguments],t=f(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new a(`streams`);var n,r=e.map(function(i,a){var o=a<e.length-1;return l(i,o,a>0,function(e){n||=e,e&&r.forEach(u),!o&&(r.forEach(u),t(n))})});return e.reduce(d)}t.exports=p})),_d=(/* @__PURE__ */ e(((e,t)=>{t.exports=r;var n=Xl().EventEmitter;Zl()(r,n),r.Readable=pd(),r.Writable=od(),r.Duplex=sd(),r.Transform=md(),r.PassThrough=hd(),r.finished=ud(),r.pipeline=gd(),r.Stream=r;function r(){n.call(this)}r.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}r.on(`data`,i);function a(){r.readable&&r.resume&&r.resume()}e.on(`drain`,a),e._isStdio||t&&t.end===!1||(r.on(`end`,s),r.on(`close`,c));var o=!1;function s(){o||(o=!0,e.end())}function c(){o||(o=!0,typeof e.destroy==`function`&&e.destroy())}function l(e){if(u(),n.listenerCount(this,`error`)===0)throw e}r.on(`error`,l),e.on(`error`,l);function u(){r.removeListener(`data`,i),e.removeListener(`drain`,a),r.removeListener(`end`,s),r.removeListener(`close`,c),r.removeListener(`error`,l),e.removeListener(`error`,l),r.removeListener(`end`,u),r.removeListener(`close`,u),e.removeListener(`close`,u)}return r.on(`end`,u),r.on(`close`,u),e.on(`close`,u),e.emit(`pipe`,r),e}})))(),vd=Xl(),yd=/* @__PURE__ */ g({Server:()=>xd,Socket:()=>bd,_default:()=>Td,connect:()=>Sd,createConnection:()=>Cd,createServer:()=>wd,default:()=>Td,isIP:()=>Ll,isIPv4:()=>Fl,isIPv6:()=>Il}),bd=class extends _d.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;_relay;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super({...e,allowHalfOpen:!!e?.allowHalfOpen,autoDestroy:!0}),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_init__(e,t){return this._busyRelease??=Jo(`tcp socket`),t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort},this._remoteAddress={address:t.remoteAddress,family:t.remoteFamily,port:t.remotePort},this._relay=t.relay,this._connected=!0),this._webVPNTcpSocketPromise=e.then(e=>{let t=e.dataReadableStream.getReader(),n=e.dataWritableStream.getWriter();return this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._remoteAddress={address:e.remoteAddress,family:e.remoteFamily,port:e.remotePort},this._relay=e.relay,{...e,reader:t,writer:n}}).catch(e=>{this.destroyed||this.destroy(Yl(e))}),this._webVPNTcpSocketPromise.then(e=>{e&&!this.destroyed&&(this._connected=!0,this.emit(`connect`),this.isPaused()||this.read(0))}),this._webVPNTcpSocketPromise}_connected=!1;_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{e?e.reader.read().then(({value:e,done:t})=>{t?(this.push(null),this.read(0)):(this._restartTimeoutTimer(),this.push(e))}).catch(e=>{this.destroy(Yl(e))}):this.push(null)})}_write(e,t,n){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e)}).then(()=>{this.destroyed||(this._restartTimeoutTimer(),n())},e=>this._fail(e)):n(/* @__PURE__ */ Error(`Socket not connected`))}_fail(e){if(!this.destroyed){e=Yl(e);for(let t of this._pendingCallbacks)t(e);this.destroy(e)}}connect(...e){let t=Rl(...e),{relay:n}=t,r=this.__webvpn_tcp_socket_init__(Po(`an outbound tcp socket`).then(e=>(n!==void 0&&es(e,`net.connect`),e.cloud.webvpn.tcpSocket({remoteAddress:t.host??`localhost`,remotePort:t.port,relay:n}))));return t.callback&&r.then(e=>{e&&!this.destroyed&&t.callback.call(this)}),this}_final(e){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async e=>{e&&await e.writer.close()}).then(()=>{this.destroyed||e()},e=>this._fail(e)):e()}_destroyError;_destroy(e,t){this._destroyError=e??void 0,this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._busyRelease?.(),this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{t&&(this._resetRequested?await t.resetAndDestroy():!e&&this._writableState.finished&&this._readableState.ended?await t.end():await t.destroy())}).then(()=>t(e),()=>t(e)):t(e)}destroy(e,t){return this.destroyed&&!t?this:(Object.assign(this,{readable:!1,writable:!1}),Reflect.apply(super.destroy,this,[e,t]))}emit(e,...t){if(e===`finish`)for(let e of this._endCallbacks.splice(0))e();if(e!==`close`||!this.destroyed)return super.emit(e,...t);let n=this._destroyError!==void 0;if(!this._connected){let e=super.emit(`close`,n);return this._settlePending(Object.assign(/* @__PURE__ */ Error(`Socket closed before the connection was established`),{code:`ERR_SOCKET_CLOSED_BEFORE_CONNECTION`})),e}return this._settlePending(Object.assign(/* @__PURE__ */ Error(`write ECANCELED`),{code:`ECANCELED`,syscall:`write`})),super.emit(`close`,n)}_settlePending(e){let t=e;for(let e of this._pendingCallbacks)e(t),t=this._destroyError??t}destroySoon(){this._writableState.finished?this.destroy():(this.once(`finish`,()=>this.destroy()),this.end())}_resetRequested=!1;resetAndDestroy(){return this._resetRequested=!0,this.destroy(),this}_timeoutMs;_timeoutTimer;_restartTimeoutTimer(){this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._timeoutMs&&!this.destroyed&&(this._timeoutTimer=setTimeout(()=>this.emit(`timeout`),this._timeoutMs))}setTimeout(e,t){return t&&this.on(`timeout`,t),this._timeoutMs=e,this._restartTimeoutTimer(),this}setNoDelay(e){let t=e??!0;return this._setTcpOption({type:0,value:t}),this}setKeepAlive(e,t){let n=typeof e==`object`&&e?e:{enable:e,initialDelay:t},r=n.initialDelay,i=r!==void 0&&r>0?Math.max(1,Math.round(r/1e3)):0;return this._setTcpOption({type:2,enabled:n.enable??!1,initialDelaySeconds:i}),this}setSendBufferSize(e){return this._setTcpOption({type:3,value:e}),this}setRecvBufferSize(e){return this._setTcpOption({type:4,value:e}),this}_typeOfService;getTypeOfService(){return this._typeOfService??0}setTypeOfService(e){return this._typeOfService=e,this}_setTcpOption(e){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.destroyed||this.emit(`error`,e)}}):this.emit(`error`,/* @__PURE__ */ Error(`Cannot set socket option before connect`))}_pendingCallbacks=/* @__PURE__ */ new Set;_settleOnClose(e){let t=n=>{this._pendingCallbacks.delete(t)&&e(n)};return this._pendingCallbacks.add(t),t}end(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`function`&&(n=e,e=void 0),e==null&&this._writableState.finished){let e=Object.assign(/* @__PURE__ */ Error(`Cannot call end after a stream was finished`),{code:`ERR_STREAM_ALREADY_FINISHED`});return n&&queueMicrotask(()=>n(e)),this}return this.destroyed?(e!=null&&this.write(e,t,n),this):(n&&this._endCallbacks.push(this._settleOnClose(n)),Reflect.apply(super.end,this,[e,t]))}_endCallbacks=[];write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),this.destroyed){let e=Object.assign(/* @__PURE__ */ Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`});return n&&queueMicrotask(()=>n(e)),!1}if(!n)return t?super.write(e,t):super.write(e);let r=this._settleOnClose(n);return t?super.write(e,t,r):super.write(e,r)}address(){return this._localAddress??{}}unref(){return this}ref(){return this}autoSelectFamilyAttemptedAddresses;bufferSize;bytesRead;bytesWritten;connecting;pending;get localAddress(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.address}get localPort(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.port}get localFamily(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.family}readyState;get remoteAddress(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.address}get remotePort(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.port}get remoteFamily(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.family}timeout;server=null},xd=class extends vd.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;_relayChoice;_allowHalfOpen;_relay;constructor(e,t){super(e),this._relayChoice=e?.relay,this._allowHalfOpen=!!e?.allowHalfOpen,t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_listener_init__(e){return this._busyRelease??=Jo(`tcp server`),this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._relay=e.relay,e)).catch(e=>{this.emit(`error`,Yl(e))}),this._webVPNTcpSocketListenerPromise.then(e=>{e?this.emit(`listening`):this._busyRelease?.()}),this._webVPNTcpSocketListenerPromise}listen(...e){let t=Rl(...e);this._closeEmitted=!1;let n=e=>{let t=new bd({allowHalfOpen:this._allowHalfOpen});t.server=this,t.__webvpn_tcp_socket_init__(Promise.resolve(e),e),this.emit(`connection`,t)},r=e=>{this._localAddress=void 0;try{e&&this.listenerCount(`error`)>0&&this.emit(`error`,e)}finally{this._emitClose()}},i=this._relayChoice,a=e=>Po(`a tcp listener`).then(a=>(i!==void 0&&es(a,`net.createServer`),a.cloud.webvpn.tcpSocketListener({localAddress:e,localPort:t.port,onConnection:n,onClose:r,relay:i}))),o=t.host?a(t.host):a(`::`).catch(()=>a(`0.0.0.0`)),s=this.__webvpn_tcp_socket_listener_init__(o);return t.callback&&s.then(e=>{e&&t.callback.call(this)}),this}_closeEmitted=!1;_emitClose(){this._closeEmitted||(this._closeEmitted=!0,this._busyRelease?.(),this.emit(`close`))}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this._emitClose(),e&&e()}catch(t){this._localAddress=void 0,this._emitClose(),e&&e(t)}}),this}address(){return this._localAddress??null}getConnections(e){throw Error(`Method not implemented.`)}ref(){return this}unref(){return this}maxConnections;connections;listening;async[Symbol.asyncDispose](){}},Sd=(e,t)=>new bd({allowHalfOpen:e?.allowHalfOpen}).connect(e,t),Cd=Sd,wd=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new xd(e);return t&&n.on(`connection`,t),n},Td={Socket:bd,Server:xd,connect:Sd,createConnection:Cd,createServer:wd,isIP:Ll,isIPv4:Fl,isIPv6:Il};$s();var Ed=/* @__PURE__ */ g({Socket:()=>Dd,createSocket:()=>Nd,default:()=>Pd}),Dd=class extends vd.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=/* @__PURE__ */ new Map;_relayChoice;_relay;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,this._relayChoice=e.relay,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){this._webVPNUdpSocketPromise?this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}}):this.emit(`error`,/* @__PURE__ */ Error(`Cannot set socket option before bind`))}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:Vl,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,i=0;for(;i+4<=e.byteLength;){let a=t.getUint32(i);i+=4;let o=i+a;if(o>e.byteLength)break;let s=i+4,c=t.getUint8(s);s+=1;let l,u,d;if(c===2){if(!this._remoteAddress){i=o;continue}l=this._remoteAddress.address,u=this._remoteAddress.family,d=this._remoteAddress.port}else{let n=new Uint8Array(e,s,c===0?4:16);c===0?(u=`IPv4`,l=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(u=`IPv6`,l=jd(n)),s+=n.byteLength,d=t.getUint16(s),s+=2}let f=t.getUint32(s);s+=4;try{this.emit(`message`,G.from(e.slice(s,s+f)),{address:l,family:u,port:d,size:f})}catch(e){n||(n=!0,r=e)}i=o}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return Od;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=Nl.Address4.isValid(e)?Ad(e):Md(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(Nl.Address4.isValid(e)){let n=Ad(e),r=t&&Nl.Address4.isValid(t)?Ad(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(Nl.Address6.isValid(e)){let t=Md(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,/* @__PURE__ */ Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let t=zl(...e),n=this._type===`udp6`?`::`:`0.0.0.0`,r=this._relayChoice,i=this.__webvpn_udp_socket_init__(Po(`a udp socket`).then(e=>(r!==void 0&&es(e,`dgram.createSocket`),e.cloud.webvpn.udpSocket({type:this._type,address:t.address??n,port:t.port,dataPort:!0,relay:r}))));return t.callback&&i.then(e=>{e&&t.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=Jo(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,G.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._relay=e.relay,this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,Yl(e))}),this._webVPNUdpSocketPromise.then(e=>{e?this.emit(`listening`):this._busyRelease?.()}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t?.close()}finally{try{n||this.emit(`close`)}finally{e&&e()}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,Yl(e))})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(Nl.Address4.isValid(e)){let n=Ad(e),r=t&&Nl.Address4.isValid(t)?Ad(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(Nl.Address6.isValid(e)){let t=Md(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,/* @__PURE__ */ Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=Bl(...e),n=kd(t.message),r=n;if(t.hasRange){let{offset:e,length:i}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(/* @__PURE__ */ RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(i)||i<0||i>n.byteLength-e)throw Object.assign(/* @__PURE__ */ RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});r=n.subarray(e,e+i)}let i=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,a=t.address??i,o=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(o||Nl.Address4.isValid(a)||Nl.Address6.isValid(a))){this._portSend(r,o?void 0:a,o?void 0:t.port),n?.call(this,null,r.byteLength);return}let s=this._destroyed;e.send({port:t.port,address:a,message:r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}).then(()=>n?.call(this,null,r.byteLength),e=>{if(this._destroyed&&!s)return;let t=Yl(e);n?n.call(this,t,0):this.emit(`error`,t)})})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},Od=new Uint8Array([2]),kd=e=>{if(typeof e==`string`)return Pl.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(kd),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},Ad=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},jd=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},Md=e=>{let t=new Nl.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},Nd=(e,t)=>{let n=new Dd(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},Pd={Socket:Dd,createSocket:Nd};$s();var Fd=/* @__PURE__ */ g({Agent:()=>tf,ClientRequest:()=>$d,HTTPParser:()=>qd,IncomingMessage:()=>Yd,METHODS:()=>Ld,STATUS_CODES:()=>Rd,Server:()=>ef,ServerResponse:()=>Zd,_default:()=>sf,createServer:()=>of,default:()=>sf,get:()=>af,globalAgent:()=>nf,request:()=>rf}),Id=new TextDecoder(`latin1`),Ld=/* @__PURE__ */ `ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),Rd={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},zd=/* @__PURE__ */ new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),Bd=13,Vd=10,Hd=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,Ud=(e,t)=>(e.code=t,e),Wd=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},Gd=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===Bd&&e[n+1]===Vd)return n;return-1},Kd=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===Bd&&e[t+1]===Vd&&e[t+2]===Bd&&e[t+3]===Vd)return t;return-1},qd=class{mode;handlers;buf=/* @__PURE__ */ new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=Wd(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=Kd(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=Id.decode(e).split(`\r
|
|
65
|
-
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],a={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(a,n,r)}let o={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:a,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);o.method=(e??`GET`).toUpperCase(),o.url=t??`/`,this.applyVersion(o,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);o.statusCode=parseInt(a,10)||0,o.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(o,t)}return o}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:
|
|
64
|
+
`)+` `+n[1]:n[0]+t+` `+e.join(`, `)+` `+n[1]}e.types=$u();function v(e){return Array.isArray(e)}e.isArray=v;function y(e){return typeof e==`boolean`}e.isBoolean=y;function b(e){return e===null}e.isNull=b;function x(e){return e==null}e.isNullOrUndefined=x;function S(e){return typeof e==`number`}e.isNumber=S;function C(e){return typeof e==`string`}e.isString=C;function w(e){return typeof e==`symbol`}e.isSymbol=w;function T(e){return e===void 0}e.isUndefined=T;function E(e){return D(e)&&M(e)===`[object RegExp]`}e.isRegExp=E,e.types.isRegExp=E;function D(e){return typeof e==`object`&&!!e}e.isObject=D;function O(e){return D(e)&&M(e)===`[object Date]`}e.isDate=O,e.types.isDate=O;function k(e){return D(e)&&(M(e)===`[object Error]`||e instanceof Error)}e.isError=k,e.types.isNativeError=k;function A(e){return typeof e==`function`}e.isFunction=A;function j(e){return e===null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||typeof e==`symbol`||e===void 0}e.isPrimitive=j,e.isBuffer=ed();function M(e){return Object.prototype.toString.call(e)}function N(e){return e<10?`0`+e.toString(10):e.toString(10)}var ee=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function te(){var e=/* @__PURE__ */ new Date,t=[N(e.getHours()),N(e.getMinutes()),N(e.getSeconds())].join(`:`);return[e.getDate(),ee[e.getMonth()],t].join(` `)}e.log=function(){console.log(`%s - %s`,te(),e.format.apply(e,arguments))},e.inherits=Ql(),e._extend=function(e,t){if(!t||!D(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};function P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var F=typeof Symbol<`u`?Symbol(`util.promisify.custom`):void 0;e.promisify=function(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);if(F&&e[F]){var n=e[F];if(typeof n!=`function`)throw TypeError(`The "util.promisify.custom" argument must be of type Function`);return Object.defineProperty(n,F,{value:n,enumerable:!1,writable:!1,configurable:!0}),n}function n(){for(var t,n,r=new Promise(function(e,r){t=e,n=r}),i=[],a=0;a<arguments.length;a++)i.push(arguments[a]);i.push(function(e,r){e?n(e):t(r)});try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),F&&Object.defineProperty(n,F,{value:n,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(n,t(e))},e.promisify.custom=F;function ne(e,t){if(!e){var n=/* @__PURE__ */ Error(`Promise was rejected with a falsy value`);n.reason=e,e=n}return t(e)}function re(e){if(typeof e!=`function`)throw TypeError(`The "original" argument must be of type Function`);function n(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if(typeof r!=`function`)throw TypeError(`The last argument must be of type Function`);var a=this,o=function(){return r.apply(a,arguments)};e.apply(this,t).then(function(e){i.nextTick(o.bind(null,null,e))},function(e){i.nextTick(ne.bind(null,e,o))})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,t(e)),n}e.callbackify=re})),nd=/* @__PURE__ */ e(((e,n)=>{function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return t=l(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e){var t=u(e,`string`);return typeof t==`symbol`?t:String(t)}function u(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var d=(ec(),t(xs)).Buffer,f=td().inspect,p=f&&f.custom||`inspect`;function m(e,t,n){d.prototype.copy.call(e,t,n)}n.exports=/*#__PURE__*/ function(){function e(){o(this,e),this.head=null,this.tail=null,this.length=0}return c(e,[{key:`push`,value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:`unshift`,value:function(e){var t={data:e,next:this.head};this.length===0&&(this.tail=t),this.head=t,++this.length}},{key:`shift`,value:function(){if(this.length!==0){var e=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,e}}},{key:`clear`,value:function(){this.head=this.tail=null,this.length=0}},{key:`join`,value:function(e){if(this.length===0)return``;for(var t=this.head,n=``+t.data;t=t.next;)n+=e+t.data;return n}},{key:`concat`,value:function(e){if(this.length===0)return d.alloc(0);for(var t=d.allocUnsafe(e>>>0),n=this.head,r=0;n;)m(n.data,t,r),r+=n.data.length,n=n.next;return t}},{key:`consume`,value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:`first`,value:function(){return this.head.data}},{key:`_getString`,value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(a===i.length?r+=i:r+=i.slice(0,e),e-=a,e===0){a===i.length?(++n,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=i.slice(a));break}++n}return this.length-=n,r}},{key:`_getBuffer`,value:function(e){var t=d.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var i=n.data,a=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,a),e-=a,e===0){a===i.length?(++r,this.head=n.next?n.next:this.tail=null):(this.head=n,n.data=i.slice(a));break}++r}return this.length-=r,t}},{key:p,value:function(e,t){return f(this,i(i({},t),{},{depth:0,customInspect:!1}))}}]),e}()})),rd=/* @__PURE__ */ e(((e,t)=>{r();function n(e,t){var n=this,r=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return r||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,i.nextTick(c,this,e)):i.nextTick(c,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?n._writableState?n._writableState.errorEmitted?i.nextTick(o,n):(n._writableState.errorEmitted=!0,i.nextTick(a,n,e)):i.nextTick(a,n,e):t?(i.nextTick(o,n),t(e)):i.nextTick(o,n)}),this)}function a(e,t){c(e,t),o(e)}function o(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit(`close`)}function s(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function c(e,t){e.emit(`error`,t)}function l(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit(`error`,t)}t.exports={destroy:n,undestroy:s,errorOrDestroy:l}})),id=/* @__PURE__ */ e(((e,t)=>{function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var r={};function i(e,t,i){i||=Error;function a(e,n,r){return typeof t==`string`?t:t(e,n,r)}var o=/*#__PURE__*/ function(e){n(t,e);function t(t,n,r){return e.call(this,a(t,n,r))||this}return t}(i);o.prototype.name=i.name,o.prototype.code=e,r[e]=o}function a(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return String(e)}),n>2?`one of ${t} ${e.slice(0,n-1).join(`, `)}, or `+e[n-1]:n===2?`one of ${t} ${e[0]} or ${e[1]}`:`of ${t} ${e[0]}`}return`of ${t} ${String(e)}`}function o(e,t,n){return e.substr(!n||n<0?0:+n,t.length)===t}function s(e,t,n){return(n===void 0||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function c(e,t,n){return typeof n!=`number`&&(n=0),n+t.length>e.length?!1:e.indexOf(t,n)!==-1}i(`ERR_INVALID_OPT_VALUE`,function(e,t){return`The value "`+t+`" is invalid for option "`+e+`"`},TypeError),i(`ERR_INVALID_ARG_TYPE`,function(e,t,n){var r;typeof t==`string`&&o(t,`not `)?(r=`must not be`,t=t.replace(/^not /,``)):r=`must be`;var i=s(e,` argument`)?`The ${e} ${r} ${a(t,`type`)}`:`The "${e}" ${c(e,`.`)?`property`:`argument`} ${r} ${a(t,`type`)}`;return i+=`. Received type ${typeof n}`,i},TypeError),i(`ERR_STREAM_PUSH_AFTER_EOF`,`stream.push() after EOF`),i(`ERR_METHOD_NOT_IMPLEMENTED`,function(e){return`The `+e+` method is not implemented`}),i(`ERR_STREAM_PREMATURE_CLOSE`,`Premature close`),i(`ERR_STREAM_DESTROYED`,function(e){return`Cannot call `+e+` after a stream was destroyed`}),i(`ERR_MULTIPLE_CALLBACK`,`Callback called multiple times`),i(`ERR_STREAM_CANNOT_PIPE`,`Cannot pipe, not readable`),i(`ERR_STREAM_WRITE_AFTER_END`,`write after end`),i(`ERR_STREAM_NULL_VALUES`,`May not write null values to stream`,TypeError),i(`ERR_UNKNOWN_ENCODING`,function(e){return`Unknown encoding: `+e},TypeError),i(`ERR_STREAM_UNSHIFT_AFTER_END_EVENT`,`stream.unshift() after end event`),t.exports.codes=r})),ad=/* @__PURE__ */ e(((e,t)=>{var n=id().codes.ERR_INVALID_OPT_VALUE;function r(e,t,n){return e.highWaterMark==null?t?e[n]:null:e.highWaterMark}function i(e,t,i,a){var o=r(t,a,i);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0)throw new n(a?i:`highWaterMark`,o);return Math.floor(o)}return e.objectMode?16:16384}t.exports={getHighWaterMark:i}})),od=/* @__PURE__ */ e(((e,t)=>{eu(),t.exports=n;function n(e,t){if(r(`noDeprecation`))return e;var n=!1;function i(){if(!n){if(r(`throwDeprecation`))throw Error(t);r(`traceDeprecation`)?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}return i}function r(e){try{if(!$l.localStorage)return!1}catch{return!1}var t=$l.localStorage[e];return t!=null&&String(t).toLowerCase()===`true`}})),sd=/* @__PURE__ */ e(((e,n)=>{eu(),r(),n.exports=O;function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){se(t,e)}}var o;O.WritableState=E;var s={deprecate:od()},c=tu(),l=(ec(),t(xs)).Buffer,u=($l===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:$l).Uint8Array||function(){};function d(e){return l.from(e)}function f(e){return l.isBuffer(e)||e instanceof u}var p=rd(),m=ad().getHighWaterMark,h=id().codes,g=h.ERR_INVALID_ARG_TYPE,_=h.ERR_METHOD_NOT_IMPLEMENTED,v=h.ERR_MULTIPLE_CALLBACK,y=h.ERR_STREAM_CANNOT_PIPE,b=h.ERR_STREAM_DESTROYED,x=h.ERR_STREAM_NULL_VALUES,S=h.ERR_STREAM_WRITE_AFTER_END,C=h.ERR_UNKNOWN_ENCODING,w=p.errorOrDestroy;Ql()(O,c);function T(){}function E(e,t,n){o||=cd(),e||={},typeof n!=`boolean`&&(n=t instanceof o),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=m(this,e,`writableHighWaterMark`,n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){P(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}E.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(E.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var D;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(D=Function.prototype[Symbol.hasInstance],Object.defineProperty(O,Symbol.hasInstance,{value:function(e){return D.call(this,e)?!0:this===O&&e&&e._writableState instanceof E}})):D=function(e){return e instanceof this};function O(e){o||=cd();var t=this instanceof o;if(!t&&!D.call(O,this))return new O(e);this._writableState=new E(e,this,t),this.writable=!0,e&&(typeof e.write==`function`&&(this._write=e.write),typeof e.writev==`function`&&(this._writev=e.writev),typeof e.destroy==`function`&&(this._destroy=e.destroy),typeof e.final==`function`&&(this._final=e.final)),c.call(this)}O.prototype.pipe=function(){w(this,new y)};function k(e,t){var n=new S;w(e,n),i.nextTick(t,n)}function A(e,t,n,r){var a;return n===null?a=new x:typeof n!=`string`&&!t.objectMode&&(a=new g(`chunk`,[`string`,`Buffer`],n)),!a||(w(e,a),i.nextTick(r,a),!1)}O.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&f(e);return a&&!l.isBuffer(e)&&(e=d(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=T),r.ending?k(this,n):(a||A(this,r,e,n))&&(r.pendingcb++,i=M(this,r,a,e,t,n)),i},O.prototype.cork=function(){this._writableState.corked++},O.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&re(this,e))},O.prototype.setDefaultEncoding=function(e){if(typeof e==`string`&&(e=e.toLowerCase()),!([`hex`,`utf8`,`utf-8`,`ascii`,`binary`,`base64`,`ucs2`,`ucs-2`,`utf16le`,`utf-16le`,`raw`].indexOf((e+``).toLowerCase())>-1))throw new C(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(O.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function j(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=l.from(t,n)),t}Object.defineProperty(O.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function M(e,t,n,r,i,a){if(!n){var o=j(t,r,i);r!==o&&(n=!0,i=`buffer`,r=o)}var s=t.objectMode?1:r.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:a,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else N(e,t,!1,s,r,i,a);return c}function N(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new b(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function ee(e,t,n,r,a){--t.pendingcb,n?(i.nextTick(a,r),i.nextTick(ae,e,t),e._writableState.errorEmitted=!0,w(e,r)):(a(r),e._writableState.errorEmitted=!0,w(e,r),ae(e,t))}function te(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function P(e,t){var n=e._writableState,r=n.sync,a=n.writecb;if(typeof a!=`function`)throw new v;if(te(n),t)ee(e,n,r,t,a);else{var o=I(n)||e.destroyed;!o&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&re(e,n),r?i.nextTick(F,e,n,o,a):F(e,n,o,a)}}function F(e,t,n,r){n||ne(e,t),t.pendingcb--,r(),ae(e,t)}function ne(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function re(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=Array(r),o=t.corkedRequestsFree;o.entry=n;for(var s=0,c=!0;n;)i[s]=n,n.isBuf||(c=!1),n=n.next,s+=1;i.allBuffers=c,N(e,t,!0,t.length,i,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback;if(N(e,t,!1,t.objectMode?1:l.length,l,u,d),n=n.next,t.bufferedRequestCount--,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}O.prototype._write=function(e,t,n){n(new _(`_write()`))},O.prototype._writev=null,O.prototype.end=function(e,t,n){var r=this._writableState;return typeof e==`function`?(n=e,e=null,t=null):typeof t==`function`&&(n=t,t=null),e!=null&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||oe(this,r,n),this},Object.defineProperty(O.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function I(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function L(e,t){e._final(function(n){t.pendingcb--,n&&w(e,n),t.prefinished=!0,e.emit(`prefinish`),ae(e,t)})}function ie(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,i.nextTick(L,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function ae(e,t){var n=I(t);if(n&&(ie(e,t),t.pendingcb===0&&(t.finished=!0,e.emit(`finish`),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}function oe(e,t,n){t.ending=!0,ae(e,t),n&&(t.finished?i.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function se(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(n),r=r.next}t.corkedRequestsFree.next=e}Object.defineProperty(O.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),O.prototype.destroy=p.destroy,O.prototype._undestroy=p.undestroy,O.prototype._destroy=function(e,t){t(e)}})),cd=/* @__PURE__ */ e(((e,t)=>{r();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=u;var a=md(),o=sd();Ql()(u,a);for(var s=n(o.prototype),c=0;c<s.length;c++){var l=s[c];u.prototype[l]||(u.prototype[l]=o.prototype[l])}function u(e){if(!(this instanceof u))return new u(e);a.call(this,e),o.call(this,e),this.allowHalfOpen=!0,e&&(e.readable===!1&&(this.readable=!1),e.writable===!1&&(this.writable=!1),e.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once(`end`,d)))}Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(u.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(u.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function d(){this._writableState.ended||i.nextTick(f,this)}function f(e){e.end()}Object.defineProperty(u.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState!==void 0&&this._writableState!==void 0&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}})})),ld=/* @__PURE__ */ e(((e,n)=>{var r=(ec(),t(xs)),i=r.Buffer;function a(e,t){for(var n in e)t[n]=e[n]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?n.exports=r:(a(r,e),e.Buffer=o);function o(e,t,n){return i(e,t,n)}o.prototype=Object.create(i.prototype),a(i,o),o.from=function(e,t,n){if(typeof e==`number`)throw TypeError(`Argument must not be a number`);return i(e,t,n)},o.alloc=function(e,t,n){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);var r=i(e);return t===void 0?r.fill(0):typeof n==`string`?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return i(e)},o.allocUnsafeSlow=function(e){if(typeof e!=`number`)throw TypeError(`Argument must be a number`);return r.SlowBuffer(e)}})),ud=/* @__PURE__ */ e((e=>{var t=ld().Buffer,n=t.isEncoding||function(e){switch(e=``+e,e&&e.toLowerCase()){case`hex`:case`utf8`:case`utf-8`:case`ascii`:case`binary`:case`base64`:case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:case`raw`:return!0;default:return!1}};function r(e){if(!e)return`utf8`;for(var t;;)switch(e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:if(t)return;e=(``+e).toLowerCase(),t=!0}}function i(e){var i=r(e);if(typeof i!=`string`&&(t.isEncoding===n||!n(e)))throw Error(`Unknown encoding: `+e);return i||e}e.StringDecoder=a;function a(e){this.encoding=i(e);var n;switch(this.encoding){case`utf16le`:this.text=f,this.end=p,n=4;break;case`utf8`:this.fillLast=l,n=4;break;case`base64`:this.text=m,this.end=h,n=3;break;default:this.write=g,this.end=_;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}a.prototype.write=function(e){if(e.length===0)return``;var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return``;n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||``},a.prototype.end=d,a.prototype.text=u,a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function o(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function s(e,t,n){var r=t.length-1;if(r<n)return 0;var i=o(t[r]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(e.lastNeed=i-2),i):--r<n||i===-2?0:(i=o(t[r]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function c(e,t,n){if((t[0]&192)!=128)return e.lastNeed=0,`�`;if(e.lastNeed>1&&t.length>1){if((t[1]&192)!=128)return e.lastNeed=1,`�`;if(e.lastNeed>2&&t.length>2&&(t[2]&192)!=128)return e.lastNeed=2,`�`}}function l(e){var t=this.lastTotal-this.lastNeed,n=c(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function u(e,t){var n=s(this,e,t);if(!this.lastNeed)return e.toString(`utf8`,t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString(`utf8`,t,r)}function d(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+`�`:t}function f(e,t){if((e.length-t)%2==0){var n=e.toString(`utf16le`,t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString(`utf16le`,t,e.length-1)}function p(e){var t=e&&e.length?this.write(e):``;if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString(`utf16le`,0,n)}return t}function m(e,t){var n=(e.length-t)%3;return n===0?e.toString(`base64`,t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString(`base64`,t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):``;return this.lastNeed?t+this.lastChar.toString(`base64`,0,3-this.lastNeed):t}function g(e){return e.toString(this.encoding)}function _(e){return e&&e.length?this.write(e):``}})),dd=/* @__PURE__ */ e(((e,t)=>{var n=id().codes.ERR_STREAM_PREMATURE_CLOSE;function r(e){var t=!1;return function(){if(!t){t=!0;var n=[...arguments];e.apply(this,n)}}}function i(){}function a(e){return e.setHeader&&typeof e.abort==`function`}function o(e,t,s){if(typeof t==`function`)return o(e,null,t);t||={},s=r(s||i);var c=t.readable||t.readable!==!1&&e.readable,l=t.writable||t.writable!==!1&&e.writable,u=function(){e.writable||f()},d=e._writableState&&e._writableState.finished,f=function(){l=!1,d=!0,c||s.call(e)},p=e._readableState&&e._readableState.endEmitted,m=function(){c=!1,p=!0,l||s.call(e)},h=function(t){s.call(e,t)},g=function(){var t;if(c&&!p)return e._readableState&&e._readableState.ended||(t=new n),s.call(e,t);if(l&&!d)return e._writableState&&e._writableState.ended||(t=new n),s.call(e,t)},_=function(){e.req.on(`finish`,f)};return a(e)?(e.on(`complete`,f),e.on(`abort`,g),e.req?_():e.on(`request`,_)):l&&!e._writableState&&(e.on(`end`,u),e.on(`close`,u)),e.on(`end`,m),e.on(`finish`,f),t.error!==!1&&e.on(`error`,h),e.on(`close`,g),function(){e.removeListener(`complete`,f),e.removeListener(`abort`,g),e.removeListener(`request`,_),e.req&&e.req.removeListener(`finish`,f),e.removeListener(`end`,u),e.removeListener(`close`,u),e.removeListener(`finish`,f),e.removeListener(`end`,m),e.removeListener(`error`,h),e.removeListener(`close`,g)}}t.exports=o})),fd=/* @__PURE__ */ e(((e,t)=>{r();var n;function a(e,t,n){return t=o(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=s(e,`string`);return typeof t==`symbol`?t:String(t)}function s(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var c=dd(),l=Symbol(`lastResolve`),u=Symbol(`lastReject`),d=Symbol(`error`),f=Symbol(`ended`),p=Symbol(`lastPromise`),m=Symbol(`handlePromise`),h=Symbol(`stream`);function g(e,t){return{value:e,done:t}}function _(e){var t=e[l];if(t!==null){var n=e[h].read();n!==null&&(e[p]=null,e[l]=null,e[u]=null,t(g(n,!1)))}}function v(e){i.nextTick(_,e)}function y(e,t){return function(n,r){e.then(function(){t[f]?n(g(void 0,!0)):t[m](n,r)},r)}}var b=Object.getPrototypeOf(function(){}),x=Object.setPrototypeOf((n={get stream(){return this[h]},next:function(){var e=this,t=this[d];if(t!==null)return Promise.reject(t);if(this[f])return Promise.resolve(g(void 0,!0));if(this[h].destroyed)return new Promise(function(t,n){i.nextTick(function(){e[d]?n(e[d]):t(g(void 0,!0))})});var n=this[p],r;if(n)r=new Promise(y(n,this));else{var a=this[h].read();if(a!==null)return Promise.resolve(g(a,!1));r=new Promise(this[m])}return this[p]=r,r}},a(n,Symbol.asyncIterator,function(){return this}),a(n,`return`,function(){var e=this;return new Promise(function(t,n){e[h].destroy(null,function(e){e?n(e):t(g(void 0,!0))})})}),n),b);t.exports=function(e){var t,n=Object.create(x,(t={},a(t,h,{value:e,writable:!0}),a(t,l,{value:null,writable:!0}),a(t,u,{value:null,writable:!0}),a(t,d,{value:null,writable:!0}),a(t,f,{value:e._readableState.endEmitted,writable:!0}),a(t,m,{value:function(e,t){var r=n[h].read();r?(n[p]=null,n[l]=null,n[u]=null,e(g(r,!1))):(n[l]=e,n[u]=t)},writable:!0}),t));return n[p]=null,c(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[u];t!==null&&(n[p]=null,n[l]=null,n[u]=null,t(e)),n[d]=e}else{var r=n[l];r!==null&&(n[p]=null,n[l]=null,n[u]=null,r(g(void 0,!0))),n[f]=!0}}),e.on(`readable`,v.bind(null,n)),n}})),pd=/* @__PURE__ */ e(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),md=/* @__PURE__ */ e(((e,n)=>{eu(),r(),n.exports=k;var a;k.ReadableState=O,Zl().EventEmitter;var o=function(e,t){return e.listeners(t).length},s=tu(),c=(ec(),t(xs)).Buffer,l=($l===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:$l).Uint8Array||function(){};function u(e){return c.from(e)}function d(e){return c.isBuffer(e)||e instanceof l}var f=td(),p=f&&f.debuglog?f.debuglog(`stream`):function(){},m=nd(),h=rd(),g=ad().getHighWaterMark,_=id().codes,v=_.ERR_INVALID_ARG_TYPE,y=_.ERR_STREAM_PUSH_AFTER_EOF,b=_.ERR_METHOD_NOT_IMPLEMENTED,x=_.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,S,C,w;Ql()(k,s);var T=h.errorOrDestroy,E=[`error`,`close`,`destroy`,`pause`,`resume`];function D(e,t,n){if(typeof e.prependListener==`function`)return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function O(e,t,n){a||=cd(),e||={},typeof n!=`boolean`&&(n=t instanceof a),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=g(this,e,`readableHighWaterMark`,n),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=e.emitClose!==!1,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||`utf8`,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(S||=ud().StringDecoder,this.decoder=new S(e.encoding),this.encoding=e.encoding)}function k(e){if(a||=cd(),!(this instanceof k))return new k(e);var t=this instanceof a;this._readableState=new O(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),s.call(this)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),k.prototype.destroy=h.destroy,k.prototype._undestroy=h.undestroy,k.prototype._destroy=function(e,t){t(e)},k.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:typeof e==`string`&&(t||=n.defaultEncoding,t!==n.encoding&&(e=c.from(e,t),t=``),r=!0),A(this,e,t,!1,r)},k.prototype.unshift=function(e){return A(this,e,null,!0,!1)};function A(e,t,n,r,i){p(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,P(e,a);else{var o;if(i||(o=M(a,t)),o)T(e,o);else if(a.objectMode||t&&t.length>0){if(typeof t!=`string`&&!a.objectMode&&Object.getPrototypeOf(t)!==c.prototype&&(t=u(t)),r)a.endEmitted?T(e,new x):j(e,a,t,!0);else if(a.ended)T(e,new y);else if(a.destroyed)return!1;else a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||t.length!==0?j(e,a,t,!1):re(e,a)):j(e,a,t,!1)}else r||(a.reading=!1,re(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function j(e,t,n,r){t.flowing&&t.length===0&&!t.sync?(t.awaitDrain=0,e.emit(`data`,n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&F(e)),re(e,t)}function M(e,t){var n;return!d(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new v(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}k.prototype.isPaused=function(){return this._readableState.flowing===!1},k.prototype.setEncoding=function(e){S||=ud().StringDecoder;var t=new S(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r=``;n!==null;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),r!==``&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var N=1073741824;function ee(e){return e>=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function te(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=ee(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}k.prototype.read=function(e){p(`read`,e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&((t.highWaterMark===0?t.length>0:t.length>=t.highWaterMark)||t.ended))return p(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?le(this):F(this),null;if(e=te(e,t),e===0&&t.ended)return t.length===0&&le(this),null;var r=t.needReadable;p(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,p(`length less than watermark`,r)),t.ended||t.reading?(r=!1,p(`reading or ended`,r)):r&&(p(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=te(n,t)));var i=e>0?ce(e,t):null;return i===null?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&le(this)),i!==null&&this.emit(`data`,i),i};function P(e,t){if(p(`onEofChunk`),!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.sync?F(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,ne(e)))}}function F(e){var t=e._readableState;p(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(p(`emitReadable`,t.flowing),t.emittedReadable=!0,i.nextTick(ne,e))}function ne(e){var t=e._readableState;p(`emitReadable_`,t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&(e.emit(`readable`),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,R(e)}function re(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(p(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}k.prototype._read=function(e){T(this,new b(`_read()`))},k.prototype.pipe=function(e,t){var n=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=e;break;case 1:r.pipes=[r.pipes,e];break;default:r.pipes.push(e)}r.pipesCount+=1,p(`pipe count=%d opts=%j`,r.pipesCount,t);var a=(!t||t.end!==!1)&&e!==i.stdout&&e!==i.stderr?c:_;r.endEmitted?i.nextTick(a):n.once(`end`,a),e.on(`unpipe`,s);function s(e,t){p(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,d())}function c(){p(`onend`),e.end()}var l=L(n);e.on(`drain`,l);var u=!1;function d(){p(`cleanup`),e.removeListener(`close`,h),e.removeListener(`finish`,g),e.removeListener(`drain`,l),e.removeListener(`error`,m),e.removeListener(`unpipe`,s),n.removeListener(`end`,c),n.removeListener(`end`,_),n.removeListener(`data`,f),u=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&l()}n.on(`data`,f);function f(t){p(`ondata`);var i=e.write(t);p(`dest.write`,i),i===!1&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&de(r.pipes,e)!==-1)&&!u&&(p(`false write response, pause`,r.awaitDrain),r.awaitDrain++),n.pause())}function m(t){p(`onerror`,t),_(),e.removeListener(`error`,m),o(e,`error`)===0&&T(e,t)}D(e,`error`,m);function h(){e.removeListener(`finish`,g),_()}e.once(`close`,h);function g(){p(`onfinish`),e.removeListener(`close`,h),_()}e.once(`finish`,g);function _(){p(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),r.flowing||(p(`pipe resume`),n.resume()),e};function L(e){return function(){var t=e._readableState;p(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&o(e,`data`)&&(t.flowing=!0,R(e))}}k.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes||(e||=t.pipes,t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit(`unpipe`,this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<i;a++)r[a].emit(`unpipe`,this,{hasUnpiped:!1});return this}var o=de(t.pipes,e);return o===-1||(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n)),this},k.prototype.on=function(e,t){var n=s.prototype.on.call(this,e,t),r=this._readableState;return e===`data`?(r.readableListening=this.listenerCount(`readable`)>0,r.flowing!==!1&&this.resume()):e===`readable`&&!r.endEmitted&&!r.readableListening&&(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,p(`on readable`,r.length,r.reading),r.length?F(this):r.reading||i.nextTick(ae,this)),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(e,t){var n=s.prototype.removeListener.call(this,e,t);return e===`readable`&&i.nextTick(ie,this),n},k.prototype.removeAllListeners=function(e){var t=s.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&i.nextTick(ie,this),t};function ie(e){var t=e._readableState;t.readableListening=e.listenerCount(`readable`)>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount(`data`)>0&&e.resume()}function ae(e){p(`readable nexttick read 0`),e.read(0)}k.prototype.resume=function(){var e=this._readableState;return e.flowing||(p(`resume`),e.flowing=!e.readableListening,oe(this,e)),e.paused=!1,this};function oe(e,t){t.resumeScheduled||(t.resumeScheduled=!0,i.nextTick(se,e,t))}function se(e,t){p(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),R(e),t.flowing&&!t.reading&&e.read(0)}k.prototype.pause=function(){return p(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(p(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function R(e){var t=e._readableState;for(p(`flow`,t.flowing);t.flowing&&e.read()!==null;);}k.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(p(`wrapped end`),n.decoder&&!n.ended){var e=n.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on(`data`,function(i){p(`wrapped data`),n.decoder&&(i=n.decoder.write(i)),!(n.objectMode&&i==null)&&(n.objectMode||i&&i.length)&&(t.push(i)||(r=!0,e.pause()))}),e)this[i]===void 0&&typeof e[i]==`function`&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var a=0;a<E.length;a++)e.on(E[a],this.emit.bind(this,E[a]));return this._read=function(t){p(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(k.prototype[Symbol.asyncIterator]=function(){return C===void 0&&(C=fd()),C(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),k._fromList=ce,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function ce(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(``):t.buffer.length===1?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function le(e){var t=e._readableState;p(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,i.nextTick(ue,t,e))}function ue(e,t){if(p(`endReadableNT`,e.endEmitted,e.length),!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit(`end`),e.autoDestroy)){var n=t._writableState;(!n||n.autoDestroy&&n.finished)&&t.destroy()}}typeof Symbol==`function`&&(k.from=function(e,t){return w===void 0&&(w=pd()),w(k,e,t)});function de(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),hd=/* @__PURE__ */ e(((e,t)=>{t.exports=l;var n=id().codes,r=n.ERR_METHOD_NOT_IMPLEMENTED,i=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,o=n.ERR_TRANSFORM_WITH_LENGTH_0,s=cd();Ql()(l,s);function c(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(r===null)return this.emit(`error`,new i);n.writechunk=null,n.writecb=null,t!=null&&this.push(t),r(e);var a=this._readableState;a.reading=!1,(a.needReadable||a.length<a.highWaterMark)&&this._read(a.highWaterMark)}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform==`function`&&(this._transform=e.transform),typeof e.flush==`function`&&(this._flush=e.flush)),this.on(`prefinish`,u)}function u(){var e=this;typeof this._flush==`function`&&!this._readableState.destroyed?this._flush(function(t,n){d(e,t,n)}):d(this,null,null)}l.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},l.prototype._transform=function(e,t,n){n(new r(`_transform()`))},l.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0},l.prototype._destroy=function(e,t){s.prototype._destroy.call(this,e,function(e){t(e)})};function d(e,t,n){if(t)return e.emit(`error`,t);if(n!=null&&e.push(n),e._writableState.length)throw new o;if(e._transformState.transforming)throw new a;return e.push(null)}})),gd=/* @__PURE__ */ e(((e,t)=>{t.exports=r;var n=hd();Ql()(r,n);function r(e){if(!(this instanceof r))return new r(e);n.call(this,e)}r.prototype._transform=function(e,t,n){n(null,e)}})),_d=/* @__PURE__ */ e(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=id().codes,a=i.ERR_MISSING_ARGS,o=i.ERR_STREAM_DESTROYED;function s(e){if(e)throw e}function c(e){return e.setHeader&&typeof e.abort==`function`}function l(e,t,i,a){a=r(a);var s=!1;e.on(`close`,function(){s=!0}),n===void 0&&(n=dd()),n(e,{readable:t,writable:i},function(e){if(e)return a(e);s=!0,a()});var l=!1;return function(t){if(!s&&!l){if(l=!0,c(e))return e.abort();if(typeof e.destroy==`function`)return e.destroy();a(t||new o(`pipe`))}}}function u(e){e()}function d(e,t){return e.pipe(t)}function f(e){return!e.length||typeof e[e.length-1]!=`function`?s:e.pop()}function p(){var e=[...arguments],t=f(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new a(`streams`);var n,r=e.map(function(i,a){var o=a<e.length-1;return l(i,o,a>0,function(e){n||=e,e&&r.forEach(u),!o&&(r.forEach(u),t(n))})});return e.reduce(d)}t.exports=p})),vd=(/* @__PURE__ */ e(((e,t)=>{t.exports=r;var n=Zl().EventEmitter;Ql()(r,n),r.Readable=md(),r.Writable=sd(),r.Duplex=cd(),r.Transform=hd(),r.PassThrough=gd(),r.finished=dd(),r.pipeline=_d(),r.Stream=r;function r(){n.call(this)}r.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}r.on(`data`,i);function a(){r.readable&&r.resume&&r.resume()}e.on(`drain`,a),e._isStdio||t&&t.end===!1||(r.on(`end`,s),r.on(`close`,c));var o=!1;function s(){o||(o=!0,e.end())}function c(){o||(o=!0,typeof e.destroy==`function`&&e.destroy())}function l(e){if(u(),n.listenerCount(this,`error`)===0)throw e}r.on(`error`,l),e.on(`error`,l);function u(){r.removeListener(`data`,i),e.removeListener(`drain`,a),r.removeListener(`end`,s),r.removeListener(`close`,c),r.removeListener(`error`,l),e.removeListener(`error`,l),r.removeListener(`end`,u),r.removeListener(`close`,u),e.removeListener(`close`,u)}return r.on(`end`,u),r.on(`close`,u),e.on(`close`,u),e.emit(`pipe`,r),e}})))(),yd=Zl(),bd=/* @__PURE__ */ g({Server:()=>Sd,Socket:()=>xd,_default:()=>Ed,connect:()=>Cd,createConnection:()=>wd,createServer:()=>Td,default:()=>Ed,isIP:()=>Rl,isIPv4:()=>Il,isIPv6:()=>Ll}),xd=class extends vd.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;_relay;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super({...e,allowHalfOpen:!!e?.allowHalfOpen,autoDestroy:!0}),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_init__(e,t){return this._busyRelease??=Yo(`tcp socket`),t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort},this._remoteAddress={address:t.remoteAddress,family:t.remoteFamily,port:t.remotePort},this._relay=t.relay,this._connected=!0),this._webVPNTcpSocketPromise=e.then(e=>{let t=e.dataReadableStream.getReader(),n=e.dataWritableStream.getWriter();return this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._remoteAddress={address:e.remoteAddress,family:e.remoteFamily,port:e.remotePort},this._relay=e.relay,{...e,reader:t,writer:n}}).catch(e=>{this.destroyed||this.destroy(Xl(e))}),this._webVPNTcpSocketPromise.then(e=>{e&&!this.destroyed&&(this._connected=!0,this.emit(`connect`),this.isPaused()||this.read(0))}),this._webVPNTcpSocketPromise}_connected=!1;_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{e?e.reader.read().then(({value:e,done:t})=>{t?(this.push(null),this.read(0)):(this._restartTimeoutTimer(),this.push(e))}).catch(e=>{this.destroy(Xl(e))}):this.push(null)})}_write(e,t,n){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e)}).then(()=>{this.destroyed||(this._restartTimeoutTimer(),n())},e=>this._fail(e)):n(/* @__PURE__ */ Error(`Socket not connected`))}_fail(e){if(!this.destroyed){e=Xl(e);for(let t of this._pendingCallbacks)t(e);this.destroy(e)}}connect(...e){let t=zl(...e),{relay:n}=t,r=this.__webvpn_tcp_socket_init__(Fo(`an outbound tcp socket`).then(e=>(n!==void 0&&ts(e,`net.connect`),e.cloud.webvpn.tcpSocket({remoteAddress:t.host??`localhost`,remotePort:t.port,relay:n}))));return t.callback&&r.then(e=>{e&&!this.destroyed&&t.callback.call(this)}),this}_final(e){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async e=>{e&&await e.writer.close()}).then(()=>{this.destroyed||e()},e=>this._fail(e)):e()}_destroyError;_destroy(e,t){this._destroyError=e??void 0,this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._busyRelease?.(),this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{t&&(this._resetRequested?await t.resetAndDestroy():!e&&this._writableState.finished&&this._readableState.ended?await t.end():await t.destroy())}).then(()=>t(e),()=>t(e)):t(e)}destroy(e,t){return this.destroyed&&!t?this:(Object.assign(this,{readable:!1,writable:!1}),Reflect.apply(super.destroy,this,[e,t]))}emit(e,...t){if(e===`finish`)for(let e of this._endCallbacks.splice(0))e();if(e!==`close`||!this.destroyed)return super.emit(e,...t);let n=this._destroyError!==void 0;if(!this._connected){let e=super.emit(`close`,n);return this._settlePending(Object.assign(/* @__PURE__ */ Error(`Socket closed before the connection was established`),{code:`ERR_SOCKET_CLOSED_BEFORE_CONNECTION`})),e}return this._settlePending(Object.assign(/* @__PURE__ */ Error(`write ECANCELED`),{code:`ECANCELED`,syscall:`write`})),super.emit(`close`,n)}_settlePending(e){let t=e;for(let e of this._pendingCallbacks)e(t),t=this._destroyError??t}destroySoon(){this._writableState.finished?this.destroy():(this.once(`finish`,()=>this.destroy()),this.end())}_resetRequested=!1;resetAndDestroy(){return this._resetRequested=!0,this.destroy(),this}_timeoutMs;_timeoutTimer;_restartTimeoutTimer(){this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._timeoutMs&&!this.destroyed&&(this._timeoutTimer=setTimeout(()=>this.emit(`timeout`),this._timeoutMs))}setTimeout(e,t){return t&&this.on(`timeout`,t),this._timeoutMs=e,this._restartTimeoutTimer(),this}setNoDelay(e){let t=e??!0;return this._setTcpOption({type:0,value:t}),this}setKeepAlive(e,t){let n=typeof e==`object`&&e?e:{enable:e,initialDelay:t},r=n.initialDelay,i=r!==void 0&&r>0?Math.max(1,Math.round(r/1e3)):0;return this._setTcpOption({type:2,enabled:n.enable??!1,initialDelaySeconds:i}),this}setSendBufferSize(e){return this._setTcpOption({type:3,value:e}),this}setRecvBufferSize(e){return this._setTcpOption({type:4,value:e}),this}_typeOfService;getTypeOfService(){return this._typeOfService??0}setTypeOfService(e){return this._typeOfService=e,this}_setTcpOption(e){this._webVPNTcpSocketPromise?this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.destroyed||this.emit(`error`,e)}}):this.emit(`error`,/* @__PURE__ */ Error(`Cannot set socket option before connect`))}_pendingCallbacks=/* @__PURE__ */ new Set;_settleOnClose(e){let t=n=>{this._pendingCallbacks.delete(t)&&e(n)};return this._pendingCallbacks.add(t),t}end(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),typeof e==`function`&&(n=e,e=void 0),e==null&&this._writableState.finished){let e=Object.assign(/* @__PURE__ */ Error(`Cannot call end after a stream was finished`),{code:`ERR_STREAM_ALREADY_FINISHED`});return n&&queueMicrotask(()=>n(e)),this}return this.destroyed?(e!=null&&this.write(e,t,n),this):(n&&this._endCallbacks.push(this._settleOnClose(n)),Reflect.apply(super.end,this,[e,t]))}_endCallbacks=[];write(e,t,n){if(typeof t==`function`&&(n=t,t=void 0),this.destroyed){let e=Object.assign(/* @__PURE__ */ Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`});return n&&queueMicrotask(()=>n(e)),!1}if(!n)return t?super.write(e,t):super.write(e);let r=this._settleOnClose(n);return t?super.write(e,t,r):super.write(e,r)}address(){return this._localAddress??{}}unref(){return this}ref(){return this}autoSelectFamilyAttemptedAddresses;bufferSize;bytesRead;bytesWritten;connecting;pending;get localAddress(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.address}get localPort(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.port}get localFamily(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.family}readyState;get remoteAddress(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.address}get remotePort(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.port}get remoteFamily(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.family}timeout;server=null},Sd=class extends yd.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;_relayChoice;_allowHalfOpen;_relay;constructor(e,t){super(e),this._relayChoice=e?.relay,this._allowHalfOpen=!!e?.allowHalfOpen,t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_listener_init__(e){return this._busyRelease??=Yo(`tcp server`),this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._relay=e.relay,e)).catch(e=>{this.emit(`error`,Xl(e))}),this._webVPNTcpSocketListenerPromise.then(e=>{e?this.emit(`listening`):this._busyRelease?.()}),this._webVPNTcpSocketListenerPromise}listen(...e){let t=zl(...e);this._closeEmitted=!1;let n=e=>{let t=new xd({allowHalfOpen:this._allowHalfOpen});t.server=this,t.__webvpn_tcp_socket_init__(Promise.resolve(e),e),this.emit(`connection`,t)},r=e=>{this._localAddress=void 0;try{e&&this.listenerCount(`error`)>0&&this.emit(`error`,e)}finally{this._emitClose()}},i=this._relayChoice,a=e=>Fo(`a tcp listener`).then(a=>(i!==void 0&&ts(a,`net.createServer`),a.cloud.webvpn.tcpSocketListener({localAddress:e,localPort:t.port,onConnection:n,onClose:r,relay:i}))),o=t.host?a(t.host):a(`::`).catch(()=>a(`0.0.0.0`)),s=this.__webvpn_tcp_socket_listener_init__(o);return t.callback&&s.then(e=>{e&&t.callback.call(this)}),this}_closeEmitted=!1;_emitClose(){this._closeEmitted||(this._closeEmitted=!0,this._busyRelease?.(),this.emit(`close`))}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this._emitClose(),e&&e()}catch(t){this._localAddress=void 0,this._emitClose(),e&&e(t)}}),this}address(){return this._localAddress??null}getConnections(e){throw Error(`Method not implemented.`)}ref(){return this}unref(){return this}maxConnections;connections;listening;async[Symbol.asyncDispose](){}},Cd=(e,t)=>new xd({allowHalfOpen:e?.allowHalfOpen}).connect(e,t),wd=Cd,Td=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new Sd(e);return t&&n.on(`connection`,t),n},Ed={Socket:xd,Server:Sd,connect:Cd,createConnection:wd,createServer:Td,isIP:Rl,isIPv4:Il,isIPv6:Ll};ec();var Dd=/* @__PURE__ */ g({Socket:()=>Od,createSocket:()=>Pd,default:()=>Fd}),Od=class extends yd.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=/* @__PURE__ */ new Map;_relayChoice;_relay;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,this._relayChoice=e.relay,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){this._webVPNUdpSocketPromise?this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}}):this.emit(`error`,/* @__PURE__ */ Error(`Cannot set socket option before bind`))}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:Hl,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,i=0;for(;i+4<=e.byteLength;){let a=t.getUint32(i);i+=4;let o=i+a;if(o>e.byteLength)break;let s=i+4,c=t.getUint8(s);s+=1;let l,u,d;if(c===2){if(!this._remoteAddress){i=o;continue}l=this._remoteAddress.address,u=this._remoteAddress.family,d=this._remoteAddress.port}else{let n=new Uint8Array(e,s,c===0?4:16);c===0?(u=`IPv4`,l=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(u=`IPv6`,l=Md(n)),s+=n.byteLength,d=t.getUint16(s),s+=2}let f=t.getUint32(s);s+=4;try{this.emit(`message`,G.from(e.slice(s,s+f)),{address:l,family:u,port:d,size:f})}catch(e){n||(n=!0,r=e)}i=o}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return kd;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=Pl.Address4.isValid(e)?jd(e):Nd(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(Pl.Address4.isValid(e)){let n=jd(e),r=t&&Pl.Address4.isValid(t)?jd(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(Pl.Address6.isValid(e)){let t=Nd(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,/* @__PURE__ */ Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let t=Bl(...e),n=this._type===`udp6`?`::`:`0.0.0.0`,r=this._relayChoice,i=this.__webvpn_udp_socket_init__(Fo(`a udp socket`).then(e=>(r!==void 0&&ts(e,`dgram.createSocket`),e.cloud.webvpn.udpSocket({type:this._type,address:t.address??n,port:t.port,dataPort:!0,relay:r}))));return t.callback&&i.then(e=>{e&&t.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=Yo(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,G.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._relay=e.relay,this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,Xl(e))}),this._webVPNUdpSocketPromise.then(e=>{e?this.emit(`listening`):this._busyRelease?.()}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t?.close()}finally{try{n||this.emit(`close`)}finally{e&&e()}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,Xl(e))})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(Pl.Address4.isValid(e)){let n=jd(e),r=t&&Pl.Address4.isValid(t)?jd(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(Pl.Address6.isValid(e)){let t=Nd(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,/* @__PURE__ */ Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=Vl(...e),n=Ad(t.message),r=n;if(t.hasRange){let{offset:e,length:i}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(/* @__PURE__ */ RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(i)||i<0||i>n.byteLength-e)throw Object.assign(/* @__PURE__ */ RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});r=n.subarray(e,e+i)}let i=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,a=t.address??i,o=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(o||Pl.Address4.isValid(a)||Pl.Address6.isValid(a))){this._portSend(r,o?void 0:a,o?void 0:t.port),n?.call(this,null,r.byteLength);return}let s=this._destroyed;e.send({port:t.port,address:a,message:r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}).then(()=>n?.call(this,null,r.byteLength),e=>{if(this._destroyed&&!s)return;let t=Xl(e);n?n.call(this,t,0):this.emit(`error`,t)})})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},kd=new Uint8Array([2]),Ad=e=>{if(typeof e==`string`)return Fl.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(Ad),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},jd=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},Md=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},Nd=e=>{let t=new Pl.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},Pd=(e,t)=>{let n=new Od(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},Fd={Socket:Od,createSocket:Pd};ec();var Id=/* @__PURE__ */ g({Agent:()=>nf,ClientRequest:()=>ef,HTTPParser:()=>Jd,IncomingMessage:()=>Xd,METHODS:()=>Rd,STATUS_CODES:()=>zd,Server:()=>tf,ServerResponse:()=>Qd,_default:()=>cf,createServer:()=>sf,default:()=>cf,get:()=>of,globalAgent:()=>rf,request:()=>af}),Ld=new TextDecoder(`latin1`),Rd=/* @__PURE__ */ `ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),zd={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},Bd=/* @__PURE__ */ new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),Vd=13,Hd=10,Ud=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,Wd=(e,t)=>(e.code=t,e),Gd=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},Kd=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===Vd&&e[n+1]===Hd)return n;return-1},qd=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===Vd&&e[t+1]===Hd&&e[t+2]===Vd&&e[t+3]===Hd)return t;return-1},Jd=class{mode;handlers;buf=/* @__PURE__ */ new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=Gd(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=qd(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=Ld.decode(e).split(`\r
|
|
65
|
+
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],a={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(a,n,r)}let o={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:a,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);o.method=(e??`GET`).toUpperCase(),o.url=t??`/`,this.applyVersion(o,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);o.statusCode=parseInt(a,10)||0,o.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(o,t)}return o}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:Bd.has(r)||(e[r]=`${i}, ${n}`)}setupBody(e){if(this.skipBody){this.framing=`none`;return}let t=e.headers[`transfer-encoding`];if(typeof t==`string`&&t.toLowerCase().includes(`chunked`)){this.framing=`chunked`,this.chunkState=`size`;return}let n=e.headers[`content-length`];if(typeof n==`string`&&n!==``){let e=parseInt(n,10);e>0?(this.framing=`length`,this.bodyRemaining=e):this.framing=`none`}else if(this.mode===`response`){let t=e.statusCode??0;this.framing=t>=100&&t<200||t===204||t===304?`none`:`eof`}else this.framing=`none`}consumeBody(){if(this.framing===`length`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);return this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0}return this.framing===`eof`?(this.buf.length>0&&(this.handlers.onBody(this.buf),this.buf=/* @__PURE__ */ new Uint8Array),!1):this.framing!==`chunked`||this.consumeChunked()}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=Kd(this.buf,0);if(e===-1)return!1;let t=Ld.decode(this.buf.subarray(0,e)),n=parseInt(t.split(`;`)[0].trim(),16);if(this.buf=this.buf.subarray(e+2),Number.isNaN(n))return!0;n===0?this.chunkState=`trailer`:(this.bodyRemaining=n,this.chunkState=`data`)}else if(this.chunkState===`data`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0&&(this.chunkState=`dataCRLF`)}else if(this.chunkState===`dataCRLF`){if(this.buf.length<2)return!1;this.buf=this.buf.subarray(2),this.chunkState=`size`}else{let e=Kd(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},Yd=(e,t)=>G.isBuffer(e)?e:typeof e==`string`?G.from(e,t??`utf8`):e instanceof Uint8Array?G.from(e):e instanceof ArrayBuffer?G.from(new Uint8Array(e)):G.from(String(e)),Xd=class extends vd.Stream.Readable{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];trailers={};rawTrailers=[];method;url;statusCode;statusMessage;complete=!1;socket;constructor(e){super(),this.socket=e}get connection(){return this.socket}_applyHead(e){this.httpVersion=e.httpVersion,this.httpVersionMajor=e.httpVersionMajor,this.httpVersionMinor=e.httpVersionMinor,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.method=e.method,this.url=e.url,this.statusCode=e.statusCode,this.statusMessage=e.statusMessage}_read(){}setTimeout(e,t){return this.socket.setTimeout(e,t),this}},Zd=class extends vd.Stream.Writable{_headerStore=/* @__PURE__ */ new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw Wd(/* @__PURE__ */ Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!Ud.test(e))throw Wd(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw Wd(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`),`ERR_HTTP_INVALID_HEADER_VALUE`);return this._headerStore.set(e.toLowerCase(),[e,Array.isArray(t)?[...t]:t]),this}getHeader(e){return this._headerStore.get(e.toLowerCase())?.[1]}getHeaderNames(){return[...this._headerStore.values()].map(([e])=>e)}getHeaders(){let e={};for(let[t,n]of this._headerStore.values())e[t]=n;return e}hasHeader(e){return this._headerStore.has(e.toLowerCase())}removeHeader(e){if(this.headersSent)throw Error(`Cannot remove headers after they are sent to the client`);this._headerStore.delete(e.toLowerCase())}_storeHeader(e){let t=this.hasHeader(`content-length`),n=this.getHeader(`transfer-encoding`);typeof n==`string`&&n.toLowerCase().includes(`chunked`)?this.chunkedEncoding=!0:!t&&this._shouldSendBody()&&(this.chunkedEncoding=!0,this.setHeader(`Transfer-Encoding`,`chunked`));let r=e+`\r
|
|
66
66
|
`;for(let[e,t]of this._headerStore.values())if(Array.isArray(t))for(let n of t)r+=`${e}: ${n}\r\n`;else r+=`${e}: ${t}\r\n`;return r+=`\r
|
|
67
|
-
`,r}_writeToSocket(e,t){this.socket?this.socket.destroyed||this.socket.write(e,e=>{e||t()}):t(/* @__PURE__ */ Error(`Socket is not available`))}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,n){let r=
|
|
67
|
+
`,r}_writeToSocket(e,t){this.socket?this.socket.destroyed||this.socket.write(e,e=>{e||t()}):t(/* @__PURE__ */ Error(`Socket is not available`))}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,n){let r=Yd(e),i=[];this.headersSent||=(this._implicitHeader(),i.push(G.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?r.length>0&&(i.push(G.from(`${r.length.toString(16)}\r\n`,`latin1`)),i.push(r),i.push(G.from(`\r
|
|
68
68
|
`,`latin1`))):i.push(r),i.length===0?n():this._writeToSocket(G.concat(i),n)}_final(e){let t=[];this.headersSent||=(!this.chunkedEncoding&&!this.hasHeader(`content-length`)&&this.setHeader(`Content-Length`,0),this._implicitHeader(),t.push(G.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding&&t.push(G.from(`0\r
|
|
69
69
|
\r
|
|
70
|
-
`,`latin1`)),this.finished=!0,t.length===0?e():this._writeToSocket(G.concat(t),e)}end(e,t,n){if(e!=null&&typeof e!=`function`&&!this._bodyWritten&&!this.headersSent&&!this.chunkedEncoding&&!this.hasHeader(`content-length`)){let n=typeof t==`string`?t:void 0;this.setHeader(`Content-Length`,
|
|
70
|
+
`,`latin1`)),this.finished=!0,t.length===0?e():this._writeToSocket(G.concat(t),e)}end(e,t,n){if(e!=null&&typeof e!=`function`&&!this._bodyWritten&&!this.headersSent&&!this.chunkedEncoding&&!this.hasHeader(`content-length`)){let n=typeof t==`string`?t:void 0;this.setHeader(`Content-Length`,Yd(e,n).length)}return super.end(e,t,n)}_headBlock},Qd=class extends Zd{statusCode=200;statusMessage;_writeHeadCalled=!1;sendDate=!0;req;socket;_keepAlive=!0;constructor(e){super(),this.req=e,this.socket=e.socket}_shouldSendBody(){if(this.req.method===`HEAD`)return!1;let e=this.statusCode;return!(e>=100&&e<200||e===204||e===304)}writeHead(e,t,n){if(this._writeHeadCalled||this.headersSent)throw Wd(/* @__PURE__ */ Error(`Cannot render headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);this._writeHeadCalled=!0,this.statusCode=e;let r=n;if(typeof t==`string`?this.statusMessage=t:t!=null&&(r=t),Array.isArray(r)){let e=Array.isArray(r[0])?r:Array.from({length:Math.floor(r.length/2)},(e,t)=>[r[t*2],r[t*2+1]]);for(let[t,n]of e)n!==void 0&&this._appendHeader(t,n)}else if(r)for(let[e,t]of Object.entries(r))t!==void 0&&this.setHeader(e,t);return this}_appendHeader(e,t){let n=this.getHeader(e);if(n===void 0)this.setHeader(e,t);else{let r=[...Array.isArray(n)?n:[n],...Array.isArray(t)?t:[t]].map(String);this.setHeader(e,r)}}_implicitHeader(){let e=this.statusMessage??zd[this.statusCode]??`unknown`;this.sendDate&&!this.hasHeader(`date`)&&this.setHeader(`Date`,(/* @__PURE__ */ new Date()).toUTCString()),this.hasHeader(`connection`)||this.setHeader(`Connection`,this._keepAlive?`keep-alive`:`close`),this._headBlock=this._storeHeader(`HTTP/1.1 ${this.statusCode} ${e}`)}writeContinue(){this._writeToSocket(G.from(`HTTP/1.1 100 Continue\r
|
|
71
71
|
\r
|
|
72
|
-
`,`latin1`),()=>{})}setTimeout(e,t){return this.socket?.setTimeout(e,t),this}},Qd=(...e)=>{let t={},n={},r,i=[...e],a=i.shift();if(typeof a==`string`||a instanceof URL){let e=typeof a==`string`?new URL(a):a;t={protocol:e.protocol,hostname:e.hostname,host:e.hostname,port:e.port,path:`${e.pathname}${e.search}`,auth:e.username?`${e.username}:${e.password}`:void 0};let o=i.shift();typeof o==`function`?r=o:o&&typeof o==`object`&&(n=o,r=i.shift())}else a&&typeof a==`object`&&(n=a,r=i.shift());return{options:{...t,...n},callback:r}},$d=class extends Xd{method;path;host;protocol;socket;get connection(){return this.socket}res=null;aborted=!1;_aborted=!1;constructor(e,t){super(),this.method=(e.method??`GET`).toUpperCase(),this.path=e.path??`/`,this.protocol=e.protocol??`http:`;let n=e.hostname??e.host??`localhost`;this.host=n;let r=Number(e.port??(this.protocol===`https:`?443:80));if(t&&this.once(`response`,t),e.headers)for(let[t,n]of Object.entries(e.headers))n!==void 0&&this.setHeader(t,n);if(!this.hasHeader(`host`)){let e=this.protocol===`https:`&&r===443||this.protocol!==`https:`&&r===80;this.setHeader(`Host`,e?n:`${n}:${r}`)}e.auth&&!this.hasHeader(`authorization`)&&this.setHeader(`Authorization`,`Basic ${G.from(e.auth).toString(`base64`)}`),this.socket=new bd,this.emit(`socket`,this.socket),this.socket.on(`error`,e=>{!this._aborted&&!this.res?.complete&&this.emit(`error`,e)}),this._attachResponseParser(),this.socket.connect({host:n,port:r,relay:e.relay},()=>{this.emit(`connect`)})}_shouldSendBody(){return this.method!==`GET`&&this.method!==`HEAD`&&this.method!==`DELETE`}_implicitHeader(){this._headBlock=this._storeHeader(`${this.method} ${this.path} HTTP/1.1`)}_attachResponseParser(){let e=new Yd(this.socket),t=new qd(`response`,{onHeaders:n=>{e._applyHead(n),this.method===`HEAD`&&(t.skipBody=!0),this.res=e,this.emit(`response`,e)},onBody:t=>{e.push(G.from(t))},onComplete:()=>{e.complete=!0,e.push(null)}});this.socket.on(`data`,e=>{this._aborted||t.execute(e)}),this.socket.on(`end`,()=>{t.finish()}),this.socket.on(`close`,()=>{this.emit(`close`)})}abort(){this._aborted||(this._aborted=!0,this.aborted=!0,this.emit(`abort`),this.socket.destroy())}destroy(e){return this._aborted||(this._aborted=!0,this.socket.destroy(e),super.destroy(e)),this}end(e,t,n){return this._aborted?this:super.end(e,t,n)}_writeToSocket(e,t){this._aborted?t():super._writeToSocket(e,t)}setTimeout(e,t){return this.socket.setTimeout(e,t),this}setNoDelay(e){this.socket.setNoDelay(e)}setSocketKeepAlive(e,t){this.socket.setKeepAlive(e,t)}},ef=new Proxy(class extends xd{constructor(e,t){let n={},r=t;typeof e==`function`?r=e:e&&(n=e),super(n),r&&this.on(`request`,r),this.on(`connection`,e=>this._handleConnection(e))}_handleConnection(e){let t=null,n=new qd(`request`,{onHeaders:r=>{t=new Yd(e),t._applyHead(r),r.method===`HEAD`&&(n.skipBody=!0);let i=new Zd(t),a=String(r.headers.connection??``).toLowerCase();i._keepAlive=r.httpVersionMinor>=1?a!==`close`:a===`keep-alive`,i.on(`finish`,()=>{i._keepAlive||e.end()}),this.emit(`request`,t,i)},onBody:e=>{t?.push(G.from(e))},onComplete:()=>{t&&(t.complete=!0,t.push(null)),t=null}});e.on(`data`,e=>n.execute(e)),e.on(`end`,()=>{n.finish(),t&&t.push(null)}),e.on(`error`,t=>this.emit(`clientError`,t,e))}},{apply:(e,t,n)=>new e(...n)}),tf=class{maxSockets;maxFreeSockets;keepAlive;options;constructor(e={}){this.options=e,this.keepAlive=!!e.keepAlive,this.maxSockets=e.maxSockets??1/0,this.maxFreeSockets=e.maxFreeSockets??256}getName(e={}){return`${e.host??`localhost`}:${e.port??``}:${e.localAddress??``}`}destroy(){}},nf=new tf,rf=(...e)=>{let{options:t,callback:n}=Qd(...e);return new $d(t,n)},af=(...e)=>{let t=rf(...e);return t.end(),t},of=(e,t)=>new ef(e,t),sf={METHODS:Ld,STATUS_CODES:Rd,Agent:tf,globalAgent:nf,Server:ef,ServerResponse:Zd,IncomingMessage:Yd,ClientRequest:$d,OutgoingMessage:Xd,createServer:of,request:rf,get:af},cf=async()=>{let e=()=>Po(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof Do))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},lf=`frame: this frame no longer holds the document the app attached it to`,uf=!1,df=()=>{uf||(uf=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},ff=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),pf=e=>typeof e?.reason==`string`?{reason:e.reason}:{},mf=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,hf=e=>{let{assertLive:t,attach:n,consent:r,current:i,declaredHosts:a,documentHost:o,freshBlank:s,session:c,approvedOrigins:l}=e,u=/* @__PURE__ */ new Set,d=()=>{try{return new URL(i()).hostname}catch{return``}},f=async()=>o?await o():d(),p=()=>R([...a,...ff(l)]),m=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:i,phase:o})=>{t();let h=I(e,i);if(h===null)return;let g=Nr(h);if(g===void 0||g===`auto`)return;if(e===`fetch`){let e=_s({session:c,declaredHosts:a,approvedOrigins:l},o===`ensure`?void 0:i[0],{classifier:`fetchTarget`});if(o===`ensure`&&!c)throw V(e.kind===`refuse`?e.reason:``,`fetch`);if(o!==`ensure`&&e.kind===`refuse`)throw V(e.reason,`fetch`);let{request:t,ensure:n}=await r();if(!t){if(e.kind===`refuse`)throw V(e.reason,`fetch`);if(!await n({scope:P(i[0],i[1]).scope,hosts:e.promptHosts}))throw V(`frame.fetch: the user did not grant this`,`fetch`);return}let s=e.kind===`consent`?e.targetHost:await f(),u=R([s,...a]);if(!u.length)throw V(`frame: navigate the frame before fetch`,`fetch`);if(await m(t,{category:`network`,hosts:u,...pf(zn(i))})===!1)throw V(mf(`fetch`,`network`,s||null),`fetch`);return}let _=await f();if(!_)throw V(`frame: navigate the frame before ${e}`,e);if(!p().includes(_))throw V(lf,e);let v=Pr(h);if(v===void 0||v===`evaluation`&&_===d()&&await s?.()||g===`critical`&&u.has(`${h} ${_}`))return;let{request:y}=await r();if(!y)return;let b=R([_,...a]),x=pf(zn(i)),S=g===`critical`?{key:h,hosts:b,attach:n,...x}:{category:v,hosts:b,...x},C=await m(y,S);if(C===!1)throw V(mf(e,v,null),e);if(C===`once`&&o!==`ensure`)for(let e of b)u.add(`${h} ${e}`)},requestCategories:async e=>{t(),Lr(`frame.requestPermissions`,e);let i=await f(),o=R(i?[i,...a]:a);if(!o.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let s=e.map(e=>{let t=e.key;return t===void 0?{named:void 0,critical:!1,category:e.category}:{named:t,critical:Nr(t)===`critical`,category:Mr(t)}}),c=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:o,allow:r}),{request:l}=await r();if(!l)return df(),s.map(e=>c(e,!1));let u=await l(s.map(({named:t,critical:r,category:i},a)=>{let s=pf(e[a]);return r?{key:t,hosts:o,attach:n,...s}:{category:i,hosts:o,...s}}));return s.map((e,t)=>c(e,u[t]!==void 0&&u[t]!==!1))},boundary:p}},gf=e=>e,_f=5e3,vf=/* @__PURE__ */ new Set([]),yf=()=>`https://fkn.app`,bf=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,xf=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(typeof n==`string`?new Gt(n):n()),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},Sf=e=>Object.assign(Error(e),{name:Lt}),Cf=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,wf=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,Tf=`frame.addScriptTag: no answer within ${Gr}ms; the script may or may not have run`,Ef=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,Df=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,Of=3e4,kf=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,Af=2e4,jf=async(e,t)=>{if(typeof e.seed!=`function`)throw Ht(kf,`storageState`,`cloud`);try{await xf(e.seed(t),Af,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw Kt(e)?Ht(kf,`storageState`,`cloud`):e}},Mf=`frame.clearCookies: the render proxy did not answer within ${Of}ms; the cookies may or may not be gone, and calling it again is safe`,Nf=e=>Kt(e)&&e.message===Ut(`addScriptTag`).message,Pf=!1,Ff=()=>{Pf||(Pf=!0,console.warn(`[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one.`))},If=({from:e,origin:t,attach:n,signal:r})=>i=>qi(window,`message`,r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))},{signal:r}),Lf=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},Rf=({control:e,target:t,blank:n=!1,session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,guard:c,consent:l,onNavigated:u,relay:d})=>{let f=t,p=n&&r!==``,m=async()=>{if(!p)return!1;let n=typeof e.blank==`function`?await c(()=>e.blank()):``;return(typeof n!=`string`||n.split(`#`)[0]!==t.split(`#`)[0])&&(p=!1),p},h=Promise.resolve(),{gate:g,requestCategories:_,boundary:v}=hf({session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,documentHost:typeof e.documentHost==`function`?()=>c(()=>e.documentHost()):void 0,current:()=>f,consent:Lf(l),freshBlank:m});return Tr({backend:`cloud`,executor:{execute:(t,n,r)=>vf.has(n)?Promise.reject(Ut(n,`cloud`)):(s(),c(()=>e.executeLocator(t,n,r))),highlight:async()=>{}},gate:g,requestPermissions:_,evaluate:async(t,n)=>(s(),await g({parts:[],operation:`evaluate`,args:[t],phase:`execute`}),xf(c(()=>e.executeLocator([],`evaluate`,[t,n])),Gr,qr)),addScriptTag:async(t,n)=>{s();let r=[t,n];await g({parts:[],operation:`addScriptTag`,args:r,phase:`execute`});try{await xf(c(()=>e.executeLocator([],`addScriptTag`,r)),Gr,Tf)}catch(e){throw Nf(e)?Ht(wf,`addScriptTag`,`cloud`):e}},clearCookies:async t=>{if(s(),typeof e.clearCookies!=`function`)throw Ht(Ef,`clearCookies`,`cloud`);if(v().length===0)throw V(Df,`clearCookies`);await xf(c(()=>e.clearCookies(t)),Of,Mf)},postMessage:(t,n,r)=>{if(s(),typeof e.messaging!=`function`)throw Ht(Cf,`postMessage`,`cloud`);if(n!==`*`&&!v().includes(new URL(n).hostname))throw V(lf,`postMessage`);let{port1:i,port2:a}=new MessageChannel;i.postMessage({data:t,transfer:r},r);let o=[a,n],l=h.then(async()=>(await g({parts:[],operation:`postMessage`,args:o,phase:`execute`}),{answer:c(()=>e.executeLocator([],`postMessage`,o))}));return h=l.catch(()=>{}),l.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&Ff(),d(t)),goto:async(t,{timeout:n,...r}={})=>{let i=new URL(t,location.href).href;s(),p=!1;let o=(()=>{try{return new URL(i).origin}catch{return``}})(),l=o!==``&&!a.has(o);l&&a.add(o);try{await xf(c(()=>e.goto(i,n===void 0?r:{...r,timeoutMs:n})),(n??3e4)+_f,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw l&&a.delete(o),Xr(e)}f=i,u()},url:()=>f})},zf=async e=>{if(e===void 0){let e=await Po(`a relay`).catch(()=>void 0);if(typeof e?.relay?.resolve!=`function`)return;let t=await e.relay.resolve().catch(()=>void 0);return t&&`id`in t?t.id:void 0}let t=await Po(`a relay choice`);es(t,`attachFrame`);let n=await t.relay.resolve(e);if(`refused`in n)throw Qo(`attachFrame: ${n.refused}`);return n.id},Bf=async(e,t)=>{if((typeof e.relay==`function`?await e.relay():``)!==t)throw Qo(`attachFrame: ${Go}`)},Vf=250,Hf=500,Uf=65e3,Wf=2e3,Gf=2e3,Kf=2,qf=2e3,Jf=2e3,Yf=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);return a.searchParams.set(`attach`,i),t&&a.searchParams.set(`url`,t),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.href},Xf=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);return r.searchParams.set(`attach`,t),n.src=r.href,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`style`,`display:none`),(document.body??document.documentElement).appendChild(n),n},Zf=(e,t)=>{let n=new MutationObserver(()=>{e.isConnected||t.aborted||(n.disconnect(),console.warn(`cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},Qf=()=>Sf(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),$f=()=>Sf(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),ep=()=>Sf(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),tp=()=>Sf(`cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window`),np=async(e,t,n)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:r=[],permissions:i,relay:a}=e,{url:o,width:c,height:l}=$r(e.window);if(window.origin===`null`)throw new pr(`opaque-opener`);let u=yf(),d=crypto.randomUUID(),f=bf(t),p=R(r),m=/* @__PURE__ */ new Set;o&&m.add(new URL(o).origin);let h=t===`persistent`?Xf(u,d):null,g=window.open(Yf({origin:u,target:n===void 0?o:``,session:f,domains:p,attach:d}),`_blank`,`popup,width=${c},height=${l}`);if(!g)throw h?.remove(),new dr;let _=new AbortController,v=!1,y=null,b=(e,t=!1)=>{if(y===null){y=e,_.abort(t?$f():Qf());try{g.closed||g.postMessage({type:zo.detach,attach:d,...t?{unanswered:t}:{}},u)}catch{}h&&setTimeout(()=>h.remove(),Jf)}};h&&Zf(h,_.signal);let x=new Promise((e,t)=>{_.signal.addEventListener(`abort`,()=>t(_.signal.reason),{once:!0})});x.catch(()=>{});let S=x.then(()=>{},()=>{}),C=()=>{if(_.signal.aborted)throw _.signal.reason},w=e=>_.signal.aborted?Promise.reject(_.signal.reason):Promise.race([e(),x]),T=e=>e.source===g&&e.origin===u;qi(window,`message`,e=>{let t=e.source===null&&e.origin===u;if(!T(e)&&!t)return;let n=e.data;typeof n==`object`&&n&&n.attach===d&&(n.type===zo.gone?b(v?Qf():ep()):n.type===zo.refused&&!t&&b(new pr(n.reason)))},{signal:_.signal}),qi(window,`pagehide`,()=>b(Qf()),{signal:_.signal});let E=zf(a),D,O,k=()=>{let e=()=>{try{g.postMessage({type:zo.hello,attach:d,...D?{relay:D}:{}},u)}catch{}};e(),O=setInterval(e,Vf)};a===void 0&&k();let A=setInterval(()=>{g.closed&&b(v?Qf():tp())},Hf);_.signal.addEventListener(`abort`,()=>{clearInterval(O),clearInterval(A)},{once:!0});let j=async e=>{try{return await Promise.race([e,x])}catch(e){throw y??e}};try{a!==void 0&&(D=await j(E),k());let e=await j(xf(s({},{key:Ro,transport:{emit:(e,t)=>g.postMessage(e,u,t??[]),receive:e=>qi(window,`message`,t=>{T(t)&&e(t.data,{source:t.source,origin:t.origin})})},unregisterSignal:_.signal,revivableModules:gf(Le)}),Bo,`cloud.attachFrame: timed out connecting to the window`));v=!0,clearInterval(O);let t=0,r=setInterval(()=>{xf(w(()=>e.ping()),Gf,`ping`).then(()=>{t=0},()=>{_.signal.aborted||(document.visibilityState===`hidden`?t=0:++t>=Kf&&b($f(),!0))})},Wf);_.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),D&&await j(xf(Bf(e,D),Uf,`cloud.attachFrame: the window never became ready`)),await j(xf(e.ready(),Uf,`cloud.attachFrame: the window never became ready`)),n!==void 0&&await j(jf(e,n)),Yo(`attached frame`,_.signal);let c=Rf({control:e,target:o,session:f,declaredHosts:p,approvedOrigins:m,attach:d,assertLive:C,guard:w,consent:{request:t=>w(()=>e.requestConsent(t)),ensure:t=>w(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:If({from:()=>g,origin:u,attach:d,signal:_.signal})}),l=null,h=Object.assign(c,{close:()=>l??=(async()=>{_.signal.aborted||await xf(Promise.allSettled([w(()=>e.flushCookies()),w(()=>e.sweepStorage())]),qf,`close`).catch(()=>{});try{g.close()}catch{}b(Qf())})(),closed:S});return D?ns(h,D):E.then(e=>ns(h,e)),n!==void 0&&o&&await j(h.goto(o)),i?.length&&await j(h.requestPermissions(i)),h}catch(e){let t=y??e;if(!(t instanceof pr))try{g.close()}catch{}throw b(t),t}},rp=2e4,ip=65e3,ap=e=>!e||e===`about:blank`,op=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,sp=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,cp=e=>e.split(`#`)[0]??``,lp=({iframe:e,lockdown:t,cookies:n,blank:r})=>{if(r===void 0)return``;if(typeof r!=`object`||!r)throw TypeError(`attachFrame: blank must be an object { url }`);let i=Object.keys(r).find(e=>e!==`url`);if(i!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${i}"`);let{url:a}=r,o=(()=>{try{return typeof a==`string`?new URL(a):null}catch{return null}})();if(!o||o.protocol!==`http:`&&o.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(a)}"`);let s=e.getAttribute(`src`)??``;if(!ap(s))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);if(t)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(n===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(ar(o.href),!bp())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return o.href},up=({target:e,blank:t,session:n,domains:r,attach:i,relay:a})=>{let o=new URL(`/attach-frame`,yf());return t?o.searchParams.set(`blank`,t):e&&o.searchParams.set(`url`,e),n&&o.searchParams.set(`session`,n),r.length&&o.searchParams.set(`domains`,r.join(`,`)),o.searchParams.set(`attach`,i),a&&o.searchParams.set(`relay`,a),o.href},dp=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{e.isConnected&&e.parentNode===r||(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},fp=()=>Sf(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),pp=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},mp=[300,1200,4e3],hp=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of mp)setTimeout(t,e)},gp=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},_p=async(e,t)=>{let n=typeof e.blank==`function`?await xf(e.blank(),ip,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof n!=`string`||cp(n)!==cp(t))throw Ht(op,`blank`,`cloud`)},vp=async(e,t,n)=>{let r=lp(e),{iframe:i,domains:a=[],permissions:o,relay:c}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!i.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);gp(i);let l=i.getAttribute(`src`)??``,u=(()=>{if(ap(l))return null;try{return new URL(i.src||l,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${l}`)}})();if(u){let e=new URL(`/attach-frame`,yf());if(u.origin===e.origin&&u.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let d=u?.href??``;d&&ar(d);let f=n===void 0?d:``,p=bf(t),m=R(a),h=/* @__PURE__ */ new Set;try{h.add(new URL(r||d).origin)}catch{}let g=zf(c),_=c===void 0?void 0:await g,v=new AbortController,y=i.referrerPolicy,b=i.allow,x=crypto.randomUUID();if(i.referrerPolicy=`origin`,i.allow=pp(Wi(),i.allow),i.src=up({target:f,blank:r,session:p,domains:m,attach:x,relay:_}),!i.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await xf(s({},{key:Lo,origin:yf(),transport:{receive:window,emit:i.contentWindow},unregisterSignal:v.signal,revivableModules:gf(Le)}),rp,`cloud.attachFrame: timed out connecting to the render proxy page`);_&&await xf(Bf(e,_),ip,`cloud.attachFrame: the render proxy never became ready`),await xf(e.ready(),ip,`cloud.attachFrame: the render proxy never became ready`),r&&await _p(e,r),n!==void 0&&await jf(e,n),(d||r)&&hp(i),dp(i,()=>v.abort()),Yo(`attached frame`,v.signal);let t=i.contentWindow,a=Rf({control:e,target:r||d,blank:r!==``,session:p,declaredHosts:m,approvedOrigins:h,attach:x,assertLive:()=>{if(v.signal.aborted||!i.isConnected||i.contentWindow!==t)throw v.abort(),fp()},guard:e=>e(),consent:cf,onNavigated:()=>hp(i),relay:If({from:()=>t,origin:yf(),attach:x,signal:v.signal})});return _?ns(a,_):g.then(e=>ns(a,e)),n!==void 0&&d&&await a.goto(d),o?.length&&await a.requestPermissions(o),a}catch(e){throw v.abort(),i.referrerPolicy=y,i.allow=b,i.src=f||`about:blank`,e}},yp=(async e=>{let{kind:t,cookies:n,storageState:r}=fi(e);if(n===`native`)throw TypeError(sp);return t===`window`?np(e,n,r):vp(e,n,r)}),bp=()=>typeof window<`u`&&!0,xp=async()=>{let e=await U.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},Sp=/* @__PURE__ */ g({attachFrame:()=>yp,available:()=>Cp,dgram:()=>Ed,dns:()=>vs,fetch:()=>ls,fs:()=>fl,http:()=>Fd,net:()=>yd,quota:()=>xp}),Cp=()=>Ji,wp=/* @__PURE__ */ g({info:()=>Dp,login:()=>Tp,logout:()=>Ep,onChange:()=>Op}),Tp=async()=>typeof window>`u`?!1:(await U).account.login(location.origin).catch(()=>!1),Ep=async()=>{typeof window<`u`&&await(await U).account.logout().catch(()=>{})},Dp=async()=>{if(typeof window>`u`)return null;let e=await U.then(e=>e.account.info()).catch(()=>null);return e?{name:e.name,image:e.image,premium:e.premium,premiumUntil:e.premiumUntil?Date.parse(e.premiumUntil):null}:null},Op=async e=>Ji?Ac(e):()=>{},kp=/* @__PURE__ */ g({available:()=>Np,list:()=>Lp,readFile:()=>Fp,remove:()=>Ip,writeFile:()=>Pp}),Ap=()=>navigator.storage.getDirectory(),jp=e=>{let t=e.split(`/`).filter(e=>e&&e!==`.`);if(t.some(e=>e===`..`)||!t.length)throw Error(`opfs: invalid path`);return t},Mp=async(e,t)=>{let n=await Ap();for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n},Np=async()=>{try{return typeof navigator<`u`&&!!navigator.storage?.getDirectory&&!!await Ap()}catch{return!1}},Pp=async(e,t,n)=>{let r=jp(e),i=r.pop(),a=await(await(await Mp(r,!0)).getFileHandle(i,{create:!0})).createWritable({keepExistingData:!1});try{let e=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);await a.write(e)}finally{await a.close()}},Fp=async e=>{let t=jp(e),n=t.pop();return(await(await Mp(t,!1)).getFileHandle(n)).getFile()},Ip=async e=>{let t=jp(e),n=t.pop();await(await Mp(t,!1)).removeEntry(n,{recursive:!0})},Lp=async()=>{let e=[],t=async(n,r)=>{for await(let[i,a]of n.entries()){let n=r?`${r}/${i}`:i;if(a.kind===`file`){let t=await a.getFile();e.push({path:n,size:t.size,contentType:t.type||null,updatedAt:new Date(t.lastModified).toISOString()})}else await t(a,n)}};return await t(await Ap(),``),e},Rp=/* @__PURE__ */ g({adopt:()=>Gm,adoptable:()=>qm,available:()=>Wp,captureAccount:()=>zp,list:()=>Dm,onConflict:()=>Pm,pending:()=>dm,pendingDeletes:()=>fm,pull:()=>Mm,readFile:()=>Om,readFileSealed:()=>km,remove:()=>jm,replicating:()=>pm,writeFile:()=>Am}),zp=Y,Bp,Vp=async()=>await(Bp??=Np().catch(()=>!1))?!0:(Bp=void 0,!1),Hp=()=>nl().catch(()=>`unknown`),Up=async()=>await Hp()===`connected`,Wp=async()=>await Vp()||await Up(),Gp=`fkn:fs:pending`,Kp=`fkn:fs:pending-delete`,qp=`fkn:fs:adopt-declined`,Jp=!0,Yp=/* @__PURE__ */ new Map,Xp=null,Zp=(e,t)=>{if(e===null)return!1;if(`generation`in e&&`generation`in t)return e.generation===t.generation;let n=e=>`pin`in e?e.pin:Kc(e),r=n(e);return r!==void 0&&r===n(t)},Qp=(e,t)=>Zp(Xp,t)?Yp.get(e)??null:null,$p=e=>e===`write`?Gp:Kp,em=e=>{try{let t=localStorage.getItem($p(e));if(!t)return{};let n=JSON.parse(t);if(Array.isArray(n))return Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,{base:null,pin:null}]));if(!n||typeof n!=`object`)return{};let r={};for(let[e,t]of Object.entries(n))if(t===null||typeof t==`string`)r[e]={base:t,pin:null};else if(typeof t==`object`){let{base:n,pin:i}=t;r[e]={base:typeof n==`string`?n:null,pin:typeof i==`string`&&i?i:null}}return r}catch{return{}}},tm=(e,t)=>{try{Object.keys(t).length?localStorage.setItem($p(e),JSON.stringify(t)):localStorage.removeItem($p(e))}catch{}},nm=()=>{try{let e=JSON.parse(localStorage.getItem(qp)??`{}`);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}},rm=/* @__PURE__ */ new Map,im=e=>`pin`in e?e.pin:Kc(e)??null,am=(e,t,n,r)=>{let i=em(e),a=i[t],o=im(r);a&&o!==null&&a.pin===o||(i[t]={base:a?a.base:n,pin:o},tm(e,i),o===null&&`generation`in r?rm.set(`${e}:${t}`,r):rm.delete(`${e}:${t}`))},om=(e,t)=>{rm.delete(`${e}:${t}`);let n=em(e);t in n&&(delete n[t],tm(e,n),ym()||(Sm=bm))},sm=(e,t,n)=>am(`write`,e,t,n),cm=e=>om(`write`,e),lm=(e,t)=>am(`delete`,e,Qp(e,t),t),um=e=>om(`delete`,e),dm=()=>Object.keys(em(`write`)),fm=()=>Object.keys(em(`delete`)),pm=()=>Jp,mm=/* @__PURE__ */ new Map,hm=e=>mm.get(e)===Y().generation,gm=(e,t,n)=>n.pin===null&&!rm.has(`${e}:${t}`),_m=null,vm=!1;Xo(`storage replication`,()=>_m!==null||Xm!==null);var ym=()=>[`write`,`delete`].some(e=>Object.entries(em(e)).some(([t,n])=>n.pin===null?!gm(e,t,n):!hm(n.pin))),bm=6e4,xm=6e5,Sm=bm,Cm=null,wm=()=>{!Cm&&typeof window<`u`&&ym()&&(Cm=setTimeout(()=>{Cm=null,Tm()},Sm),Sm=Math.min(Sm*2,xm))},Tm=()=>{_m?vm=!0:ym()&&(_m=Hm(!1,Y()).then(e=>{ym()?e.failed.length&&wm():Sm=bm}).catch(()=>{wm()}).finally(()=>{_m=null,Em()}))},Em=()=>{vm&&(vm=!1,Tm())},Dm=async e=>{let t=e?.pin??Y();rh();let n=await Hp(),r=n===`connected`,[i,a]=await Promise.all([Vp().then(e=>e?Lp():[]).catch(()=>[]),r?rl({pin:t}).then(e=>({ok:!0,entries:e}),e=>({ok:!1,entries:[],changed:Rc(e)?e:void 0})):Promise.resolve({ok:n===`disconnected`,entries:[]})]);if(n!==`unknown`&&(Jp=a.ok),a.ok&&n!==`unknown`&&(Yp=new Map(a.entries.map(e=>[e.path,e.updatedAt])),Xp=t),a.changed)throw a.changed;let o=/* @__PURE__ */ new Map,s=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},c=e=>{let t=o.get(e.path);(!t||s(e)>=s(t))&&o.set(e.path,e)};for(let e of i)c(e);for(let e of a.entries)c(e);return a.ok&&r&&(th(i,a.entries).catch(()=>{}),ym()?Tm():Qm({local:i,remote:a.entries,from:t}).catch(()=>{})),[...o.values()]},Om=async(e,t)=>{let n=t?.pin??Y();if(await Vp())try{return await Fp(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await al(e,{pin:n});return await Vp()&&Pp(e,r).catch(()=>{}),r},km=async(e,t)=>{let n=t?.pin??Y();if(await Vp())try{let t=await Fp(e);return{data:new Uint8Array(await t.arrayBuffer()),sealedAt:null}}catch(e){if(e?.name!==`NotFoundError`)throw e}return sl(e,{pin:n})},Am=async(e,t,n)=>{let r=n?.pin??Y(),i=n?.contentType,a=i?{contentType:i}:void 0,o=t instanceof Blob?t:new Blob([t],a?{type:a.contentType}:void 0);if(await Vp()){await Pp(e,o,a),rh();let t=Qp(e,r),n=await Hp();if(n===`disconnected`)return;if(n===`unknown`||!Jp){sm(e,t,r),wm();return}cl(e,o,{...a,pin:r}).then(()=>cm(e)).catch(n=>{sm(e,t,r),Rc(n)||wm(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let s=await Hp();if(s===`connected`)return cl(e,o,{...a,pin:r});throw Error(s===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},jm=async(e,t)=>{let n=t?.pin??Y();rh();let r=[];await Vp()&&r.push(Ip(e).catch(()=>{}));let i=await Hp();if(i===`connected`?r.push(ll(e,{pin:n}).then(()=>um(e)).catch(t=>{lm(e,n),Rc(t)||wm(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):i===`unknown`&&r.length&&Qp(e,n)!==null&&(lm(e,n),wm()),!r.length)throw Error(i===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);cm(e),await Promise.all(r)},Mm=async e=>{let t=await al(e,{pin:Y()});return await Vp()&&await Pp(e,t),t},Nm=null,Pm=e=>(Nm=e,()=>{Nm===e&&(Nm=null)}),Fm=async e=>{let t=await(await U).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null);return t===`local`?e.readLocal():t===`cloud`?e.readCloud():null},Im=async e=>{if(Nm)try{return await Nm(e)}catch{return null}return Fm(e)},Lm=class extends Error{},Rm=e=>e instanceof Error?e.message:String(e),zm=()=>{let e=/* @__PURE__ */ new Map,t=t=>{let n=e.get(t);return n||e.set(t,n={writes:/* @__PURE__ */ new Map,deletes:/* @__PURE__ */ new Map}),n};for(let[e,n]of Object.entries(em(`write`)))t(n.pin).writes.set(e,n.base);for(let[e,n]of Object.entries(em(`delete`)))t(n.pin).deletes.set(e,n.base);return e},Bm=async()=>{for(let[e,t]of[...rm]){let n=e.startsWith(`write:`)?`write`:`delete`,r=e.slice(n.length+1),i;try{i=await qc(t)}catch(t){Rc(t)&&rm.delete(e);continue}if(rm.get(e)!==t)continue;rm.delete(e);let a=em(n),o=a[r];o&&o.pin===null&&(a[r]={base:o.base,pin:i},tm(n,a))}},Vm=async(e,t,n,r,i,a)=>{let o=new Map(t.map(e=>[e.path,e])),s=e=>{if(Rc(e))throw new Lm};for(let[t,a]of e.deletes){let e=o.get(t);if(!e)um(t);else if(r.some(e=>e.path===t))um(t);else if(e.updatedAt!==a)um(t);else try{await ll(t,n),um(t),i.deleted.push(t)}catch(e){s(e),i.failed.push({path:t,error:Rm(e)})}}for(let t of r){let r=o.get(t.path),c=e.writes.has(t.path);if(!c){if(!a(t))continue;if(r){i.kept.push(t.path);continue}}let l=e.writes.get(t.path)??null;if(c&&r&&r.updatedAt!==l){let e=null,a=null,o=await Im({path:t.path,local:{size:t.size,updatedAt:t.updatedAt},cloud:{size:r.size,updatedAt:r.updatedAt},readLocal:()=>e??=Fp(t.path),readCloud:()=>a??=al(t.path,n)});if(o==null){i.unresolved.push(t.path);continue}try{let r=e!==null&&o===await e,s=a!==null&&o===await a;s||await cl(t.path,o,t.contentType?{contentType:t.contentType,...n}:n),r||await Pp(t.path,o),cm(t.path),i.resolved.push({path:t.path,choice:r?`local`:s?`cloud`:`merged`})}catch(e){if(s(e),e?.code===`FKN_E2E_LOCKED`)throw e;i.failed.push({path:t.path,error:Rm(e)})}}else try{let e=await Fp(t.path);await cl(t.path,e,t.contentType?{contentType:t.contentType,...n}:n),cm(t.path),i.uploaded.push(t.path)}catch(e){if(c||sm(t.path,r?.updatedAt??null,n.pin),s(e),e?.code===`FKN_E2E_LOCKED`)throw e;i.failed.push({path:t.path,error:Rm(e)})}}},Hm=async(e,t)=>{let n={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},r=await Hp();if(r===`unknown`)throw Error(`fs: cloud unreachable`);if(r!==`connected`)throw Error(`fs: this needs a signed-in account`);let i=await Vp(),a=i?await Lp():[];if(i)for(let e of Object.keys(em(`write`)))a.some(t=>t.path===e)||cm(e);await Bm();for(let[e,r]of zm()){if(e===null||hm(e))continue;let i={pin:{pin:e}},o;try{o=await rl(i)}catch(n){if(Rc(n)){mm.set(e,t.generation);continue}if(zc(n)){Um(e);continue}throw n}try{await Vm(r,o,i,a,n,()=>!1)}catch(n){if(!(n instanceof Lm))throw n;mm.set(e,t.generation)}}if(e){let e={pin:t},r=await rl(e),i=em(`write`),o=zm().get(null)??{writes:/* @__PURE__ */ new Map,deletes:/* @__PURE__ */ new Map},s=/* @__PURE__ */ new Set([...n.uploaded,...n.resolved.map(({path:e})=>e),...n.unresolved,...n.failed.map(({path:e})=>e)]),c=e=>!(e.path in i)&&!s.has(e.path);try{await Vm(o,r,e,a,n,c)}catch(e){throw e instanceof Lm?new Ic:e}}return n},Um=e=>{for(let t of[`write`,`delete`]){let n=em(t),r=!1;for(let t of Object.values(n))t.pin===e&&(t.pin=null,r=!0);r&&tm(t,n)}},Wm=async e=>{for(;_m;)await _m;let t=Hm(!0,e);_m=t.then(()=>{},()=>{});try{return await t}finally{_m=null,Em()}},Gm=()=>Wm(Y()),Km=(e,t)=>{let n=new Set(t.map(e=>e.path)),r=em(`write`);return e.filter(e=>{let t=r[e.path];return t?gm(`write`,e.path,t):!n.has(e.path)})},qm=async()=>{let e=Y();if(!await Up()||!await Vp())return{paths:[],bytes:0};let[t,n]=await Promise.all([Lp(),rl({pin:e})]),r=Km(t,n);return{paths:r.map(e=>e.path),bytes:r.reduce((e,t)=>e+t.size,0)}},Jm=()=>new Set(Object.keys(nm())),Ym=e=>{let t=nm();for(let n of e)t[n]=null;try{localStorage.setItem(qp,JSON.stringify(t))}catch{}},Xm=null,Zm=!1,Qm=e=>{if(Xm)return Zm=!0,Xm;let t=e?.from??Y();return Xm=(async()=>{if(!await Up())return;let n=e??(await Vp()?{local:await Lp(),remote:await rl({pin:t})}:null);if(!n)return;let r=Jm(),i=Km(n.local,n.remote).filter(e=>!r.has(e.path));if(!i.length)return;let a=await U,o=i.reduce((e,t)=>e+t.size,0);await a.cloud.fs.promptAdopt({files:i.length,bytes:o}).catch(()=>!1)?`generation`in t&&await Wm(t):Ym(i.map(e=>e.path))})().catch(()=>{}).finally(()=>{Xm=null,Zm&&(Zm=!1,Qm())}),Xm},$m=null,eh=!1,th=async(e,t)=>{let n=Km(e,t),r=await U,i=async()=>{await Gm().catch(()=>{});let e=await qm().catch(()=>({paths:[],bytes:0}));await r.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},i).catch(()=>{})},a={files:n.length,bytes:n.reduce((e,t)=>e+t.size,0)};$m=()=>{r.cloud.fs.setAdoptSource(a,i).catch(()=>{})},eh||(eh=!0,Fo((e,t)=>{t>1&&$m?.()})),await r.cloud.fs.setAdoptSource(a,i)},nh=!1,rh=()=>{nh||typeof window>`u`||(nh=!0,qi(window,`online`,()=>{Tm()}),Op(()=>{Qm().catch(()=>{}),Tm()}).catch(()=>{}))},ih=gc(Rp,{memfs:!0}),{available:ah,readFileSync:oh,writeFileSync:sh,appendFileSync:ch,existsSync:lh,statSync:uh,lstatSync:dh,readdirSync:fh,mkdirSync:ph,rmSync:mh,rmdirSync:hh,unlinkSync:gh,renameSync:_h,readFile:vh,writeFile:yh,appendFile:bh,stat:xh,readdir:Sh,mkdir:Ch,rm:wh,unlink:Th,rename:Eh,exists:Dh,promises:Oh,mount:kh,flush:Ah,remount:jh}=ih;({...ih});var{available:Mh,readFileSync:Nh,writeFileSync:Ph,appendFileSync:Fh,existsSync:Ih,statSync:Lh,lstatSync:Rh,readdirSync:zh,mkdirSync:Bh,rmSync:Vh,rmdirSync:Hh,unlinkSync:Uh,renameSync:Wh,readFile:Gh,writeFile:Kh,appendFile:qh,stat:Jh,readdir:Yh,mkdir:Xh,rm:Zh,unlink:Qh,rename:$h,exists:eg,promises:tg,mount:ng,flush:rg,remount:ig}=gc(kp,{memfs:!0}),ag=/* @__PURE__ */ g({attach:()=>Ng,connect:()=>Dg,hide:()=>Eg,install:()=>mg,isVisible:()=>qg,list:()=>gg,mount:()=>Mg,onConnect:()=>Kg,onVisibilityChange:()=>Jg,pick:()=>pg,search:()=>fg,show:()=>Tg,supportsTemporary:()=>hg,uninstall:()=>_g}),og=`fkn-packages-connection`,sg=`https://fkn.app`,cg=3e4,X=(e,t)=>Object.assign(Error(t),{code:e}),lg=async()=>{if(!Ji)throw X(`unavailable`,`packages: no FKN transport in this realm - use relayWorker to bridge workers`);return U},ug=(e,t,n)=>s(e??{},{transport:t,key:og,unregisterSignal:n}),dg=async(e,t,n={})=>{let{signal:r,closed:i}=n;if(r?.aborted)throw X(`unavailable`,`packages.connect: aborted before connecting`);let a=new AbortController;r&&r.addEventListener(`abort`,()=>a.abort(r.reason),{once:!0});let o=new AbortController,s=new Promise((e,n)=>{let a=setTimeout(()=>n(X(`timeout`,`packages.connect: the package did not complete the connection`)),cg);o.signal.addEventListener(`abort`,()=>clearTimeout(a),{once:!0}),t.addEventListener(`message`,e=>{if(e.data?.type===`fkn-packages-nack`){let t=e.data.message;n(X(`unavailable`,typeof t==`string`&&t?t:`packages.connect: the package refused the connection`))}},{signal:o.signal}),t.start(),r&&r.addEventListener(`abort`,()=>n(X(`unavailable`,`packages.connect: aborted before connecting`)),{once:!0,signal:o.signal}),i?.then(()=>n(X(`unavailable`,`packages.connect: the package closed before connecting`)))});try{return await Promise.race([ug(e,t,a.signal),s])}catch(e){a.abort(e);try{t.close()}catch{}throw e}finally{o.abort()}},fg=async e=>{let t=await(await lg()).packages.search(e);if(`error`in t)throw X(t.error,t.message);return t.results},pg=async(e,t)=>{let n=await(await lg()).packages.pick(e,t);if(`error`in n)throw X(n.error,n.message);return`declined`in n?[]:n.results},mg=async(e,t)=>{let{packages:n}=await lg(),r=t?.temporary?n.installTemporary:n.install;if(!r)throw X(`unsupported`,`packages.install: this fkn.app cannot install a package temporarily`);let i=await r(e,t);if(`error`in i)throw X(i.error,i.message);return`declined`in i?null:i.installed},hg=async()=>typeof(await lg()).packages.installTemporary==`function`,gg=async()=>(await(await lg()).packages.list()).results,_g=async e=>{let t=await(await lg()).packages.uninstall(e);if(`error`in t)throw X(t.error,t.message)},vg=({x:e,y:t,width:n,height:r})=>({x:Math.round(e),y:Math.round(t),width:Math.round(n),height:Math.round(r)}),yg=(e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,width:Math.max(0,Math.min(e.x+e.width,t.x+t.width)-n),height:Math.max(0,Math.min(e.y+e.height,t.y+t.height)-r)}},bg=(e,t)=>{let n=t;for(let t=e.parentElement;t;t=t.parentElement){let e=getComputedStyle(t);if((e.overflowX!==`visible`||e.overflowY!==`visible`)&&(n=yg(n,vg(t.getBoundingClientRect())),n.width===0||n.height===0))break}return n},xg=e=>{let t=getComputedStyle(e),n=[t.borderTopLeftRadius,t.borderTopRightRadius,t.borderBottomRightRadius,t.borderBottomLeftRadius];if(n.some(e=>e.includes(`%`)||e.includes(` `)))return;let r=n.map(e=>{let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:0});return r.some(e=>e>0)?r:void 0},Sg=(e,t)=>{if(!e)return!1;let n=(e,t)=>e===t||!!e&&!!t&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;return n(e.rect,t.rect)&&n(e.clip,t.clip)&&((e,t)=>e===t||!!e&&!!t&&e.every((e,n)=>e===t[n]))(e.radius,t.radius)},Cg=/* @__PURE__ */ new Map;Xo(`package view`,()=>Cg.size>0);var wg=async(e,t)=>{let n=Cg.get(e);if(n){for(let e of n)t&&e.element!==t||(e.stop(),n.delete(e));if(n.size>0)return;Cg.delete(e)}let r=await(await lg()).packages.hide(e);if(`error`in r)throw X(r.error,r.message)},Tg=async(e,t)=>{let{element:n,rect:r}=t;if(!n&&!r)throw X(`invalid`,`packages.show: pass an element or a rect`);let i=(await lg()).packages,a=()=>{if(!n)return{rect:vg(r)};let e=vg(n.getBoundingClientRect());return{rect:e,clip:bg(n,e),radius:xg(n)}},o=!0,s,c=0,l=async t=>{s=t;let n=await i.show(e,t);if(`error`in n)throw o=!1,X(n.error,n.message)};await l(a());let u=()=>{if(!o)return;let e=a();Sg(s,e)||l(e).catch(()=>{}),c=requestAnimationFrame(u)};n&&(c=requestAnimationFrame(u));let d={element:n,stop:()=>{o=!1,cancelAnimationFrame(c)}},f=Cg.get(e)??/* @__PURE__ */ new Set;return f.add(d),Cg.set(e,f),{hide:()=>{wg(e,n).catch(()=>{})},refresh:()=>{if(!o)return;let e=a();Sg(s,e)||l(e).catch(()=>{})}}},Eg=async(e,t={})=>wg(e,t.element),Dg=(async(e,t={})=>{let n=await(await lg()).packages.connect(e,{protocol:t.protocol,...t.path===void 0?{}:{path:t.path}});if(`error`in n)throw X(n.error,n.message);let r=Jo(`package connection`),i=Io()?.epoch??0,a=Fo((e,t)=>{t!==i&&(r(),a())});Promise.resolve(n.closed).then(()=>{r(),a()},()=>{r(),a()});let{port:o,closed:s}=n;if(t.raw)return{closed:s,port:o};let c=await dg(t.payload,o,{signal:t.signal,closed:s});return t.signal&&t.signal.addEventListener(`abort`,()=>{try{o.postMessage({type:`fkn-packages-disconnect`})}catch{}},{once:!0}),{remote:c,closed:s,port:o}}),Og=[`allow-scripts`,`allow-same-origin`],kg=e=>{let t=e.getAttribute(`sandbox`);if(t!==null){let e=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),n=Og.filter(t=>!e.has(t));if(n.length)throw X(`invalid`,`packages.mount: the iframe's sandbox attribute must include ${n.join(` and `)}, or the package cannot start`)}if(globalThis.crossOriginIsolated&&!new Set((e.getAttribute(`allow`)??``).toLowerCase().split(`;`).map(e=>e.trim().split(/\s+/)[0]).filter(Boolean)).has(`cross-origin-isolated`))throw X(`invalid`,`packages.mount: this page is cross-origin isolated, so the iframe's allow attribute must include 'cross-origin-isolated' to hand that down to the package`)},Ag=3e4,jg=(e,t)=>new Promise((n,r)=>{let i=e=>{clearTimeout(o),window.removeEventListener(`message`,a),e?r(e):n()},a=n=>{if(n.source!==e.contentWindow||n.origin!==t)return;let r=n.data;if(r?.type===`fkn-packages-ready`)return i();r?.type===`fkn-packages-failed`&&i(X(`unavailable`,typeof r.message==`string`&&r.message?r.message:`packages.mount: the package failed to boot`))},o=setTimeout(()=>i(X(`timeout`,`packages.mount: the package did not register a connection handler`)),Ag);window.addEventListener(`message`,a)}),Mg=async(e,t)=>{let{iframe:n}=t;if(!(n instanceof HTMLIFrameElement))throw X(`invalid`,`packages.mount: pass the iframe to load the package into`);if(!n.isConnected)throw X(`invalid`,`packages.mount: the iframe must be in the document before mounting into it`);kg(n);let r=await(await lg()).packages.frame(e);if(`error`in r)throw X(r.error,r.message);n.src=r.url;let i=new AbortController;n.addEventListener(`load`,()=>{try{n.contentWindow?.postMessage({type:`fkn-packages-mount`},r.origin)}catch{}},{signal:i.signal});let a={done:!1},o=()=>{},s=new Promise(e=>{o=e}),c=Jo(`mounted package`),l=()=>{if(a.done)return;a.done=!0,i.abort(),c();try{n.contentWindow?.postMessage({type:`fkn-packages-close`},r.origin)}catch{}let e=()=>{try{if(n.contentWindow?.location.href!==`about:blank`)return;n.contentWindow.name=``}catch{return}n.removeEventListener(`load`,e)};n.addEventListener(`load`,e),n.src=`about:blank`,o()};try{await jg(n,r.origin)}catch(e){throw l(),e}let u=new MessageChannel,d=n.contentWindow;if(!d)throw l(),X(`unavailable`,`packages.mount: the frame was detached before it could connect`);d.postMessage({type:`fkn-packages-port`,from:r.from,protocol:t.protocol,uri:r.uri,name:r.name,version:r.version},r.origin,[u.port2]);try{d.postMessage({type:`fkn-packages-visibility`,visible:!0},r.origin)}catch{}if(t.raw)return{closed:s,port:u.port1,frame:n,unmount:l};try{return{remote:await dg(t.payload,u.port1,{signal:t.signal,closed:s}),closed:s,port:u.port1,frame:n,unmount:l}}catch(e){throw l(),e}},Ng=(e,t,n)=>dg(t,e,{signal:n?.signal}),Pg=null,Fg=!1,Ig=/* @__PURE__ */ new Set,Lg=[],Rg=/* @__PURE__ */ new Map,zg=!1,Bg=!1,Vg=e=>{let t=Rg.get(e);t&&(Rg.delete(e),t())},Hg=(e,t)=>{try{e.postMessage({type:`fkn-packages-nack`,message:t})}catch{}try{e.close()}catch{}},Ug=async(e,t)=>{let{port:n,...r}=e;e.port.addEventListener(`message`,t=>{t.data?.type===`fkn-packages-disconnect`&&Vg(e.port)});let i;try{i=await t.createPayload(r)}catch(t){throw Hg(e.port,t instanceof Error?t.message:`the package failed to produce a connection`),t}let a=new Promise(t=>Rg.set(e.port,t)),o=await ug(i,e.port);t.handler?.({...r,remote:o,closed:a,port:e.port})},Wg=()=>{zg||typeof window>`u`||window.parent===window||(zg=!0,qi(window,`message`,e=>{if(e.source!==window.parent)return;let t=e.data;if(t?.type===`fkn-packages-port`){let n=e.ports[0];if(!n)return;let r={port:n,from:typeof t.from==`string`?t.from:``,brokered:e.origin===sg,protocol:typeof t.protocol==`string`?t.protocol:null,uri:typeof t.uri==`string`?t.uri:``,name:typeof t.name==`string`?t.name:``,version:typeof t.version==`string`?t.version:``};Pg?Ug(r,Pg).catch(e=>console.warn(`packages.onConnect:`,e)):Lg.push(r)}if(t?.type===`fkn-packages-close`)for(let e of[...Rg.keys()])Vg(e);if(t?.type===`fkn-packages-visibility`){Fg=t.visible===!0;for(let e of Ig)try{e(Fg)}catch{}}}))},Gg=()=>{Bg||typeof window>`u`||window.parent===window||(Bg=!0,window.parent.postMessage({type:`fkn-packages-ready`},`*`))},Kg=(e,t)=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Wg();let n={createPayload:e,handler:t};for(Pg=n,Gg();Lg.length&&Pg===n;)Ug(Lg.shift(),n).catch(e=>console.warn(`packages.onConnect:`,e));return{unsubscribe:()=>{Pg===n&&(Pg=null)}}},qg=()=>Fg,Jg=e=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Wg(),Ig.add(e);try{e(Fg)}catch{}return{unsubscribe:()=>{Ig.delete(e)}}},Yg=/* @__PURE__ */ g({available:()=>m_,create:()=>__,join:()=>v_,open:()=>g_}),Z={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,notClaimingApp:`rooms: only the app that claimed the room can change it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,mailboxUnavailable:`rooms: the mailbox switch is not available`,guestUnavailable:`rooms: guest joins are not available`,schemasUnavailable:`rooms: room schemas are not available`,bytesUnavailable:`rooms: binary messages are not available`,badSchema:`rooms: the schema is not one a room can take`,newerSchema:`rooms: the room holds a newer schema`,noSchema:`rooms: the room has no schema`,misfit:`rooms: the message does not fit the room's schema`,ownerSends:`rooms: only the owner sends this type`,accountSends:`rooms: sending this needs an account`,perAccount:`rooms: you have as many of these here as the room allows`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},Q=(e,t)=>Object.assign(Error(t),{code:e}),Xg=e=>e instanceof Error&&typeof e.code==`string`,Zg={send:!0,receive:!0,maxMessageBytes:262144},Qg=2048,$g=()=>({messages:0,bytes:0,cap:5e8,archived:!1}),e_=async()=>{if(!Ji)return;let e=(await Po(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},t_=()=>{throw Q(`unavailable`,Z.unavailable)},n_=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,r_=e=>{if(e!==void 0&&e!==!1)return e===!0?Vo.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=Vo.min&&e<=Vo.max?e:null},i_=(e,t)=>{let n=t?e?.guest:e;return typeof n?.join==`function`?n:void 0},a_=e=>{let t;try{t=JSON.stringify(e)}catch{}let n=t===void 0?void 0:JSON.parse(t),r=typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.type==`string`;if(t===void 0||!r||t.length>Qg)throw Q(`invalid`,Z.misfit);return t},o_=e=>{let t;try{t=JSON.parse(JSON.stringify(e))}catch{}if(typeof t!=`object`||!t||Array.isArray(t))throw Q(`invalid`,Z.badSchema);return t},s_=e=>e?.schema===void 0?e:{...e,schema:o_(e.schema)},c_=e=>{if(e.schemas!==!0)throw Q(`unavailable`,Z.schemasUnavailable);return e},l_=e=>{if(e.bytes!==!0)throw Q(`unavailable`,Z.bytesUnavailable);return e},u_=e=>{if(typeof e==`string`)return e;try{return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice():(Reflect.get(ArrayBuffer.prototype,`byteLength`,e),new Uint8Array(e).slice())}catch{throw Q(`invalid`,Z.malformed)}},d_=(e,t,n)=>{let r=typeof t==`string`?e:l_(e);return n===void 0?r:c_(r)},f_=e=>{let t=e?.guest;if(t!==void 0&&typeof t!=`boolean`)throw Q(`invalid`,Z.malformed);return t===!0},p_=async(e,t)=>{let n=e.invite,r=e,i=0,a=e.self,o=e.owner,s=e.claimed,c=e.mailbox,l=0,u=await e.defaults().catch(()=>Zg),d=e.schemas===!0?await Promise.resolve(e.schema()).catch(()=>null):null,f=0,p=!1,m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=Jo(`room`),_=()=>{},v=()=>{},y=new Promise(e=>{v=e}),b=e=>{let t=[...h];h.clear();for(let n of t)try{n(e)}catch{}},x=e=>{p||(p=!0,_(),m.clear(),g(),b(Q(`closed`,Z.ended)),v({reason:e}))},S=e=>{if(p)return;let t=e;if(t.type===`defaults`&&(u=t.defaults),t.type===`schema`&&(f+=1,d=t.schema),t.type===`message`||t.type===`edited`){let e={...t.message,envelope:t.message.envelope??null};t=t.type===`message`?{...t,message:e}:{type:`edited`,message:e}}if(t.type===`permissions`&&t.id===a.id&&(a={id:a.id,permissions:t.permissions,maxMessageBytes:t.maxMessageBytes}),t.type===`claim`){l+=1;let e=t.claimed&&t.mailbox!==!1;t={type:`claim`,claimed:t.claimed,owner:t.owner,mailbox:e},s=t.claimed,o=t.owner,c=e?$g():null}for(let e of[...m])try{e(t)}catch{}},C=(e,t)=>{Promise.resolve(e.on(S)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===i&&x(e.reason)},()=>{})},w=async(e,l)=>{let f=i_(e,t);if(!f)return x(`unavailable`);let m=await f.join(n).catch(()=>void 0);if(p||l!==i)return;if(!m)return x(`unavailable`);if(`error`in m)return x(n_(m.error));if(m.self.id!==a.id)return Promise.resolve(m.leave()).catch(()=>{}),x(`unavailable`);r=m,a=m.self,o=m.owner,s=m.claimed,c=m.mailbox,C(m,l);let h=await m.defaults().catch(()=>void 0);if(h&&!p&&l===i&&(u=h),m.schemas!==!0)return;let g=await Promise.resolve(m.schema()).catch(()=>void 0);g!==void 0&&!p&&l===i&&(d=g)};_=Fo((e,t)=>{let n=i;i=t,!(p||n===0||n===t)&&(b(Q(`unavailable`,Z.unavailable)),w(e.rooms,t))}),C(e,i);let T=async e=>{if(p)throw Q(`closed`,Z.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});h.add(t);try{return await Promise.race([Promise.resolve(e(r)),n])}catch(e){throw Xg(e)?e:Q(`unavailable`,Z.unavailable)}finally{h.delete(t)}},E=async e=>{let t=await T(e);if(`error`in t)throw Q(t.error,t.message)},D=async e=>{let t=await T(e);if(typeof t==`object`&&t&&`error`in t)throw Q(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:n,get self(){return a},get owner(){return o},get claimed(){return s},get mailbox(){return c},defaults:()=>u,members:()=>T(e=>e.members()),schema:()=>d,send:async(e,t)=>{let n=u_(e);if(t===void 0)return E(e=>d_(e,n,void 0).send(n));let r=a_(t);return E(e=>d_(e,n,r).send(n,r))},edit:async(e,t,n)=>{let r=u_(t);if(n===void 0)return E(t=>d_(t,r,void 0).edit(e,r));let i=a_(n);return E(t=>d_(t,r,i).edit(e,r,i))},setSchema:async e=>{let t=o_(e),n=f;await E(e=>c_(e).setSchema(t)),f===n&&(d=t)},delete:(e,t)=>E(n=>n.delete(e,t)),backlog:(e,t)=>D(n=>n.backlog(e,t)),setDefault:(e,t)=>E(n=>n.setDefault(e,t)),limit:(e,t)=>E(n=>n.limit(e,t)),grant:(e,t)=>E(n=>n.grant(e,t)),revoke:(e,t)=>E(n=>n.revoke(e,t)),remove:e=>E(t=>t.remove(e)),block:e=>E(t=>t.block(e)),unblock:e=>E(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw Q(`invalid`,Z.badDescription);let n=r_(e?.temporary);if(n===null)throw Q(`invalid`,Z.badTemporary);let r=e?.mailbox;if(r!==void 0&&typeof r!=`boolean`)throw Q(`invalid`,Z.malformed);let i={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n},...r===void 0?{}:{mailbox:r}};return Object.keys(i).length===0?E(e=>e.claim()):E(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw Q(`unavailable`,Z.temporaryUnavailable);if(r===!1&&e.mailboxSwitch!==!0)throw Q(`unavailable`,Z.mailboxUnavailable);return e.claim(i)})},setMailbox:async e=>{if(typeof e!=`boolean`)throw Q(`invalid`,Z.malformed);let t=l;await E(t=>{if(t.mailboxSwitch!==!0)throw Q(`unavailable`,Z.mailboxUnavailable);return t.setMailbox(e)}),l===t&&(e?c===null&&(c=$g()):c=null)},release:()=>E(e=>e.release()),usage:async()=>{let e=await D(e=>e.usage());return c=e,e},on:async e=>p?()=>{}:(m.add(e),()=>{m.delete(e)}),leave:async()=>{await Promise.resolve(r.leave()).catch(()=>{}),x(`left`)},closed:y}},m_=async()=>{let e=await e_();return e?e.available().catch(()=>!1):!1},h_=async(e,t,n)=>{let r=await e_();if(!r)throw Q(`unavailable`,Z.unavailable);let i=i_(r,e);if(!i)throw Q(`unavailable`,Z.guestUnavailable);let a=await n(i).catch(t_);if(`error`in a)throw Q(a.error,a.message);if(t?.schema!==void 0&&a.schemas!==!0)throw await Promise.resolve(a.leave()).catch(()=>{}),Q(`unavailable`,Z.schemasUnavailable);return p_(a,e)},g_=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw Q(`invalid`,Z.badName);let n=f_(t),r=s_(t);return h_(n,r,t=>t.open(e,r))},__=async e=>{let t=f_(e),n=s_(e);return h_(t,n,e=>e.create(n))},v_=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw Q(`invalid`,Z.inviteNoKey);return h_(f_(t),void 0,n=>n.join(e,t))},y_=new Map(Object.values(Ho).map(({code:e,message:t})=>[t,e]));new Set(y_.values());var b_=(async e=>{let{kind:t,cookies:n}=fi(e);if(t===`window`){let t=e;return n===`native`?Mi(t):yp(t)}let r=e;return n===`native`?x_(r):yp(r)}),x_=e=>(lp(e),Mi(e)),S_=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let n=await so;if(!n)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);po(),Yo(`relayed worker`,yo(n,e,t?.unregisterSignal))},C_=/* @__PURE__ */ new Set,w_=e=>(C_.add(e),()=>{C_.delete(e)}),T_=()=>{if(C_.size===0)return!1;for(let e of[...C_])try{e()}catch{}return!0},E_=(e,t)=>{if(typeof e?.onUpdateTaken==`function`)return Promise.resolve(e.onUpdateTaken(t))},D_=/* @__PURE__ */ g({applyUpdate:()=>B_,busyReasons:()=>z_,isAppTab:()=>V_,onUpdate:()=>P_,onUpdateTaken:()=>F_,updateReady:()=>O_}),O_=async()=>typeof window>`u`?!1:U.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),k_=/* @__PURE__ */ new Set,A_=!1,j_=()=>{A_=!0;for(let e of[...k_])try{e()}catch{}},M_=0,N_=()=>{let e=Io();e&&k_.size!==0&&M_!==e.epoch&&(M_=e.epoch,A_=!1,Promise.resolve(e.remote.shell?.onUpdate(j_)).catch(()=>{M_===e.epoch&&(M_=0)}))};typeof window<`u`&&Fo(N_);var P_=async e=>{if(typeof window>`u`)return()=>{};if(k_.add(e),A_)try{e()}catch{}return N_(),()=>{k_.delete(e)}},F_=e=>typeof window>`u`?()=>{}:w_(e),I_=0,L_=!1,R_=()=>{if(!T_()&&!L_){L_=!0;try{location.reload()}catch{}}};typeof window<`u`&&Fo(()=>{let e=Io();if(!e||I_===e.epoch)return;I_=e.epoch;let t=E_(e.remote.shell,R_);t?t.catch(()=>{I_===e.epoch&&(I_=0)}):I_=0});var z_=()=>Zo(),B_=async()=>typeof window>`u`?!1:U.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1),V_=async()=>{if(typeof window>`u`||window.parent===window||window.parent!==window.top)return!1;let e=Po(`shell.isAppTab`).then(e=>e.shell?.isAppTab?.()).then(e=>e===!0,()=>!1);return Promise.race([e,new Promise(e=>setTimeout(e,Oo,!1))])},H_=/* @__PURE__ */ `en.es-419.pt-BR.fr.de.it.ru.ja.ko.zh-Hans.zh-Hant.tr.pl.ar.he.id.vi.th.hi.uk.nl.sv.cs.el.ro.hu.ms`.split(`.`),U_=e=>{try{return new Intl.Locale(e)}catch{return}},W_=(e,t)=>{let n=t.flatMap(e=>{let t=U_(e);if(!t)return[];let{language:n,script:r}=t.maximize();return[{tag:e,exact:t.baseName,language:n,script:r}]});for(let t of e){let e=U_(t);if(!e)continue;let{language:r,script:i}=e.maximize(),a=n.find(t=>t.exact===e.baseName)??n.find(e=>e.language===r&&e.script===i)??n.find(e=>e.language===r);if(a)return a.tag}},G_=`stub.settings.account`,K_=e=>{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,e])=>e===null||typeof e==`string`)):{}},q_=(e=()=>globalThis.localStorage,{accountKey:t=G_,merge:n}={})=>{let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=()=>{},o=t=>{try{return e().getItem(t)}catch{return null}},s=(t,n)=>{n===null?e().removeItem(t):e().setItem(t,n)},c=()=>{let e=o(t);if(e!==null)try{return K_(e)}catch{return{}}},l=e=>{let t=c()?.[e];return t===void 0?o(e):t},u=e=>{for(let t of r.get(e)??[])t()},d=(e,r)=>{let o=n?n(l(e),r):r;i.set(e,n?n(i.get(e)??null,r):r);try{let n=c();n?s(t,JSON.stringify({...n,[e]:o})):s(e,o)}finally{u(e),a()}};return{getItem:l,setItem:(e,t)=>d(e,t),removeItem:e=>d(e,null),watch:(e,n)=>{let i=r.get(e);i||r.set(e,i=/* @__PURE__ */ new Set),i.add(n);let a=r=>{(r.key===e||r.key===t||r.key===null)&&n()};return globalThis.addEventListener?.(`storage`,a),()=>{i.delete(n),globalThis.removeEventListener?.(`storage`,a)}},flush:()=>a(!0),unsaved:e=>i.has(e),internal:{raw:o,write:s,edits:i,tell:u,accountKey:t,merge:n,onEdit:e=>{a=e}}}},$=q_(),J_=`stub.language`,Y_=H_,X_=/* @__PURE__ */ new Set([`ar`,`ckb`,`dv`,`fa`,`he`,`ps`,`sd`,`ug`,`ur`,`yi`]),Z_=()=>globalThis.navigator?.languages??[],Q_=e=>X_.has(U_(e)?.language??``),$_=()=>{let e=$.getItem(J_);return e&&Y_.includes(e)?e:void 0},ev=`stub.language.carried`,tv=(e,t)=>{try{t?e.setItem(J_,t):e.removeItem(J_)}catch{}},nv=2e3,rv=async(e,{saved:t,reload:n})=>{tv($,e);let r;if(await Promise.race([t(),new Promise(e=>{r=setTimeout(e,nv)})]),clearTimeout(r),$.unsaved(`stub.language`))try{sessionStorage.setItem(ev,e??``)}catch{}n()},iv=(e=$)=>{let t=null;try{t=sessionStorage.getItem(ev),sessionStorage.removeItem(ev)}catch{}t!==null&&tv(e,t||void 0)},av=(e=Z_(),t=Y_)=>W_(e,t)??`en`,ov=(e=Z_(),t=Y_)=>$_()??av(e,t),sv=(e=ov(),t=Z_())=>{let{language:n,script:r}=U_(e)?.maximize()??{},i=t.find(e=>{let t=U_(e)?.maximize();return!!t&&t.language===n&&t.script===r})??e,{calendar:a,numberingSystem:o}=new Intl.DateTimeFormat(i).resolvedOptions(),s={...a===`gregory`?{}:{calendar:`gregory`},...o===`latn`?{}:{numberingSystem:`latn`}};return Object.keys(s).length?new Intl.Locale(i,s).toString():i},cv=(e=Z_())=>$_()??e?.[0]??`en`,lv=(e,t)=>Sp.fetch(e,t),uv=[`www.crunchyroll.com`,`crunchyroll.com`,`sso.crunchyroll.com`,`static.crunchyroll.com`],dv=`https://www.crunchyroll.com`,fv=`${dv}/`,pv=`noaihdevm_6iyg0a8l0q`,mv=`https://sso.crunchyroll.com/authorize?${new URLSearchParams({client_id:pv,redirect_uri:`${dv}/callback`,response_type:`cookie`,state:`/`})}`,hv=e=>e.locator(`#user-menu-authenticated`).exists(),gv=async()=>Xe()?`extension`:(document.readyState!==`complete`&&await new Promise(e=>{let t=()=>{clearTimeout(n),e()},n=setTimeout(()=>{window.removeEventListener(`load`,t),e()},1e4);window.addEventListener(`load`,t,{once:!0})}),await new Promise(e=>setTimeout(e,300)),Xe()?`extension`:`cloud`),_v=e=>e===`extension`?`native`:`persistent`,vv=()=>fs(`Play it in stub`),yv=({userAgent:e,maxTouchPoints:t}=navigator)=>/Chrome\/|Firefox\//.test(e)&&!/Android|Mobile/.test(e)&&!(/Macintosh/.test(e)&&t>1),bv=/* @__PURE__ */ new Set([`ExtensionOperationUnsupportedError`,`FrameWindowRefusedError`]),xv=(e,t)=>{let n;return Promise.race([Promise.resolve().then(e).catch(()=>void 0),new Promise(e=>{n=setTimeout(()=>e(void 0),t)})]).finally(()=>clearTimeout(n))},Sv=async({url:e,domains:t,isSignedIn:n,permissions:r,cookies:i,width:a,height:o,pollMs:s=1e3,readTimeoutMs:c=5e3})=>{let l=b_({window:{...a===void 0?{}:{width:a},...o===void 0?{}:{height:o}},domains:t,cookies:i??_v(Xe()?`extension`:`cloud`),...r?{permissions:r}:{}}),u;try{u=await l}catch(e){let t=e?.name;if(t===`FrameWindowBlockedError`)return`blocked`;if(t&&bv.has(t))return console.warn(`[login-window] window mode was refused`,e),`unsupported`;if(Yt(e))return`closed`;throw e}try{await u.goto(e,{waitUntil:`commit`})}catch(e){if(!Yt(e))throw await u.close().catch(()=>{}),e}let d=u.closed.then(()=>`closed`);for(;;){let e=await Promise.race([d,new Promise(e=>setTimeout(e,s)).then(()=>xv(()=>n(u),c))]);if(e===`closed`)return`closed`;if(e===!0)return await u.close(),`authed`}},Cv=`stub.sessions`,wv=`stub.sessions`,Tv=e=>{try{let t=JSON.parse(e??`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},Ev=(e,t)=>{let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=()=>{try{return Tv(e().getItem(Cv))}catch{return[]}};return{isConnected:e=>n.has(e)||!r.has(e)&&i().includes(e),connect:a=>{r.delete(a);try{let n=i();n.includes(a)?t.postMessage(a):e().setItem(Cv,JSON.stringify([...n,a]))}catch{n.add(a)}},disconnect:t=>{n.delete(t);try{e().setItem(Cv,JSON.stringify(i().filter(e=>e!==t)))}catch{r.add(t)}}}},Dv=e=>{let t=e?.name;return t===`LocatorDeniedError`||t===`PermissionDeniedError`},Ov=(e,t)=>({call:async(n,r,i,a)=>{if(!t.isConnected(n))return{kind:`not-connected`};try{return{kind:`response`,response:await e.use(n,e=>{let t=e[r];if(typeof t!=`function`)throw Error(`The ${n} page serves no ${r}`);return t(i)},a)}}catch(e){if(Dv(e))return{kind:`not-connected`};throw e}},watch:(t,n)=>{e.watch(t,()=>{n()})}}),kv=(e,t,{frames:n,connections:r})=>t().then(t=>(t!==`blocked`&&(r.connect(e),n.reload(e)),t)),Av=(e,{frames:t,connections:n})=>{n.disconnect(e),t.reload(e)},jv=`stub.site-status`,Mv=e=>typeof e==`object`&&!!e&&(e.state===`signed-in`||e.state===`signed-out`)&&Number.isFinite(e.checkedAt),Nv=e=>{try{let t=JSON.parse(e()??`{}`);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}},Pv=(e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=()=>Nv(()=>e().getItem(jv)),i=e=>{for(let t of n.get(e)??[])t()},a=(n,a)=>{try{e().setItem(jv,JSON.stringify({...r(),[n]:a})),t.delete(n)}catch{t.set(n,a)}i(n)},o={read:e=>{let n=t.get(e)??r()[e];if(Mv(n))return n.state===`signed-out`&&n.signedInBefore===!0?{state:n.state,checkedAt:n.checkedAt,signedInBefore:!0}:{state:n.state,checkedAt:n.checkedAt}},record:(e,t,n=Date.now())=>{let r=o.read(e);a(e,t===`signed-out`&&(r?.state===`signed-in`||r?.signedInBefore)?{state:t,checkedAt:n,signedInBefore:!0}:{state:t,checkedAt:n})},recordSignOut:(e,t=Date.now())=>a(e,{state:`signed-out`,checkedAt:t}),watch:(e,t)=>{let r=n.get(e);return r||n.set(e,r=/* @__PURE__ */ new Set),r.add(t),()=>{r.delete(t)}},heard:(e,t)=>{let n=Nv(()=>e),r=Nv(()=>t);for(let e of/* @__PURE__ */ new Set([...Object.keys(n),...Object.keys(r)]))JSON.stringify(n[e])!==JSON.stringify(r[e])&&i(e)}};return o})(()=>localStorage);globalThis.addEventListener?.(`storage`,({key:e,oldValue:t,newValue:n})=>{e===`stub.site-status`&&Pv.heard(t,n)});var Fv=(e,t,n=Date.now)=>{let r=/* @__PURE__ */ new Map;return(i,a)=>{if(n()-Math.max(e.read(i)?.checkedAt??-1/0,r.get(i)??-1/0)<6e4)return;let o=n();r.set(i,1/0),t(i,a).then(t=>{(e.read(i)?.checkedAt??-1/0)<o&&e.record(i,t,n())},()=>{}).finally(()=>r.set(i,n()))}},Iv=(e,t)=>n=>(n===`authed`&&e.record(t,`signed-in`),n),Lv=[`anilist`,`mal`,`trakt`],Rv=(e,t,n)=>{for(let{state:r,tracker:i}of e){let e=i.id;Lv.includes(e)&&n(e)&&(r===`LISTED`||r===`NOT_LISTED`?t.record(e,`signed-in`):r===`SIGNED_OUT`&&t.record(e,`signed-out`))}},zv={"Africa/Abidjan":`CI`,"Africa/Accra":`GH`,"Africa/Addis_Ababa":`ET`,"Africa/Algiers":`DZ`,"Africa/Asmara":`ER`,"Africa/Asmera":`ER`,"Africa/Bamako":`ML`,"Africa/Bangui":`CF`,"Africa/Banjul":`GM`,"Africa/Bissau":`GW`,"Africa/Blantyre":`MW`,"Africa/Brazzaville":`CG`,"Africa/Bujumbura":`BI`,"Africa/Cairo":`EG`,"Africa/Casablanca":`MA`,"Africa/Ceuta":`ES`,"Africa/Conakry":`GN`,"Africa/Dakar":`SN`,"Africa/Dar_es_Salaam":`TZ`,"Africa/Djibouti":`DJ`,"Africa/Douala":`CM`,"Africa/El_Aaiun":`EH`,"Africa/Freetown":`SL`,"Africa/Gaborone":`BW`,"Africa/Harare":`ZW`,"Africa/Johannesburg":`ZA`,"Africa/Juba":`SS`,"Africa/Kampala":`UG`,"Africa/Khartoum":`SD`,"Africa/Kigali":`RW`,"Africa/Kinshasa":`CD`,"Africa/Lagos":`NG`,"Africa/Libreville":`GA`,"Africa/Lome":`TG`,"Africa/Luanda":`AO`,"Africa/Lubumbashi":`CD`,"Africa/Lusaka":`ZM`,"Africa/Malabo":`GQ`,"Africa/Maputo":`MZ`,"Africa/Maseru":`LS`,"Africa/Mbabane":`SZ`,"Africa/Mogadishu":`SO`,"Africa/Monrovia":`LR`,"Africa/Nairobi":`KE`,"Africa/Ndjamena":`TD`,"Africa/Niamey":`NE`,"Africa/Nouakchott":`MR`,"Africa/Ouagadougou":`BF`,"Africa/Porto-Novo":`BJ`,"Africa/Sao_Tome":`ST`,"Africa/Tripoli":`LY`,"Africa/Tunis":`TN`,"Africa/Windhoek":`NA`,"America/Adak":`US`,"America/Anchorage":`US`,"America/Anguilla":`AI`,"America/Antigua":`AG`,"America/Araguaina":`BR`,"America/Argentina/Buenos_Aires":`AR`,"America/Argentina/Catamarca":`AR`,"America/Argentina/Cordoba":`AR`,"America/Argentina/Jujuy":`AR`,"America/Argentina/La_Rioja":`AR`,"America/Argentina/Mendoza":`AR`,"America/Argentina/Rio_Gallegos":`AR`,"America/Argentina/Salta":`AR`,"America/Argentina/San_Juan":`AR`,"America/Argentina/San_Luis":`AR`,"America/Argentina/Tucuman":`AR`,"America/Argentina/Ushuaia":`AR`,"America/Aruba":`AW`,"America/Asuncion":`PY`,"America/Atikokan":`CA`,"America/Bahia":`BR`,"America/Bahia_Banderas":`MX`,"America/Barbados":`BB`,"America/Belem":`BR`,"America/Belize":`BZ`,"America/Blanc-Sablon":`CA`,"America/Boa_Vista":`BR`,"America/Bogota":`CO`,"America/Boise":`US`,"America/Buenos_Aires":`AR`,"America/Cambridge_Bay":`CA`,"America/Campo_Grande":`BR`,"America/Cancun":`MX`,"America/Caracas":`VE`,"America/Catamarca":`AR`,"America/Cayenne":`GF`,"America/Cayman":`KY`,"America/Chicago":`US`,"America/Chihuahua":`MX`,"America/Ciudad_Juarez":`MX`,"America/Coral_Harbour":`CA`,"America/Cordoba":`AR`,"America/Costa_Rica":`CR`,"America/Coyhaique":`CL`,"America/Creston":`CA`,"America/Cuiaba":`BR`,"America/Curacao":`CW`,"America/Danmarkshavn":`GL`,"America/Dawson":`CA`,"America/Dawson_Creek":`CA`,"America/Denver":`US`,"America/Detroit":`US`,"America/Dominica":`DM`,"America/Edmonton":`CA`,"America/Eirunepe":`BR`,"America/El_Salvador":`SV`,"America/Fort_Nelson":`CA`,"America/Fortaleza":`BR`,"America/Glace_Bay":`CA`,"America/Godthab":`GL`,"America/Goose_Bay":`CA`,"America/Grand_Turk":`TC`,"America/Grenada":`GD`,"America/Guadeloupe":`GP`,"America/Guatemala":`GT`,"America/Guayaquil":`EC`,"America/Guyana":`GY`,"America/Halifax":`CA`,"America/Havana":`CU`,"America/Hermosillo":`MX`,"America/Indiana/Indianapolis":`US`,"America/Indiana/Knox":`US`,"America/Indiana/Marengo":`US`,"America/Indiana/Petersburg":`US`,"America/Indiana/Tell_City":`US`,"America/Indiana/Vevay":`US`,"America/Indiana/Vincennes":`US`,"America/Indiana/Winamac":`US`,"America/Indianapolis":`US`,"America/Inuvik":`CA`,"America/Iqaluit":`CA`,"America/Jamaica":`JM`,"America/Jujuy":`AR`,"America/Juneau":`US`,"America/Kentucky/Louisville":`US`,"America/Kentucky/Monticello":`US`,"America/Kralendijk":`BQ`,"America/La_Paz":`BO`,"America/Lima":`PE`,"America/Los_Angeles":`US`,"America/Louisville":`US`,"America/Lower_Princes":`SX`,"America/Maceio":`BR`,"America/Managua":`NI`,"America/Manaus":`BR`,"America/Marigot":`MF`,"America/Martinique":`MQ`,"America/Matamoros":`MX`,"America/Mazatlan":`MX`,"America/Mendoza":`AR`,"America/Menominee":`US`,"America/Merida":`MX`,"America/Metlakatla":`US`,"America/Mexico_City":`MX`,"America/Miquelon":`PM`,"America/Moncton":`CA`,"America/Monterrey":`MX`,"America/Montevideo":`UY`,"America/Montserrat":`MS`,"America/Nassau":`BS`,"America/New_York":`US`,"America/Nome":`US`,"America/Noronha":`BR`,"America/North_Dakota/Beulah":`US`,"America/North_Dakota/Center":`US`,"America/North_Dakota/New_Salem":`US`,"America/Nuuk":`GL`,"America/Ojinaga":`MX`,"America/Panama":`PA`,"America/Paramaribo":`SR`,"America/Phoenix":`US`,"America/Port-au-Prince":`HT`,"America/Port_of_Spain":`TT`,"America/Porto_Velho":`BR`,"America/Puerto_Rico":`PR`,"America/Punta_Arenas":`CL`,"America/Rankin_Inlet":`CA`,"America/Recife":`BR`,"America/Regina":`CA`,"America/Resolute":`CA`,"America/Rio_Branco":`BR`,"America/Santarem":`BR`,"America/Santiago":`CL`,"America/Santo_Domingo":`DO`,"America/Sao_Paulo":`BR`,"America/Scoresbysund":`GL`,"America/Sitka":`US`,"America/St_Barthelemy":`BL`,"America/St_Johns":`CA`,"America/St_Kitts":`KN`,"America/St_Lucia":`LC`,"America/St_Thomas":`VI`,"America/St_Vincent":`VC`,"America/Swift_Current":`CA`,"America/Tegucigalpa":`HN`,"America/Thule":`GL`,"America/Tijuana":`MX`,"America/Toronto":`CA`,"America/Tortola":`VG`,"America/Vancouver":`CA`,"America/Whitehorse":`CA`,"America/Winnipeg":`CA`,"America/Yakutat":`US`,"Antarctica/Casey":`AQ`,"Antarctica/Davis":`AQ`,"Antarctica/DumontDUrville":`AQ`,"Antarctica/Macquarie":`AU`,"Antarctica/Mawson":`AQ`,"Antarctica/McMurdo":`AQ`,"Antarctica/Palmer":`AQ`,"Antarctica/Rothera":`AQ`,"Antarctica/Syowa":`AQ`,"Antarctica/Troll":`AQ`,"Antarctica/Vostok":`AQ`,"Arctic/Longyearbyen":`SJ`,"Asia/Aden":`YE`,"Asia/Almaty":`KZ`,"Asia/Amman":`JO`,"Asia/Anadyr":`RU`,"Asia/Aqtau":`KZ`,"Asia/Aqtobe":`KZ`,"Asia/Ashgabat":`TM`,"Asia/Atyrau":`KZ`,"Asia/Baghdad":`IQ`,"Asia/Bahrain":`BH`,"Asia/Baku":`AZ`,"Asia/Bangkok":`TH`,"Asia/Barnaul":`RU`,"Asia/Beirut":`LB`,"Asia/Bishkek":`KG`,"Asia/Brunei":`BN`,"Asia/Calcutta":`IN`,"Asia/Chita":`RU`,"Asia/Colombo":`LK`,"Asia/Damascus":`SY`,"Asia/Dhaka":`BD`,"Asia/Dili":`TL`,"Asia/Dubai":`AE`,"Asia/Dushanbe":`TJ`,"Asia/Famagusta":`CY`,"Asia/Gaza":`PS`,"Asia/Hebron":`PS`,"Asia/Ho_Chi_Minh":`VN`,"Asia/Hong_Kong":`HK`,"Asia/Hovd":`MN`,"Asia/Irkutsk":`RU`,"Asia/Jakarta":`ID`,"Asia/Jayapura":`ID`,"Asia/Jerusalem":`IL`,"Asia/Kabul":`AF`,"Asia/Kamchatka":`RU`,"Asia/Karachi":`PK`,"Asia/Kathmandu":`NP`,"Asia/Katmandu":`NP`,"Asia/Khandyga":`RU`,"Asia/Kolkata":`IN`,"Asia/Krasnoyarsk":`RU`,"Asia/Kuala_Lumpur":`MY`,"Asia/Kuching":`MY`,"Asia/Kuwait":`KW`,"Asia/Macau":`MO`,"Asia/Magadan":`RU`,"Asia/Makassar":`ID`,"Asia/Manila":`PH`,"Asia/Muscat":`OM`,"Asia/Nicosia":`CY`,"Asia/Novokuznetsk":`RU`,"Asia/Novosibirsk":`RU`,"Asia/Omsk":`RU`,"Asia/Oral":`KZ`,"Asia/Phnom_Penh":`KH`,"Asia/Pontianak":`ID`,"Asia/Pyongyang":`KP`,"Asia/Qatar":`QA`,"Asia/Qostanay":`KZ`,"Asia/Qyzylorda":`KZ`,"Asia/Rangoon":`MM`,"Asia/Riyadh":`SA`,"Asia/Saigon":`VN`,"Asia/Sakhalin":`RU`,"Asia/Samarkand":`UZ`,"Asia/Seoul":`KR`,"Asia/Shanghai":`CN`,"Asia/Singapore":`SG`,"Asia/Srednekolymsk":`RU`,"Asia/Taipei":`TW`,"Asia/Tashkent":`UZ`,"Asia/Tbilisi":`GE`,"Asia/Tehran":`IR`,"Asia/Thimphu":`BT`,"Asia/Tokyo":`JP`,"Asia/Tomsk":`RU`,"Asia/Ulaanbaatar":`MN`,"Asia/Urumqi":`CN`,"Asia/Ust-Nera":`RU`,"Asia/Vientiane":`LA`,"Asia/Vladivostok":`RU`,"Asia/Yakutsk":`RU`,"Asia/Yangon":`MM`,"Asia/Yekaterinburg":`RU`,"Asia/Yerevan":`AM`,"Atlantic/Azores":`PT`,"Atlantic/Bermuda":`BM`,"Atlantic/Canary":`ES`,"Atlantic/Cape_Verde":`CV`,"Atlantic/Faeroe":`FO`,"Atlantic/Faroe":`FO`,"Atlantic/Madeira":`PT`,"Atlantic/Reykjavik":`IS`,"Atlantic/South_Georgia":`GS`,"Atlantic/St_Helena":`SH`,"Atlantic/Stanley":`FK`,"Australia/Adelaide":`AU`,"Australia/Brisbane":`AU`,"Australia/Broken_Hill":`AU`,"Australia/Darwin":`AU`,"Australia/Eucla":`AU`,"Australia/Hobart":`AU`,"Australia/Lindeman":`AU`,"Australia/Lord_Howe":`AU`,"Australia/Melbourne":`AU`,"Australia/Perth":`AU`,"Australia/Sydney":`AU`,"Europe/Amsterdam":`NL`,"Europe/Andorra":`AD`,"Europe/Astrakhan":`RU`,"Europe/Athens":`GR`,"Europe/Belgrade":`RS`,"Europe/Berlin":`DE`,"Europe/Bratislava":`SK`,"Europe/Brussels":`BE`,"Europe/Bucharest":`RO`,"Europe/Budapest":`HU`,"Europe/Busingen":`DE`,"Europe/Chisinau":`MD`,"Europe/Copenhagen":`DK`,"Europe/Dublin":`IE`,"Europe/Gibraltar":`GI`,"Europe/Guernsey":`GG`,"Europe/Helsinki":`FI`,"Europe/Isle_of_Man":`IM`,"Europe/Istanbul":`TR`,"Europe/Jersey":`JE`,"Europe/Kaliningrad":`RU`,"Europe/Kiev":`UA`,"Europe/Kirov":`RU`,"Europe/Kyiv":`UA`,"Europe/Lisbon":`PT`,"Europe/Ljubljana":`SI`,"Europe/London":`GB`,"Europe/Luxembourg":`LU`,"Europe/Madrid":`ES`,"Europe/Malta":`MT`,"Europe/Mariehamn":`AX`,"Europe/Minsk":`BY`,"Europe/Monaco":`MC`,"Europe/Moscow":`RU`,"Europe/Oslo":`NO`,"Europe/Paris":`FR`,"Europe/Podgorica":`ME`,"Europe/Prague":`CZ`,"Europe/Riga":`LV`,"Europe/Rome":`IT`,"Europe/Samara":`RU`,"Europe/San_Marino":`SM`,"Europe/Sarajevo":`BA`,"Europe/Saratov":`RU`,"Europe/Simferopol":`UA`,"Europe/Skopje":`MK`,"Europe/Sofia":`BG`,"Europe/Stockholm":`SE`,"Europe/Tallinn":`EE`,"Europe/Tirane":`AL`,"Europe/Ulyanovsk":`RU`,"Europe/Vaduz":`LI`,"Europe/Vatican":`VA`,"Europe/Vienna":`AT`,"Europe/Vilnius":`LT`,"Europe/Volgograd":`RU`,"Europe/Warsaw":`PL`,"Europe/Zagreb":`HR`,"Europe/Zurich":`CH`,"Indian/Antananarivo":`MG`,"Indian/Chagos":`IO`,"Indian/Christmas":`CX`,"Indian/Cocos":`CC`,"Indian/Comoro":`KM`,"Indian/Kerguelen":`TF`,"Indian/Mahe":`SC`,"Indian/Maldives":`MV`,"Indian/Mauritius":`MU`,"Indian/Mayotte":`YT`,"Indian/Reunion":`RE`,"Pacific/Apia":`WS`,"Pacific/Auckland":`NZ`,"Pacific/Bougainville":`PG`,"Pacific/Chatham":`NZ`,"Pacific/Chuuk":`FM`,"Pacific/Easter":`CL`,"Pacific/Efate":`VU`,"Pacific/Enderbury":`KI`,"Pacific/Fakaofo":`TK`,"Pacific/Fiji":`FJ`,"Pacific/Funafuti":`TV`,"Pacific/Galapagos":`EC`,"Pacific/Gambier":`PF`,"Pacific/Guadalcanal":`SB`,"Pacific/Guam":`GU`,"Pacific/Honolulu":`US`,"Pacific/Kanton":`KI`,"Pacific/Kiritimati":`KI`,"Pacific/Kosrae":`FM`,"Pacific/Kwajalein":`MH`,"Pacific/Majuro":`MH`,"Pacific/Marquesas":`PF`,"Pacific/Midway":`UM`,"Pacific/Nauru":`NR`,"Pacific/Niue":`NU`,"Pacific/Norfolk":`NF`,"Pacific/Noumea":`NC`,"Pacific/Pago_Pago":`AS`,"Pacific/Palau":`PW`,"Pacific/Pitcairn":`PN`,"Pacific/Pohnpei":`FM`,"Pacific/Ponape":`FM`,"Pacific/Port_Moresby":`PG`,"Pacific/Rarotonga":`CK`,"Pacific/Saipan":`MP`,"Pacific/Tahiti":`PF`,"Pacific/Tarawa":`KI`,"Pacific/Tongatapu":`TO`,"Pacific/Truk":`FM`,"Pacific/Wake":`UM`,"Pacific/Wallis":`WF`},Bv=`stub.country`,Vv=zv,Hv=[...new Set(Object.values(zv))],Uv=(e=Intl.DateTimeFormat().resolvedOptions().timeZone)=>Vv[e]??`US`,Wv=()=>{let e=$.getItem(Bv);return e&&Hv.includes(e)?e:void 0},Gv=e=>{try{e?$.setItem(Bv,e):$.removeItem(Bv)}catch{}},Kv=e=>$.watch(Bv,e),qv,Jv=()=>Wv()??qv??Uv(),Yv=`stub.player.audio-language`,Xv=`stub.player.subtitle-language`,Zv=`stub.player.always-subtitles`,Qv=`original`,$v=(e=e=>$.getItem(e),t=cv())=>{let n=e(Yv),r=e(Xv);return{audio:n===`original`?void 0:n??t,subtitles:r===`off`?null:r??t,alwaysSubtitles:e(Zv)===`on`}},ey=e=>{try{e===void 0?$.removeItem(Yv):$.setItem(Yv,e)}catch{}},ty=e=>{try{e===void 0?$.removeItem(Xv):$.setItem(Xv,e??`off`)}catch{}},ny=e=>{try{e?$.setItem(Zv,`on`):$.removeItem(Zv)}catch{}},ry=e=>{let t=[Yv,Xv,Zv].map(t=>$.watch(t,e));return()=>{for(let e of t)e()}};export{q_ as $,vv as A,lv as B,Cv as C,Xe as Ct,kv as D,Av as E,uv as F,cv as G,J_ as H,mv as I,rv as J,sv as K,fv as L,yv as M,gv as N,Ov as O,dv as P,G_ as Q,pv as R,wv as S,qt as St,Ev as T,Y_ as U,ev as V,av as W,iv as X,$_ as Y,ov as Z,jv as _,ul as _t,ny as a,b_ as at,Iv as b,rs as bt,$v as c,ag as ct,Bv as d,wp as dt,K_ as et,Gv as f,Sp as ft,Uv as g,nl as gt,Kv as h,dl as ht,Xv as i,S_ as it,_v as j,Sv as k,ry as l,mg as lt,Jv as m,Cl as mt,Yv as n,W_ as nt,ey as o,Yg as ot,Wv as p,Sl as pt,Q_ as q,Qv as r,D_ as rt,ty as s,Dg as st,Zv as t,$ as tt,Hv as u,Op as ut,Fv as v,gs as vt,Tv as w,Pi as wt,Pv as x,qi as xt,Rv as y,$o as yt,hv as z};
|
|
72
|
+
`,`latin1`),()=>{})}setTimeout(e,t){return this.socket?.setTimeout(e,t),this}},$d=(...e)=>{let t={},n={},r,i=[...e],a=i.shift();if(typeof a==`string`||a instanceof URL){let e=typeof a==`string`?new URL(a):a;t={protocol:e.protocol,hostname:e.hostname,host:e.hostname,port:e.port,path:`${e.pathname}${e.search}`,auth:e.username?`${e.username}:${e.password}`:void 0};let o=i.shift();typeof o==`function`?r=o:o&&typeof o==`object`&&(n=o,r=i.shift())}else a&&typeof a==`object`&&(n=a,r=i.shift());return{options:{...t,...n},callback:r}},ef=class extends Zd{method;path;host;protocol;socket;get connection(){return this.socket}res=null;aborted=!1;_aborted=!1;constructor(e,t){super(),this.method=(e.method??`GET`).toUpperCase(),this.path=e.path??`/`,this.protocol=e.protocol??`http:`;let n=e.hostname??e.host??`localhost`;this.host=n;let r=Number(e.port??(this.protocol===`https:`?443:80));if(t&&this.once(`response`,t),e.headers)for(let[t,n]of Object.entries(e.headers))n!==void 0&&this.setHeader(t,n);if(!this.hasHeader(`host`)){let e=this.protocol===`https:`&&r===443||this.protocol!==`https:`&&r===80;this.setHeader(`Host`,e?n:`${n}:${r}`)}e.auth&&!this.hasHeader(`authorization`)&&this.setHeader(`Authorization`,`Basic ${G.from(e.auth).toString(`base64`)}`),this.socket=new xd,this.emit(`socket`,this.socket),this.socket.on(`error`,e=>{!this._aborted&&!this.res?.complete&&this.emit(`error`,e)}),this._attachResponseParser(),this.socket.connect({host:n,port:r,relay:e.relay},()=>{this.emit(`connect`)})}_shouldSendBody(){return this.method!==`GET`&&this.method!==`HEAD`&&this.method!==`DELETE`}_implicitHeader(){this._headBlock=this._storeHeader(`${this.method} ${this.path} HTTP/1.1`)}_attachResponseParser(){let e=new Xd(this.socket),t=new Jd(`response`,{onHeaders:n=>{e._applyHead(n),this.method===`HEAD`&&(t.skipBody=!0),this.res=e,this.emit(`response`,e)},onBody:t=>{e.push(G.from(t))},onComplete:()=>{e.complete=!0,e.push(null)}});this.socket.on(`data`,e=>{this._aborted||t.execute(e)}),this.socket.on(`end`,()=>{t.finish()}),this.socket.on(`close`,()=>{this.emit(`close`)})}abort(){this._aborted||(this._aborted=!0,this.aborted=!0,this.emit(`abort`),this.socket.destroy())}destroy(e){return this._aborted||(this._aborted=!0,this.socket.destroy(e),super.destroy(e)),this}end(e,t,n){return this._aborted?this:super.end(e,t,n)}_writeToSocket(e,t){this._aborted?t():super._writeToSocket(e,t)}setTimeout(e,t){return this.socket.setTimeout(e,t),this}setNoDelay(e){this.socket.setNoDelay(e)}setSocketKeepAlive(e,t){this.socket.setKeepAlive(e,t)}},tf=new Proxy(class extends Sd{constructor(e,t){let n={},r=t;typeof e==`function`?r=e:e&&(n=e),super(n),r&&this.on(`request`,r),this.on(`connection`,e=>this._handleConnection(e))}_handleConnection(e){let t=null,n=new Jd(`request`,{onHeaders:r=>{t=new Xd(e),t._applyHead(r),r.method===`HEAD`&&(n.skipBody=!0);let i=new Qd(t),a=String(r.headers.connection??``).toLowerCase();i._keepAlive=r.httpVersionMinor>=1?a!==`close`:a===`keep-alive`,i.on(`finish`,()=>{i._keepAlive||e.end()}),this.emit(`request`,t,i)},onBody:e=>{t?.push(G.from(e))},onComplete:()=>{t&&(t.complete=!0,t.push(null)),t=null}});e.on(`data`,e=>n.execute(e)),e.on(`end`,()=>{n.finish(),t&&t.push(null)}),e.on(`error`,t=>this.emit(`clientError`,t,e))}},{apply:(e,t,n)=>new e(...n)}),nf=class{maxSockets;maxFreeSockets;keepAlive;options;constructor(e={}){this.options=e,this.keepAlive=!!e.keepAlive,this.maxSockets=e.maxSockets??1/0,this.maxFreeSockets=e.maxFreeSockets??256}getName(e={}){return`${e.host??`localhost`}:${e.port??``}:${e.localAddress??``}`}destroy(){}},rf=new nf,af=(...e)=>{let{options:t,callback:n}=$d(...e);return new ef(t,n)},of=(...e)=>{let t=af(...e);return t.end(),t},sf=(e,t)=>new tf(e,t),cf={METHODS:Rd,STATUS_CODES:zd,Agent:nf,globalAgent:rf,Server:tf,ServerResponse:Qd,IncomingMessage:Xd,ClientRequest:ef,OutgoingMessage:Zd,createServer:sf,request:af,get:of},lf=async()=>{let e=()=>Fo(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof Oo))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},uf=`frame: this frame no longer holds the document the app attached it to`,df=!1,ff=()=>{df||(df=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},pf=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),mf=e=>typeof e?.reason==`string`?{reason:e.reason}:{},hf=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,gf=e=>{let{assertLive:t,attach:n,consent:r,current:i,declaredHosts:a,documentHost:o,freshBlank:s,session:c,approvedOrigins:l}=e,u=/* @__PURE__ */ new Set,d=()=>{try{return new URL(i()).hostname}catch{return``}},f=async()=>o?await o():d(),p=()=>R([...a,...pf(l)]),m=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:i,phase:o})=>{t();let h=I(e,i);if(h===null)return;let g=Nr(h);if(g===void 0||g===`auto`)return;if(e===`fetch`){let e=vs({session:c,declaredHosts:a,approvedOrigins:l},o===`ensure`?void 0:i[0],{classifier:`fetchTarget`});if(o===`ensure`&&!c)throw V(e.kind===`refuse`?e.reason:``,`fetch`);if(o!==`ensure`&&e.kind===`refuse`)throw V(e.reason,`fetch`);let{request:t,ensure:n}=await r();if(!t){if(e.kind===`refuse`)throw V(e.reason,`fetch`);if(!await n({scope:P(i[0],i[1]).scope,hosts:e.promptHosts}))throw V(`frame.fetch: the user did not grant this`,`fetch`);return}let s=e.kind===`consent`?e.targetHost:await f(),u=R([s,...a]);if(!u.length)throw V(`frame: navigate the frame before fetch`,`fetch`);if(await m(t,{category:`network`,hosts:u,...mf(zn(i))})===!1)throw V(hf(`fetch`,`network`,s||null),`fetch`);return}let _=await f();if(!_)throw V(`frame: navigate the frame before ${e}`,e);if(!p().includes(_))throw V(uf,e);let v=Pr(h);if(v===void 0||v===`evaluation`&&_===d()&&await s?.()||g===`critical`&&u.has(`${h} ${_}`))return;let{request:y}=await r();if(!y)return;let b=R([_,...a]),x=mf(zn(i)),S=g===`critical`?{key:h,hosts:b,attach:n,...x}:{category:v,hosts:b,...x},C=await m(y,S);if(C===!1)throw V(hf(e,v,null),e);if(C===`once`&&o!==`ensure`)for(let e of b)u.add(`${h} ${e}`)},requestCategories:async e=>{t(),Lr(`frame.requestPermissions`,e);let i=await f(),o=R(i?[i,...a]:a);if(!o.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let s=e.map(e=>{let t=e.key;return t===void 0?{named:void 0,critical:!1,category:e.category}:{named:t,critical:Nr(t)===`critical`,category:Mr(t)}}),c=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:o,allow:r}),{request:l}=await r();if(!l)return ff(),s.map(e=>c(e,!1));let u=await l(s.map(({named:t,critical:r,category:i},a)=>{let s=mf(e[a]);return r?{key:t,hosts:o,attach:n,...s}:{category:i,hosts:o,...s}}));return s.map((e,t)=>c(e,u[t]!==void 0&&u[t]!==!1))},boundary:p}},_f=e=>e,vf=5e3,yf=/* @__PURE__ */ new Set([]),bf=()=>`https://fkn.app`,xf=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,Sf=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(typeof n==`string`?new Gt(n):n()),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},Cf=e=>Object.assign(Error(e),{name:Lt}),wf=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,Tf=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,Ef=`frame.addScriptTag: no answer within ${Gr}ms; the script may or may not have run`,Df=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,Of=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,kf=3e4,Af=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,jf=2e4,Mf=async(e,t)=>{if(typeof e.seed!=`function`)throw Ht(Af,`storageState`,`cloud`);try{await Sf(e.seed(t),jf,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw Kt(e)?Ht(Af,`storageState`,`cloud`):e}},Nf=`frame.clearCookies: the render proxy did not answer within ${kf}ms; the cookies may or may not be gone, and calling it again is safe`,Pf=e=>Kt(e)&&e.message===Ut(`addScriptTag`).message,Ff=!1,If=()=>{Ff||(Ff=!0,console.warn(`[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one.`))},Lf=({from:e,origin:t,attach:n,signal:r})=>i=>qi(window,`message`,r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))},{signal:r}),Rf=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},zf=({control:e,target:t,blank:n=!1,session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,guard:c,consent:l,onNavigated:u,relay:d})=>{let f=t,p=n&&r!==``,m=async()=>{if(!p)return!1;let n=typeof e.blank==`function`?await c(()=>e.blank()):``;return(typeof n!=`string`||n.split(`#`)[0]!==t.split(`#`)[0])&&(p=!1),p},h=Promise.resolve(),{gate:g,requestCategories:_,boundary:v}=gf({session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,documentHost:typeof e.documentHost==`function`?()=>c(()=>e.documentHost()):void 0,current:()=>f,consent:Rf(l),freshBlank:m});return Tr({backend:`cloud`,executor:{execute:(t,n,r)=>yf.has(n)?Promise.reject(Ut(n,`cloud`)):(s(),c(()=>e.executeLocator(t,n,r))),highlight:async()=>{}},gate:g,requestPermissions:_,evaluate:async(t,n)=>(s(),await g({parts:[],operation:`evaluate`,args:[t],phase:`execute`}),Sf(c(()=>e.executeLocator([],`evaluate`,[t,n])),Gr,qr)),addScriptTag:async(t,n)=>{s();let r=[t,n];await g({parts:[],operation:`addScriptTag`,args:r,phase:`execute`});try{await Sf(c(()=>e.executeLocator([],`addScriptTag`,r)),Gr,Ef)}catch(e){throw Pf(e)?Ht(Tf,`addScriptTag`,`cloud`):e}},clearCookies:async t=>{if(s(),typeof e.clearCookies!=`function`)throw Ht(Df,`clearCookies`,`cloud`);if(v().length===0)throw V(Of,`clearCookies`);await Sf(c(()=>e.clearCookies(t)),kf,Nf)},postMessage:(t,n,r)=>{if(s(),typeof e.messaging!=`function`)throw Ht(wf,`postMessage`,`cloud`);if(n!==`*`&&!v().includes(new URL(n).hostname))throw V(uf,`postMessage`);let{port1:i,port2:a}=new MessageChannel;i.postMessage({data:t,transfer:r},r);let o=[a,n],l=h.then(async()=>(await g({parts:[],operation:`postMessage`,args:o,phase:`execute`}),{answer:c(()=>e.executeLocator([],`postMessage`,o))}));return h=l.catch(()=>{}),l.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&If(),d(t)),goto:async(t,{timeout:n,...r}={})=>{let i=new URL(t,location.href).href;s(),p=!1;let o=(()=>{try{return new URL(i).origin}catch{return``}})(),l=o!==``&&!a.has(o);l&&a.add(o);try{await Sf(c(()=>e.goto(i,n===void 0?r:{...r,timeoutMs:n})),(n??3e4)+vf,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw l&&a.delete(o),Xr(e)}f=i,u()},url:()=>f})},Bf=async e=>{if(e===void 0){let e=await Fo(`a relay`).catch(()=>void 0);if(typeof e?.relay?.resolve!=`function`)return;let t=await e.relay.resolve().catch(()=>void 0);return t&&`id`in t?t.id:void 0}let t=await Fo(`a relay choice`);ts(t,`attachFrame`);let n=await t.relay.resolve(e);if(`refused`in n)throw $o(`attachFrame: ${n.refused}`);return n.id},Vf=async(e,t)=>{if((typeof e.relay==`function`?await e.relay():``)!==t)throw $o(`attachFrame: ${Ko}`)},Hf=250,Uf=500,Wf=65e3,Gf=2e3,Kf=2e3,qf=2,Jf=2e3,Yf=2e3,Xf=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);return a.searchParams.set(`attach`,i),t&&a.searchParams.set(`url`,t),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.href},Zf=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);return r.searchParams.set(`attach`,t),n.src=r.href,n.tabIndex=-1,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`style`,`display:none`),(document.body??document.documentElement).appendChild(n),n},Qf=(e,t)=>{let n=new MutationObserver(()=>{e.isConnected||t.aborted||(n.disconnect(),console.warn(`cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},$f=()=>Cf(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),ep=()=>Cf(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),tp=()=>Cf(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),np=()=>Cf(`cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window`),rp=async(e,t,n)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:r=[],permissions:i,relay:a}=e,{url:o,width:c,height:l}=$r(e.window);if(window.origin===`null`)throw new pr(`opaque-opener`);let u=bf(),d=crypto.randomUUID(),f=xf(t),p=R(r),m=/* @__PURE__ */ new Set;o&&m.add(new URL(o).origin);let h=t===`persistent`?Zf(u,d):null,g=window.open(Xf({origin:u,target:n===void 0?o:``,session:f,domains:p,attach:d}),`_blank`,`popup,width=${c},height=${l}`);if(!g)throw h?.remove(),new dr;let _=new AbortController,v=!1,y=null,b=(e,t=!1)=>{if(y===null){y=e,_.abort(t?ep():$f());try{g.closed||g.postMessage({type:Bo.detach,attach:d,...t?{unanswered:t}:{}},u)}catch{}h&&setTimeout(()=>h.remove(),Yf)}};h&&Qf(h,_.signal);let x=new Promise((e,t)=>{_.signal.addEventListener(`abort`,()=>t(_.signal.reason),{once:!0})});x.catch(()=>{});let S=x.then(()=>{},()=>{}),C=()=>{if(_.signal.aborted)throw _.signal.reason},w=e=>_.signal.aborted?Promise.reject(_.signal.reason):Promise.race([e(),x]),T=e=>e.source===g&&e.origin===u;qi(window,`message`,e=>{let t=e.source===null&&e.origin===u;if(!T(e)&&!t)return;let n=e.data;typeof n==`object`&&n&&n.attach===d&&(n.type===Bo.gone?b(v?$f():tp()):n.type===Bo.refused&&!t&&b(new pr(n.reason)))},{signal:_.signal}),qi(window,`pagehide`,()=>b($f()),{signal:_.signal});let E=Bf(a),D,O,k=()=>{let e=()=>{try{g.postMessage({type:Bo.hello,attach:d,...D?{relay:D}:{}},u)}catch{}};e(),O=setInterval(e,Hf)};a===void 0&&k();let A=setInterval(()=>{g.closed&&b(v?$f():np())},Uf);_.signal.addEventListener(`abort`,()=>{clearInterval(O),clearInterval(A)},{once:!0});let j=async e=>{try{return await Promise.race([e,x])}catch(e){throw y??e}};try{a!==void 0&&(D=await j(E),k());let e=await j(Sf(s({},{key:zo,transport:{emit:(e,t)=>g.postMessage(e,u,t??[]),receive:e=>qi(window,`message`,t=>{T(t)&&e(t.data,{source:t.source,origin:t.origin})})},unregisterSignal:_.signal,revivableModules:_f(Le)}),Vo,`cloud.attachFrame: timed out connecting to the window`));v=!0,clearInterval(O);let t=0,r=setInterval(()=>{Sf(w(()=>e.ping()),Kf,`ping`).then(()=>{t=0},()=>{_.signal.aborted||(document.visibilityState===`hidden`?t=0:++t>=qf&&b(ep(),!0))})},Gf);_.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),D&&await j(Sf(Vf(e,D),Wf,`cloud.attachFrame: the window never became ready`)),await j(Sf(e.ready(),Wf,`cloud.attachFrame: the window never became ready`)),n!==void 0&&await j(Mf(e,n)),Xo(`attached frame`,_.signal);let c=zf({control:e,target:o,session:f,declaredHosts:p,approvedOrigins:m,attach:d,assertLive:C,guard:w,consent:{request:t=>w(()=>e.requestConsent(t)),ensure:t=>w(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:Lf({from:()=>g,origin:u,attach:d,signal:_.signal})}),l=null,h=Object.assign(c,{close:()=>l??=(async()=>{_.signal.aborted||await Sf(Promise.allSettled([w(()=>e.flushCookies()),w(()=>e.sweepStorage())]),Jf,`close`).catch(()=>{});try{g.close()}catch{}b($f())})(),closed:S});return D?rs(h,D):E.then(e=>rs(h,e)),n!==void 0&&o&&await j(h.goto(o)),i?.length&&await j(h.requestPermissions(i)),h}catch(e){let t=y??e;if(!(t instanceof pr))try{g.close()}catch{}throw b(t),t}},ip=2e4,ap=65e3,op=e=>!e||e===`about:blank`,sp=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,cp=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,lp=e=>e.split(`#`)[0]??``,up=({iframe:e,lockdown:t,cookies:n,blank:r})=>{if(r===void 0)return``;if(typeof r!=`object`||!r)throw TypeError(`attachFrame: blank must be an object { url }`);let i=Object.keys(r).find(e=>e!==`url`);if(i!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${i}"`);let{url:a}=r,o=(()=>{try{return typeof a==`string`?new URL(a):null}catch{return null}})();if(!o||o.protocol!==`http:`&&o.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(a)}"`);let s=e.getAttribute(`src`)??``;if(!op(s))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);if(t)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(n===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(ar(o.href),!xp())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return o.href},dp=({target:e,blank:t,session:n,domains:r,attach:i,relay:a})=>{let o=new URL(`/attach-frame`,bf());return t?o.searchParams.set(`blank`,t):e&&o.searchParams.set(`url`,e),n&&o.searchParams.set(`session`,n),r.length&&o.searchParams.set(`domains`,r.join(`,`)),o.searchParams.set(`attach`,i),a&&o.searchParams.set(`relay`,a),o.href},fp=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{e.isConnected&&e.parentNode===r||(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},pp=()=>Cf(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),mp=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},hp=[300,1200,4e3],gp=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of hp)setTimeout(t,e)},_p=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},vp=async(e,t)=>{let n=typeof e.blank==`function`?await Sf(e.blank(),ap,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof n!=`string`||lp(n)!==lp(t))throw Ht(sp,`blank`,`cloud`)},yp=async(e,t,n)=>{let r=up(e),{iframe:i,domains:a=[],permissions:o,relay:c}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!i.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);_p(i);let l=i.getAttribute(`src`)??``,u=(()=>{if(op(l))return null;try{return new URL(i.src||l,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${l}`)}})();if(u){let e=new URL(`/attach-frame`,bf());if(u.origin===e.origin&&u.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let d=u?.href??``;d&&ar(d);let f=n===void 0?d:``,p=xf(t),m=R(a),h=/* @__PURE__ */ new Set;try{h.add(new URL(r||d).origin)}catch{}let g=Bf(c),_=c===void 0?void 0:await g,v=new AbortController,y=i.referrerPolicy,b=i.allow,x=crypto.randomUUID();if(i.referrerPolicy=`origin`,i.allow=mp(Wi(),i.allow),i.src=dp({target:f,blank:r,session:p,domains:m,attach:x,relay:_}),!i.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await Sf(s({},{key:Ro,origin:bf(),transport:{receive:window,emit:i.contentWindow},unregisterSignal:v.signal,revivableModules:_f(Le)}),ip,`cloud.attachFrame: timed out connecting to the render proxy page`);_&&await Sf(Vf(e,_),ap,`cloud.attachFrame: the render proxy never became ready`),await Sf(e.ready(),ap,`cloud.attachFrame: the render proxy never became ready`),r&&await vp(e,r),n!==void 0&&await Mf(e,n),(d||r)&&gp(i),fp(i,()=>v.abort()),Xo(`attached frame`,v.signal);let t=i.contentWindow,a=zf({control:e,target:r||d,blank:r!==``,session:p,declaredHosts:m,approvedOrigins:h,attach:x,assertLive:()=>{if(v.signal.aborted||!i.isConnected||i.contentWindow!==t)throw v.abort(),pp()},guard:e=>e(),consent:lf,onNavigated:()=>gp(i),relay:Lf({from:()=>t,origin:bf(),attach:x,signal:v.signal})});return _?rs(a,_):g.then(e=>rs(a,e)),n!==void 0&&d&&await a.goto(d),o?.length&&await a.requestPermissions(o),a}catch(e){throw v.abort(),i.referrerPolicy=y,i.allow=b,i.src=f||`about:blank`,e}},bp=(async e=>{let{kind:t,cookies:n,storageState:r}=fi(e);if(n===`native`)throw TypeError(cp);return t===`window`?rp(e,n,r):yp(e,n,r)}),xp=()=>typeof window<`u`&&!0,Sp=async()=>{let e=await U.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},Cp=/* @__PURE__ */ g({attachFrame:()=>bp,available:()=>wp,dgram:()=>Dd,dns:()=>ys,fetch:()=>us,fs:()=>pl,http:()=>Id,net:()=>bd,quota:()=>Sp}),wp=()=>Ji,Tp=/* @__PURE__ */ g({info:()=>Op,login:()=>Ep,logout:()=>Dp,onChange:()=>kp}),Ep=async()=>typeof window>`u`?!1:(await U).account.login(location.origin).catch(()=>!1),Dp=async()=>{typeof window<`u`&&await(await U).account.logout().catch(()=>{})},Op=async()=>{if(typeof window>`u`)return null;let e=await U.then(e=>e.account.info()).catch(()=>null);return e?{name:e.name,image:e.image,premium:e.premium,premiumUntil:e.premiumUntil?Date.parse(e.premiumUntil):null}:null},kp=async e=>Ji?jc(e):()=>{},Ap=/* @__PURE__ */ g({available:()=>Pp,list:()=>Rp,readFile:()=>Ip,remove:()=>Lp,writeFile:()=>Fp}),jp=()=>navigator.storage.getDirectory(),Mp=e=>{let t=e.split(`/`).filter(e=>e&&e!==`.`);if(t.some(e=>e===`..`)||!t.length)throw Error(`opfs: invalid path`);return t},Np=async(e,t)=>{let n=await jp();for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n},Pp=async()=>{try{return typeof navigator<`u`&&!!navigator.storage?.getDirectory&&!!await jp()}catch{return!1}},Fp=async(e,t,n)=>{let r=Mp(e),i=r.pop(),a=await(await(await Np(r,!0)).getFileHandle(i,{create:!0})).createWritable({keepExistingData:!1});try{let e=t instanceof Blob?t:new Blob([t],n?.contentType?{type:n.contentType}:void 0);await a.write(e)}finally{await a.close()}},Ip=async e=>{let t=Mp(e),n=t.pop();return(await(await Np(t,!1)).getFileHandle(n)).getFile()},Lp=async e=>{let t=Mp(e),n=t.pop();await(await Np(t,!1)).removeEntry(n,{recursive:!0})},Rp=async()=>{let e=[],t=async(n,r)=>{for await(let[i,a]of n.entries()){let n=r?`${r}/${i}`:i;if(a.kind===`file`){let t=await a.getFile();e.push({path:n,size:t.size,contentType:t.type||null,updatedAt:new Date(t.lastModified).toISOString()})}else await t(a,n)}};return await t(await jp(),``),e},zp=/* @__PURE__ */ g({adopt:()=>Km,adoptable:()=>Jm,available:()=>Gp,captureAccount:()=>Bp,list:()=>Om,onConflict:()=>Fm,pending:()=>fm,pendingDeletes:()=>pm,pull:()=>Nm,readFile:()=>km,readFileSealed:()=>Am,remove:()=>Mm,replicating:()=>mm,writeFile:()=>jm}),Bp=Y,Vp,Hp=async()=>await(Vp??=Pp().catch(()=>!1))?!0:(Vp=void 0,!1),Up=()=>rl().catch(()=>`unknown`),Wp=async()=>await Up()===`connected`,Gp=async()=>await Hp()||await Wp(),Kp=`fkn:fs:pending`,qp=`fkn:fs:pending-delete`,Jp=`fkn:fs:adopt-declined`,Yp=!0,Xp=/* @__PURE__ */ new Map,Zp=null,Qp=(e,t)=>{if(e===null)return!1;if(`generation`in e&&`generation`in t)return e.generation===t.generation;let n=e=>`pin`in e?e.pin:qc(e),r=n(e);return r!==void 0&&r===n(t)},$p=(e,t)=>Qp(Zp,t)?Xp.get(e)??null:null,em=e=>e===`write`?Kp:qp,tm=e=>{try{let t=localStorage.getItem(em(e));if(!t)return{};let n=JSON.parse(t);if(Array.isArray(n))return Object.fromEntries(n.filter(e=>typeof e==`string`).map(e=>[e,{base:null,pin:null}]));if(!n||typeof n!=`object`)return{};let r={};for(let[e,t]of Object.entries(n))if(t===null||typeof t==`string`)r[e]={base:t,pin:null};else if(typeof t==`object`){let{base:n,pin:i}=t;r[e]={base:typeof n==`string`?n:null,pin:typeof i==`string`&&i?i:null}}return r}catch{return{}}},nm=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(em(e),JSON.stringify(t)):localStorage.removeItem(em(e))}catch{}},rm=()=>{try{let e=JSON.parse(localStorage.getItem(Jp)??`{}`);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}},im=/* @__PURE__ */ new Map,am=e=>`pin`in e?e.pin:qc(e)??null,om=(e,t,n,r)=>{let i=tm(e),a=i[t],o=am(r);a&&o!==null&&a.pin===o||(i[t]={base:a?a.base:n,pin:o},nm(e,i),o===null&&`generation`in r?im.set(`${e}:${t}`,r):im.delete(`${e}:${t}`))},sm=(e,t)=>{im.delete(`${e}:${t}`);let n=tm(e);t in n&&(delete n[t],nm(e,n),bm()||(Cm=xm))},cm=(e,t,n)=>om(`write`,e,t,n),lm=e=>sm(`write`,e),um=(e,t)=>om(`delete`,e,$p(e,t),t),dm=e=>sm(`delete`,e),fm=()=>Object.keys(tm(`write`)),pm=()=>Object.keys(tm(`delete`)),mm=()=>Yp,hm=/* @__PURE__ */ new Map,gm=e=>hm.get(e)===Y().generation,_m=(e,t,n)=>n.pin===null&&!im.has(`${e}:${t}`),vm=null,ym=!1;Zo(`storage replication`,()=>vm!==null||Zm!==null);var bm=()=>[`write`,`delete`].some(e=>Object.entries(tm(e)).some(([t,n])=>n.pin===null?!_m(e,t,n):!gm(n.pin))),xm=6e4,Sm=6e5,Cm=xm,wm=null,Tm=()=>{!wm&&typeof window<`u`&&bm()&&(wm=setTimeout(()=>{wm=null,Em()},Cm),Cm=Math.min(Cm*2,Sm))},Em=()=>{vm?ym=!0:bm()&&(vm=Um(!1,Y()).then(e=>{bm()?e.failed.length&&Tm():Cm=xm}).catch(()=>{Tm()}).finally(()=>{vm=null,Dm()}))},Dm=()=>{ym&&(ym=!1,Em())},Om=async e=>{let t=e?.pin??Y();ih();let n=await Up(),r=n===`connected`,[i,a]=await Promise.all([Hp().then(e=>e?Rp():[]).catch(()=>[]),r?il({pin:t}).then(e=>({ok:!0,entries:e}),e=>({ok:!1,entries:[],changed:zc(e)?e:void 0})):Promise.resolve({ok:n===`disconnected`,entries:[]})]);if(n!==`unknown`&&(Yp=a.ok),a.ok&&n!==`unknown`&&(Xp=new Map(a.entries.map(e=>[e.path,e.updatedAt])),Zp=t),a.changed)throw a.changed;let o=/* @__PURE__ */ new Map,s=e=>{let t=Date.parse(e.updatedAt??``);return Number.isFinite(t)?t:0},c=e=>{let t=o.get(e.path);(!t||s(e)>=s(t))&&o.set(e.path,e)};for(let e of i)c(e);for(let e of a.entries)c(e);return a.ok&&r&&(nh(i,a.entries).catch(()=>{}),bm()?Em():$m({local:i,remote:a.entries,from:t}).catch(()=>{})),[...o.values()]},km=async(e,t)=>{let n=t?.pin??Y();if(await Hp())try{return await Ip(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await ol(e,{pin:n});return await Hp()&&Fp(e,r).catch(()=>{}),r},Am=async(e,t)=>{let n=t?.pin??Y();if(await Hp())try{let t=await Ip(e);return{data:new Uint8Array(await t.arrayBuffer()),sealedAt:null}}catch(e){if(e?.name!==`NotFoundError`)throw e}return cl(e,{pin:n})},jm=async(e,t,n)=>{let r=n?.pin??Y(),i=n?.contentType,a=i?{contentType:i}:void 0,o=t instanceof Blob?t:new Blob([t],a?{type:a.contentType}:void 0);if(await Hp()){await Fp(e,o,a),ih();let t=$p(e,r),n=await Up();if(n===`disconnected`)return;if(n===`unknown`||!Yp){cm(e,t,r),Tm();return}ll(e,o,{...a,pin:r}).then(()=>lm(e)).catch(n=>{cm(e,t,r),zc(n)||Tm(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let s=await Up();if(s===`connected`)return ll(e,o,{...a,pin:r});throw Error(s===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},Mm=async(e,t)=>{let n=t?.pin??Y();ih();let r=[];await Hp()&&r.push(Lp(e).catch(()=>{}));let i=await Up();if(i===`connected`?r.push(ul(e,{pin:n}).then(()=>dm(e)).catch(t=>{um(e,n),zc(t)||Tm(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):i===`unknown`&&r.length&&$p(e,n)!==null&&(um(e,n),Tm()),!r.length)throw Error(i===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);lm(e),await Promise.all(r)},Nm=async e=>{let t=await ol(e,{pin:Y()});return await Hp()&&await Fp(e,t),t},Pm=null,Fm=e=>(Pm=e,()=>{Pm===e&&(Pm=null)}),Im=async e=>{let t=await(await U).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null);return t===`local`?e.readLocal():t===`cloud`?e.readCloud():null},Lm=async e=>{if(Pm)try{return await Pm(e)}catch{return null}return Im(e)},Rm=class extends Error{},zm=e=>e instanceof Error?e.message:String(e),Bm=()=>{let e=/* @__PURE__ */ new Map,t=t=>{let n=e.get(t);return n||e.set(t,n={writes:/* @__PURE__ */ new Map,deletes:/* @__PURE__ */ new Map}),n};for(let[e,n]of Object.entries(tm(`write`)))t(n.pin).writes.set(e,n.base);for(let[e,n]of Object.entries(tm(`delete`)))t(n.pin).deletes.set(e,n.base);return e},Vm=async()=>{for(let[e,t]of[...im]){let n=e.startsWith(`write:`)?`write`:`delete`,r=e.slice(n.length+1),i;try{i=await Jc(t)}catch(t){zc(t)&&im.delete(e);continue}if(im.get(e)!==t)continue;im.delete(e);let a=tm(n),o=a[r];o&&o.pin===null&&(a[r]={base:o.base,pin:i},nm(n,a))}},Hm=async(e,t,n,r,i,a)=>{let o=new Map(t.map(e=>[e.path,e])),s=e=>{if(zc(e))throw new Rm};for(let[t,a]of e.deletes){let e=o.get(t);if(!e)dm(t);else if(r.some(e=>e.path===t))dm(t);else if(e.updatedAt!==a)dm(t);else try{await ul(t,n),dm(t),i.deleted.push(t)}catch(e){s(e),i.failed.push({path:t,error:zm(e)})}}for(let t of r){let r=o.get(t.path),c=e.writes.has(t.path);if(!c){if(!a(t))continue;if(r){i.kept.push(t.path);continue}}let l=e.writes.get(t.path)??null;if(c&&r&&r.updatedAt!==l){let e=null,a=null,o=await Lm({path:t.path,local:{size:t.size,updatedAt:t.updatedAt},cloud:{size:r.size,updatedAt:r.updatedAt},readLocal:()=>e??=Ip(t.path),readCloud:()=>a??=ol(t.path,n)});if(o==null){i.unresolved.push(t.path);continue}try{let r=e!==null&&o===await e,s=a!==null&&o===await a;s||await ll(t.path,o,t.contentType?{contentType:t.contentType,...n}:n),r||await Fp(t.path,o),lm(t.path),i.resolved.push({path:t.path,choice:r?`local`:s?`cloud`:`merged`})}catch(e){if(s(e),e?.code===`FKN_E2E_LOCKED`)throw e;i.failed.push({path:t.path,error:zm(e)})}}else try{let e=await Ip(t.path);await ll(t.path,e,t.contentType?{contentType:t.contentType,...n}:n),lm(t.path),i.uploaded.push(t.path)}catch(e){if(c||cm(t.path,r?.updatedAt??null,n.pin),s(e),e?.code===`FKN_E2E_LOCKED`)throw e;i.failed.push({path:t.path,error:zm(e)})}}},Um=async(e,t)=>{let n={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},r=await Up();if(r===`unknown`)throw Error(`fs: cloud unreachable`);if(r!==`connected`)throw Error(`fs: this needs a signed-in account`);let i=await Hp(),a=i?await Rp():[];if(i)for(let e of Object.keys(tm(`write`)))a.some(t=>t.path===e)||lm(e);await Vm();for(let[e,r]of Bm()){if(e===null||gm(e))continue;let i={pin:{pin:e}},o;try{o=await il(i)}catch(n){if(zc(n)){hm.set(e,t.generation);continue}if(Bc(n)){Wm(e);continue}throw n}try{await Hm(r,o,i,a,n,()=>!1)}catch(n){if(!(n instanceof Rm))throw n;hm.set(e,t.generation)}}if(e){let e={pin:t},r=await il(e),i=tm(`write`),o=Bm().get(null)??{writes:/* @__PURE__ */ new Map,deletes:/* @__PURE__ */ new Map},s=/* @__PURE__ */ new Set([...n.uploaded,...n.resolved.map(({path:e})=>e),...n.unresolved,...n.failed.map(({path:e})=>e)]),c=e=>!(e.path in i)&&!s.has(e.path);try{await Hm(o,r,e,a,n,c)}catch(e){throw e instanceof Rm?new Lc:e}}return n},Wm=e=>{for(let t of[`write`,`delete`]){let n=tm(t),r=!1;for(let t of Object.values(n))t.pin===e&&(t.pin=null,r=!0);r&&nm(t,n)}},Gm=async e=>{for(;vm;)await vm;let t=Um(!0,e);vm=t.then(()=>{},()=>{});try{return await t}finally{vm=null,Dm()}},Km=()=>Gm(Y()),qm=(e,t)=>{let n=new Set(t.map(e=>e.path)),r=tm(`write`);return e.filter(e=>{let t=r[e.path];return t?_m(`write`,e.path,t):!n.has(e.path)})},Jm=async()=>{let e=Y();if(!await Wp()||!await Hp())return{paths:[],bytes:0};let[t,n]=await Promise.all([Rp(),il({pin:e})]),r=qm(t,n);return{paths:r.map(e=>e.path),bytes:r.reduce((e,t)=>e+t.size,0)}},Ym=()=>new Set(Object.keys(rm())),Xm=e=>{let t=rm();for(let n of e)t[n]=null;try{localStorage.setItem(Jp,JSON.stringify(t))}catch{}},Zm=null,Qm=!1,$m=e=>{if(Zm)return Qm=!0,Zm;let t=e?.from??Y();return Zm=(async()=>{if(!await Wp())return;let n=e??(await Hp()?{local:await Rp(),remote:await il({pin:t})}:null);if(!n)return;let r=Ym(),i=qm(n.local,n.remote).filter(e=>!r.has(e.path));if(!i.length)return;let a=await U,o=i.reduce((e,t)=>e+t.size,0);await a.cloud.fs.promptAdopt({files:i.length,bytes:o}).catch(()=>!1)?`generation`in t&&await Gm(t):Xm(i.map(e=>e.path))})().catch(()=>{}).finally(()=>{Zm=null,Qm&&(Qm=!1,$m())}),Zm},eh=null,th=!1,nh=async(e,t)=>{let n=qm(e,t),r=await U,i=async()=>{await Km().catch(()=>{});let e=await Jm().catch(()=>({paths:[],bytes:0}));await r.cloud.fs.setAdoptSource({files:e.paths.length,bytes:e.bytes},i).catch(()=>{})},a={files:n.length,bytes:n.reduce((e,t)=>e+t.size,0)};eh=()=>{r.cloud.fs.setAdoptSource(a,i).catch(()=>{})},th||(th=!0,Io((e,t)=>{t>1&&eh?.()})),await r.cloud.fs.setAdoptSource(a,i)},rh=!1,ih=()=>{rh||typeof window>`u`||(rh=!0,qi(window,`online`,()=>{Em()}),kp(()=>{$m().catch(()=>{}),Em()}).catch(()=>{}))},ah=_c(zp,{memfs:!0}),{available:oh,readFileSync:sh,writeFileSync:ch,appendFileSync:lh,existsSync:uh,statSync:dh,lstatSync:fh,readdirSync:ph,mkdirSync:mh,rmSync:hh,rmdirSync:gh,unlinkSync:_h,renameSync:vh,readFile:yh,writeFile:bh,appendFile:xh,stat:Sh,readdir:Ch,mkdir:wh,rm:Th,unlink:Eh,rename:Dh,exists:Oh,promises:kh,mount:Ah,flush:jh,remount:Mh}=ah;({...ah});var{available:Nh,readFileSync:Ph,writeFileSync:Fh,appendFileSync:Ih,existsSync:Lh,statSync:Rh,lstatSync:zh,readdirSync:Bh,mkdirSync:Vh,rmSync:Hh,rmdirSync:Uh,unlinkSync:Wh,renameSync:Gh,readFile:Kh,writeFile:qh,appendFile:Jh,stat:Yh,readdir:Xh,mkdir:Zh,rm:Qh,unlink:$h,rename:eg,exists:tg,promises:ng,mount:rg,flush:ig,remount:ag}=_c(Ap,{memfs:!0}),og=/* @__PURE__ */ g({attach:()=>Pg,connect:()=>Og,hide:()=>Dg,install:()=>hg,isVisible:()=>Jg,list:()=>_g,mount:()=>Ng,onConnect:()=>qg,onVisibilityChange:()=>Yg,pick:()=>mg,search:()=>pg,show:()=>Eg,supportsTemporary:()=>gg,uninstall:()=>vg}),sg=`fkn-packages-connection`,cg=`https://fkn.app`,lg=3e4,X=(e,t)=>Object.assign(Error(t),{code:e}),ug=async()=>{if(!Ji)throw X(`unavailable`,`packages: no FKN transport in this realm - use relayWorker to bridge workers`);return U},dg=(e,t,n)=>s(e??{},{transport:t,key:sg,unregisterSignal:n}),fg=async(e,t,n={})=>{let{signal:r,closed:i}=n;if(r?.aborted)throw X(`unavailable`,`packages.connect: aborted before connecting`);let a=new AbortController;r&&r.addEventListener(`abort`,()=>a.abort(r.reason),{once:!0});let o=new AbortController,s=new Promise((e,n)=>{let a=setTimeout(()=>n(X(`timeout`,`packages.connect: the package did not complete the connection`)),lg);o.signal.addEventListener(`abort`,()=>clearTimeout(a),{once:!0}),t.addEventListener(`message`,e=>{if(e.data?.type===`fkn-packages-nack`){let t=e.data.message;n(X(`unavailable`,typeof t==`string`&&t?t:`packages.connect: the package refused the connection`))}},{signal:o.signal}),t.start(),r&&r.addEventListener(`abort`,()=>n(X(`unavailable`,`packages.connect: aborted before connecting`)),{once:!0,signal:o.signal}),i?.then(()=>n(X(`unavailable`,`packages.connect: the package closed before connecting`)))});try{return await Promise.race([dg(e,t,a.signal),s])}catch(e){a.abort(e);try{t.close()}catch{}throw e}finally{o.abort()}},pg=async e=>{let t=await(await ug()).packages.search(e);if(`error`in t)throw X(t.error,t.message);return t.results},mg=async(e,t)=>{let n=await(await ug()).packages.pick(e,t);if(`error`in n)throw X(n.error,n.message);return`declined`in n?[]:n.results},hg=async(e,t)=>{let{packages:n}=await ug(),r=t?.temporary?n.installTemporary:n.install;if(!r)throw X(`unsupported`,`packages.install: this fkn.app cannot install a package temporarily`);let i=await r(e,t);if(`error`in i)throw X(i.error,i.message);return`declined`in i?null:i.installed},gg=async()=>typeof(await ug()).packages.installTemporary==`function`,_g=async()=>(await(await ug()).packages.list()).results,vg=async e=>{let t=await(await ug()).packages.uninstall(e);if(`error`in t)throw X(t.error,t.message)},yg=({x:e,y:t,width:n,height:r})=>({x:Math.round(e),y:Math.round(t),width:Math.round(n),height:Math.round(r)}),bg=(e,t)=>{let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y);return{x:n,y:r,width:Math.max(0,Math.min(e.x+e.width,t.x+t.width)-n),height:Math.max(0,Math.min(e.y+e.height,t.y+t.height)-r)}},xg=(e,t)=>{let n=t;for(let t=e.parentElement;t;t=t.parentElement){let e=getComputedStyle(t);if((e.overflowX!==`visible`||e.overflowY!==`visible`)&&(n=bg(n,yg(t.getBoundingClientRect())),n.width===0||n.height===0))break}return n},Sg=e=>{let t=getComputedStyle(e),n=[t.borderTopLeftRadius,t.borderTopRightRadius,t.borderBottomRightRadius,t.borderBottomLeftRadius];if(n.some(e=>e.includes(`%`)||e.includes(` `)))return;let r=n.map(e=>{let t=Number.parseFloat(e);return Number.isFinite(t)&&t>0?t:0});return r.some(e=>e>0)?r:void 0},Cg=(e,t)=>{if(!e)return!1;let n=(e,t)=>e===t||!!e&&!!t&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;return n(e.rect,t.rect)&&n(e.clip,t.clip)&&((e,t)=>e===t||!!e&&!!t&&e.every((e,n)=>e===t[n]))(e.radius,t.radius)},wg=/* @__PURE__ */ new Map;Zo(`package view`,()=>wg.size>0);var Tg=async(e,t)=>{let n=wg.get(e);if(n){for(let e of n)t&&e.element!==t||(e.stop(),n.delete(e));if(n.size>0)return;wg.delete(e)}let r=await(await ug()).packages.hide(e);if(`error`in r)throw X(r.error,r.message)},Eg=async(e,t)=>{let{element:n,rect:r}=t;if(!n&&!r)throw X(`invalid`,`packages.show: pass an element or a rect`);let i=(await ug()).packages,a=()=>{if(!n)return{rect:yg(r)};let e=yg(n.getBoundingClientRect());return{rect:e,clip:xg(n,e),radius:Sg(n)}},o=!0,s,c=0,l=async t=>{s=t;let n=await i.show(e,t);if(`error`in n)throw o=!1,X(n.error,n.message)};await l(a());let u=()=>{if(!o)return;let e=a();Cg(s,e)||l(e).catch(()=>{}),c=requestAnimationFrame(u)};n&&(c=requestAnimationFrame(u));let d={element:n,stop:()=>{o=!1,cancelAnimationFrame(c)}},f=wg.get(e)??/* @__PURE__ */ new Set;return f.add(d),wg.set(e,f),{hide:()=>{Tg(e,n).catch(()=>{})},refresh:()=>{if(!o)return;let e=a();Cg(s,e)||l(e).catch(()=>{})}}},Dg=async(e,t={})=>Tg(e,t.element),Og=(async(e,t={})=>{let n=await(await ug()).packages.connect(e,{protocol:t.protocol,...t.path===void 0?{}:{path:t.path}});if(`error`in n)throw X(n.error,n.message);let r=Yo(`package connection`),i=Lo()?.epoch??0,a=Io((e,t)=>{t!==i&&(r(),a())});Promise.resolve(n.closed).then(()=>{r(),a()},()=>{r(),a()});let{port:o,closed:s}=n;if(t.raw)return{closed:s,port:o};let c=await fg(t.payload,o,{signal:t.signal,closed:s});return t.signal&&t.signal.addEventListener(`abort`,()=>{try{o.postMessage({type:`fkn-packages-disconnect`})}catch{}},{once:!0}),{remote:c,closed:s,port:o}}),kg=[`allow-scripts`,`allow-same-origin`],Ag=e=>{let t=e.getAttribute(`sandbox`);if(t!==null){let e=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),n=kg.filter(t=>!e.has(t));if(n.length)throw X(`invalid`,`packages.mount: the iframe's sandbox attribute must include ${n.join(` and `)}, or the package cannot start`)}if(globalThis.crossOriginIsolated&&!new Set((e.getAttribute(`allow`)??``).toLowerCase().split(`;`).map(e=>e.trim().split(/\s+/)[0]).filter(Boolean)).has(`cross-origin-isolated`))throw X(`invalid`,`packages.mount: this page is cross-origin isolated, so the iframe's allow attribute must include 'cross-origin-isolated' to hand that down to the package`)},jg=3e4,Mg=(e,t)=>new Promise((n,r)=>{let i=e=>{clearTimeout(o),window.removeEventListener(`message`,a),e?r(e):n()},a=n=>{if(n.source!==e.contentWindow||n.origin!==t)return;let r=n.data;if(r?.type===`fkn-packages-ready`)return i();r?.type===`fkn-packages-failed`&&i(X(`unavailable`,typeof r.message==`string`&&r.message?r.message:`packages.mount: the package failed to boot`))},o=setTimeout(()=>i(X(`timeout`,`packages.mount: the package did not register a connection handler`)),jg);window.addEventListener(`message`,a)}),Ng=async(e,t)=>{let{iframe:n}=t;if(!(n instanceof HTMLIFrameElement))throw X(`invalid`,`packages.mount: pass the iframe to load the package into`);if(!n.isConnected)throw X(`invalid`,`packages.mount: the iframe must be in the document before mounting into it`);Ag(n);let r=await(await ug()).packages.frame(e);if(`error`in r)throw X(r.error,r.message);n.src=r.url;let i=new AbortController;n.addEventListener(`load`,()=>{try{n.contentWindow?.postMessage({type:`fkn-packages-mount`},r.origin)}catch{}},{signal:i.signal});let a={done:!1},o=()=>{},s=new Promise(e=>{o=e}),c=Yo(`mounted package`),l=()=>{if(a.done)return;a.done=!0,i.abort(),c();try{n.contentWindow?.postMessage({type:`fkn-packages-close`},r.origin)}catch{}let e=()=>{try{if(n.contentWindow?.location.href!==`about:blank`)return;n.contentWindow.name=``}catch{return}n.removeEventListener(`load`,e)};n.addEventListener(`load`,e),n.src=`about:blank`,o()};try{await Mg(n,r.origin)}catch(e){throw l(),e}let u=new MessageChannel,d=n.contentWindow;if(!d)throw l(),X(`unavailable`,`packages.mount: the frame was detached before it could connect`);d.postMessage({type:`fkn-packages-port`,from:r.from,protocol:t.protocol,uri:r.uri,name:r.name,version:r.version},r.origin,[u.port2]);try{d.postMessage({type:`fkn-packages-visibility`,visible:!0},r.origin)}catch{}if(t.raw)return{closed:s,port:u.port1,frame:n,unmount:l};try{return{remote:await fg(t.payload,u.port1,{signal:t.signal,closed:s}),closed:s,port:u.port1,frame:n,unmount:l}}catch(e){throw l(),e}},Pg=(e,t,n)=>fg(t,e,{signal:n?.signal}),Fg=null,Ig=!1,Lg=/* @__PURE__ */ new Set,Rg=[],zg=/* @__PURE__ */ new Map,Bg=!1,Vg=!1,Hg=e=>{let t=zg.get(e);t&&(zg.delete(e),t())},Ug=(e,t)=>{try{e.postMessage({type:`fkn-packages-nack`,message:t})}catch{}try{e.close()}catch{}},Wg=async(e,t)=>{let{port:n,...r}=e;e.port.addEventListener(`message`,t=>{t.data?.type===`fkn-packages-disconnect`&&Hg(e.port)});let i;try{i=await t.createPayload(r)}catch(t){throw Ug(e.port,t instanceof Error?t.message:`the package failed to produce a connection`),t}let a=new Promise(t=>zg.set(e.port,t)),o=await dg(i,e.port);t.handler?.({...r,remote:o,closed:a,port:e.port})},Gg=()=>{Bg||typeof window>`u`||window.parent===window||(Bg=!0,qi(window,`message`,e=>{if(e.source!==window.parent)return;let t=e.data;if(t?.type===`fkn-packages-port`){let n=e.ports[0];if(!n)return;let r={port:n,from:typeof t.from==`string`?t.from:``,brokered:e.origin===cg,protocol:typeof t.protocol==`string`?t.protocol:null,uri:typeof t.uri==`string`?t.uri:``,name:typeof t.name==`string`?t.name:``,version:typeof t.version==`string`?t.version:``};Fg?Wg(r,Fg).catch(e=>console.warn(`packages.onConnect:`,e)):Rg.push(r)}if(t?.type===`fkn-packages-close`)for(let e of[...zg.keys()])Hg(e);if(t?.type===`fkn-packages-visibility`){Ig=t.visible===!0;for(let e of Lg)try{e(Ig)}catch{}}}))},Kg=()=>{Vg||typeof window>`u`||window.parent===window||(Vg=!0,window.parent.postMessage({type:`fkn-packages-ready`},`*`))},qg=(e,t)=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Gg();let n={createPayload:e,handler:t};for(Fg=n,Kg();Rg.length&&Fg===n;)Wg(Rg.shift(),n).catch(e=>console.warn(`packages.onConnect:`,e));return{unsubscribe:()=>{Fg===n&&(Fg=null)}}},Jg=()=>Ig,Yg=e=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Gg(),Lg.add(e);try{e(Ig)}catch{}return{unsubscribe:()=>{Lg.delete(e)}}},Xg=/* @__PURE__ */ g({available:()=>h_,create:()=>v_,join:()=>y_,open:()=>__}),Z={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,notClaimingApp:`rooms: only the app that claimed the room can change it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,mailboxUnavailable:`rooms: the mailbox switch is not available`,guestUnavailable:`rooms: guest joins are not available`,schemasUnavailable:`rooms: room schemas are not available`,bytesUnavailable:`rooms: binary messages are not available`,badSchema:`rooms: the schema is not one a room can take`,newerSchema:`rooms: the room holds a newer schema`,noSchema:`rooms: the room has no schema`,misfit:`rooms: the message does not fit the room's schema`,ownerSends:`rooms: only the owner sends this type`,accountSends:`rooms: sending this needs an account`,perAccount:`rooms: you have as many of these here as the room allows`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},Q=(e,t)=>Object.assign(Error(t),{code:e}),Zg=e=>e instanceof Error&&typeof e.code==`string`,Qg={send:!0,receive:!0,maxMessageBytes:262144},$g=2048,e_=()=>({messages:0,bytes:0,cap:5e8,archived:!1}),t_=async()=>{if(!Ji)return;let e=(await Fo(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},n_=()=>{throw Q(`unavailable`,Z.unavailable)},r_=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,i_=e=>{if(e!==void 0&&e!==!1)return e===!0?Ho.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=Ho.min&&e<=Ho.max?e:null},a_=(e,t)=>{let n=t?e?.guest:e;return typeof n?.join==`function`?n:void 0},o_=e=>{let t;try{t=JSON.stringify(e)}catch{}let n=t===void 0?void 0:JSON.parse(t),r=typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.type==`string`;if(t===void 0||!r||t.length>$g)throw Q(`invalid`,Z.misfit);return t},s_=e=>{let t;try{t=JSON.parse(JSON.stringify(e))}catch{}if(typeof t!=`object`||!t||Array.isArray(t))throw Q(`invalid`,Z.badSchema);return t},c_=e=>e?.schema===void 0?e:{...e,schema:s_(e.schema)},l_=e=>{if(e.schemas!==!0)throw Q(`unavailable`,Z.schemasUnavailable);return e},u_=e=>{if(e.bytes!==!0)throw Q(`unavailable`,Z.bytesUnavailable);return e},d_=e=>{if(typeof e==`string`)return e;try{return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice():(Reflect.get(ArrayBuffer.prototype,`byteLength`,e),new Uint8Array(e).slice())}catch{throw Q(`invalid`,Z.malformed)}},f_=(e,t,n)=>{let r=typeof t==`string`?e:u_(e);return n===void 0?r:l_(r)},p_=e=>{let t=e?.guest;if(t!==void 0&&typeof t!=`boolean`)throw Q(`invalid`,Z.malformed);return t===!0},m_=async(e,t)=>{let n=e.invite,r=e,i=0,a=e.self,o=e.owner,s=e.claimed,c=e.mailbox,l=0,u=await e.defaults().catch(()=>Qg),d=e.schemas===!0?await Promise.resolve(e.schema()).catch(()=>null):null,f=0,p=!1,m=/* @__PURE__ */ new Set,h=/* @__PURE__ */ new Set,g=Yo(`room`),_=()=>{},v=()=>{},y=new Promise(e=>{v=e}),b=e=>{let t=[...h];h.clear();for(let n of t)try{n(e)}catch{}},x=e=>{p||(p=!0,_(),m.clear(),g(),b(Q(`closed`,Z.ended)),v({reason:e}))},S=e=>{if(p)return;let t=e;if(t.type===`defaults`&&(u=t.defaults),t.type===`schema`&&(f+=1,d=t.schema),t.type===`message`||t.type===`edited`){let e={...t.message,envelope:t.message.envelope??null};t=t.type===`message`?{...t,message:e}:{type:`edited`,message:e}}if(t.type===`permissions`&&t.id===a.id&&(a={id:a.id,permissions:t.permissions,maxMessageBytes:t.maxMessageBytes}),t.type===`claim`){l+=1;let e=t.claimed&&t.mailbox!==!1;t={type:`claim`,claimed:t.claimed,owner:t.owner,mailbox:e},s=t.claimed,o=t.owner,c=e?e_():null}for(let e of[...m])try{e(t)}catch{}},C=(e,t)=>{Promise.resolve(e.on(S)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===i&&x(e.reason)},()=>{})},w=async(e,l)=>{let f=a_(e,t);if(!f)return x(`unavailable`);let m=await f.join(n).catch(()=>void 0);if(p||l!==i)return;if(!m)return x(`unavailable`);if(`error`in m)return x(r_(m.error));if(m.self.id!==a.id)return Promise.resolve(m.leave()).catch(()=>{}),x(`unavailable`);r=m,a=m.self,o=m.owner,s=m.claimed,c=m.mailbox,C(m,l);let h=await m.defaults().catch(()=>void 0);if(h&&!p&&l===i&&(u=h),m.schemas!==!0)return;let g=await Promise.resolve(m.schema()).catch(()=>void 0);g!==void 0&&!p&&l===i&&(d=g)};_=Io((e,t)=>{let n=i;i=t,!(p||n===0||n===t)&&(b(Q(`unavailable`,Z.unavailable)),w(e.rooms,t))}),C(e,i);let T=async e=>{if(p)throw Q(`closed`,Z.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});h.add(t);try{return await Promise.race([Promise.resolve(e(r)),n])}catch(e){throw Zg(e)?e:Q(`unavailable`,Z.unavailable)}finally{h.delete(t)}},E=async e=>{let t=await T(e);if(`error`in t)throw Q(t.error,t.message)},D=async e=>{let t=await T(e);if(typeof t==`object`&&t&&`error`in t)throw Q(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:n,get self(){return a},get owner(){return o},get claimed(){return s},get mailbox(){return c},defaults:()=>u,members:()=>T(e=>e.members()),schema:()=>d,send:async(e,t)=>{let n=d_(e);if(t===void 0)return E(e=>f_(e,n,void 0).send(n));let r=o_(t);return E(e=>f_(e,n,r).send(n,r))},edit:async(e,t,n)=>{let r=d_(t);if(n===void 0)return E(t=>f_(t,r,void 0).edit(e,r));let i=o_(n);return E(t=>f_(t,r,i).edit(e,r,i))},setSchema:async e=>{let t=s_(e),n=f;await E(e=>l_(e).setSchema(t)),f===n&&(d=t)},delete:(e,t)=>E(n=>n.delete(e,t)),backlog:(e,t)=>D(n=>n.backlog(e,t)),setDefault:(e,t)=>E(n=>n.setDefault(e,t)),limit:(e,t)=>E(n=>n.limit(e,t)),grant:(e,t)=>E(n=>n.grant(e,t)),revoke:(e,t)=>E(n=>n.revoke(e,t)),remove:e=>E(t=>t.remove(e)),block:e=>E(t=>t.block(e)),unblock:e=>E(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw Q(`invalid`,Z.badDescription);let n=i_(e?.temporary);if(n===null)throw Q(`invalid`,Z.badTemporary);let r=e?.mailbox;if(r!==void 0&&typeof r!=`boolean`)throw Q(`invalid`,Z.malformed);let i={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n},...r===void 0?{}:{mailbox:r}};return Object.keys(i).length===0?E(e=>e.claim()):E(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw Q(`unavailable`,Z.temporaryUnavailable);if(r===!1&&e.mailboxSwitch!==!0)throw Q(`unavailable`,Z.mailboxUnavailable);return e.claim(i)})},setMailbox:async e=>{if(typeof e!=`boolean`)throw Q(`invalid`,Z.malformed);let t=l;await E(t=>{if(t.mailboxSwitch!==!0)throw Q(`unavailable`,Z.mailboxUnavailable);return t.setMailbox(e)}),l===t&&(e?c===null&&(c=e_()):c=null)},release:()=>E(e=>e.release()),usage:async()=>{let e=await D(e=>e.usage());return c=e,e},on:async e=>p?()=>{}:(m.add(e),()=>{m.delete(e)}),leave:async()=>{await Promise.resolve(r.leave()).catch(()=>{}),x(`left`)},closed:y}},h_=async()=>{let e=await t_();return e?e.available().catch(()=>!1):!1},g_=async(e,t,n)=>{let r=await t_();if(!r)throw Q(`unavailable`,Z.unavailable);let i=a_(r,e);if(!i)throw Q(`unavailable`,Z.guestUnavailable);let a=await n(i).catch(n_);if(`error`in a)throw Q(a.error,a.message);if(t?.schema!==void 0&&a.schemas!==!0)throw await Promise.resolve(a.leave()).catch(()=>{}),Q(`unavailable`,Z.schemasUnavailable);return m_(a,e)},__=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw Q(`invalid`,Z.badName);let n=p_(t),r=c_(t);return g_(n,r,t=>t.open(e,r))},v_=async e=>{let t=p_(e),n=c_(e);return g_(t,n,e=>e.create(n))},y_=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw Q(`invalid`,Z.inviteNoKey);return g_(p_(t),void 0,n=>n.join(e,t))},b_=new Map(Object.values(Uo).map(({code:e,message:t})=>[t,e]));new Set(b_.values());var x_=(async e=>{let{kind:t,cookies:n}=fi(e);if(t===`window`){let t=e;return n===`native`?Mi(t):bp(t)}let r=e;return n===`native`?S_(r):bp(r)}),S_=e=>(up(e),Mi(e)),C_=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let n=await co;if(!n)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);mo(),Xo(`relayed worker`,bo(n,e,t?.unregisterSignal))},w_=/* @__PURE__ */ new Set,T_=e=>(w_.add(e),()=>{w_.delete(e)}),E_=()=>{if(w_.size===0)return!1;for(let e of[...w_])try{e()}catch{}return!0},D_=(e,t)=>{if(typeof e?.onUpdateTaken==`function`)return Promise.resolve(e.onUpdateTaken(t))},O_=/* @__PURE__ */ g({applyUpdate:()=>V_,busyReasons:()=>B_,isAppTab:()=>H_,onUpdate:()=>F_,onUpdateTaken:()=>I_,updateReady:()=>k_}),k_=async()=>typeof window>`u`?!1:U.then(e=>e.shell?.updateReady()).then(e=>e===!0).catch(()=>!1),A_=/* @__PURE__ */ new Set,j_=!1,M_=()=>{j_=!0;for(let e of[...A_])try{e()}catch{}},N_=0,P_=()=>{let e=Lo();e&&A_.size!==0&&N_!==e.epoch&&(N_=e.epoch,j_=!1,Promise.resolve(e.remote.shell?.onUpdate(M_)).catch(()=>{N_===e.epoch&&(N_=0)}))};typeof window<`u`&&Io(P_);var F_=async e=>{if(typeof window>`u`)return()=>{};if(A_.add(e),j_)try{e()}catch{}return P_(),()=>{A_.delete(e)}},I_=e=>typeof window>`u`?()=>{}:T_(e),L_=0,R_=!1,z_=()=>{if(!E_()&&!R_){R_=!0;try{location.reload()}catch{}}};typeof window<`u`&&Io(()=>{let e=Lo();if(!e||L_===e.epoch)return;L_=e.epoch;let t=D_(e.remote.shell,z_);t?t.catch(()=>{L_===e.epoch&&(L_=0)}):L_=0});var B_=()=>Qo(),V_=async()=>typeof window>`u`?!1:U.then(e=>e.shell?.applyUpdate()).then(e=>e===!0).catch(()=>!1),H_=async()=>{if(typeof window>`u`||window.parent===window||window.parent!==window.top)return!1;let e=Fo(`shell.isAppTab`).then(e=>e.shell?.isAppTab?.()).then(e=>e===!0,()=>!1);return Promise.race([e,new Promise(e=>setTimeout(e,ko,!1))])},U_=/* @__PURE__ */ `en.es-419.pt-BR.fr.de.it.ru.ja.ko.zh-Hans.zh-Hant.tr.pl.ar.he.id.vi.th.hi.uk.nl.sv.cs.el.ro.hu.ms`.split(`.`),W_=e=>{try{return new Intl.Locale(e)}catch{return}},G_=(e,t)=>{let n=t.flatMap(e=>{let t=W_(e);if(!t)return[];let{language:n,script:r}=t.maximize();return[{tag:e,exact:t.baseName,language:n,script:r}]});for(let t of e){let e=W_(t);if(!e)continue;let{language:r,script:i}=e.maximize(),a=n.find(t=>t.exact===e.baseName)??n.find(e=>e.language===r&&e.script===i)??n.find(e=>e.language===r);if(a)return a.tag}},K_=`stub.settings.account`,q_=e=>{let t=JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?Object.fromEntries(Object.entries(t).filter(([,e])=>e===null||typeof e==`string`)):{}},J_=(e=()=>globalThis.localStorage,{accountKey:t=K_,merge:n}={})=>{let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=()=>{},o=t=>{try{return e().getItem(t)}catch{return null}},s=(t,n)=>{n===null?e().removeItem(t):e().setItem(t,n)},c=()=>{let e=o(t);if(e!==null)try{return q_(e)}catch{return{}}},l=e=>{let t=c()?.[e];return t===void 0?o(e):t},u=e=>{for(let t of r.get(e)??[])t()},d=(e,r)=>{let o=n?n(l(e),r):r;i.set(e,n?n(i.get(e)??null,r):r);try{let n=c();n?s(t,JSON.stringify({...n,[e]:o})):s(e,o)}finally{u(e),a()}};return{getItem:l,setItem:(e,t)=>d(e,t),removeItem:e=>d(e,null),watch:(e,n)=>{let i=r.get(e);i||r.set(e,i=/* @__PURE__ */ new Set),i.add(n);let a=r=>{(r.key===e||r.key===t||r.key===null)&&n()};return globalThis.addEventListener?.(`storage`,a),()=>{i.delete(n),globalThis.removeEventListener?.(`storage`,a)}},flush:()=>a(!0),unsaved:e=>i.has(e),internal:{raw:o,write:s,edits:i,tell:u,accountKey:t,merge:n,onEdit:e=>{a=e}}}},$=J_(),Y_=`stub.language`,X_=U_,Z_=/* @__PURE__ */ new Set([`ar`,`ckb`,`dv`,`fa`,`he`,`ps`,`sd`,`ug`,`ur`,`yi`]),Q_=()=>globalThis.navigator?.languages??[],$_=e=>Z_.has(W_(e)?.language??``),ev=()=>{let e=$.getItem(Y_);return e&&X_.includes(e)?e:void 0},tv=`stub.language.carried`,nv=(e,t)=>{try{t?e.setItem(Y_,t):e.removeItem(Y_)}catch{}},rv=2e3,iv=async(e,{saved:t,reload:n})=>{nv($,e);let r;if(await Promise.race([t(),new Promise(e=>{r=setTimeout(e,rv)})]),clearTimeout(r),$.unsaved(`stub.language`))try{sessionStorage.setItem(tv,e??``)}catch{}n()},av=(e=$)=>{let t=null;try{t=sessionStorage.getItem(tv),sessionStorage.removeItem(tv)}catch{}t!==null&&nv(e,t||void 0)},ov=(e=Q_(),t=X_)=>G_(e,t)??`en`,sv=(e=Q_(),t=X_)=>ev()??ov(e,t),cv=(e=sv(),t=Q_())=>{let{language:n,script:r}=W_(e)?.maximize()??{},i=t.find(e=>{let t=W_(e)?.maximize();return!!t&&t.language===n&&t.script===r})??e,{calendar:a,numberingSystem:o}=new Intl.DateTimeFormat(i).resolvedOptions(),s={...a===`gregory`?{}:{calendar:`gregory`},...o===`latn`?{}:{numberingSystem:`latn`}};return Object.keys(s).length?new Intl.Locale(i,s).toString():i},lv=(e=Q_())=>ev()??e?.[0]??`en`,uv=(e,t)=>Cp.fetch(e,t),dv=[`www.crunchyroll.com`,`crunchyroll.com`,`sso.crunchyroll.com`,`static.crunchyroll.com`],fv=`https://www.crunchyroll.com`,pv=`${fv}/`,mv=`noaihdevm_6iyg0a8l0q`,hv=`https://sso.crunchyroll.com/authorize?${new URLSearchParams({client_id:mv,redirect_uri:`${fv}/callback`,response_type:`cookie`,state:`/`})}`,gv=e=>e.locator(`#user-menu-authenticated`).exists(),_v=async()=>Xe()?`extension`:(document.readyState!==`complete`&&await new Promise(e=>{let t=()=>{clearTimeout(n),e()},n=setTimeout(()=>{window.removeEventListener(`load`,t),e()},1e4);window.addEventListener(`load`,t,{once:!0})}),await new Promise(e=>setTimeout(e,300)),Xe()?`extension`:`cloud`),vv=e=>e===`extension`?`native`:`persistent`,yv=()=>ps(`Play it in stub`),bv=({userAgent:e,maxTouchPoints:t}=navigator)=>/Chrome\/|Firefox\//.test(e)&&!/Android|Mobile/.test(e)&&!(/Macintosh/.test(e)&&t>1),xv=/* @__PURE__ */ new Set([`ExtensionOperationUnsupportedError`,`FrameWindowRefusedError`]),Sv=(e,t)=>{let n;return Promise.race([Promise.resolve().then(e).catch(()=>void 0),new Promise(e=>{n=setTimeout(()=>e(void 0),t)})]).finally(()=>clearTimeout(n))},Cv=async({url:e,domains:t,isSignedIn:n,permissions:r,cookies:i,width:a,height:o,pollMs:s=1e3,readTimeoutMs:c=5e3})=>{let l=x_({window:{...a===void 0?{}:{width:a},...o===void 0?{}:{height:o}},domains:t,cookies:i??vv(Xe()?`extension`:`cloud`),...r?{permissions:r}:{}}),u;try{u=await l}catch(e){let t=e?.name;if(t===`FrameWindowBlockedError`)return`blocked`;if(t&&xv.has(t))return console.warn(`[login-window] window mode was refused`,e),`unsupported`;if(Yt(e))return`closed`;throw e}try{await u.goto(e,{waitUntil:`commit`})}catch(e){if(!Yt(e))throw await u.close().catch(()=>{}),e}let d=u.closed.then(()=>`closed`);for(;;){let e=await Promise.race([d,new Promise(e=>setTimeout(e,s)).then(()=>Sv(()=>n(u),c))]);if(e===`closed`)return`closed`;if(e===!0)return await u.close(),`authed`}},wv=`stub.sessions`,Tv=`stub.sessions`,Ev=e=>{try{let t=JSON.parse(e??`[]`);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}},Dv=(e,t)=>{let n=/* @__PURE__ */ new Set,r=/* @__PURE__ */ new Set,i=()=>{try{return Ev(e().getItem(wv))}catch{return[]}};return{isConnected:e=>n.has(e)||!r.has(e)&&i().includes(e),connect:a=>{r.delete(a);try{let n=i();n.includes(a)?t.postMessage(a):e().setItem(wv,JSON.stringify([...n,a]))}catch{n.add(a)}},disconnect:t=>{n.delete(t);try{e().setItem(wv,JSON.stringify(i().filter(e=>e!==t)))}catch{r.add(t)}}}},Ov=e=>{let t=e?.name;return t===`LocatorDeniedError`||t===`PermissionDeniedError`},kv=(e,t)=>({call:async(n,r,i,a)=>{if(!t.isConnected(n))return{kind:`not-connected`};try{return{kind:`response`,response:await e.use(n,e=>{let t=e[r];if(typeof t!=`function`)throw Error(`The ${n} page serves no ${r}`);return t(i)},a)}}catch(e){if(Ov(e))return{kind:`not-connected`};throw e}},watch:(t,n)=>{e.watch(t,()=>{n()})}}),Av=(e,t,{frames:n,connections:r})=>t().then(t=>(t!==`blocked`&&(r.connect(e),n.reload(e)),t)),jv=(e,{frames:t,connections:n})=>{n.disconnect(e),t.reload(e)},Mv=`stub.site-status`,Nv=e=>typeof e==`object`&&!!e&&(e.state===`signed-in`||e.state===`signed-out`)&&Number.isFinite(e.checkedAt),Pv=e=>{try{let t=JSON.parse(e()??`{}`);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}},Fv=(e=>{let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=()=>Pv(()=>e().getItem(Mv)),i=e=>{for(let t of n.get(e)??[])t()},a=(n,a)=>{try{e().setItem(Mv,JSON.stringify({...r(),[n]:a})),t.delete(n)}catch{t.set(n,a)}i(n)},o={read:e=>{let n=t.get(e)??r()[e];if(Nv(n))return n.state===`signed-out`&&n.signedInBefore===!0?{state:n.state,checkedAt:n.checkedAt,signedInBefore:!0}:{state:n.state,checkedAt:n.checkedAt}},record:(e,t,n=Date.now())=>{let r=o.read(e);a(e,t===`signed-out`&&(r?.state===`signed-in`||r?.signedInBefore)?{state:t,checkedAt:n,signedInBefore:!0}:{state:t,checkedAt:n})},recordSignOut:(e,t=Date.now())=>a(e,{state:`signed-out`,checkedAt:t}),watch:(e,t)=>{let r=n.get(e);return r||n.set(e,r=/* @__PURE__ */ new Set),r.add(t),()=>{r.delete(t)}},heard:(e,t)=>{let n=Pv(()=>e),r=Pv(()=>t);for(let e of/* @__PURE__ */ new Set([...Object.keys(n),...Object.keys(r)]))JSON.stringify(n[e])!==JSON.stringify(r[e])&&i(e)}};return o})(()=>localStorage);globalThis.addEventListener?.(`storage`,({key:e,oldValue:t,newValue:n})=>{e===`stub.site-status`&&Fv.heard(t,n)});var Iv=(e,t,n=Date.now)=>{let r=/* @__PURE__ */ new Map;return(i,a)=>{if(n()-Math.max(e.read(i)?.checkedAt??-1/0,r.get(i)??-1/0)<6e4)return;let o=n();r.set(i,1/0),t(i,a).then(t=>{(e.read(i)?.checkedAt??-1/0)<o&&e.record(i,t,n())},()=>{}).finally(()=>r.set(i,n()))}},Lv=(e,t)=>n=>(n===`authed`&&e.record(t,`signed-in`),n),Rv=[`anilist`,`mal`,`trakt`],zv=(e,t,n)=>{for(let{state:r,tracker:i}of e){let e=i.id;Rv.includes(e)&&n(e)&&(r===`LISTED`||r===`NOT_LISTED`?t.record(e,`signed-in`):r===`SIGNED_OUT`&&t.record(e,`signed-out`))}},Bv={"Africa/Abidjan":`CI`,"Africa/Accra":`GH`,"Africa/Addis_Ababa":`ET`,"Africa/Algiers":`DZ`,"Africa/Asmara":`ER`,"Africa/Asmera":`ER`,"Africa/Bamako":`ML`,"Africa/Bangui":`CF`,"Africa/Banjul":`GM`,"Africa/Bissau":`GW`,"Africa/Blantyre":`MW`,"Africa/Brazzaville":`CG`,"Africa/Bujumbura":`BI`,"Africa/Cairo":`EG`,"Africa/Casablanca":`MA`,"Africa/Ceuta":`ES`,"Africa/Conakry":`GN`,"Africa/Dakar":`SN`,"Africa/Dar_es_Salaam":`TZ`,"Africa/Djibouti":`DJ`,"Africa/Douala":`CM`,"Africa/El_Aaiun":`EH`,"Africa/Freetown":`SL`,"Africa/Gaborone":`BW`,"Africa/Harare":`ZW`,"Africa/Johannesburg":`ZA`,"Africa/Juba":`SS`,"Africa/Kampala":`UG`,"Africa/Khartoum":`SD`,"Africa/Kigali":`RW`,"Africa/Kinshasa":`CD`,"Africa/Lagos":`NG`,"Africa/Libreville":`GA`,"Africa/Lome":`TG`,"Africa/Luanda":`AO`,"Africa/Lubumbashi":`CD`,"Africa/Lusaka":`ZM`,"Africa/Malabo":`GQ`,"Africa/Maputo":`MZ`,"Africa/Maseru":`LS`,"Africa/Mbabane":`SZ`,"Africa/Mogadishu":`SO`,"Africa/Monrovia":`LR`,"Africa/Nairobi":`KE`,"Africa/Ndjamena":`TD`,"Africa/Niamey":`NE`,"Africa/Nouakchott":`MR`,"Africa/Ouagadougou":`BF`,"Africa/Porto-Novo":`BJ`,"Africa/Sao_Tome":`ST`,"Africa/Tripoli":`LY`,"Africa/Tunis":`TN`,"Africa/Windhoek":`NA`,"America/Adak":`US`,"America/Anchorage":`US`,"America/Anguilla":`AI`,"America/Antigua":`AG`,"America/Araguaina":`BR`,"America/Argentina/Buenos_Aires":`AR`,"America/Argentina/Catamarca":`AR`,"America/Argentina/Cordoba":`AR`,"America/Argentina/Jujuy":`AR`,"America/Argentina/La_Rioja":`AR`,"America/Argentina/Mendoza":`AR`,"America/Argentina/Rio_Gallegos":`AR`,"America/Argentina/Salta":`AR`,"America/Argentina/San_Juan":`AR`,"America/Argentina/San_Luis":`AR`,"America/Argentina/Tucuman":`AR`,"America/Argentina/Ushuaia":`AR`,"America/Aruba":`AW`,"America/Asuncion":`PY`,"America/Atikokan":`CA`,"America/Bahia":`BR`,"America/Bahia_Banderas":`MX`,"America/Barbados":`BB`,"America/Belem":`BR`,"America/Belize":`BZ`,"America/Blanc-Sablon":`CA`,"America/Boa_Vista":`BR`,"America/Bogota":`CO`,"America/Boise":`US`,"America/Buenos_Aires":`AR`,"America/Cambridge_Bay":`CA`,"America/Campo_Grande":`BR`,"America/Cancun":`MX`,"America/Caracas":`VE`,"America/Catamarca":`AR`,"America/Cayenne":`GF`,"America/Cayman":`KY`,"America/Chicago":`US`,"America/Chihuahua":`MX`,"America/Ciudad_Juarez":`MX`,"America/Coral_Harbour":`CA`,"America/Cordoba":`AR`,"America/Costa_Rica":`CR`,"America/Coyhaique":`CL`,"America/Creston":`CA`,"America/Cuiaba":`BR`,"America/Curacao":`CW`,"America/Danmarkshavn":`GL`,"America/Dawson":`CA`,"America/Dawson_Creek":`CA`,"America/Denver":`US`,"America/Detroit":`US`,"America/Dominica":`DM`,"America/Edmonton":`CA`,"America/Eirunepe":`BR`,"America/El_Salvador":`SV`,"America/Fort_Nelson":`CA`,"America/Fortaleza":`BR`,"America/Glace_Bay":`CA`,"America/Godthab":`GL`,"America/Goose_Bay":`CA`,"America/Grand_Turk":`TC`,"America/Grenada":`GD`,"America/Guadeloupe":`GP`,"America/Guatemala":`GT`,"America/Guayaquil":`EC`,"America/Guyana":`GY`,"America/Halifax":`CA`,"America/Havana":`CU`,"America/Hermosillo":`MX`,"America/Indiana/Indianapolis":`US`,"America/Indiana/Knox":`US`,"America/Indiana/Marengo":`US`,"America/Indiana/Petersburg":`US`,"America/Indiana/Tell_City":`US`,"America/Indiana/Vevay":`US`,"America/Indiana/Vincennes":`US`,"America/Indiana/Winamac":`US`,"America/Indianapolis":`US`,"America/Inuvik":`CA`,"America/Iqaluit":`CA`,"America/Jamaica":`JM`,"America/Jujuy":`AR`,"America/Juneau":`US`,"America/Kentucky/Louisville":`US`,"America/Kentucky/Monticello":`US`,"America/Kralendijk":`BQ`,"America/La_Paz":`BO`,"America/Lima":`PE`,"America/Los_Angeles":`US`,"America/Louisville":`US`,"America/Lower_Princes":`SX`,"America/Maceio":`BR`,"America/Managua":`NI`,"America/Manaus":`BR`,"America/Marigot":`MF`,"America/Martinique":`MQ`,"America/Matamoros":`MX`,"America/Mazatlan":`MX`,"America/Mendoza":`AR`,"America/Menominee":`US`,"America/Merida":`MX`,"America/Metlakatla":`US`,"America/Mexico_City":`MX`,"America/Miquelon":`PM`,"America/Moncton":`CA`,"America/Monterrey":`MX`,"America/Montevideo":`UY`,"America/Montserrat":`MS`,"America/Nassau":`BS`,"America/New_York":`US`,"America/Nome":`US`,"America/Noronha":`BR`,"America/North_Dakota/Beulah":`US`,"America/North_Dakota/Center":`US`,"America/North_Dakota/New_Salem":`US`,"America/Nuuk":`GL`,"America/Ojinaga":`MX`,"America/Panama":`PA`,"America/Paramaribo":`SR`,"America/Phoenix":`US`,"America/Port-au-Prince":`HT`,"America/Port_of_Spain":`TT`,"America/Porto_Velho":`BR`,"America/Puerto_Rico":`PR`,"America/Punta_Arenas":`CL`,"America/Rankin_Inlet":`CA`,"America/Recife":`BR`,"America/Regina":`CA`,"America/Resolute":`CA`,"America/Rio_Branco":`BR`,"America/Santarem":`BR`,"America/Santiago":`CL`,"America/Santo_Domingo":`DO`,"America/Sao_Paulo":`BR`,"America/Scoresbysund":`GL`,"America/Sitka":`US`,"America/St_Barthelemy":`BL`,"America/St_Johns":`CA`,"America/St_Kitts":`KN`,"America/St_Lucia":`LC`,"America/St_Thomas":`VI`,"America/St_Vincent":`VC`,"America/Swift_Current":`CA`,"America/Tegucigalpa":`HN`,"America/Thule":`GL`,"America/Tijuana":`MX`,"America/Toronto":`CA`,"America/Tortola":`VG`,"America/Vancouver":`CA`,"America/Whitehorse":`CA`,"America/Winnipeg":`CA`,"America/Yakutat":`US`,"Antarctica/Casey":`AQ`,"Antarctica/Davis":`AQ`,"Antarctica/DumontDUrville":`AQ`,"Antarctica/Macquarie":`AU`,"Antarctica/Mawson":`AQ`,"Antarctica/McMurdo":`AQ`,"Antarctica/Palmer":`AQ`,"Antarctica/Rothera":`AQ`,"Antarctica/Syowa":`AQ`,"Antarctica/Troll":`AQ`,"Antarctica/Vostok":`AQ`,"Arctic/Longyearbyen":`SJ`,"Asia/Aden":`YE`,"Asia/Almaty":`KZ`,"Asia/Amman":`JO`,"Asia/Anadyr":`RU`,"Asia/Aqtau":`KZ`,"Asia/Aqtobe":`KZ`,"Asia/Ashgabat":`TM`,"Asia/Atyrau":`KZ`,"Asia/Baghdad":`IQ`,"Asia/Bahrain":`BH`,"Asia/Baku":`AZ`,"Asia/Bangkok":`TH`,"Asia/Barnaul":`RU`,"Asia/Beirut":`LB`,"Asia/Bishkek":`KG`,"Asia/Brunei":`BN`,"Asia/Calcutta":`IN`,"Asia/Chita":`RU`,"Asia/Colombo":`LK`,"Asia/Damascus":`SY`,"Asia/Dhaka":`BD`,"Asia/Dili":`TL`,"Asia/Dubai":`AE`,"Asia/Dushanbe":`TJ`,"Asia/Famagusta":`CY`,"Asia/Gaza":`PS`,"Asia/Hebron":`PS`,"Asia/Ho_Chi_Minh":`VN`,"Asia/Hong_Kong":`HK`,"Asia/Hovd":`MN`,"Asia/Irkutsk":`RU`,"Asia/Jakarta":`ID`,"Asia/Jayapura":`ID`,"Asia/Jerusalem":`IL`,"Asia/Kabul":`AF`,"Asia/Kamchatka":`RU`,"Asia/Karachi":`PK`,"Asia/Kathmandu":`NP`,"Asia/Katmandu":`NP`,"Asia/Khandyga":`RU`,"Asia/Kolkata":`IN`,"Asia/Krasnoyarsk":`RU`,"Asia/Kuala_Lumpur":`MY`,"Asia/Kuching":`MY`,"Asia/Kuwait":`KW`,"Asia/Macau":`MO`,"Asia/Magadan":`RU`,"Asia/Makassar":`ID`,"Asia/Manila":`PH`,"Asia/Muscat":`OM`,"Asia/Nicosia":`CY`,"Asia/Novokuznetsk":`RU`,"Asia/Novosibirsk":`RU`,"Asia/Omsk":`RU`,"Asia/Oral":`KZ`,"Asia/Phnom_Penh":`KH`,"Asia/Pontianak":`ID`,"Asia/Pyongyang":`KP`,"Asia/Qatar":`QA`,"Asia/Qostanay":`KZ`,"Asia/Qyzylorda":`KZ`,"Asia/Rangoon":`MM`,"Asia/Riyadh":`SA`,"Asia/Saigon":`VN`,"Asia/Sakhalin":`RU`,"Asia/Samarkand":`UZ`,"Asia/Seoul":`KR`,"Asia/Shanghai":`CN`,"Asia/Singapore":`SG`,"Asia/Srednekolymsk":`RU`,"Asia/Taipei":`TW`,"Asia/Tashkent":`UZ`,"Asia/Tbilisi":`GE`,"Asia/Tehran":`IR`,"Asia/Thimphu":`BT`,"Asia/Tokyo":`JP`,"Asia/Tomsk":`RU`,"Asia/Ulaanbaatar":`MN`,"Asia/Urumqi":`CN`,"Asia/Ust-Nera":`RU`,"Asia/Vientiane":`LA`,"Asia/Vladivostok":`RU`,"Asia/Yakutsk":`RU`,"Asia/Yangon":`MM`,"Asia/Yekaterinburg":`RU`,"Asia/Yerevan":`AM`,"Atlantic/Azores":`PT`,"Atlantic/Bermuda":`BM`,"Atlantic/Canary":`ES`,"Atlantic/Cape_Verde":`CV`,"Atlantic/Faeroe":`FO`,"Atlantic/Faroe":`FO`,"Atlantic/Madeira":`PT`,"Atlantic/Reykjavik":`IS`,"Atlantic/South_Georgia":`GS`,"Atlantic/St_Helena":`SH`,"Atlantic/Stanley":`FK`,"Australia/Adelaide":`AU`,"Australia/Brisbane":`AU`,"Australia/Broken_Hill":`AU`,"Australia/Darwin":`AU`,"Australia/Eucla":`AU`,"Australia/Hobart":`AU`,"Australia/Lindeman":`AU`,"Australia/Lord_Howe":`AU`,"Australia/Melbourne":`AU`,"Australia/Perth":`AU`,"Australia/Sydney":`AU`,"Europe/Amsterdam":`NL`,"Europe/Andorra":`AD`,"Europe/Astrakhan":`RU`,"Europe/Athens":`GR`,"Europe/Belgrade":`RS`,"Europe/Berlin":`DE`,"Europe/Bratislava":`SK`,"Europe/Brussels":`BE`,"Europe/Bucharest":`RO`,"Europe/Budapest":`HU`,"Europe/Busingen":`DE`,"Europe/Chisinau":`MD`,"Europe/Copenhagen":`DK`,"Europe/Dublin":`IE`,"Europe/Gibraltar":`GI`,"Europe/Guernsey":`GG`,"Europe/Helsinki":`FI`,"Europe/Isle_of_Man":`IM`,"Europe/Istanbul":`TR`,"Europe/Jersey":`JE`,"Europe/Kaliningrad":`RU`,"Europe/Kiev":`UA`,"Europe/Kirov":`RU`,"Europe/Kyiv":`UA`,"Europe/Lisbon":`PT`,"Europe/Ljubljana":`SI`,"Europe/London":`GB`,"Europe/Luxembourg":`LU`,"Europe/Madrid":`ES`,"Europe/Malta":`MT`,"Europe/Mariehamn":`AX`,"Europe/Minsk":`BY`,"Europe/Monaco":`MC`,"Europe/Moscow":`RU`,"Europe/Oslo":`NO`,"Europe/Paris":`FR`,"Europe/Podgorica":`ME`,"Europe/Prague":`CZ`,"Europe/Riga":`LV`,"Europe/Rome":`IT`,"Europe/Samara":`RU`,"Europe/San_Marino":`SM`,"Europe/Sarajevo":`BA`,"Europe/Saratov":`RU`,"Europe/Simferopol":`UA`,"Europe/Skopje":`MK`,"Europe/Sofia":`BG`,"Europe/Stockholm":`SE`,"Europe/Tallinn":`EE`,"Europe/Tirane":`AL`,"Europe/Ulyanovsk":`RU`,"Europe/Vaduz":`LI`,"Europe/Vatican":`VA`,"Europe/Vienna":`AT`,"Europe/Vilnius":`LT`,"Europe/Volgograd":`RU`,"Europe/Warsaw":`PL`,"Europe/Zagreb":`HR`,"Europe/Zurich":`CH`,"Indian/Antananarivo":`MG`,"Indian/Chagos":`IO`,"Indian/Christmas":`CX`,"Indian/Cocos":`CC`,"Indian/Comoro":`KM`,"Indian/Kerguelen":`TF`,"Indian/Mahe":`SC`,"Indian/Maldives":`MV`,"Indian/Mauritius":`MU`,"Indian/Mayotte":`YT`,"Indian/Reunion":`RE`,"Pacific/Apia":`WS`,"Pacific/Auckland":`NZ`,"Pacific/Bougainville":`PG`,"Pacific/Chatham":`NZ`,"Pacific/Chuuk":`FM`,"Pacific/Easter":`CL`,"Pacific/Efate":`VU`,"Pacific/Enderbury":`KI`,"Pacific/Fakaofo":`TK`,"Pacific/Fiji":`FJ`,"Pacific/Funafuti":`TV`,"Pacific/Galapagos":`EC`,"Pacific/Gambier":`PF`,"Pacific/Guadalcanal":`SB`,"Pacific/Guam":`GU`,"Pacific/Honolulu":`US`,"Pacific/Kanton":`KI`,"Pacific/Kiritimati":`KI`,"Pacific/Kosrae":`FM`,"Pacific/Kwajalein":`MH`,"Pacific/Majuro":`MH`,"Pacific/Marquesas":`PF`,"Pacific/Midway":`UM`,"Pacific/Nauru":`NR`,"Pacific/Niue":`NU`,"Pacific/Norfolk":`NF`,"Pacific/Noumea":`NC`,"Pacific/Pago_Pago":`AS`,"Pacific/Palau":`PW`,"Pacific/Pitcairn":`PN`,"Pacific/Pohnpei":`FM`,"Pacific/Ponape":`FM`,"Pacific/Port_Moresby":`PG`,"Pacific/Rarotonga":`CK`,"Pacific/Saipan":`MP`,"Pacific/Tahiti":`PF`,"Pacific/Tarawa":`KI`,"Pacific/Tongatapu":`TO`,"Pacific/Truk":`FM`,"Pacific/Wake":`UM`,"Pacific/Wallis":`WF`},Vv=`stub.country`,Hv=Bv,Uv=[...new Set(Object.values(Bv))],Wv=(e=Intl.DateTimeFormat().resolvedOptions().timeZone)=>Hv[e]??`US`,Gv=()=>{let e=$.getItem(Vv);return e&&Uv.includes(e)?e:void 0},Kv=e=>{try{e?$.setItem(Vv,e):$.removeItem(Vv)}catch{}},qv=e=>$.watch(Vv,e),Jv,Yv=()=>Gv()??Jv??Wv(),Xv=`stub.player.audio-language`,Zv=`stub.player.subtitle-language`,Qv=`stub.player.always-subtitles`,$v=`original`,ey=(e=e=>$.getItem(e),t=lv())=>{let n=e(Xv),r=e(Zv);return{audio:n===`original`?void 0:n??t,subtitles:r===`off`?null:r??t,alwaysSubtitles:e(Qv)===`on`}},ty=e=>{try{e===void 0?$.removeItem(Xv):$.setItem(Xv,e)}catch{}},ny=e=>{try{e===void 0?$.removeItem(Zv):$.setItem(Zv,e??`off`)}catch{}},ry=e=>{try{e?$.setItem(Qv,`on`):$.removeItem(Qv)}catch{}},iy=e=>{let t=[Xv,Zv,Qv].map(t=>$.watch(t,e));return()=>{for(let e of t)e()}};export{J_ as $,yv as A,uv as B,wv as C,Xe as Ct,Av as D,jv as E,dv as F,lv as G,Y_ as H,hv as I,iv as J,cv as K,pv as L,bv as M,_v as N,kv as O,fv as P,K_ as Q,mv as R,Tv as S,qt as St,Dv as T,X_ as U,tv as V,ov as W,av as X,ev as Y,sv as Z,Mv as _,dl as _t,ry as a,x_ as at,Lv as b,is as bt,ey as c,og as ct,Vv as d,Tp as dt,q_ as et,Kv as f,Cp as ft,Wv as g,rl as gt,qv as h,fl as ht,Zv as i,C_ as it,vv as j,Cv as k,iy as l,hg as lt,Yv as m,wl as mt,Xv as n,G_ as nt,ty as o,Xg as ot,Gv as p,Cl as pt,$_ as q,$v as r,O_ as rt,ny as s,Og as st,Qv as t,$ as tt,Uv as u,kp as ut,Iv as v,_s as vt,Ev as w,Pi as wt,Fv as x,qi as xt,zv as y,es as yt,gv as z};
|