@banou/stub 0.0.44 → 0.0.45
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/{account-uIgK7-D5.js → account-B2ETje0Z.js} +1 -1
- package/build/assets/account-QzTt80xa.js +1 -0
- package/build/assets/api-CXwRN66S.js +1 -0
- package/build/assets/api-DIgTslNb-Cs0uqWX1.js +3 -0
- package/build/assets/embed-BSfHdWDm.js +1609 -0
- package/build/assets/{embed-title-CKGXRNB_.js → embed-title-glP3xA0i.js} +1 -1
- package/build/assets/index-uuiiUU3P.js +2485 -0
- package/build/assets/lib-account-B1yNOmvG.js +2 -0
- package/build/assets/{lib-account-DgN_bHrt.js → lib-account-D3OycIgO.js} +4 -4
- package/build/assets/lib-api-BH2vA5gl.js +2 -0
- package/build/assets/{lib-api-Dp-2AT3u-5287Hymh.js → lib-api-DIgTslNb-Dy8pDGuW.js} +736 -696
- package/build/assets/{lib-worker-CRUroXGN.js → lib-worker-BsxFF1Cm.js} +1 -1
- package/build/assets/{lib-worker-CVIm8dzD.js → lib-worker-DOqynLhk.js} +2584 -1974
- package/build/assets/lib-worker-index-CBZBPhZm.js +2485 -0
- package/build/assets/login-window-Ceh8mJXR.js +71 -0
- package/build/assets/main-wCzkdSVR.js +4445 -0
- package/build/assets/{worker-JsuU2Daq.js → worker-BUw9_QQ0.js} +1 -1
- package/build/assets/worker-D0R4jFi3.js +1 -0
- package/build/embed.html +5 -5
- package/build/favicon.ico +0 -0
- package/build/icons/icon-192.png +0 -0
- package/build/icons/icon-512.png +0 -0
- package/build/icons/icon.svg +5 -15
- package/build/index.html +6 -6
- package/build/index.js +7802 -6712
- package/fkn.json +1 -1
- package/package.json +4 -3
- package/build/assets/account-Dqz2amwB.js +0 -1
- package/build/assets/api-Dp-2AT3u-DnXkochq.js +0 -3
- package/build/assets/api-rrvhokeg.js +0 -1
- package/build/assets/embed-Dq58Zgjw.js +0 -1609
- package/build/assets/index-vFQloIIu.js +0 -2485
- package/build/assets/lib-account-BsgOxvGV.js +0 -2
- package/build/assets/lib-api-kFj1W6Gv.js +0 -2
- package/build/assets/lib-worker-index-oAXxrvjb.js +0 -2485
- package/build/assets/login-window-BippQvfb.js +0 -71
- package/build/assets/main-5KJGhxz1.js +0 -4253
- package/build/assets/worker-C09SA0TU.js +0 -1
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./api-CXwRN66S.js","./api-DIgTslNb-Cs0uqWX1.js","./build-mcPaLDi_.js","./account-QzTt80xa.js","./account-B2ETje0Z.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{gt as e,ht as t,mt as n,pt as r}from"./embed-title-glP3xA0i.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./build-mcPaLDi_.js";import{c as u,l as d,o as f,s as p}from"./account-B2ETje0Z.js";import{a as m,c as h,d as g,f as _,n as v,o as y,r as b,s as x,t as S,u as C}from"./api-DIgTslNb-Cs0uqWX1.js";var w={scope:`read.text`,category:`storage`,severity:1,chip:`read text`,title:`Read text from the page`,description:`Lets the app see the text shown on this page.`},T={scope:`read.info`,category:`storage`,severity:1,chip:`read details`,title:`Read info from the page`,description:`Lets the app read a detail of a part of the page.`},E={scope:`read.visible`,category:`storage`,severity:0,title:`See what’s visible on the page`,description:`Lets the app check which elements are currently on screen.`},D={scope:`read.check`,category:`storage`,severity:0,title:`Check if something is on the page`,description:`Lets the app test whether a specific element exists.`},O={scope:`read.count`,category:`storage`,severity:0,title:`Count items on the page`,description:`Lets the app count how many matching elements are present.`},k={scope:`act.click`,category:`interaction`,severity:3,chip:`click`,title:`Click on the page`,description:`Lets the app press buttons or links for you.`},A={scope:`act.type`,category:`interaction`,severity:1,chip:`type`,title:`Type into a text field`,description:`Lets the app fill in form fields on your behalf.`},j={scope:`act.hover`,category:`interaction`,severity:1,chip:`hover`,title:`Hover over the page`,description:`Lets the app point at things to reveal menus or tooltips.`},M={scope:`media.video`,category:`interaction`,severity:0,title:`Control video playback`,description:`Lets the app play, pause, seek, and read the video on the page.`},ee={scope:`media.appear`,category:`interaction`,severity:0,title:`Change page appearance`,description:`Lets the app restyle parts of the page (safely filtered).`},N={scope:`media.appearU`,category:`evaluation`,severity:2,chip:`unfiltered styles`,unsafe:!0,title:`Change page appearance (unsafe)`,description:`Lets the app restyle the page WITHOUT safety filtering. Could be used to leak data over the network.`},P={scope:`frame.evaluate`,category:`evaluation`,severity:3,chip:`run code`,unsafe:!0,title:`Run the app’s code on this site`,description:`Lets the app run its own script inside this site, with full access to the page and the data it shows.`},F={scope:`frame.message`,category:`evaluation`,severity:3,chip:`message the page`,unsafe:!0,title:`Send messages to this site`,description:`Lets the app send messages and open channels into this site, which its scripts receive as their own.`},te=e=>e?.noSanitize?N:ee,ne={scope:`frame.fetchRead`,category:`network`,severity:3,chip:`load`,unsafe:!0,title:`Read your account data on this site`,description:`Lets the app read pages and data from this site as you, using the session in the frame.`},re={scope:`frame.fetchWrite`,category:`network`,severity:3,chip:`send`,unsafe:!0,title:`Change your account data on this site`,description:`Lets the app send changes to this site as you, using the session in the frame.`},I=new Set([`GET`,`HEAD`,`OPTIONS`]),L=(e,t)=>I.has((t?.method??`GET`).toUpperCase())?ne:re,ie={click:k,fill:A,hover:j,textContent:w,getAttribute:T,isVisible:E,count:O,exists:D,videoElement:M,addStyleTag:te,fetch:L,evaluate:P},ae={postMessage:F,addScriptTag:P};[w,T,E,D,O,k,A,j,M,ee,N,ne,re,P,F].map(e=>e.scope);var oe={...ie,...ae},se=(e,t)=>{let n=oe[e];return n?(typeof n==`function`?n(...t):n).scope:null},ce=(e,t)=>{try{return new URL(e,t)}catch{return}},le=e=>{let t=ce(e,`https://s.invalid/`),n=ce(e,`http://s.invalid/`);if(!t||!n)return{kind:`invalid`};let r=ce(e);return!r||r.href!==t.href||r.href!==n.href?{kind:`relative`}:r.protocol!==`https:`&&r.protocol!==`http:`?{kind:`unsupported`,protocol:r.protocol}:{kind:`absolute`,host:r.hostname,protocol:r.protocol}},ue=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/,de=/^\[[0-9a-f:.]+\]$/,fe=e=>{try{return new URL(`http://${e}/`).hostname}catch{return}},R=(e,{ipv6:t=!1}={})=>{let n=[];for(let r of e){let e=r.trim().toLowerCase();if(!e||e.length>253)continue;let i=ue.test(e)?e:t&&de.test(e)?fe(e):void 0;i&&!n.includes(i)&&n.push(i)}return n},pe=(e,t)=>{let n=new EventTarget,r=new Map,i=EventTarget.prototype.addEventListener.bind(n),a=EventTarget.prototype.removeEventListener.bind(n);return Object.defineProperty(n,"addEventListener",{configurable:!0,value:(a,o,s)=>{if(o!==null){if(!r.has(a)){let i=r=>{n.dispatchEvent(new CustomEvent(a,{detail:t(r,e),bubbles:r.bubbles,cancelable:r.cancelable,composed:r.composed}))};e.addEventListener(a,i),r.set(a,i)}i(a,o,s)}}}),Object.defineProperty(n,"removeEventListener",{configurable:!0,value:(t,n,i)=>{if(n===null)return;a(t,n,i);let o=r.get(t);o&&(e.removeEventListener(t,o),r.delete(t))}}),n},me=e=>typeof e==`boolean`?+!!e:+!!e?.capture,he=e=>{let t=new WeakMap;return{addEventListener:(n,r,i)=>{if(r===null)return;let a=`${n}|${me(i)}`,o=t.get(r);if(o||(o=new Map,t.set(r,o)),o.has(a))return;let s=typeof i==`object`&&!!i&&!!i.once,c=t=>{s&&o.delete(a);let i=e.unenrich(t,n);typeof r==`function`?r.call(e.target,i):r.handleEvent(i)};o.set(a,c),e.remoteEvents.addEventListener(n,c,i)},removeEventListener:(n,r,i)=>{if(r===null)return;let a=`${n}|${me(i)}`,o=t.get(r),s=o?.get(a);s&&(e.remoteEvents.removeEventListener(n,s,i),o.delete(a))},dispatchEvent:t=>e.remoteEvents.dispatchEvent(t)}},ge=d({box:()=>Pe,createVideoElementHandle:()=>Me,isType:()=>Ne,revive:()=>Fe,type:()=>_e}),_e=`videoElement`,ve=[`currentTime`,`volume`,`muted`,`playbackRate`,`src`,`loop`,`autoplay`,`preload`,`poster`,`disableRemotePlayback`],ye=[`duration`,`paused`,`ended`,`seeking`,`readyState`,`currentSrc`],be=[`buffered`,`seekable`],xe=Symbol.for(`fkn.remoteVideoElement`),Se=Symbol.for(`fkn.remoteVideoElement.state`),Ce=Symbol.for(`fkn.remoteVideoElement.controller`),we=e=>e?Array.from({length:e.length},(t,n)=>[e.start(n),e.end(n)]):[],Te=e=>{let t={};for(let n of[...ve,...ye])t[n]=e[n];for(let n of be)t[n]=we(e[n]);return t.error=e.error?{code:e.error.code,message:e.error.message}:null,t},Ee=e=>{let t=t=>{if(!Number.isInteger(t)||t<0||t>=e.length)throw new DOMException(`Index or size is negative or greater than the allowed amount`,`IndexSizeError`)};return{get length(){return e.length},start(n){return t(n),e[n][0]},end(n){return t(n),e[n][1]}}},De=e=>e?{code:e.code,message:e.message,MEDIA_ERR_ABORTED:1,MEDIA_ERR_NETWORK:2,MEDIA_ERR_DECODE:3,MEDIA_ERR_SRC_NOT_SUPPORTED:4}:null,Oe=e=>pe(e,(e,t)=>({originalDetail:e instanceof CustomEvent?e.detail:null,snapshot:Te(t)})),ke=async(e,t)=>{switch(t){case`play`:return await e.play(),null;case`pause`:return e.pause(),null;case`load`:return e.load(),null;case`requestPictureInPicture`:if(typeof e.requestPictureInPicture!=`function`)throw Error(`requestPictureInPicture is not supported in this environment`);return await e.requestPictureInPicture(),null;case`exitPictureInPicture`:{let t=e.ownerDocument;if(typeof t?.exitPictureInPicture!=`function`)throw Error(`exitPictureInPicture is not supported in this environment`);return await t.exitPictureInPicture(),null}default:throw Error(`videoElement: unknown method "${t}"`)}},Ae=e=>({call:async t=>ke(e,t),set:async(t,n)=>{try{e[t]=n}catch{}return Te(e)},events:Oe(e)}),je=(e,t)=>{let n=new EventTarget;Object.defineProperty(n,xe,{value:!0}),Object.defineProperty(n,Se,{value:e}),Object.defineProperty(n,Ce,{value:t});let r=he({target:n,remoteEvents:t.events,unenrich:(t,n)=>{if(!(t instanceof CustomEvent))return t;let r=t.detail;if(!r||!(`snapshot`in r))return t;Object.assign(e,r.snapshot);let i={bubbles:t.bubbles,cancelable:t.cancelable,composed:t.composed};return r.originalDetail===null?new Event(n,i):new CustomEvent(n,{...i,detail:r.originalDetail})}}),i={addEventListener:{configurable:!0,value:r.addEventListener},removeEventListener:{configurable:!0,value:r.removeEventListener},dispatchEvent:{configurable:!0,value:r.dispatchEvent},error:{configurable:!0,enumerable:!0,get(){return De(e.error)}},play:{configurable:!0,value:()=>t.call(`play`,[])},pause:{configurable:!0,value:()=>{t.call(`pause`,[]).catch(()=>{})}},load:{configurable:!0,value:()=>{t.call(`load`,[]).catch(()=>{})}},requestPictureInPicture:{configurable:!0,value:()=>t.call(`requestPictureInPicture`,[])},exitPictureInPicture:{configurable:!0,value:()=>t.call(`exitPictureInPicture`,[])},HAVE_FUTURE_DATA:{enumerable:!0,value:3},HAVE_ENOUGH_DATA:{enumerable:!0,value:4}};for(let n of ve)i[n]={configurable:!0,enumerable:!0,get(){return e[n]},set(r){e[n]=r,t.set(n,r).then(t=>{Object.assign(e,t)},()=>{})}};for(let t of ye)i[t]={configurable:!0,enumerable:!0,get(){return e[t]}};for(let t of be)i[t]={configurable:!0,enumerable:!0,get(){return Ee(e[t])}};return Object.defineProperties(n,i),n},Me=e=>je(Te(e),Ae(e)),Ne=e=>typeof e==`object`&&!!e&&e[xe]===!0,Pe=(e,t)=>{let n=e;return{...c,type:_e,initialState:n[Se],controller:a(n[Ce],t)}},Fe=(e,t)=>{let n=l(e.controller,t);return je({...e.initialState},n)},Ie=e=>[ge,...e],Le=`fknExtension`,Re=`fknExtensionAbi`,ze=`fknExtensionOps`,Be=[`data-fkn-extension`,`data-fkn-extension-abi`,`data-fkn-extension-ops`],Ve=e=>{if(e===void 0)return 0;let t=Number(e);return Number.isInteger(t)&&t>=0?t:0},He=e=>e===void 0?null:e.split(`,`).map(e=>e.trim()).filter(Boolean),Ue=(e,t=0)=>{if(e.fknExtension!==`true`)return{status:`absent`};let n=Ve(e[Re]),r=He(e[ze]);return n<t?{status:`outdated`,abi:n,required:t,operations:r}:{status:`ok`,abi:n,operations:r}},We=(e,t)=>e.status===`ok`&&e.operations!==null&&e.operations.includes(t),Ge=class extends Error{abi;required;name=`ExtensionOutdatedError`;constructor(e,t){super(`The FKN WebExtension is installed but too old for this page: it speaks ABI ${e} and this page needs at least ${t}. Updating the extension fixes this.`),this.abi=e,this.required=t}},Ke=class extends Error{operation;abi;name=`ExtensionOperationUnsupportedError`;constructor(e,t,n){super(n??`The FKN WebExtension does not support "${e}" (ABI ${t}). Updating the extension may add it.`),this.operation=e,this.abi=t}},qe=`FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY`,Je=Le,Ye=o();typeof document<`u`&&document.addEventListener(qe,()=>{Ye.dispatchEvent(new CustomEvent(`statuschange`,{detail:{enabled:Xe()}}))});var Xe=()=>typeof document>`u`?!1:document.documentElement.dataset[Je]===`true`,Ze=()=>typeof document>`u`?{status:`absent`}:Ue(document.documentElement.dataset),Qe=null,$e=e=>{Qe=e},et=150,tt=(e=1e3)=>new Promise((t,n)=>{let r=()=>Ze().status===`ok`;if(r())return t();let i,a=e=>{clearTimeout(i),c.disconnect(),document.removeEventListener(`readystatechange`,l),e()},o=()=>a(async()=>{let e=Ze();if(e.status===`outdated`)return n(new Ge(e.abi,e.required));if(Qe){if(await Qe().catch(()=>{}),r())return t();let e=Ze();if(e.status===`outdated`)return n(new Ge(e.abi,e.required))}n(Error(`The FKN WebExtension is not installed, enabled or not exposed on this page.`))}),s=()=>{clearTimeout(i),i=setTimeout(()=>r()?a(t):o(),et)},c=new MutationObserver(()=>{r()&&a(t)}),l=()=>{document.readyState===`complete`&&!r()&&s()};if(i=setTimeout(o,e),c.observe(document.documentElement,{attributes:!0,attributeFilter:[...Be]}),document.addEventListener(`readystatechange`,l),document.readyState===`complete`)return s();r()&&a(t)}),nt,rt=new Proxy({},{get:(e,t)=>async(...e)=>{await tt(),nt??=i({},{transport:window,revivableModules:Ie});let n=(await nt)[t];return n(...e)}}),it=[`fkn.app`,`fkn.dev`,`sdbx.app`],at=e=>e.replace(/\.+$/,``),ot=e=>{let t=at(e);return it.some(e=>t===e||t.endsWith(`.${e}`))},st={scope:`network.fetch`,category:`network`,severity:0,title:`Fetch data from other sites`,description:`Lets the app download public data from other websites directly, past the usual cross-origin limits.`},ct={scope:`network.fetchCredentialed`,category:`network`,severity:3,chip:`load as you`,unsafe:!0,title:`Fetch from other sites, signed in as you`,description:`Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see.`},lt={scope:`network.fetchLocal`,category:`network`,severity:3,chip:`local network`,unsafe:!0,title:`Access devices on your local network`,description:`Lets the app reach devices and services on your home or work network, which websites normally cannot touch.`},ut={scope:`network.readCookie`,category:`network`,severity:3,chip:`read cookie`,unsafe:!0,title:`Read a site’s cookie`,description:`Lets the app read a named cookie from another site, which can include the login token only that site should see.`},dt={scope:`network.modifyRequestHeaders`,category:`network`,severity:2,chip:`rewrite headers`,unsafe:!0,title:`Rewrite request headers to other sites`,description:`Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites.`},ft=class extends Error{reason;filename;line;column;source;constructor(e,t,n,r,i){super(`${e}:${n}:${r}: ${t}`),this.reason=t,this.filename=e,this.line=n,this.column=r,this.source=i}},pt=class{start;end;source;constructor(e,t,n){this.start=e,this.end=t,this.source=n}},z;(function(e){e.stylesheet=`stylesheet`,e.rule=`rule`,e.declaration=`declaration`,e.comment=`comment`,e.atRule=`at-rule`,e.container=`container`,e.charset=`charset`,e.counterStyle=`counter-style`,e.document=`document`,e.customMedia=`custom-media`,e.fontFace=`font-face`,e.fontFeatureValues=`font-feature-values`,e.host=`host`,e.import=`import`,e.keyframes=`keyframes`,e.keyframe=`keyframe`,e.layer=`layer`,e.media=`media`,e.namespace=`namespace`,e.page=`page`,e.pageMarginBox=`page-margin-box`,e.positionTry=`position-try`,e.property=`property`,e.scope=`scope`,e.startingStyle=`starting-style`,e.supports=`supports`,e.viewTransition=`view-transition`})(z||={});var mt=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);if(e[o]!==`\\`)return o;r=o+2,i--}while(i>0);throw Error(`Too many escaping`)},ht=(e,t,n)=>{let r=n,i=1e4;do{let n=t.map(t=>e.indexOf(t,r));n.push(e.indexOf(`(`,r)),n.push(e.indexOf(`"`,r)),n.push(e.indexOf(`'`,r)),n.push(e.indexOf(`\\`,r));let a=n.filter(e=>e!==-1);if(a.length===0)return-1;let o=Math.min(...a);switch(e[o]){case`\\`:r=o+2;break;case`(`:{let t=ht(e,[`)`],o+1);if(t===-1)return-1;r=t+1}break;case`"`:{let t=mt(e,[`"`],o+1);if(t===-1)return-1;r=t+1}break;case`'`:{let t=mt(e,[`'`],o+1);if(t===-1)return-1;r=t+1}break;default:return o}i--}while(i>0);throw Error(`Too many escaping`)},gt=/\/\*[^]*?(?:\*\/|$)/g;function B(e){return e?e.trim():``}function _t(e,t){let n=e&&typeof e.type==`string`,r=n?e:t;for(let t in e){let n=e[t];Array.isArray(n)?n.forEach(e=>{_t(e,r)}):n&&typeof n==`object`&&_t(n,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var vt=class{level=0;indentation=` `;compress=!1;constructor(e){typeof e?.indent==`string`&&(this.indentation=e?.indent),e?.compress&&(this.compress=!0)}emit(e,t){return e}indent(e){return this.level=this.level||1,e?(this.level+=e,``):Array(this.level).join(this.indentation)}visit(e){switch(e.type){case z.stylesheet:return this.stylesheet(e);case z.rule:return this.rule(e);case z.declaration:return this.declaration(e);case z.comment:return this.comment(e);case z.container:return this.container(e);case z.charset:return this.charset(e);case z.counterStyle:return this.counterStyle(e);case z.document:return this.document(e);case z.customMedia:return this.customMedia(e);case z.fontFace:return this.fontFace(e);case z.fontFeatureValues:return this.fontFeatureValues(e);case z.host:return this.host(e);case z.import:return this.import(e);case z.keyframes:return this.keyframes(e);case z.keyframe:return this.keyframe(e);case z.layer:return this.layer(e);case z.media:return this.media(e);case z.namespace:return this.namespace(e);case z.page:return this.page(e);case z.pageMarginBox:return this.pageMarginBox(e);case z.positionTry:return this.positionTry(e);case z.property:return this.property(e);case z.scope:return this.scope(e);case z.startingStyle:return this.startingStyle(e);case z.supports:return this.supports(e);case z.viewTransition:return this.viewTransition(e);case z.atRule:return this.genericAtRule(e)}}mapVisit(e,t){let n=``;t||=``;for(let r=0,i=e.length;r<i;r++)n+=this.visit(e[r]),t&&r<i-1&&(n+=this.emit(t));return n}compile(e){return this.compress?e.stylesheet.rules.map(this.visit,this).join(``):this.stylesheet(e)}stylesheet(e){return this.mapVisit(e.stylesheet.rules,`
|
|
3
|
+
|
|
4
|
+
`)}comment(e){return this.compress?this.emit(``,e.position):this.emit(`${this.indent()}/*${e.comment}*/`,e.position)}container(e){return this.compress?this.emit(`@container ${e.container}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@container ${e.container}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
5
|
+
|
|
6
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}layer(e){return this.compress?this.emit(`@layer ${e.layer}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`):this.emit(`${this.indent()}@layer ${e.layer}`,e.position)+(e.rules?this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
7
|
+
|
|
8
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`):`;`)}import(e){return this.emit(`@import ${e.import};`,e.position)}media(e){return this.compress?this.emit(`@media ${e.media}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@media ${e.media}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
9
|
+
|
|
10
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}document(e){let t=`@${e.vendor||``}document ${e.document}`;return this.compress?this.emit(t,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(t,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
11
|
+
|
|
12
|
+
`)+this.emit(`${this.indent(-1)}\n}`)}charset(e){return this.emit(`@charset ${e.charset};`,e.position)}namespace(e){return this.emit(`@namespace ${e.namespace};`,e.position)}startingStyle(e){return this.compress?this.emit(`@starting-style`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@starting-style`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
13
|
+
|
|
14
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}supports(e){return this.compress?this.emit(`@supports ${e.supports}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@supports ${e.supports}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
15
|
+
|
|
16
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}keyframes(e){return this.compress?this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.keyframes)+this.emit(`}`):this.emit(`@${e.vendor||``}keyframes ${e.name}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.keyframes,`
|
|
17
|
+
`)+this.emit(`${this.indent(-1)}}`)}keyframe(e){let t=e.declarations;return this.compress?this.emit(e.values.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`):this.emit(this.indent())+this.emit(e.values.join(`, `),e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(t,`
|
|
18
|
+
`)+this.emit(`${this.indent(-1)}\n${this.indent()}}\n`)}page(e){if(this.compress){let t=e.selectors.length?e.selectors.join(`, `):``;return this.emit(`@page ${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`)}let t=e.selectors.length?`${e.selectors.join(`, `)} `:``;return this.emit(`@page ${t}`,e.position)+this.emit(`{
|
|
19
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
20
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
21
|
+
}`)}pageMarginBox(e){return this.compress?this.emit(`@${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`${this.indent()}@${e.name} `,e.position)+this.emit(`{
|
|
22
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
23
|
+
`)+this.emit(this.indent(-1))+this.emit(`\n${this.indent()}}`)}fontFace(e){return this.compress?this.emit(`@font-face`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@font-face `,e.position)+this.emit(`{
|
|
24
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
25
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
26
|
+
}`)}host(e){return this.compress?this.emit(`@host`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`@host`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
27
|
+
|
|
28
|
+
`)+this.emit(`${this.indent(-1)}\n}`)}customMedia(e){return this.emit(`@custom-media ${e.name} ${e.media};`,e.position)}property(e){return this.compress?this.emit(`@property ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@property ${e.name} `,e.position)+this.emit(`{
|
|
29
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
30
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
31
|
+
}`)}counterStyle(e){return this.compress?this.emit(`@counter-style ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@counter-style ${e.name} `,e.position)+this.emit(`{
|
|
32
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
33
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
34
|
+
}`)}fontFeatureValues(e){return this.compress?this.emit(`@font-feature-values ${e.fontFamily}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@font-feature-values ${e.fontFamily}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
35
|
+
|
|
36
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}scope(e){let t=e.scope?` ${e.scope}`:``;return this.compress?this.emit(`@scope${t}`,e.position)+this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):this.emit(`${this.indent()}@scope${t}`,e.position)+this.emit(` {\n${this.indent(1)}`)+this.mapVisit(e.rules,`
|
|
37
|
+
|
|
38
|
+
`)+this.emit(`\n${this.indent(-1)}${this.indent()}}`)}viewTransition(e){return this.compress?this.emit(`@view-transition`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@view-transition `,e.position)+this.emit(`{
|
|
39
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
40
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
41
|
+
}`)}positionTry(e){return this.compress?this.emit(`@position-try ${e.name}`,e.position)+this.emit(`{`)+this.mapVisit(e.declarations)+this.emit(`}`):this.emit(`@position-try ${e.name} `,e.position)+this.emit(`{
|
|
42
|
+
`)+this.emit(this.indent(1))+this.mapVisit(e.declarations,`
|
|
43
|
+
`)+this.emit(this.indent(-1))+this.emit(`
|
|
44
|
+
}`)}genericAtRule(e){let t=e.prelude?` ${e.prelude}`:``;if(this.compress)return this.emit(`@${e.name}${t}`,e.position)+(e.rules?this.emit(`{`)+this.mapVisit(e.rules)+this.emit(`}`):`;`);if(!e.rules)return this.emit(`${this.indent()}@${e.name}${t};`,e.position);let n=e.rules.some(e=>e.type!==z.declaration&&e.type!==z.comment),r=n?`
|
|
45
|
+
|
|
46
|
+
`:`
|
|
47
|
+
`;return this.emit(`${this.indent()}@${e.name}${t}`,e.position)+this.emit(n?` {\n${this.indent(1)}`:` {
|
|
48
|
+
`)+this.emit(n?``:this.indent(1))+this.mapVisit(e.rules,r)+this.emit(n?`\n${this.indent(-1)}${this.indent()}}`:`${this.indent(-1)}\n${this.indent()}}`)}rule(e){let t=e.declarations;if(!t.length)return``;if(this.compress)return this.emit(e.selectors.join(`,`),e.position)+this.emit(`{`)+this.mapVisit(t)+this.emit(`}`);let n=this.indent();return this.emit(e.selectors.map(e=>n+e).join(`,
|
|
49
|
+
`),e.position)+this.emit(` {
|
|
50
|
+
`)+this.emit(this.indent(1))+this.mapVisit(t,`
|
|
51
|
+
`)+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(`
|
|
52
|
+
`).join(`
|
|
53
|
+
`.padEnd(22)+this.indent()),e.position)+this.emit(`;`):this.emit(this.indent())+this.emit(`${e.property}: ${e.value}`,e.position)+this.emit(`;`)}},yt=(e,t)=>{t||={};let n=1,r=1;function i(){let e={line:n,column:r};return i=>(i.position=new pt(e,{line:n,column:r},t?.source||``),u(),i)}let a=[];function o(i){let o=new ft(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(`
|
|
54
|
+
`);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=ht(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=ht(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(gt,``),[`,`]).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=ht(e,[`;`,`}`]);c!==-1&&(s=e.substring(0,c),l([s]),s=B(s).replace(gt,``));let u=t({type:z.declaration,property:r.replace(gt,``),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=ht(e,[`{`]);if(t===-1)return!1;let n=ht(e,[`;`]),r=ht(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=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`].join(`|`)})(?![\\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=ht(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 _t(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}}}())},bt=(e,t)=>new vt(t||{}).compile(e),xt=Object.defineProperty,St=(e,t)=>{let n={};for(var r in e)xt(n,r,{get:e[r],enumerable:!0});return t||xt(n,Symbol.toStringTag,{value:`Module`}),n},Ct=`LocatorError`,wt=`LocatorUnsupportedError`,Tt=`LocatorDeniedError`,Et=`LocatorInvalidError`,Dt=e=>typeof e==`object`&&e?e.name:void 0,Ot=e=>Object.assign(Error(e),{name:Ct}),kt=(e,t=``,n)=>Object.assign(Error(e),{name:wt,operation:t,backend:n}),At=(e,t)=>kt(`Locator operation not supported${t?` on the ${t} backend`:``}: ${e}`,e,t),V=(e,t)=>Object.assign(Error(e),{name:Tt,operation:t}),jt=(e,t)=>Object.assign(Error(e),{name:Et,operation:t}),Mt=class extends Error{name=`TimeoutError`;constructor(e,t){super(e,t?.cause===void 0?void 0:{cause:t.cause})}},Nt=e=>Dt(e)===wt,Pt=e=>Dt(e)===Tt,Ft=e=>Dt(e)===Et,It=e=>Pt(e)||Nt(e)||Ft(e),Lt=e=>{let t=(e.ownerDocument??e).defaultView;if(!t)throw Ot(`the resolved element belongs to a document with no window`);return t},Rt=(e,t)=>{let n=e?.[t];return typeof n==`function`?n:null},zt=(e,t)=>{if(typeof e!=`object`||!e)return null;let n=(()=>{try{return Rt(Lt(e),t)}catch{return null}})();if(n&&e instanceof n)return n;let r=Rt(globalThis,t);return r&&e instanceof r?r:null},Bt=(e,t)=>zt(e,t)!==null,Vt=e=>{if(e.length===0)throw Ot(`No elements found`);if(e.length>1)throw Ot(`Strict mode violation: locator resolved to ${e.length} elements`);return e[0]},Ht=(e,t)=>{if(!Bt(e,t))throw Ot(`Strict mode violation: expected ${t}, got <${e.tagName.toLowerCase()}>`);return e},Ut=e=>e.tagName.toLowerCase(),Wt=new Set,Gt=e=>{Wt.add(e)},Kt=/(?:^|[^\w-])(?:url|image|image-set|cross-fade|paint|element|expression)\s*\(/i,qt=e=>e.replace(/\\([0-9a-fA-F]{1,6})\s?/g,(e,t)=>String.fromCodePoint(Number.parseInt(t,16))).replace(/\\(.)/g,`$1`),Jt=e=>!Kt.test(qt(e.value)),Yt=new Set([z.import,z.fontFace,z.namespace,z.charset,z.document,z.comment]),Xt=e=>{if(Yt.has(e.type))return null;if(e.type===z.declaration)return Jt(e)?e:null;let t=e,n={...t};for(let e of[`declarations`,`rules`,`keyframes`]){let r=t[e];Array.isArray(r)&&(n[e]=Zt(r))}return n},Zt=e=>e.map(e=>Xt(e)).filter(e=>e!==null),Qt=e=>{let t;try{t=yt(e,{silent:!0})}catch{return``}return t.stylesheet.rules=Zt(t.stylesheet.rules),bt(t)},$t=(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)},en={resolve:(e,t)=>{let n=e.document.createElement(`style`);n.textContent=t.noSanitize?t.content:Qt(t.content);try{$t(e.document,n)}catch(e){console.error(e)}Gt(n)}},tn=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},nn={kind:`frame`,ensureArgs:e=>[void 0,e],resolve:async(e,t,n={})=>{if(typeof t!=`string`)throw jt(`fetch: url must be a string`,`fetch`);let r=Lt(e.document),i;try{i=new r.URL(t,e.document.baseURI).href}catch{throw jt(`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:tn(a.headers),body:await a.arrayBuffer()}}},rn=St({click:()=>on,count:()=>mn,exists:()=>hn,fill:()=>un,getAttribute:()=>fn,hover:()=>sn,isVisible:()=>pn,textContent:()=>dn}),an=(e,t)=>{let n=e.getBoundingClientRect();return{clientX:n.left+n.width*(t?.x??.5),clientY:n.top+n.height*(t?.y??.5)}},on={resolve:(e,t={})=>{let n=Vt(e.elements),r=Lt(n),i={bubbles:!0,cancelable:!0,composed:!0,...an(n,t.position),button:0},a={...i,pointerType:`mouse`,pointerId:1,isPrimary:!0};n.dispatchEvent(new r.PointerEvent(`pointerdown`,{...a,buttons:1})),n.dispatchEvent(new r.MouseEvent(`mousedown`,{...i,buttons:1})),n.dispatchEvent(new r.PointerEvent(`pointerup`,{...a,buttons:0})),n.dispatchEvent(new r.MouseEvent(`mouseup`,{...i,buttons:0})),n.dispatchEvent(new r.MouseEvent(`click`,{...i,buttons:0}))}},sn={resolve:(e,t={})=>{let n=Vt(e.elements),r=Lt(n),i={bubbles:!0,cancelable:!0,composed:!0,...an(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=(zt(e,`HTMLTextAreaElement`)??zt(e,`HTMLInputElement`))?.prototype,r=n&&Object.getOwnPropertyDescriptor(n,`value`)?.set;r?r.call(e,t):e.value=t},ln=(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}}},un={resolve:(e,t,n={})=>{let r=Vt(e.elements),i=Lt(r),a=Bt(r,`HTMLInputElement`);if(a||Bt(r,`HTMLTextAreaElement`)){let e=r,n=a?ln(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}));return}if(Bt(r,`HTMLElement`)&&r.isContentEditable){r.textContent=t,r.dispatchEvent(new i.Event(`input`,{bubbles:!0}));return}throw Error(`fill: element <${Ut(r)}> is not fillable`)}},dn={resolve:(e,t={})=>Vt(e.elements).textContent},fn={resolve:(e,t,n={})=>Vt(e.elements).getAttribute(t)},pn={resolve:(e,t={})=>{let n=Vt(e.elements);if(!Bt(n,`HTMLElement`))return!0;let r=Lt(n).getComputedStyle(n);if(r?.display===`none`||r?.visibility===`hidden`)return!1;let i=n.getBoundingClientRect();return i.width>0&&i.height>0}},mn={resolve:(e,t={})=>e.elements.length},hn={resolve:(e,t={})=>e.elements.length>0},gn=(e,t)=>e.elements.flatMap(e=>[...e.querySelectorAll(t)]),_n=e=>e.replaceAll(`"`,`\\"`),vn={to:`element`,css:!0,resolve:(e,t)=>gn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`descend`})},yn={to:`frame`,css:!0,barrier:`down`,resolve:(e,t)=>gn(e,t),render:e=>({fragment:typeof e==`string`?e:`?`,separator:`down`})},bn={element:{selectors:{locator:vn,frameLocator:yn,getByRole:{to:`element`,resolve:(e,t)=>gn(e,`[role="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[role="${_n(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("${_n(e)}")`:`:has-text(...)`})},getByTestId:{to:`element`,resolve:(e,t)=>gn(e,`[data-testid="${CSS.escape(t)}"]`),render:e=>({fragment:typeof e==`string`?`[data-testid="${_n(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:on,fill:un,hover:sn,textContent:dn,getAttribute:fn,isVisible:pn,count:mn,exists:hn}},frame:{selectors:{locator:vn,frameLocator:yn,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:en,fetch:nn}}},xn=(e,t=bn)=>({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}}}),Sn=3e4,Cn=50,wn=e=>{let t=e[e.length-1];return typeof t==`object`&&t?t:void 0},Tn=e=>{let t=wn(e)?.timeout;return typeof t==`number`?t:Sn},En=({executor:e,parts:t})=>({highlight:n=>e.highlight(t,n).then(()=>{},()=>{})}),Dn=async e=>{let t={parts:e.parts,operation:e.operation,args:e.args,phase:`ensure`};await e.gate?.(t,En(e))},On=(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`)},kn=e=>typeof e==`object`&&e&&typeof e.message==`string`?e.message:String(e),An=async e=>{let{executor:t,gate:n,parts:r,operation:i,args:a}=e;On(i,wn(a)?.timeout),n&&await n({parts:r,operation:i,args:a,phase:`execute`},En(e));let o=Tn(a),s=Date.now()+o,c=Error(`Locator timeout (${o}ms): ${i}`),{promise:l,reject:u}=Promise.withResolvers();l.catch(()=>{});let d=setTimeout(()=>u(c),o),f=c;try{for(;Date.now()<s;)try{return await Promise.race([t.execute(r,i,a),l])}catch(e){if(e===c)break;if(It(e))throw e;f=e;let t=s-Date.now();if(t<=0)break;await new Promise(e=>setTimeout(e,Math.min(Cn,t)))}}finally{clearTimeout(d)}throw f===c?new Mt(c.message):new Mt(kn(f),{cause:f})},jn=(e,t,n,r,i)=>{let a={};for(let[o,s]of Object.entries(t[r].selectors))a[o]=(...a)=>jn(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)=>An({...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)=>jn(e,t,n,s,c(i,...r));return a.ensure=(n,a={})=>{let o=t[r].operations[n]?.ensureArgs;return Dn({...e,parts:i,operation:n,args:o?.(a)??[a]})},a},Mn=e=>jn(e,e.modules??bn,e.rewrites??{},`frame`,[]),Nn=()=>{let e=Ze();return e.status===`ok`&&e.abi>=2},Pn=async()=>{await tt();let e=Ze();if(e.status===`ok`&&e.abi<2)throw new Ge(e.abi,2)},Fn=e=>`Read the text, links and details ${e} shows.`,In=e=>`Inject unfiltered styles or code into ${e}. This can pass page details along to other sites.`,Ln=[{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:Fn,cloudTitle:e=>`Read what's on ${e}`,cloudDescription:Fn},{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:In,cloudTitle:e=>`Run its own code on ${e}`,cloudDescription:In}],Rn=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}]},zn=xn({element:{operations:{click:{resolve:(e,t={})=>rn.click.resolve(e,t),send:Rn(`click`)},hover:{resolve:(e,t={})=>rn.hover.resolve(e,t),send:Rn(`hover`)},fill:{resolve:(e,t,n={})=>rn.fill.resolve(e,t,n)},textContent:{resolve:(e,t={})=>rn.textContent.resolve(e)},getAttribute:{resolve:(e,t,n={})=>rn.getAttribute.resolve(e,t)},isVisible:{resolve:(e,t={})=>rn.isVisible.resolve(e)},count:{resolve:(e,t={})=>rn.count.resolve(e)},exists:{resolve:(e,t={})=>rn.exists.resolve(e)},videoElement:{resolve:(e,t={})=>Me(Ht(Vt(e.elements),`HTMLVideoElement`))}}},frame:{operations:{addStyleTag:{resolve:(e,t)=>en.resolve(e,t)},fetch:{resolve:(e,t,n={})=>nn.resolve(e,t,n),kind:nn.kind,ensureArgs:nn.ensureArgs},evaluate:{kind:`frame`,typed:!1,resolve:(e,t,n)=>{throw At(`evaluate`,`this realm`)}}}}}),Bn=e=>e[e.length-1],Vn={element:{last:{to:`element`,rewrite:e=>[...e,{kind:`element`,name:`nth`,args:[-1]}]},contentFrame:{to:`frame`,rewrite:e=>{let t=Bn(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=Bn(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]}]}}},Hn=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:`&&ot(t.hostname)},Un=e=>{if(Hn(e))throw Error(`attachFrame: refusing to target the extension's own pages or an FKN platform origin`)},Wn=({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`)},Gn={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.`},Kn={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.`},qn=[`load`,`commit`],Jn=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&&!qn.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`);On(`frame.goto`,n)},Yn=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`)}},Xn=new Set([`jar-unreachable`,`bad-url`,`opaque-opener`]),Zn=class extends Error{name=`FrameWindowRefusedError`;reason;constructor(e){let t=Xn.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}},Qn=[`message`,`document`],$n=e=>{if(e===`*`)return`*`;let t=()=>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},er=(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:$n(r),transfer:i===void 0?[]:[...i]}},tr=[`url`,`path`,`type`],nr=[`content`,`sourceUrl`],rr=/[\n\r\u2028\u2029]/,ir=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=>tr.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=>!nr.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===``||rr.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}},ar=[`name`,`domain`,`path`],or=e=>e instanceof RegExp||Object.prototype.toString.call(e)===`[object RegExp]`,sr=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=>!ar.includes(e));if(n!==void 0)throw TypeError(`frame.clearCookies: unknown option "${n}"`);let r=ar.flatMap(e=>{let n=t[e];return n===void 0?[]:[{key:e,value:n}]}),i=r.find(({value:e})=>or(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},cr=e=>{typeof globalThis.reportError==`function`?globalThis.reportError(e):console.error(e)},lr=e=>{let{owner:t,...n}=Mn({executor:e.executor,modules:zn,rewrites:Vn,gate:e.gate}),r=async(t,n={})=>(Un(t),Jn(n),e.goto(t,n)),i=()=>e.url(),a=async t=>{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}=ir(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=sr(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=er(n,r);return i(t,a.targetOrigin,a.transfer)}catch(e){return Promise.reject(e)}}),u={message:new Set,document:new Set},d=null,f=(e,t)=>{if(!Qn.includes(e))throw TypeError(`frame.${t}: the event type must be ${Qn.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){cr(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 _},ur=[w,T,E,D,O,k,A,j,M,ee,N,P,F,Gn,Kn,ne,re,st,ct,lt,ut,dt],dr=Ln.map(e=>e.id),fr={interaction:`act.click`,storage:`read.text`,network:`network.fetchCredentialed`,evaluation:`media.appearU`},pr=e=>e===0?`auto`:e===4?`critical`:`bundled`,mr=ur,hr=new Map;(()=>{hr=new Map(mr.map(e=>[e.scope,e])),Object.fromEntries(hr),mr.filter(e=>e.severity===4).map(e=>e.scope);let e=e=>mr.filter(t=>t.category===e&&pr(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 gr=e=>hr.get(e)?.category,_r=e=>{let t=hr.get(e);return t&&pr(t.severity)},vr=e=>{let t=hr.get(e);if(t)return pr(t.severity)===`critical`?t.scope:t.category},yr=e=>fr[e],br=({category:e,key:t})=>{let n=t??(e&&yr(e));return n!==void 0&&gr(n)!==void 0?n:void 0},xr=(e,t)=>{for(let{category:n,key:r}of t)if(br({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}"`)},Sr=e=>typeof e==`object`&&!!e,Cr=typeof chrome<`u`&&!!chrome.runtime?.id,wr=e=>Sr(e)&&e.FKN_WEB_EXTENSION_FRAME_ANNOUNCE_KEY===!0&&typeof e.frameId==`string`&&typeof e.document==`string`,Tr=new WeakMap,Er=new WeakMap,Dr=new WeakMap,Or=new Set;typeof window<`u`&&Cr&&window.addEventListener(`message`,e=>{if(!wr(e.data))return;e.stopImmediatePropagation();let t=e.source;if(!t||typeof t!=`object`)return;let n=t,r=Tr.get(n),i=e.data.frameId,a=e.data.document;if(Tr.set(n,i),Er.set(n,a),r)for(let e of Or)e(r);let o=Dr.get(n);if(o){for(let e of[...o])(e.notDocument===void 0||e.notDocument!==a)&&(o.delete(e),e.resolve(i));o.size||Dr.delete(n)}},{capture:!0});var kr=3e4,Ar=`frame.evaluate: the code did not settle within ${kr}ms`,jr=()=>new Mt(Ar),Mr=e=>Ft(e)&&e.message===Ar?jr():e,Nr=[/^frame load timed out after \d+ms for /,/^frame goto: documentstart timed out$/,/^navigation to .+ did not commit a document within \d+ms$/s],Pr=e=>{if(e instanceof Mt)return e;let t=typeof e?.message==`string`?e.message:``;return Nr.some(e=>e.test(t))?new Mt(t):e},Fr=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`},Ir=(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)},Lr=({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&&Un(r),{url:r,width:Ir(t,500,`width`),height:Ir(n,700,`height`)}},Rr=[`persistent`,`ephemeral`,`native`],zr=`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'`,Br=e=>{if(`syncCookies`in e)throw TypeError(zr);let{cookies:t=`persistent`}=e;if(!Rr.includes(t))throw TypeError(`attachFrame: cookies must be 'persistent', 'ephemeral' or 'native', not ${JSON.stringify(t)}`);if(`storageState`in e)throw TypeError(`attachFrame: storageState is not available yet`);let n=Fr(e);if(n===`iframe`&&e.lockdown&&t!==`native`)throw TypeError(`attachFrame: lockdown runs on the extension, which serves only cookies: 'native'`);return{kind:n,cookies:t}},Vr=e=>{try{return new URL(e).hostname}catch{return``}},Hr=`FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY`,Ur=!1,Wr=()=>{Ur||(Ur=!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.`))},Gr=`frame: this frame no longer holds the document the app attached it to`,Kr=`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`,qr=()=>{let e=Ze();if(e.status===`ok`&&e.abi>=1)return;let t=e.status===`absent`?0:e.abi;throw new Ke(`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.`)},Jr=e=>{try{return new URL(e,location.href).hostname}catch{return``}},Yr=()=>{let e=Ze();return e.status===`absent`?0:e.abi},Xr=`attachFrame: a blank page is served by the cloud render proxy only; call cloud.attachFrame`,Zr=`frame.addScriptTag: an extension frame does not run scripts through mirage yet; attach with cloud.attachFrame`,Qr=`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`,$r=async({iframe:e,domains:t=[],lockdown:n=!1,permissions:r,blank:i})=>{if(i!==void 0)throw new Ke(`blank`,Yr(),Xr);let a=crypto.randomUUID();if(Un(e.src),Wn({src:e.src,domains:t,lockdown:n}),await tt(),n&&qr(),!e.isConnected)throw Error(`attachFrame: the iframe must be connected to the document before attaching`);e.dispatchEvent(new CustomEvent(Hr,{detail:a}));let{executeLocator:o,highlightLocator:s,ensureLocatorPermission:c,requestCategories:l,evaluateFrame:u,goto:d}=await rt.attachFrame({marker:a,domains:t,syncCookies:!0,lockdown:n}),f=new Set(R([...t,Jr(e.src)],{ipv6:!0})),p=e=>f.has(R([Vr(e)],{ipv6:!0})[0]??``),m=lr({backend:`extension`,executor:{execute:o,highlight:s},gate:e=>c(e.parts,e.operation,e.args),requestPermissions:async e=>(xr(`frame.requestPermissions`,e),await Pn(),l(e)),evaluate:async(e,t)=>{if(!We(Ze(),`evaluate`)){let e=Ze();throw new Ke(`evaluate`,e.status===`ok`?e.abi:0)}return u({source:e,arg:t}).catch(e=>{throw Mr(e)})},addScriptTag:async()=>{throw new Ke(`addScriptTag`,Yr(),Zr)},clearCookies:async()=>{throw new Ke(`clearCookies`,Yr(),Qr)},postMessage:(t,n,r)=>{if(n===`*`)throw kt(Kr,`postMessage`,`extension`);if(!p(n))throw V(Gr,`postMessage`);let i=e.contentWindow;if(i===null)throw V(`frame: navigate the frame before postMessage`,`postMessage`);return i.postMessage(t,n,r),Promise.resolve()},listen:t=>{let n=n=>{n.source!==null&&n.source===e.contentWindow&&!wr(n.data)&&p(n.origin)&&t({type:`message`,data:n.data,origin:n.origin,ports:n.ports})},r=()=>t({type:`document`,origin:``});return window.addEventListener(`message`,n),e.addEventListener(`load`,r),()=>{window.removeEventListener(`message`,n),e.removeEventListener(`load`,r)}},goto:(e,{waitUntil:t,timeout:n,...r}={})=>{for(let t of R([Jr(e)],{ipv6:!0}))f.add(t);return d({url:e,...r,...t===void 0?{}:{waitUntil:t===`commit`?`documentstart`:t},...n===void 0?{}:{timeoutMs:n}}).catch(e=>{throw Pr(e)})},url:()=>e.src});return r?.length&&(Nn()?await m.requestPermissions(r):Wr()),m},ei=`attachFrame: a window on cookies: 'native' is not served yet; a window runs on the cloud render proxy, which has no browser cookies`,ti=e=>`attachFrame: cookies: '${e}' runs on the cloud render proxy; call cloud.attachFrame or the top-level attachFrame`,ni=async e=>{throw Lr(e.window),new Ke(`attachWindow`,Yr(),ei)},ri=(async e=>{let{kind:t,cookies:n}=Br(e);if(n!==`native`)throw new Ke(`cookies`,Yr(),ti(n));return t===`window`?ni(e):$r(e)}),ii=new Map,ai=new Set,oi=e=>{ii.set(e,(ii.get(e)??0)+1);let t=!1;return()=>{t||(t=!0,ii.set(e,Math.max(0,(ii.get(e)??1)-1)))}},si=(e,t)=>{ai.add({kind:e,probe:t})},ci=typeof FinalizationRegistry>`u`?void 0:new FinalizationRegistry(e=>e()),li=e=>{let t=e.body;if(!t)return e;let n=oi(`streamed response`),r=t.getReader(),i=new ReadableStream({pull:async e=>{try{let{done:t,value:i}=await r.read();if(t){n(),e.close();return}e.enqueue(i)}catch(t){n(),e.error(t)}},cancel:async e=>{n(),await r.cancel(e).catch(()=>{})}}),a=new Response(i,{status:e.status,statusText:e.statusText,headers:e.headers});return ci?.register(a,n),a},ui=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()},di=async e=>{if(e.method===`GET`||e.method===`HEAD`)return;let t=await e.clone().arrayBuffer();return t.byteLength?t:void 0},fi=async(e,t)=>{if(m(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 ui(t?.body===void 0?await di(n):t.body);return g.then(e=>e.cloud.fetch(n.url,{...t,method:t?.method??n.method,headers:t?.headers??r,body:i})).then(li)}let n=e instanceof URL?e.href:e,r=await ui(t?.body);return g.then(e=>e.cloud.fetch(n,t?.body===void 0?t:{...t,body:r})).then(li)},pi=(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`&&le(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}},mi=`fkn-attach-frame`,hi=`fkn-attach-window`,gi={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},_i=6e4,vi={default:6048e5,min:6e4,max:31536e6},yi=d({lookup:()=>bi}),bi=(e,t)=>g.then(n=>n.cloud.dns.lookup(e,t)),xi=t({Blob:()=>Li,BlobOptions:()=>Ri,Buffer:()=>W,File:()=>zi,FileOptions:()=>Bi,INSPECT_MAX_BYTES:()=>Vi,SlowBuffer:()=>Hi,TranscodeEncoding:()=>Ui,atob:()=>Wi,btoa:()=>Gi,constants:()=>Ki,default:()=>Ii,isAscii:()=>qi,isUtf8:()=>Ji,kMaxLength:()=>Yi,kStringMaxLength:()=>Xi,resolveObjectURL:()=>Zi,transcode:()=>Qi});function Si(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 Ci(e){var t=Si(e),n=t[0],r=t[1];return(n+r)*3/4-r}function wi(e,t,n){return(t+n)*3/4-n}function Ti(e){for(var t,n=Si(e),r=n[0],i=n[1],a=new ji(wi(e,r,i)),o=0,s=i>0?r-4:r,c=0;c<s;c+=4)t=U[e.charCodeAt(c)]<<18|U[e.charCodeAt(c+1)]<<12|U[e.charCodeAt(c+2)]<<6|U[e.charCodeAt(c+3)],a[o++]=t>>16&255,a[o++]=t>>8&255,a[o++]=t&255;return i===2&&(t=U[e.charCodeAt(c)]<<2|U[e.charCodeAt(c+1)]>>4,a[o++]=t&255),i===1&&(t=U[e.charCodeAt(c)]<<10|U[e.charCodeAt(c+1)]<<4|U[e.charCodeAt(c+2)]>>2,a[o++]=t>>8&255,a[o++]=t&255),a}function Ei(e){return Ai[e>>18&63]+Ai[e>>12&63]+Ai[e>>6&63]+Ai[e&63]}function Di(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(Ei(r));return i.join(``)}function Oi(e){for(var t,n=e.length,r=n%3,i=[],a=16383,o=0,s=n-r;o<s;o+=a)i.push(Di(e,o,o+a>s?s:o+a));return r===1?(t=e[n-1],i.push(Ai[t>>2]+Ai[t<<4&63]+`==`)):r===2&&(t=(e[n-2]<<8)+e[n-1],i.push(Ai[t>>10]+Ai[t>>4&63]+Ai[t<<2&63]+`=`)),i.join(``)}var H,ki,Ai,U,ji,Mi,Ni,Pi,Fi,Ii,Li,Ri,W,zi,Bi,Vi,Hi,Ui,Wi,Gi,Ki,qi,Ji,Yi,Xi,Zi,Qi,$i=n((()=>{for(H={},ki={},ki.byteLength=Ci,ki.toByteArray=Ti,ki.fromByteArray=Oi,Ai=[],U=[],ji=typeof Uint8Array<`u`?Uint8Array:Array,Mi=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ni=0,Pi=Mi.length;Ni<Pi;++Ni)Ai[Ni]=Mi[Ni],U[Mi.charCodeAt(Ni)]=Ni;U[45]=62,U[95]=63,Fi={},Fi.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)},Fi.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=ki,n=Fi,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 ee(this,t,n);case`ascii`:return F(this,t,n);case`latin1`:case`binary`:return te(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?ee(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 ee(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 P(r)}let N=4096;function P(e){let t=e.length;if(t<=N)return String.fromCharCode.apply(String,e);let n=``,r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=N));return n}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]&127);return r}function te(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){R(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){R(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 ce(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 ce(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return ce(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 le={};function ue(e,t,n){le[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}`}}}ue(`ERR_BUFFER_OUT_OF_BOUNDS`,function(e){return e?`${e} is outside of buffer bounds`:`Attempt to access memory outside buffer bounds`},RangeError),ue(`ERR_INVALID_ARG_TYPE`,function(e,t){return`The "${e}" argument must be of type number. Received type ${typeof t}`},TypeError),ue(`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=de(String(n)):typeof n==`bigint`&&(i=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(i=de(i)),i+=`n`),r+=` It must be ${t}. Received ${i}`,r},RangeError);function de(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 fe(e,t,n){pe(t,`offset`),(e[t]===void 0||e[t+n]===void 0)&&me(t,e.length-(n+1))}function R(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 le.ERR_OUT_OF_RANGE(`value`,i,e)}fe(r,i,a)}function pe(e,t){if(typeof e!=`number`)throw new le.ERR_INVALID_ARG_TYPE(t,`number`,e)}function me(e,t,n){throw Math.floor(e)===e?t<0?new le.ERR_BUFFER_OUT_OF_BOUNDS:new le.ERR_OUT_OF_RANGE(n||`offset`,`>= ${+!!n} and <= ${t}`,e):(pe(e,n),new le.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){(t-=3)>-1&&a.push(239,191,189);continue}if(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`)}})(H),Ii=H.Buffer,Li=H.Blob,Ri=H.BlobOptions,W=H.Buffer,zi=H.File,Bi=H.FileOptions,Vi=H.INSPECT_MAX_BYTES,Hi=H.SlowBuffer,Ui=H.TranscodeEncoding,Wi=H.atob,Gi=H.btoa,Ki=H.constants,qi=H.isAscii,Ji=H.isUtf8,Yi=H.kMaxLength,Xi=H.kStringMaxLength,Zi=H.resolveObjectURL,Qi=H.transcode}));$i();var ea={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`},ta=(e,t)=>{if(t)return t;let n=e.split(`/`).pop()??``,r=n.lastIndexOf(`.`);if(!(r<=0))return ea[n.slice(r+1).toLowerCase()]},na=(e,t)=>({size:e,mtimeMs:t,mtime:new Date(t),atimeMs:t,ctimeMs:t,mode:420,isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}),ra=(e=0)=>({size:0,mtimeMs:e,mtime:new Date(e),atimeMs:e,ctimeMs:e,mode:493,isFile:()=>!1,isDirectory:()=>!0,isSymbolicLink:()=>!1}),G=(e,t,n)=>{let r=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`}[e]??e}, ${n} '${t}'`);return r.code=e,r.path=t,r.syscall=n,r},K=e=>{let t=[];for(let n of e.split(`/`))if(n&&n!==`.`){if(n===`..`){t.pop();continue}t.push(n)}return t.join(`/`)},ia=e=>e.split(`/`).slice(0,-1).join(`/`),q=e=>typeof e==`string`?e:e instanceof URL?decodeURIComponent(e.pathname):e.toString(),aa=e=>typeof e==`string`?e:e?.encoding??void 0,oa=e=>typeof e==`object`?e?.contentType:void 0,sa=e=>typeof e==`object`&&!!e?.recursive,ca=(e,t)=>{let n=aa(t);return n?W.from(e).toString(n):W.from(e)},la=(e,t)=>{if(typeof e==`string`)return new Uint8Array(W.from(e,aa(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`)},ua=e=>{let t=new Map([[``,{kind:`dir`,mtimeMs:0}]]),n=new Map,r=new Map,i=()=>e.captureAccount?{pin:e.captureAccount()}:{};si(`unsaved files`,()=>n.size>0||r.size>0);let a=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 G(`ENOTDIR`,r,`mkdir`)}},c,l=0,u=async()=>{let c=i(),u=await e.list(c).catch(()=>[]),d=new Set,f=!1;for(let i of u){let l=K(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(ia(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=ta(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 addEventListener<`u`&&(addEventListener(`pagehide`,()=>{p().catch(()=>{})}),addEventListener(`visibilitychange`,()=>{typeof document<`u`&&document.visibilityState===`hidden`&&p().catch(()=>{})}));let g=e=>e.kind===`file`?na(e.data.byteLength,e.mtimeMs):ra(e.mtimeMs),_=e=>Object.assign(Error(`storage: ${e} exists but could not be read, retry once its scope is available`),{code:`FKN_E2E_LOCKED`}),v=e=>{let n=K(e);return t.has(n)||a.has(n)},y=e=>{let n=K(e),r=t.get(n);if(!r)throw a.has(n)?_(e):G(`ENOENT`,e,`stat`);return g(r)},b=e=>{let n=K(e),r=t.get(n);if(!r)throw a.has(n)?_(e):G(`ENOENT`,e,`open`);if(r.kind===`dir`)throw G(`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=K(e);if(!d)throw G(`EISDIR`,e,`open`);if(a.has(d))throw _(e);let f=t.get(d);if(f?.kind===`dir`)throw G(`EISDIR`,e,`open`);s(ia(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=K(e);if(r){if(t.has(r)){if(n)return;throw G(`EEXIST`,e,`mkdir`)}if(!n&&!t.has(ia(r)))throw G(`ENOENT`,e,`mkdir`);s(r)}},w=e=>{let n=K(e),r=t.get(n);if(!r)throw G(`ENOENT`,e,`scandir`);if(r.kind===`file`)throw G(`ENOTDIR`,e,`scandir`);let i=n?`${n}/`:``,o=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=K(e),d=t.get(u);if(!d&&a.has(u)){if(o===`rmdir`)throw G(`ENOTDIR`,e,`rmdir`);a.delete(u),n.delete(u),r.set(u,l),h();return}if(!d){if(c||o===`rmdir`&&s)return;throw G(`ENOENT`,e,o===`rmdir`?`rmdir`:`unlink`)}if(o===`unlink`&&d.kind===`dir`)throw G(`EISDIR`,e,`unlink`);if(o===`rmdir`&&d.kind===`file`)throw G(`ENOTDIR`,e,`rmdir`);if(o===`rm`&&d.kind===`dir`&&!s)throw G(`ERR_FS_EISDIR`,e,`rm`);let f=`${u}/`,p=[...t.keys()].filter(e=>e.startsWith(f));if(p.length&&!s)throw G(`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=K(e),u=K(o);if(!l)throw G(`EBUSY`,e,`rename`);if(u===l||u.startsWith(`${l}/`))throw G(`EINVAL`,e,`rename`);if(a.has(l))throw _(e);if(a.has(u))throw _(o);let d=t.get(l);if(!d)throw G(`ENOENT`,e,`rename`);let f=t.get(u);if(f){if(f.kind!==d.kind)throw G(d.kind===`dir`?`ENOTDIR`:`EISDIR`,o,`rename`);T(u,{op:`rm`,recursive:!0,force:!0})}s(ia(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()}}},da=(e,t)=>typeof e==`function`?e:t,fa=e=>typeof e==`function`?void 0:e,pa=(e,t)=>{e.then(e=>t(null,e),e=>t(e))},ma=e=>{let t=ua(e),n=(e,n)=>ca(t.readFile(q(e)),n),r=(e,n,r)=>t.writeFile(q(e),la(n,r),!1,oa(r)),i=(e,n,r)=>t.writeFile(q(e),la(n,r),!0,oa(r)),a=e=>t.exists(q(e)),o=e=>t.stat(q(e)),s=e=>t.readdir(q(e)),c=(e,n)=>t.mkdir(q(e),sa(n)),l=(e,n)=>t.remove(q(e),{op:`rm`,...n}),u=(e,n)=>t.remove(q(e),{op:`rmdir`,...n}),d=e=>t.remove(q(e),{op:`unlink`}),f=(e,n)=>t.rename(q(e),q(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(()=>ca(t.readFile(q(e)),fa(n)),da(n,r)),writeFile:(e,n,r,i)=>p(()=>t.writeFile(q(e),la(n,fa(r)),!1,oa(fa(r))),da(r,i)),appendFile:(e,n,r,i)=>p(()=>t.writeFile(q(e),la(n,fa(r)),!0,oa(fa(r))),da(r,i)),stat:(e,n)=>p(()=>t.stat(q(e)),n),readdir:(e,n,r)=>p(()=>t.readdir(q(e)),da(n,r)),mkdir:(e,n,r)=>p(()=>t.mkdir(q(e),sa(fa(n))),da(n,r)),rm:(e,n,r)=>p(()=>t.remove(q(e),{op:`rm`,...fa(n)}),da(n,r)),unlink:(e,n)=>p(()=>t.remove(q(e),{op:`unlink`}),n),rename:(e,n,r)=>p(()=>t.rename(q(e),q(n)),r),exists:(e,n)=>{t.mount().finally(()=>n(t.exists(q(e))))},promises:{readFile:(e,n)=>m(()=>ca(t.readFile(q(e)),n)),writeFile:(e,n,r)=>m(()=>t.writeFile(q(e),la(n,r),!1,oa(r))),appendFile:(e,n,r)=>m(()=>t.writeFile(q(e),la(n,r),!0,oa(r))),stat:e=>m(()=>t.stat(q(e))),lstat:e=>m(()=>t.stat(q(e))),readdir:e=>m(()=>t.readdir(q(e))),mkdir:(e,n)=>m(()=>t.mkdir(q(e),sa(n))),rm:(e,n)=>m(()=>t.remove(q(e),{op:`rm`,...n})),rmdir:(e,n)=>m(()=>t.remove(q(e),{op:`rmdir`,...n})),unlink:e=>m(()=>t.remove(q(e),{op:`unlink`})),rename:(e,n)=>m(()=>t.rename(q(e),q(n))),access:e=>m(()=>{if(!t.exists(q(e)))throw G(`ENOENT`,q(e),`access`)})},mount:t.mount,flush:t.flush,remount:t.remount}},ha=e=>{let t=()=>e.captureAccount?{pin:e.captureAccount()}:{},n=async(t,n)=>{let r=await e.readFile(q(t));return ca(new Uint8Array(await r.arrayBuffer()),n)},r=async(t,n,r)=>{let i=q(t),a=ta(i,oa(r));await e.writeFile(i,la(n,r),a?{contentType:a}:void 0)},i=t=>e.remove(q(t)),a=async(n,r)=>{let i=t(),a=K(q(n)),o=K(q(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=K(q(t)),r=n?`${n}/`:``,i=new Set;for(let t of await e.list()){let e=K(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=K(q(n));if(!r?.recursive){await e.remove(q(n),i);return}let o=`${a}/`,s=await e.list(i);await Promise.all(s.filter(e=>{let t=K(e.path);return t===a||t.startsWith(o)}).map(t=>e.remove(t.path,i).catch(()=>{})))},l=async t=>{let n=K(q(t)),r=await e.list(),i=r.find(e=>K(e.path)===n);if(i){let e=Date.parse(i.updatedAt??``);return na(i.size,Number.isFinite(e)?e:0)}if(r.some(e=>K(e.path).startsWith(`${n}/`)))return ra();throw G(`ENOENT`,q(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)=>pa(n(e,fa(t)),da(t,r)),writeFile:(e,t,n,i)=>pa(r(e,t,fa(n)),da(n,i)),unlink:(e,t)=>pa(i(e),t),rename:(e,t,n)=>pa(a(e,t),n),readdir:(e,t,n)=>pa(o(e),da(t,n)),mkdir:(e,t,n)=>pa(s(),da(t,n)),rm:(e,t,n)=>pa(c(e,fa(t)),da(t,n)),stat:(e,t)=>pa(l(e),t)}};function ga(e,t){return t.memfs?ma(e):ha(e)}var _a=`FKN_STORAGE_NOT_FOUND`,va=`FKN_ACCOUNT_CHANGED`,ya=`FKN_ACCOUNT_PIN_UNSUPPORTED`,ba=d({StorageAccountChangedError:()=>wa,StorageAccountPinUnsupportedError:()=>Ta,StorageLockedError:()=>xa,StorageNotFoundError:()=>Sa,availability:()=>Wa,available:()=>za,captureAccount:()=>J,encryption:()=>Qa,isAccountChanged:()=>Ea,isInvalidPin:()=>Da,isNotFound:()=>Ca,knownPin:()=>Pa,list:()=>Ga,pinFor:()=>Fa,quota:()=>Ka,readFile:()=>qa,readFileSealed:()=>Ya,remove:()=>Za,unlock:()=>$a,writeFile:()=>Xa}),xa=class extends Error{code=`FKN_E2E_LOCKED`;constructor(){super(`storage locked: connect the app again to open encrypted data`)}},Sa=class extends Error{code=_a;constructor(e=`storage: no object at that path`){super(e)}},Ca=e=>e?.code===_a,wa=class extends Error{code=va;constructor(e=`storage: the signed-in account changed, so this call was not made`){super(e)}},Ta=class extends Error{code=ya;constructor(e=`storage: the FKN broker cannot pin calls to an account yet, so nothing was sent`){super(e)}},Ea=e=>e?.code===`FKN_ACCOUNT_CHANGED`||e instanceof Error&&e.message.startsWith(`fkn:account-changed`),Da=e=>e instanceof Error&&e.message.startsWith(`fkn:account-pin-invalid`),Oa=e=>{throw e instanceof Error&&e.message.startsWith(`fkn:e2e-locked`)?new xa:Ca(e)?new Sa(e.message):Ea(e)?new wa:e instanceof Error&&e.message.startsWith(`fkn:account-pin-unsupported`)?new Ta:e instanceof Error&&(/^not found$/i.test(e.message)||/\(404\)$/.test(e.message))?new Sa(e.message):e},J=()=>(f(),{generation:p()}),ka=new Map,Aa=null,ja=e=>typeof e?.accountPin==`function`,Ma=(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 p()===e&&ka.set(e,t),t});return Aa={generation:e,pin:n},n.catch(()=>{Aa?.pin===n&&(Aa=null)}),n},Na=async(e,t)=>{let n=ka.get(e.generation);if(n!==void 0)return n;if(e.generation!==p())throw new wa;let r=await(Aa?.generation===e.generation?Aa.pin:Ma(e.generation,t)).catch(Oa);if(e.generation!==p())throw new wa;return r},Pa=e=>ka.get(e.generation),Fa=async e=>{let t=(await g).cloud.fs;if(!ja(t))throw new Ta;return Na(e,t)},Ia=e=>{for(let[t,n]of ka)if(n===e)return t},La=e=>e?.pin??J(),Ra=async(e,t)=>{let n=(await g).cloud.fs;if(!ja(n))throw new Ta;let r=`pin`in e?e.pin:await Na(e,n);if(!ja(n))throw new Ta;return t(n,{accountPin:r}).catch(t=>{if(Ea(t)){let t=`generation`in e?e.generation:Ia(r);t!==void 0&&u(t)}return Oa(t)})},za=()=>g.then(e=>e.cloud.fs.available()).catch(()=>!1),Ba=8e3,Va=1e3,Ha=!1,Ua=async()=>{let e=(await g).cloud.fs;return typeof e.availability==`function`?e.availability():await e.available()?`connected`:`disconnected`},Wa=async()=>{let e=Ha?Va:Ba,t=await new Promise(t=>{let n=setTimeout(()=>t(`timeout`),e);Ua().then(e=>{clearTimeout(n),t(e)},()=>{clearTimeout(n),t(`unknown`)})});return t===`timeout`?(Ha=!0,`unknown`):(Ha=!1,t)},Ga=e=>Ra(La(e),(e,t)=>e.list(t)),Ka=()=>g.then(e=>e.cloud.fs.quota()),qa=async(e,t)=>{let n=await Ra(La(t),(t,n)=>t.readFile(e,n));return new Blob([n])},Ja=e=>{if(e===null||!Number.isFinite(e))return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()},Ya=async(e,t)=>Ra(La(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:Ja(i.sealedAt)}}),Xa=async(e,t,n)=>{let r=La(n),i=t instanceof Blob?new Uint8Array(await t.arrayBuffer()):t;await Ra(r,(t,r)=>t.writeFile(e,i,n?.contentType??null,r))},Za=async(e,t)=>{await Ra(La(t),(t,n)=>t.remove(e,n))},Qa=()=>g.then(e=>e.cloud.fs.encryption()),$a=()=>g.then(e=>e.cloud.fs.unlock()),eo=d({STORAGE_ACCOUNT_CHANGED:()=>va,STORAGE_ACCOUNT_PIN_UNSUPPORTED:()=>ya,STORAGE_NOT_FOUND:()=>_a,StorageAccountChangedError:()=>wa,StorageAccountPinUnsupportedError:()=>Ta,StorageLockedError:()=>xa,StorageNotFoundError:()=>Sa,availability:()=>Wa,available:()=>to,encryption:()=>Qa,isAccountChanged:()=>Ea,isNotFound:()=>Ca,list:()=>fo,mkdir:()=>so,promises:()=>uo,quota:()=>Ka,readFile:()=>no,readFileSealed:()=>po,readdir:()=>oo,rename:()=>ao,rm:()=>co,stat:()=>lo,unlink:()=>io,unlock:()=>$a,writeFile:()=>ro}),{available:to,readFile:no,writeFile:ro,unlink:io,rename:ao,readdir:oo,mkdir:so,rm:co,stat:lo,promises:uo}=ga(ba,{memfs:!1}),fo=()=>Ga(),po=e=>Ya(e),mo=r((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}}})),ho=r((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=mo();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`}})),go=r((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]]})),_o=r((e=>{var t=e&&e.__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]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address4=void 0;var i=r(ho()),a=r(go()),o=mo(),s=i.isCorrect(a.BITS),c=class e{constructor(e){this.addressMinusSuffix=``,this.groups=a.GROUPS,this.parsedAddress=[],this.parsedSubnet=``,this.subnet=`/32`,this.subnetMask=32,this.v4=!0,this.isCorrect=s,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.address=e;let t=a.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>a.BITS)throw new o.AddressError(`Invalid subnet mask.`);e=e.replace(a.RE_SUBNET_STRING,``)}let n=a.GROUPS*4-1;if(e.length>n)throw new o.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 o.AddressError(`IPv4 addresses can't have leading zeroes.`);if(!e.match(a.RE_ADDRESS))throw new o.AddressError(`Invalid IPv4 address.`);return t}correctForm(){return this.parsedAddress.map(e=>parseInt(e,10)).join(`.`)}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),a.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(a.BITS))-BigInt(1),o=i.prefixLengthFromMask(r,a.BITS);return new e(`${t}/${o}`)}static fromWildcard(t){let n=t.split(`.`);if(n.length!==a.GROUPS)throw new o.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 o.AddressError("Wildcard `*` must only appear in trailing octets (e.g. `192.168.0.*`)");let i=r===-1?0:n.length-r,s=n.map(e=>e===`*`?`0`:e),c=a.BITS-i*8;return new e(`${s.join(`.`)}/${c}`)}static fromHex(t){let n=t.replace(/:/g,``);if(!/^[0-9a-fA-F]{8}$/.test(n))throw new o.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 o.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=a.GROUPS*4-1+3+14;if(t.length>n)throw new o.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=>i.stringToPaddedHex(e)).join(`:`)}toArray(){return this.parsedAddress.map(e=>parseInt(e,10))}toGroup6(){let e=[],t=0;for(;t<a.GROUPS;t+=2)e.push(`${i.stringToPaddedHex(this.parsedAddress[t])}${i.stringToPaddedHex(this.parsedAddress[t+1])}`);return e.join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(e=>i.stringToPaddedHex(e)).join(``)}`)}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(a.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(i.offsetBigInt(this.bigInt(),t,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,a.BITS,`IPv4`)).withSubnetMask(this.subnetMask)}withSubnetMask(t){return new e(`${this.correctForm()}/${t}`)}_endAddress(){return BigInt(`0b${this.mask()+`1`.repeat(a.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(a.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(a.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}static fromBigInt(t){if(t<BigInt(0)||t>BigInt(4294967295))throw new o.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 i.assertByteArray(e,4,`IPv4`,0),this.fromUnsignedByteArray(e)}static fromUnsignedByteArray(t){if(t.length!==4)throw new o.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(l)}isPrivate(){return u.some(e=>this.isHostInSubnet(e))}isLoopback(){return this.isHostInSubnet(d)}isLinkLocal(){return this.isHostInSubnet(f)}isUnspecified(){return this.isHostInSubnet(p)}isBroadcast(){return this.isHostInSubnet(m)}isCGNAT(){return this.isHostInSubnet(h)}isDocumentation(){return g.some(e=>this.isHostInSubnet(e))}isBenchmarking(){return this.isHostInSubnet(_)}isReserved(){return this.isHostInSubnet(v)}isGlobal(){return!this.isMulticast()&&i.isGloballyReachable.call(this,y)}binaryZeroPad(){return this._binaryZeroPad===void 0&&(this._binaryZeroPad=this.bigInt().toString(2).padStart(a.BITS,`0`)),this._binaryZeroPad}groupForV6(){let e=this.parsedAddress;return this.correctForm().replace(a.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=c;var l=new c(`224.0.0.0/4`),u=[new c(`10.0.0.0/8`),new c(`172.16.0.0/12`),new c(`192.168.0.0/16`)],d=new c(`127.0.0.0/8`),f=new c(`169.254.0.0/16`),p=new c(`0.0.0.0/32`),m=new c(`255.255.255.255/32`),h=new c(`100.64.0.0/10`),g=[new c(`192.0.2.0/24`),new c(`198.51.100.0/24`),new c(`203.0.113.0/24`)],_=new c(`198.18.0.0/15`),v=new c(`240.0.0.0/4`),y=a.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new c(e),reachable:t}))})),vo=r((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]]})),yo=r((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>`)}})),bo=r((e=>{var t=e&&e.__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]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.ADDRESS_BOUNDARY=void 0,e.groupPossibilities=a,e.padGroup=o,e.simpleRegularExpression=s,e.possibleElisions=c;var i=r(vo());function a(e){return`(${e.join(`|`)})`}function o(e){return e.length<4?`0{0,${4-e.length}}${e}`:e}e.ADDRESS_BOUNDARY=`[^A-Fa-f0-9:]`;function s(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===i.GROUPS-1?`:`:``;return a([o(e),t])}return o(e)}).join(`:`));return n.push(e.map(o).join(`:`)),a(n)}function c(e,t,n){let r=t?``:`:`,i=n?``:`:`,o=[];!t&&!n&&o.push(`::`),t&&n&&o.push(``),(n&&!t||!n&&t)&&o.push(`:`),o.push(`${r}(:0{1,4}){1,${e-1}}`),o.push(`(0{1,4}:){1,${e-1}}${i}`),o.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++)o.push(`(0{1,4}:){${n}}:(0{1,4}:){${e-n-t-1}}0{1,4}`);return a(o)}})),xo=r((e=>{var t=e&&e.__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]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.Address6=void 0;var i=r(ho()),a=r(go()),o=r(vo()),s=r(yo()),c=_o(),l=bo(),u=mo(),d=ho(),f=i.isCorrect(o.BITS);function p(e){if(!e)throw Error(`Assertion failed.`)}function m(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,`$1,$2`);return e}function h(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 g(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 _(e){return parseInt(e,16).toString(16).padStart(4,`0`)}function v(e){return e&255}var y=class e{constructor(e,t){this.addressMinusSuffix=``,this.parsedSubnet=``,this.subnet=`/128`,this.subnetMask=128,this.v4=!1,this.zone=``,this.isInSubnet=i.isInSubnet,this.isHostInSubnet=i.isHostInSubnet,this.isCorrect=f,this.groups=t===void 0?o.GROUPS:t,this.address=e;let n=o.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>o.BITS)throw new u.AddressError(`Invalid subnet mask.`);e=e.replace(o.RE_SUBNET_STRING,``)}if(/\//.test(e))throw new u.AddressError(`Invalid subnet mask.`);let r=o.RE_ZONE_STRING.exec(e);r&&(this.zone=r[0],e=e.replace(o.RE_ZONE_STRING,``));let a=this.groups*5+5;if(e.length>a)throw new u.AddressError(`IPv6 addresses are at most ${a} 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(o.BITS))-BigInt(1))throw new u.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<o.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,s=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``);if(s.indexOf(`[`)!==-1&&s.indexOf(`]:`)!==-1){if(a=`failed to parse address with port`,i=o.RE_URL_WITH_PORT.exec(s),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=o.RE_URL.exec(s),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 c;try{c=new e(n)}catch{return{error:a,address:null,port:null}}return{address:c,port:r}}static fromAddressAndMask(t,n){let r=i.prefixLengthFromMask(new e(n).bigInt(),o.BITS);return new e(`${t}/${r}`)}static fromAddressAndWildcardMask(t,n){let r=new e(n).bigInt()^(BigInt(1)<<BigInt(o.BITS))-BigInt(1),a=i.prefixLengthFromMask(r,o.BITS);return new e(`${t}/${a}`)}static fromWildcard(t){if(t.includes(`%`)||t.includes(`/`))throw new u.AddressError(`Wildcard pattern must not include a zone or CIDR suffix`);let n=t.split(`::`);if(n.length>2)throw new u.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=o.GROUPS-e.length-t.length;if(i<1)throw new u.AddressError(`Wildcard pattern with '::' has too many groups`);r=[...e,...Array(i).fill(`0`),...t]}else r=t.split(`:`);if(r.length!==o.GROUPS)throw new u.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 u.AddressError("Wildcard `*` must only appear in trailing groups (e.g. `2001:db8:*:*:*:*:*:*`)");let a=i===-1?0:r.length-i,s=r.map(e=>e===`*`?`0`:e),c=o.BITS-a*16;return new e(`${s.join(`:`)}/${c}`)}static fromAddress4(t){let n=new c.Address4(t),r=o.BITS-(a.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 u.AddressError(`Invalid 'ip6.arpa' form.`);let r=n.split(`.`).reverse(),i=r.length*4,a=r.join(``).padEnd(32,`0`),s=[];for(let e=0;e<o.GROUPS;e++)s.push(a.slice(e*4,(e+1)*4));return new e(`${s.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=o.BITS-this.subnetMask-Math.abs(e-o.BITS);return t<0?`0`:m((BigInt(`2`)**BigInt(t)).toString(10))}_startAddress(){return BigInt(`0b${this.mask()+`0`.repeat(o.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(o.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(i.offsetBigInt(this.bigInt(),t,o.BITS,`IPv6`)).withSubnetMask(this.subnetMask)}nextNetwork(){return e.fromBigInt(i.offsetBigInt(this._endAddress(),1,o.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(o.BITS-this.subnetMask)}`))}wildcardMask(){return e.fromBigInt(BigInt(`0b${`0`.repeat(this.subnetMask)}${`1`.repeat(o.BITS-this.subnetMask)}`))}networkForm(){return`${this.startAddress().correctForm()}/${this.subnetMask}`}getScope(){let e=this.getType();return e===`Multicast`||e.startsWith(`Multicast `)?o.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<b.length;e++){let t=b[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,o.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=g(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(o.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===a.GROUPS&&r.every(e=>/^\d{1,3}$/.test(e))&&r.some(e=>/^0\d/.test(e))){let e=r.map(h).join(`.`),n=t.slice(0,-1).map(s.escapeHtml).join(`:`),i=t.length>1?`:`:``;throw new u.AddressError(`IPv4 addresses can't have leading zeroes.`,`${n}${i}${e}`)}let i=n.match(a.RE_ADDRESS);if(i){this.parsedAddress4=i[0];let n=this.subnetMask>=96?`/${this.subnetMask-96}`:``;this.address4=new c.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(o.RE_BAD_CHARACTERS);if(t)throw new u.AddressError(`Bad character${t.length>1?`s`:``} detected in address: ${t.join(``)}`,e.replace(o.RE_BAD_CHARACTERS,`<span class="parse-error">$1</span>`));let n=e.match(o.RE_BAD_ADDRESS);if(n)throw new u.AddressError(`Address failed regex: ${n.join(``)}`,e.replace(o.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 u.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 u.AddressError(`Too many :: groups found`);if(r=r.map(e=>parseInt(e,16).toString(16)),r.length!==this.groups)throw new u.AddressError(`Incorrect number of groups found`);return r}canonicalForm(){return this.parsedAddress.map(_).join(`:`)}decimal(){return this.parsedAddress.map(e=>parseInt(e,16).toString(10).padStart(5,`0`)).join(`:`)}bigInt(){return BigInt(`0x${this.parsedAddress.map(_).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 c.Address4(`${n.join(`.`)}/${e}`)}return c.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=c.Address4.fromHex(this.getBitsBase16(32,64)),r=this.getBits(96,128),i=c.Address4.fromHex((r^BigInt(`0xffffffff`)).toString(16).padStart(8,`0`)),a=this.getBitsBase2(64,80),o=(0,d.testBit)(a,15),s=(0,d.testBit)(a,14),l=(0,d.testBit)(a,8),u=(0,d.testBit)(a,9),f=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:u,groupIndividual:l,nonce:f},udpPort:t}}inspect6to4(){let e=this.getBitsBase16(0,16),t=c.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 c.Address4(t),i=new e(n),a=i.subnetMask;if(a!==32&&a!==40&&a!==48&&a!==56&&a!==64&&a!==96)throw new u.AddressError(`NAT64 prefix length must be 32, 40, 48, 56, 64, or 96`);let o=i.binaryZeroPad(),s=r.binaryZeroPad(),l;if(a===96)l=o.slice(0,96)+s;else{let e=64-a;l=[o.slice(0,a),s.slice(0,e),`00000000`,s.slice(e),`0`.repeat(56-(32-e))].join(``)}let d=BigInt(`0b${l}`).toString(16).padStart(32,`0`),f=[];for(let e=0;e<8;e++)f.push(d.slice(e*4,(e+1)*4));return new e(f.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 u.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 c.Address4(o.join(`.`))}toByteArray(){let e=this.bigInt().toString(16).padStart(o.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(v)}static fromByteArray(e){return i.assertByteArray(e,16,`IPv6`,-128),this.fromUnsignedByteArray(e.map(v))}static fromUnsignedByteArray(t){i.assertByteArray(t,16,`IPv6`,0);let n=BigInt(`256`),r=BigInt(`0`),a=BigInt(`1`);for(let e=t.length-1;e>=0;e--)r+=a*BigInt(t[e].toString(10)),a*=n;return e.fromBigInt(r)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){let e=this.embeddedIPv4();return e?e.isLinkLocal():this.isHostInSubnet(w)}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(k)}embeddedIPv4(){return this.isMapped4()||this.isHostInSubnet(A)?this.to4():null}isTeredo(){return this.isHostInSubnet(x)}is6to4(){return this.isHostInSubnet(S)}isLoopback(){let e=this.embeddedIPv4();return e?e.isLoopback():this.getType()===`Loopback`}isULA(){return this.isHostInSubnet(C)}isPrivate(){let e=this.embeddedIPv4();return e?e.isPrivate():this.isULA()||this.isHostInSubnet(j)}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 T.some(e=>this.isHostInSubnet(e))}isBenchmarking(){let e=this.embeddedIPv4();return e?e.isBenchmarking():this.isHostInSubnet(E)}isGlobal(){let e=this.embeddedIPv4();return e?e.isGlobal():this.isHostInSubnet(D)&&i.isGloballyReachable.call(this,O)}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=s.escapeHtml(`${e.prefix}${n}`),i=s.escapeHtml(n);return e.className?`<a href="${r}" class="${s.escapeHtml(e.className)}">${i}</a>`:`<a href="${r}">${i}</a>`}group(){if(this.elidedGroups===0)return s.simpleGroup(this.addressMinusSuffix).join(`:`);p(typeof this.elidedGroups==`number`),p(typeof this.elisionBegin==`number`);let e=[],[t,n]=this.addressMinusSuffix.split(`::`);t.length?e.push(...s.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(...s.simpleGroup(n,this.elisionEnd)):e.push(``),this.is4()&&(p(this.address4 instanceof c.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,l.simpleRegularExpression)(r.parsedAddress));else if(r.elidedGroups===o.GROUPS)n.push((0,l.possibleElisions)(o.GROUPS));else{let e=r.address.split(`::`);e[0].length&&n.push((0,l.simpleRegularExpression)(e[0].split(`:`))),p(typeof r.elidedGroups==`number`),n.push((0,l.possibleElisions)(r.elidedGroups,e[0].length!==0,e[1].length!==0)),e[1].length&&n.push((0,l.simpleRegularExpression)(e[1].split(`:`))),n=[n.join(`:`)]}return t||(n=[`(?=^|`,l.ADDRESS_BOUNDARY,`|[^\\w\\:])(`,...n,`)(?=[^\\w\\:]|`,l.ADDRESS_BOUNDARY,`|$)`]),n.join(``)}regularExpression(e=!1){return new RegExp(this.regularExpressionString(e),`i`)}};e.Address6=y;var b=Object.keys(o.TYPES).map(e=>[new y(e),o.TYPES[e]]),x=new y(`2001::/32`),S=new y(`2002::/16`),C=new y(`fc00::/7`),w=new y(`fe80::/10`),T=[new y(`2001:db8::/32`),new y(`3fff::/20`)],E=new y(`2001:2::/48`),D=new y(`2000::/3`),O=o.SPECIAL_PURPOSE.map(([e,,t])=>({subnet:new y(e),reachable:t})),k=new y(`::ffff:0:0/96`),A=new y(`64:ff9b::/96`),j=new y(`64:ff9b:1::/48`)})),So=r((e=>{var t=e&&e.__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]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!=="default"&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,"__esModule",{value:!0}),e.v6=e.AddressError=e.Address6=e.Address4=void 0;var i=_o();Object.defineProperty(e,"Address4",{enumerable:!0,get:function(){return i.Address4}});var a=xo();Object.defineProperty(e,"Address6",{enumerable:!0,get:function(){return a.Address6}});var o=mo();Object.defineProperty(e,"AddressError",{enumerable:!0,get:function(){return o.AddressError}}),e.v6={helpers:r(yo())}}))(),Co=new TextEncoder;new TextDecoder;var wo=`webvpn-udp-port-ack`,To=e=>So.Address4.isValid(e),Eo=e=>So.Address6.isValid(e),Do=e=>To(e)?4:Eo(e)?6:0,Oo=(...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:e[0]??0,host:typeof e[1]==`string`?e[1]:void 0,callback:t}},ko=(...e)=>{let t=typeof e.at(-1)==`function`?e.at(-1):void 0,n=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??n,callback:t}:{address:r,port:n,callback:t}},Ao=(...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}}},jo=r(((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=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=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)}})),Mo=r(((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}}})),No,Po=n((()=>{No=globalThis||self}));function Fo(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}function Io(){throw Error(`setTimeout has not been defined`)}function Lo(){throw Error(`clearTimeout has not been defined`)}function Ro(e){if(Go===setTimeout)return setTimeout(e,0);if((Go===Io||!Go)&&setTimeout)return Go=setTimeout,setTimeout(e,0);try{return Go(e,0)}catch{try{return Go.call(null,e,0)}catch{return Go.call(this,e,0)}}}function zo(e){if(Ko===clearTimeout)return clearTimeout(e);if((Ko===Lo||!Ko)&&clearTimeout)return Ko=clearTimeout,clearTimeout(e);try{return Ko(e)}catch{try{return Ko.call(null,e)}catch{return Ko.call(this,e)}}}function Bo(){Jo&&Yo&&(Jo=!1,Yo.length?qo=Yo.concat(qo):Xo=-1,qo.length&&Vo())}function Vo(){if(!Jo){var e=Ro(Bo);Jo=!0;for(var t=qo.length;t;){for(Yo=qo,qo=[];++Xo<t;)Yo&&Yo[Xo].run();Xo=-1,t=qo.length}Yo=null,Jo=!1,zo(e)}}function Ho(e,t){this.fun=e,this.array=t}function Uo(){}var Wo,Y,Go,Ko,qo,Jo,Yo,Xo,Zo,X,Qo=n((()=>{Wo={exports:{}},Y=Wo.exports={},(function(){try{Go=typeof setTimeout==`function`?setTimeout:Io}catch{Go=Io}try{Ko=typeof clearTimeout==`function`?clearTimeout:Lo}catch{Ko=Lo}})(),qo=[],Jo=!1,Xo=-1,Y.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];qo.push(new Ho(e,t)),qo.length===1&&!Jo&&Ro(Vo)},Ho.prototype.run=function(){this.fun.apply(null,this.array)},Y.title=`browser`,Y.browser=!0,Y.env={},Y.argv=[],Y.version=``,Y.versions={},Y.on=Uo,Y.addListener=Uo,Y.once=Uo,Y.off=Uo,Y.removeListener=Uo,Y.removeAllListeners=Uo,Y.emit=Uo,Y.prependListener=Uo,Y.prependOnceListener=Uo,Y.listeners=function(e){return[]},Y.binding=function(e){throw Error(`process.binding is not supported`)},Y.cwd=function(){return`/`},Y.chdir=function(e){throw Error(`process.chdir is not supported`)},Y.umask=function(){return 0},Zo=Wo.exports,X=Fo(Zo)})),$o=r(((e,t)=>{t.exports=jo().EventEmitter})),es=r(((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}})),ts=r(((e,t)=>{var n=es();t.exports=function(){return n()&&!!Symbol.toStringTag}})),ns=r(((e,t)=>{t.exports=Object})),rs=r(((e,t)=>{t.exports=Error})),is=r(((e,t)=>{t.exports=EvalError})),as=r(((e,t)=>{t.exports=RangeError})),os=r(((e,t)=>{t.exports=ReferenceError})),ss=r(((e,t)=>{t.exports=SyntaxError})),cs=r(((e,t)=>{t.exports=TypeError})),ls=r(((e,t)=>{t.exports=URIError})),us=r(((e,t)=>{t.exports=Math.abs})),ds=r(((e,t)=>{t.exports=Math.floor})),fs=r(((e,t)=>{t.exports=Math.max})),ps=r(((e,t)=>{t.exports=Math.min})),ms=r(((e,t)=>{t.exports=Math.pow})),hs=r(((e,t)=>{t.exports=Math.round})),gs=r(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),_s=r(((e,t)=>{var n=gs();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),vs=r(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),ys=r(((e,t)=>{var n=vs();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),bs=r(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),xs=r(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=es();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),Ss=r(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),Cs=r(((e,t)=>{t.exports=ns().getPrototypeOf||null})),ws=r(((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}})),Ts=r(((e,t)=>{var n=ws();t.exports=Function.prototype.bind||n})),Es=r(((e,t)=>{t.exports=Function.prototype.call})),Ds=r(((e,t)=>{t.exports=Function.prototype.apply})),Os=r(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),ks=r(((e,t)=>{var n=Ts(),r=Ds(),i=Es();t.exports=Os()||n.call(i,r)})),As=r(((e,t)=>{var n=Ts(),r=cs(),i=Es(),a=ks();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),js=r(((e,t)=>{var n=As(),r=ys(),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))}})),Ms=r(((e,t)=>{var n=Ss(),r=Cs(),i=js();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})),Ns=r(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=Ts().call(n,r)})),Ps=r(((e,t)=>{var n,r=ns(),i=rs(),a=is(),o=as(),s=os(),c=ss(),l=cs(),u=ls(),d=us(),f=ds(),p=fs(),m=ps(),h=ms(),g=hs(),_=_s(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=ys(),x=bs(),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=xs()(),T=Ms(),E=Cs(),D=Ss(),O=Ds(),k=Es(),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(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(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 ee=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},N={__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`]},P=Ts(),F=Ns(),te=P.call(k,Array.prototype.concat),ne=P.call(O,Array.prototype.splice),re=P.call(k,String.prototype.replace),I=P.call(k,String.prototype.slice),L=P.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(F(N,n)&&(r=N[n],n=`%`+r[0]+`%`),F(M,n)){var i=M[n];if(i===A&&(i=ee(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,te([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+`%`,F(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=F(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),Fs=r(((e,t)=>{var n=Ps(),r=As(),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}})),Is=r(((e,t)=>{var n=ts()(),r=Fs()(`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})),Ls=r(((e,t)=>{var n=Fs(),r=ts()(),i=Ns(),a=ys(),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})),Rs=r(((e,t)=>{var n=Fs(),r=Ls(),i=n(`RegExp.prototype.exec`),a=cs();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),zs=r(((e,t)=>{var n=Fs(),r=Rs()(/^\s*(?:function)?\*/),i=ts()(),a=Ms(),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}})),Bs=r(((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)}})),Vs=r(((e,t)=>{var n=Bs(),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)}})),Hs=r(((e,t)=>{t.exports=[`Float16Array`,`Float32Array`,`Float64Array`,`Int8Array`,`Int16Array`,`Int32Array`,`Uint8Array`,`Uint8ClampedArray`,`Uint16Array`,`Uint32Array`,`BigInt64Array`,`BigUint64Array`]})),Us=r(((e,t)=>{Po();var n=Hs(),r=typeof globalThis>`u`?No: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}})),Ws=r(((e,t)=>{var n=bs(),r=ss(),i=cs(),a=ys();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.`)}})),Gs=r(((e,t)=>{var n=bs(),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})),Ks=r(((e,t)=>{var n=Ps(),r=Ws(),i=Gs()(),a=ys(),o=cs(),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}})),qs=r(((e,t)=>{var n=Ts(),r=Ds(),i=ks();t.exports=function(){return i(n,r,arguments)}})),Js=r(((e,t)=>{var n=Ks(),r=bs(),i=As(),a=qs();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})),Ys=r(((e,t)=>{Po();var n=Vs(),r=Us(),i=Js(),a=Fs(),o=ys(),s=Ms(),c=a(`Object.prototype.toString`),l=ts()(),u=typeof globalThis>`u`?No: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}})),Xs=r(((e,t)=>{var n=Ys();t.exports=function(e){return!!n(e)}})),Zs=r((e=>{var t=Is(),n=zs(),r=Ys(),i=Xs();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(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(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(new WeakMap);function ee(e){return typeof WeakMap>`u`?!1:M.working?M(e):e instanceof WeakMap}e.isWeakMap=ee;function N(e){return c(e)===`[object WeakSet]`}N.working=typeof WeakSet<`u`&&N(new WeakSet);function P(e){return N(e)}e.isWeakSet=P;function F(e){return c(e)===`[object ArrayBuffer]`}F.working=typeof ArrayBuffer<`u`&&F(new ArrayBuffer);function te(e){return typeof ArrayBuffer>`u`?!1:F.working?F(e):e instanceof ArrayBuffer}e.isArrayBuffer=te;function ne(e){return c(e)===`[object DataView]`}ne.working=typeof ArrayBuffer<`u`&&typeof DataView<`u`&&ne(new DataView(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 ce(e){return c(e)===`[object Generator]`}e.isGeneratorObject=ce;function le(e){return c(e)===`[object WebAssembly.Module]`}e.isWebAssemblyCompiledModule=le;function ue(e){return m(e,l)}e.isNumberObject=ue;function de(e){return m(e,u)}e.isStringObject=de;function fe(e){return m(e,d)}e.isBooleanObject=fe;function R(e){return o&&m(e,f)}e.isBigIntObject=R;function pe(e){return s&&m(e,p)}e.isSymbolObject=pe;function me(e){return ue(e)||de(e)||fe(e)||R(e)||pe(e)}e.isBoxedPrimitive=me;function he(e){return typeof Uint8Array<`u`&&(te(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`)}})})})),Qs=r(((e,t)=>{t.exports=function(e){return e&&typeof e==`object`&&typeof e.copy==`function`&&typeof e.fill==`function`&&typeof e.readUInt8==`function`}})),$s=r((e=>{Qo();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(!x(e)){for(var t=[],r=0;r<arguments.length;r++)t.push(o(arguments[r]));return t.join(` `)}for(var r=1,i=arguments,a=i.length,s=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}}),c=i[r];r<a;c=i[++r])v(c)||!T(c)?s+=` `+c:s+=` `+o(c);return s},e.deprecate=function(t,n){if(X!==void 0&&X.noDeprecation===!0)return t;if(X===void 0)return function(){return e.deprecate(t,n).apply(this,arguments)};var r=!1;function i(){if(!r){if(X.throwDeprecation)throw Error(n);X.traceDeprecation?console.trace(n):console.error(n),r=!0}return t.apply(this,arguments)}return i};var r={},i=/^$/;if({}.NODE_DEBUG){var a={}.NODE_DEBUG;a=a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`).replace(/,/g,`$|^`).toUpperCase(),i=RegExp(`^`+a+`$`,`i`)}e.debuglog=function(t){if(t=t.toUpperCase(),!r[t]){if(i.test(t)){var n=X.pid;r[t]=function(){var r=e.format.apply(e,arguments);console.error(`%s %d: %s`,t,n,r)}}else r[t]=function(){}}return r[t]};function o(t,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),_(n)?r.showHidden=n:n&&e._extend(r,n),C(r.showHidden)&&(r.showHidden=!1),C(r.depth)&&(r.depth=2),C(r.colors)&&(r.colors=!1),C(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=s),u(r,t,r.depth)}e.inspect=o,o.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]},o.styles={special:`cyan`,number:`yellow`,boolean:`yellow`,undefined:`grey`,null:`bold`,string:`green`,date:`magenta`,regexp:`red`};function s(e,t){var n=o.styles[t];return n?`\x1B[`+o.colors[n][0]+`m`+e+`\x1B[`+o.colors[n][1]+`m`:e}function c(e,t){return e}function l(e){var t={};return e.forEach(function(e,n){t[e]=!0}),t}function u(t,n,r){if(t.customInspect&&n&&O(n.inspect)&&n.inspect!==e.inspect&&!(n.constructor&&n.constructor.prototype===n)){var i=n.inspect(r,t);return x(i)||(i=u(t,i,r)),i}var a=d(t,n);if(a)return a;var o=Object.keys(n),s=l(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(n)),D(n)&&(o.indexOf(`message`)>=0||o.indexOf(`description`)>=0))return f(n);if(o.length===0){if(O(n)){var c=n.name?`: `+n.name:``;return t.stylize(`[Function`+c+`]`,`special`)}if(w(n))return t.stylize(RegExp.prototype.toString.call(n),`regexp`);if(E(n))return t.stylize(Date.prototype.toString.call(n),`date`);if(D(n))return f(n)}var _=``,v=!1,y=[`{`,`}`];if(g(n)&&(v=!0,y=[`[`,`]`]),O(n)&&(_=` [Function`+(n.name?`: `+n.name:``)+`]`),w(n)&&(_=` `+RegExp.prototype.toString.call(n)),E(n)&&(_=` `+Date.prototype.toUTCString.call(n)),D(n)&&(_=` `+f(n)),o.length===0&&(!v||n.length==0))return y[0]+_+y[1];if(r<0)return w(n)?t.stylize(RegExp.prototype.toString.call(n),`regexp`):t.stylize(`[Object]`,`special`);t.seen.push(n);var b=v?p(t,n,r,s,o):o.map(function(e){return m(t,n,r,s,e,v)});return t.seen.pop(),h(b,_,y)}function d(e,t){if(C(t))return e.stylize(`undefined`,`undefined`);if(x(t)){var n=`'`+JSON.stringify(t).replace(/^"|"$/g,``).replace(/'/g,`\\'`).replace(/\\"/g,`"`)+`'`;return e.stylize(n,`string`)}if(b(t))return e.stylize(``+t,`number`);if(_(t))return e.stylize(``+t,`boolean`);if(v(t))return e.stylize(`null`,`null`)}function f(e){return`[`+Error.prototype.toString.call(e)+`]`}function p(e,t,n,r,i){for(var a=[],o=0,s=t.length;o<s;++o)N(t,String(o))?a.push(m(e,t,n,r,String(o),!0)):a.push(``);return i.forEach(function(i){i.match(/^\d+$/)||a.push(m(e,t,n,r,i,!0))}),a}function m(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`)),N(r,i)||(o=`[`+i+`]`),s||(e.seen.indexOf(c.value)<0?(s=v(n)?u(e,c.value,null):u(e,c.value,n-1),s.indexOf(`
|
|
55
|
+
`)>-1&&(s=a?s.split(`
|
|
56
|
+
`).map(function(e){return` `+e}).join(`
|
|
57
|
+
`).slice(2):`
|
|
58
|
+
`+s.split(`
|
|
59
|
+
`).map(function(e){return` `+e}).join(`
|
|
60
|
+
`))):s=e.stylize(`[Circular]`,`special`)),C(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 h(e,t,n){var r=0;return e.reduce(function(e,t){return r++,t.indexOf(`
|
|
61
|
+
`)>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,``).length+1},0)>60?n[0]+(t===``?``:t+`
|
|
62
|
+
`)+` `+e.join(`,
|
|
63
|
+
`)+` `+n[1]:n[0]+t+` `+e.join(`, `)+` `+n[1]}e.types=Zs();function g(e){return Array.isArray(e)}e.isArray=g;function _(e){return typeof e==`boolean`}e.isBoolean=_;function v(e){return e===null}e.isNull=v;function y(e){return e==null}e.isNullOrUndefined=y;function b(e){return typeof e==`number`}e.isNumber=b;function x(e){return typeof e==`string`}e.isString=x;function S(e){return typeof e==`symbol`}e.isSymbol=S;function C(e){return e===void 0}e.isUndefined=C;function w(e){return T(e)&&A(e)===`[object RegExp]`}e.isRegExp=w,e.types.isRegExp=w;function T(e){return typeof e==`object`&&!!e}e.isObject=T;function E(e){return T(e)&&A(e)===`[object Date]`}e.isDate=E,e.types.isDate=E;function D(e){return T(e)&&(A(e)===`[object Error]`||e instanceof Error)}e.isError=D,e.types.isNativeError=D;function O(e){return typeof e==`function`}e.isFunction=O;function k(e){return e===null||typeof e==`boolean`||typeof e==`number`||typeof e==`string`||typeof e==`symbol`||e===void 0}e.isPrimitive=k,e.isBuffer=Qs();function A(e){return Object.prototype.toString.call(e)}function j(e){return e<10?`0`+e.toString(10):e.toString(10)}var M=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function ee(){var e=new Date,t=[j(e.getHours()),j(e.getMinutes()),j(e.getSeconds())].join(`:`);return[e.getDate(),M[e.getMonth()],t].join(` `)}e.log=function(){console.log(`%s - %s`,ee(),e.format.apply(e,arguments))},e.inherits=Mo(),e._extend=function(e,t){if(!t||!T(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};function N(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var P=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(P&&e[P]){var n=e[P];if(typeof n!=`function`)throw TypeError(`The "util.promisify.custom" argument must be of type Function`);return Object.defineProperty(n,P,{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)),P&&Object.defineProperty(n,P,{value:n,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(n,t(e))},e.promisify.custom=P;function F(e,t){if(!e){var n=Error(`Promise was rejected with a falsy value`);n.reason=e,e=n}return t(e)}function te(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 i=this,a=function(){return r.apply(i,arguments)};e.apply(this,t).then(function(e){X.nextTick(a.bind(null,null,e))},function(e){X.nextTick(F.bind(null,e,a))})}return Object.setPrototypeOf(n,Object.getPrototypeOf(e)),Object.defineProperties(n,t(e)),n}e.callbackify=te})),ec=r(((t,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=($i(),e(xi)).Buffer,f=$s().inspect,p=f&&f.custom||`inspect`;function m(e,t,n){d.prototype.copy.call(e,t,n)}n.exports=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}()})),tc=r(((e,t)=>{Qo();function n(e,t){var n=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,X.nextTick(o,this,e)):X.nextTick(o,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?X.nextTick(i,n):(n._writableState.errorEmitted=!0,X.nextTick(r,n,e)):X.nextTick(r,n,e):t?(X.nextTick(i,n),t(e)):X.nextTick(i,n)}),this)}function r(e,t){o(e,t),i(e)}function i(e){(!e._writableState||e._writableState.emitClose)&&(!e._readableState||e._readableState.emitClose)&&e.emit(`close`)}function a(){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 o(e,t){e.emit(`error`,t)}function s(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:a,errorOrDestroy:s}})),nc=r(((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=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})),rc=r(((e,t)=>{var n=nc().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}})),ic=r(((e,t)=>{Po(),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(!No.localStorage)return!1}catch{return!1}var t=No.localStorage[e];return t!=null&&String(t).toLowerCase()===`true`}})),ac=r(((t,n)=>{Po(),Qo(),n.exports=E;function r(e){var t=this;this.next=null,this.entry=null,this.finish=function(){ae(t,e)}}var i;E.WritableState=w;var a={deprecate:ic()},o=$o(),s=($i(),e(xi)).Buffer,c=(No===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:No).Uint8Array||function(){};function l(e){return s.from(e)}function u(e){return s.isBuffer(e)||e instanceof c}var d=tc(),f=rc().getHighWaterMark,p=nc().codes,m=p.ERR_INVALID_ARG_TYPE,h=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,_=p.ERR_STREAM_CANNOT_PIPE,v=p.ERR_STREAM_DESTROYED,y=p.ERR_STREAM_NULL_VALUES,b=p.ERR_STREAM_WRITE_AFTER_END,x=p.ERR_UNKNOWN_ENCODING,S=d.errorOrDestroy;Mo()(E,o);function C(){}function w(e,t,n){i||=oc(),e||={},typeof n!=`boolean`&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=f(this,e,`writableHighWaterMark`,n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||`utf8`,this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){N(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 r(this)}w.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},(function(){try{Object.defineProperty(w.prototype,"buffer",{get:a.deprecate(function(){return this.getBuffer()},`_writableState.buffer is deprecated. Use _writableState.getBuffer instead.`,`DEP0003`)})}catch{}})();var T;typeof Symbol==`function`&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]==`function`?(T=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return T.call(this,e)?!0:this===E&&e&&e._writableState instanceof w}})):T=function(e){return e instanceof this};function E(e){i||=oc();var t=this instanceof i;if(!t&&!T.call(E,this))return new E(e);this._writableState=new w(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)),o.call(this)}E.prototype.pipe=function(){S(this,new _)};function D(e,t){var n=new b;S(e,n),X.nextTick(t,n)}function O(e,t,n,r){var i;return n===null?i=new y:typeof n!=`string`&&!t.objectMode&&(i=new m(`chunk`,[`string`,`Buffer`],n)),!i||(S(e,i),X.nextTick(r,i),!1)}E.prototype.write=function(e,t,n){var r=this._writableState,i=!1,a=!r.objectMode&&u(e);return a&&!s.isBuffer(e)&&(e=l(e)),typeof t==`function`&&(n=t,t=null),a?t=`buffer`:t||=r.defaultEncoding,typeof n!=`function`&&(n=C),r.ending?D(this,n):(a||O(this,r,e,n))&&(r.pendingcb++,i=A(this,r,a,e,t,n)),i},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&te(this,e))},E.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 x(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function k(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t==`string`&&(t=s.from(t,n)),t}Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function A(e,t,n,r,i,a){if(!n){var o=k(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 j(e,t,!1,s,r,i,a);return c}function j(e,t,n,r,i,a,o){t.writelen=r,t.writecb=o,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new v(`write`)):n?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function M(e,t,n,r,i){--t.pendingcb,n?(X.nextTick(i,r),X.nextTick(L,e,t),e._writableState.errorEmitted=!0,S(e,r)):(i(r),e._writableState.errorEmitted=!0,S(e,r),L(e,t))}function ee(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function N(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(typeof i!=`function`)throw new g;if(ee(n),t)M(e,n,r,t,i);else{var a=ne(n)||e.destroyed;!a&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&te(e,n),r?X.nextTick(P,e,n,a,i):P(e,n,a,i)}}function P(e,t,n,r){n||F(e,t),t.pendingcb--,r(),L(e,t)}function F(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit(`drain`))}function te(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,a=Array(i),o=t.corkedRequestsFree;o.entry=n;for(var s=0,c=!0;n;)a[s]=n,n.isBuf||(c=!1),n=n.next,s+=1;a.allBuffers=c,j(e,t,!0,t.length,a,``,o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new r(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,d=n.callback;if(j(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}E.prototype._write=function(e,t,n){n(new h(`_write()`))},E.prototype._writev=null,E.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||ie(this,r,n),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function ne(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function re(e,t){e._final(function(n){t.pendingcb--,n&&S(e,n),t.prefinished=!0,e.emit(`prefinish`),L(e,t)})}function I(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final==`function`&&!t.destroyed?(t.pendingcb++,t.finalCalled=!0,X.nextTick(re,e,t)):(t.prefinished=!0,e.emit(`prefinish`)))}function L(e,t){var n=ne(t);if(n&&(I(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 ie(e,t,n){t.ending=!0,L(e,t),n&&(t.finished?X.nextTick(n):e.once(`finish`,n)),t.ended=!0,e.writable=!1}function ae(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(E.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=d.destroy,E.prototype._undestroy=d.undestroy,E.prototype._destroy=function(e,t){t(e)}})),oc=r(((e,t)=>{Qo();var n=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=c;var r=fc(),i=ac();Mo()(c,r);for(var a=n(i.prototype),o=0;o<a.length;o++){var s=a[o];c.prototype[s]||(c.prototype[s]=i.prototype[s])}function c(e){if(!(this instanceof c))return new c(e);r.call(this,e),i.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`,l)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function l(){this._writableState.ended||X.nextTick(u,this)}function u(e){e.end()}Object.defineProperty(c.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)}})})),sc=r(((t,n)=>{var r=($i(),e(xi)),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,t),t.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)}})),cc=r((e=>{var t=sc().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):``}})),lc=r(((e,t)=>{var n=nc().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})),uc=r(((e,t)=>{Qo();var n;function r(e,t,n){return t=i(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){var t=a(e,`string`);return typeof t==`symbol`?t:String(t)}function a(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 o=lc(),s=Symbol(`lastResolve`),c=Symbol(`lastReject`),l=Symbol(`error`),u=Symbol(`ended`),d=Symbol(`lastPromise`),f=Symbol(`handlePromise`),p=Symbol(`stream`);function m(e,t){return{value:e,done:t}}function h(e){var t=e[s];if(t!==null){var n=e[p].read();n!==null&&(e[d]=null,e[s]=null,e[c]=null,t(m(n,!1)))}}function g(e){X.nextTick(h,e)}function _(e,t){return function(n,r){e.then(function(){if(t[u]){n(m(void 0,!0));return}t[f](n,r)},r)}}var v=Object.getPrototypeOf(function(){}),y=Object.setPrototypeOf((n={get stream(){return this[p]},next:function(){var e=this,t=this[l];if(t!==null)return Promise.reject(t);if(this[u])return Promise.resolve(m(void 0,!0));if(this[p].destroyed)return new Promise(function(t,n){X.nextTick(function(){e[l]?n(e[l]):t(m(void 0,!0))})});var n=this[d],r;if(n)r=new Promise(_(n,this));else{var i=this[p].read();if(i!==null)return Promise.resolve(m(i,!1));r=new Promise(this[f])}return this[d]=r,r}},r(n,Symbol.asyncIterator,function(){return this}),r(n,`return`,function(){var e=this;return new Promise(function(t,n){e[p].destroy(null,function(e){if(e){n(e);return}t(m(void 0,!0))})})}),n),v);t.exports=function(e){var t,n=Object.create(y,(t={},r(t,p,{value:e,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,c,{value:null,writable:!0}),r(t,l,{value:null,writable:!0}),r(t,u,{value:e._readableState.endEmitted,writable:!0}),r(t,f,{value:function(e,t){var r=n[p].read();r?(n[d]=null,n[s]=null,n[c]=null,e(m(r,!1))):(n[s]=e,n[c]=t)},writable:!0}),t));return n[d]=null,o(e,function(e){if(e&&e.code!==`ERR_STREAM_PREMATURE_CLOSE`){var t=n[c];t!==null&&(n[d]=null,n[s]=null,n[c]=null,t(e)),n[l]=e;return}var r=n[s];r!==null&&(n[d]=null,n[s]=null,n[c]=null,r(m(void 0,!0))),n[u]=!0}),e.on(`readable`,g.bind(null,n)),n}})),dc=r(((e,t)=>{t.exports=function(){throw Error(`Readable.from is not available in the browser`)}})),fc=r(((t,n)=>{Po(),Qo(),n.exports=D;var r;D.ReadableState=E,jo().EventEmitter;var i=function(e,t){return e.listeners(t).length},a=$o(),o=($i(),e(xi)).Buffer,s=(No===void 0?typeof window<`u`?window:typeof self<`u`?self:{}:No).Uint8Array||function(){};function c(e){return o.from(e)}function l(e){return o.isBuffer(e)||e instanceof s}var u=$s(),d=u&&u.debuglog?u.debuglog(`stream`):function(){},f=ec(),p=tc(),m=rc().getHighWaterMark,h=nc().codes,g=h.ERR_INVALID_ARG_TYPE,_=h.ERR_STREAM_PUSH_AFTER_EOF,v=h.ERR_METHOD_NOT_IMPLEMENTED,y=h.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,b,x,S;Mo()(D,a);var C=p.errorOrDestroy,w=[`error`,`close`,`destroy`,`pause`,`resume`];function T(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 E(e,t,n){r||=oc(),e||={},typeof n!=`boolean`&&(n=t instanceof r),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=m(this,e,`readableHighWaterMark`,n),this.buffer=new f,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&&(b||=cc().StringDecoder,this.decoder=new b(e.encoding),this.encoding=e.encoding)}function D(e){if(r||=oc(),!(this instanceof D))return new D(e);var t=this instanceof r;this._readableState=new E(e,this,t),this.readable=!0,e&&(typeof e.read==`function`&&(this._read=e.read),typeof e.destroy==`function`&&(this._destroy=e.destroy)),a.call(this)}Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),D.prototype.destroy=p.destroy,D.prototype._undestroy=p.undestroy,D.prototype._destroy=function(e,t){t(e)},D.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=o.from(e,t),t=``),r=!0),O(this,e,t,!1,r)},D.prototype.unshift=function(e){return O(this,e,null,!0,!1)};function O(e,t,n,r,i){d(`readableAddChunk`,t);var a=e._readableState;if(t===null)a.reading=!1,N(e,a);else{var s;if(i||(s=A(a,t)),s)C(e,s);else if(a.objectMode||t&&t.length>0){if(typeof t!=`string`&&!a.objectMode&&Object.getPrototypeOf(t)!==o.prototype&&(t=c(t)),r)a.endEmitted?C(e,new y):k(e,a,t,!0);else if(a.ended)C(e,new _);else if(a.destroyed)return!1;else a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||t.length!==0?k(e,a,t,!1):te(e,a)):k(e,a,t,!1)}else r||(a.reading=!1,te(e,a))}return!a.ended&&(a.length<a.highWaterMark||a.length===0)}function k(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&&P(e)),te(e,t)}function A(e,t){var n;return!l(t)&&typeof t!=`string`&&t!==void 0&&!e.objectMode&&(n=new g(`chunk`,[`string`,`Buffer`,`Uint8Array`],t)),n}D.prototype.isPaused=function(){return this._readableState.flowing===!1},D.prototype.setEncoding=function(e){b||=cc().StringDecoder;var t=new b(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 j=1073741824;function M(e){return e>=j?e=j:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function ee(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=M(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}D.prototype.read=function(e){d(`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 d(`read: emitReadable`,t.length,t.ended),t.length===0&&t.ended?ce(this):P(this),null;if(e=ee(e,t),e===0&&t.ended)return t.length===0&&ce(this),null;var r=t.needReadable;d(`need readable`,r),(t.length===0||t.length-e<t.highWaterMark)&&(r=!0,d(`length less than watermark`,r)),t.ended||t.reading?(r=!1,d(`reading or ended`,r)):r&&(d(`do read`),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=ee(n,t)));var i=e>0?se(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&&ce(this)),i!==null&&this.emit(`data`,i),i};function N(e,t){if(d(`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?P(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,F(e)))}}function P(e){var t=e._readableState;d(`emitReadable`,t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(d(`emitReadable`,t.flowing),t.emittedReadable=!0,X.nextTick(F,e))}function F(e){var t=e._readableState;d(`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,oe(e)}function te(e,t){t.readingMore||(t.readingMore=!0,X.nextTick(ne,e,t))}function ne(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&t.length===0);){var n=t.length;if(d(`maybeReadMore read 0`),e.read(0),n===t.length)break}t.readingMore=!1}D.prototype._read=function(e){C(this,new v(`_read()`))},D.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,d(`pipe count=%d opts=%j`,r.pipesCount,t);var a=(!t||t.end!==!1)&&e!==X.stdout&&e!==X.stderr?s:g;r.endEmitted?X.nextTick(a):n.once(`end`,a),e.on(`unpipe`,o);function o(e,t){d(`onunpipe`),e===n&&t&&t.hasUnpiped===!1&&(t.hasUnpiped=!0,u())}function s(){d(`onend`),e.end()}var c=re(n);e.on(`drain`,c);var l=!1;function u(){d(`cleanup`),e.removeListener(`close`,m),e.removeListener(`finish`,h),e.removeListener(`drain`,c),e.removeListener(`error`,p),e.removeListener(`unpipe`,o),n.removeListener(`end`,s),n.removeListener(`end`,g),n.removeListener(`data`,f),l=!0,r.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}n.on(`data`,f);function f(t){d(`ondata`);var i=e.write(t);d(`dest.write`,i),i===!1&&((r.pipesCount===1&&r.pipes===e||r.pipesCount>1&&ue(r.pipes,e)!==-1)&&!l&&(d(`false write response, pause`,r.awaitDrain),r.awaitDrain++),n.pause())}function p(t){d(`onerror`,t),g(),e.removeListener(`error`,p),i(e,`error`)===0&&C(e,t)}T(e,`error`,p);function m(){e.removeListener(`finish`,h),g()}e.once(`close`,m);function h(){d(`onfinish`),e.removeListener(`close`,m),g()}e.once(`finish`,h);function g(){d(`unpipe`),n.unpipe(e)}return e.emit(`pipe`,n),r.flowing||(d(`pipe resume`),n.resume()),e};function re(e){return function(){var t=e._readableState;d(`pipeOnDrain`,t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&i(e,`data`)&&(t.flowing=!0,oe(e))}}D.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?this:(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=ue(t.pipes,e);return o===-1?this:(t.pipes.splice(o,1),--t.pipesCount,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit(`unpipe`,this,n),this)},D.prototype.on=function(e,t){var n=a.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,d(`on readable`,r.length,r.reading),r.length?P(this):r.reading||X.nextTick(L,this)),n},D.prototype.addListener=D.prototype.on,D.prototype.removeListener=function(e,t){var n=a.prototype.removeListener.call(this,e,t);return e===`readable`&&X.nextTick(I,this),n},D.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return(e===`readable`||e===void 0)&&X.nextTick(I,this),t};function I(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 L(e){d(`readable nexttick read 0`),e.read(0)}D.prototype.resume=function(){var e=this._readableState;return e.flowing||(d(`resume`),e.flowing=!e.readableListening,ie(this,e)),e.paused=!1,this};function ie(e,t){t.resumeScheduled||(t.resumeScheduled=!0,X.nextTick(ae,e,t))}function ae(e,t){d(`resume`,t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit(`resume`),oe(e),t.flowing&&!t.reading&&e.read(0)}D.prototype.pause=function(){return d(`call pause flowing=%j`,this._readableState.flowing),this._readableState.flowing!==!1&&(d(`pause`),this._readableState.flowing=!1,this.emit(`pause`)),this._readableState.paused=!0,this};function oe(e){var t=e._readableState;for(d(`flow`,t.flowing);t.flowing&&e.read()!==null;);}D.prototype.wrap=function(e){var t=this,n=this._readableState,r=!1;for(var i in e.on(`end`,function(){if(d(`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){d(`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<w.length;a++)e.on(w[a],this.emit.bind(this,w[a]));return this._read=function(t){d(`wrapped _read`,t),r&&(r=!1,e.resume())},this},typeof Symbol==`function`&&(D.prototype[Symbol.asyncIterator]=function(){return x===void 0&&(x=uc()),x(this)}),Object.defineProperty(D.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(D.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(D.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),D._fromList=se,Object.defineProperty(D.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function se(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 ce(e){var t=e._readableState;d(`endReadable`,t.endEmitted),t.endEmitted||(t.ended=!0,X.nextTick(le,t,e))}function le(e,t){if(d(`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`&&(D.from=function(e,t){return S===void 0&&(S=dc()),S(D,e,t)});function ue(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}})),pc=r(((e,t)=>{t.exports=l;var n=nc().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=oc();Mo()(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)}})),mc=r(((e,t)=>{t.exports=r;var n=pc();Mo()(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)}})),hc=r(((e,t)=>{var n;function r(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var i=nc().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=lc()),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})),gc=r(((e,t)=>{t.exports=r;var n=jo().EventEmitter;Mo()(r,n),r.Readable=fc(),r.Writable=ac(),r.Duplex=oc(),r.Transform=pc(),r.PassThrough=mc(),r.finished=lc(),r.pipeline=hc(),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}}))(),_c=jo(),vc=d({Server:()=>bc,Socket:()=>yc,_default:()=>wc,connect:()=>xc,createConnection:()=>Sc,createServer:()=>Cc,default:()=>wc,isIP:()=>Do,isIPv4:()=>To,isIPv6:()=>Eo}),yc=class extends gc.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super(e),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_init__(e,t){if(this._busyRelease??=oi(`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._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},{...e,reader:t,writer:n}}).catch(e=>{this.emit(`error`,e)}),!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);return this._webVPNTcpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`connect`)}),this._webVPNTcpSocketPromise}_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{if(!e){this.push(null);return}e.reader.read().then(({value:e,done:t})=>{if(t){this.push(null);return}this._restartTimeoutTimer(),this.push(e)}).catch(e=>{this.destroy(e)})})}_write(e,t,n){if(!this._webVPNTcpSocketPromise){n(Error(`Socket not connected`));return}this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e),this._restartTimeoutTimer(),n()}).catch(n)}connect(...e){let t=Oo(...e),n=this.__webvpn_tcp_socket_init__(v(`an outbound tcp socket`).then(e=>e.cloud.webvpn.tcpSocket({remoteAddress:t.host??`localhost`,remotePort:t.port})));return t.callback&&n.then(e=>{e&&t.callback.call(this)}),this}_final(e){if(!this._webVPNTcpSocketPromise){e();return}this._webVPNTcpSocketPromise.then(async e=>{e&&await e.writer.close()}).then(()=>e(),t=>e(t))}_destroy(e,t){if(this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._busyRelease?.(),!this._webVPNTcpSocketPromise){t(e);return}this._webVPNTcpSocketPromise.then(async e=>{e&&await(this._resetRequested?e.resetAndDestroy():e.destroy())}).then(()=>t(e),()=>t(e))}destroySoon(){if(this.writableFinished){this.destroy();return}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._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=e??!1,r=t!==void 0&&t>0?Math.max(1,Math.round(t/1e3)):0;return this._setTcpOption({type:2,enabled:n,initialDelaySeconds:r}),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){if(!this._webVPNTcpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before connect`));return}this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}write(e,t,...n){return super.write(e,t,...n)}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},bc=class extends _c.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;constructor(e,t){super(e),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??=oi(`tcp server`),this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e)).catch(e=>{this.emit(`error`,e)}),this._webVPNTcpSocketListenerPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNTcpSocketListenerPromise}listen(...e){let t=Oo(...e);this._closeEmitted=!1;let n=e=>{let t=new yc;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=e=>v(`a tcp listener`).then(i=>i.cloud.webvpn.tcpSocketListener({localAddress:e,localPort:t.port,onConnection:n,onClose:r})),a=t.host?i(t.host):i(`::`).catch(()=>i(`0.0.0.0`)),o=this.__webvpn_tcp_socket_listener_init__(a);return t.callback&&o.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](){}},xc=(e,t)=>new yc().connect(e,t),Sc=(e,t)=>new yc().connect(e,t),Cc=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new bc(e);return t&&n.on(`connection`,t),n},wc={Socket:yc,Server:bc,connect:xc,createConnection:Sc,createServer:Cc,isIP:Do,isIPv4:To,isIPv6:Eo};$i();var Tc=d({Socket:()=>Ec,createSocket:()=>Mc,default:()=>Nc}),Ec=class extends _c.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_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:wo,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=Ac(n)),s+=n.byteLength,d=t.getUint16(s),s+=2}let f=t.getUint32(s);s+=4;try{this.emit(`message`,W.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 Dc;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=So.Address4.isValid(e)?kc(e):jc(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(So.Address4.isValid(e)){let n=kc(e),r=t&&So.Address4.isValid(t)?kc(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(So.Address6.isValid(e)){let t=jc(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let t=ko(...e),n=this._type===`udp6`?`::`:`0.0.0.0`,r=this.__webvpn_udp_socket_init__(v(`a udp socket`).then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:t.address??n,port:t.port,dataPort:!0})));return t.callback&&r.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??=oi(`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`,W.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._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).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`,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(So.Address4.isValid(e)){let n=kc(e),r=t&&So.Address4.isValid(t)?kc(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(So.Address6.isValid(e)){let t=jc(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,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=Ao(...e),n=Oc(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(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(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||So.Address4.isValid(a)||So.Address6.isValid(a))){this._portSend(r,o?void 0:a,o?void 0:t.port),n?.call(this,null,r.byteLength);return}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=>n?n.call(this,e,0):this.emit(`error`,e))})}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)})}},Dc=new Uint8Array([2]),Oc=e=>{if(typeof e==`string`)return Co.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(Oc),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)},kc=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)},Ac=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(`:`)}`},jc=e=>{let t=new So.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)))},Mc=(e,t)=>{let n=new Ec(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},Nc={Socket:Ec,createSocket:Mc};$i();var Pc=d({Agent:()=>el,ClientRequest:()=>Qc,HTTPParser:()=>Kc,IncomingMessage:()=>Jc,METHODS:()=>Ic,STATUS_CODES:()=>Lc,Server:()=>$c,ServerResponse:()=>Xc,_default:()=>al,createServer:()=>il,default:()=>al,get:()=>rl,globalAgent:()=>tl,request:()=>nl}),Fc=new TextDecoder(`latin1`),Ic=`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(`.`),Lc={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`},Rc=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`]),zc=13,Bc=10,Vc=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,Hc=(e,t)=>(e.code=t,e),Uc=(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},Wc=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===zc&&e[n+1]===Bc)return n;return-1},Gc=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===zc&&e[t+1]===Bc&&e[t+2]===zc&&e[t+3]===Bc)return t;return-1},Kc=class{mode;handlers;buf=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=Uc(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=Gc(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=Fc.decode(e).split(`\r
|
|
64
|
+
`),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:Rc.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`;return}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=new Uint8Array),!1):this.framing!==`chunked`||this.consumeChunked()}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=Wc(this.buf,0);if(e===-1)return!1;let t=Fc.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=Wc(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},qc=(e,t)=>W.isBuffer(e)?e:typeof e==`string`?W.from(e,t??`utf8`):e instanceof Uint8Array?W.from(e):e instanceof ArrayBuffer?W.from(new Uint8Array(e)):W.from(String(e)),Jc=class extends gc.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}},Yc=class extends gc.Stream.Writable{_headerStore=new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw Hc(Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!Vc.test(e))throw Hc(TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw Hc(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
|
|
65
|
+
`;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
|
|
66
|
+
`,r}_writeToSocket(e,t){if(!this.socket){t(Error(`Socket is not available`));return}this.socket.write(e,t)}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,n){let r=qc(e),i=[];if(this.headersSent||=(this._implicitHeader(),i.push(W.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?r.length>0&&(i.push(W.from(`${r.length.toString(16)}\r\n`,`latin1`)),i.push(r),i.push(W.from(`\r
|
|
67
|
+
`,`latin1`))):i.push(r),i.length===0){n();return}this._writeToSocket(W.concat(i),n)}_final(e){let t=[];if(this.headersSent||=(!this.chunkedEncoding&&!this.hasHeader(`content-length`)&&this.setHeader(`Content-Length`,0),this._implicitHeader(),t.push(W.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding&&t.push(W.from(`0\r
|
|
68
|
+
\r
|
|
69
|
+
`,`latin1`)),this.finished=!0,t.length===0){e();return}this._writeToSocket(W.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`,qc(e,n).length)}return super.end(e,t,n)}_headBlock},Xc=class extends Yc{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 Hc(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??Lc[this.statusCode]??`unknown`;this.sendDate&&!this.hasHeader(`date`)&&this.setHeader(`Date`,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(W.from(`HTTP/1.1 100 Continue\r
|
|
70
|
+
\r
|
|
71
|
+
`,`latin1`),()=>{})}setTimeout(e,t){return this.socket?.setTimeout(e,t),this}},Zc=(...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}},Qc=class extends Yc{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 ${W.from(e.auth).toString(`base64`)}`),this.socket=new yc,this.emit(`socket`,this.socket),this.socket.on(`error`,e=>{this._aborted||this.emit(`error`,e)}),this._attachResponseParser(),this.socket.connect({host:n,port:r},()=>{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 Jc(this.socket),t=new Kc(`response`,{onHeaders:n=>{e._applyHead(n),this.method===`HEAD`&&(t.skipBody=!0),this.res=e,this.emit(`response`,e)},onBody:t=>{e.push(W.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:(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){if(this._aborted){t();return}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)}},$c=new Proxy(class extends bc{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 Kc(`request`,{onHeaders:r=>{t=new Jc(e),t._applyHead(r),r.method===`HEAD`&&(n.skipBody=!0);let i=new Xc(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(W.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)}),el=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(){}},tl=new el,nl=(...e)=>{let{options:t,callback:n}=Zc(...e);return new Qc(t,n)},rl=(...e)=>{let t=nl(...e);return t.end(),t},il=(e,t)=>new $c(e,t),al={METHODS:Ic,STATUS_CODES:Lc,Agent:el,globalAgent:tl,Server:$c,ServerResponse:Xc,IncomingMessage:Jc,ClientRequest:Qc,OutgoingMessage:Yc,createServer:il,request:nl,get:rl},ol=async()=>{let e=()=>v(`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 h))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},sl=`frame: this frame no longer holds the document the app attached it to`,cl=!1,ll=()=>{cl||(cl=!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.`))},ul=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),dl=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,fl=e=>{let{assertLive:t,attach:n,consent:r,current:i,declaredHosts:a,documentHost:o,freshBlank:s,session:c,approvedOrigins:l}=e,u=new Set,d=()=>{try{return new URL(i()).hostname}catch{return``}},f=async()=>o?await o():d(),p=()=>R([...a,...ul(l)]),m=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:i,phase:o})=>{t();let h=se(e,i);if(h===null)return;let g=_r(h);if(g===void 0||g===`auto`)return;if(e===`fetch`){let e=pi({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:L(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})===!1)throw V(dl(`fetch`,`network`,s||null),`fetch`);return}let _=await f();if(!_)throw V(`frame: navigate the frame before ${e}`,e);if(!p().includes(_))throw V(sl,e);let v=vr(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=await m(y,g===`critical`?{key:h,hosts:b,attach:n}:{category:v,hosts:b});if(x===!1)throw V(dl(e,v,null),e);if(x===`once`&&o!==`ensure`)for(let e of b)u.add(`${h} ${e}`)},requestCategories:async e=>{t(),xr(`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:_r(t)===`critical`,category:gr(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 ll(),s.map(e=>c(e,!1));let u=await l(s.map(({named:e,critical:t,category:r})=>t?{key:e,hosts:o,attach:n}:{category:r,hosts:o}));return s.map((e,t)=>c(e,u[t]!==void 0&&u[t]!==!1))},boundary:p}},pl=e=>e,ml=5e3,hl=new Set([]),gl=()=>`https://fkn.app`,_l=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,vl=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(typeof n==`string`?new Mt(n):n()),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},yl=e=>Object.assign(Error(e),{name:wt}),bl=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,xl=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,Sl=`frame.addScriptTag: no answer within ${kr}ms; the script may or may not have run`,Cl=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,wl=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,Tl=3e4,El=`frame.clearCookies: the render proxy did not answer within ${Tl}ms; the cookies may or may not be gone, and calling it again is safe`,Dl=e=>Nt(e)&&e.message===At(`addScriptTag`).message,Ol=!1,kl=()=>{Ol||(Ol=!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.`))},Al=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=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}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},jl=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},Ml=({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}=fl({session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,documentHost:typeof e.documentHost==`function`?()=>c(()=>e.documentHost()):void 0,current:()=>f,consent:jl(l),freshBlank:m});return lr({backend:`cloud`,executor:{execute:(t,n,r)=>hl.has(n)?Promise.reject(At(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,n],phase:`execute`}),vl(c(()=>e.executeLocator([],`evaluate`,[t,n])),kr,jr)),addScriptTag:async(t,n)=>{s();let r=[t,n];await g({parts:[],operation:`addScriptTag`,args:r,phase:`execute`});try{await vl(c(()=>e.executeLocator([],`addScriptTag`,r)),kr,Sl)}catch(e){throw Dl(e)?kt(xl,`addScriptTag`,`cloud`):e}},clearCookies:async t=>{if(s(),typeof e.clearCookies!=`function`)throw kt(Cl,`clearCookies`,`cloud`);if(v().length===0)throw V(wl,`clearCookies`);await vl(c(()=>e.clearCookies(t)),Tl,El)},postMessage:(t,n,r)=>{if(s(),typeof e.messaging!=`function`)throw kt(bl,`postMessage`,`cloud`);if(n!==`*`&&!v().includes(new URL(n).hostname))throw V(sl,`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`&&kl(),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 vl(c(()=>e.goto(i,n===void 0?r:{...r,timeoutMs:n})),(n??3e4)+ml,`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),Pr(e)}f=i,u()},url:()=>f})},Nl=250,Pl=500,Fl=65e3,Il=2e3,Ll=2e3,Rl=2,zl=2e3,Bl=2e3,Vl=({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},Hl=(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},Ul=(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})},Wl=()=>yl(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),Gl=()=>yl(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),Kl=()=>yl(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),ql=()=>yl(`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`),Jl=async(e,t)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:n=[],permissions:r}=e,{url:a,width:o,height:s}=Lr(e.window);if(window.origin===`null`)throw new Zn(`opaque-opener`);let c=gl(),l=crypto.randomUUID(),u=_l(t),d=R(n),f=new Set;a&&f.add(new URL(a).origin);let p=t===`persistent`?Hl(c,l):null,m=window.open(Vl({origin:c,target:a,session:u,domains:d,attach:l}),`_blank`,`popup,width=${o},height=${s}`);if(!m)throw p?.remove(),new Yn;let h=new AbortController,g=!1,_=null,v=(e,t=!1)=>{if(_===null){_=e,h.abort(t?Gl():Wl());try{m.closed||m.postMessage({type:gi.detach,attach:l,...t?{unanswered:t}:{}},c)}catch{}p&&setTimeout(()=>p.remove(),Bl)}};p&&Ul(p,h.signal);let y=new Promise((e,t)=>{h.signal.addEventListener(`abort`,()=>t(h.signal.reason),{once:!0})});y.catch(()=>{});let b=y.then(()=>{},()=>{}),x=()=>{if(h.signal.aborted)throw h.signal.reason},S=e=>h.signal.aborted?Promise.reject(h.signal.reason):Promise.race([e(),y]),C=e=>e.source===m&&e.origin===c;window.addEventListener(`message`,e=>{if(!C(e))return;let t=e.data;typeof t==`object`&&t&&t.attach===l&&(t.type===gi.refused?v(new Zn(t.reason)):t.type===gi.gone&&v(g?Wl():Kl()))},{signal:h.signal}),window.addEventListener(`pagehide`,()=>v(Wl()),{signal:h.signal});let w=()=>{try{m.postMessage({type:gi.hello,attach:l},c)}catch{}};w();let T=setInterval(w,Nl),E=setInterval(()=>{m.closed&&v(g?Wl():ql())},Pl);h.signal.addEventListener(`abort`,()=>{clearInterval(T),clearInterval(E)},{once:!0});let D=async e=>{try{return await Promise.race([e,y])}catch(e){throw _??e}};try{let e=await D(vl(i({},{key:hi,transport:{emit:(e,t)=>m.postMessage(e,c,t??[]),receive:e=>{let t=t=>{C(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:h.signal,revivableModules:pl(Ie)}),_i,`cloud.attachFrame: timed out connecting to the window`));g=!0,clearInterval(T);let t=0,n=setInterval(()=>{vl(S(()=>e.ping()),Ll,`ping`).then(()=>{t=0},()=>{h.signal.aborted||(document.visibilityState===`hidden`?t=0:++t>=Rl&&v(Gl(),!0))})},Il);h.signal.addEventListener(`abort`,()=>clearInterval(n),{once:!0}),await D(vl(e.ready(),Fl,`cloud.attachFrame: the window never became ready`));let o=oi(`attached frame`);h.signal.aborted?o():h.signal.addEventListener(`abort`,o,{once:!0});let s=Ml({control:e,target:a,session:u,declaredHosts:d,approvedOrigins:f,attach:l,assertLive:x,guard:S,consent:{request:t=>S(()=>e.requestConsent(t)),ensure:t=>S(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:Al({from:()=>m,origin:c,attach:l,signal:h.signal})}),p=null,_=Object.assign(s,{close:()=>p??=(async()=>{h.signal.aborted||await vl(Promise.allSettled([S(()=>e.flushCookies()),S(()=>e.sweepStorage())]),zl,`close`).catch(()=>{});try{m.close()}catch{}v(Wl())})(),closed:b});return r?.length&&await D(_.requestPermissions(r)),_}catch(e){let t=_??e;if(!(t instanceof Zn))try{m.close()}catch{}throw v(t),t}},Yl=2e4,Xl=65e3,Zl=e=>!e||e===`about:blank`,Ql=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,$l=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,eu=e=>e.split(`#`)[0]??``,tu=({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(!Zl(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(Un(o.href),!fu())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return o.href},nu=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,gl());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ru=(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())},iu=()=>yl(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),au=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},ou=[300,1200,4e3],su=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 ou)setTimeout(t,e)},cu=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`)},lu=async(e,t)=>{let n=typeof e.blank==`function`?await vl(e.blank(),Xl,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof n!=`string`||eu(n)!==eu(t))throw kt(Ql,`blank`,`cloud`)},uu=async(e,t)=>{let n=tu(e),{iframe:r,domains:a=[],permissions:o}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!r.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);cu(r);let s=r.getAttribute(`src`)??``,c=(()=>{if(Zl(s))return null;try{return new URL(r.src||s,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${s}`)}})();if(c){let e=new URL(`/attach-frame`,gl());if(c.origin===e.origin&&c.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 l=c?.href??``;l&&Un(l);let u=_l(t),d=R(a),f=new Set;try{f.add(new URL(n||l).origin)}catch{}let p=new AbortController,m=r.referrerPolicy,h=r.allow,g=crypto.randomUUID();if(r.referrerPolicy=`origin`,r.allow=au(b(),r.allow),r.src=nu({target:l,blank:n,session:u,domains:d,attach:g}),!r.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await vl(i({},{key:mi,origin:gl(),transport:{receive:window,emit:r.contentWindow},unregisterSignal:p.signal,revivableModules:pl(Ie)}),Yl,`cloud.attachFrame: timed out connecting to the render proxy page`);await vl(e.ready(),Xl,`cloud.attachFrame: the render proxy never became ready`),n&&await lu(e,n),(l||n)&&su(r),ru(r,()=>p.abort());let t=oi(`attached frame`);p.signal.aborted?t():p.signal.addEventListener(`abort`,t,{once:!0});let a=r.contentWindow,s=Ml({control:e,target:n||l,blank:n!==``,session:u,declaredHosts:d,approvedOrigins:f,attach:g,assertLive:()=>{if(p.signal.aborted||!r.isConnected||r.contentWindow!==a)throw p.abort(),iu()},guard:e=>e(),consent:ol,onNavigated:()=>su(r),relay:Al({from:()=>a,origin:gl(),attach:g,signal:p.signal})});return o?.length&&await s.requestPermissions(o),s}catch(e){throw p.abort(),r.referrerPolicy=m,r.allow=h,r.src=l||`about:blank`,e}},du=(async e=>{let{kind:t,cookies:n}=Br(e);if(n===`native`)throw TypeError($l);return t===`window`?Jl(e,n):uu(e,n)}),fu=()=>typeof window<`u`&&!0,pu=async()=>{let e=await g.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}},mu=d({attachFrame:()=>du,available:()=>hu,dgram:()=>Tc,dns:()=>yi,fetch:()=>fi,fs:()=>eo,http:()=>Pc,net:()=>vc,quota:()=>pu}),hu=()=>y,gu=async e=>{if(typeof window>`u`)return!1;if(Xe())return!0;let t=await g,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},_u=null;$e(()=>(_u||=gu().then(()=>void 0).finally(()=>{_u=null}),_u));var vu=d({available:()=>Su,list:()=>Eu,readFile:()=>wu,remove:()=>Tu,writeFile:()=>Cu}),yu=()=>navigator.storage.getDirectory(),bu=e=>{let t=e.split(`/`).filter(e=>e&&e!==`.`);if(t.some(e=>e===`..`)||!t.length)throw Error(`opfs: invalid path`);return t},xu=async(e,t)=>{let n=await yu();for(let r of e)n=await n.getDirectoryHandle(r,{create:t});return n},Su=async()=>{try{return typeof navigator<`u`&&!!navigator.storage?.getDirectory&&!!await yu()}catch{return!1}},Cu=async(e,t,n)=>{let r=bu(e),i=r.pop(),a=await(await(await xu(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()}},wu=async e=>{let t=bu(e),n=t.pop();return(await(await xu(t,!1)).getFileHandle(n)).getFile()},Tu=async e=>{let t=bu(e),n=t.pop();await(await xu(t,!1)).removeEntry(n,{recursive:!0})},Eu=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 yu(),``),e},Du=`modulepreload`,Ou=function(e,t){return new URL(e,t).href},ku={},Au=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Ou(t,n),t=s(t),t in ku)return;ku[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Du,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ju=d({adopt:()=>Bd,adoptable:()=>Hd,available:()=>Lu,captureAccount:()=>Mu,list:()=>Sd,onConflict:()=>kd,pending:()=>id,pendingDeletes:()=>ad,pull:()=>Dd,readFile:()=>Cd,readFileSealed:()=>wd,remove:()=>Ed,replicating:()=>od,writeFile:()=>Td}),Mu=J,Nu,Pu=async()=>await(Nu??=Su().catch(()=>!1))?!0:(Nu=void 0,!1),Fu=()=>Wa().catch(()=>`unknown`),Iu=async()=>await Fu()===`connected`,Lu=async()=>await Pu()||await Iu(),Ru=`fkn:fs:pending`,zu=`fkn:fs:pending-delete`,Bu=`fkn:fs:adopt-declined`,Vu=!0,Hu=new Map,Uu=null,Wu=(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:Pa(e),r=n(e);return r!==void 0&&r===n(t)},Gu=(e,t)=>Wu(Uu,t)?Hu.get(e)??null:null,Ku=e=>e===`write`?Ru:zu,qu=e=>{try{let t=localStorage.getItem(Ku(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{}}},Ju=(e,t)=>{try{Object.keys(t).length?localStorage.setItem(Ku(e),JSON.stringify(t)):localStorage.removeItem(Ku(e))}catch{}},Yu=()=>{try{let e=JSON.parse(localStorage.getItem(Bu)??`{}`);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}},Xu=new Map,Zu=e=>`pin`in e?e.pin:Pa(e)??null,Qu=(e,t,n,r)=>{let i=qu(e),a=i[t],o=Zu(r);a&&o!==null&&a.pin===o||(i[t]={base:a?a.base:n,pin:o},Ju(e,i),o===null&&`generation`in r?Xu.set(`${e}:${t}`,r):Xu.delete(`${e}:${t}`))},$u=(e,t)=>{Xu.delete(`${e}:${t}`);let n=qu(e);t in n&&(delete n[t],Ju(e,n),fd()||(hd=pd))},ed=(e,t,n)=>Qu(`write`,e,t,n),td=e=>$u(`write`,e),nd=(e,t)=>Qu(`delete`,e,Gu(e,t),t),rd=e=>$u(`delete`,e),id=()=>Object.keys(qu(`write`)),ad=()=>Object.keys(qu(`delete`)),od=()=>Vu,sd=new Map,cd=e=>sd.get(e)===J().generation,ld=(e,t,n)=>n.pin===null&&!Xu.has(`${e}:${t}`),ud=null,dd=!1;si(`storage replication`,()=>ud!==null||Gd!==null);var fd=()=>[`write`,`delete`].some(e=>Object.entries(qu(e)).some(([t,n])=>n.pin===null?!ld(e,t,n):!cd(n.pin))),pd=6e4,md=6e5,hd=pd,gd=null,_d=()=>{!gd&&typeof window<`u`&&fd()&&(gd=setTimeout(()=>{gd=null,vd()},hd),hd=Math.min(hd*2,md))},vd=()=>{if(ud){dd=!0;return}fd()&&(ud=Ld(!1,J()).then(e=>{if(!fd()){hd=pd;return}e.failed.length&&_d()}).catch(()=>{_d()}).finally(()=>{ud=null,yd()}))},yd=()=>{dd&&(dd=!1,vd())},bd=null,xd=()=>bd??=Au(()=>import(`./api-CXwRN66S.js`).then(e=>e.apiPromise),__vite__mapDeps([0,1,2]),import.meta.url),Sd=async e=>{let t=e?.pin??J();Qd();let n=await Fu(),r=n===`connected`,[i,a]=await Promise.all([Pu().then(e=>e?Eu():[]).catch(()=>[]),r?Ga({pin:t}).then(e=>({ok:!0,entries:e}),e=>({ok:!1,entries:[],changed:Ea(e)?e:void 0})):Promise.resolve({ok:n===`disconnected`,entries:[]})]);if(n!==`unknown`&&(Vu=a.ok),a.ok&&n!==`unknown`&&(Hu=new Map(a.entries.map(e=>[e.path,e.updatedAt])),Uu=t),a.changed)throw a.changed;let o=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&&(Xd(i,a.entries).catch(()=>{}),fd()?vd():qd({local:i,remote:a.entries,from:t}).catch(()=>{})),[...o.values()]},Cd=async(e,t)=>{let n=t?.pin??J();if(await Pu())try{return await wu(e)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await qa(e,{pin:n});return await Pu()&&Cu(e,r).catch(()=>{}),r},wd=async(e,t)=>{let n=t?.pin??J();if(await Pu())try{let t=await wu(e);return{data:new Uint8Array(await t.arrayBuffer()),sealedAt:null}}catch(e){if(e?.name!==`NotFoundError`)throw e}return Ya(e,{pin:n})},Td=async(e,t,n)=>{let r=n?.pin??J(),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 Pu()){await Cu(e,o,a),Qd();let t=Gu(e,r),n=await Fu();if(n===`disconnected`)return;if(n===`unknown`||!Vu){ed(e,t,r),_d();return}Xa(e,o,{...a,pin:r}).then(()=>td(e)).catch(n=>{ed(e,t,r),Ea(n)||_d(),console.warn(`fs: cloud replicate failed, queued for adopt()`,n)});return}let s=await Fu();if(s===`connected`)return Xa(e,o,{...a,pin:r});throw Error(s===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`)},Ed=async(e,t)=>{let n=t?.pin??J();Qd();let r=[];await Pu()&&r.push(Tu(e).catch(()=>{}));let i=await Fu();if(i===`connected`?r.push(Za(e,{pin:n}).then(()=>rd(e)).catch(t=>{nd(e,n),Ea(t)||_d(),console.warn(`fs: cloud delete failed, queued for retry`,t)})):i===`unknown`&&r.length&&Gu(e,n)!==null&&(nd(e,n),_d()),!r.length)throw Error(i===`unknown`?`fs: cloud unreachable`:`fs: no storage backend available`);td(e),await Promise.all(r)},Dd=async e=>{let t=await qa(e,{pin:J()});return await Pu()&&await Cu(e,t),t},Od=null,kd=e=>(Od=e,()=>{Od===e&&(Od=null)}),Ad=async e=>{let t=await(await xd()).cloud.fs.promptConflict({path:e.path,local:e.local,cloud:e.cloud}).catch(()=>null);return t===`local`?e.readLocal():t===`cloud`?e.readCloud():null},jd=async e=>{if(Od)try{return await Od(e)}catch{return null}return Ad(e)},Md=class extends Error{},Nd=e=>e instanceof Error?e.message:String(e),Pd=()=>{let e=new Map,t=t=>{let n=e.get(t);return n||e.set(t,n={writes:new Map,deletes:new Map}),n};for(let[e,n]of Object.entries(qu(`write`)))t(n.pin).writes.set(e,n.base);for(let[e,n]of Object.entries(qu(`delete`)))t(n.pin).deletes.set(e,n.base);return e},Fd=async()=>{for(let[e,t]of[...Xu]){let n=e.startsWith(`write:`)?`write`:`delete`,r=e.slice(n.length+1),i;try{i=await Fa(t)}catch(t){Ea(t)&&Xu.delete(e);continue}if(Xu.get(e)!==t)continue;Xu.delete(e);let a=qu(n),o=a[r];o&&o.pin===null&&(a[r]={base:o.base,pin:i},Ju(n,a))}},Id=async(e,t,n,r,i,a)=>{let o=new Map(t.map(e=>[e.path,e])),s=e=>{if(Ea(e))throw new Md};for(let[t,a]of e.deletes){let e=o.get(t);if(!e){rd(t);continue}if(r.some(e=>e.path===t)){rd(t);continue}if(e.updatedAt!==a){rd(t);continue}try{await Za(t,n),rd(t),i.deleted.push(t)}catch(e){s(e),i.failed.push({path:t,error:Nd(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 jd({path:t.path,local:{size:t.size,updatedAt:t.updatedAt},cloud:{size:r.size,updatedAt:r.updatedAt},readLocal:()=>e??=wu(t.path),readCloud:()=>a??=qa(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 Xa(t.path,o,t.contentType?{contentType:t.contentType,...n}:n),r||await Cu(t.path,o),td(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:Nd(e)})}continue}try{let e=await wu(t.path);await Xa(t.path,e,t.contentType?{contentType:t.contentType,...n}:n),td(t.path),i.uploaded.push(t.path)}catch(e){if(c||ed(t.path,r?.updatedAt??null,n.pin),s(e),e?.code===`FKN_E2E_LOCKED`)throw e;i.failed.push({path:t.path,error:Nd(e)})}}},Ld=async(e,t)=>{let n={uploaded:[],kept:[],resolved:[],unresolved:[],deleted:[],failed:[]},r=await Fu();if(r===`unknown`)throw Error(`fs: cloud unreachable`);if(r!==`connected`)throw Error(`fs: this needs a signed-in account`);let i=await Pu(),a=i?await Eu():[];if(i)for(let e of Object.keys(qu(`write`)))a.some(t=>t.path===e)||td(e);await Fd();for(let[e,r]of Pd()){if(e===null||cd(e))continue;let i={pin:{pin:e}},o;try{o=await Ga(i)}catch(n){if(Ea(n)){sd.set(e,t.generation);continue}if(Da(n)){Rd(e);continue}throw n}try{await Id(r,o,i,a,n,()=>!1)}catch(n){if(!(n instanceof Md))throw n;sd.set(e,t.generation)}}if(e){let e={pin:t},r=await Ga(e),i=qu(`write`),o=Pd().get(null)??{writes:new Map,deletes:new Map},s=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 Id(o,r,e,a,n,c)}catch(e){throw e instanceof Md?new wa:e}}return n},Rd=e=>{for(let t of[`write`,`delete`]){let n=qu(t),r=!1;for(let t of Object.values(n))t.pin===e&&(t.pin=null,r=!0);r&&Ju(t,n)}},zd=async e=>{for(;ud;)await ud;let t=Ld(!0,e);ud=t.then(()=>{},()=>{});try{return await t}finally{ud=null,yd()}},Bd=()=>zd(J()),Vd=(e,t)=>{let n=new Set(t.map(e=>e.path)),r=qu(`write`);return e.filter(e=>{let t=r[e.path];return t?ld(`write`,e.path,t):!n.has(e.path)})},Hd=async()=>{let e=J();if(!await Iu()||!await Pu())return{paths:[],bytes:0};let[t,n]=await Promise.all([Eu(),Ga({pin:e})]),r=Vd(t,n);return{paths:r.map(e=>e.path),bytes:r.reduce((e,t)=>e+t.size,0)}},Ud=()=>new Set(Object.keys(Yu())),Wd=e=>{let t=Yu();for(let n of e)t[n]=null;try{localStorage.setItem(Bu,JSON.stringify(t))}catch{}},Gd=null,Kd=!1,qd=e=>{if(Gd)return Kd=!0,Gd;let t=e?.from??J();return Gd=(async()=>{if(!await Iu())return;let n=e??(await Pu()?{local:await Eu(),remote:await Ga({pin:t})}:null);if(!n)return;let r=Ud(),i=Vd(n.local,n.remote).filter(e=>!r.has(e.path));if(!i.length)return;let a=await xd(),o=i.reduce((e,t)=>e+t.size,0);if(!await a.cloud.fs.promptAdopt({files:i.length,bytes:o}).catch(()=>!1)){Wd(i.map(e=>e.path));return}`generation`in t&&await zd(t)})().catch(()=>{}).finally(()=>{Gd=null,Kd&&(Kd=!1,qd())}),Gd},Jd=null,Yd=!1,Xd=async(e,t)=>{let n=Vd(e,t),r=await xd(),i=async()=>{await Bd().catch(()=>{});let e=await Hd().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)};Jd=()=>{r.cloud.fs.setAdoptSource(a,i).catch(()=>{})},Yd||(Yd=!0,Au(()=>import(`./api-CXwRN66S.js`).then(e=>e.onApiEpoch((e,t)=>{t>1&&Jd?.()})),__vite__mapDeps([0,1,2]),import.meta.url).catch(()=>{})),await r.cloud.fs.setAdoptSource(a,i)},Zd=!1,Qd=()=>{Zd||typeof window>`u`||(Zd=!0,window.addEventListener(`online`,()=>{vd()}),Au(()=>import(`./account-QzTt80xa.js`).then(e=>e.onChange(()=>{qd().catch(()=>{}),vd()})),__vite__mapDeps([3,4,1,2]),import.meta.url).catch(()=>{}))},$d=ga(ju,{memfs:!0}),{available:ef,readFileSync:tf,writeFileSync:nf,appendFileSync:rf,existsSync:af,statSync:of,lstatSync:sf,readdirSync:cf,mkdirSync:lf,rmSync:uf,rmdirSync:df,unlinkSync:ff,renameSync:pf,readFile:mf,writeFile:hf,appendFile:gf,stat:_f,readdir:vf,mkdir:yf,rm:bf,unlink:xf,rename:Sf,exists:Cf,promises:wf,mount:Tf,flush:Ef,remount:Df}=$d;({...$d});var{available:Of,readFileSync:kf,writeFileSync:Af,appendFileSync:jf,existsSync:Mf,statSync:Nf,lstatSync:Pf,readdirSync:Ff,mkdirSync:If,rmSync:Lf,rmdirSync:Rf,unlinkSync:zf,renameSync:Bf,readFile:Vf,writeFile:Hf,appendFile:Uf,stat:Wf,readdir:Gf,mkdir:Kf,rm:qf,unlink:Jf,rename:Yf,exists:Xf,promises:Zf,mount:Qf,flush:$f,remount:ep}=ga(vu,{memfs:!0}),tp=d({attach:()=>Dp,connect:()=>xp,hide:()=>bp,install:()=>lp,isVisible:()=>Vp,list:()=>up,mount:()=>Ep,onConnect:()=>Bp,onVisibilityChange:()=>Hp,pick:()=>cp,search:()=>sp,show:()=>yp,uninstall:()=>dp}),np=`fkn-packages-connection`,rp=3e4,Z=(e,t)=>Object.assign(Error(t),{code:e}),ip=async()=>{if(!y)throw Z(`unavailable`,`packages: no FKN transport in this realm - use relayWorker to bridge workers`);return g},ap=(e,t,n)=>i(e??{},{transport:t,key:np,unregisterSignal:n}),op=async(e,t,n={})=>{let{signal:r,closed:i}=n;if(r?.aborted)throw Z(`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(Z(`timeout`,`packages.connect: the package did not complete the connection`)),rp);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(Z(`unavailable`,typeof t==`string`&&t?t:`packages.connect: the package refused the connection`))}},{signal:o.signal}),t.start(),r&&r.addEventListener(`abort`,()=>n(Z(`unavailable`,`packages.connect: aborted before connecting`)),{once:!0,signal:o.signal}),i?.then(()=>n(Z(`unavailable`,`packages.connect: the package closed before connecting`)))});try{return await Promise.race([ap(e,t,a.signal),s])}catch(e){a.abort(e);try{t.close()}catch{}throw e}finally{o.abort()}},sp=async e=>{let t=await(await ip()).packages.search(e);if(`error`in t)throw Z(t.error,t.message);return t.results},cp=async(e,t)=>{let n=await(await ip()).packages.pick(e,t);if(`error`in n)throw Z(n.error,n.message);return`declined`in n?[]:n.results},lp=async(e,t)=>{let n=await(await ip()).packages.install(e,t);if(`error`in n)throw Z(n.error,n.message);return`declined`in n?null:n.installed},up=async()=>(await(await ip()).packages.list()).results,dp=async e=>{let t=await(await ip()).packages.uninstall(e);if(`error`in t)throw Z(t.error,t.message)},fp=({x:e,y:t,width:n,height:r})=>({x:Math.round(e),y:Math.round(t),width:Math.round(n),height:Math.round(r)}),pp=(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)}},mp=(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=pp(n,fp(t.getBoundingClientRect())),n.width===0||n.height===0))break}return n},hp=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},gp=(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)},_p=new Map;si(`package view`,()=>_p.size>0);var vp=async(e,t)=>{let n=_p.get(e);if(n){for(let e of n)t&&e.element!==t||(e.stop(),n.delete(e));if(n.size>0)return;_p.delete(e)}let r=await(await ip()).packages.hide(e);if(`error`in r)throw Z(r.error,r.message)},yp=async(e,t)=>{let{element:n,rect:r}=t;if(!n&&!r)throw Z(`invalid`,`packages.show: pass an element or a rect`);let i=(await ip()).packages,a=()=>{if(!n)return{rect:fp(r)};let e=fp(n.getBoundingClientRect());return{rect:e,clip:mp(n,e),radius:hp(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,Z(n.error,n.message)};await l(a());let u=()=>{if(!o)return;let e=a();gp(s,e)||l(e).catch(()=>{}),c=requestAnimationFrame(u)};n&&(c=requestAnimationFrame(u));let d={element:n,stop:()=>{o=!1,cancelAnimationFrame(c)}},f=_p.get(e)??new Set;return f.add(d),_p.set(e,f),{hide:()=>{vp(e,n).catch(()=>{})},refresh:()=>{if(!o)return;let e=a();gp(s,e)||l(e).catch(()=>{})}}},bp=async(e,t={})=>vp(e,t.element),xp=(async(e,t={})=>{let n=await(await ip()).packages.connect(e,{protocol:t.protocol,...t.path===void 0?{}:{path:t.path}});if(`error`in n)throw Z(n.error,n.message);let r=oi(`package connection`),i=C()?.epoch??0,a=S((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 op(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}}),Sp=[`allow-scripts`,`allow-same-origin`],Cp=e=>{let t=e.getAttribute(`sandbox`);if(t!==null){let e=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),n=Sp.filter(t=>!e.has(t));if(n.length)throw Z(`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 Z(`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`)},wp=3e4,Tp=(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(Z(`unavailable`,typeof r.message==`string`&&r.message?r.message:`packages.mount: the package failed to boot`))},o=setTimeout(()=>i(Z(`timeout`,`packages.mount: the package did not register a connection handler`)),wp);window.addEventListener(`message`,a)}),Ep=async(e,t)=>{let{iframe:n}=t;if(!(n instanceof HTMLIFrameElement))throw Z(`invalid`,`packages.mount: pass the iframe to load the package into`);if(!n.isConnected)throw Z(`invalid`,`packages.mount: the iframe must be in the document before mounting into it`);Cp(n);let r=await(await ip()).packages.frame(e);if(`error`in r)throw Z(r.error,r.message);n.src=r.url;let i={done:!1},a=()=>{},o=new Promise(e=>{a=e}),s=oi(`mounted package`),c=()=>{if(!i.done){i.done=!0,s();try{n.contentWindow?.postMessage({type:`fkn-packages-close`},r.origin)}catch{}n.src=`about:blank`,a()}};try{await Tp(n,r.origin)}catch(e){throw c(),e}let l=new MessageChannel,u=n.contentWindow;if(!u)throw c(),Z(`unavailable`,`packages.mount: the frame was detached before it could connect`);u.postMessage({type:`fkn-packages-port`,from:r.from,protocol:t.protocol,uri:r.uri,name:r.name,version:r.version},r.origin,[l.port2]);try{u.postMessage({type:`fkn-packages-visibility`,visible:!0},r.origin)}catch{}if(t.raw)return{closed:o,port:l.port1,frame:n,unmount:c};try{return{remote:await op(t.payload,l.port1,{signal:t.signal,closed:o}),closed:o,port:l.port1,frame:n,unmount:c}}catch(e){throw c(),e}},Dp=(e,t,n)=>op(t,e,{signal:n?.signal}),Op=null,kp=!1,Ap=new Set,jp=[],Mp=new Map,Np=!1,Pp=!1,Fp=e=>{let t=Mp.get(e);t&&(Mp.delete(e),t())},Ip=(e,t)=>{try{e.postMessage({type:`fkn-packages-nack`,message:t})}catch{}try{e.close()}catch{}},Lp=async(e,t)=>{let{port:n,...r}=e;e.port.addEventListener(`message`,t=>{t.data?.type===`fkn-packages-disconnect`&&Fp(e.port)});let i;try{i=await t.createPayload(r)}catch(t){throw Ip(e.port,t instanceof Error?t.message:`the package failed to produce a connection`),t}let a=new Promise(t=>Mp.set(e.port,t)),o=await ap(i,e.port);t.handler?.({...r,remote:o,closed:a,port:e.port})},Rp=()=>{Np||typeof window>`u`||window.parent===window||(Np=!0,window.addEventListener(`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:``,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:``};Op?Lp(r,Op).catch(e=>console.warn(`packages.onConnect:`,e)):jp.push(r)}if(t?.type===`fkn-packages-close`)for(let e of[...Mp.keys()])Fp(e);if(t?.type===`fkn-packages-visibility`){kp=t.visible===!0;for(let e of Ap)try{e(kp)}catch{}}}))},zp=()=>{Pp||typeof window>`u`||window.parent===window||(Pp=!0,window.parent.postMessage({type:`fkn-packages-ready`},`*`))},Bp=(e,t)=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Rp();let n={createPayload:e,handler:t};for(Op=n,zp();jp.length&&Op===n;)Lp(jp.shift(),n).catch(e=>console.warn(`packages.onConnect:`,e));return{unsubscribe:()=>{Op===n&&(Op=null)}}},Vp=()=>kp,Hp=e=>{if(typeof window>`u`)return{unsubscribe:()=>{}};Rp(),Ap.add(e);try{e(kp)}catch{}return{unsubscribe:()=>{Ap.delete(e)}}},Up=d({available:()=>Zp,create:()=>$p,join:()=>em,open:()=>Qp}),Q={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`,needsPremium:`rooms: claiming needs premium`,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`,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`,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`},$=(e,t)=>Object.assign(Error(t),{code:e}),Wp=e=>e instanceof Error&&typeof e.code==`string`,Gp={send:!0,receive:!0,maxMessageBytes:262144},Kp=async()=>{if(!y)return;let e=(await v(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},qp=()=>{throw $(`unavailable`,Q.unavailable)},Jp=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,Yp=e=>{if(e!==void 0&&e!==!1)return e===!0?vi.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=vi.min&&e<=vi.max?e:null},Xp=async e=>{let t=e.invite,n=e,r=0,i=e.self,a=e.owner,o=e.claimed,s=e.mailbox,c=await e.defaults().catch(()=>Gp),l=!1,u=new Set,d=new Set,f=oi(`room`),p=()=>{},m=()=>{},h=new Promise(e=>{m=e}),g=e=>{let t=[...d];d.clear();for(let n of t)try{n(e)}catch{}},_=e=>{l||(l=!0,p(),u.clear(),f(),g($(`closed`,Q.ended)),m({reason:e}))},v=e=>{if(!l){e.type===`defaults`&&(c=e.defaults),e.type===`permissions`&&e.id===i.id&&(i={id:i.id,permissions:e.permissions,maxMessageBytes:e.maxMessageBytes}),e.type===`claim`&&(o=e.claimed,a=e.owner,o||(s=null));for(let t of[...u])try{t(e)}catch{}}},y=(e,t)=>{Promise.resolve(e.on(v)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===r&&_(e.reason)},()=>{})},b=async(e,u)=>{if(typeof e?.join!=`function`)return _(`unavailable`);let d=await e.join(t).catch(()=>void 0);if(l||u!==r)return;if(!d)return _(`unavailable`);if(`error`in d)return _(Jp(d.error));if(d.self.id!==i.id)return Promise.resolve(d.leave()).catch(()=>{}),_(`unavailable`);n=d,i=d.self,a=d.owner,o=d.claimed,s=d.mailbox,y(d,u);let f=await d.defaults().catch(()=>void 0);f&&!l&&u===r&&(c=f)};p=S((e,t)=>{let n=r;r=t,!(l||n===0||n===t)&&(g($(`unavailable`,Q.unavailable)),b(e.rooms,t))}),y(e,r);let x=async e=>{if(l)throw $(`closed`,Q.ended);let t=()=>{},r=new Promise((e,n)=>{t=n});d.add(t);try{return await Promise.race([Promise.resolve(e(n)),r])}catch(e){throw Wp(e)?e:$(`unavailable`,Q.unavailable)}finally{d.delete(t)}},C=async e=>{let t=await x(e);if(`error`in t)throw $(t.error,t.message)},w=async e=>{let t=await x(e);if(typeof t==`object`&&t&&`error`in t)throw $(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:t,get self(){return i},get owner(){return a},get claimed(){return o},get mailbox(){return s},defaults:()=>c,members:()=>x(e=>e.members()),send:e=>C(t=>t.send(e)),edit:(e,t)=>C(n=>n.edit(e,t)),delete:(e,t)=>C(n=>n.delete(e,t)),backlog:(e,t)=>w(n=>n.backlog(e,t)),setDefault:(e,t)=>C(n=>n.setDefault(e,t)),limit:(e,t)=>C(n=>n.limit(e,t)),grant:(e,t)=>C(n=>n.grant(e,t)),revoke:(e,t)=>C(n=>n.revoke(e,t)),remove:e=>C(t=>t.remove(e)),block:e=>C(t=>t.block(e)),unblock:e=>C(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw $(`invalid`,Q.badDescription);let n=Yp(e?.temporary);if(n===null)throw $(`invalid`,Q.badTemporary);let r={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n}};return Object.keys(r).length===0?C(e=>e.claim()):C(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw $(`unavailable`,Q.temporaryUnavailable);return e.claim(r)})},release:()=>C(e=>e.release()),usage:async()=>{let e=await w(e=>e.usage());return s=e,e},on:async e=>l?()=>{}:(u.add(e),()=>{u.delete(e)}),leave:async()=>{await Promise.resolve(n.leave()).catch(()=>{}),_(`left`)},closed:h}},Zp=async()=>{let e=await Kp();return e?e.available().catch(()=>!1):!1},Qp=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw $(`invalid`,Q.badName);let n=await Kp();if(!n)throw $(`unavailable`,Q.unavailable);let r=await n.open(e,t).catch(qp);if(`error`in r)throw $(r.error,r.message);return Xp(r)},$p=async e=>{let t=await Kp();if(!t)throw $(`unavailable`,Q.unavailable);let n=await t.create(e).catch(qp);if(`error`in n)throw $(n.error,n.message);return Xp(n)},em=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw $(`invalid`,Q.inviteNoKey);let r=await Kp();if(!r)throw $(`unavailable`,Q.unavailable);let i=await r.join(e,t).catch(qp);if(`error`in i)throw $(i.error,i.message);return Xp(i)},tm=1e4,nm=150,rm=()=>new Promise(e=>{if(Xe())return e(!0);let t,n=setTimeout(()=>r(Xe()),tm),r=r=>{clearTimeout(t),clearTimeout(n),a.disconnect(),document.removeEventListener(`readystatechange`,o),e(r)},i=()=>{clearTimeout(t),t=setTimeout(()=>r(Xe()),nm)},a=new MutationObserver(()=>{Xe()&&r(!0)}),o=()=>{document.readyState===`complete`&&!Xe()&&i()};a.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-fkn-extension`]}),document.addEventListener(`readystatechange`,o),document.readyState===`complete`&&i()}),im=(async e=>{let{kind:t,cookies:n}=Br(e);if(t===`window`){let t=e;return n===`native`?ri(t):du(t)}let r=e;return n===`native`?am(r):du(r)}),am=async e=>(tu(e),await rm(),ri(e)),om=`https://fkn.app`,sm=async(e,t)=>{if(typeof window>`u`)throw Error(`FKN @fkn/lib: relayWorker must be called from the main thread`);let n=await x;if(!n)throw Error(`FKN @fkn/lib: relayWorker found no FKN transport in this realm`);_();let r=oi(`relayed worker`);t?.unregisterSignal?.aborted?r():t?.unregisterSignal?.addEventListener(`abort`,r,{once:!0});let i=n.emit instanceof MessagePort?{}:{originA:t?.originA??om,originB:t?.originB??`*`};s(n,e,{key:`fkn-api`,...i,unregisterSignal:t?.unregisterSignal})},cm=new Set,lm=()=>{if(cm.size===0)return!1;for(let e of[...cm])try{e()}catch{}return!0},um=(e,t)=>{if(typeof e?.onUpdateTaken==`function`)return Promise.resolve(e.onUpdateTaken(t))},dm=new Set,fm=()=>{for(let e of[...dm])try{e()}catch{}},pm=0;typeof window<`u`&&S(()=>{let e=C();e&&dm.size!==0&&pm!==e.epoch&&(pm=e.epoch,Promise.resolve(e.remote.shell?.onUpdate(fm)).catch(()=>{pm===e.epoch&&(pm=0)}))});var mm=0,hm=!1,gm=()=>{if(!lm()&&!hm){hm=!0;try{location.reload()}catch{}}};typeof window<`u`&&S(()=>{let e=C();if(!e||mm===e.epoch)return;mm=e.epoch;let t=um(e.remote.shell,gm);if(!t){mm=0;return}t.catch(()=>{mm===e.epoch&&(mm=0)})});var _m=(e,t)=>mu.fetch(e,t),vm=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`),ym=e=>e===`extension`?`native`:`persistent`,bm=new Set([`ExtensionOperationUnsupportedError`,`FrameWindowRefusedError`]),xm=(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))},Sm=async({url:e,domains:t,isSignedIn:n,permissions:r,width:i,height:a,pollMs:o=1e3,readTimeoutMs:s=5e3})=>{let c=im({window:{...i===void 0?{}:{width:i},...a===void 0?{}:{height:a}},domains:t,cookies:ym(Xe()?`extension`:`cloud`),...r?{permissions:r}:{}}),l;try{l=await c}catch(e){let t=e?.name;if(t===`FrameWindowBlockedError`)return`blocked`;if(t&&bm.has(t))return console.warn(`[login-window] window mode was refused`,e),`unsupported`;if(It(e))return`closed`;throw e}try{await l.goto(e,{waitUntil:`commit`})}catch(e){if(!It(e))throw await l.close().catch(()=>{}),e}let u=l.closed.then(()=>`closed`);for(;;){let e=await Promise.race([u,new Promise(e=>setTimeout(e,o)).then(()=>xm(()=>n(l),s))]);if(e===`closed`)return`closed`;if(e===!0)return await l.close(),`authed`}};export{Xe as _,im as a,tp as c,X as d,uo as f,Qa as g,Wa as h,_m as i,Au as l,$a as m,ym as n,sm as o,fo as p,vm as r,Up as s,Sm as t,Qo as u};
|