sliccy 6.76.0 → 6.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/node-server/_shared/agent-wire-types.d.ts +28 -0
  2. package/dist/node-server/_shared/agent-wire-types.d.ts.map +1 -1
  3. package/dist/node-server/bridge-security.js +1 -1
  4. package/dist/node-server/fetch-proxy-headers.d.ts +7 -0
  5. package/dist/node-server/fetch-proxy-headers.js +7 -0
  6. package/dist/node-server/routes/fetch-proxy.js +18 -1
  7. package/dist/ui/.vite/manifest.json +233 -233
  8. package/dist/ui/assets/{account-store-BxGdz4En.js → account-store-BYQKqAgp.js} +3 -3
  9. package/dist/ui/assets/{account-store-BOO_CzoH.js → account-store-DxVNrRBU.js} +2 -2
  10. package/dist/ui/assets/{adobe-BS726v5F.js → adobe-DgvyQkR3.js} +2 -2
  11. package/dist/ui/assets/{adobe-DRIeZ7SH.js → adobe-d0FS6rbN.js} +1 -1
  12. package/dist/ui/assets/{apply-layout-8FDKkAyS.js → apply-layout-BR2L_XAe.js} +1 -1
  13. package/dist/ui/assets/{apps-Dy99L1_j.js → apps-yCWHyFOJ.js} +1 -1
  14. package/dist/ui/assets/{azure-openai-CSLwIPI9.js → azure-openai-BzlubeJS.js} +1 -1
  15. package/dist/ui/assets/{azure-openai-2PeEIEpE.js → azure-openai-DUj5um3l.js} +1 -1
  16. package/dist/ui/assets/{cerebras-Ba7Z9duV.js → cerebras-GaJLd0iF.js} +1 -1
  17. package/dist/ui/assets/{cerebras-QV_fd2ps.js → cerebras-LxIEL_2m.js} +1 -1
  18. package/dist/ui/assets/{client-BGJKiXya.js → client-BTUV7dbh.js} +1 -1
  19. package/dist/ui/assets/{composer-speech-faUgsBUj.js → composer-speech-SNeD5SER.js} +1 -1
  20. package/dist/ui/assets/{connect-surface-CTu0wr2Y.js → connect-surface-n0EhwnRN.js} +1 -1
  21. package/dist/ui/assets/{cost-command-AOg9dLn6.js → cost-command-Be2VSQE-.js} +1 -1
  22. package/dist/ui/assets/{discovery-preference-DnRQbFjv.js → discovery-preference-fqUhjzeE.js} +1 -1
  23. package/dist/ui/assets/{dist-BC2_PL11.js → dist-BgBby8A3.js} +2 -2
  24. package/dist/ui/assets/{dist-R_O83owj.js → dist-CUNJrB-E.js} +2 -2
  25. package/dist/ui/assets/{dist-lsxvfsEu.js → dist-DflFofKs.js} +1 -1
  26. package/dist/ui/assets/{dist-CbS97zBQ.js → dist-lpaE9omP.js} +1 -1
  27. package/dist/ui/assets/{ensure-speech-assets-tfN1ILpq.js → ensure-speech-assets-DDGWBTuw.js} +1 -1
  28. package/dist/ui/assets/{float-topology-BX3WJDxo.js → float-topology-BgioAcOd.js} +1 -1
  29. package/dist/ui/assets/{follower-navigate-watcher-B9JWWBt4.js → follower-navigate-watcher-CNC7ybEv.js} +1 -1
  30. package/dist/ui/assets/fs-M8pR-IYy.js +1 -0
  31. package/dist/ui/assets/fs-k3SuP720.js +2 -0
  32. package/dist/ui/assets/{github-BjNCMOTH.js → github-CSrhTw9O.js} +1 -1
  33. package/dist/ui/assets/{github-copilot-7vobYWUU.js → github-copilot-BMoQjC4H.js} +1 -1
  34. package/dist/ui/assets/{github-copilot-DlzADrSr.js → github-copilot-Cr-fq2Ji.js} +1 -1
  35. package/dist/ui/assets/{github-DGwuCXij.js → github-hM4cqkpY.js} +2 -2
  36. package/dist/ui/assets/{github-install-B8nRAI8z.js → github-install-BQa8EEjK.js} +1 -1
  37. package/dist/ui/assets/{github-zip-7k6aGRi5.js → github-zip-BDtWVoGh.js} +1 -1
  38. package/dist/ui/assets/{hear-BUBmK8Kl.js → hear-D33CHppO.js} +1 -1
  39. package/dist/ui/assets/{host-command-CzRn3Wvz.js → host-command-BsHBnvjR.js} +1 -1
  40. package/dist/ui/assets/{js-realm-worker-BH_Uhjou.js → js-realm-worker-CN4kgXJf.js} +1 -1
  41. package/dist/ui/assets/{kernel-worker-COfVGbIN.js → kernel-worker-BH0rEmWC.js} +658 -657
  42. package/dist/ui/assets/{lick-urls-DEfVsxzt.js → lick-urls-AW0BSaf4.js} +1 -1
  43. package/dist/ui/assets/{lick-ws-bridge-DZ5pLaXa.js → lick-ws-bridge-CWRES2H2.js} +1 -1
  44. package/dist/ui/assets/{lick-ws-bridge-C5jpbwXT.js → lick-ws-bridge-DiPcVRfN.js} +1 -1
  45. package/dist/ui/assets/{local-llm-CDx8pQEL.js → local-llm-CiXCcmVr.js} +1 -1
  46. package/dist/ui/assets/{local-llm-Ca41QR9W.js → local-llm-D256GT_v.js} +1 -1
  47. package/dist/ui/assets/{main-CBjLDGjV.js → main-BS0D26py.js} +3 -3
  48. package/dist/ui/assets/{mount-BNWucV-S.js → mount-B9_3ZQzT.js} +2 -2
  49. package/dist/ui/assets/{mount-bridge-client-CdactLBz.js → mount-bridge-client-4blXuJO1.js} +1 -1
  50. package/dist/ui/assets/{mount-recovery-B1Eib3Wt.js → mount-recovery-BZ_CHinL.js} +1 -1
  51. package/dist/ui/assets/{mount-Dcl0CQrv.js → mount-tfINOI55.js} +1 -1
  52. package/dist/ui/assets/{new-session-CGv5e7P7.js → new-session-B-Hg54W3.js} +2 -2
  53. package/dist/ui/assets/{oauth-bootstrap-DBbtYdzz.js → oauth-bootstrap-Cm9RUT-G.js} +2 -2
  54. package/dist/ui/assets/{oauth-service-DNcIcWT8.js → oauth-service-Bbrrl8Mr.js} +1 -1
  55. package/dist/ui/assets/{oauth-service-C9Jn4g2n.js → oauth-service-Cy5ngmcU.js} +1 -1
  56. package/dist/ui/assets/{openai-codex-BTUlRTto.js → openai-codex-BwJnndoW.js} +1 -1
  57. package/dist/ui/assets/{openai-codex-CZs8JRSw.js → openai-codex-SI6Y9VIv.js} +1 -1
  58. package/dist/ui/assets/{openrouter-Bvd2Eqif.js → openrouter-75bG7oVb.js} +1 -1
  59. package/dist/ui/assets/{openrouter-DYhI1zom.js → openrouter-CCkgw1Hq.js} +1 -1
  60. package/dist/ui/assets/{openrouter-oauth-DK-5hp2X.js → openrouter-oauth-BsRxdUIm.js} +1 -1
  61. package/dist/ui/assets/{openrouter-oauth-C6mgQiRV.js → openrouter-oauth-CxKccPms.js} +1 -1
  62. package/dist/ui/assets/{page-approval-service-BwheP_IN.js → page-approval-service-Bbc3_KdK.js} +1 -1
  63. package/dist/ui/assets/{panel-rpc-handlers-BXCRWF2E.js → panel-rpc-handlers-PZanZLgN.js} +2 -2
  64. package/dist/ui/assets/{port-bridge-client-CqQzd6rs.js → port-bridge-client-BbVs1yhx.js} +1 -1
  65. package/dist/ui/assets/{port-bridge-client-VUdCD0pB.js → port-bridge-client-DxYLF2-N.js} +1 -1
  66. package/dist/ui/assets/{provider-xByUgvpM.js → provider-CCymriTA.js} +1 -1
  67. package/dist/ui/assets/{provider-DxVWgpTU.js → provider-D7o2EKwf.js} +2 -2
  68. package/dist/ui/assets/{provider-settings-BWmqGvFK.js → provider-settings-DEB4b4aJ.js} +1 -1
  69. package/dist/ui/assets/{provider-settings-DByKbVop.js → provider-settings-TzcAGHan.js} +2 -2
  70. package/dist/ui/assets/{provider-store-access-BQfEu3u9.js → provider-store-access-BAr3RNys.js} +2 -2
  71. package/dist/ui/assets/provider-store-access-DI_9BT-e.js +1 -0
  72. package/dist/ui/assets/{providers-Db_Doqrk.js → providers-COBW-XCJ.js} +2 -2
  73. package/dist/ui/assets/{providers-DH1Mhm__.js → providers-NPujfHKb.js} +1 -1
  74. package/dist/ui/assets/proxied-fetch-B4g-4VbQ.js +2 -0
  75. package/dist/ui/assets/proxied-fetch-n2pCvcgW.js +1 -0
  76. package/dist/ui/assets/{quick-llm-nv9Pz0pZ.js → quick-llm-DDn8RKhn.js} +1 -1
  77. package/dist/ui/assets/{recovery-screen-0OnsBXuN.js → recovery-screen-DIiiwxvZ.js} +1 -1
  78. package/dist/ui/assets/{redirect-uri-DVwxCbAH.js → redirect-uri-DMl66Kja.js} +1 -1
  79. package/dist/ui/assets/{secret-env-D-b2fLc6.js → secret-env-q4hxkt7Z.js} +1 -1
  80. package/dist/ui/assets/secret-topology-xLmXoozo.js +1 -0
  81. package/dist/ui/assets/{secrets-bridge-client-C6W2y020.js → secrets-bridge-client-cWDAnFqs.js} +1 -1
  82. package/dist/ui/assets/{session-freezer-BVmmPVzM.js → session-freezer-DEQ1yv8N.js} +3 -3
  83. package/dist/ui/assets/{setup-feature-flags-remote-DCYtiT5O.js → setup-feature-flags-remote-C5LY6I_m.js} +1 -1
  84. package/dist/ui/assets/{setup-standalone-prelude-C89-5Dtf.js → setup-standalone-prelude-BfNMCJt3.js} +2 -2
  85. package/dist/ui/assets/{setup-sudo-CHykhXbm.js → setup-sudo-BSuoDx7e.js} +2 -2
  86. package/dist/ui/assets/{skills-BKsLImdA.js → skills-DUSnM1rm.js} +1 -1
  87. package/dist/ui/assets/slicc-version-Jic4BOQq.js +1 -0
  88. package/dist/ui/assets/{speak-B7odF4tO.js → speak-BDT9rGzg.js} +1 -1
  89. package/dist/ui/assets/{store-CEccVDd7.js → store-BkhxqaNb.js} +1 -1
  90. package/dist/ui/assets/{store-CgULlP3e.js → store-CQG01Tk6.js} +1 -1
  91. package/dist/ui/assets/{sudo-Bi--9XjE.js → sudo-C8XByrIL.js} +1 -1
  92. package/dist/ui/assets/{transformers-env-Ca8O2jds.js → transformers-env-SL0zTs7S.js} +1 -1
  93. package/dist/ui/assets/{tray-leader-CXKotSM9.js → tray-leader-DcRtwWl-.js} +1 -1
  94. package/dist/ui/assets/{tray-leave-runtime-5MLCSmgw.js → tray-leave-runtime-BGfdX5KF.js} +1 -1
  95. package/dist/ui/assets/{tray-runtime-config-BoItLnrD.js → tray-runtime-config-B1LF8Kd4.js} +1 -1
  96. package/dist/ui/assets/{tray-runtime-config-DAGrwZQV.js → tray-runtime-config-CRGwg9SK.js} +1 -1
  97. package/dist/ui/assets/{upgrade-detection-Di65pY4y.js → upgrade-detection-DRU7F7my.js} +1 -1
  98. package/dist/ui/assets/{voice-reply-D0FE04Jw.js → voice-reply-CnP5wEO_.js} +1 -1
  99. package/dist/ui/assets/{wc-extension-CwbvHOae.js → wc-extension-B70bdD0p.js} +2 -2
  100. package/dist/ui/assets/{wc-float-label-BhT8N0Fl.js → wc-float-label-qqb_uM9y.js} +1 -1
  101. package/dist/ui/assets/{wc-follower-DfFkmNjM.js → wc-follower-8z-K6oOv.js} +3 -3
  102. package/dist/ui/assets/wc-live-DtPpvPYm.js +41 -0
  103. package/dist/ui/assets/{wc-nav-D4I71uQu.js → wc-nav-B6RzcW_X.js} +2 -2
  104. package/dist/ui/assets/{wc-onboarding-UrMxL1c-.js → wc-onboarding-CR0RV6sk.js} +2 -2
  105. package/dist/ui/assets/{wc-placeholder-zxd8RVYO.js → wc-placeholder-DBbTc5wU.js} +2 -2
  106. package/dist/ui/assets/{wc-settings-BcpEli20.js → wc-settings-BbxgKizd.js} +3 -3
  107. package/dist/ui/assets/{wc-shell-ClIw7Xp7.js → wc-shell-HRL75vOX.js} +13 -13
  108. package/dist/ui/assets/{wc-sprinkles-DmaQ6PZC.js → wc-sprinkles-DJI-9XkZ.js} +2 -2
  109. package/dist/ui/assets/{wc-tray-D8C4hzMc.js → wc-tray-DaIyyHwC.js} +2 -2
  110. package/dist/ui/assets/{wc-tray-scoops-CNqQ6-vb.js → wc-tray-scoops-bjahDti3.js} +1 -1
  111. package/dist/ui/assets/{whisper-session-SKAIZswP.js → whisper-session-Cf2gGkoR.js} +2 -2
  112. package/dist/ui/assets/{xai-grok-C4yc6t0c.js → xai-grok-B-djVuhX.js} +1 -1
  113. package/dist/ui/assets/{xai-grok-CTETAYca.js → xai-grok-LqyYZqJi.js} +1 -1
  114. package/dist/ui/index.html +12 -12
  115. package/dist/ui/packages/webapp/index.html +12 -12
  116. package/package.json +2 -2
  117. package/dist/ui/assets/fs-3kOP04jS.js +0 -2
  118. package/dist/ui/assets/fs-Boij2gPF.js +0 -1
  119. package/dist/ui/assets/provider-store-access-dlrRLglC.js +0 -1
  120. package/dist/ui/assets/proxied-fetch-5-UeqOh8.js +0 -2
  121. package/dist/ui/assets/proxied-fetch-CWqWgyRG.js +0 -1
  122. package/dist/ui/assets/secret-topology-DzxAuCnz.js +0 -1
  123. package/dist/ui/assets/slicc-version-DV1WF_eM.js +0 -1
  124. package/dist/ui/assets/wc-live-C5Y8LMGm.js +0 -41
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{n as r,t as i}from"./safe-buffer-BwTVRVVo.js";function a(e,t){if(e.byteLength>=t)return e;if(ArrayBuffer.isView(e)){let n=a(e.buffer,t);return new e.constructor(n,e.byteOffset,t)}let n=typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer;if(e.maxByteLength>t)return n?e.grow(t):e.resize(t),e;if(n){let n=new SharedArrayBuffer(t);return new Uint8Array(n).set(new Uint8Array(e)),n}try{return e.transfer(t)}catch{let n=new ArrayBuffer(t);return new Uint8Array(n).set(new Uint8Array(e)),n}}var o=class extends DataView{constructor(e,t,n){let{buffer:r,byteOffset:i,byteLength:a}=new Uint8Array(e,t,n);super(r,i,a)}};for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(o.prototype,e,{value:()=>{throw ReferenceError(`Do not use DataView methods on a BufferView.`)},writable:!1,enumerable:!1,configurable:!1});var s=class{id;_size;options;regions=[];get size(){return this._size}set size(e){if(e>=this._size){this._size=e;return}this._size=e;for(let t=this.regions.length-1;t>=0;t--){let n=this.regions[t];if(n.offset>=e){this.regions.splice(t,1);continue}let r=e-n.offset;n.data.byteLength>r&&(n.data=n.data.subarray(0,r)),n.ranges=n.ranges.filter(t=>t.start<e).map(t=>t.end>e?{start:t.start,end:e}:t)}}constructor(e,t,n,r){this.id=e,this._size=t,this.options=n,n.sparse??=!0,n.sparse||this.regions.push({offset:0,data:new Uint8Array(t),ranges:[]}),r?.set(e,this)}collect(){if(!this.options.sparse)return;let{regionGapThreshold:e=4095}=this.options;for(let t=0;t<this.regions.length-1;){let n=this.regions[t],r=this.regions[t+1];if(r.offset-(n.offset+n.data.byteLength)>e){t++;continue}n.ranges.push(...r.ranges),n.ranges.sort((e,t)=>e.start-t.start),n.ranges=n.ranges.reduce((e,t)=>(!e.length||e.at(-1).end<t.start?e.push(t):e.at(-1).end=Math.max(e.at(-1).end,t.end),e),[]),n.data=a(n.data,r.offset+r.data.byteLength),n.data.set(r.data,r.offset-n.offset),this.regions.splice(t+1,1)}}missing(e,t){let n=[];for(let r of this.regions){if(r.offset>=t)break;for(let i of r.ranges)if(!(i.end<=e)&&(i.start>=t||(i.start>e&&n.push({start:e,end:Math.min(i.start,t)}),i.end>e&&(e=Math.max(e,i.end)),e>=t)))break;if(e>=t)break}return e<t&&n.push({start:e,end:t}),n}cached(e,t){let n=[];for(let r of this.regions){if(r.offset>=t)break;for(let i of r.ranges)if(!(i.end<=e)){if(i.start>=t)break;n.push({start:Math.max(e,i.start),end:Math.min(t,i.end)})}}n.sort((e,t)=>e.start-t.start);let r=[];for(let e of n){let t=r.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):r.push(e)}return r}regionAt(e){if(this.regions.length)for(let t of this.regions){if(t.offset>e)break;if(e>=t.offset&&e<t.offset+t.data.byteLength)return t}}add(e,t){let n=t+e.byteLength,r=this.regionAt(t);if(r)return r.data=a(r.data,n),r.data.set(e,t),r.ranges.push({start:t,end:n}),r.ranges.sort((e,t)=>e.start-t.start),this.collect(),this;let i={data:e,offset:t,ranges:[{start:t,end:n}]},o=this.regions.findIndex(e=>e.offset>t);return o==-1?this.regions.push(i):this.regions.splice(o,0,i),this.collect(),this}},c=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=t&1?2197175160^t>>>1:t>>>1;c[e]=t}function l(e){let t=4294967295;for(let n=0;n<e.length;n++)t=t>>>8^c[(t^e[n])&255];return(t^4294967295)>>>0}var u=e(n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),d=class extends u.default{[Symbol.toStringTag]=`List`;constructor(e){super(),e&&this.push(...e)}data=new Set;toSet(){return new Set(this.data)}toArray(){return Array.from(this.data)}toJSON(){return Array.from(this.data)}toString(){return this.join(`,`)}_set(e,t,n=!1){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not set an element outside the bounds of the list`);let r=Array.from(this.data);r.splice(e,+n,t),this.data=new Set(r),this.emit(`update`)}set(e,t){this._set(e,t,!0)}deleteAt(e){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not delete an element outside the bounds of the list`);this.delete(Array.from(this.data).at(e))}insert(e,t=this.data.size){this._set(t,e,!1)}at(e){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not access an element outside the bounds of the list`);return Array.from(this.data).at(e)}pop(){let e=Array.from(this.data).pop();return e!==void 0&&this.delete(e),e}push(...e){for(let t of e)this.add(t);return this.data.size}join(e){return Array.from(this.data).join(e)}splice(e,t,...n){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not splice elements outside the bounds of the list`);let r=Array.from(this.data),i=r.splice(e,t,...n);return this.data=new Set(r),this.emit(`update`),i}add(e){return this.data.add(e),this.emit(`update`),this.emit(`add`,e),this}clear(){this.data.clear(),this.emit(`update`)}delete(e){let t=this.data.delete(e);return this.emit(`update`),t}has(e){return this.data.has(e)}get size(){return this.data.size}entries(){return this.toArray().entries()}keys(){return this.toArray().keys()}values(){return this.data.values()}[Symbol.iterator](){return this.data[Symbol.iterator]()}};function f(e,t){let n=Object.entries(e);return Object.fromEntries(n.filter(([e,n])=>t(e,n)))}function p(e,...t){let n={};for(let r of t.flat())n[r]=e[r];return n}function m(e,...t){return f(e,e=>!t.flat().includes(e))}function h(e){try{return JSON.parse(e),!0}catch{return!1}}function g(e){let t=[];for(let n=e;n&&![`Function`,`Object`].includes(n.constructor.name);n=Object.getPrototypeOf(n))t.push(n.constructor.name);return t}function _(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,typeof n==`function`?n.bind(t):n]))}function v(e=Error()){let t=setTimeout(()=>{throw e},5e3);return()=>clearTimeout(t)}function y(e){throw e&&typeof e==`object`&&g(e).includes(`Error`)&&Error?.captureStackTrace(e,y),e}function b(e,t){if(![`getter`,`accessor`].includes(t.kind))throw Error(`@memoize can only be used on getters and auto-accessors`);let n=new WeakMap;function r(){if(n.has(this))return n.get(this);let t=typeof e==`function`?e.call(this):e.get.call(this);return n.set(this,t),t}switch(t.kind){case`getter`:return r;case`accessor`:return{...e,get:r}}}var x=Intl.NumberFormat(`en`,{notation:`compact`});x.format.bind(x);function S(e=0,t=1){return Math.round(Math.random()*(t-e)+e)}function C(e){return e.at(0).toUpperCase()+e.slice(1)}var w=new TextEncoder;function T(e){return w.encode(e)}var ee=new TextDecoder;function E(e){if(!e)return``;if(e.buffer instanceof ArrayBuffer&&!e.buffer.resizable)return ee.decode(e);let t=new Uint8Array(e.byteLength);return t.set(e),ee.decode(t)}function te(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function ne(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function D(e){let t=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function O(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}var k;(function(e){e[e.EPERM=1]=`EPERM`,e[e.ENOENT=2]=`ENOENT`,e[e.ESRCH=3]=`ESRCH`,e[e.EINTR=4]=`EINTR`,e[e.EIO=5]=`EIO`,e[e.ENXIO=6]=`ENXIO`,e[e.E2BIG=7]=`E2BIG`,e[e.ENOEXEC=8]=`ENOEXEC`,e[e.EBADF=9]=`EBADF`,e[e.ECHILD=10]=`ECHILD`,e[e.EAGAIN=11]=`EAGAIN`,e[e.ENOMEM=12]=`ENOMEM`,e[e.EACCES=13]=`EACCES`,e[e.EFAULT=14]=`EFAULT`,e[e.ENOTBLK=15]=`ENOTBLK`,e[e.EBUSY=16]=`EBUSY`,e[e.EEXIST=17]=`EEXIST`,e[e.EXDEV=18]=`EXDEV`,e[e.ENODEV=19]=`ENODEV`,e[e.ENOTDIR=20]=`ENOTDIR`,e[e.EISDIR=21]=`EISDIR`,e[e.EINVAL=22]=`EINVAL`,e[e.ENFILE=23]=`ENFILE`,e[e.EMFILE=24]=`EMFILE`,e[e.ETXTBSY=26]=`ETXTBSY`,e[e.EFBIG=27]=`EFBIG`,e[e.ENOSPC=28]=`ENOSPC`,e[e.ESPIPE=29]=`ESPIPE`,e[e.EROFS=30]=`EROFS`,e[e.EMLINK=31]=`EMLINK`,e[e.EPIPE=32]=`EPIPE`,e[e.EDOM=33]=`EDOM`,e[e.ERANGE=34]=`ERANGE`,e[e.EDEADLK=35]=`EDEADLK`,e[e.ENAMETOOLONG=36]=`ENAMETOOLONG`,e[e.ENOLCK=37]=`ENOLCK`,e[e.ENOSYS=38]=`ENOSYS`,e[e.ENOTEMPTY=39]=`ENOTEMPTY`,e[e.ELOOP=40]=`ELOOP`,e[e.ENOMSG=42]=`ENOMSG`,e[e.EIDRM=43]=`EIDRM`,e[e.ECHRNG=44]=`ECHRNG`,e[e.EL2NSYNC=45]=`EL2NSYNC`,e[e.EL3HLT=46]=`EL3HLT`,e[e.EL3RST=47]=`EL3RST`,e[e.ENRNG=48]=`ENRNG`,e[e.EUNATCH=49]=`EUNATCH`,e[e.ECSI=50]=`ECSI`,e[e.EL2HLT=51]=`EL2HLT`,e[e.EBADE=52]=`EBADE`,e[e.EBADR=53]=`EBADR`,e[e.EXFULL=54]=`EXFULL`,e[e.ENOANO=55]=`ENOANO`,e[e.EBADRQC=56]=`EBADRQC`,e[e.EBADSLT=57]=`EBADSLT`,e[e.EBFONT=59]=`EBFONT`,e[e.ENOSTR=60]=`ENOSTR`,e[e.ENODATA=61]=`ENODATA`,e[e.ETIME=62]=`ETIME`,e[e.ENOSR=63]=`ENOSR`,e[e.ENONET=64]=`ENONET`,e[e.ENOPKG=65]=`ENOPKG`,e[e.EREMOTE=66]=`EREMOTE`,e[e.ENOLINK=67]=`ENOLINK`,e[e.EADV=68]=`EADV`,e[e.ESRMNT=69]=`ESRMNT`,e[e.ECOMM=70]=`ECOMM`,e[e.EPROTO=71]=`EPROTO`,e[e.EMULTIHOP=72]=`EMULTIHOP`,e[e.EDOTDOT=73]=`EDOTDOT`,e[e.EBADMSG=74]=`EBADMSG`,e[e.EOVERFLOW=75]=`EOVERFLOW`,e[e.ENOTUNIQ=76]=`ENOTUNIQ`,e[e.EBADFD=77]=`EBADFD`,e[e.EREMCHG=78]=`EREMCHG`,e[e.ELIBACC=79]=`ELIBACC`,e[e.ELIBBAD=80]=`ELIBBAD`,e[e.ELIBSCN=81]=`ELIBSCN`,e[e.ELIBMAX=82]=`ELIBMAX`,e[e.ELIBEXEC=83]=`ELIBEXEC`,e[e.EILSEQ=84]=`EILSEQ`,e[e.ERESTART=85]=`ERESTART`,e[e.ESTRPIPE=86]=`ESTRPIPE`,e[e.EUSERS=87]=`EUSERS`,e[e.ENOTSOCK=88]=`ENOTSOCK`,e[e.EDESTADDRREQ=89]=`EDESTADDRREQ`,e[e.EMSGSIZE=90]=`EMSGSIZE`,e[e.EPROTOTYPE=91]=`EPROTOTYPE`,e[e.ENOPROTOOPT=92]=`ENOPROTOOPT`,e[e.EPROTONOSUPPORT=93]=`EPROTONOSUPPORT`,e[e.ESOCKTNOSUPPORT=94]=`ESOCKTNOSUPPORT`,e[e.ENOTSUP=95]=`ENOTSUP`,e[e.EPFNOSUPPORT=96]=`EPFNOSUPPORT`,e[e.EAFNOSUPPORT=97]=`EAFNOSUPPORT`,e[e.EADDRINUSE=98]=`EADDRINUSE`,e[e.EADDRNOTAVAIL=99]=`EADDRNOTAVAIL`,e[e.ENETDOWN=100]=`ENETDOWN`,e[e.ENETUNREACH=101]=`ENETUNREACH`,e[e.ENETRESET=102]=`ENETRESET`,e[e.ECONNABORTED=103]=`ECONNABORTED`,e[e.ECONNRESET=104]=`ECONNRESET`,e[e.ENOBUFS=105]=`ENOBUFS`,e[e.EISCONN=106]=`EISCONN`,e[e.ENOTCONN=107]=`ENOTCONN`,e[e.ESHUTDOWN=108]=`ESHUTDOWN`,e[e.ETOOMANYREFS=109]=`ETOOMANYREFS`,e[e.ETIMEDOUT=110]=`ETIMEDOUT`,e[e.ECONNREFUSED=111]=`ECONNREFUSED`,e[e.EHOSTDOWN=112]=`EHOSTDOWN`,e[e.EHOSTUNREACH=113]=`EHOSTUNREACH`,e[e.EALREADY=114]=`EALREADY`,e[e.EINPROGRESS=115]=`EINPROGRESS`,e[e.ESTALE=116]=`ESTALE`,e[e.EEUCLEAN=117]=`EEUCLEAN`,e[e.ENOTNAM=118]=`ENOTNAM`,e[e.ENAVAIL=119]=`ENAVAIL`,e[e.EISNAM=120]=`EISNAM`,e[e.EREMOTEIO=121]=`EREMOTEIO`,e[e.EDQUOT=122]=`EDQUOT`,e[e.ENOMEDIUM=123]=`ENOMEDIUM`,e[e.EMEDIUMTYPE=124]=`EMEDIUMTYPE`,e[e.ECANCELED=125]=`ECANCELED`,e[e.ENOKEY=126]=`ENOKEY`,e[e.EKEYEXPIRED=127]=`EKEYEXPIRED`,e[e.EKEYREVOKED=128]=`EKEYREVOKED`,e[e.EKEYREJECTED=129]=`EKEYREJECTED`,e[e.EOWNERDEAD=130]=`EOWNERDEAD`,e[e.ENOTRECOVERABLE=131]=`ENOTRECOVERABLE`,e[e.ERFKILL=132]=`ERFKILL`,e[e.EHWPOISON=133]=`EHWPOISON`})(k||={});var A={[k.EPERM]:`operation not permitted`,[k.ENOENT]:`no such file or directory`,[k.ESRCH]:`no such process`,[k.EINTR]:`interrupted system call`,[k.EIO]:`i/o error`,[k.ENXIO]:`no such device or address`,[k.E2BIG]:`argument list too long`,[k.ENOEXEC]:`exec format error`,[k.EBADF]:`bad file descriptor`,[k.ECHILD]:`no child processes`,[k.EAGAIN]:`resource temporarily unavailable`,[k.ENOMEM]:`not enough memory`,[k.EACCES]:`permission denied`,[k.EFAULT]:`bad address in system call argument`,[k.ENOTBLK]:`block device required`,[k.EBUSY]:`resource busy or locked`,[k.EEXIST]:`file already exists`,[k.EXDEV]:`cross-device link not permitted`,[k.ENODEV]:`no such device`,[k.ENOTDIR]:`not a directory`,[k.EISDIR]:`illegal operation on a directory`,[k.EINVAL]:`invalid argument`,[k.ENFILE]:`file table overflow`,[k.EMFILE]:`too many open files`,[k.ETXTBSY]:`text file is busy`,[k.EFBIG]:`file too large`,[k.ENOSPC]:`no space left on device`,[k.ESPIPE]:`invalid seek`,[k.EROFS]:`read-only file system`,[k.EMLINK]:`too many links`,[k.EPIPE]:`broken pipe`,[k.EDOM]:`numerical argument out of domain`,[k.ERANGE]:`result too large`,[k.EDEADLK]:`resource deadlock would occur`,[k.ENAMETOOLONG]:`name too long`,[k.ENOLCK]:`no locks available`,[k.ENOSYS]:`function not implemented`,[k.ENOTEMPTY]:`directory not empty`,[k.ELOOP]:`too many symbolic links encountered`,[k.ENOMSG]:`no message of desired type`,[k.EIDRM]:`identifier removed`,[k.ECHRNG]:`channel number out of range`,[k.EL2NSYNC]:`level 2 not synchronized`,[k.EL3HLT]:`level 3 halted`,[k.EL3RST]:`level 3 reset`,[k.ENRNG]:`link number out of range`,[k.EUNATCH]:`protocol driver not attached`,[k.ECSI]:`no CSI structure available`,[k.EL2HLT]:`level 2 halted`,[k.EBADE]:`invalid exchange`,[k.EBADR]:`invalid request descriptor`,[k.EXFULL]:`exchange full`,[k.ENOANO]:`no anode`,[k.EBADRQC]:`invalid request code`,[k.EBADSLT]:`invalid slot`,[k.EBFONT]:`bad font file format`,[k.ENOSTR]:`device not a stream`,[k.ENODATA]:`no data available`,[k.ETIME]:`timer expired`,[k.ENOSR]:`out of streams resources`,[k.ENONET]:`machine is not on the network`,[k.ENOPKG]:`package not installed`,[k.EREMOTE]:`object is remote`,[k.ENOLINK]:`link has been severed`,[k.EADV]:`advertise error`,[k.ESRMNT]:`srmount error`,[k.ECOMM]:`communication error on send`,[k.EPROTO]:`protocol error`,[k.EMULTIHOP]:`multihop attempted`,[k.EDOTDOT]:`rFS specific error`,[k.EBADMSG]:`bad message`,[k.EOVERFLOW]:`value too large for defined data type`,[k.ENOTUNIQ]:`name not unique on network`,[k.EBADFD]:`file descriptor in bad state`,[k.EREMCHG]:`remote address changed`,[k.ELIBACC]:`can not access a needed shared library`,[k.ELIBBAD]:`accessing a corrupted shared library`,[k.ELIBSCN]:`.lib section in a.out corrupted`,[k.ELIBMAX]:`attempting to link in too many shared libraries`,[k.ELIBEXEC]:`cannot exec a shared library directly`,[k.EILSEQ]:`illegal byte sequence`,[k.ERESTART]:`interrupted system call should be restarted`,[k.ESTRPIPE]:`streams pipe error`,[k.EUSERS]:`too many users`,[k.ENOTSOCK]:`socket operation on non-socket`,[k.EDESTADDRREQ]:`destination address required`,[k.EMSGSIZE]:`message too long`,[k.EPROTOTYPE]:`protocol wrong type for socket`,[k.ENOPROTOOPT]:`protocol not available`,[k.EPROTONOSUPPORT]:`protocol not supported`,[k.ESOCKTNOSUPPORT]:`socket type not supported`,[k.ENOTSUP]:`operation not supported on socket`,[k.EPFNOSUPPORT]:`protocol family not supported`,[k.EAFNOSUPPORT]:`address family not supported`,[k.EADDRINUSE]:`address already in use`,[k.EADDRNOTAVAIL]:`address not available`,[k.ENETDOWN]:`network is down`,[k.ENETUNREACH]:`network is unreachable`,[k.ENETRESET]:`network dropped connection on reset`,[k.ECONNABORTED]:`software caused connection abort`,[k.ECONNRESET]:`connection reset by peer`,[k.ENOBUFS]:`no buffer space available`,[k.EISCONN]:`socket is already connected`,[k.ENOTCONN]:`socket is not connected`,[k.ESHUTDOWN]:`cannot send after transport endpoint shutdown`,[k.ETOOMANYREFS]:`too many references: cannot splice`,[k.ETIMEDOUT]:`connection timed out`,[k.ECONNREFUSED]:`connection refused`,[k.EHOSTDOWN]:`host is down`,[k.EHOSTUNREACH]:`host is unreachable`,[k.EALREADY]:`connection already in progress`,[k.EINPROGRESS]:`operation now in progress`,[k.ESTALE]:`stale file handle`,[k.EEUCLEAN]:`structure needs cleaning`,[k.ENOTNAM]:`not a XENIX named type file`,[k.ENAVAIL]:`no XENIX semaphores available`,[k.EISNAM]:`is a named type file`,[k.EREMOTEIO]:`remote I/O error`,[k.EDQUOT]:`disk quota exceeded`,[k.ENOMEDIUM]:`no medium found`,[k.EMEDIUMTYPE]:`wrong medium type`,[k.ECANCELED]:`operation canceled`,[k.ENOKEY]:`required key not available`,[k.EKEYEXPIRED]:`key has expired`,[k.EKEYREVOKED]:`key has been revoked`,[k.EKEYREJECTED]:`key was rejected by service`,[k.EOWNERDEAD]:`owner died`,[k.ENOTRECOVERABLE]:`state not recoverable`,[k.ERFKILL]:`operation not possible due to RF-kill`,[k.EHWPOISON]:`memory page has hardware error`};function j(e){let t=`${e.code}: ${A[e.errno]}, ${e.syscall}`;e.path&&(t+=` '${e.path}'`),e.dest&&(t+=` -> '${e.dest}'`);let n=e.message.startsWith(A[e.errno])||/^E[A-Z0-9]+: /.test(e.message);return e.message&&!n&&(t+=` (${e.message})`),e.message=t,e}var M=class e extends Error{errno;code;path;dest;syscall;constructor(e,t,n={}){let r=k[e];super(t||``),this.errno=e,this.code=r,Object.assign(this,m(n,`message`)),t||j(this),Error.captureStackTrace?.(this,this.constructor)}toString(){return this.message}toJSON(){let e={errno:this.errno,code:this.code,stack:this.stack,message:this.message};return this.path&&(e.path=this.path),this.dest&&(e.dest=this.dest),this.syscall&&(e.syscall=this.syscall),e}static fromJSON(t){let n=t.syscall?new e(t.errno,!1,t):new e(t.errno,t.message);return n.stack=t.stack,n}};function N(e,t,n,r){typeof t==`string`&&(t={syscall:t,path:n,dest:r});let i=new M(k[e],!1,t??{});return Error.captureStackTrace?.(i,N),i}function P(e,t){let n=new M(k[e],t??A[k[e]]);return Error.captureStackTrace?.(n,P),n}function F(e,t,n){let r=typeof e==`string`?{syscall:e}:e;return t&&(r.path=t),n&&(r.dest=n),function(e){throw Object.assign(e,r),j(e),e}}var re=t({Level:()=>I,alert:()=>ue,configure:()=>De,crit:()=>de,debug:()=>me,deprecated:()=>he,emerg:()=>le,entries:()=>oe,err:()=>L,fancy:()=>be,format:()=>z,info:()=>pe,isEnabled:()=>Ee,levelOf:()=>ae,levels:()=>ie,log:()=>se,notice:()=>fe,warn:()=>R}),I;(function(e){e[e.EMERG=0]=`EMERG`,e[e.ALERT=1]=`ALERT`,e[e.CRIT=2]=`CRIT`,e[e.ERR=3]=`ERR`,e[e.WARN=4]=`WARN`,e[e.NOTICE=5]=`NOTICE`,e[e.INFO=6]=`INFO`,e[e.DEBUG=7]=`DEBUG`})(I||={});var ie=[`emergency`,`alert`,`critical`,`error`,`warning`,`notice`,`info`,`debug`];function ae(e){return ie.indexOf(e)}var oe=new d;function se(e,t){if(!Ee)return;let n={level:e,message:t,timestamp:new Date,elapsedMs:performance.now()};if(oe.size>=1e4){let e=oe.values().next().value;e!==void 0&&oe.delete(e)}oe.add(n),Ce(n)}function ce(e){return function(t){return se(e,t.toString()),t}}var le=ce(I.EMERG),ue=ce(I.ALERT),de=ce(I.CRIT),L=ce(I.ERR),R=ce(I.WARN),fe=ce(I.NOTICE),pe=ce(I.INFO),me=ce(I.DEBUG);function he(e){se(I.WARN,e+` is deprecated and should not be used.`)}function ge(e,t){return`\x1b[${t}m${e}\x1b[0m`}function _e(e){return`[`+(e.elapsedMs/1e3).toFixed(3).padStart(10)+`] `}var ve={ansi:{[I.EMERG]:`1;4;37;41`,[I.ALERT]:`1;37;41`,[I.CRIT]:`1;35`,[I.ERR]:`1;31`,[I.WARN]:`1;33`,[I.NOTICE]:`1;36`,[I.INFO]:`1;37`,[I.DEBUG]:`0;2;37`},css:{[I.EMERG]:`font-weight: bold; text-decoration: underline; color: white; background-color: red;`,[I.ALERT]:`font-weight: bold; color: white; background-color: red;`,[I.CRIT]:`font-weight: bold; color: magenta;`,[I.ERR]:`font-weight: bold; color: red;`,[I.WARN]:`font-weight: bold; color: yellow;`,[I.NOTICE]:`font-weight: bold; color: cyan;`,[I.INFO]:`font-weight: bold; color: white;`,[I.DEBUG]:`opacity: 0.8; color: white;`}},ye={ansi:{[I.EMERG]:`1;31`,[I.ALERT]:`1;31`,[I.CRIT]:`1;31`,[I.ERR]:`31`,[I.WARN]:`33`,[I.NOTICE]:`1;37`,[I.INFO]:`37`,[I.DEBUG]:`2;37`},css:{[I.EMERG]:`font-weight: bold; color: red;`,[I.ALERT]:`font-weight: bold; color: red;`,[I.CRIT]:`font-weight: bold; color: red;`,[I.ERR]:`color: red;`,[I.WARN]:`color: yellow;`,[I.NOTICE]:`font-weight: bold; color: white;`,[I.INFO]:`color: white;`,[I.DEBUG]:`opacity: 0.8; color: white;`}};function be({style:e,colorize:t}){return function*(n){e==`css`&&(yield t==`level`?`%c%s %c%s`:`%c%s %c%s%s %c%s`),yield*e==`ansi`?[ge(_e(n),`2;37`)]:[`opacity: 0.8; color: white;`,_e(n)];let r=e==`ansi`?[ge(ie[n.level].toUpperCase(),ve.ansi[n.level])]:[ve.css[n.level],ie[n.level].toUpperCase()];if(t==`level`){yield*r,yield n.message;return}n.level<I.CRIT&&(yield*r),e==`ansi`?yield ge(n.message,ye.ansi[n.level]):yield*[ye.css[n.level],n.message]}}var xe=e=>[_e(e),e.message];function z(e){let t=xe(e);return typeof t==`string`?[t]:Array.from(t)}var Se=console.error;function Ce(e){e.level>we||Se(...z(e))}var we=I.ALERT,Te=!1,Ee=!0;function De(e){if(xe=e.format??xe,Se=e.output??Se,we=typeof e.level==`string`?ae(e.level):e.level??we,Ee=e.enabled??Ee,Te=e.stack??Te,e.dumpBacklog)for(let e of oe)Ce(e)}function Oe(e){return typeof e==`object`&&!!e&&`create`in e&&typeof e.create==`function`}function ke(e,t){return Object.defineProperty(t,"prototype",{value:void 0}),e&&Object.defineProperty(t,"name",{value:e}),t}function Ae(e){return!(e&&e.constructor===Function)||e.prototype===void 0?!1:Function.prototype!==Object.getPrototypeOf(e)||Object.getOwnPropertyNames(e.prototype).length>1}function je(e,t){if(typeof t!=`object`||!t)throw L(P(`EINVAL`,`Invalid options`));for(let[n,r]of Object.entries(e.options)){let e=t?.[n];if(e==null){if(!r.required){me(`Using default for option: `+n);continue}throw L(P(`EINVAL`,`Missing required option: `+n))}let i=(t,n=e)=>typeof t==`function`?Ae(t)?e instanceof t:t(e):typeof e===t||e?.constructor?.name===t;if(Array.isArray(r.type)?r.type.some(e=>i(e)):i(r.type))continue;let a=typeof e==`object`&&`constructor`in e?e.constructor.name:typeof e,o=e=>typeof e==`function`?e.name==`type`?e.toString():e.name:e;throw L(P(`EINVAL`,`Incorrect type for "${n}": ${a} (expected ${Array.isArray(r.type)?`one of ${r.type.map(o).join(`, `)}`:o(r.type)})`))}}function Me(e){return typeof e==`object`&&!!e&&`backend`in e&&Oe(e.backend)}function Ne(e){return{suid:e.uid,sgid:e.gid,euid:e.uid,egid:e.gid,groups:[],...e}}function Pe(e){return e?!e.uid||!e.gid||!e.euid||!e.egid||e.groups.some(e=>!e):!1}var Fe=Symbol(`ZenFSContext`),Ie={[Fe]:!0,id:0,root:`/`,pwd:`/`,credentials:Ne({uid:0,gid:0}),descriptors:new Map,parent:null,children:[]};function Le(e){return typeof e==`object`&&e&&Fe in e?e:Ie}var Re=1;function ze(e,t={}){let{root:n=e.root,pwd:r=e.pwd,credentials:i=structuredClone(e.credentials)}=t,a={[Fe]:!0,id:Re++,root:n,pwd:r,credentials:Ne(i),descriptors:new Map,parent:e,children:[]};return Object.defineProperties(a,{id:{configurable:!1,writable:!1},credentials:{configurable:!1,writable:!1},descriptors:{configurable:!1,writable:!1},parent:{configurable:!1,writable:!1},children:{configurable:!1,writable:!1}}),a}var Be=t({COPYFILE_EXCL:()=>1,COPYFILE_FICLONE:()=>2,COPYFILE_FICLONE_FORCE:()=>4,F_OK:()=>0,O_APPEND:()=>Ve,O_CREAT:()=>64,O_DIRECT:()=>Je,O_DIRECTORY:()=>He,O_DSYNC:()=>Ke,O_EXCL:()=>128,O_NOATIME:()=>Ue,O_NOCTTY:()=>256,O_NOFOLLOW:()=>We,O_NONBLOCK:()=>Ye,O_RDONLY:()=>0,O_RDWR:()=>2,O_SYMLINK:()=>qe,O_SYNC:()=>Ge,O_TRUNC:()=>512,O_WRONLY:()=>1,R_OK:()=>4,S_IFBLK:()=>et,S_IFCHR:()=>nt,S_IFDIR:()=>tt,S_IFIFO:()=>rt,S_IFLNK:()=>Qe,S_IFMT:()=>Xe,S_IFREG:()=>$e,S_IFSOCK:()=>Ze,S_IRGRP:()=>32,S_IROTH:()=>4,S_IRUSR:()=>256,S_IRWXG:()=>56,S_IRWXO:()=>7,S_IRWXU:()=>448,S_ISGID:()=>at,S_ISUID:()=>it,S_ISVTX:()=>512,S_IWGRP:()=>16,S_IWOTH:()=>2,S_IWUSR:()=>128,S_IXGRP:()=>8,S_IXOTH:()=>1,S_IXUSR:()=>64,UV_FS_O_FILEMAP:()=>0,W_OK:()=>2,X_OK:()=>1,size_max:()=>ot}),Ve=1024,He=65536,Ue=262144,We=131072,Ge=1052672,Ke=4096,qe=32768,Je=16384,Ye=2048,Xe=61440,Ze=49152,Qe=40960,$e=32768,et=24576,tt=16384,nt=8192,rt=4096,it=2048,at=1024,ot=4294967295;function st(e){return`__isArrayType`in e&&e.__isArrayType===!0}function ct(e){return typeof e!=`object`&&typeof e!=`function`||e==null?!1:st(e)?ct(e.type):`name`in e&&`size`in e&&`get`in e&&`set`in e&&typeof e.name==`string`&&typeof e.size==`number`&&typeof e.get==`function`&&typeof e.set==`function`&&lt.has(e.name)&&lt.get(e.name)?.name===e.name}var lt=new Map;function ut(e){if(lt.has(e.name))throw ReferenceError(`Type is already registered: ${e.name}`);lt.set(e.name,e)}var dt=Symbol(`DataView`);function ft(e){return e[dt]??=new DataView(e),e[dt]}var pt={name:`int8`,size:1,array:Int8Array,get:(e,t)=>ft(e).getInt8(t),set:(e,t,n)=>ft(e).setInt8(t,n)},mt={name:`uint8`,size:1,array:Uint8Array,get:(e,t)=>ft(e).getUint8(t),set:(e,t,n)=>ft(e).setUint8(t,n)},ht={int8:pt,uint8:mt,int16:{name:`int16`,size:2,array:Int16Array,get:(e,t)=>ft(e).getInt16(t,!0),set:(e,t,n)=>ft(e).setInt16(t,n,!0)},uint16:{name:`uint16`,size:2,array:Uint16Array,get:(e,t)=>ft(e).getUint16(t,!0),set:(e,t,n)=>ft(e).setUint16(t,n,!0)},int32:{name:`int32`,size:4,array:Int32Array,get:(e,t)=>ft(e).getInt32(t,!0),set:(e,t,n)=>ft(e).setInt32(t,n,!0)},uint32:{name:`uint32`,size:4,array:Uint32Array,get:(e,t)=>ft(e).getUint32(t,!0),set:(e,t,n)=>ft(e).setUint32(t,n,!0)},int64:{name:`int64`,size:8,array:BigInt64Array,get:(e,t)=>ft(e).getBigInt64(t,!0),set:(e,t,n)=>ft(e).setBigInt64(t,n,!0)},uint64:{name:`uint64`,size:8,array:BigUint64Array,get:(e,t)=>ft(e).getBigUint64(t,!0),set:(e,t,n)=>ft(e).setBigUint64(t,n,!0)},float32:{name:`float32`,size:4,array:Float32Array,get:(e,t)=>ft(e).getFloat32(t,!0),set:(e,t,n)=>ft(e).setFloat32(t,n,!0)},float64:{name:`float64`,size:8,array:Float64Array,get:(e,t)=>ft(e).getFloat64(t,!0),set:(e,t,n)=>ft(e).setFloat64(t,n,!0)}},gt=Object.keys(ht);for(let e of Object.values(ht))ut(e);var _t={...ht,...Object.fromEntries(gt.map(e=>[C(e),ht[e]])),char:mt},vt=Object.keys(_t);function yt(e){return vt.includes(e.toString())}function bt(e){if(!yt(e))throw P(`EINVAL`,`Not a valid primitive type: `+e)}function xt(e){return e==`char`?`uint8`:e.toLowerCase()}function St(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&`toInit`in e&&typeof e.toInit==`function`}function Ct(e){return St(e)?e.toInit():ct(e)?{type:e}:e}function wt(e,t,n={}){if(!e)throw P(`EINVAL`,`Invalid name for struct field`);typeof e==`symbol`&&console.warn(`Symbol used for struct field name will be coerced to string: `+e.toString());let r=e.toString(),i=Object.assign(Ct(t),n);if(!ct(i.type))throw P(`EINVAL`,`Invalid type for struct field "${r}"`);let a=i.countedBy?` counted_by(${typeof i.countedBy==`string`?i.countedBy:`<function>`})`:``;return{name:r,offset:0,type:i.type,countedBy:i.countedBy,alignment:i.align??i.type.size,decl:i.type instanceof Bt?`${i.typeName??i.type.type.name} ${r}[${i.type.length}]${a}`:`${i.typeName??i.type.name} ${r}`,littleEndian:!i.bigEndian}}function Tt(e,t){if(!(e instanceof Error)||e.message.toLowerCase()!==`offset is outside the bounds of the dataview`)throw e;let n=P(`EFAULT`,`Segmentation fault (at 0x${t.toString(16)})`);throw Error.captureStackTrace(n,Tt),n}function Et(e,t){return t.type instanceof Bt&&t.type.length==0&&!!t.countedBy?.length&&!!e.constructor.isDynamic}function Dt(e,t){let n=typeof t.countedBy==`function`?t.countedBy(e):e[t.countedBy];if(typeof n==`bigint`){if(n>BigInt(2**53-1))throw P(`EOVERFLOW`,`countedBy field value exceeds max safe integer`);n=Number(n)}if(typeof n!=`number`)throw P(`EINVAL`,`countedBy field value is not a number`);return n}function Ot(e,t){let n=t.type.type.size*Dt(e,t);if(Pt(t.type.type)&&t.type.type.isDynamic)for(let r of e[t.name])n+=Ft(r);return n}var kt=Symbol(`kOffsets`);function At(e,t,n){let{offset:r,name:i}=t;e[kt]||=Object.create(null);let a=e[kt];if(a[i]!==void 0){if(n)return a[i];delete a[i]}let{fields:o}=e.constructor,s=o.indexOf(t);for(let t of o.slice(0,s)){Et(e,t)&&(r+=Ot(e,t));let n=e[t.name];Nt(n)&&n.constructor.isDynamic&&(r+=Ft(n))}if(n)a[i]=r;else for(let e of o.slice(s))a[e.name]!==void 0&&delete a[e.name];return r}function jt(e,t,n,r){typeof n==`string`&&(n=n.charCodeAt(0));let i=e.byteOffset+At(e,t,!1)+(r??0)*t.type.size;try{t.type.set(e.buffer,i,n);return}catch(e){Tt(e,i)}}function Mt(e,t){let n=t.type;if(Et(e,t)){let r=t.type.type;n=new Bt(r,Dt(e,t))}let r=e.byteOffset+At(e,t,!0);try{return n.get(e.buffer,r)}catch(e){Tt(e,r)}}function Nt(e){return typeof e==`object`&&!!e&&`constructor`in e&&Pt(e.constructor)}function Pt(e){return typeof e==`function`&&`prototype`in e&&`fields`in e&&typeof e.fields==`object`&&ct(e)}function Ft(e){let t=0;for(let n of e.constructor.fields){let r=e[n.name];Et(e,n)&&(t+=Ot(e,n)),Nt(r)&&r.constructor.isDynamic&&(t+=Ft(r))}return t}function It(e){if(ct(e))return e.size;if(e==null)return 0;if(typeof e==`object`&&ct(e.constructor))return e.constructor.size;if(Array.isArray(e)){let t=0;for(let n=0;n<e.length;n++)t+=It(e[n]);return t}if(typeof e==`string`)return bt(e),ht[xt(e)].size;throw TypeError(`Unable to resolve size of \`${e.toString()}\``)}function B(e){let t=It(e);return Nt(e)&&e.constructor.isDynamic?t+Ft(e):t}function Lt(e,t){let n;if(Pt(e)){if(e.isDynamic)throw P(`EINVAL`,`Cannot get offset of field in dynamic struct from the constructor`);n=e}else if(Nt(e))n=e.constructor;else throw P(`EINVAL`,`Type is not a struct or struct constructor`);let{fields:r}=n,i=r.find(e=>e.name===t);if(!i)throw P(`EINVAL`,`Struct does not have field: `+t);return Pt(e)?i.offset:At(e,i,!0)}function Rt(e,t){class n extends DataView{length;type=e;*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this[e]}_offsets=[0];offsetOf(t){if(!e.isDynamic)return t*e.size;if(t<this._offsets.length)return this._offsets[t];for(let n=this._offsets.length;n<=t;n++)this._offsets[n]=this._offsets[n-1]+B(e.get(this.buffer,this.byteOffset+this._offsets[n-1]));return this._offsets[t]}constructor(n,r,i){let a=typeof n==`object`?n:new ArrayBuffer((n??0)*e.size);super(a,r,i),this.length=typeof n==`number`?n:e.isDynamic?t??y(`Unknown length of StructArray<${e.name}>`):Math.floor(this.byteLength/e.size);let o=e=>this.byteOffset+this.offsetOf(e);return new Proxy(this,{get(t,n){if(n in t)return t[n];let r=parseInt(n.toString());if(Number.isSafeInteger(r))return e.get(t.buffer,o(r))},set(t,n,r){let i=parseInt(n.toString());return Number.isSafeInteger(i)?(e.set(t.buffer,o(i),r),!0):!1}})}}for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(n.prototype,e,{enumerable:!1,configurable:!1,writable:!1,value:void 0});return n}function zt(e){return typeof e==`function`&&`prototype`in e&&`fields`in e&&typeof e.fields==`object`&&ct(e)}var Bt=class{type;length;name;size;__structArray;__arrayType;__isArrayType=!0;constructor(e,t){this.type=e,this.length=t,this.name=`${e.name}[${t}]`,this.size=e.size*t,this.array=Rt(this),this.__structArray=Rt(e,t),this.__arrayType=e.array?e.array:this.__structArray}get=(e,t)=>yt(this.type.name)&&t%this.type.size!==0?new this.__structArray(e,t,this.size):new this.__arrayType(e,t,this.size);set=(e,t,n)=>{if(this.length)for(let r=0;r<this.length;r++)this.type.set(e,t+r*this.type.size,n[r]);else{let r=t;for(let t=0;t<n.length;t++)this.type.set(e,r,n[t]),r+=zt(this.type)&&this.type.isDynamic?B(n[t]):this.type.size}};array};Symbol.metadata??=Symbol.for(`Symbol.metadata`);function Vt(e){e.metadata??={};let t=e.metadata.structInit??{};return e.metadata.structInit={fields:[...t.fields??[]]},e.metadata.structInit}function Ht(...e){let t=e.reduce((e,t)=>({...e,...t}),{});return typeof this==`object`&&Object.assign(t,this),function(e,n){let r=Vt(n),i=1,a=[],o=0,s=e=>{o=Math.ceil(o/e)*e};for(let e of r.fields)t.isPacked||s(e.alignment),t.isUnion?o=Math.max(o,e.type.size):(e.offset=o,o+=e.type.size),a.push(e),i=Math.max(i,e.alignment);t.alignment??=i,t.isPacked||s(t.alignment);class c extends e{static name=e.name;static size=o;static alignment=t.alignment;static isUnion=!!t.isUnion;static isDynamic=!!t.isDynamic;static fields=a;static get(e,t){return new this(e,t)}static set(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,this.size),i=new Uint8Array(e,t,this.size);if(n.buffer!==e||n.byteOffset!==t)for(let e=0;e<this.size;e++)i[e]=r[e]}static[Symbol.toStringTag]=`[struct ${e.name}]`;constructor(...e){e.length||(e=[new ArrayBuffer(o),0,o]),super(...e);for(let e of Object.values(a))Object.defineProperty(this,e.name,{enumerable:!0,configurable:!0,get(){return Mt(this,e)},set(t){jt(this,e,t)}})}}return n.addInitializer(function(){Object.defineProperty(c,"name",{value:e.name}),ut(c)}),c}}Ht.packed=Ht.bind({isPacked:!0}),Ht.align=function(e){return Ht.bind({alignment:e})};function Ut(e,t={}){return function(n,r){if(r.kind!=`accessor`)throw P(`EINVAL`,`Field must be an accessor`);let i=Vt(r),a=wt(r.name,e,t);return i.fields.push(a),{get(){return Mt(this,a)},set(e){jt(this,a,e)}}}}function Wt(e){let t=ht[xt(e)];function n(n,r){return typeof n==`number`?Ut(new Bt(t,n),{typeName:e,...r}):Ut(t,{typeName:e})(n,r&&`name`in r?r:y(P(`EINVAL`,`Invalid decorator context object`)))}return n}var V=Object.fromEntries(vt.map(e=>[e,Wt(e)]));function Gt(e){return e}Gt.typed=function(e){return e};var Kt=class e{type;init;constructor(t,n){this.type=t,this.init=n;let r=(r=>new e(new Bt(t,r),n));return Object.setPrototypeOf(r,new.target.prototype),Object.assign(r,{type:t,init:n}),r}align(t){return new e(this.type,{...this.init,align:t})}countedBy(t){return new e(this.type,{...this.init,countedBy:t})}bigEndian(){return new e(this.type,{...this.init,bigEndian:!0})}toInit(){return{type:this.type,...this.init}}$type(){return new e(this.type,this.init)}};function qt(e,t=0){return new Kt(new Bt(e,t),{})}function Jt(e,t,...n){let r=n.reduce((e,t)=>({...e,...t}),{});typeof this==`object`&&Object.assign(r,this);let i=1,a=0,o=e=>{a=Math.ceil(a/e)*e},s=[];for(let[e,n]of Object.entries(t)){if(typeof e==`number`)throw TypeError(`Field names can not be numbers`);let t=wt(e,n);r.isPacked||o(t.alignment),r.isUnion?a=Math.max(a,t.type.size):(t.offset=a,a+=t.type.size),s.push(t),i=Math.max(i,t.alignment)}r.alignment??=i,r.isPacked||o(r.alignment);class c extends DataView{static name=e;static size=a;static alignment=r.alignment;static isUnion=!!r.isUnion;static isDynamic=!!r.isDynamic;static fields=s;static get(e,t){return new this(e,t)}static set(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,this.size),i=new Uint8Array(e,t,this.size);if(n.buffer!==e||n.byteOffset!==t)for(let e=0;e<this.size;e++)i[e]=r[e]}static[Symbol.toStringTag]=`[struct ${e}]`;constructor(e=new ArrayBuffer(a),t,n){super(e,t,n??e.byteLength-(t??0));for(let e of Object.values(this.constructor.fields??s))Object.defineProperty(this,e.name,{enumerable:!0,configurable:!0,get(){return Mt(this,e)},set(t){jt(this,e,t)}})}}for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(c.prototype,e,{enumerable:!1,configurable:!1,writable:!1,value:void 0});return ut(c),c}Jt.extend=function(e,t,n,...r){let i=r.reduce((e,t)=>({...e,...t}),{});typeof this==`object`&&Object.assign(i,this);let a=1,o=e.size,s=e=>{o=Math.ceil(o/e)*e},c=e.fields;for(let[e,t]of Object.entries(n)){if(typeof e==`number`)throw TypeError(`Field names can not be numbers`);let n=wt(e,t);i.isPacked||s(n.alignment),i.isUnion?o=Math.max(o,n.type.size):(n.offset=o,o+=n.type.size),c.push(n),a=Math.max(a,n.alignment)}i.alignment??=a,i.isPacked||s(i.alignment);class l extends e{static name=t;static size=o;static alignment=i.alignment;static isUnion=!!i.isUnion;static isDynamic=!!i.isDynamic;static fields=c;static[Symbol.toStringTag]=`[struct ${t}]`}return ut(l),l},Jt.packed=Jt.bind({isPacked:!0}),Jt.align=function(e){return Jt.bind({alignment:e})},Jt.dynamic=Jt.bind({isDynamic:!0}),Object.fromEntries(Object.entries(_t).map(([e,t])=>[e,new Kt(t,{typeName:e})]));function Yt(e){return JSON.parse(E(e),(e,t)=>e==``?t:typeof t==`string`?BigInt(t).toString(16).slice(0,Math.min(t.length,8)):t)}function Xt(e){return T(JSON.stringify(e))}function Zt(e,t){if(typeof e==`number`)return e;if(typeof e==`string`){let t=parseInt(e,8);if(!isNaN(t))return t}if(typeof t==`number`)return t;throw P(`EINVAL`,`Invalid mode: `+e?.toString())}var Qt=2147483647;function $t(e){if(!(Number.isInteger(e)&&e>=0&&e<=Qt))throw Object.assign(RangeError(`The value of "fd" is out of range. It must be >= 0 && <= ${Qt}. Received ${e}`),{code:`ERR_OUT_OF_RANGE`})}function en(e){if(e instanceof Date)return e.getTime();let t=Number(e);if(!Number.isFinite(t))throw P(`EINVAL`,`Invalid time.`);return t<0?Date.now():t*1e3}function H(e,t=!1){if(e instanceof URL){if(e.protocol!=`file:`)throw P(`EINVAL`,`URLs must use the file: protocol`);e=e.pathname}if(e=e.toString(),e.startsWith(`file://`)&&(e=e.slice(7)),e.includes(`\0`))throw P(`EINVAL`,`Path can not contain null character`);if(e.length==0)throw P(`EINVAL`,`Path can not be empty`);return e=e.replaceAll(/[/\\]+/g,`/`),t?e:un.call(this,e)}function tn(e,t=`utf8`,n,r=0){return typeof e!=`object`||!e?{encoding:typeof e==`string`?e:t??null,flag:n,mode:r}:{encoding:typeof e?.encoding==`string`?e.encoding:t??null,flag:typeof e?.flag==`string`?e.flag:n,mode:Zt(`mode`in e?e?.mode:null,r)}}function nn(e){let t=`\0GS\0`;return e=e.replace(/\*\*/g,t).replace(/\*/g,`\0S\0`).replace(/[.+^$(){}|[\]\\]/g,`\\$&`).replace(/\?/g,`.`).replaceAll(`/\0GS\0/`,`(?:/.*)?/`).replaceAll(t,`.*`).replaceAll(`\0S\0`,`[^/]*`),RegExp(`^${e}$`)}async function rn(e){let t=Promise.withResolvers();setTimeout(()=>t.reject(P(`ETIMEDOUT`)),500),e.on(`online`,t.resolve),await t.promise}function an(e){return`${H(e,!0)}${Date.now()}-${Math.random().toString(36).slice(2)}`}var on=t({basename:()=>mn,dirname:()=>W,extname:()=>hn,format:()=>gn,formatExt:()=>ln,isAbsolute:()=>fn,join:()=>U,matchesGlob:()=>vn,normalize:()=>dn,normalizeString:()=>cn,parse:()=>_n,relative:()=>pn,resolve:()=>un,sep:()=>`/`});function sn(e,t){if(typeof e!=`object`)throw TypeError(`"${t}" is not an object`)}function cn(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o==`/`)break;else o=`/`;if(o==`/`){if(i!==s-1&&a!==1)if(a===2){if(n.length<2||r!==2||n.at(-1)!==`.`||n.at(-2)!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function ln(e){return e?`${e[0]===`.`?``:`.`}${e}`:``}function un(...e){let t=``;for(let n of[...e.reverse(),Le(this).pwd])if(n?.length&&(t=`${n}/${t}`,n.startsWith(`/`)))break;let n=t.startsWith(`/`);return t=cn(t,!n),n?`/${t}`:t.length?t:`/`}function dn(e){if(!e.length)return`.`;let t=e[0]===`/`,n=e.at(-1)===`/`;return e=cn(e,!t),e.length?(n&&(e+=`/`),t?`/${e}`:e):t?`/`:n?`./`:`.`}function fn(e){return e.startsWith(`/`)}function U(...e){if(!e.length)return`.`;let t=e.filter(e=>e).join(`/`);return t?.length?dn(t):`.`}function pn(e,t){if(e===t||(e=un.call(this,e),t=un.call(this,t),e===t))return``;let n=e.length,r=n-1,i=t.length-1,a=r<i?r:i,o=-1,s=0;for(;s<a;s++){let n=e[1+s];if(n!==t[1+s])break;n===`/`&&(o=s)}if(s===a)if(i>a){if(t[1+s]===`/`)return t.slice(1+s+1);if(s===0)return t.slice(1+s)}else r>a&&(e[1+s]===`/`?o=s:s===0&&(o=0));let c=``;for(s=1+o+1;s<=n;++s)(s===n||e[s]===`/`)&&(c+=c.length===0?`..`:`/..`);return`${c}${t.slice(1+o)}`}function W(e){if(e.length===0)return`.`;let t=e[0]===`/`,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e[t]===`/`){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function mn(e,t){let n=0,r=-1,i=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=0;--s)if(e[s]===`/`){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(e[s]===t[a]?--a===-1&&(r=s):(a=-1,r=o));return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}for(let t=e.length-1;t>=0;--t)if(e[t]===`/`){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}function hn(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){if(e[o]===`/`){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),e[o]===`.`?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function gn(e){sn(e,`pathObject`);let t=e.dir||e.root,n=e.base||`${e.name||``}${ln(e.ext)}`;return t?t===e.root?`${t}${n}`:`${t}/${n}`:n}function _n(e){let t=e[0]===`/`,n={root:t?`/`:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return n;let r=+!!t,i=-1,a=0,o=-1,s=!0,c=e.length-1,l=0;for(;c>=r;--c){if(e[c]===`/`){if(!s){a=c+1;break}continue}o===-1&&(s=!1,o=c+1),e[c]===`.`?i===-1?i=c:l!==1&&(l=1):i!==-1&&(l=-1)}if(o!==-1){let r=a===0&&t?1:a;i===-1||l===0||l===1&&i===o-1&&i===a+1?n.base=n.name=e.slice(r,o):(n.name=e.slice(r,i),n.base=e.slice(r,o),n.ext=e.slice(i,o))}return a>0?n.dir=e.slice(0,a-1):t&&(n.dir=`/`),n}function vn(e,t){return nn(e).test(t)}var yn=BigInt(1e3),bn=class{_convert(e){return this._isBigint?BigInt(e):Number(e)}get blocks(){return this._convert(Math.ceil(Number(this.size)/512))}set blocks(e){}mode;dev=this._convert(0);ino=this._convert(0);rdev=this._convert(0);nlink=this._convert(1);blksize=this._convert(4096);uid=this._convert(0);gid=this._convert(0);atimeMs;get atime(){return new Date(Number(this.atimeMs))}set atime(e){this.atimeMs=this._convert(e.getTime())}mtimeMs;get mtime(){return new Date(Number(this.mtimeMs))}set mtime(e){this.mtimeMs=this._convert(e.getTime())}ctimeMs;get ctime(){return new Date(Number(this.ctimeMs))}set ctime(e){this.ctimeMs=this._convert(e.getTime())}birthtimeMs;get birthtime(){return new Date(Number(this.birthtimeMs))}set birthtime(e){this.birthtimeMs=this._convert(e.getTime())}size;data;flags;version;constructor({atimeMs:e,mtimeMs:t,ctimeMs:n,birthtimeMs:r,uid:i,gid:a,size:o,mode:s,ino:c,...l}={}){let u=Date.now();this.atimeMs=this._convert(e??u),this.mtimeMs=this._convert(t??u),this.ctimeMs=this._convert(n??u),this.birthtimeMs=this._convert(r??u),this.uid=this._convert(i??0),this.gid=this._convert(a??0),this.size=this._convert(o??0),this.ino=this._convert(c??0),this.mode=this._convert(s??0),this.mode&61440||(this.mode|=this._convert($e)),Object.assign(this,l)}isFile(){return(this.mode&Xe)===$e}isDirectory(){return(this.mode&Xe)===tt}isSymbolicLink(){return(this.mode&Xe)===Qe}isSocket(){return(this.mode&Xe)===Ze}isBlockDevice(){return(this.mode&Xe)===et}isCharacterDevice(){return(this.mode&Xe)===nt}isFIFO(){return(this.mode&Xe)===rt}toJSON(){return p(this,An)}hasAccess(e,t){return J(t,this._isBigint?new xn(this):this,e)}get atimeNs(){return BigInt(this.atimeMs)*yn}get mtimeNs(){return BigInt(this.mtimeMs)*yn}get ctimeNs(){return BigInt(this.ctimeMs)*yn}get birthtimeNs(){return BigInt(this.birthtimeMs)*yn}},xn=class extends bn{_isBigint=!1},Sn=class extends bn{_isBigint=!0};function Cn(e,t){return e.size==t.size&&+e.atime==+t.atime&&+e.mtime==+t.mtime&&+e.ctime==+t.ctime&&e.mode==t.mode}var wn=class{type=525687744115;bsize=4096;blocks=0;bfree=0;bavail=0;files=ot;ffree=ot},Tn=class{type=BigInt(`0x7a656e6673`);bsize=BigInt(4096);blocks=BigInt(0);bfree=BigInt(0);bavail=BigInt(0);files=BigInt(ot);ffree=BigInt(ot)},En=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},G=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Dn=3968,On=(()=>{var e,t;let n=[Ht.packed()],r,i=[],a,o=Gt.typed(Uint8Array),s,c=[],l=[],u,d=[],f=[];var p=class extends o{static{a=this}static{let m=typeof Symbol==`function`&&Symbol.metadata?Object.create(o[Symbol.metadata]??null):void 0;s=[(e=V).uint32.bind(e)],u=[(t=V).uint32.bind(t)],En(this,null,s,{kind:`accessor`,name:`keySize`,static:!1,private:!1,access:{has:e=>`keySize`in e,get:e=>e.keySize,set:(e,t)=>{e.keySize=t}},metadata:m},c,l),En(this,null,u,{kind:`accessor`,name:`valueSize`,static:!1,private:!1,access:{has:e=>`valueSize`in e,get:e=>e.valueSize,set:(e,t)=>{e.valueSize=t}},metadata:m},d,f),En(null,r={value:a},n,{kind:`class`,name:a.name,metadata:m},null,i),p=a=r.value,m&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:m})}static name=`Attribute`;#e=G(this,c,void 0);get keySize(){return this.#e}set keySize(e){this.#e=e}#t=(G(this,l),G(this,d,void 0));get valueSize(){return this.#t}set valueSize(e){this.#t=e}get name(){return E(this.subarray(8,8+this.keySize))}set name(e){let t=T(e);if(8+t.length+this.valueSize>Dn)throw P(`EOVERFLOW`);this.set(t,8),this.keySize=t.length}get value(){return this.subarray(8+this.keySize,this.size)}set value(e){if(8+this.keySize+e.length>Dn)throw P(`EOVERFLOW`);this.valueSize=e.length,this.set(e,8+this.keySize)}get size(){return 8+this.keySize+this.valueSize}constructor(){super(...arguments),G(this,f)}static{G(a,i)}};return a})(),kn=(()=>{var e;let t=[Ht.packed()],n,r=[],i,a=Gt(o),s,c=[],l=[];var u=class extends a{static{i=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(a[Symbol.metadata]??null):void 0;s=[(e=V).uint32.bind(e)],En(this,null,s,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:o},c,l),En(null,n={value:i},t,{kind:`class`,name:i.name,metadata:o},null,r),u=i=n.value,o&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`Attributes`;#e=G(this,c,void 0);get size(){return this.#e}set size(e){this.#e=e}get byteSize(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);e+=t.size}return e}has(e){let t=this.byteOffset+B(this);for(let n=0;n<this.size;n++){let n=new On(this.buffer,t);if(n.name==e)return!0;t+=n.size}return!1}get(e){let t=this.byteOffset+B(this);for(let n=0;n<this.size;n++){let n=new On(this.buffer,t);if(n.name==e)return n.value;t+=n.size}}set(e,t){let n=this.byteOffset+B(this),r;for(let t=0;t<this.size;t++){let t=new On(this.buffer,n);t.name==e&&(r=[n,t.size]),n+=t.size}let i=new Uint8Array(this.buffer);if(r){let[e,t]=r;n-=t,i.copyWithin(e,e+t,n+t),i.fill(0,n,n+t),this.size--}let a=new On(this.buffer,n);a.name=e,a.value=t,this.size++}remove(e){let t=this.byteOffset+B(this),n;for(let r=0;r<this.size;r++){let r=new On(this.buffer,t);r.name==e&&(n=[t,r.size]),t+=r.size}if(!n)return!1;let[r,i]=n,a=new Uint8Array(this.buffer);return a.copyWithin(r,r+i,t),a.fill(0,t-i,t),this.size--,!0}copyFrom(e){let{byteSize:t}=e;new Uint8Array(this.buffer,this.byteOffset,t).set(new Uint8Array(e.buffer,e.byteOffset,t))}*keys(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield t.name,e+=t.size}}*values(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield t.value,e+=t.size}}*entries(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield[t.name,t.value],e+=t.size}}constructor(){super(...arguments),G(this,l)}static{G(i,r)}};return i})(),An=[`ino`,`data`,`size`,`mode`,`flags`,`nlink`,`uid`,`gid`,`atimeMs`,`birthtimeMs`,`mtimeMs`,`ctimeMs`,`version`],jn;(function(e){e[e.Sync=1]=`Sync`,e[e.NoAtime=2]=`NoAtime`,e[e.Append=4]=`Append`,e[e.Immutable=8]=`Immutable`,e[e.Dead=16]=`Dead`,e[e.NoQuota=32]=`NoQuota`,e[e.Dirsync=64]=`Dirsync`,e[e.NoCMtime=128]=`NoCMtime`,e[e.SwapFile=256]=`SwapFile`,e[e.Private=512]=`Private`,e[e.IMA=1024]=`IMA`,e[e.AutoMount=2048]=`AutoMount`,e[e.NoSec=4096]=`NoSec`,e[e.DAX=8192]=`DAX`,e[e.Encrypted=16384]=`Encrypted`,e[e.CaseFold=32768]=`CaseFold`,e[e.Verity=65536]=`Verity`,e[e.KernelFile=131072]=`KernelFile`})(jn||={});var Mn=253951,Nn=229631,K=(()=>{var e,t,n,r,i,a,s,c,l,u,d,f,m,h,g,_;let v=[Ht.packed()],y,b=[],x,S=Gt(o),C,w=[],T=[],ee,E=[],te=[],ne,D=[],O=[],k,A=[],j=[],M,N=[],F=[],re,I=[],ie=[],ae,oe=[],se=[],ce,le=[],ue=[],L,fe=[],pe=[],me,he=[],ge=[],_e,ve=[],ye=[],be,xe=[],z=[],Se,Ce=[],we=[],Te,Ee=[],De=[],Oe,ke=[],Ae=[],je,Me=[],Ne=[],Pe,Fe=[],Ie=[],Le,Re=[],ze=[],Be,Ve=[],He=[];var Ue=class extends S{static{x=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(S[Symbol.metadata]??null):void 0;C=[(e=V).uint32.bind(e)],ee=[(t=V).uint32.bind(t)],ne=[(n=V).uint32.bind(n)],k=[(r=V).uint16.bind(r)],M=[(i=V).uint32.bind(i)],re=[(a=V).uint32.bind(a)],ae=[(s=V).uint32.bind(s)],ce=[(c=V).float64.bind(c)],L=[(l=V).float64.bind(l)],me=[(u=V).float64.bind(u)],_e=[(d=V).float64.bind(d)],be=[(f=V).uint32.bind(f)],Se=[(m=V).uint32.bind(m)],Te=[(h=V).uint32.bind(h)],Oe=[(g=V).uint16.bind(g)],je=[(_=V).uint32.bind(_)],Pe=[V.uint8(48)],Le=[Ut(kn)],Be=[V.uint8(Dn)],En(this,null,C,{kind:`accessor`,name:`data`,static:!1,private:!1,access:{has:e=>`data`in e,get:e=>e.data,set:(e,t)=>{e.data=t}},metadata:o},w,T),En(this,null,ee,{kind:`accessor`,name:`__data_old`,static:!1,private:!1,access:{has:e=>`__data_old`in e,get:e=>e.__data_old,set:(e,t)=>{e.__data_old=t}},metadata:o},E,te),En(this,null,ne,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:o},D,O),En(this,null,k,{kind:`accessor`,name:`mode`,static:!1,private:!1,access:{has:e=>`mode`in e,get:e=>e.mode,set:(e,t)=>{e.mode=t}},metadata:o},A,j),En(this,null,M,{kind:`accessor`,name:`nlink`,static:!1,private:!1,access:{has:e=>`nlink`in e,get:e=>e.nlink,set:(e,t)=>{e.nlink=t}},metadata:o},N,F),En(this,null,re,{kind:`accessor`,name:`uid`,static:!1,private:!1,access:{has:e=>`uid`in e,get:e=>e.uid,set:(e,t)=>{e.uid=t}},metadata:o},I,ie),En(this,null,ae,{kind:`accessor`,name:`gid`,static:!1,private:!1,access:{has:e=>`gid`in e,get:e=>e.gid,set:(e,t)=>{e.gid=t}},metadata:o},oe,se),En(this,null,ce,{kind:`accessor`,name:`atimeMs`,static:!1,private:!1,access:{has:e=>`atimeMs`in e,get:e=>e.atimeMs,set:(e,t)=>{e.atimeMs=t}},metadata:o},le,ue),En(this,null,L,{kind:`accessor`,name:`birthtimeMs`,static:!1,private:!1,access:{has:e=>`birthtimeMs`in e,get:e=>e.birthtimeMs,set:(e,t)=>{e.birthtimeMs=t}},metadata:o},fe,pe),En(this,null,me,{kind:`accessor`,name:`mtimeMs`,static:!1,private:!1,access:{has:e=>`mtimeMs`in e,get:e=>e.mtimeMs,set:(e,t)=>{e.mtimeMs=t}},metadata:o},he,ge),En(this,null,_e,{kind:`accessor`,name:`ctimeMs`,static:!1,private:!1,access:{has:e=>`ctimeMs`in e,get:e=>e.ctimeMs,set:(e,t)=>{e.ctimeMs=t}},metadata:o},ve,ye),En(this,null,be,{kind:`accessor`,name:`ino`,static:!1,private:!1,access:{has:e=>`ino`in e,get:e=>e.ino,set:(e,t)=>{e.ino=t}},metadata:o},xe,z),En(this,null,Se,{kind:`accessor`,name:`__ino_old`,static:!1,private:!1,access:{has:e=>`__ino_old`in e,get:e=>e.__ino_old,set:(e,t)=>{e.__ino_old=t}},metadata:o},Ce,we),En(this,null,Te,{kind:`accessor`,name:`flags`,static:!1,private:!1,access:{has:e=>`flags`in e,get:e=>e.flags,set:(e,t)=>{e.flags=t}},metadata:o},Ee,De),En(this,null,Oe,{kind:`accessor`,name:`__after_flags`,static:!1,private:!1,access:{has:e=>`__after_flags`in e,get:e=>e.__after_flags,set:(e,t)=>{e.__after_flags=t}},metadata:o},ke,Ae),En(this,null,je,{kind:`accessor`,name:`version`,static:!1,private:!1,access:{has:e=>`version`in e,get:e=>e.version,set:(e,t)=>{e.version=t}},metadata:o},Me,Ne),En(this,null,Pe,{kind:`accessor`,name:`__padding`,static:!1,private:!1,access:{has:e=>`__padding`in e,get:e=>e.__padding,set:(e,t)=>{e.__padding=t}},metadata:o},Fe,Ie),En(this,null,Le,{kind:`accessor`,name:`attributes`,static:!1,private:!1,access:{has:e=>`attributes`in e,get:e=>e.attributes,set:(e,t)=>{e.attributes=t}},metadata:o},Re,ze),En(this,null,Be,{kind:`accessor`,name:`__data`,static:!1,private:!1,access:{has:e=>`__data`in e,get:e=>e.__data,set:(e,t)=>{e.__data=t}},metadata:o},Ve,He),En(null,y={value:x},v,{kind:`class`,name:x.name,metadata:o},null,b),Ue=x=y.value,o&&Object.defineProperty(x,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`Inode`;constructor(...e){let t={};if(typeof e[0]==`object`&&e[0]!==null&&!ArrayBuffer.isView(e[0])&&(t=e[0],e=[B(Ue)]),e[0]instanceof Ue&&(e=[new Uint8Array(e[0].buffer,e[0].byteOffset,e[0].byteLength)]),super(...e),G(this,He),this.byteLength<B(Ue))throw de(P(`EIO`,`Buffer is too small to create an inode (${this.byteLength} bytes)`));Object.assign(this,t),this.atimeMs||=Date.now(),this.mtimeMs||=Date.now(),this.ctimeMs||=Date.now(),this.birthtimeMs||=Date.now(),this.ino&&!this.nlink&&R(`Inode ${this.ino} has an nlink of 0`)}#e=G(this,w,void 0);get data(){return this.#e}set data(e){this.#e=e}#t=(G(this,T),G(this,E,void 0));get __data_old(){return this.#t}set __data_old(e){this.#t=e}#n=(G(this,te),G(this,D,void 0));get size(){return this.#n}set size(e){this.#n=e}#r=(G(this,O),G(this,A,void 0));get mode(){return this.#r}set mode(e){this.#r=e}#i=(G(this,j),G(this,N,void 0));get nlink(){return this.#i}set nlink(e){this.#i=e}#a=(G(this,F),G(this,I,void 0));get uid(){return this.#a}set uid(e){this.#a=e}#o=(G(this,ie),G(this,oe,void 0));get gid(){return this.#o}set gid(e){this.#o=e}#s=(G(this,se),G(this,le,void 0));get atimeMs(){return this.#s}set atimeMs(e){this.#s=e}#c=(G(this,ue),G(this,fe,void 0));get birthtimeMs(){return this.#c}set birthtimeMs(e){this.#c=e}#l=(G(this,pe),G(this,he,void 0));get mtimeMs(){return this.#l}set mtimeMs(e){this.#l=e}#u=(G(this,ge),G(this,ve,void 0));get ctimeMs(){return this.#u}set ctimeMs(e){this.#u=e}#d=(G(this,ye),G(this,xe,void 0));get ino(){return this.#d}set ino(e){this.#d=e}#f=(G(this,z),G(this,Ce,void 0));get __ino_old(){return this.#f}set __ino_old(e){this.#f=e}#p=(G(this,we),G(this,Ee,void 0));get flags(){return this.#p}set flags(e){this.#p=e}#m=(G(this,De),G(this,ke,void 0));get __after_flags(){return this.#m}set __after_flags(e){this.#m=e}#h=(G(this,Ae),G(this,Me,void 0));get version(){return this.#h}set version(e){this.#h=e}#g=(G(this,Ne),G(this,Fe,void 0));get __padding(){return this.#g}set __padding(e){this.#g=e}#_=(G(this,Ie),G(this,Re,void 0));get attributes(){return this.#_}set attributes(e){this.#_=e}#v=(G(this,ze),G(this,Ve,void 0));get __data(){return this.#v}set __data(e){this.#v=e}toString(){return`<Inode ${this.ino}>`}toJSON(){return{...p(this,An),attributes:this.attributes}}toStats(){return new xn(this)}update(e){if(!e)return!1;let t=!1;for(let n of An)e[n]!==void 0&&n!=`ino`&&n!=`data`&&this[n]!==e[n]&&(n==`atimeMs`&&this.flags&jn.NoAtime||(this[n]=e[n],t=!0));return e.attributes&&(this.attributes.copyFrom(e.attributes),t=!0),t&&(this.ctimeMs=Date.now()),t}static{G(x,b)}};return Ue=x})();function Pn(e){return(e.mode&Xe)===$e}function q(e){return(e.mode&Xe)===tt}function Fn(e){return(e.mode&Xe)===Qe}function In(e){return(e.mode&Xe)===Ze}function Ln(e){return(e.mode&Xe)===et}function Rn(e){return(e.mode&Xe)===nt}function zn(e){return(e.mode&Xe)===rt}function J(e,t,n){let{credentials:r}=Le(e);if(Fn(t)||r.euid===0||r.egid===0)return!0;let i=0;return r.uid===t.uid&&(t.mode&256&&(i|=4),t.mode&128&&(i|=2),t.mode&64&&(i|=1)),(r.gid===t.gid||r.groups.includes(Number(t.gid)))&&(t.mode&32&&(i|=4),t.mode&16&&(i|=2),t.mode&8&&(i|=1)),t.mode&4&&(i|=4),t.mode&2&&(i|=2),t.mode&1&&(i|=1),(i&n)===n}function Bn(e,t,n){let r=!0;return!isNaN(t)&&t>=0&&t<4294967295?e.uid=t:r=!1,!isNaN(n)&&n>=0&&n<4294967295?e.gid=n:r=!1,r}var Vn=class e extends Map{maxSize=ot;toJSON(){return{version:1,maxSize:this.maxSize,entries:Object.fromEntries([...this].map(([e,t])=>[e,t.toJSON()]))}}toString(){return JSON.stringify(this.toJSON())}get byteSize(){let e=this.size*B(K);for(let t of this.values())e+=t.size;return e}usage(){return{totalSpace:this.maxSize,freeSpace:this.maxSize-this.byteSize}}pathOf(e){for(let[t,n]of this)if(n.ino==e||n.data==e)return t}getByID(e){return this.entryByID(e)?.inode}entryByID(e){for(let[t,n]of this)if(n.ino==e||n.data==e)return{path:t,inode:n}}directoryEntries(e){let t=this.get(e);if(!t)throw P(`ENOENT`);if((t.mode&61440)!=16384)throw P(`ENOTDIR`);let n={};for(let t of this.keys())W(t)==e&&t!=e&&(n[mn(t)]=this.get(t).ino);return n}_alloc(){return Math.max(...[...this.values()].flatMap(e=>[e.ino,e.data]))+1}directories(){let e=new Map;for(let[t,n]of this){if((n.mode&61440)!=16384)continue;let r={};for(let e of this.keys())W(e)==t&&e!=t&&(r[mn(e)]=this.get(e).ino);e.set(t,r)}return e}fromJSON(e){if(e.version!=1)throw P(`EINVAL`,`Index version mismatch`);this.clear();for(let[t,n]of Object.entries(e.entries))n.data??=S(1,ot),t==`/`&&(n.ino=0),this.set(t,new K(n));return this}static parse(t){if(!h(t))throw P(`EINVAL`,`Invalid JSON`);let n=JSON.parse(t),r=new e;return r.fromJSON(n),r}},Hn=4096,Un=class e{type;name;label;_mountPoint;_uuid=crypto.randomUUID();get uuid(){return this._uuid}attributes=new Map;constructor(t,n){this.type=t,this.name=n,this.streamRead===e.prototype.streamRead&&this.attributes.set(`default_stream_read`),this.streamWrite===e.prototype.streamWrite&&this.attributes.set(`default_stream_write`)}toString(){return`${this.name} ${this.label?JSON.stringify(this.label):``} (${this._mountPoint?`mounted on `+this._mountPoint:`unmounted`})`}usage(){return{totalSpace:0,freeSpace:0}}async ready(){}readySync(){if(this.ready!==e.prototype.ready)throw P(`EAGAIN`)}async exists(e){try{return await this.stat(e),!0}catch(e){return e.code!=`ENOENT`}}existsSync(e){try{return this.statSync(e),!0}catch(e){return e.code!=`ENOENT`}}streamRead(e,t){return new ReadableStream({start:async n=>{let{size:r}=await this.stat(e),{start:i=0,end:a=r}=t;for(let t=i;t<a;t+=Hn){let r=t+Hn>a?a-t:Hn,i=new Uint8Array(r);await this.read(e,i,t,t+r).catch(n.error.bind(n)),n.enqueue(i)}n.close()},type:`bytes`})}streamWrite(e,t){let n=t.start??0;return new WritableStream({write:async(t,r)=>{let i=!1,a=e=>{i=!0,r.error(e)},{size:o}=await this.stat(e);await this.write(e,t,n).catch(a),!i&&(n+=t.byteLength,await this.touch(e,{mtimeMs:Date.now(),size:Math.max(o,n)}).catch(a))}})}};Promise.withResolvers??=(R(`Using a polyfill of Promise.withResolvers`),function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}),Symbol.dispose??=(R(`Using a polyfill of Symbol.dispose`),Symbol(`Symbol.dispose`)),Symbol.asyncDispose??=(R(`Using a polyfill of Symbol.asyncDispose`),Symbol(`Symbol.asyncDispose`)),globalThis.crypto.randomUUID??=(R(`Using a polyfill of crypto.randomUUID`),function(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}),Uint8Array.prototype.toBase64??=(R(`Using a polyfill of Uint8Array.prototype.toBase64`),function(){return btoa(String.fromCharCode(...this))}),Uint8Array.fromBase64??=(R(`Using a polyfill of Uint8Array.fromBase64`),function(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}),Uint8Array.prototype.toHex??=(R(`Using a polyfill of Uint8Array.prototype.toHex`),function(){return[...this].map(e=>e.toString(16).padStart(2,`0`)).join(``)}),Uint8Array.fromHex??=(R(`Using a polyfill of Uint8Array.fromHex`),function(e){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t});var Wn=class{store;constructor(e){this.store=e}},Gn=class extends Wn{async get(e,t,n){return this.getSync(e,t,n)}async set(e,t,n){return this.setSync(e,t,n)}async remove(e){return this.removeSync(e)}},Kn=class extends Wn{asyncDone=Promise.resolve();async(e){this.asyncDone=this.asyncDone.then(()=>e)}_cached(e,t){this.store.cache??=new Map;let n=this.store.cache.get(e);return n?(t&&(n.size=t.size),n):t?new s(e,t.size,{},this.store.cache):void 0}getSync(e,t,n){let r=this._cached(e);if(!r)return;n??=r.size;let i=r.missing(t,n);for(let{start:t,end:n}of i)this.async(this.get(e,t,n));if(i.length)throw P(`EAGAIN`);let a=r.regionAt(t);if(!a){R(`Missing cache region for `+e);return}return a.data.subarray(t-a.offset,n-a.offset)}setSync(e,t,n){this.async(this.set(e,t,n))}removeSync(e){this.async(this.remove(e)),this.store.cache?.delete(e)}},qn=class{raw;fs;done=!1;flag(e){return this.raw.store.flags?.includes(e)??!1}constructor(e,t){this.raw=e,this.fs=t}originalData=new Map;modifiedKeys=new Set;keys(){return this.raw.keys()}async get(e,t=0,n){let r=await this.raw.get(e,t,n);return this.stash(e),r}getSync(e,t=0,n){let r=this.raw.getSync(e,t,n);return this.stash(e),r}async set(e,t,n=0){await this.markModified(e,n,t.byteLength);let r=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);await this.raw.set(e,r,n)}setSync(e,t,n=0){this.markModifiedSync(e,n,t.byteLength);let r=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this.raw.setSync(e,r,n)}async remove(e){await this.markModified(e,0,void 0),await this.raw.remove(e)}removeSync(e){this.markModifiedSync(e,0,void 0),this.raw.removeSync(e)}commit(){return this.done=!0,Promise.resolve()}commitSync(){this.done=!0}async abort(){if(!this.done){for(let[e,t]of this.originalData)if(this.modifiedKeys.has(e)){if(t.some(e=>!e.data)){await this.raw.remove(e),this.fs._remove(e);continue}for(let n of t.reverse())await this.raw.set(e,n.data,n.offset)}this.done=!0}}abortSync(){if(!this.done){for(let[e,t]of this.originalData)if(this.modifiedKeys.has(e)){if(t.some(e=>!e.data)){this.raw.removeSync(e),this.fs._remove(e);continue}for(let n of t.reverse())this.raw.setSync(e,n.data,n.offset)}this.done=!0}}async[Symbol.asyncDispose](){this.done||await this.abort()}[Symbol.dispose](){this.done||this.abortSync()}stash(e,t,n=0){this.originalData.has(e)||this.originalData.set(e,[]),this.originalData.get(e).push({data:t,offset:n})}async markModified(e,t,n){this.modifiedKeys.add(e);let r=n?t+n:void 0;try{this.stash(e,await this.raw.get(e,t,r),t)}catch(n){if(!(this.raw instanceof Kn))throw n;let i=this.raw._cached(e);if(!i)throw n;for(let n of i.cached(t,r??t))this.stash(e,await this.raw.get(e,n.start,n.end),n.start)}}markModifiedSync(e,t,n){this.modifiedKeys.add(e);let r=n?t+n:void 0;try{this.stash(e,this.raw.getSync(e,t,r),t)}catch(n){if(!(this.raw instanceof Kn))throw n;let i=this.raw._cached(e);if(!i)throw n;for(let n of i.cached(t,r??t))this.stash(e,this.raw.getSync(e,n.start,n.end),n.start)}}},Jn=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Yn=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Xn=class extends Un{store;_ids=new Map([[`/`,0]]);_paths=new Map([[0,new Set(`/`)]]);_path(e){let[t]=this._paths.get(e)??[];return t}_add(e,t){this._paths.has(e)||this._paths.set(e,new Set),this._paths.get(e).add(t),this._ids.set(t,e)}_remove(e){for(let t of this._paths.get(e)??[])this._ids.delete(t);this._paths.delete(e)}_move(e,t){let n=[];for(let[r,i]of this._ids){let a=pn(e,r);if(a.startsWith(`..`))continue;let o=U(t,a);o.endsWith(`/`)&&(o=o.slice(0,-1)),n.push({oldKey:r,newKey:o,ino:i})}for(let{oldKey:e,newKey:t,ino:r}of n){this._ids.delete(e),this._ids.set(t,r);let n=this._paths.get(r);if(!n){R(`Missing paths in table for ino `+r);continue}n.delete(e),n.add(t)}}_initialized=!1;async ready(){this._initialized||=(this.attributes.has(`no_async_preload`)||this.checkRootSync(),await this.checkRoot(),await this._populate(),!0)}readySync(){this._initialized||=(this.attributes.has(`no_async_preload`)||this.checkRootSync(),this.checkRootSync(),this._populateSync(),!0)}constructor(e){super(e.type??1802921587,e.name),this.store=e,e.fs=this,this._uuid=e.uuid??this.uuid,this.label=e.label,me(this.name+`: supports features: `+this.store.flags?.join(`, `))}usage(){return this.store.usage?.()||{totalSpace:0,freeSpace:0}}async loadIndex(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0),r=e.directories();for(let[t,i]of e)this._add(i.ino,t),await n.set(i.ino,i),r.has(t)&&await n.set(i.data,Xt(r.get(t)));await n.commit()}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}loadIndexSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1),r=e.directories();for(let[t,i]of e)this._add(i.ino,t),n.setSync(i.ino,i),r.has(t)&&n.setSync(i.data,Xt(r.get(t)));n.commitSync()}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async createIndex(){let e={stack:[],error:void 0,hasError:!1};try{let t=new Vn,n=Jn(e,this.transaction(),!0),r=[[`/`,0]],i=v(P(`EDEADLK`));for(;r.length;){let[e,i]=r.shift(),a=new K(await n.get(i));if(t.set(e,a),a.mode&16384){let t=Yt(await n.get(a.data)??y(P(`ENODATA`)));for(let[n,i]of Object.entries(t))r.push([U(e,n),i])}}return i(),t}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}createIndexSync(){let e={stack:[],error:void 0,hasError:!1};try{let t=new Vn,n=Jn(e,this.transaction(),!1),r=[[`/`,0]],i=v(P(`EDEADLK`));for(;r.length;){let[e,i]=r.shift(),a=new K(n.getSync(i));if(t.set(e,a),a.mode&16384){let t=Yt(n.getSync(a.data)??y(P(`ENODATA`)));for(let[n,i]of Object.entries(t))r.push([U(e,n),i])}}return i(),t}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async rename(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=_n(e),a=_n(t),o=await this.findInode(r,i.dir),s=Yt(await r.get(o.data)??y(P(`ENODATA`)));if(!s[i.base])throw P(`ENOENT`);let c=s[i.base];if(c!=this._ids.get(e)&&L(`Ino mismatch while renaming ${e} to ${t}`),delete s[i.base],(a.dir+`/`).startsWith(e+`/`))throw P(`EBUSY`);let l=a.dir==i.dir,u=l?o:await this.findInode(r,a.dir),d=l?s:Yt(await r.get(u.data)??y(P(`ENODATA`)));if(d[a.base]){let e=new K(await r.get(d[a.base])??y(P(`ENOENT`)));if(!Pn(e))throw P(`EISDIR`);await r.remove(e.data),await r.remove(d[a.base])}d[a.base]=c,await r.set(o.data,Xt(s)),await r.set(u.data,Xt(d)),await r.commit(),this._move(e,t)}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}renameSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=_n(e),a=_n(t),o=this.findInodeSync(r,i.dir),s=Yt(r.getSync(o.data)??y(P(`ENODATA`)));if(!s[i.base])throw P(`ENOENT`);let c=s[i.base];if(c!=this._ids.get(e)&&L(`Ino mismatch while renaming ${e} to ${t}`),delete s[i.base],(a.dir+`/`).startsWith(e+`/`))throw P(`EBUSY`);let l=a.dir===i.dir,u=l?o:this.findInodeSync(r,a.dir),d=l?s:Yt(r.getSync(u.data)??y(P(`ENODATA`)));if(d[a.base]){let e=new K(r.getSync(d[a.base])??y(P(`ENOENT`)));if(!Pn(e))throw P(`EISDIR`);r.removeSync(e.data),r.removeSync(d[a.base])}d[a.base]=c,r.setSync(o.data,Xt(s)),r.setSync(u.data,Xt(d)),r.commitSync(),this._move(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async stat(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0);return await this.findInode(n,e)}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}statSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1);return this.findInodeSync(n,e)}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async touch(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=await this.findInode(r,e);i.update(t)&&(this._add(i.ino,e),r.setSync(i.ino,i)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}touchSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=this.findInodeSync(r,e);i.update(t)&&(this._add(i.ino,e),r.setSync(i.ino,i)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async createFile(e,t){return await this.commitNew(e,{...t,mode:t.mode|$e},new Uint8Array)}createFileSync(e,t){return this.commitNewSync(e,{...t,mode:t.mode|$e},new Uint8Array)}async unlink(e){return this.remove(e,!1)}unlinkSync(e){this.removeSync(e,!1)}async rmdir(e){if((await this.readdir(e)).length)throw P(`ENOTEMPTY`);await this.remove(e,!0)}rmdirSync(e){if(this.readdirSync(e).length)throw P(`ENOTEMPTY`);this.removeSync(e,!0)}async mkdir(e,t){return await this.commitNew(e,{...t,mode:t.mode|tt},T(`{}`))}mkdirSync(e,t){return this.commitNewSync(e,{...t,mode:t.mode|tt},T(`{}`))}async readdir(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0),r=await this.findInode(n,e);return Object.keys(Yt(await n.get(r.data)??y(P(`ENOENT`))))}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}readdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1),r=this.findInodeSync(n,e);return Object.keys(Yt(n.getSync(r.data)??y(P(`ENOENT`))))}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async sync(){}syncSync(){}async link(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=W(t),a=await this.findInode(r,i),o=Yt(await r.get(a.data)??y(P(`ENOENT`))),s=await this.findInode(r,e);s.nlink++,o[mn(t)]=s.ino,this._add(s.ino,t),await r.set(s.ino,s),await r.set(a.data,Xt(o)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}linkSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=W(t),a=this.findInodeSync(r,i),o=Yt(r.getSync(a.data)??y(P(`ENOENT`))),s=this.findInodeSync(r,e);s.nlink++,o[mn(t)]=s.ino,this._add(s.ino,t),r.setSync(s.ino,s),r.setSync(a.data,Xt(o)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async read(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{let a=Jn(i,this.transaction(),!0),o=await this.findInode(a,e);if(o.size==0)return;let s=await a.get(o.data,n,r)??y(P(`ENODATA`)),c=a.flag(`partial`)?s:s.subarray(n,r);c.byteLength>t.byteLength&&L(`Trying to place ${c.byteLength} bytes into a ${t.byteLength} byte buffer on read`),t.set(c)}catch(e){i.error=e,i.hasError=!0}finally{let e=Yn(i);e&&await e}}readSync(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{let a=Jn(i,this.transaction(),!1),o=this.findInodeSync(a,e);if(o.size==0)return;let s=a.getSync(o.data,n,r)??y(P(`ENODATA`)),c=a.flag(`partial`)?s:s.subarray(n,r);c.byteLength>t.byteLength&&L(`Trying to place ${c.byteLength} bytes into a ${t.byteLength} byte buffer on read`),t.set(c)}catch(e){i.error=e,i.hasError=!0}finally{Yn(i)}}async write(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{let i=Jn(r,this.transaction(),!0),o=await this.findInode(i,e),s=n+t.byteLength,c=t;i.flag(`partial`)||(c=a(await i.get(o.data)??new Uint8Array,s),c.set(t,n),n=0),await i.set(o.data,c,n),o.update({size:Math.max(o.size,s),mtimeMs:Date.now()}),await i.set(o.ino,o),this._add(o.ino,e),await i.commit()}catch(e){r.error=e,r.hasError=!0}finally{let e=Yn(r);e&&await e}}writeSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{let i=Jn(r,this.transaction(),!1),o=this.findInodeSync(i,e),s=n+t.byteLength,c=t;i.flag(`partial`)||(c=a(i.getSync(o.data)??new Uint8Array,s),c.set(t,n),n=0),i.setSync(o.data,c,n),o.update({size:Math.max(o.size,s),mtimeMs:Date.now()}),i.setSync(o.ino,o),this._add(o.ino,e),i.commitSync()}catch(e){r.error=e,r.hasError=!0}finally{Yn(r)}}transaction(){return new qn(this.store.transaction(),this)}async checkRoot(){let e={stack:[],error:void 0,hasError:!1};try{let t=Jn(e,this.transaction(),!0);if(await t.get(0))return;let n=new K({ino:0,data:1,mode:511|tt});await t.set(n.data,T(`{}`)),this._add(0,`/`),await t.set(0,n),await t.commit()}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}checkRootSync(){let e={stack:[],error:void 0,hasError:!1};try{let t=Jn(e,this.transaction(),!1);if(t.getSync(0))return;let n=new K({ino:0,data:1,mode:511|tt});t.setSync(n.data,T(`{}`)),this._add(0,`/`),t.setSync(0,n),t.commitSync()}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async _populate(){let e={stack:[],error:void 0,hasError:!1};try{if(this._initialized){R(`Attempted to populate tables after initialization`);return}me(`Populating tables with existing store metadata`);let t=Jn(e,this.transaction(),!0),n=await t.get(0);if(!n){fe(`Store does not have a root inode`);let e=new K({ino:0,data:1,mode:511|tt});await t.set(e.data,T(`{}`)),this._add(0,`/`),await t.set(0,e),await t.commit();return}if(n.length<B(K)){de(`Store contains an invalid root inode. Refusing to populate tables`);return}let r=new Set,i=0,a=[[`/`,0]];for(;a.length>0;){i++;let[e,n]=a.shift();this._add(n,e);let o=await t.get(n);if(!o){R(`Store is missing data for inode: `+n);continue}if(o.length<B(K)){R(`Invalid inode size for ino ${n}: ${o.length}`);continue}let s=new K(o);if((s.mode&16384)!=16384||r.has(n))continue;r.add(n);let c=await t.get(s.data);if(!c){R(`Store is missing directory data: `+s.data);continue}let l=Yt(c);for(let[t,n]of Object.entries(l))a.push([U(e,t),n])}me(`Added ${i} existing inode(s) from store`)}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}_populateSync(){let e={stack:[],error:void 0,hasError:!1};try{if(this._initialized){R(`Attempted to populate tables after initialization`);return}me(`Populating tables with existing store metadata`);let t=Jn(e,this.transaction(),!1),n=t.getSync(0);if(!n){fe(`Store does not have a root inode`);let e=new K({ino:0,data:1,mode:511|tt});t.setSync(e.data,T(`{}`)),this._add(0,`/`),t.setSync(0,e),t.commitSync();return}if(n.length<B(K)){de(`Store contains an invalid root inode. Refusing to populate tables`);return}let r=new Set,i=0,a=[[`/`,0]];for(;a.length>0;){i++;let[e,n]=a.shift();this._add(n,e);let o=t.getSync(n);if(!o){R(`Store is missing data for inode: `+n);continue}if(o.length<B(K)){R(`Invalid inode size for ino ${n}: ${o.length}`);continue}let s=new K(o);if((s.mode&16384)!=16384||r.has(n))continue;r.add(n);let c=t.getSync(s.data);if(!c){R(`Store is missing directory data: `+s.data);continue}let l=Yt(c);for(let[t,n]of Object.entries(l))a.push([U(e,t),n])}me(`Added ${i} existing inode(s) from store`)}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async _findInode(e,t,n=new Set){if(n.has(t))throw de(P(`EIO`,`Infinite loop detected while finding inode`));if(n.add(t),t==`/`)return new K(await e.get(0)??y(P(`ENODATA`)));let{dir:r,base:i}=_n(t),a=await this._findInode(e,r,n),o=Yt(await e.get(a.data)??y(P(`ENODATA`)));if(!(i in o))throw P(`ENOENT`);return new K(await e.get(o[i])??y(P(`ENODATA`)))}_findInodeSync(e,t,n=new Set){if(n.has(t))throw de(P(`EIO`,`Infinite loop detected while finding inode`));if(n.add(t),t==`/`)return new K(e.getSync(0)??y(P(`ENOENT`)));let{dir:r,base:i}=_n(t),a=this._findInodeSync(e,r,n),o=Yt(e.getSync(a.data)??y(P(`ENODATA`)));if(!(i in o))throw P(`ENOENT`);return new K(e.getSync(o[i])??y(P(`ENODATA`)))}async findInode(e,t){if(this.attributes.has(`no_id_tables`))return await this._findInode(e,t);let n=this._ids.get(t);if(n===void 0)throw P(`ENOENT`);return new K(await e.get(n)??y(P(`ENOENT`)))}findInodeSync(e,t){if(this.attributes.has(`no_id_tables`))return this._findInodeSync(e,t);let n=this._ids.get(t);if(n===void 0)throw P(`ENOENT`);return new K(e.getSync(n)??y(P(`ENOENT`)))}_lastID;allocNew(e){this._lastID??=Math.max(...this._paths.keys()),this._lastID+=2;let t=this._lastID;if(t>4294967295)throw L(P(`ENOSPC`,`No IDs available`));return this._add(t,e),t}async commitNew(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{if(e==`/`)throw P(`EEXIST`);let i=Jn(r,this.transaction(),!0),{dir:a,base:o}=_n(e),s=await this.findInode(i,a),c=Yt(await i.get(s.data)??y(P(`ENOENT`)));if(c[o])throw P(`EEXIST`);let l=this.allocNew(e),u=new K({...t,ino:l,data:l+1,size:n.byteLength,nlink:1});return await i.set(u.ino,u),await i.set(u.data,n),c[o]=u.ino,await i.set(s.data,Xt(c)),await i.commit(),u}catch(e){r.error=e,r.hasError=!0}finally{let e=Yn(r);e&&await e}}commitNewSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{if(e==`/`)throw P(`EEXIST`);let i=Jn(r,this.transaction(),!1),{dir:a,base:o}=_n(e),s=this.findInodeSync(i,a),c=Yt(i.getSync(s.data)??y(P(`ENOENT`)));if(c[o])throw P(`EEXIST`);let l=this.allocNew(e),u=new K({...t,ino:l,data:l+1,size:n.byteLength,nlink:1});return i.setSync(u.ino,u),i.setSync(u.data,n),c[o]=u.ino,i.setSync(s.data,Xt(c)),i.commitSync(),u}catch(e){r.error=e,r.hasError=!0}finally{Yn(r)}}async remove(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),{dir:i,base:a}=_n(e),o=await this.findInode(r,i),s=Yt(await r.get(o.data)??y(P(`ENOENT`)));if(!s[a])throw P(`ENOENT`);let c=s[a],l=new K(await r.get(c)??y(P(`ENOENT`)));if(delete s[a],!t&&q(l))throw P(`EISDIR`);await r.set(o.data,Xt(s)),l.nlink>1?(l.update({nlink:l.nlink-1}),await r.set(l.ino,l)):(await r.remove(l.data),await r.remove(c),this._remove(c)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}removeSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),{dir:i,base:a}=_n(e),o=this.findInodeSync(r,i),s=Yt(r.getSync(o.data)??y(P(`ENOENT`))),c=s[a];if(!c)throw P(`ENOENT`);let l=new K(r.getSync(c)??y(P(`ENOENT`)));if(delete s[a],!t&&q(l))throw P(`EISDIR`);r.setSync(o.data,Xt(s)),l.nlink>1?(l.update({nlink:l.nlink-1}),r.setSync(l.ino,l)):(r.removeSync(l.data),r.removeSync(c),this._remove(c)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}},Zn=class extends Gn{async keys(){return this.store.keys()}async get(e){return await(this.store.getAsync?.(e)??this.store.get(e))}getSync(e){return this.store.get(e)}setSync(e,t){this.store.set(e,t)}removeSync(e){this.store.delete(e)}},Qn=class extends Kn{async keys(){return await this.asyncDone,this.store.keys()}async get(e,t,n){return await this.asyncDone,await this.store.get(e,t,n)}getSync(e,t,n){return this.store.cached(e,t,n)}async set(e,t,n=0){await this.asyncDone,await this.store.set(e,t,n)}async remove(e){await this.asyncDone,await this.store.delete(e)}},$n=class extends Map{maxSize;label;flags=[];name=`tmpfs`;constructor(e=ot,t){super(),this.maxSize=e,this.label=t}async sync(){}transaction(){return new Zn(this)}get bytes(){let e=this.size*4;for(let t of this.values())e+=t.byteLength;return e}usage(){return{totalSpace:this.maxSize,freeSpace:this.maxSize-this.bytes}}},er={name:`InMemory`,options:{maxSize:{type:`number`,required:!1},label:{type:`string`,required:!1}},create({maxSize:e,label:t}){let n=new Xn(new $n(e,t));return n.checkRootSync(),n}},tr=class extends Xn{devices=new Map;devicesWithDriver(e,t){if(t&&typeof e==`string`)throw L(P(`EINVAL`,`Can not fetch devices using only a driver name`));let n=[];for(let r of this.devices.values())t&&r.driver!=e||(typeof e==`string`?e:e.name)==r.driver.name&&n.push(r);return n}_createDevice(e,t={}){let n=1,r=Array.from(this.devices.values()).at(-1);for(;this.store.has(n)||r?.inode.ino==n;)n++;let i=e.init?.(n,t),a={data:{},minor:0,major:0,...m(i??{},`metadata`),driver:e,inode:new K({mode:nt|438,...i?.metadata})},o=`/`+(a.name||e.name)+(e.singleton?``:this.devicesWithDriver(e).length);if(this.existsSync(o))throw P(`EEXIST`);return this.devices.set(o,a),pe(`Initialized device: `+this._mountPoint+o),a}addDefaults(){this._createDevice(rr),this._createDevice(ir),this._createDevice(ar),this._createDevice(or),this._createDevice(sr),me(`Added default devices`)}constructor(){super(new $n(16777216,`devfs`))}async rename(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.rename(e,t)}renameSync(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.renameSync(e,t)}async stat(e){let t=this.devices.get(e);return t?t.inode:super.stat(e)}statSync(e){let t=this.devices.get(e);return t?t.inode:super.statSync(e)}async touch(e,t){let n=this.devices.get(e);n?n.inode.update(t):await super.touch(e,t)}touchSync(e,t){let n=this.devices.get(e);n?n.inode.update(t):super.touchSync(e,t)}async createFile(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.createFile(e,t)}createFileSync(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.createFileSync(e,t)}async unlink(e){if(this.devices.has(e))throw P(`EPERM`);return super.unlink(e)}unlinkSync(e){if(this.devices.has(e))throw P(`EPERM`);return super.unlinkSync(e)}async rmdir(e){return super.rmdir(e)}rmdirSync(e){return super.rmdirSync(e)}async mkdir(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.mkdir(e,t)}mkdirSync(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.mkdirSync(e,t)}async readdir(e){let t=await super.readdir(e);for(let n of this.devices.keys())W(n)==e&&t.push(mn(n));return t}readdirSync(e){let t=super.readdirSync(e);for(let n of this.devices.keys())W(n)==e&&t.push(mn(n));return t}async link(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.link(e,t)}linkSync(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.linkSync(e,t)}async sync(){for(let e of this.devices.values())e.driver.sync?.(e);return super.sync()}syncSync(){for(let e of this.devices.values())e.driver.sync?.(e);return super.syncSync()}async read(e,t,n,r){let i=this.devices.get(e);if(!i){await super.read(e,t,n,r);return}i.driver.read(i,t,n,r)}readSync(e,t,n,r){let i=this.devices.get(e);if(!i){super.readSync(e,t,n,r);return}i.driver.read(i,t,n,r)}async write(e,t,n){let r=this.devices.get(e);if(!r)return await super.write(e,t,n);r.driver.write(r,t,n)}writeSync(e,t,n){let r=this.devices.get(e);if(!r)return super.writeSync(e,t,n);r.driver.write(r,t,n)}},nr=new Uint8Array,rr={name:`null`,singleton:!0,init(){return{major:1,minor:3}},read(){return nr},write(){}},ir={name:`zero`,singleton:!0,init(){return{major:1,minor:5}},read(e,t,n,r){t.fill(0,n,r)},write(){}},ar={name:`full`,singleton:!0,init(){return{major:1,minor:7}},read(e,t,n,r){t.fill(0,n,r)},write(){throw P(`ENOSPC`)}},or={name:`random`,singleton:!0,init(){return{major:1,minor:8}},read(e,t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256)},write(){}},sr={name:`console`,singleton:!0,init(e,{output:t=e=>console.log(e)}={}){return{major:5,minor:1,data:{output:t}}},read(){return nr},write(e,t,n){let r=E(t);e.data.output(r,n)}},cr={null:rr,zero:ir,full:ar,random:or,console:sr},lr=r(),Y=!0;function ur(e){Y=e}var dr;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.FIFO=1]=`FIFO`,e[e.CHR=2]=`CHR`,e[e.DIR=4]=`DIR`,e[e.BLK=6]=`BLK`,e[e.REG=8]=`REG`,e[e.LNK=10]=`LNK`,e[e.SOCK=12]=`SOCK`,e[e.WHT=14]=`WHT`})(dr||={});function fr(e){return(e&61440)>>12}function pr(e){return e<<12}var mr=class{ino;type;path;name},hr=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},gr=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},_r=class{pending=new Set;lastWriter;writeState=0;readers=0;syncReaders=0;take(e,t,n){e==`rw`?this.writeState=t?2:1:(this.readers++,t&&this.syncReaders++);let r=!1,i=()=>{r||(r=!0,e==`rw`?this.writeState=0:(this.readers--,t&&this.syncReaders--),n())};return i[Symbol.dispose]=i,i}queue(e){let{promise:t,resolve:n}=Promise.withResolvers();return this.pending.add(t),e==`rw`&&(this.lastWriter=t),t.then(()=>{this.pending.delete(t),this.lastWriter==t&&delete this.lastWriter}),n}async acquire(e){let t=e==`ro`?this.lastWriter:Promise.all(this.pending),n=this.queue(e);return await t,this.take(e,!1,n)}acquireSync(e){if(this.writeState==2||e==`rw`&&this.syncReaders)throw P(`EDEADLK`);if(this.writeState||e==`rw`&&this.readers)throw P(`EAGAIN`);return this.take(e,!0,this.queue(e))}isAvailable(e){return(e!=`rw`||!this.readers)&&!this.writeState}get isFree(){return!this.writeState&&!this.readers}get mode(){return this.writeState?`rw`:this.readers?`ro`:null}},vr=(()=>{let e=[],t,n;return class{static{let r=typeof Symbol==`function`&&Symbol.metadata?Object.create(null):void 0;t=[b],n=[b],gr(this,null,t,{kind:`getter`,name:`lock`,static:!1,private:!1,access:{has:e=>`lock`in e,get:e=>e.lock},metadata:r},null,e),gr(this,null,n,{kind:`getter`,name:`lockSync`,static:!1,private:!1,access:{has:e=>`lockSync`in e,get:e=>e.lockSync},metadata:r},null,e),r&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:r})}_rwLock=(hr(this,e),new _r);get lock(){return this._rwLock.acquire.bind(this._rwLock)}get lockSync(){return this._rwLock.acquireSync.bind(this._rwLock)}get isLocked(){return!this._rwLock.isFree}get lockMode(){return this._rwLock.mode}}})(),yr=class extends vr{fs;inode;data;dirtyRanges=[];truncatedTo;metadataDirty=!1;refs=0;paths=new Set;_lastPath;constructor(e,t,n){super(),this.fs=e,this.inode=n,this.paths.add(t),this._lastPath=t,this.data=new s(n.ino,n.size,{sparse:!0})}get ino(){return this.inode.ino}get path(){let[e]=this.paths;return e!==void 0&&(this._lastPath=e),e??this._lastPath}get dirty(){return this.metadataDirty||this.dirtyRanges.length>0}get bypassCache(){return Rn(this.inode)||Ln(this.inode)||!!(this.inode.flags&jn.DAX)}markDirty(e,t){this.dirtyRanges.push({start:e,end:t}),this.dirtyRanges.sort((e,t)=>e.start-t.start);let n=[];for(let e of this.dirtyRanges){let t=n.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):n.push(e)}this.dirtyRanges=n}copyFromCache(e,t,n){let r=t;for(let i of this.data.regions){let a=i.offset+i.data.byteLength;if(a<=r)continue;if(i.offset>=n)break;i.offset>r&&(e.fill(0,r-t,i.offset-t),r=i.offset);let o=Math.min(n,a);e.set(i.data.subarray(r-i.offset,o-i.offset),r-t),r=o}r<n&&e.fill(0,r-t,n-t)}async read(e,t,n){if(this.bypassCache)return await this.fs.read(this.path,e,t,n);for(let{start:e,end:r}of this.data.missing(t,n)){let t=new Uint8Array(r-e);await this.fs.read(this.path,t,e,r),this.data.add(t,e)}this.copyFromCache(e,t,n)}readSync(e,t,n){if(this.bypassCache)return this.fs.readSync(this.path,e,t,n);for(let{start:e,end:r}of this.data.missing(t,n)){let t=new Uint8Array(r-e);this.fs.readSync(this.path,t,e,r),this.data.add(t,e)}this.copyFromCache(e,t,n)}async write(e,t){this.bypassCache?await this.fs.write(this.path,e,t):this._writeCached(e,t),this._writeMetadata(t+e.byteLength)}writeSync(e,t){this.bypassCache?this.fs.writeSync(this.path,e,t):this._writeCached(e,t),this._writeMetadata(t+e.byteLength)}_writeCached(e,t){let n=t+e.byteLength;this.data.add(e.slice(),t),n>this.data.size&&(this.data.size=n),this.markDirty(t,n)}_writeMetadata(e){!this.bypassCache&&e>this.inode.size&&(this.inode.size=e),this.inode.mtimeMs=Date.now(),this.inode.ctimeMs=Date.now(),this.metadataDirty=!0}truncate(e){this.truncatedTo=Math.min(this.truncatedTo??e,e),this.data.size=e,this.dirtyRanges=this.dirtyRanges.filter(t=>t.start<e).map(t=>t.end>e?{start:t.start,end:e}:t),this.inode.size=e,this.inode.mtimeMs=Date.now(),this.inode.ctimeMs=Date.now(),this.metadataDirty=!0}get needsPreTruncate(){return!this.bypassCache&&this.truncatedTo!==void 0&&this.truncatedTo<this.inode.size&&!this.fs.attributes.has(`no_write`)}async sync(){this.needsPreTruncate&&await this.fs.touch(this.path,{size:this.truncatedTo}),this.truncatedTo=void 0;for(let e of this.dirtyRanges)for(let t=e.start;t<e.end;){let n=this.data.regionAt(t);if(!n)break;let r=Math.min(e.end,n.offset+n.data.byteLength);await this.fs.write(this.path,n.data.subarray(t-n.offset,r-n.offset),t),t=r}this.dirtyRanges=[],this.metadataDirty&&=(this.fs.attributes.has(`no_write`)||await this.fs.touch(this.path,this.inode),!1)}syncSync(){this.needsPreTruncate&&this.fs.touchSync(this.path,{size:this.truncatedTo}),this.truncatedTo=void 0;for(let e of this.dirtyRanges)for(let t=e.start;t<e.end;){let n=this.data.regionAt(t);if(!n)break;let r=Math.min(e.end,n.offset+n.data.byteLength);this.fs.writeSync(this.path,n.data.subarray(t-n.offset,r-n.offset),t),t=r}this.dirtyRanges=[],this.metadataDirty&&=(this.fs.attributes.has(`no_write`)||this.fs.touchSync(this.path,this.inode),!1)}},br=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},xr=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Sr=class{fs;byIno=new Map;byPath=new Map;constructor(e){this.fs=e}get(e){return this.byPath.get(e)}ref(e,t){let n=this.byIno.get(t.ino);return n&&!n.paths.has(e)&&(t.ino===0||t.nlink<=1||n.inode.nlink<=1||(n.inode.mode^t.mode)&61440)&&(n=this.byPath.get(e),n&&(n.inode.mode^t.mode)&61440&&(n=void 0)),n?(n.paths.add(e),!n.dirty&&t!==n.inode&&Object.assign(n.inode,t)):(n=new yr(this.fs,e,t),this.byIno.set(t.ino,n)),this.byPath.set(e,n),n.refs++,n}unref(e){e.refs--,!(e.refs>0||e.dirty)&&this.evict(e)}evict(e){this.byIno.delete(e.ino);for(let t of e.paths)this.byPath.delete(t)}rename(e,t){for(let[n,r]of this.byPath){if(n!=e&&!n.startsWith(e+`/`))continue;let i=t+n.slice(e.length);this.byPath.delete(n),this.byPath.set(i,r),r.paths.delete(n),r.paths.add(i)}}link(e,t){let n=this.byPath.get(e);n&&(n.paths.add(t),this.byPath.set(t,n))}remove(e){let t=this.byPath.get(e);t&&(this.byPath.delete(e),t.paths.delete(e),!t.paths.size&&!t.refs&&this.evict(t))}async sync(){for(let e of this.byIno.values()){let t={stack:[],error:void 0,hasError:!1};try{if(!e.dirty)continue;br(t,await e.lock(`rw`),!1),await e.sync(),e.refs||this.evict(e)}catch(e){t.error=e,t.hasError=!0}finally{xr(t)}}}syncSync(){for(let e of this.byIno.values()){let t={stack:[],error:void 0,hasError:!1};try{if(!e.dirty)continue;br(t,e.lockSync(`rw`),!1),e.syncSync(),e.refs||this.evict(e)}catch(e){t.error=e,t.hasError=!0}finally{xr(t)}}}},Cr=new Map;function wr(e){let t=Cr.get(e.uuid);return t||(t=new Sr(e),Cr.set(e.uuid,t)),t}async function Tr(e,t,n,r){let i=wr(e);r??=i.get(t)?.inode??await e.stat(t);let a=i.ref(t,r),o=await a.lock(n),s=!1,c=()=>{s||(s=!0,o(),i.unref(a))};return c[Symbol.dispose]=c,c}function Er(e,t,n,r){let i=wr(e);r??=i.get(t)?.inode??e.statSync(t);let a=i.ref(t,r),o;try{o=a.lockSync(n)}catch(e){throw i.unref(a),e}let s=!1,c=()=>{s||(s=!0,o(),i.unref(a))};return c[Symbol.dispose]=c,c}var Dr=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Or=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},kr=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Ar=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),jr=4096,Mr=(()=>{let e=[],t,n;return class{static{let r=typeof Symbol==`function`&&Symbol.metadata?Object.create(null):void 0;Or(this,null,t,{kind:`getter`,name:`inode`,static:!1,private:!1,access:{has:e=>`inode`in e,get:e=>e.inode},metadata:r},null,e),Or(this,null,n,{kind:`getter`,name:`fs`,static:!1,private:!1,access:{has:e=>`fs`in e,get:e=>e.fs},metadata:r},null,e),r&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:r})}context=Dr(this,e);path;internalPath;flag;vnode;_position=0;get position(){return this.flag&1024?this.inode.size:this._position}set position(e){this._position=e}get inode(){return this.vnode.inode}get fs(){return this.vnode.fs}get dirty(){return this.vnode.dirty}closed=!1;get isClosed(){return this.closed}constructor(e,t,n,r,i){this.context=e,this.path=t,this.internalPath=n,this.flag=r,this.vnode=i}get _isSync(){return!!(this.flag&1052672||this.inode.flags&jn.Sync||this.fs.attributes.has(`sync`))}[(t=[b],n=[b],Symbol.dispose)](){this.closeSync()}syncSync(){let e={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`sync`,this.path);if(!this.dirty)return;kr(e,this.vnode.lockSync(`rw`),!1),this.vnode.syncSync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}datasyncSync(){return this.syncSync()}closeSync(){if(this.closed)throw N(`EBADF`,`close`,this.path);this.syncSync(),this.disposeSync(!0)}disposeSync(e){if(this.closed)throw N(`EBADF`,`close`,this.path);if(this.dirty&&!e)throw N(`EBUSY`,`close`,this.path);this.closed=!0,wr(this.fs).unref(this.vnode)}truncateSync(e){let t={stack:[],error:void 0,hasError:!1};try{if(e<0)throw N(`EINVAL`,`truncate`,this.path);if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`truncate`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`truncate`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`truncate`,this.path);kr(t,this.vnode.lockSync(`rw`),!1),this.vnode.truncate(e),this._isSync&&this.vnode.syncSync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}writeSync(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);kr(i,this.vnode.lockSync(`rw`),!1);let a=e.subarray(t,t+n);return this.vnode.writeSync(a,r),this._position=r+a.byteLength,this._isSync&&this.vnode.syncSync(),a.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}readSync(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||this.flag&1)throw N(`EBADF`,`read`,this.path);kr(i,this.vnode.lockSync(`ro`),!1),!(this.inode.flags&jn.NoAtime)&&!this.fs.attributes.has(`no_atime`)&&(this.vnode.metadataDirty=!0,this.inode.atimeMs=Date.now());let a=r+n;!Rn(this.inode)&&!Ln(this.inode)&&a>this.inode.size&&(a=r+Math.max(this.inode.size-r,0)),this._position=a;let o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return this.vnode.readSync(o.subarray(t,t+n),r,a),this._isSync&&this.vnode.syncSync(),a-r}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}chmodSync(e){let t={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(t,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.mode=this.inode.mode&(e>61440?~Xe:Xe)|e,(this._isSync||e>61440)&&this.vnode.syncSync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}chownSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(n,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,Bn(this.inode,e,t),this._isSync&&this.vnode.syncSync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}utimesSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`utimes`,this.path);kr(n,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.atimeMs=e,this.inode.mtimeMs=t,this._isSync&&this.vnode.syncSync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}async[Symbol.asyncDispose](){await this.close()}async sync(){let e={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`sync`,this.path);if(!this.dirty)return;kr(e,await this.vnode.lock(`rw`),!1),await this.vnode.sync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}datasync(){return this.sync()}async close(){if(this.closed)throw N(`EBADF`,`close`,this.path);await this.sync(),this.dispose(!0)}dispose(e){if(this.closed)throw N(`EBADF`,`close`,this.path);if(this.dirty&&!e)throw N(`EBUSY`,`close`,this.path);this.closed=!0,wr(this.fs).unref(this.vnode)}stat(){if(this.closed)throw N(`EBADF`,`stat`,this.path);return this.inode}async truncate(e){let t={stack:[],error:void 0,hasError:!1};try{if(e<0)throw N(`EINVAL`,`truncate`,this.path);if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`truncate`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`truncate`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`truncate`,this.path);kr(t,await this.vnode.lock(`rw`),!1),this.vnode.truncate(e),this._isSync&&await this.vnode.sync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}async write(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);kr(i,await this.vnode.lock(`rw`),!1);let a=e.subarray(t,t+n);return await this.vnode.write(a,r),this._position=r+a.byteLength,this._isSync&&await this.vnode.sync(),a.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}async read(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||this.flag&1)throw N(`EBADF`,`read`,this.path);kr(i,await this.vnode.lock(`ro`),!1),!(this.inode.flags&jn.NoAtime)&&!this.fs.attributes.has(`no_atime`)&&(this.vnode.metadataDirty=!0,this.inode.atimeMs=Date.now());let a=r+n;!Rn(this.inode)&&!Ln(this.inode)&&a>this.inode.size&&(a=r+Math.max(this.inode.size-r,0)),this._position=a;let o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return await this.vnode.read(o.subarray(t,t+n),r,a),this._isSync&&await this.vnode.sync(),a-r}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}async chmod(e){let t={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(t,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.mode=this.inode.mode&(e>61440?~Xe:Xe)|e,(this._isSync||e>61440)&&await this.vnode.sync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}async chown(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chown`,this.path);kr(n,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,Bn(this.inode,e,t),this._isSync&&await this.vnode.sync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}async utimes(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`utimes`,this.path);kr(n,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.atimeMs=e,this.inode.mtimeMs=t,this._isSync&&await this.vnode.sync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}streamRead(e){if(this.closed)throw N(`EBADF`,`streamRead`,this.path);let{vnode:t}=this;return new ReadableStream({async start(n){let r={stack:[],error:void 0,hasError:!1};try{kr(r,await t.lock(`ro`),!1);let{start:i=0,end:a=t.inode.size}=e;for(let e=i;e<a;e+=jr){let r=e+jr>a?a-e:jr,i=new Uint8Array(r);await t.read(i,e,e+r).catch(n.error.bind(n)),n.enqueue(i)}n.close()}catch(e){r.error=e,r.hasError=!0}finally{Ar(r)}},type:`bytes`})}streamWrite(e){if(this.closed)throw N(`EBADF`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);let{vnode:t}=this,n=e.start??0;return new WritableStream({async write(e,r){let i={stack:[],error:void 0,hasError:!1};try{kr(i,await t.lock(`rw`),!1),await t.write(e,n).catch(r.error.bind(r)),n+=e.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}},async close(){let e={stack:[],error:void 0,hasError:!1};try{kr(e,await t.lock(`rw`),!1),await t.sync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}})}}})();function Nr(e){let t=Le(e.context).descriptors,n=Math.max(t.size?Math.max(...t.keys())+1:0,4);return t.set(n,e),n}function Pr(e,t){$t(t);let n=Le(e).descriptors.get(t);if(!n)throw P(`EBADF`);return n}function Fr(e,t){return Le(e).descriptors.delete(t)}var Ir=/[rwasx]{1,2}\+?/;function Lr(e){if(typeof e==`number`)return e;if(!Ir.test(e))throw P(`EINVAL`,`Invalid flag string: `+e);return Rr(e)}function Rr(e){if(!e.includes(`r`)&&!e.includes(`w`)&&!e.includes(`a`))throw P(`EINVAL`,`Invalid flag string: `+e);let t=e.includes(`r`)?0:64;return e.includes(`w`)&&(t|=512),e.includes(`a`)&&(t|=Ve),e.includes(`+`)?t|=2:e.includes(`r`)||(t|=1),e.includes(`s`)&&(t|=Ge),e.includes(`x`)&&(t|=128),t}function zr(e){let t=0;return e&1||(t|=4),(e&1||e&2)&&(t|=2),t}var Br=M;function Vr(e,t){return e.path=t,e}function Hr(e,t,n,r){let i=typeof n==`string`?{path:n,dest:r,syscall:t.endsWith(`Sync`)?t.slice(0,-4):t}:n,a=e[t];if(typeof a!=`function`)throw TypeError(`${t} is not a function`);return function(...t){try{return a.call(e,...t)}catch(e){throw j(Object.assign(e,i))}}}function Ur(e,t){return new Proxy(e,{get(e,n){let r=Reflect.get(e,n);return typeof r==`function`?function n(...i){try{let a=r.apply(e,i);return a instanceof Promise?a.catch(e=>{if(`code`in e)throw j(Object.assign(e,t));if(e in k){let r=N(e,t);Error.captureStackTrace(r,n)}throw e}):a}catch(e){throw j(Object.assign(e,t))}}:r}})}var Wr=new Map;Gr(`/`,er.create({label:`root`}));function Gr(e,t){if(e[0]!=`/`&&(e=`/`+e),e=un.call(this,e),Wr.has(e))throw L(P(`EINVAL`,`Mount point is already in use: `+e));t._mountPoint=e,Wr.set(e,t),Cr.has(t.uuid)||Cr.set(t.uuid,new Sr(t)),pe(`Mounted ${t.name} on ${e}`),me(`${t.name} attributes: ${[...t.attributes].map(([e,t])=>t==null?e:e+`=`+t).join(`, `)}`)}function Kr(e){e[0]!=`/`&&(e=`/`+e),e=un.call(this,e);let t=Wr.get(e);if(!t){R(e+` is already unmounted`);return}let n=()=>{Cr.delete(t.uuid),pe(`Synced all changes to `+e)};try{Cr.get(t.uuid)?.syncSync(),n()}catch{R(`Could not flush to ${e} synchronously.`),Cr.get(t.uuid)?.sync().then(n)}Wr.delete(e),fe(`Unmounted `+e)}function X(e,t,n){let{root:r}=Le(t),i={path:e,...n};e=H(U(r,e),!0),e=un.call(t,e);let a=[...Wr].sort((e,t)=>e[0].length>t[0].length?-1:1);for(let[t,n]of a){if(!Yr(t,e))continue;e=e.slice(t.length>1?t.length:0),e===``&&(e=`/`);let a=n.attributes.get(`case_fold`);return a===`lower`&&(e=e.toLowerCase()),a===`upper`&&(e=e.toUpperCase()),{fs:Ur(n,i),path:e,mountPoint:t,root:r}}throw ue(new M(k.EIO,`No file system for `+e))}function qr(e,t){let n=e.usage(),r=n.blockSize||4096;return{type:(t?BigInt:Number)(e.type),bsize:(t?BigInt:Number)(r),ffree:(t?BigInt:Number)(n.freeNodes||4294967295),files:(t?BigInt:Number)(n.totalNodes||4294967295),bavail:(t?BigInt:Number)(n.freeSpace/r),bfree:(t?BigInt:Number)(n.freeSpace/r),blocks:(t?BigInt:Number)(n.totalSpace/r)}}function Jr(e){let t=Le(this);if(!Pe(t.credentials))throw P(`EPERM`,`Can not chroot() as non-root user`);t.root??=`/`;let n=U(t.root,e);for(let e of t.descriptors?.values()??[]){if(!e.path.startsWith(t.root))throw N(`EBUSY`,`chroot`,e.path);e.path=e.path.slice(t.root.length)}if(n.length>t.root.length)throw P(`EPERM`,`Can not chroot() outside of current root`);t.root=n}function Yr(e,t){return e===`/`||e===t||(e.endsWith(`/`)||(e+=`/`),t.startsWith(e))}var Xr=t({link:()=>ai,mkdir:()=>ni,open:()=>ei,readdir:()=>ri,readlink:()=>ti,rename:()=>ii,resolve:()=>$r,stat:()=>oi}),Zr=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Qr=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});function $r(e,t,n,r){t=un.call(e,t);try{let i=X(t,e),a=wr(i.fs).get(i.path)?.inode??i.fs.statSync(i.path);return!Fn(a)||n?{...i,fullPath:t,stats:a}:$r(e,un.call(e,W(t),ti.call(e,t)),n,r)}catch(e){if(j(Object.assign(e,{syscall:`stat`,path:t,...r})),n)throw e}let{base:i,dir:a}=_n(t),o=a==`/`?`/`:$r(e,a,!1,r).fullPath,s=U(o,i),c=X(s,e),l;try{l=wr(c.fs).get(c.path)?.inode??c.fs.statSync(c.path)}catch(e){if(e.code===`ENOENT`)return{...c,fullPath:s};throw j(Object.assign(e,{syscall:`stat`,path:s,...r}))}return Fn(l)?$r(e,un.call(e,o,ti.call(e,s)),!1,r):{...c,fullPath:s,stats:l}}function ei(e,t){e=H(e);let n=Zt(t.mode,420),r=Lr(t.flag);e=t.preserveSymlinks?e:$r(this,e).fullPath;let{fs:i,path:a}=X(e,this),o;try{o=i.statSync(a)}catch{}if(!o){let o={stack:[],error:void 0,hasError:!1};try{if(!(r&64))throw N(`ENOENT`,`open`,e);let s=W(a),c=i.statSync(s);if(Y&&!J(this,c,2))throw N(`EACCES`,`open`,e);if(!q(c))throw N(`ENOTDIR`,`open`,e);if(!t.allowDirectory&&n&16384)throw N(`EISDIR`,`open`,e);Zr(o,Er(i,s,`rw`,c),!1);let{euid:l,egid:u}=Le(this).credentials,d=i.createFileSync(a,{mode:n,uid:c.mode&2048?c.uid:l,gid:c.mode&1024?c.gid:u});return ua(this,`rename`,e),new Mr(this,e,a,r,wr(i).ref(a,d))}catch(e){o.error=e,o.hasError=!0}finally{Qr(o)}}if(Y&&(!J(this,o,n)||!J(this,o,zr(r))))throw N(`EACCES`,`open`,e);if(r&128)throw N(`EEXIST`,`open`,e);if(!t.allowDirectory&&o.mode&16384)throw N(`EISDIR`,`open`,e);let s=new Mr(this,e,a,r,wr(i).ref(a,o));return r&512&&s.truncateSync(0),s}function ti(e){e=H(e);let{fs:t,stats:n,path:r}=$r(this,e,!0,{syscall:`readlink`});if(!n)throw N(`ENOENT`,`readlink`,e);if(Y&&!J(this,n,4))throw N(`EACCES`,`readlink`,e);if(!Fn(n))throw N(`EINVAL`,`readlink`,e);let i=n.size,a=new Uint8Array(i);return t.readSync(r,a,0,i),E(a)}function ni(e,t={}){let n=H(e),r={syscall:`mkdir`,path:n},{fullPath:i}=$r(this,W(n),!1,r),{fs:a,path:o}=X(U(i,mn(n)),this,r),s=i!=W(n),{euid:c,egid:l}=Le(this).credentials,{mode:u=511,recursive:d}=t,f,p=(e,t)=>{let n={stack:[],error:void 0,hasError:!1};try{let i=W(t),m=d&&i!=`/`?p(W(e),i):a.statSync(i);if(d){let n;try{n=wr(a).get(t)?.inode??a.statSync(t)}catch{}if(n){let i=Fn(n)?$r(this,e,!1,r).stats:n;if(!i)throw N(`ENOENT`,r);if(!q(i))throw N(t==o?`EEXIST`:`ENOTDIR`,r);return n}if(s&&a.existsSync(U(i,mn(e))))throw N(`ENOENT`,r)}if(Y&&!J(this,m,2))throw N(`EACCES`,`mkdir`,e);Zr(n,Er(a,i,`rw`,m),!1);let h=Hr(a,`mkdirSync`,{path:e,syscall:`mkdir`})(t,{mode:u,uid:m.mode&2048?m.uid:c,gid:m.mode&1024?m.gid:l});return d&&(f??=e),ua(this,`rename`,e),h}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}};return p(n,o),f}function ri(e,t={}){e=H(e);let{fs:n,path:r}=$r(this,e),i=wr(n).get(r)?.inode??Hr(n,`statSync`,{path:e,syscall:`scandir`})(r);if(Y&&!J(this,i,4))throw N(`EACCES`,`scandir`,e);if(!q(i))throw N(`ENOTDIR`,`scandir`,e);let a;{let e={stack:[],error:void 0,hasError:!1};try{Zr(e,Er(n,r,`ro`,i),!1),a=n.readdirSync(r)}catch(t){e.error=t,e.hasError=!0}finally{Qr(e)}}let o=[],s=e=>{let i;try{i=n.statSync(U(r,e))}catch(e){if(e.code==`ENOENT`)return;throw e}let a=new mr;if(a.ino=i.ino,a.type=fr(i.mode),a.path=e,a.name=mn(e),o.push(a),!q(i)||!t?.recursive)return;let c=n.readdirSync(U(r,e));for(let t of c)s(U(e,t))};for(let e of a)s(e);return o}function ii(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`rename`,path:e,dest:t},i=$r(this,e,!0,r),a=X(t,this,r);if(i.fs.uuid!==a.fs.uuid)throw N(`EXDEV`,r);if(a.path.startsWith(i.path+`/`))throw N(`EINVAL`,r);if(!i.stats)throw N(`ENOENT`,r);let o=i.fs,s=o.statSync(W(i.path)),c=o.statSync(W(a.path)),l;try{l=o.statSync(a.path)}catch(e){if(e.code!=`ENOENT`)throw e}if(Y&&(!J(this,s,4)||!J(this,c,2)))throw N(`EACCES`,r);if(l&&!q(i.stats)&&q(l))throw N(`EISDIR`,r);if(l&&q(i.stats)&&!q(l))throw N(`ENOTDIR`,r);let u=W(i.path),d=W(a.path),f=[[u,s],[d,c]];s.ino>c.ino&&f.reverse(),Zr(n,Er(o,f[0][0],`rw`,f[0][1]),!1),Zr(n,s.ino==c.ino?null:Er(o,f[1][0],`rw`,f[1][1]),!1),i.fs.renameSync(i.path,a.path),wr(o).rename(i.path,a.path),ua(this,`rename`,e),ua(this,`rename`,t)}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}}function ai(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`link`,path:e,dest:t},{fs:i,path:a}=X(e,this,r),o=X(t,this,r);if(i.uuid!==o.fs.uuid)throw N(`EXDEV`,r);let s=i.statSync(a);if(Y){if(!J(this,s,4))throw N(`EACCES`,r);let e=i.statSync(W(a));if(!J(this,e,4))throw N(`EACCES`,r);let t=i.statSync(W(o.path));if(!J(this,t,2))throw N(`EACCES`,r)}Zr(n,Er(i,W(o.path),`rw`),!1),i.linkSync(a,o.path),wr(i).link(a,o.path)}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}}function oi(e,t){e=H.call(this,e);let n={syscall:t?`lstat`:`stat`,path:e},r;if(!t)r=$r(this,e,!1,n).stats;else{let{base:t,dir:i}=_n(e),{fs:a,path:o}=$r(this,i,!1,n);try{let e=t?U(o,t):o;r=wr(a).get(e)?.inode??a.statSync(e)}catch(e){throw j(Object.assign(e,n)),e}}if(!r)throw N(`ENOENT`,n);if(Y&&!J(this,r,4))throw N(`EACCES`,n);return r}var si=class e{ino;type;_name;get name(){let e=lr.Buffer.from(this._name);return this._encoding==`buffer`?e:e.toString(this._encoding)}_encoding;_parentPath;get parentPath(){return this._parentPath}get path(){return R(`Dirent.path was removed in Node v24, use parentPath instead`),this._parentPath}static from(t,n,r=`.`){let i=new e,{base:a,dir:o}=_n(t.path);return i._parentPath=U(r,o),i._name=a,i.ino=t.ino,i.type=t.type,i._encoding=n,i}isFile(){return this.type===dr.REG}isDirectory(){return this.type===dr.DIR}isBlockDevice(){return this.type===dr.BLK}isCharacterDevice(){return this.type===dr.CHR}isSymbolicLink(){return this.type===dr.LNK}isFIFO(){return this.type===dr.FIFO}isSocket(){return this.type===dr.SOCK}};function ci(){return Object.assign(Error(`Directory handle was closed`),{code:`ERR_DIR_CLOSED`})}var li=class{path;context;closed=!1;checkClosed(){if(this.closed)throw ci()}_entries;constructor(e,t){this.path=e,this.context=t}close(e){if(this.closed){let t=ci();if(!e)return Promise.reject(t);e(t);return}if(this.closed=!0,!e)return Promise.resolve();e(null)}closeSync(){if(this.closed)throw ci();this.closed=!0}async _read(){return this.checkClosed(),this._entries??=await xo.call(this.context,this.path,{withFileTypes:!0}),this._entries.length?this._entries.shift()??null:null}read(e){if(!e)return this._read();this._read().then(t=>e(null,t))}readSync(){return this.checkClosed(),this._entries??=Fi.call(this.context,this.path,{withFileTypes:!0}),this._entries.length?this._entries.shift()??null:null}async next(){let e=await this._read();return e?{done:!1,value:e}:(await this.close(),{done:!0,value:void 0})}[Symbol.asyncIterator](){return this}[Symbol.dispose](){this.closed||this.closeSync()}async[Symbol.asyncDispose](){this.closed||await this.close()}},ui=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},di=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});function fi(e,t){return ii.call(this,e,t)}function pi(e){e=H(e);try{let{fs:t,path:n}=$r(this,e);return t.existsSync(n)}catch(e){if(e.errno==k.ENOENT)return!1;throw e}}function mi(e,t){let n=oi.call(this,e,!1);return t?.bigint?new Sn(n):new xn(n)}function hi(e,t){let n=oi.call(this,e,!0);return t?.bigint?new Sn(n):new xn(n)}function gi(e,t=0){let n={stack:[],error:void 0,hasError:!1};try{let r=ui(n,ei.call(this,e,{flag:`r+`}),!1);if(t||=0,t<0)throw N(`EINVAL`,`truncate`,e.toString());r.truncateSync(t)}catch(e){n.error=e,n.hasError=!0}finally{di(n)}}function _i(e){e=H(e);let{fs:t,path:n}=X(e,this);try{let e={stack:[],error:void 0,hasError:!1};try{if(Y&&!J(this,t.statSync(n),2))throw N(`EACCES`,`unlink`);ui(e,Er(t,W(n),`rw`),!1),t.unlinkSync(n),wr(t).remove(n)}catch(t){e.error=t,e.hasError=!0}finally{di(e)}}catch(t){throw j(Object.assign(t,{syscall:`unlink`,path:e}))}ua(this,`rename`,e.toString())}function vi(e,t,n=0){return Nr(ei.call(this,e,{flag:t,mode:n}))}function yi(e,t,n){return Nr(ei.call(this,e,{flag:t,mode:n,preserveSymlinks:!0}))}function bi(e,t={}){let n={stack:[],error:void 0,hasError:!1};try{let r=tn(t,null,`r`,420);if(Lr(r.flag)&1)throw N(`EBADF`,`read`,e.toString());let i=ui(n,typeof e==`number`?Pr(this,e):ei.call(this,e.toString(),{flag:r.flag,mode:420,preserveSymlinks:!1}),!1),{size:a}=i.stat(),o=lr.Buffer.alloc(a);return i.readSync(o,0,a,0),r.encoding?o.toString(r.encoding):o}catch(e){n.error=e,n.hasError=!0}finally{di(n)}}function xi(e,t,n={}){let r={stack:[],error:void 0,hasError:!1};try{let i=tn(n,`utf8`,`w+`,420),a=Lr(i.flag);if(!(a&1||a&2))throw new M(k.EINVAL,`Flag passed to writeFile must allow for writing`);if(typeof t!=`string`&&!i.encoding)throw new M(k.EINVAL,`Encoding not specified`);let o=typeof t==`string`?lr.Buffer.from(t,i.encoding):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(!o)throw new M(k.EINVAL,`Data not specified`);ui(r,typeof e==`number`?Pr(this,e):ei.call(this,e.toString(),{flag:a,mode:i.mode}),!1).writeSync(o,0,o.byteLength,0),ua(this,`change`,e.toString())}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Si(e,t,n={}){let r=tn(n,`utf8`,`a+`,420),i=Lr(r.flag);if(!(i&1024))throw new M(k.EINVAL,`Flag passed to appendFile must allow for appending`);if(typeof t!=`string`&&!r.encoding)throw new M(k.EINVAL,`Encoding not specified`);let a=typeof t==`string`?lr.Buffer.from(t,r.encoding):new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=typeof e==`number`?Pr(this,e):ei.call(this,H(e),{flag:i,mode:r.mode});o.writeSync(a,0,a.byteLength),typeof o!=`number`&&o.closeSync()}function Ci(e,t){let n=Pr(this,e).stat();return t?.bigint?new Sn(n):new xn(n)}function wi(e){Pr(this,e).closeSync(),Fr(this,e)}function Ti(e,t=0){if(t||=0,t<0)throw new M(k.EINVAL);Pr(this,e).truncateSync(t)}function Ei(e){Pr(this,e).syncSync()}function Di(e){Pr(this,e).datasyncSync()}function Oi(e,t,n,r,i){let a,o,s,c;if(typeof t==`string`){c=typeof n==`number`?n:null;let e=typeof r==`string`?r:`utf8`;o=0,a=lr.Buffer.from(t,e),s=a.byteLength}else a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=n,s=r,c=typeof i==`number`?i:null;let l=Pr(this,e);c??=l.position;let u=l.writeSync(a,o,s,c);return ua(this,`change`,l.path),u}function ki(e,t,n,r,i){let a=Pr(this,e),o=typeof n==`object`?n.offset:n;if(typeof n==`object`&&(r=n.length,i=n.position),i&&i>2**53-1)throw N(`EINVAL`);return typeof i==`bigint`&&(i=Number(i)),i=Number.isSafeInteger(i)?i:a.position,a.readSync(t,o,r,i)}function Ai(e,t,n){Pr(this,e).chownSync(t,n)}function ji(e,t){let n=Zt(t,-1);if(n<0)throw new M(k.EINVAL,`Invalid mode.`);Pr(this,e).chmodSync(n)}function Mi(e,t,n){Pr(this,e).utimesSync(en(t),en(n))}function Ni(e){let t={stack:[],error:void 0,hasError:!1};try{e=H(e);let{fs:n,path:r}=$r(this,e),i=Hr(n,`statSync`,{path:e,syscall:`rmdir`})(r);if(!q(i))throw N(`ENOTDIR`,`rmdir`,e);if(Y&&!J(this,i,2))throw N(`EACCES`,`rmdir`,e);ui(t,Er(n,W(r),`rw`),!1),Hr(n,`rmdirSync`,e)(r),wr(n).remove(r),ua(this,`rename`,e.toString())}catch(e){t.error=e,t.hasError=!0}finally{di(t)}}function Pi(e,t){t=typeof t==`object`?t:{mode:t};let n=Zt(t?.mode,511);return ni.call(this,e,{...t,mode:n})}function Fi(e,t){t=typeof t==`object`?t:{encoding:t},e=H(e);let n=[],r=ri.call(this,e,t??void 0);for(let i of r)t?.withFileTypes?n.push(si.from(i,t.encoding,e)):t?.encoding==`buffer`?n.push(lr.Buffer.from(i.path)):n.push(i.path);return n}function Ii(e,t){return ai.call(this,e,t)}function Li(e,t,n=`file`){let r={stack:[],error:void 0,hasError:!1};try{if(![`file`,`dir`,`junction`].includes(n))throw TypeError(`Invalid symlink type: `+n);t=H(t);let i=ui(r,ei.call(this,t,{flag:`wx`,mode:420}),!1);i.writeSync(T(H(e,!0))),i.chmodSync(Qe)}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Ri(e,t){let n=lr.Buffer.from(ti.call(this,e)),r=typeof t==`object`?t?.encoding:t;return r==`buffer`?n:n.toString(r??`utf-8`)}function zi(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{ui(r,ei.call(this,e,{flag:`r+`,mode:0}),!1).chownSync(t,n)}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Bi(e,t,n){let r=yi.call(this,e,`r+`);Ai.call(this,r,t,n),wi.call(this,r)}function Vi(e,t){let n;try{n=vi.call(this,e,`r+`)}catch(t){throw j(Object.assign(t,{syscall:`chmod`,path:H(e)}))}ji.call(this,n,t),wi.call(this,n)}function Hi(e,t){let n=yi.call(this,e,`r+`);ji.call(this,n,t),wi.call(this,n)}function Ui(e,t,n){let r=vi.call(this,e,`r+`);Mi.call(this,r,t,n),wi.call(this,r)}function Wi(e,t,n){let r=yi.call(this,e,`r+`);Mi.call(this,r,t,n),wi.call(this,r)}function Gi(e,t){let n=typeof t==`string`?t:t?.encoding??`utf8`;e=H(e,!0);let{fullPath:r}=$r(this,e);if(n==`utf8`||n==`utf-8`)return r;let i=lr.Buffer.from(r,`utf-8`);return n==`buffer`?i:i.toString(n)}function Ki(e,t=384){if(Y&&!J(this,mi.call(this,e),t))throw new M(k.EACCES)}function qi(e,t){e=H(e);let n;try{n=hi.bind(this)(e)}catch(e){if(e.code!=`ENOENT`||!t?.force)throw e}if(n)switch(n.mode&Xe){case tt:if(t?.recursive)for(let n of Fi.call(this,e))qi.call(this,U(e,n),t);Ni.call(this,e);break;case $e:case Qe:case et:case nt:_i.call(this,e);break;case rt:case Ze:default:throw N(`ENOSYS`,`rm`,e)}}function Ji(e,t){let n=typeof t==`object`?t?.encoding:t||`utf8`,r=an(e);return Pi.call(this,r),n==`buffer`?lr.Buffer.from(r):r}function Yi(e,t){let n=an(e);Pi.call(this,n);let r=()=>qi(n,{recursive:!0,force:!0});return{path:n,remove:r,[Symbol.dispose]:r}}function Xi(e,t,n){if(e=H(e),t=H(t),n&&n&1&&pi.call(this,t))throw N(`EEXIST`,`copyFile`,t);xi.call(this,t,bi.call(this,e)),ua(this,`rename`,t.toString())}function Zi(e,t,n){let r=Pr(this,e),i=0;for(let e of t)i+=r.readSync(e,0,e.byteLength,n+i);return i}function Qi(e,t,n){let r=Pr(this,e),i=0;for(let e of t)i+=r.writeSync(new Uint8Array(e.buffer),0,e.byteLength,n+i);return i}function $i(e,t){return e=H(e),new li(e,this)}function ea(e,t,n){e=H(e),t=H(t);let r=hi.call(this,e);if(n?.errorOnExist&&pi.call(this,t))throw N(`EEXIST`,`cp`,t);switch(r.mode&Xe){case tt:if(!n?.recursive)throw N(`EISDIR`,`cp`,e);Pi.call(this,t,{recursive:!0});for(let r of Fi.call(this,e,{withFileTypes:!0}))n.filter&&!n.filter(U(e,r.name),U(t,r.name))||ea.call(this,U(e,r.name),U(t,r.name),n);break;case Qe:if(n?.dereference)Xi.call(this,e,t);else{let r=Ri.call(this,e,`utf8`);Li.call(this,n?.verbatimSymlinks?r:un.call(this,W(e),r),t)}break;case $e:Xi.call(this,e,t);break;case et:case nt:case rt:case Ze:default:throw N(`ENOSYS`,`cp`,e)}n?.preserveTimestamps&&Ui.call(this,t,r.atime,r.mtime)}function ta(e,t){e=H(e);let{fs:n}=X(e,this);return qr(n,t?.bigint)}function na(e,t={}){e=Array.isArray(e)?e:[e];let{cwd:n=`/`,withFileTypes:r=!1,exclude:i=()=>!1}=t,a=e.map(e=>e.replace(/^\/+/g,``)),o=a.some(e=>e.includes(`**`)),s=a.map(e=>{let t=e.search(/[*?[\]{]/);if(t===-1)return e;let n=e.lastIndexOf(`/`,t);return n===-1?``:e.slice(0,n)}),c=a.map(nn),l=[];function u(e){let t=Fi(e,{withFileTypes:r,encoding:`utf8`});for(let n of t){let t=U(e,r?n.name:n);if(typeof i==`function`?i(r?n:t):i.some(e=>vn(e,t)))continue;let a=t.replace(/^\/+/g,``);mi(t).isDirectory()&&(o||s.some(e=>a===e||e.startsWith(a+`/`)))&&u(t),c.some(e=>e.test(a))&&l.push(r?n:a)}}return u(n instanceof URL?n.pathname:n),l}var ra=mi,ia=class extends u.default{_context;path;off(e,t,n,r){return super.off(e,t,n,r)}removeListener(e,t,n,r){return super.removeListener(e,t,n,r)}constructor(e,t){super(),this._context=e,this.path=t}setMaxListeners(){throw N(`ENOSYS`,`Watcher.setMaxListeners`)}getMaxListeners(){throw N(`ENOSYS`,`Watcher.getMaxListeners`)}prependListener(){throw N(`ENOSYS`,`Watcher.prependListener`)}prependOnceListener(){throw N(`ENOSYS`,`Watcher.prependOnceListener`)}rawListeners(){throw N(`ENOSYS`,`Watcher.rawListeners`)}ref(){return this}unref(){return this}},aa=class extends ia{options;realpath;constructor(e,t,n){let r=Le(e);super(r,t),this.options=n,this.realpath=U(r.root,t),ca(this.realpath,this)}close(){super.emit(`close`),la(this.realpath,this)}[Symbol.dispose](){this.close()}},oa=class extends ia{options;intervalId;previous;constructor(e,t,n){super(e,t),this.options=n,this.start()}onInterval(){try{let e=ra.call(this._context,this.path);Cn(this.previous,e)||(this.emit(`change`,e,this.previous),this.previous=e)}catch(e){this.emit(`error`,e)}}start(){let e=this.options.interval||5e3;try{this.previous=ra.call(this._context,this.path)}catch(e){this.emit(`error`,e);return}this.intervalId=setInterval(this.onInterval.bind(this),e),!this.options.persistent&&typeof this.intervalId==`object`&&this.intervalId.unref()}stop(){this.intervalId&&=(clearInterval(this.intervalId),void 0),this.removeAllListeners()}},sa=new Map;function ca(e,t){let n=H(e);sa.has(n)||sa.set(n,new Set),sa.get(n).add(t)}function la(e,t){let n=H(e);sa.has(n)&&(sa.get(n).delete(t),sa.get(n).size===0&&sa.delete(n))}function ua(e,t,n){let r=Le(e);r&&(n=U(r.root??`/`,n)),n=H(n);for(let e=n;;e=W(e)){let r=sa.get(e);if(r)for(let i of r)i.emit(`change`,t,pn.call(i._context,e,n)||mn(n));if(e===`/`)break}}var da=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},fa=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});async function pa(e,t,n,r){if(t=un.call(e,t),n){let n=X(t,e,r),i=wr(n.fs).get(n.path)?.inode??await n.fs.stat(n.path).catch(()=>void 0);return{...n,fullPath:t,stats:i}}try{let i=X(t,e),a=wr(i.fs).get(i.path)?.inode??await i.fs.stat(i.path);return Fn(a)?await pa(e,un.call(e,W(t),await ha.call(e,t)),n,r):{...i,fullPath:t,stats:a}}catch{}let{base:i,dir:a}=_n(t),o=a==`/`?`/`:(await pa(e,a,!1,r)).fullPath,s=U(o,i),c=X(s,e),l=wr(c.fs).get(c.path)?.inode??await c.fs.stat(c.path).catch(e=>{if(e.code!=`ENOENT`)throw j(Object.assign(e,{syscall:`stat`,path:s,...r}))});return l?Fn(l)?await pa(e,un.call(e,o,await ha.call(e,s)),!1,r):{...c,fullPath:s,stats:l}:{...c,fullPath:s}}async function ma(e,t,n){t=H(t);let r=Zt(n.mode,420),i=Lr(n.flag),a={syscall:`open`,path:t},{fs:o,path:s,stats:c}=await pa(e,t,n.preserveSymlinks,a);if(!c){let l={stack:[],error:void 0,hasError:!1};try{if(!(i&64))throw N(`ENOENT`,a);let u=W(s),d=await o.stat(u);if(Y&&!J(e,d,2))throw N(`EACCES`,`open`,W(t));if(!q(d))throw N(`ENOTDIR`,`open`,W(t));if(!n.allowDirectory&&r&16384)throw N(`EISDIR`,`open`,t);if(da(l,await Tr(o,u,`rw`,d),!1),c=wr(o).get(s)?.inode??await o.stat(s).catch(()=>void 0),!c){let{euid:n,egid:a}=Le(e).credentials,c=await o.createFile(s,{mode:r,uid:d.mode&2048?d.uid:n,gid:d.mode&1024?d.gid:a});return ua(e,`rename`,t),new Mr(e,t,s,i,wr(o).ref(s,c))}}catch(e){l.error=e,l.hasError=!0}finally{fa(l)}}if(Y&&!J(e,c,zr(i)))throw N(`EACCES`,a);if(i&128)throw N(`EEXIST`,a);if(!n.allowDirectory&&r&16384)throw N(`EISDIR`,`open`,t);let l=new Mr(e,t,s,i,wr(o).ref(s,c));return i&512&&await l.truncate(0),l}async function ha(e){e=H(e);let t={syscall:`readlink`,path:e},{fs:n,stats:r,path:i}=await pa(this,e,!0,t);if(!r)throw N(`ENOENT`,t);if(Y&&!J(this,r,4))throw N(`EACCES`,t);if(!Fn(r))throw N(`EINVAL`,t);let a=r.size,o=new Uint8Array(a);return await n.read(i,o,0,a),E(o)}async function ga(e,t={}){let n=H(e),{euid:r,egid:i}=Le(this).credentials,{mode:a=511,recursive:o}=t,s={syscall:`mkdir`,path:n},{fullPath:c}=await pa(this,W(n),!1,s),{fs:l,path:u}=X(U(c,mn(n)),this,s),d=c!=W(n),f,p=async(e,t)=>{let n={stack:[],error:void 0,hasError:!1};try{let c=W(t),m=o&&c!=`/`?await p(W(e),c):await l.stat(c);if(da(n,await Tr(l,c,`rw`,m),!1),o){let n=wr(l).get(t)?.inode??await l.stat(t).catch(()=>null);if(n){let r=Fn(n)?(await pa(this,e,!1,s)).stats:n;if(!r)throw N(`ENOENT`,s);if(!q(r))throw N(t==u?`EEXIST`:`ENOTDIR`,s);return n}if(d&&await l.exists(U(c,mn(e))))throw N(`ENOTDIR`,`mkdir`,e)}if(Y&&!J(this,m,2))throw N(`EACCES`,`mkdir`,e);let h=await l.mkdir(t,{mode:a,uid:m.mode&2048?m.uid:r,gid:m.mode&1024?m.gid:i}).catch(F({syscall:`mkdir`,path:e}));return o&&(f??=e),ua(this,`rename`,e),h}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}};return await p(n,u),f}async function _a(e,t={}){e=H(e);let n={syscall:`scandir`,path:e},{fs:r,path:i,stats:a}=await pa(this,e,!1,n);if(!a)throw N(`ENOENT`,n);if(Y&&!J(this,a,4))throw N(`EACCES`,n);if(!q(a))throw N(`ENOTDIR`,n);let o;{let e={stack:[],error:void 0,hasError:!1};try{da(e,await Tr(r,i,`ro`,a),!1),o=await r.readdir(i)}catch(t){e.error=t,e.hasError=!0}finally{fa(e)}}let s=[],c=async e=>{let n=await r.stat(U(i,e)).catch(e=>{if(e.code!=`ENOENT`)throw e});if(!n)return;let a=new mr;if(a.ino=n.ino,a.type=fr(n.mode),a.path=e,a.name=mn(e),s.push(a),!t.recursive||!q(n))return;let o=await r.readdir(U(i,e));for(let t of o)await c(U(e,t))};return await Promise.all(o.map(c)),s}async function va(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`rename`,path:e,dest:t},i=await pa(this,e,!0,r),a=X(t,this,r);if(i.fs.uuid!==a.fs.uuid)throw N(`EXDEV`,r);if(a.path.startsWith(i.path+`/`))throw N(`EINVAL`,r);if(!i.stats)throw N(`ENOENT`,r);let o=i.fs,s=await o.stat(W(i.path)),c=await o.stat(W(a.path)),l=await o.stat(a.path).catch(e=>{if(e.code==`ENOENT`)return null;throw e});if(Y&&(!J(this,s,4)||!J(this,c,2)))throw N(`EACCES`,r);if(l&&!q(i.stats)&&q(l))throw N(`EISDIR`,r);if(l&&q(i.stats)&&!q(l))throw N(`ENOTDIR`,r);let u=W(i.path),d=W(a.path),f=[[u,s],[d,c]];s.ino>c.ino&&f.reverse(),da(n,await Tr(o,f[0][0],`rw`,f[0][1]),!1),da(n,s.ino==c.ino?null:await Tr(o,f[1][0],`rw`,f[1][1]),!1),await i.fs.rename(i.path,a.path),wr(o).rename(i.path,a.path),ua(this,`rename`,e),ua(this,`rename`,t)}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}}async function ya(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`link`,path:e,dest:t},{fs:i,path:a}=X(e,this,r),o=X(t,this,r);if(i.uuid!=o.fs.uuid)throw N(`EXDEV`,r);let s=await i.stat(a);if(Y){if(!J(this,s,4))throw N(`EACCES`,r);let e=await i.stat(W(a));if(!J(this,e,4))throw N(`EACCES`,r);let t=await i.stat(W(o.path));if(!J(this,t,2))throw N(`EACCES`,r)}da(n,await Tr(i,W(o.path),`rw`),!1),await i.link(a,o.path),wr(i).link(a,o.path)}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}}async function ba(e,t){e=H.call(this,e);let n={syscall:t?`lstat`:`stat`,path:e},r;if(!t)r=(await pa(this,e,!1,n)).stats;else{let{base:t,dir:i}=_n(e),{fs:a,path:o}=await pa(this,i,!1,n),s=t?U(o,t):o;r=wr(a).get(s)?.inode??await a.stat(s).catch(F(n))}if(!r)throw N(`ENOENT`,n);if(Y&&!J(this,r,4))throw N(`EACCES`,n);return r}var xa=class extends u.default{input;output;terminal;line=``;_cursor=0;get cursor(){return this._cursor}_buffer=``;_closed=!1;_paused=!1;_prompt=``;_history=[];_historyIndex=-1;_currentLine=``;constructor(e,t,n,r=!1){super(),this.input=e,this.output=t,this.terminal=r,this.input.on(`data`,this._onData),this.input.on(`end`,this.close.bind(this)),this.input.on(`close`,this.close.bind(this))}_onData=e=>{if(!(this._paused||this._closed)){this._buffer+=typeof e==`string`?e:e.toString(`utf8`);for(let e=this._buffer.indexOf(`
1
+ import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{n as r,t as i}from"./safe-buffer-BwTVRVVo.js";function a(e,t){if(e.byteLength>=t)return e;if(ArrayBuffer.isView(e)){let n=a(e.buffer,t);return new e.constructor(n,e.byteOffset,t)}let n=typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer;if(e.maxByteLength>t)return n?e.grow(t):e.resize(t),e;if(n){let n=new SharedArrayBuffer(t);return new Uint8Array(n).set(new Uint8Array(e)),n}try{return e.transfer(t)}catch{let n=new ArrayBuffer(t);return new Uint8Array(n).set(new Uint8Array(e)),n}}var o=class extends DataView{constructor(e,t,n){let{buffer:r,byteOffset:i,byteLength:a}=new Uint8Array(e,t,n);super(r,i,a)}};for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(o.prototype,e,{value:()=>{throw ReferenceError(`Do not use DataView methods on a BufferView.`)},writable:!1,enumerable:!1,configurable:!1});var s=class{id;_size;options;regions=[];get size(){return this._size}set size(e){if(e>=this._size){this._size=e;return}this._size=e;for(let t=this.regions.length-1;t>=0;t--){let n=this.regions[t];if(n.offset>=e){this.regions.splice(t,1);continue}let r=e-n.offset;n.data.byteLength>r&&(n.data=n.data.subarray(0,r)),n.ranges=n.ranges.filter(t=>t.start<e).map(t=>t.end>e?{start:t.start,end:e}:t)}}constructor(e,t,n,r){this.id=e,this._size=t,this.options=n,n.sparse??=!0,n.sparse||this.regions.push({offset:0,data:new Uint8Array(t),ranges:[]}),r?.set(e,this)}collect(){if(!this.options.sparse)return;let{regionGapThreshold:e=4095}=this.options;for(let t=0;t<this.regions.length-1;){let n=this.regions[t],r=this.regions[t+1];if(r.offset-(n.offset+n.data.byteLength)>e){t++;continue}n.ranges.push(...r.ranges),n.ranges.sort((e,t)=>e.start-t.start),n.ranges=n.ranges.reduce((e,t)=>(!e.length||e.at(-1).end<t.start?e.push(t):e.at(-1).end=Math.max(e.at(-1).end,t.end),e),[]),n.data=a(n.data,r.offset+r.data.byteLength),n.data.set(r.data,r.offset-n.offset),this.regions.splice(t+1,1)}}missing(e,t){let n=[];for(let r of this.regions){if(r.offset>=t)break;for(let i of r.ranges)if(!(i.end<=e)&&(i.start>=t||(i.start>e&&n.push({start:e,end:Math.min(i.start,t)}),i.end>e&&(e=Math.max(e,i.end)),e>=t)))break;if(e>=t)break}return e<t&&n.push({start:e,end:t}),n}cached(e,t){let n=[];for(let r of this.regions){if(r.offset>=t)break;for(let i of r.ranges)if(!(i.end<=e)){if(i.start>=t)break;n.push({start:Math.max(e,i.start),end:Math.min(t,i.end)})}}n.sort((e,t)=>e.start-t.start);let r=[];for(let e of n){let t=r.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):r.push(e)}return r}regionAt(e){if(this.regions.length)for(let t of this.regions){if(t.offset>e)break;if(e>=t.offset&&e<t.offset+t.data.byteLength)return t}}add(e,t){let n=t+e.byteLength,r=this.regionAt(t);if(r)return r.data=a(r.data,n),r.data.set(e,t),r.ranges.push({start:t,end:n}),r.ranges.sort((e,t)=>e.start-t.start),this.collect(),this;let i={data:e,offset:t,ranges:[{start:t,end:n}]},o=this.regions.findIndex(e=>e.offset>t);return o==-1?this.regions.push(i):this.regions.splice(o,0,i),this.collect(),this}},c=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=t&1?2197175160^t>>>1:t>>>1;c[e]=t}function l(e){let t=4294967295;for(let n=0;n<e.length;n++)t=t>>>8^c[(t^e[n])&255];return(t^4294967295)>>>0}var u=e(n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),d=class extends u.default{[Symbol.toStringTag]=`List`;constructor(e){super(),e&&this.push(...e)}data=new Set;toSet(){return new Set(this.data)}toArray(){return Array.from(this.data)}toJSON(){return Array.from(this.data)}toString(){return this.join(`,`)}_set(e,t,n=!1){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not set an element outside the bounds of the list`);let r=Array.from(this.data);r.splice(e,+n,t),this.data=new Set(r),this.emit(`update`)}set(e,t){this._set(e,t,!0)}deleteAt(e){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not delete an element outside the bounds of the list`);this.delete(Array.from(this.data).at(e))}insert(e,t=this.data.size){this._set(t,e,!1)}at(e){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not access an element outside the bounds of the list`);return Array.from(this.data).at(e)}pop(){let e=Array.from(this.data).pop();return e!==void 0&&this.delete(e),e}push(...e){for(let t of e)this.add(t);return this.data.size}join(e){return Array.from(this.data).join(e)}splice(e,t,...n){if(Math.abs(e)>this.data.size)throw ReferenceError(`Can not splice elements outside the bounds of the list`);let r=Array.from(this.data),i=r.splice(e,t,...n);return this.data=new Set(r),this.emit(`update`),i}add(e){return this.data.add(e),this.emit(`update`),this.emit(`add`,e),this}clear(){this.data.clear(),this.emit(`update`)}delete(e){let t=this.data.delete(e);return this.emit(`update`),t}has(e){return this.data.has(e)}get size(){return this.data.size}entries(){return this.toArray().entries()}keys(){return this.toArray().keys()}values(){return this.data.values()}[Symbol.iterator](){return this.data[Symbol.iterator]()}};function f(e,t){let n=Object.entries(e);return Object.fromEntries(n.filter(([e,n])=>t(e,n)))}function p(e,...t){let n={};for(let r of t.flat())n[r]=e[r];return n}function m(e,...t){return f(e,e=>!t.flat().includes(e))}function h(e){try{return JSON.parse(e),!0}catch{return!1}}function g(e){let t=[];for(let n=e;n&&![`Function`,`Object`].includes(n.constructor.name);n=Object.getPrototypeOf(n))t.push(n.constructor.name);return t}function _(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,typeof n==`function`?n.bind(t):n]))}function v(e=Error()){let t=setTimeout(()=>{throw e},5e3);return()=>clearTimeout(t)}function y(e){throw e&&typeof e==`object`&&g(e).includes(`Error`)&&Error?.captureStackTrace(e,y),e}function b(e,t){if(![`getter`,`accessor`].includes(t.kind))throw Error(`@memoize can only be used on getters and auto-accessors`);let n=new WeakMap;function r(){if(n.has(this))return n.get(this);let t=typeof e==`function`?e.call(this):e.get.call(this);return n.set(this,t),t}switch(t.kind){case`getter`:return r;case`accessor`:return{...e,get:r}}}var x=Intl.NumberFormat(`en`,{notation:`compact`});x.format.bind(x);function S(e=0,t=1){return Math.round(Math.random()*(t-e)+e)}function C(e){return e.at(0).toUpperCase()+e.slice(1)}var w=new TextEncoder;function T(e){return w.encode(e)}var ee=new TextDecoder;function E(e){if(!e)return``;if(e.buffer instanceof ArrayBuffer&&!e.buffer.resizable)return ee.decode(e);let t=new Uint8Array(e.byteLength);return t.set(e),ee.decode(t)}function te(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function ne(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}function D(e){let t=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function O(e){let t=e.replace(/-/g,``),n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}var k;(function(e){e[e.EPERM=1]=`EPERM`,e[e.ENOENT=2]=`ENOENT`,e[e.ESRCH=3]=`ESRCH`,e[e.EINTR=4]=`EINTR`,e[e.EIO=5]=`EIO`,e[e.ENXIO=6]=`ENXIO`,e[e.E2BIG=7]=`E2BIG`,e[e.ENOEXEC=8]=`ENOEXEC`,e[e.EBADF=9]=`EBADF`,e[e.ECHILD=10]=`ECHILD`,e[e.EAGAIN=11]=`EAGAIN`,e[e.ENOMEM=12]=`ENOMEM`,e[e.EACCES=13]=`EACCES`,e[e.EFAULT=14]=`EFAULT`,e[e.ENOTBLK=15]=`ENOTBLK`,e[e.EBUSY=16]=`EBUSY`,e[e.EEXIST=17]=`EEXIST`,e[e.EXDEV=18]=`EXDEV`,e[e.ENODEV=19]=`ENODEV`,e[e.ENOTDIR=20]=`ENOTDIR`,e[e.EISDIR=21]=`EISDIR`,e[e.EINVAL=22]=`EINVAL`,e[e.ENFILE=23]=`ENFILE`,e[e.EMFILE=24]=`EMFILE`,e[e.ETXTBSY=26]=`ETXTBSY`,e[e.EFBIG=27]=`EFBIG`,e[e.ENOSPC=28]=`ENOSPC`,e[e.ESPIPE=29]=`ESPIPE`,e[e.EROFS=30]=`EROFS`,e[e.EMLINK=31]=`EMLINK`,e[e.EPIPE=32]=`EPIPE`,e[e.EDOM=33]=`EDOM`,e[e.ERANGE=34]=`ERANGE`,e[e.EDEADLK=35]=`EDEADLK`,e[e.ENAMETOOLONG=36]=`ENAMETOOLONG`,e[e.ENOLCK=37]=`ENOLCK`,e[e.ENOSYS=38]=`ENOSYS`,e[e.ENOTEMPTY=39]=`ENOTEMPTY`,e[e.ELOOP=40]=`ELOOP`,e[e.ENOMSG=42]=`ENOMSG`,e[e.EIDRM=43]=`EIDRM`,e[e.ECHRNG=44]=`ECHRNG`,e[e.EL2NSYNC=45]=`EL2NSYNC`,e[e.EL3HLT=46]=`EL3HLT`,e[e.EL3RST=47]=`EL3RST`,e[e.ENRNG=48]=`ENRNG`,e[e.EUNATCH=49]=`EUNATCH`,e[e.ECSI=50]=`ECSI`,e[e.EL2HLT=51]=`EL2HLT`,e[e.EBADE=52]=`EBADE`,e[e.EBADR=53]=`EBADR`,e[e.EXFULL=54]=`EXFULL`,e[e.ENOANO=55]=`ENOANO`,e[e.EBADRQC=56]=`EBADRQC`,e[e.EBADSLT=57]=`EBADSLT`,e[e.EBFONT=59]=`EBFONT`,e[e.ENOSTR=60]=`ENOSTR`,e[e.ENODATA=61]=`ENODATA`,e[e.ETIME=62]=`ETIME`,e[e.ENOSR=63]=`ENOSR`,e[e.ENONET=64]=`ENONET`,e[e.ENOPKG=65]=`ENOPKG`,e[e.EREMOTE=66]=`EREMOTE`,e[e.ENOLINK=67]=`ENOLINK`,e[e.EADV=68]=`EADV`,e[e.ESRMNT=69]=`ESRMNT`,e[e.ECOMM=70]=`ECOMM`,e[e.EPROTO=71]=`EPROTO`,e[e.EMULTIHOP=72]=`EMULTIHOP`,e[e.EDOTDOT=73]=`EDOTDOT`,e[e.EBADMSG=74]=`EBADMSG`,e[e.EOVERFLOW=75]=`EOVERFLOW`,e[e.ENOTUNIQ=76]=`ENOTUNIQ`,e[e.EBADFD=77]=`EBADFD`,e[e.EREMCHG=78]=`EREMCHG`,e[e.ELIBACC=79]=`ELIBACC`,e[e.ELIBBAD=80]=`ELIBBAD`,e[e.ELIBSCN=81]=`ELIBSCN`,e[e.ELIBMAX=82]=`ELIBMAX`,e[e.ELIBEXEC=83]=`ELIBEXEC`,e[e.EILSEQ=84]=`EILSEQ`,e[e.ERESTART=85]=`ERESTART`,e[e.ESTRPIPE=86]=`ESTRPIPE`,e[e.EUSERS=87]=`EUSERS`,e[e.ENOTSOCK=88]=`ENOTSOCK`,e[e.EDESTADDRREQ=89]=`EDESTADDRREQ`,e[e.EMSGSIZE=90]=`EMSGSIZE`,e[e.EPROTOTYPE=91]=`EPROTOTYPE`,e[e.ENOPROTOOPT=92]=`ENOPROTOOPT`,e[e.EPROTONOSUPPORT=93]=`EPROTONOSUPPORT`,e[e.ESOCKTNOSUPPORT=94]=`ESOCKTNOSUPPORT`,e[e.ENOTSUP=95]=`ENOTSUP`,e[e.EPFNOSUPPORT=96]=`EPFNOSUPPORT`,e[e.EAFNOSUPPORT=97]=`EAFNOSUPPORT`,e[e.EADDRINUSE=98]=`EADDRINUSE`,e[e.EADDRNOTAVAIL=99]=`EADDRNOTAVAIL`,e[e.ENETDOWN=100]=`ENETDOWN`,e[e.ENETUNREACH=101]=`ENETUNREACH`,e[e.ENETRESET=102]=`ENETRESET`,e[e.ECONNABORTED=103]=`ECONNABORTED`,e[e.ECONNRESET=104]=`ECONNRESET`,e[e.ENOBUFS=105]=`ENOBUFS`,e[e.EISCONN=106]=`EISCONN`,e[e.ENOTCONN=107]=`ENOTCONN`,e[e.ESHUTDOWN=108]=`ESHUTDOWN`,e[e.ETOOMANYREFS=109]=`ETOOMANYREFS`,e[e.ETIMEDOUT=110]=`ETIMEDOUT`,e[e.ECONNREFUSED=111]=`ECONNREFUSED`,e[e.EHOSTDOWN=112]=`EHOSTDOWN`,e[e.EHOSTUNREACH=113]=`EHOSTUNREACH`,e[e.EALREADY=114]=`EALREADY`,e[e.EINPROGRESS=115]=`EINPROGRESS`,e[e.ESTALE=116]=`ESTALE`,e[e.EEUCLEAN=117]=`EEUCLEAN`,e[e.ENOTNAM=118]=`ENOTNAM`,e[e.ENAVAIL=119]=`ENAVAIL`,e[e.EISNAM=120]=`EISNAM`,e[e.EREMOTEIO=121]=`EREMOTEIO`,e[e.EDQUOT=122]=`EDQUOT`,e[e.ENOMEDIUM=123]=`ENOMEDIUM`,e[e.EMEDIUMTYPE=124]=`EMEDIUMTYPE`,e[e.ECANCELED=125]=`ECANCELED`,e[e.ENOKEY=126]=`ENOKEY`,e[e.EKEYEXPIRED=127]=`EKEYEXPIRED`,e[e.EKEYREVOKED=128]=`EKEYREVOKED`,e[e.EKEYREJECTED=129]=`EKEYREJECTED`,e[e.EOWNERDEAD=130]=`EOWNERDEAD`,e[e.ENOTRECOVERABLE=131]=`ENOTRECOVERABLE`,e[e.ERFKILL=132]=`ERFKILL`,e[e.EHWPOISON=133]=`EHWPOISON`})(k||={});var A={[k.EPERM]:`operation not permitted`,[k.ENOENT]:`no such file or directory`,[k.ESRCH]:`no such process`,[k.EINTR]:`interrupted system call`,[k.EIO]:`i/o error`,[k.ENXIO]:`no such device or address`,[k.E2BIG]:`argument list too long`,[k.ENOEXEC]:`exec format error`,[k.EBADF]:`bad file descriptor`,[k.ECHILD]:`no child processes`,[k.EAGAIN]:`resource temporarily unavailable`,[k.ENOMEM]:`not enough memory`,[k.EACCES]:`permission denied`,[k.EFAULT]:`bad address in system call argument`,[k.ENOTBLK]:`block device required`,[k.EBUSY]:`resource busy or locked`,[k.EEXIST]:`file already exists`,[k.EXDEV]:`cross-device link not permitted`,[k.ENODEV]:`no such device`,[k.ENOTDIR]:`not a directory`,[k.EISDIR]:`illegal operation on a directory`,[k.EINVAL]:`invalid argument`,[k.ENFILE]:`file table overflow`,[k.EMFILE]:`too many open files`,[k.ETXTBSY]:`text file is busy`,[k.EFBIG]:`file too large`,[k.ENOSPC]:`no space left on device`,[k.ESPIPE]:`invalid seek`,[k.EROFS]:`read-only file system`,[k.EMLINK]:`too many links`,[k.EPIPE]:`broken pipe`,[k.EDOM]:`numerical argument out of domain`,[k.ERANGE]:`result too large`,[k.EDEADLK]:`resource deadlock would occur`,[k.ENAMETOOLONG]:`name too long`,[k.ENOLCK]:`no locks available`,[k.ENOSYS]:`function not implemented`,[k.ENOTEMPTY]:`directory not empty`,[k.ELOOP]:`too many symbolic links encountered`,[k.ENOMSG]:`no message of desired type`,[k.EIDRM]:`identifier removed`,[k.ECHRNG]:`channel number out of range`,[k.EL2NSYNC]:`level 2 not synchronized`,[k.EL3HLT]:`level 3 halted`,[k.EL3RST]:`level 3 reset`,[k.ENRNG]:`link number out of range`,[k.EUNATCH]:`protocol driver not attached`,[k.ECSI]:`no CSI structure available`,[k.EL2HLT]:`level 2 halted`,[k.EBADE]:`invalid exchange`,[k.EBADR]:`invalid request descriptor`,[k.EXFULL]:`exchange full`,[k.ENOANO]:`no anode`,[k.EBADRQC]:`invalid request code`,[k.EBADSLT]:`invalid slot`,[k.EBFONT]:`bad font file format`,[k.ENOSTR]:`device not a stream`,[k.ENODATA]:`no data available`,[k.ETIME]:`timer expired`,[k.ENOSR]:`out of streams resources`,[k.ENONET]:`machine is not on the network`,[k.ENOPKG]:`package not installed`,[k.EREMOTE]:`object is remote`,[k.ENOLINK]:`link has been severed`,[k.EADV]:`advertise error`,[k.ESRMNT]:`srmount error`,[k.ECOMM]:`communication error on send`,[k.EPROTO]:`protocol error`,[k.EMULTIHOP]:`multihop attempted`,[k.EDOTDOT]:`rFS specific error`,[k.EBADMSG]:`bad message`,[k.EOVERFLOW]:`value too large for defined data type`,[k.ENOTUNIQ]:`name not unique on network`,[k.EBADFD]:`file descriptor in bad state`,[k.EREMCHG]:`remote address changed`,[k.ELIBACC]:`can not access a needed shared library`,[k.ELIBBAD]:`accessing a corrupted shared library`,[k.ELIBSCN]:`.lib section in a.out corrupted`,[k.ELIBMAX]:`attempting to link in too many shared libraries`,[k.ELIBEXEC]:`cannot exec a shared library directly`,[k.EILSEQ]:`illegal byte sequence`,[k.ERESTART]:`interrupted system call should be restarted`,[k.ESTRPIPE]:`streams pipe error`,[k.EUSERS]:`too many users`,[k.ENOTSOCK]:`socket operation on non-socket`,[k.EDESTADDRREQ]:`destination address required`,[k.EMSGSIZE]:`message too long`,[k.EPROTOTYPE]:`protocol wrong type for socket`,[k.ENOPROTOOPT]:`protocol not available`,[k.EPROTONOSUPPORT]:`protocol not supported`,[k.ESOCKTNOSUPPORT]:`socket type not supported`,[k.ENOTSUP]:`operation not supported on socket`,[k.EPFNOSUPPORT]:`protocol family not supported`,[k.EAFNOSUPPORT]:`address family not supported`,[k.EADDRINUSE]:`address already in use`,[k.EADDRNOTAVAIL]:`address not available`,[k.ENETDOWN]:`network is down`,[k.ENETUNREACH]:`network is unreachable`,[k.ENETRESET]:`network dropped connection on reset`,[k.ECONNABORTED]:`software caused connection abort`,[k.ECONNRESET]:`connection reset by peer`,[k.ENOBUFS]:`no buffer space available`,[k.EISCONN]:`socket is already connected`,[k.ENOTCONN]:`socket is not connected`,[k.ESHUTDOWN]:`cannot send after transport endpoint shutdown`,[k.ETOOMANYREFS]:`too many references: cannot splice`,[k.ETIMEDOUT]:`connection timed out`,[k.ECONNREFUSED]:`connection refused`,[k.EHOSTDOWN]:`host is down`,[k.EHOSTUNREACH]:`host is unreachable`,[k.EALREADY]:`connection already in progress`,[k.EINPROGRESS]:`operation now in progress`,[k.ESTALE]:`stale file handle`,[k.EEUCLEAN]:`structure needs cleaning`,[k.ENOTNAM]:`not a XENIX named type file`,[k.ENAVAIL]:`no XENIX semaphores available`,[k.EISNAM]:`is a named type file`,[k.EREMOTEIO]:`remote I/O error`,[k.EDQUOT]:`disk quota exceeded`,[k.ENOMEDIUM]:`no medium found`,[k.EMEDIUMTYPE]:`wrong medium type`,[k.ECANCELED]:`operation canceled`,[k.ENOKEY]:`required key not available`,[k.EKEYEXPIRED]:`key has expired`,[k.EKEYREVOKED]:`key has been revoked`,[k.EKEYREJECTED]:`key was rejected by service`,[k.EOWNERDEAD]:`owner died`,[k.ENOTRECOVERABLE]:`state not recoverable`,[k.ERFKILL]:`operation not possible due to RF-kill`,[k.EHWPOISON]:`memory page has hardware error`};function j(e){let t=`${e.code}: ${A[e.errno]}, ${e.syscall}`;e.path&&(t+=` '${e.path}'`),e.dest&&(t+=` -> '${e.dest}'`);let n=e.message.startsWith(A[e.errno])||/^E[A-Z0-9]+: /.test(e.message);return e.message&&!n&&(t+=` (${e.message})`),e.message=t,e}var M=class e extends Error{errno;code;path;dest;syscall;constructor(e,t,n={}){let r=k[e];super(t||``),this.errno=e,this.code=r,Object.assign(this,m(n,`message`)),t||j(this),Error.captureStackTrace?.(this,this.constructor)}toString(){return this.message}toJSON(){let e={errno:this.errno,code:this.code,stack:this.stack,message:this.message};return this.path&&(e.path=this.path),this.dest&&(e.dest=this.dest),this.syscall&&(e.syscall=this.syscall),e}static fromJSON(t){let n=t.syscall?new e(t.errno,!1,t):new e(t.errno,t.message);return n.stack=t.stack,n}};function N(e,t,n,r){typeof t==`string`&&(t={syscall:t,path:n,dest:r});let i=new M(k[e],!1,t??{});return Error.captureStackTrace?.(i,N),i}function P(e,t){let n=new M(k[e],t??A[k[e]]);return Error.captureStackTrace?.(n,P),n}function F(e,t,n){let r=typeof e==`string`?{syscall:e}:e;return t&&(r.path=t),n&&(r.dest=n),function(e){throw Object.assign(e,r),j(e),e}}var re=t({Level:()=>I,alert:()=>ue,configure:()=>De,crit:()=>de,debug:()=>me,deprecated:()=>he,emerg:()=>le,entries:()=>oe,err:()=>L,fancy:()=>be,format:()=>z,info:()=>pe,isEnabled:()=>Ee,levelOf:()=>ae,levels:()=>ie,log:()=>se,notice:()=>fe,warn:()=>R}),I;(function(e){e[e.EMERG=0]=`EMERG`,e[e.ALERT=1]=`ALERT`,e[e.CRIT=2]=`CRIT`,e[e.ERR=3]=`ERR`,e[e.WARN=4]=`WARN`,e[e.NOTICE=5]=`NOTICE`,e[e.INFO=6]=`INFO`,e[e.DEBUG=7]=`DEBUG`})(I||={});var ie=[`emergency`,`alert`,`critical`,`error`,`warning`,`notice`,`info`,`debug`];function ae(e){return ie.indexOf(e)}var oe=new d;function se(e,t){if(!Ee)return;let n={level:e,message:t,timestamp:new Date,elapsedMs:performance.now()};if(oe.size>=1e4){let e=oe.values().next().value;e!==void 0&&oe.delete(e)}oe.add(n),Ce(n)}function ce(e){return function(t){return se(e,t.toString()),t}}var le=ce(I.EMERG),ue=ce(I.ALERT),de=ce(I.CRIT),L=ce(I.ERR),R=ce(I.WARN),fe=ce(I.NOTICE),pe=ce(I.INFO),me=ce(I.DEBUG);function he(e){se(I.WARN,e+` is deprecated and should not be used.`)}function ge(e,t){return`\x1b[${t}m${e}\x1b[0m`}function _e(e){return`[`+(e.elapsedMs/1e3).toFixed(3).padStart(10)+`] `}var ve={ansi:{[I.EMERG]:`1;4;37;41`,[I.ALERT]:`1;37;41`,[I.CRIT]:`1;35`,[I.ERR]:`1;31`,[I.WARN]:`1;33`,[I.NOTICE]:`1;36`,[I.INFO]:`1;37`,[I.DEBUG]:`0;2;37`},css:{[I.EMERG]:`font-weight: bold; text-decoration: underline; color: white; background-color: red;`,[I.ALERT]:`font-weight: bold; color: white; background-color: red;`,[I.CRIT]:`font-weight: bold; color: magenta;`,[I.ERR]:`font-weight: bold; color: red;`,[I.WARN]:`font-weight: bold; color: yellow;`,[I.NOTICE]:`font-weight: bold; color: cyan;`,[I.INFO]:`font-weight: bold; color: white;`,[I.DEBUG]:`opacity: 0.8; color: white;`}},ye={ansi:{[I.EMERG]:`1;31`,[I.ALERT]:`1;31`,[I.CRIT]:`1;31`,[I.ERR]:`31`,[I.WARN]:`33`,[I.NOTICE]:`1;37`,[I.INFO]:`37`,[I.DEBUG]:`2;37`},css:{[I.EMERG]:`font-weight: bold; color: red;`,[I.ALERT]:`font-weight: bold; color: red;`,[I.CRIT]:`font-weight: bold; color: red;`,[I.ERR]:`color: red;`,[I.WARN]:`color: yellow;`,[I.NOTICE]:`font-weight: bold; color: white;`,[I.INFO]:`color: white;`,[I.DEBUG]:`opacity: 0.8; color: white;`}};function be({style:e,colorize:t}){return function*(n){e==`css`&&(yield t==`level`?`%c%s %c%s`:`%c%s %c%s%s %c%s`),yield*e==`ansi`?[ge(_e(n),`2;37`)]:[`opacity: 0.8; color: white;`,_e(n)];let r=e==`ansi`?[ge(ie[n.level].toUpperCase(),ve.ansi[n.level])]:[ve.css[n.level],ie[n.level].toUpperCase()];if(t==`level`){yield*r,yield n.message;return}n.level<I.CRIT&&(yield*r),e==`ansi`?yield ge(n.message,ye.ansi[n.level]):yield*[ye.css[n.level],n.message]}}var xe=e=>[_e(e),e.message];function z(e){let t=xe(e);return typeof t==`string`?[t]:Array.from(t)}var Se=console.error;function Ce(e){e.level>we||Se(...z(e))}var we=I.ALERT,Te=!1,Ee=!0;function De(e){if(xe=e.format??xe,Se=e.output??Se,we=typeof e.level==`string`?ae(e.level):e.level??we,Ee=e.enabled??Ee,Te=e.stack??Te,e.dumpBacklog)for(let e of oe)Ce(e)}function Oe(e){return typeof e==`object`&&!!e&&`create`in e&&typeof e.create==`function`}function ke(e,t){return Object.defineProperty(t,"prototype",{value:void 0}),e&&Object.defineProperty(t,"name",{value:e}),t}function Ae(e){return!(e&&e.constructor===Function)||e.prototype===void 0?!1:Function.prototype!==Object.getPrototypeOf(e)||Object.getOwnPropertyNames(e.prototype).length>1}function je(e,t){if(typeof t!=`object`||!t)throw L(P(`EINVAL`,`Invalid options`));for(let[n,r]of Object.entries(e.options)){let e=t?.[n];if(e==null){if(!r.required){me(`Using default for option: `+n);continue}throw L(P(`EINVAL`,`Missing required option: `+n))}let i=(t,n=e)=>typeof t==`function`?Ae(t)?e instanceof t:t(e):typeof e===t||e?.constructor?.name===t;if(Array.isArray(r.type)?r.type.some(e=>i(e)):i(r.type))continue;let a=typeof e==`object`&&`constructor`in e?e.constructor.name:typeof e,o=e=>typeof e==`function`?e.name==`type`?e.toString():e.name:e;throw L(P(`EINVAL`,`Incorrect type for "${n}": ${a} (expected ${Array.isArray(r.type)?`one of ${r.type.map(o).join(`, `)}`:o(r.type)})`))}}function Me(e){return typeof e==`object`&&!!e&&`backend`in e&&Oe(e.backend)}function Ne(e){return{suid:e.uid,sgid:e.gid,euid:e.uid,egid:e.gid,groups:[],...e}}function Pe(e){return e?!e.uid||!e.gid||!e.euid||!e.egid||e.groups.some(e=>!e):!1}var Fe=Symbol(`ZenFSContext`),Ie={[Fe]:!0,id:0,root:`/`,pwd:`/`,credentials:Ne({uid:0,gid:0}),descriptors:new Map,parent:null,children:[]};function Le(e){return typeof e==`object`&&e&&Fe in e?e:Ie}var Re=1;function ze(e,t={}){let{root:n=e.root,pwd:r=e.pwd,credentials:i=structuredClone(e.credentials)}=t,a={[Fe]:!0,id:Re++,root:n,pwd:r,credentials:Ne(i),descriptors:new Map,parent:e,children:[]};return Object.defineProperties(a,{id:{configurable:!1,writable:!1},credentials:{configurable:!1,writable:!1},descriptors:{configurable:!1,writable:!1},parent:{configurable:!1,writable:!1},children:{configurable:!1,writable:!1}}),a}var Be=t({COPYFILE_EXCL:()=>1,COPYFILE_FICLONE:()=>2,COPYFILE_FICLONE_FORCE:()=>4,F_OK:()=>0,O_APPEND:()=>Ve,O_CREAT:()=>64,O_DIRECT:()=>Je,O_DIRECTORY:()=>He,O_DSYNC:()=>Ke,O_EXCL:()=>128,O_NOATIME:()=>Ue,O_NOCTTY:()=>256,O_NOFOLLOW:()=>We,O_NONBLOCK:()=>Ye,O_RDONLY:()=>0,O_RDWR:()=>2,O_SYMLINK:()=>qe,O_SYNC:()=>Ge,O_TRUNC:()=>512,O_WRONLY:()=>1,R_OK:()=>4,S_IFBLK:()=>et,S_IFCHR:()=>nt,S_IFDIR:()=>tt,S_IFIFO:()=>rt,S_IFLNK:()=>Qe,S_IFMT:()=>Xe,S_IFREG:()=>$e,S_IFSOCK:()=>Ze,S_IRGRP:()=>32,S_IROTH:()=>4,S_IRUSR:()=>256,S_IRWXG:()=>56,S_IRWXO:()=>7,S_IRWXU:()=>448,S_ISGID:()=>at,S_ISUID:()=>it,S_ISVTX:()=>512,S_IWGRP:()=>16,S_IWOTH:()=>2,S_IWUSR:()=>128,S_IXGRP:()=>8,S_IXOTH:()=>1,S_IXUSR:()=>64,UV_FS_O_FILEMAP:()=>0,W_OK:()=>2,X_OK:()=>1,size_max:()=>ot}),Ve=1024,He=65536,Ue=262144,We=131072,Ge=1052672,Ke=4096,qe=32768,Je=16384,Ye=2048,Xe=61440,Ze=49152,Qe=40960,$e=32768,et=24576,tt=16384,nt=8192,rt=4096,it=2048,at=1024,ot=4294967295;function st(e){return`__isArrayType`in e&&e.__isArrayType===!0}function ct(e){return typeof e!=`object`&&typeof e!=`function`||e==null?!1:st(e)?ct(e.type):`name`in e&&`size`in e&&`get`in e&&`set`in e&&typeof e.name==`string`&&typeof e.size==`number`&&typeof e.get==`function`&&typeof e.set==`function`&&lt.has(e.name)&&lt.get(e.name)?.name===e.name}var lt=new Map;function ut(e){if(lt.has(e.name))throw ReferenceError(`Type is already registered: ${e.name}`);lt.set(e.name,e)}var dt=Symbol(`DataView`);function ft(e){return e[dt]??=new DataView(e),e[dt]}var pt={name:`int8`,size:1,array:Int8Array,get:(e,t)=>ft(e).getInt8(t),set:(e,t,n)=>ft(e).setInt8(t,n)},mt={name:`uint8`,size:1,array:Uint8Array,get:(e,t)=>ft(e).getUint8(t),set:(e,t,n)=>ft(e).setUint8(t,n)},ht={int8:pt,uint8:mt,int16:{name:`int16`,size:2,array:Int16Array,get:(e,t)=>ft(e).getInt16(t,!0),set:(e,t,n)=>ft(e).setInt16(t,n,!0)},uint16:{name:`uint16`,size:2,array:Uint16Array,get:(e,t)=>ft(e).getUint16(t,!0),set:(e,t,n)=>ft(e).setUint16(t,n,!0)},int32:{name:`int32`,size:4,array:Int32Array,get:(e,t)=>ft(e).getInt32(t,!0),set:(e,t,n)=>ft(e).setInt32(t,n,!0)},uint32:{name:`uint32`,size:4,array:Uint32Array,get:(e,t)=>ft(e).getUint32(t,!0),set:(e,t,n)=>ft(e).setUint32(t,n,!0)},int64:{name:`int64`,size:8,array:BigInt64Array,get:(e,t)=>ft(e).getBigInt64(t,!0),set:(e,t,n)=>ft(e).setBigInt64(t,n,!0)},uint64:{name:`uint64`,size:8,array:BigUint64Array,get:(e,t)=>ft(e).getBigUint64(t,!0),set:(e,t,n)=>ft(e).setBigUint64(t,n,!0)},float32:{name:`float32`,size:4,array:Float32Array,get:(e,t)=>ft(e).getFloat32(t,!0),set:(e,t,n)=>ft(e).setFloat32(t,n,!0)},float64:{name:`float64`,size:8,array:Float64Array,get:(e,t)=>ft(e).getFloat64(t,!0),set:(e,t,n)=>ft(e).setFloat64(t,n,!0)}},gt=Object.keys(ht);for(let e of Object.values(ht))ut(e);var _t={...ht,...Object.fromEntries(gt.map(e=>[C(e),ht[e]])),char:mt},vt=Object.keys(_t);function yt(e){return vt.includes(e.toString())}function bt(e){if(!yt(e))throw P(`EINVAL`,`Not a valid primitive type: `+e)}function xt(e){return e==`char`?`uint8`:e.toLowerCase()}function St(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&`toInit`in e&&typeof e.toInit==`function`}function Ct(e){return St(e)?e.toInit():ct(e)?{type:e}:e}function wt(e,t,n={}){if(!e)throw P(`EINVAL`,`Invalid name for struct field`);typeof e==`symbol`&&console.warn(`Symbol used for struct field name will be coerced to string: `+e.toString());let r=e.toString(),i=Object.assign(Ct(t),n);if(!ct(i.type))throw P(`EINVAL`,`Invalid type for struct field "${r}"`);let a=i.countedBy?` counted_by(${typeof i.countedBy==`string`?i.countedBy:`<function>`})`:``;return{name:r,offset:0,type:i.type,countedBy:i.countedBy,alignment:i.align??i.type.size,decl:i.type instanceof Bt?`${i.typeName??i.type.type.name} ${r}[${i.type.length}]${a}`:`${i.typeName??i.type.name} ${r}`,littleEndian:!i.bigEndian}}function Tt(e,t){if(!(e instanceof Error)||e.message.toLowerCase()!==`offset is outside the bounds of the dataview`)throw e;let n=P(`EFAULT`,`Segmentation fault (at 0x${t.toString(16)})`);throw Error.captureStackTrace(n,Tt),n}function Et(e,t){return t.type instanceof Bt&&t.type.length==0&&!!t.countedBy?.length&&!!e.constructor.isDynamic}function Dt(e,t){let n=typeof t.countedBy==`function`?t.countedBy(e):e[t.countedBy];if(typeof n==`bigint`){if(n>BigInt(2**53-1))throw P(`EOVERFLOW`,`countedBy field value exceeds max safe integer`);n=Number(n)}if(typeof n!=`number`)throw P(`EINVAL`,`countedBy field value is not a number`);return n}function Ot(e,t){let n=t.type.type.size*Dt(e,t);if(Pt(t.type.type)&&t.type.type.isDynamic)for(let r of e[t.name])n+=Ft(r);return n}var kt=Symbol(`kOffsets`);function At(e,t,n){let{offset:r,name:i}=t;e[kt]||=Object.create(null);let a=e[kt];if(a[i]!==void 0){if(n)return a[i];delete a[i]}let{fields:o}=e.constructor,s=o.indexOf(t);for(let t of o.slice(0,s)){Et(e,t)&&(r+=Ot(e,t));let n=e[t.name];Nt(n)&&n.constructor.isDynamic&&(r+=Ft(n))}if(n)a[i]=r;else for(let e of o.slice(s))a[e.name]!==void 0&&delete a[e.name];return r}function jt(e,t,n,r){typeof n==`string`&&(n=n.charCodeAt(0));let i=e.byteOffset+At(e,t,!1)+(r??0)*t.type.size;try{t.type.set(e.buffer,i,n);return}catch(e){Tt(e,i)}}function Mt(e,t){let n=t.type;if(Et(e,t)){let r=t.type.type;n=new Bt(r,Dt(e,t))}let r=e.byteOffset+At(e,t,!0);try{return n.get(e.buffer,r)}catch(e){Tt(e,r)}}function Nt(e){return typeof e==`object`&&!!e&&`constructor`in e&&Pt(e.constructor)}function Pt(e){return typeof e==`function`&&`prototype`in e&&`fields`in e&&typeof e.fields==`object`&&ct(e)}function Ft(e){let t=0;for(let n of e.constructor.fields){let r=e[n.name];Et(e,n)&&(t+=Ot(e,n)),Nt(r)&&r.constructor.isDynamic&&(t+=Ft(r))}return t}function It(e){if(ct(e))return e.size;if(e==null)return 0;if(typeof e==`object`&&ct(e.constructor))return e.constructor.size;if(Array.isArray(e)){let t=0;for(let n=0;n<e.length;n++)t+=It(e[n]);return t}if(typeof e==`string`)return bt(e),ht[xt(e)].size;throw TypeError(`Unable to resolve size of \`${e.toString()}\``)}function B(e){let t=It(e);return Nt(e)&&e.constructor.isDynamic?t+Ft(e):t}function Lt(e,t){let n;if(Pt(e)){if(e.isDynamic)throw P(`EINVAL`,`Cannot get offset of field in dynamic struct from the constructor`);n=e}else if(Nt(e))n=e.constructor;else throw P(`EINVAL`,`Type is not a struct or struct constructor`);let{fields:r}=n,i=r.find(e=>e.name===t);if(!i)throw P(`EINVAL`,`Struct does not have field: `+t);return Pt(e)?i.offset:At(e,i,!0)}function Rt(e,t){class n extends DataView{length;type=e;*[Symbol.iterator](){for(let e=0;e<this.length;e++)yield this[e]}_offsets=[0];offsetOf(t){if(!e.isDynamic)return t*e.size;if(t<this._offsets.length)return this._offsets[t];for(let n=this._offsets.length;n<=t;n++)this._offsets[n]=this._offsets[n-1]+B(e.get(this.buffer,this.byteOffset+this._offsets[n-1]));return this._offsets[t]}constructor(n,r,i){let a=typeof n==`object`?n:new ArrayBuffer((n??0)*e.size);super(a,r,i),this.length=typeof n==`number`?n:e.isDynamic?t??y(`Unknown length of StructArray<${e.name}>`):Math.floor(this.byteLength/e.size);let o=e=>this.byteOffset+this.offsetOf(e);return new Proxy(this,{get(t,n){if(n in t)return t[n];let r=parseInt(n.toString());if(Number.isSafeInteger(r))return e.get(t.buffer,o(r))},set(t,n,r){let i=parseInt(n.toString());return Number.isSafeInteger(i)?(e.set(t.buffer,o(i),r),!0):!1}})}}for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(n.prototype,e,{enumerable:!1,configurable:!1,writable:!1,value:void 0});return n}function zt(e){return typeof e==`function`&&`prototype`in e&&`fields`in e&&typeof e.fields==`object`&&ct(e)}var Bt=class{type;length;name;size;__structArray;__arrayType;__isArrayType=!0;constructor(e,t){this.type=e,this.length=t,this.name=`${e.name}[${t}]`,this.size=e.size*t,this.array=Rt(this),this.__structArray=Rt(e,t),this.__arrayType=e.array?e.array:this.__structArray}get=(e,t)=>yt(this.type.name)&&t%this.type.size!==0?new this.__structArray(e,t,this.size):new this.__arrayType(e,t,this.size);set=(e,t,n)=>{if(this.length)for(let r=0;r<this.length;r++)this.type.set(e,t+r*this.type.size,n[r]);else{let r=t;for(let t=0;t<n.length;t++)this.type.set(e,r,n[t]),r+=zt(this.type)&&this.type.isDynamic?B(n[t]):this.type.size}};array};Symbol.metadata??=Symbol.for(`Symbol.metadata`);function Vt(e){e.metadata??={};let t=e.metadata.structInit??{};return e.metadata.structInit={fields:[...t.fields??[]]},e.metadata.structInit}function Ht(...e){let t=e.reduce((e,t)=>({...e,...t}),{});return typeof this==`object`&&Object.assign(t,this),function(e,n){let r=Vt(n),i=1,a=[],o=0,s=e=>{o=Math.ceil(o/e)*e};for(let e of r.fields)t.isPacked||s(e.alignment),t.isUnion?o=Math.max(o,e.type.size):(e.offset=o,o+=e.type.size),a.push(e),i=Math.max(i,e.alignment);t.alignment??=i,t.isPacked||s(t.alignment);class c extends e{static name=e.name;static size=o;static alignment=t.alignment;static isUnion=!!t.isUnion;static isDynamic=!!t.isDynamic;static fields=a;static get(e,t){return new this(e,t)}static set(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,this.size),i=new Uint8Array(e,t,this.size);if(n.buffer!==e||n.byteOffset!==t)for(let e=0;e<this.size;e++)i[e]=r[e]}static[Symbol.toStringTag]=`[struct ${e.name}]`;constructor(...e){e.length||(e=[new ArrayBuffer(o),0,o]),super(...e);for(let e of Object.values(a))Object.defineProperty(this,e.name,{enumerable:!0,configurable:!0,get(){return Mt(this,e)},set(t){jt(this,e,t)}})}}return n.addInitializer(function(){Object.defineProperty(c,"name",{value:e.name}),ut(c)}),c}}Ht.packed=Ht.bind({isPacked:!0}),Ht.align=function(e){return Ht.bind({alignment:e})};function Ut(e,t={}){return function(n,r){if(r.kind!=`accessor`)throw P(`EINVAL`,`Field must be an accessor`);let i=Vt(r),a=wt(r.name,e,t);return i.fields.push(a),{get(){return Mt(this,a)},set(e){jt(this,a,e)}}}}function Wt(e){let t=ht[xt(e)];function n(n,r){return typeof n==`number`?Ut(new Bt(t,n),{typeName:e,...r}):Ut(t,{typeName:e})(n,r&&`name`in r?r:y(P(`EINVAL`,`Invalid decorator context object`)))}return n}var V=Object.fromEntries(vt.map(e=>[e,Wt(e)]));function Gt(e){return e}Gt.typed=function(e){return e};var Kt=class e{type;init;constructor(t,n){this.type=t,this.init=n;let r=(r=>new e(new Bt(t,r),n));return Object.setPrototypeOf(r,new.target.prototype),Object.assign(r,{type:t,init:n}),r}align(t){return new e(this.type,{...this.init,align:t})}countedBy(t){return new e(this.type,{...this.init,countedBy:t})}bigEndian(){return new e(this.type,{...this.init,bigEndian:!0})}toInit(){return{type:this.type,...this.init}}$type(){return new e(this.type,this.init)}};function qt(e,t=0){return new Kt(new Bt(e,t),{})}function Jt(e,t,...n){let r=n.reduce((e,t)=>({...e,...t}),{});typeof this==`object`&&Object.assign(r,this);let i=1,a=0,o=e=>{a=Math.ceil(a/e)*e},s=[];for(let[e,n]of Object.entries(t)){if(typeof e==`number`)throw TypeError(`Field names can not be numbers`);let t=wt(e,n);r.isPacked||o(t.alignment),r.isUnion?a=Math.max(a,t.type.size):(t.offset=a,a+=t.type.size),s.push(t),i=Math.max(i,t.alignment)}r.alignment??=i,r.isPacked||o(r.alignment);class c extends DataView{static name=e;static size=a;static alignment=r.alignment;static isUnion=!!r.isUnion;static isDynamic=!!r.isDynamic;static fields=s;static get(e,t){return new this(e,t)}static set(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,this.size),i=new Uint8Array(e,t,this.size);if(n.buffer!==e||n.byteOffset!==t)for(let e=0;e<this.size;e++)i[e]=r[e]}static[Symbol.toStringTag]=`[struct ${e}]`;constructor(e=new ArrayBuffer(a),t,n){super(e,t,n??e.byteLength-(t??0));for(let e of Object.values(this.constructor.fields??s))Object.defineProperty(this,e.name,{enumerable:!0,configurable:!0,get(){return Mt(this,e)},set(t){jt(this,e,t)}})}}for(let e of Object.getOwnPropertyNames(DataView.prototype))!e.startsWith(`get`)&&!e.startsWith(`set`)||Object.defineProperty(c.prototype,e,{enumerable:!1,configurable:!1,writable:!1,value:void 0});return ut(c),c}Jt.extend=function(e,t,n,...r){let i=r.reduce((e,t)=>({...e,...t}),{});typeof this==`object`&&Object.assign(i,this);let a=1,o=e.size,s=e=>{o=Math.ceil(o/e)*e},c=e.fields;for(let[e,t]of Object.entries(n)){if(typeof e==`number`)throw TypeError(`Field names can not be numbers`);let n=wt(e,t);i.isPacked||s(n.alignment),i.isUnion?o=Math.max(o,n.type.size):(n.offset=o,o+=n.type.size),c.push(n),a=Math.max(a,n.alignment)}i.alignment??=a,i.isPacked||s(i.alignment);class l extends e{static name=t;static size=o;static alignment=i.alignment;static isUnion=!!i.isUnion;static isDynamic=!!i.isDynamic;static fields=c;static[Symbol.toStringTag]=`[struct ${t}]`}return ut(l),l},Jt.packed=Jt.bind({isPacked:!0}),Jt.align=function(e){return Jt.bind({alignment:e})},Jt.dynamic=Jt.bind({isDynamic:!0}),Object.fromEntries(Object.entries(_t).map(([e,t])=>[e,new Kt(t,{typeName:e})]));function Yt(e){return JSON.parse(E(e),(e,t)=>e==``?t:typeof t==`string`?BigInt(t).toString(16).slice(0,Math.min(t.length,8)):t)}function Xt(e){return T(JSON.stringify(e))}function Zt(e,t){if(typeof e==`number`)return e;if(typeof e==`string`){let t=parseInt(e,8);if(!isNaN(t))return t}if(typeof t==`number`)return t;throw P(`EINVAL`,`Invalid mode: `+e?.toString())}var Qt=2147483647;function $t(e){if(!(Number.isInteger(e)&&e>=0&&e<=Qt))throw Object.assign(RangeError(`The value of "fd" is out of range. It must be >= 0 && <= ${Qt}. Received ${e}`),{code:`ERR_OUT_OF_RANGE`})}function en(e){if(e instanceof Date)return e.getTime();let t=Number(e);if(!Number.isFinite(t))throw P(`EINVAL`,`Invalid time.`);return t<0?Date.now():t*1e3}function H(e,t=!1){if(e instanceof URL){if(e.protocol!=`file:`)throw P(`EINVAL`,`URLs must use the file: protocol`);e=e.pathname}if(e=e.toString(),e.startsWith(`file://`)&&(e=e.slice(7)),e.includes(`\0`))throw P(`EINVAL`,`Path can not contain null character`);if(e.length==0)throw P(`EINVAL`,`Path can not be empty`);return e=e.replaceAll(/[/\\]+/g,`/`),t?e:un.call(this,e)}function tn(e,t=`utf8`,n,r=0){return typeof e!=`object`||!e?{encoding:typeof e==`string`?e:t??null,flag:n,mode:r}:{encoding:typeof e?.encoding==`string`?e.encoding:t??null,flag:typeof e?.flag==`string`?e.flag:n,mode:Zt(`mode`in e?e?.mode:null,r)}}function nn(e){let t=`\0GS\0`;return e=e.replace(/\*\*/g,t).replace(/\*/g,`\0S\0`).replace(/[.+^$(){}|[\]\\]/g,`\\$&`).replace(/\?/g,`.`).replaceAll(`/\0GS\0/`,`(?:/.*)?/`).replaceAll(t,`.*`).replaceAll(`\0S\0`,`[^/]*`),RegExp(`^${e}$`)}async function rn(e){let t=Promise.withResolvers();setTimeout(()=>t.reject(P(`ETIMEDOUT`)),500),e.on(`online`,t.resolve),await t.promise}function an(e){return`${H(e,!0)}${Date.now()}-${Math.random().toString(36).slice(2)}`}var on=t({basename:()=>mn,dirname:()=>W,extname:()=>hn,format:()=>gn,formatExt:()=>ln,isAbsolute:()=>fn,join:()=>U,matchesGlob:()=>vn,normalize:()=>dn,normalizeString:()=>cn,parse:()=>_n,relative:()=>pn,resolve:()=>un,sep:()=>`/`});function sn(e,t){if(typeof e!=`object`)throw TypeError(`"${t}" is not an object`)}function cn(e,t){let n=``,r=0,i=-1,a=0,o=`\0`;for(let s=0;s<=e.length;++s){if(s<e.length)o=e[s];else if(o==`/`)break;else o=`/`;if(o==`/`){if(i!==s-1&&a!==1)if(a===2){if(n.length<2||r!==2||n.at(-1)!==`.`||n.at(-2)!==`.`){if(n.length>2){let e=n.lastIndexOf(`/`);e===-1?(n=``,r=0):(n=n.slice(0,e),r=n.length-1-n.lastIndexOf(`/`)),i=s,a=0;continue}if(n.length!==0){n=``,r=0,i=s,a=0;continue}}t&&(n+=n.length>0?`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,s):n=e.slice(i+1,s),r=s-i-1;i=s,a=0}else o===`.`&&a!==-1?++a:a=-1}return n}function ln(e){return e?`${e[0]===`.`?``:`.`}${e}`:``}function un(...e){let t=``;for(let n of[...e.reverse(),Le(this).pwd])if(n?.length&&(t=`${n}/${t}`,n.startsWith(`/`)))break;let n=t.startsWith(`/`);return t=cn(t,!n),n?`/${t}`:t.length?t:`/`}function dn(e){if(!e.length)return`.`;let t=e[0]===`/`,n=e.at(-1)===`/`;return e=cn(e,!t),e.length?(n&&(e+=`/`),t?`/${e}`:e):t?`/`:n?`./`:`.`}function fn(e){return e.startsWith(`/`)}function U(...e){if(!e.length)return`.`;let t=e.filter(e=>e).join(`/`);return t?.length?dn(t):`.`}function pn(e,t){if(e===t||(e=un.call(this,e),t=un.call(this,t),e===t))return``;let n=e.length,r=n-1,i=t.length-1,a=r<i?r:i,o=-1,s=0;for(;s<a;s++){let n=e[1+s];if(n!==t[1+s])break;n===`/`&&(o=s)}if(s===a)if(i>a){if(t[1+s]===`/`)return t.slice(1+s+1);if(s===0)return t.slice(1+s)}else r>a&&(e[1+s]===`/`?o=s:s===0&&(o=0));let c=``;for(s=1+o+1;s<=n;++s)(s===n||e[s]===`/`)&&(c+=c.length===0?`..`:`/..`);return`${c}${t.slice(1+o)}`}function W(e){if(e.length===0)return`.`;let t=e[0]===`/`,n=-1,r=!0;for(let t=e.length-1;t>=1;--t)if(e[t]===`/`){if(!r){n=t;break}}else r=!1;return n===-1?t?`/`:`.`:t&&n===1?`//`:e.slice(0,n)}function mn(e,t){let n=0,r=-1,i=!0;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t===e)return``;let a=t.length-1,o=-1;for(let s=e.length-1;s>=0;--s)if(e[s]===`/`){if(!i){n=s+1;break}}else o===-1&&(i=!1,o=s+1),a>=0&&(e[s]===t[a]?--a===-1&&(r=s):(a=-1,r=o));return n===r?r=o:r===-1&&(r=e.length),e.slice(n,r)}for(let t=e.length-1;t>=0;--t)if(e[t]===`/`){if(!i){n=t+1;break}}else r===-1&&(i=!1,r=t+1);return r===-1?``:e.slice(n,r)}function hn(e){let t=-1,n=0,r=-1,i=!0,a=0;for(let o=e.length-1;o>=0;--o){if(e[o]===`/`){if(!i){n=o+1;break}continue}r===-1&&(i=!1,r=o+1),e[o]===`.`?t===-1?t=o:a!==1&&(a=1):t!==-1&&(a=-1)}return t===-1||r===-1||a===0||a===1&&t===r-1&&t===n+1?``:e.slice(t,r)}function gn(e){sn(e,`pathObject`);let t=e.dir||e.root,n=e.base||`${e.name||``}${ln(e.ext)}`;return t?t===e.root?`${t}${n}`:`${t}/${n}`:n}function _n(e){let t=e[0]===`/`,n={root:t?`/`:``,dir:``,base:``,ext:``,name:``};if(e.length===0)return n;let r=+!!t,i=-1,a=0,o=-1,s=!0,c=e.length-1,l=0;for(;c>=r;--c){if(e[c]===`/`){if(!s){a=c+1;break}continue}o===-1&&(s=!1,o=c+1),e[c]===`.`?i===-1?i=c:l!==1&&(l=1):i!==-1&&(l=-1)}if(o!==-1){let r=a===0&&t?1:a;i===-1||l===0||l===1&&i===o-1&&i===a+1?n.base=n.name=e.slice(r,o):(n.name=e.slice(r,i),n.base=e.slice(r,o),n.ext=e.slice(i,o))}return a>0?n.dir=e.slice(0,a-1):t&&(n.dir=`/`),n}function vn(e,t){return nn(e).test(t)}var yn=BigInt(1e3),bn=class{_convert(e){return this._isBigint?BigInt(e):Number(e)}get blocks(){return this._convert(Math.ceil(Number(this.size)/512))}set blocks(e){}mode;dev=this._convert(0);ino=this._convert(0);rdev=this._convert(0);nlink=this._convert(1);blksize=this._convert(4096);uid=this._convert(0);gid=this._convert(0);atimeMs;get atime(){return new Date(Number(this.atimeMs))}set atime(e){this.atimeMs=this._convert(e.getTime())}mtimeMs;get mtime(){return new Date(Number(this.mtimeMs))}set mtime(e){this.mtimeMs=this._convert(e.getTime())}ctimeMs;get ctime(){return new Date(Number(this.ctimeMs))}set ctime(e){this.ctimeMs=this._convert(e.getTime())}birthtimeMs;get birthtime(){return new Date(Number(this.birthtimeMs))}set birthtime(e){this.birthtimeMs=this._convert(e.getTime())}size;data;flags;version;constructor({atimeMs:e,mtimeMs:t,ctimeMs:n,birthtimeMs:r,uid:i,gid:a,size:o,mode:s,ino:c,...l}={}){let u=Date.now();this.atimeMs=this._convert(e??u),this.mtimeMs=this._convert(t??u),this.ctimeMs=this._convert(n??u),this.birthtimeMs=this._convert(r??u),this.uid=this._convert(i??0),this.gid=this._convert(a??0),this.size=this._convert(o??0),this.ino=this._convert(c??0),this.mode=this._convert(s??0),this.mode&61440||(this.mode|=this._convert($e)),Object.assign(this,l)}isFile(){return(this.mode&Xe)===$e}isDirectory(){return(this.mode&Xe)===tt}isSymbolicLink(){return(this.mode&Xe)===Qe}isSocket(){return(this.mode&Xe)===Ze}isBlockDevice(){return(this.mode&Xe)===et}isCharacterDevice(){return(this.mode&Xe)===nt}isFIFO(){return(this.mode&Xe)===rt}toJSON(){return p(this,An)}hasAccess(e,t){return J(t,this._isBigint?new xn(this):this,e)}get atimeNs(){return BigInt(this.atimeMs)*yn}get mtimeNs(){return BigInt(this.mtimeMs)*yn}get ctimeNs(){return BigInt(this.ctimeMs)*yn}get birthtimeNs(){return BigInt(this.birthtimeMs)*yn}},xn=class extends bn{_isBigint=!1},Sn=class extends bn{_isBigint=!0};function Cn(e,t){return e.size==t.size&&+e.atime==+t.atime&&+e.mtime==+t.mtime&&+e.ctime==+t.ctime&&e.mode==t.mode}var wn=class{type=525687744115;bsize=4096;blocks=0;bfree=0;bavail=0;files=ot;ffree=ot},Tn=class{type=BigInt(`0x7a656e6673`);bsize=BigInt(4096);blocks=BigInt(0);bfree=BigInt(0);bavail=BigInt(0);files=BigInt(ot);ffree=BigInt(ot)},En=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},G=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Dn=3968,On=(()=>{var e,t;let n=[Ht.packed()],r,i=[],a,o=Gt.typed(Uint8Array),s,c=[],l=[],u,d=[],f=[];var p=class extends o{static{a=this}static{let m=typeof Symbol==`function`&&Symbol.metadata?Object.create(o[Symbol.metadata]??null):void 0;s=[(e=V).uint32.bind(e)],u=[(t=V).uint32.bind(t)],En(this,null,s,{kind:`accessor`,name:`keySize`,static:!1,private:!1,access:{has:e=>`keySize`in e,get:e=>e.keySize,set:(e,t)=>{e.keySize=t}},metadata:m},c,l),En(this,null,u,{kind:`accessor`,name:`valueSize`,static:!1,private:!1,access:{has:e=>`valueSize`in e,get:e=>e.valueSize,set:(e,t)=>{e.valueSize=t}},metadata:m},d,f),En(null,r={value:a},n,{kind:`class`,name:a.name,metadata:m},null,i),p=a=r.value,m&&Object.defineProperty(a,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:m})}static name=`Attribute`;#e=G(this,c,void 0);get keySize(){return this.#e}set keySize(e){this.#e=e}#t=(G(this,l),G(this,d,void 0));get valueSize(){return this.#t}set valueSize(e){this.#t=e}get name(){return E(this.subarray(8,8+this.keySize))}set name(e){let t=T(e);if(8+t.length+this.valueSize>Dn)throw P(`EOVERFLOW`);this.set(t,8),this.keySize=t.length}get value(){return this.subarray(8+this.keySize,this.size)}set value(e){if(8+this.keySize+e.length>Dn)throw P(`EOVERFLOW`);this.valueSize=e.length,this.set(e,8+this.keySize)}get size(){return 8+this.keySize+this.valueSize}constructor(){super(...arguments),G(this,f)}static{G(a,i)}};return a})(),kn=(()=>{var e;let t=[Ht.packed()],n,r=[],i,a=Gt(o),s,c=[],l=[];var u=class extends a{static{i=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(a[Symbol.metadata]??null):void 0;s=[(e=V).uint32.bind(e)],En(this,null,s,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:o},c,l),En(null,n={value:i},t,{kind:`class`,name:i.name,metadata:o},null,r),u=i=n.value,o&&Object.defineProperty(i,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`Attributes`;#e=G(this,c,void 0);get size(){return this.#e}set size(e){this.#e=e}get byteSize(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);e+=t.size}return e}has(e){let t=this.byteOffset+B(this);for(let n=0;n<this.size;n++){let n=new On(this.buffer,t);if(n.name==e)return!0;t+=n.size}return!1}get(e){let t=this.byteOffset+B(this);for(let n=0;n<this.size;n++){let n=new On(this.buffer,t);if(n.name==e)return n.value;t+=n.size}}set(e,t){let n=this.byteOffset+B(this),r;for(let t=0;t<this.size;t++){let t=new On(this.buffer,n);t.name==e&&(r=[n,t.size]),n+=t.size}let i=new Uint8Array(this.buffer);if(r){let[e,t]=r;n-=t,i.copyWithin(e,e+t,n+t),i.fill(0,n,n+t),this.size--}let a=new On(this.buffer,n);a.name=e,a.value=t,this.size++}remove(e){let t=this.byteOffset+B(this),n;for(let r=0;r<this.size;r++){let r=new On(this.buffer,t);r.name==e&&(n=[t,r.size]),t+=r.size}if(!n)return!1;let[r,i]=n,a=new Uint8Array(this.buffer);return a.copyWithin(r,r+i,t),a.fill(0,t-i,t),this.size--,!0}copyFrom(e){let{byteSize:t}=e;new Uint8Array(this.buffer,this.byteOffset,t).set(new Uint8Array(e.buffer,e.byteOffset,t))}*keys(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield t.name,e+=t.size}}*values(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield t.value,e+=t.size}}*entries(){let e=this.byteOffset+B(this);for(let t=0;t<this.size;t++){let t=new On(this.buffer,e);yield[t.name,t.value],e+=t.size}}constructor(){super(...arguments),G(this,l)}static{G(i,r)}};return i})(),An=[`ino`,`data`,`size`,`mode`,`flags`,`nlink`,`uid`,`gid`,`atimeMs`,`birthtimeMs`,`mtimeMs`,`ctimeMs`,`version`],jn;(function(e){e[e.Sync=1]=`Sync`,e[e.NoAtime=2]=`NoAtime`,e[e.Append=4]=`Append`,e[e.Immutable=8]=`Immutable`,e[e.Dead=16]=`Dead`,e[e.NoQuota=32]=`NoQuota`,e[e.Dirsync=64]=`Dirsync`,e[e.NoCMtime=128]=`NoCMtime`,e[e.SwapFile=256]=`SwapFile`,e[e.Private=512]=`Private`,e[e.IMA=1024]=`IMA`,e[e.AutoMount=2048]=`AutoMount`,e[e.NoSec=4096]=`NoSec`,e[e.DAX=8192]=`DAX`,e[e.Encrypted=16384]=`Encrypted`,e[e.CaseFold=32768]=`CaseFold`,e[e.Verity=65536]=`Verity`,e[e.KernelFile=131072]=`KernelFile`})(jn||={});var Mn=253951,Nn=229631,K=(()=>{var e,t,n,r,i,a,s,c,l,u,d,f,m,h,g,_;let v=[Ht.packed()],y,b=[],x,S=Gt(o),C,w=[],T=[],ee,E=[],te=[],ne,D=[],O=[],k,A=[],j=[],M,N=[],F=[],re,I=[],ie=[],ae,oe=[],se=[],ce,le=[],ue=[],L,fe=[],pe=[],me,he=[],ge=[],_e,ve=[],ye=[],be,xe=[],z=[],Se,Ce=[],we=[],Te,Ee=[],De=[],Oe,ke=[],Ae=[],je,Me=[],Ne=[],Pe,Fe=[],Ie=[],Le,Re=[],ze=[],Be,Ve=[],He=[];var Ue=class extends S{static{x=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(S[Symbol.metadata]??null):void 0;C=[(e=V).uint32.bind(e)],ee=[(t=V).uint32.bind(t)],ne=[(n=V).uint32.bind(n)],k=[(r=V).uint16.bind(r)],M=[(i=V).uint32.bind(i)],re=[(a=V).uint32.bind(a)],ae=[(s=V).uint32.bind(s)],ce=[(c=V).float64.bind(c)],L=[(l=V).float64.bind(l)],me=[(u=V).float64.bind(u)],_e=[(d=V).float64.bind(d)],be=[(f=V).uint32.bind(f)],Se=[(m=V).uint32.bind(m)],Te=[(h=V).uint32.bind(h)],Oe=[(g=V).uint16.bind(g)],je=[(_=V).uint32.bind(_)],Pe=[V.uint8(48)],Le=[Ut(kn)],Be=[V.uint8(Dn)],En(this,null,C,{kind:`accessor`,name:`data`,static:!1,private:!1,access:{has:e=>`data`in e,get:e=>e.data,set:(e,t)=>{e.data=t}},metadata:o},w,T),En(this,null,ee,{kind:`accessor`,name:`__data_old`,static:!1,private:!1,access:{has:e=>`__data_old`in e,get:e=>e.__data_old,set:(e,t)=>{e.__data_old=t}},metadata:o},E,te),En(this,null,ne,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:o},D,O),En(this,null,k,{kind:`accessor`,name:`mode`,static:!1,private:!1,access:{has:e=>`mode`in e,get:e=>e.mode,set:(e,t)=>{e.mode=t}},metadata:o},A,j),En(this,null,M,{kind:`accessor`,name:`nlink`,static:!1,private:!1,access:{has:e=>`nlink`in e,get:e=>e.nlink,set:(e,t)=>{e.nlink=t}},metadata:o},N,F),En(this,null,re,{kind:`accessor`,name:`uid`,static:!1,private:!1,access:{has:e=>`uid`in e,get:e=>e.uid,set:(e,t)=>{e.uid=t}},metadata:o},I,ie),En(this,null,ae,{kind:`accessor`,name:`gid`,static:!1,private:!1,access:{has:e=>`gid`in e,get:e=>e.gid,set:(e,t)=>{e.gid=t}},metadata:o},oe,se),En(this,null,ce,{kind:`accessor`,name:`atimeMs`,static:!1,private:!1,access:{has:e=>`atimeMs`in e,get:e=>e.atimeMs,set:(e,t)=>{e.atimeMs=t}},metadata:o},le,ue),En(this,null,L,{kind:`accessor`,name:`birthtimeMs`,static:!1,private:!1,access:{has:e=>`birthtimeMs`in e,get:e=>e.birthtimeMs,set:(e,t)=>{e.birthtimeMs=t}},metadata:o},fe,pe),En(this,null,me,{kind:`accessor`,name:`mtimeMs`,static:!1,private:!1,access:{has:e=>`mtimeMs`in e,get:e=>e.mtimeMs,set:(e,t)=>{e.mtimeMs=t}},metadata:o},he,ge),En(this,null,_e,{kind:`accessor`,name:`ctimeMs`,static:!1,private:!1,access:{has:e=>`ctimeMs`in e,get:e=>e.ctimeMs,set:(e,t)=>{e.ctimeMs=t}},metadata:o},ve,ye),En(this,null,be,{kind:`accessor`,name:`ino`,static:!1,private:!1,access:{has:e=>`ino`in e,get:e=>e.ino,set:(e,t)=>{e.ino=t}},metadata:o},xe,z),En(this,null,Se,{kind:`accessor`,name:`__ino_old`,static:!1,private:!1,access:{has:e=>`__ino_old`in e,get:e=>e.__ino_old,set:(e,t)=>{e.__ino_old=t}},metadata:o},Ce,we),En(this,null,Te,{kind:`accessor`,name:`flags`,static:!1,private:!1,access:{has:e=>`flags`in e,get:e=>e.flags,set:(e,t)=>{e.flags=t}},metadata:o},Ee,De),En(this,null,Oe,{kind:`accessor`,name:`__after_flags`,static:!1,private:!1,access:{has:e=>`__after_flags`in e,get:e=>e.__after_flags,set:(e,t)=>{e.__after_flags=t}},metadata:o},ke,Ae),En(this,null,je,{kind:`accessor`,name:`version`,static:!1,private:!1,access:{has:e=>`version`in e,get:e=>e.version,set:(e,t)=>{e.version=t}},metadata:o},Me,Ne),En(this,null,Pe,{kind:`accessor`,name:`__padding`,static:!1,private:!1,access:{has:e=>`__padding`in e,get:e=>e.__padding,set:(e,t)=>{e.__padding=t}},metadata:o},Fe,Ie),En(this,null,Le,{kind:`accessor`,name:`attributes`,static:!1,private:!1,access:{has:e=>`attributes`in e,get:e=>e.attributes,set:(e,t)=>{e.attributes=t}},metadata:o},Re,ze),En(this,null,Be,{kind:`accessor`,name:`__data`,static:!1,private:!1,access:{has:e=>`__data`in e,get:e=>e.__data,set:(e,t)=>{e.__data=t}},metadata:o},Ve,He),En(null,y={value:x},v,{kind:`class`,name:x.name,metadata:o},null,b),Ue=x=y.value,o&&Object.defineProperty(x,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`Inode`;constructor(...e){let t={};if(typeof e[0]==`object`&&e[0]!==null&&!ArrayBuffer.isView(e[0])&&(t=e[0],e=[B(Ue)]),e[0]instanceof Ue&&(e=[new Uint8Array(e[0].buffer,e[0].byteOffset,e[0].byteLength)]),super(...e),G(this,He),this.byteLength<B(Ue))throw de(P(`EIO`,`Buffer is too small to create an inode (${this.byteLength} bytes)`));Object.assign(this,t),this.atimeMs||=Date.now(),this.mtimeMs||=Date.now(),this.ctimeMs||=Date.now(),this.birthtimeMs||=Date.now(),this.ino&&!this.nlink&&R(`Inode ${this.ino} has an nlink of 0`)}#e=G(this,w,void 0);get data(){return this.#e}set data(e){this.#e=e}#t=(G(this,T),G(this,E,void 0));get __data_old(){return this.#t}set __data_old(e){this.#t=e}#n=(G(this,te),G(this,D,void 0));get size(){return this.#n}set size(e){this.#n=e}#r=(G(this,O),G(this,A,void 0));get mode(){return this.#r}set mode(e){this.#r=e}#i=(G(this,j),G(this,N,void 0));get nlink(){return this.#i}set nlink(e){this.#i=e}#a=(G(this,F),G(this,I,void 0));get uid(){return this.#a}set uid(e){this.#a=e}#o=(G(this,ie),G(this,oe,void 0));get gid(){return this.#o}set gid(e){this.#o=e}#s=(G(this,se),G(this,le,void 0));get atimeMs(){return this.#s}set atimeMs(e){this.#s=e}#c=(G(this,ue),G(this,fe,void 0));get birthtimeMs(){return this.#c}set birthtimeMs(e){this.#c=e}#l=(G(this,pe),G(this,he,void 0));get mtimeMs(){return this.#l}set mtimeMs(e){this.#l=e}#u=(G(this,ge),G(this,ve,void 0));get ctimeMs(){return this.#u}set ctimeMs(e){this.#u=e}#d=(G(this,ye),G(this,xe,void 0));get ino(){return this.#d}set ino(e){this.#d=e}#f=(G(this,z),G(this,Ce,void 0));get __ino_old(){return this.#f}set __ino_old(e){this.#f=e}#p=(G(this,we),G(this,Ee,void 0));get flags(){return this.#p}set flags(e){this.#p=e}#m=(G(this,De),G(this,ke,void 0));get __after_flags(){return this.#m}set __after_flags(e){this.#m=e}#h=(G(this,Ae),G(this,Me,void 0));get version(){return this.#h}set version(e){this.#h=e}#g=(G(this,Ne),G(this,Fe,void 0));get __padding(){return this.#g}set __padding(e){this.#g=e}#_=(G(this,Ie),G(this,Re,void 0));get attributes(){return this.#_}set attributes(e){this.#_=e}#v=(G(this,ze),G(this,Ve,void 0));get __data(){return this.#v}set __data(e){this.#v=e}toString(){return`<Inode ${this.ino}>`}toJSON(){return{...p(this,An),attributes:this.attributes}}toStats(){return new xn(this)}update(e){if(!e)return!1;let t=!1;for(let n of An)e[n]!==void 0&&n!=`ino`&&n!=`data`&&this[n]!==e[n]&&(n==`atimeMs`&&this.flags&jn.NoAtime||(this[n]=e[n],t=!0));return e.attributes&&(this.attributes.copyFrom(e.attributes),t=!0),t&&(this.ctimeMs=Date.now()),t}static{G(x,b)}};return Ue=x})();function Pn(e){return(e.mode&Xe)===$e}function q(e){return(e.mode&Xe)===tt}function Fn(e){return(e.mode&Xe)===Qe}function In(e){return(e.mode&Xe)===Ze}function Ln(e){return(e.mode&Xe)===et}function Rn(e){return(e.mode&Xe)===nt}function zn(e){return(e.mode&Xe)===rt}function J(e,t,n){let{credentials:r}=Le(e);if(Fn(t)||r.euid===0||r.egid===0)return!0;let i=0;return r.uid===t.uid&&(t.mode&256&&(i|=4),t.mode&128&&(i|=2),t.mode&64&&(i|=1)),(r.gid===t.gid||r.groups.includes(Number(t.gid)))&&(t.mode&32&&(i|=4),t.mode&16&&(i|=2),t.mode&8&&(i|=1)),t.mode&4&&(i|=4),t.mode&2&&(i|=2),t.mode&1&&(i|=1),(i&n)===n}function Bn(e,t,n){let r=!0;return!isNaN(t)&&t>=0&&t<4294967295?e.uid=t:r=!1,!isNaN(n)&&n>=0&&n<4294967295?e.gid=n:r=!1,r}var Vn=class e extends Map{maxSize=ot;toJSON(){return{version:1,maxSize:this.maxSize,entries:Object.fromEntries([...this].map(([e,t])=>[e,t.toJSON()]))}}toString(){return JSON.stringify(this.toJSON())}get byteSize(){let e=this.size*B(K);for(let t of this.values())e+=t.size;return e}usage(){return{totalSpace:this.maxSize,freeSpace:this.maxSize-this.byteSize}}pathOf(e){for(let[t,n]of this)if(n.ino==e||n.data==e)return t}getByID(e){return this.entryByID(e)?.inode}entryByID(e){for(let[t,n]of this)if(n.ino==e||n.data==e)return{path:t,inode:n}}directoryEntries(e){let t=this.get(e);if(!t)throw P(`ENOENT`);if((t.mode&61440)!=16384)throw P(`ENOTDIR`);let n={};for(let t of this.keys())W(t)==e&&t!=e&&(n[mn(t)]=this.get(t).ino);return n}_alloc(){let e=0;for(let t of this.values())t.ino>e&&(e=t.ino),t.data>e&&(e=t.data);return e+1}directories(){let e=new Map;for(let[t,n]of this){if((n.mode&61440)!=16384)continue;let r={};for(let e of this.keys())W(e)==t&&e!=t&&(r[mn(e)]=this.get(e).ino);e.set(t,r)}return e}fromJSON(e){if(e.version!=1)throw P(`EINVAL`,`Index version mismatch`);this.clear();for(let[t,n]of Object.entries(e.entries))n.data??=S(1,ot),t==`/`&&(n.ino=0),this.set(t,new K(n));return this}static parse(t){if(!h(t))throw P(`EINVAL`,`Invalid JSON`);let n=JSON.parse(t),r=new e;return r.fromJSON(n),r}},Hn=4096,Un=class e{type;name;label;_mountPoint;_uuid=crypto.randomUUID();get uuid(){return this._uuid}attributes=new Map;constructor(t,n){this.type=t,this.name=n,this.streamRead===e.prototype.streamRead&&this.attributes.set(`default_stream_read`),this.streamWrite===e.prototype.streamWrite&&this.attributes.set(`default_stream_write`)}toString(){return`${this.name} ${this.label?JSON.stringify(this.label):``} (${this._mountPoint?`mounted on `+this._mountPoint:`unmounted`})`}usage(){return{totalSpace:0,freeSpace:0}}async ready(){}readySync(){if(this.ready!==e.prototype.ready)throw P(`EAGAIN`)}async exists(e){try{return await this.stat(e),!0}catch(e){return e.code!=`ENOENT`}}existsSync(e){try{return this.statSync(e),!0}catch(e){return e.code!=`ENOENT`}}streamRead(e,t){return new ReadableStream({start:async n=>{let{size:r}=await this.stat(e),{start:i=0,end:a=r}=t;for(let t=i;t<a;t+=Hn){let r=t+Hn>a?a-t:Hn,i=new Uint8Array(r);await this.read(e,i,t,t+r).catch(n.error.bind(n)),n.enqueue(i)}n.close()},type:`bytes`})}streamWrite(e,t){let n=t.start??0;return new WritableStream({write:async(t,r)=>{let i=!1,a=e=>{i=!0,r.error(e)},{size:o}=await this.stat(e);await this.write(e,t,n).catch(a),!i&&(n+=t.byteLength,await this.touch(e,{mtimeMs:Date.now(),size:Math.max(o,n)}).catch(a))}})}};Promise.withResolvers??=(R(`Using a polyfill of Promise.withResolvers`),function(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}),Symbol.dispose??=(R(`Using a polyfill of Symbol.dispose`),Symbol(`Symbol.dispose`)),Symbol.asyncDispose??=(R(`Using a polyfill of Symbol.asyncDispose`),Symbol(`Symbol.asyncDispose`)),globalThis.crypto.randomUUID??=(R(`Using a polyfill of crypto.randomUUID`),function(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}),Uint8Array.prototype.toBase64??=(R(`Using a polyfill of Uint8Array.prototype.toBase64`),function(){return btoa(String.fromCharCode(...this))}),Uint8Array.fromBase64??=(R(`Using a polyfill of Uint8Array.fromBase64`),function(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}),Uint8Array.prototype.toHex??=(R(`Using a polyfill of Uint8Array.prototype.toHex`),function(){return[...this].map(e=>e.toString(16).padStart(2,`0`)).join(``)}),Uint8Array.fromHex??=(R(`Using a polyfill of Uint8Array.fromHex`),function(e){let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t});var Wn=class{store;constructor(e){this.store=e}},Gn=class extends Wn{async get(e,t,n){return this.getSync(e,t,n)}async set(e,t,n){return this.setSync(e,t,n)}async remove(e){return this.removeSync(e)}},Kn=class extends Wn{asyncDone=Promise.resolve();async(e){this.asyncDone=this.asyncDone.then(()=>e)}_cached(e,t){this.store.cache??=new Map;let n=this.store.cache.get(e);return n?(t&&(n.size=t.size),n):t?new s(e,t.size,{},this.store.cache):void 0}getSync(e,t,n){let r=this._cached(e);if(!r)return;n??=r.size;let i=r.missing(t,n);for(let{start:t,end:n}of i)this.async(this.get(e,t,n));if(i.length)throw P(`EAGAIN`);let a=r.regionAt(t);if(!a){R(`Missing cache region for `+e);return}return a.data.subarray(t-a.offset,n-a.offset)}setSync(e,t,n){this.async(this.set(e,t,n))}removeSync(e){this.async(this.remove(e)),this.store.cache?.delete(e)}},qn=class{raw;fs;done=!1;flag(e){return this.raw.store.flags?.includes(e)??!1}constructor(e,t){this.raw=e,this.fs=t}originalData=new Map;modifiedKeys=new Set;keys(){return this.raw.keys()}async get(e,t=0,n){let r=await this.raw.get(e,t,n);return this.stash(e),r}getSync(e,t=0,n){let r=this.raw.getSync(e,t,n);return this.stash(e),r}async set(e,t,n=0){await this.markModified(e,n,t.byteLength);let r=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);await this.raw.set(e,r,n)}setSync(e,t,n=0){this.markModifiedSync(e,n,t.byteLength);let r=t instanceof Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this.raw.setSync(e,r,n)}async remove(e){await this.markModified(e,0,void 0),await this.raw.remove(e)}removeSync(e){this.markModifiedSync(e,0,void 0),this.raw.removeSync(e)}commit(){return this.done=!0,Promise.resolve()}commitSync(){this.done=!0}async abort(){if(!this.done){for(let[e,t]of this.originalData)if(this.modifiedKeys.has(e)){if(t.some(e=>!e.data)){await this.raw.remove(e),this.fs._remove(e);continue}for(let n of t.reverse())await this.raw.set(e,n.data,n.offset)}this.done=!0}}abortSync(){if(!this.done){for(let[e,t]of this.originalData)if(this.modifiedKeys.has(e)){if(t.some(e=>!e.data)){this.raw.removeSync(e),this.fs._remove(e);continue}for(let n of t.reverse())this.raw.setSync(e,n.data,n.offset)}this.done=!0}}async[Symbol.asyncDispose](){this.done||await this.abort()}[Symbol.dispose](){this.done||this.abortSync()}stash(e,t,n=0){this.originalData.has(e)||this.originalData.set(e,[]),this.originalData.get(e).push({data:t,offset:n})}async markModified(e,t,n){this.modifiedKeys.add(e);let r=n?t+n:void 0;try{this.stash(e,await this.raw.get(e,t,r),t)}catch(n){if(!(this.raw instanceof Kn))throw n;let i=this.raw._cached(e);if(!i)throw n;for(let n of i.cached(t,r??t))this.stash(e,await this.raw.get(e,n.start,n.end),n.start)}}markModifiedSync(e,t,n){this.modifiedKeys.add(e);let r=n?t+n:void 0;try{this.stash(e,this.raw.getSync(e,t,r),t)}catch(n){if(!(this.raw instanceof Kn))throw n;let i=this.raw._cached(e);if(!i)throw n;for(let n of i.cached(t,r??t))this.stash(e,this.raw.getSync(e,n.start,n.end),n.start)}}},Jn=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Yn=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Xn=class extends Un{store;_ids=new Map([[`/`,0]]);_paths=new Map([[0,new Set(`/`)]]);_path(e){let[t]=this._paths.get(e)??[];return t}_add(e,t){this._paths.has(e)||this._paths.set(e,new Set),this._paths.get(e).add(t),this._ids.set(t,e)}_remove(e){for(let t of this._paths.get(e)??[])this._ids.delete(t);this._paths.delete(e)}_move(e,t){let n=[];for(let[r,i]of this._ids){let a=pn(e,r);if(a.startsWith(`..`))continue;let o=U(t,a);o.endsWith(`/`)&&(o=o.slice(0,-1)),n.push({oldKey:r,newKey:o,ino:i})}for(let{oldKey:e,newKey:t,ino:r}of n){this._ids.delete(e),this._ids.set(t,r);let n=this._paths.get(r);if(!n){R(`Missing paths in table for ino `+r);continue}n.delete(e),n.add(t)}}_initialized=!1;async ready(){this._initialized||=(this.attributes.has(`no_async_preload`)||this.checkRootSync(),await this.checkRoot(),await this._populate(),!0)}readySync(){this._initialized||=(this.attributes.has(`no_async_preload`)||this.checkRootSync(),this.checkRootSync(),this._populateSync(),!0)}constructor(e){super(e.type??1802921587,e.name),this.store=e,e.fs=this,this._uuid=e.uuid??this.uuid,this.label=e.label,me(this.name+`: supports features: `+this.store.flags?.join(`, `))}usage(){return this.store.usage?.()||{totalSpace:0,freeSpace:0}}async loadIndex(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0),r=e.directories();for(let[t,i]of e)this._add(i.ino,t),await n.set(i.ino,i),r.has(t)&&await n.set(i.data,Xt(r.get(t)));await n.commit()}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}loadIndexSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1),r=e.directories();for(let[t,i]of e)this._add(i.ino,t),n.setSync(i.ino,i),r.has(t)&&n.setSync(i.data,Xt(r.get(t)));n.commitSync()}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async createIndex(){let e={stack:[],error:void 0,hasError:!1};try{let t=new Vn,n=Jn(e,this.transaction(),!0),r=[[`/`,0]],i=v(P(`EDEADLK`));for(;r.length;){let[e,i]=r.shift(),a=new K(await n.get(i));if(t.set(e,a),a.mode&16384){let t=Yt(await n.get(a.data)??y(P(`ENODATA`)));for(let[n,i]of Object.entries(t))r.push([U(e,n),i])}}return i(),t}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}createIndexSync(){let e={stack:[],error:void 0,hasError:!1};try{let t=new Vn,n=Jn(e,this.transaction(),!1),r=[[`/`,0]],i=v(P(`EDEADLK`));for(;r.length;){let[e,i]=r.shift(),a=new K(n.getSync(i));if(t.set(e,a),a.mode&16384){let t=Yt(n.getSync(a.data)??y(P(`ENODATA`)));for(let[n,i]of Object.entries(t))r.push([U(e,n),i])}}return i(),t}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async rename(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=_n(e),a=_n(t),o=await this.findInode(r,i.dir),s=Yt(await r.get(o.data)??y(P(`ENODATA`)));if(!s[i.base])throw P(`ENOENT`);let c=s[i.base];if(c!=this._ids.get(e)&&L(`Ino mismatch while renaming ${e} to ${t}`),delete s[i.base],(a.dir+`/`).startsWith(e+`/`))throw P(`EBUSY`);let l=a.dir==i.dir,u=l?o:await this.findInode(r,a.dir),d=l?s:Yt(await r.get(u.data)??y(P(`ENODATA`)));if(d[a.base]){let e=new K(await r.get(d[a.base])??y(P(`ENOENT`)));if(!Pn(e))throw P(`EISDIR`);await r.remove(e.data),await r.remove(d[a.base])}d[a.base]=c,await r.set(o.data,Xt(s)),await r.set(u.data,Xt(d)),await r.commit(),this._move(e,t)}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}renameSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=_n(e),a=_n(t),o=this.findInodeSync(r,i.dir),s=Yt(r.getSync(o.data)??y(P(`ENODATA`)));if(!s[i.base])throw P(`ENOENT`);let c=s[i.base];if(c!=this._ids.get(e)&&L(`Ino mismatch while renaming ${e} to ${t}`),delete s[i.base],(a.dir+`/`).startsWith(e+`/`))throw P(`EBUSY`);let l=a.dir===i.dir,u=l?o:this.findInodeSync(r,a.dir),d=l?s:Yt(r.getSync(u.data)??y(P(`ENODATA`)));if(d[a.base]){let e=new K(r.getSync(d[a.base])??y(P(`ENOENT`)));if(!Pn(e))throw P(`EISDIR`);r.removeSync(e.data),r.removeSync(d[a.base])}d[a.base]=c,r.setSync(o.data,Xt(s)),r.setSync(u.data,Xt(d)),r.commitSync(),this._move(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async stat(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0);return await this.findInode(n,e)}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}statSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1);return this.findInodeSync(n,e)}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async touch(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=await this.findInode(r,e);i.update(t)&&(this._add(i.ino,e),r.setSync(i.ino,i)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}touchSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=this.findInodeSync(r,e);i.update(t)&&(this._add(i.ino,e),r.setSync(i.ino,i)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async createFile(e,t){return await this.commitNew(e,{...t,mode:t.mode|$e},new Uint8Array)}createFileSync(e,t){return this.commitNewSync(e,{...t,mode:t.mode|$e},new Uint8Array)}async unlink(e){return this.remove(e,!1)}unlinkSync(e){this.removeSync(e,!1)}async rmdir(e){if((await this.readdir(e)).length)throw P(`ENOTEMPTY`);await this.remove(e,!0)}rmdirSync(e){if(this.readdirSync(e).length)throw P(`ENOTEMPTY`);this.removeSync(e,!0)}async mkdir(e,t){return await this.commitNew(e,{...t,mode:t.mode|tt},T(`{}`))}mkdirSync(e,t){return this.commitNewSync(e,{...t,mode:t.mode|tt},T(`{}`))}async readdir(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!0),r=await this.findInode(n,e);return Object.keys(Yt(await n.get(r.data)??y(P(`ENOENT`))))}catch(e){t.error=e,t.hasError=!0}finally{let e=Yn(t);e&&await e}}readdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{let n=Jn(t,this.transaction(),!1),r=this.findInodeSync(n,e);return Object.keys(Yt(n.getSync(r.data)??y(P(`ENOENT`))))}catch(e){t.error=e,t.hasError=!0}finally{Yn(t)}}async sync(){}syncSync(){}async link(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),i=W(t),a=await this.findInode(r,i),o=Yt(await r.get(a.data)??y(P(`ENOENT`))),s=await this.findInode(r,e);s.nlink++,o[mn(t)]=s.ino,this._add(s.ino,t),await r.set(s.ino,s),await r.set(a.data,Xt(o)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}linkSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),i=W(t),a=this.findInodeSync(r,i),o=Yt(r.getSync(a.data)??y(P(`ENOENT`))),s=this.findInodeSync(r,e);s.nlink++,o[mn(t)]=s.ino,this._add(s.ino,t),r.setSync(s.ino,s),r.setSync(a.data,Xt(o)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}async read(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{let a=Jn(i,this.transaction(),!0),o=await this.findInode(a,e);if(o.size==0)return;let s=await a.get(o.data,n,r)??y(P(`ENODATA`)),c=a.flag(`partial`)?s:s.subarray(n,r);c.byteLength>t.byteLength&&L(`Trying to place ${c.byteLength} bytes into a ${t.byteLength} byte buffer on read`),t.set(c)}catch(e){i.error=e,i.hasError=!0}finally{let e=Yn(i);e&&await e}}readSync(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{let a=Jn(i,this.transaction(),!1),o=this.findInodeSync(a,e);if(o.size==0)return;let s=a.getSync(o.data,n,r)??y(P(`ENODATA`)),c=a.flag(`partial`)?s:s.subarray(n,r);c.byteLength>t.byteLength&&L(`Trying to place ${c.byteLength} bytes into a ${t.byteLength} byte buffer on read`),t.set(c)}catch(e){i.error=e,i.hasError=!0}finally{Yn(i)}}async write(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{let i=Jn(r,this.transaction(),!0),o=await this.findInode(i,e),s=n+t.byteLength,c=t;i.flag(`partial`)||(c=a(await i.get(o.data)??new Uint8Array,s),c.set(t,n),n=0),await i.set(o.data,c,n),o.update({size:Math.max(o.size,s),mtimeMs:Date.now()}),await i.set(o.ino,o),this._add(o.ino,e),await i.commit()}catch(e){r.error=e,r.hasError=!0}finally{let e=Yn(r);e&&await e}}writeSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{let i=Jn(r,this.transaction(),!1),o=this.findInodeSync(i,e),s=n+t.byteLength,c=t;i.flag(`partial`)||(c=a(i.getSync(o.data)??new Uint8Array,s),c.set(t,n),n=0),i.setSync(o.data,c,n),o.update({size:Math.max(o.size,s),mtimeMs:Date.now()}),i.setSync(o.ino,o),this._add(o.ino,e),i.commitSync()}catch(e){r.error=e,r.hasError=!0}finally{Yn(r)}}transaction(){return new qn(this.store.transaction(),this)}async checkRoot(){let e={stack:[],error:void 0,hasError:!1};try{let t=Jn(e,this.transaction(),!0);if(await t.get(0))return;let n=new K({ino:0,data:1,mode:511|tt});await t.set(n.data,T(`{}`)),this._add(0,`/`),await t.set(0,n),await t.commit()}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}checkRootSync(){let e={stack:[],error:void 0,hasError:!1};try{let t=Jn(e,this.transaction(),!1);if(t.getSync(0))return;let n=new K({ino:0,data:1,mode:511|tt});t.setSync(n.data,T(`{}`)),this._add(0,`/`),t.setSync(0,n),t.commitSync()}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async _populate(){let e={stack:[],error:void 0,hasError:!1};try{if(this._initialized){R(`Attempted to populate tables after initialization`);return}me(`Populating tables with existing store metadata`);let t=Jn(e,this.transaction(),!0),n=await t.get(0);if(!n){fe(`Store does not have a root inode`);let e=new K({ino:0,data:1,mode:511|tt});await t.set(e.data,T(`{}`)),this._add(0,`/`),await t.set(0,e),await t.commit();return}if(n.length<B(K)){de(`Store contains an invalid root inode. Refusing to populate tables`);return}let r=new Set,i=0,a=[[`/`,0]];for(;a.length>0;){i++;let[e,n]=a.shift();this._add(n,e);let o=await t.get(n);if(!o){R(`Store is missing data for inode: `+n);continue}if(o.length<B(K)){R(`Invalid inode size for ino ${n}: ${o.length}`);continue}let s=new K(o);if((s.mode&16384)!=16384||r.has(n))continue;r.add(n);let c=await t.get(s.data);if(!c){R(`Store is missing directory data: `+s.data);continue}let l=Yt(c);for(let[t,n]of Object.entries(l))a.push([U(e,t),n])}me(`Added ${i} existing inode(s) from store`)}catch(t){e.error=t,e.hasError=!0}finally{let t=Yn(e);t&&await t}}_populateSync(){let e={stack:[],error:void 0,hasError:!1};try{if(this._initialized){R(`Attempted to populate tables after initialization`);return}me(`Populating tables with existing store metadata`);let t=Jn(e,this.transaction(),!1),n=t.getSync(0);if(!n){fe(`Store does not have a root inode`);let e=new K({ino:0,data:1,mode:511|tt});t.setSync(e.data,T(`{}`)),this._add(0,`/`),t.setSync(0,e),t.commitSync();return}if(n.length<B(K)){de(`Store contains an invalid root inode. Refusing to populate tables`);return}let r=new Set,i=0,a=[[`/`,0]];for(;a.length>0;){i++;let[e,n]=a.shift();this._add(n,e);let o=t.getSync(n);if(!o){R(`Store is missing data for inode: `+n);continue}if(o.length<B(K)){R(`Invalid inode size for ino ${n}: ${o.length}`);continue}let s=new K(o);if((s.mode&16384)!=16384||r.has(n))continue;r.add(n);let c=t.getSync(s.data);if(!c){R(`Store is missing directory data: `+s.data);continue}let l=Yt(c);for(let[t,n]of Object.entries(l))a.push([U(e,t),n])}me(`Added ${i} existing inode(s) from store`)}catch(t){e.error=t,e.hasError=!0}finally{Yn(e)}}async _findInode(e,t,n=new Set){if(n.has(t))throw de(P(`EIO`,`Infinite loop detected while finding inode`));if(n.add(t),t==`/`)return new K(await e.get(0)??y(P(`ENODATA`)));let{dir:r,base:i}=_n(t),a=await this._findInode(e,r,n),o=Yt(await e.get(a.data)??y(P(`ENODATA`)));if(!(i in o))throw P(`ENOENT`);return new K(await e.get(o[i])??y(P(`ENODATA`)))}_findInodeSync(e,t,n=new Set){if(n.has(t))throw de(P(`EIO`,`Infinite loop detected while finding inode`));if(n.add(t),t==`/`)return new K(e.getSync(0)??y(P(`ENOENT`)));let{dir:r,base:i}=_n(t),a=this._findInodeSync(e,r,n),o=Yt(e.getSync(a.data)??y(P(`ENODATA`)));if(!(i in o))throw P(`ENOENT`);return new K(e.getSync(o[i])??y(P(`ENODATA`)))}async findInode(e,t){if(this.attributes.has(`no_id_tables`))return await this._findInode(e,t);let n=this._ids.get(t);if(n===void 0)throw P(`ENOENT`);return new K(await e.get(n)??y(P(`ENOENT`)))}findInodeSync(e,t){if(this.attributes.has(`no_id_tables`))return this._findInodeSync(e,t);let n=this._ids.get(t);if(n===void 0)throw P(`ENOENT`);return new K(e.getSync(n)??y(P(`ENOENT`)))}_lastID;allocNew(e){this._lastID??=Math.max(...this._paths.keys()),this._lastID+=2;let t=this._lastID;if(t>4294967295)throw L(P(`ENOSPC`,`No IDs available`));return this._add(t,e),t}async commitNew(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{if(e==`/`)throw P(`EEXIST`);let i=Jn(r,this.transaction(),!0),{dir:a,base:o}=_n(e),s=await this.findInode(i,a),c=Yt(await i.get(s.data)??y(P(`ENOENT`)));if(c[o])throw P(`EEXIST`);let l=this.allocNew(e),u=new K({...t,ino:l,data:l+1,size:n.byteLength,nlink:1});return await i.set(u.ino,u),await i.set(u.data,n),c[o]=u.ino,await i.set(s.data,Xt(c)),await i.commit(),u}catch(e){r.error=e,r.hasError=!0}finally{let e=Yn(r);e&&await e}}commitNewSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{if(e==`/`)throw P(`EEXIST`);let i=Jn(r,this.transaction(),!1),{dir:a,base:o}=_n(e),s=this.findInodeSync(i,a),c=Yt(i.getSync(s.data)??y(P(`ENOENT`)));if(c[o])throw P(`EEXIST`);let l=this.allocNew(e),u=new K({...t,ino:l,data:l+1,size:n.byteLength,nlink:1});return i.setSync(u.ino,u),i.setSync(u.data,n),c[o]=u.ino,i.setSync(s.data,Xt(c)),i.commitSync(),u}catch(e){r.error=e,r.hasError=!0}finally{Yn(r)}}async remove(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!0),{dir:i,base:a}=_n(e),o=await this.findInode(r,i),s=Yt(await r.get(o.data)??y(P(`ENOENT`)));if(!s[a])throw P(`ENOENT`);let c=s[a],l=new K(await r.get(c)??y(P(`ENOENT`)));if(delete s[a],!t&&q(l))throw P(`EISDIR`);await r.set(o.data,Xt(s)),l.nlink>1?(l.update({nlink:l.nlink-1}),await r.set(l.ino,l)):(await r.remove(l.data),await r.remove(c),this._remove(c)),await r.commit()}catch(e){n.error=e,n.hasError=!0}finally{let e=Yn(n);e&&await e}}removeSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{let r=Jn(n,this.transaction(),!1),{dir:i,base:a}=_n(e),o=this.findInodeSync(r,i),s=Yt(r.getSync(o.data)??y(P(`ENOENT`))),c=s[a];if(!c)throw P(`ENOENT`);let l=new K(r.getSync(c)??y(P(`ENOENT`)));if(delete s[a],!t&&q(l))throw P(`EISDIR`);r.setSync(o.data,Xt(s)),l.nlink>1?(l.update({nlink:l.nlink-1}),r.setSync(l.ino,l)):(r.removeSync(l.data),r.removeSync(c),this._remove(c)),r.commitSync()}catch(e){n.error=e,n.hasError=!0}finally{Yn(n)}}},Zn=class extends Gn{async keys(){return this.store.keys()}async get(e){return await(this.store.getAsync?.(e)??this.store.get(e))}getSync(e){return this.store.get(e)}setSync(e,t){this.store.set(e,t)}removeSync(e){this.store.delete(e)}},Qn=class extends Kn{async keys(){return await this.asyncDone,this.store.keys()}async get(e,t,n){return await this.asyncDone,await this.store.get(e,t,n)}getSync(e,t,n){return this.store.cached(e,t,n)}async set(e,t,n=0){await this.asyncDone,await this.store.set(e,t,n)}async remove(e){await this.asyncDone,await this.store.delete(e)}},$n=class extends Map{maxSize;label;flags=[];name=`tmpfs`;constructor(e=ot,t){super(),this.maxSize=e,this.label=t}async sync(){}transaction(){return new Zn(this)}get bytes(){let e=this.size*4;for(let t of this.values())e+=t.byteLength;return e}usage(){return{totalSpace:this.maxSize,freeSpace:this.maxSize-this.bytes}}},er={name:`InMemory`,options:{maxSize:{type:`number`,required:!1},label:{type:`string`,required:!1}},create({maxSize:e,label:t}){let n=new Xn(new $n(e,t));return n.checkRootSync(),n}},tr=class extends Xn{devices=new Map;devicesWithDriver(e,t){if(t&&typeof e==`string`)throw L(P(`EINVAL`,`Can not fetch devices using only a driver name`));let n=[];for(let r of this.devices.values())t&&r.driver!=e||(typeof e==`string`?e:e.name)==r.driver.name&&n.push(r);return n}_createDevice(e,t={}){let n=1,r=Array.from(this.devices.values()).at(-1);for(;this.store.has(n)||r?.inode.ino==n;)n++;let i=e.init?.(n,t),a={data:{},minor:0,major:0,...m(i??{},`metadata`),driver:e,inode:new K({mode:nt|438,...i?.metadata})},o=`/`+(a.name||e.name)+(e.singleton?``:this.devicesWithDriver(e).length);if(this.existsSync(o))throw P(`EEXIST`);return this.devices.set(o,a),pe(`Initialized device: `+this._mountPoint+o),a}addDefaults(){this._createDevice(rr),this._createDevice(ir),this._createDevice(ar),this._createDevice(or),this._createDevice(sr),me(`Added default devices`)}constructor(){super(new $n(16777216,`devfs`))}async rename(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.rename(e,t)}renameSync(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.renameSync(e,t)}async stat(e){let t=this.devices.get(e);return t?t.inode:super.stat(e)}statSync(e){let t=this.devices.get(e);return t?t.inode:super.statSync(e)}async touch(e,t){let n=this.devices.get(e);n?n.inode.update(t):await super.touch(e,t)}touchSync(e,t){let n=this.devices.get(e);n?n.inode.update(t):super.touchSync(e,t)}async createFile(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.createFile(e,t)}createFileSync(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.createFileSync(e,t)}async unlink(e){if(this.devices.has(e))throw P(`EPERM`);return super.unlink(e)}unlinkSync(e){if(this.devices.has(e))throw P(`EPERM`);return super.unlinkSync(e)}async rmdir(e){return super.rmdir(e)}rmdirSync(e){return super.rmdirSync(e)}async mkdir(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.mkdir(e,t)}mkdirSync(e,t){if(this.devices.has(e))throw P(`EEXIST`);return super.mkdirSync(e,t)}async readdir(e){let t=await super.readdir(e);for(let n of this.devices.keys())W(n)==e&&t.push(mn(n));return t}readdirSync(e){let t=super.readdirSync(e);for(let n of this.devices.keys())W(n)==e&&t.push(mn(n));return t}async link(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.link(e,t)}linkSync(e,t){if(this.devices.has(e))throw P(`EPERM`);if(this.devices.has(t))throw P(`EEXIST`);return super.linkSync(e,t)}async sync(){for(let e of this.devices.values())e.driver.sync?.(e);return super.sync()}syncSync(){for(let e of this.devices.values())e.driver.sync?.(e);return super.syncSync()}async read(e,t,n,r){let i=this.devices.get(e);if(!i){await super.read(e,t,n,r);return}i.driver.read(i,t,n,r)}readSync(e,t,n,r){let i=this.devices.get(e);if(!i){super.readSync(e,t,n,r);return}i.driver.read(i,t,n,r)}async write(e,t,n){let r=this.devices.get(e);if(!r)return await super.write(e,t,n);r.driver.write(r,t,n)}writeSync(e,t,n){let r=this.devices.get(e);if(!r)return super.writeSync(e,t,n);r.driver.write(r,t,n)}},nr=new Uint8Array,rr={name:`null`,singleton:!0,init(){return{major:1,minor:3}},read(){return nr},write(){}},ir={name:`zero`,singleton:!0,init(){return{major:1,minor:5}},read(e,t,n,r){t.fill(0,n,r)},write(){}},ar={name:`full`,singleton:!0,init(){return{major:1,minor:7}},read(e,t,n,r){t.fill(0,n,r)},write(){throw P(`ENOSPC`)}},or={name:`random`,singleton:!0,init(){return{major:1,minor:8}},read(e,t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*256)},write(){}},sr={name:`console`,singleton:!0,init(e,{output:t=e=>console.log(e)}={}){return{major:5,minor:1,data:{output:t}}},read(){return nr},write(e,t,n){let r=E(t);e.data.output(r,n)}},cr={null:rr,zero:ir,full:ar,random:or,console:sr},lr=r(),Y=!0;function ur(e){Y=e}var dr;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.FIFO=1]=`FIFO`,e[e.CHR=2]=`CHR`,e[e.DIR=4]=`DIR`,e[e.BLK=6]=`BLK`,e[e.REG=8]=`REG`,e[e.LNK=10]=`LNK`,e[e.SOCK=12]=`SOCK`,e[e.WHT=14]=`WHT`})(dr||={});function fr(e){return(e&61440)>>12}function pr(e){return e<<12}var mr=class{ino;type;path;name},hr=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},gr=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},_r=class{pending=new Set;lastWriter;writeState=0;readers=0;syncReaders=0;take(e,t,n){e==`rw`?this.writeState=t?2:1:(this.readers++,t&&this.syncReaders++);let r=!1,i=()=>{r||(r=!0,e==`rw`?this.writeState=0:(this.readers--,t&&this.syncReaders--),n())};return i[Symbol.dispose]=i,i}queue(e){let{promise:t,resolve:n}=Promise.withResolvers();return this.pending.add(t),e==`rw`&&(this.lastWriter=t),t.then(()=>{this.pending.delete(t),this.lastWriter==t&&delete this.lastWriter}),n}async acquire(e){let t=e==`ro`?this.lastWriter:Promise.all(this.pending),n=this.queue(e);return await t,this.take(e,!1,n)}acquireSync(e){if(this.writeState==2||e==`rw`&&this.syncReaders)throw P(`EDEADLK`);if(this.writeState||e==`rw`&&this.readers)throw P(`EAGAIN`);return this.take(e,!0,this.queue(e))}isAvailable(e){return(e!=`rw`||!this.readers)&&!this.writeState}get isFree(){return!this.writeState&&!this.readers}get mode(){return this.writeState?`rw`:this.readers?`ro`:null}},vr=(()=>{let e=[],t,n;return class{static{let r=typeof Symbol==`function`&&Symbol.metadata?Object.create(null):void 0;t=[b],n=[b],gr(this,null,t,{kind:`getter`,name:`lock`,static:!1,private:!1,access:{has:e=>`lock`in e,get:e=>e.lock},metadata:r},null,e),gr(this,null,n,{kind:`getter`,name:`lockSync`,static:!1,private:!1,access:{has:e=>`lockSync`in e,get:e=>e.lockSync},metadata:r},null,e),r&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:r})}_rwLock=(hr(this,e),new _r);get lock(){return this._rwLock.acquire.bind(this._rwLock)}get lockSync(){return this._rwLock.acquireSync.bind(this._rwLock)}get isLocked(){return!this._rwLock.isFree}get lockMode(){return this._rwLock.mode}}})(),yr=class extends vr{fs;inode;data;dirtyRanges=[];truncatedTo;metadataDirty=!1;refs=0;paths=new Set;_lastPath;constructor(e,t,n){super(),this.fs=e,this.inode=n,this.paths.add(t),this._lastPath=t,this.data=new s(n.ino,n.size,{sparse:!0})}get ino(){return this.inode.ino}get path(){let[e]=this.paths;return e!==void 0&&(this._lastPath=e),e??this._lastPath}get dirty(){return this.metadataDirty||this.dirtyRanges.length>0}get bypassCache(){return Rn(this.inode)||Ln(this.inode)||!!(this.inode.flags&jn.DAX)}markDirty(e,t){this.dirtyRanges.push({start:e,end:t}),this.dirtyRanges.sort((e,t)=>e.start-t.start);let n=[];for(let e of this.dirtyRanges){let t=n.at(-1);t&&e.start<=t.end?t.end=Math.max(t.end,e.end):n.push(e)}this.dirtyRanges=n}copyFromCache(e,t,n){let r=t;for(let i of this.data.regions){let a=i.offset+i.data.byteLength;if(a<=r)continue;if(i.offset>=n)break;i.offset>r&&(e.fill(0,r-t,i.offset-t),r=i.offset);let o=Math.min(n,a);e.set(i.data.subarray(r-i.offset,o-i.offset),r-t),r=o}r<n&&e.fill(0,r-t,n-t)}async read(e,t,n){if(this.bypassCache)return await this.fs.read(this.path,e,t,n);for(let{start:e,end:r}of this.data.missing(t,n)){let t=new Uint8Array(r-e);await this.fs.read(this.path,t,e,r),this.data.add(t,e)}this.copyFromCache(e,t,n)}readSync(e,t,n){if(this.bypassCache)return this.fs.readSync(this.path,e,t,n);for(let{start:e,end:r}of this.data.missing(t,n)){let t=new Uint8Array(r-e);this.fs.readSync(this.path,t,e,r),this.data.add(t,e)}this.copyFromCache(e,t,n)}async write(e,t){this.bypassCache?await this.fs.write(this.path,e,t):this._writeCached(e,t),this._writeMetadata(t+e.byteLength)}writeSync(e,t){this.bypassCache?this.fs.writeSync(this.path,e,t):this._writeCached(e,t),this._writeMetadata(t+e.byteLength)}_writeCached(e,t){let n=t+e.byteLength;this.data.add(e.slice(),t),n>this.data.size&&(this.data.size=n),this.markDirty(t,n)}_writeMetadata(e){!this.bypassCache&&e>this.inode.size&&(this.inode.size=e),this.inode.mtimeMs=Date.now(),this.inode.ctimeMs=Date.now(),this.metadataDirty=!0}truncate(e){this.truncatedTo=Math.min(this.truncatedTo??e,e),this.data.size=e,this.dirtyRanges=this.dirtyRanges.filter(t=>t.start<e).map(t=>t.end>e?{start:t.start,end:e}:t),this.inode.size=e,this.inode.mtimeMs=Date.now(),this.inode.ctimeMs=Date.now(),this.metadataDirty=!0}get needsPreTruncate(){return!this.bypassCache&&this.truncatedTo!==void 0&&this.truncatedTo<this.inode.size&&!this.fs.attributes.has(`no_write`)}async sync(){this.needsPreTruncate&&await this.fs.touch(this.path,{size:this.truncatedTo}),this.truncatedTo=void 0;for(let e of this.dirtyRanges)for(let t=e.start;t<e.end;){let n=this.data.regionAt(t);if(!n)break;let r=Math.min(e.end,n.offset+n.data.byteLength);await this.fs.write(this.path,n.data.subarray(t-n.offset,r-n.offset),t),t=r}this.dirtyRanges=[],this.metadataDirty&&=(this.fs.attributes.has(`no_write`)||await this.fs.touch(this.path,this.inode),!1)}syncSync(){this.needsPreTruncate&&this.fs.touchSync(this.path,{size:this.truncatedTo}),this.truncatedTo=void 0;for(let e of this.dirtyRanges)for(let t=e.start;t<e.end;){let n=this.data.regionAt(t);if(!n)break;let r=Math.min(e.end,n.offset+n.data.byteLength);this.fs.writeSync(this.path,n.data.subarray(t-n.offset,r-n.offset),t),t=r}this.dirtyRanges=[],this.metadataDirty&&=(this.fs.attributes.has(`no_write`)||this.fs.touchSync(this.path,this.inode),!1)}},br=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},xr=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Sr=class{fs;byIno=new Map;byPath=new Map;constructor(e){this.fs=e}get(e){return this.byPath.get(e)}ref(e,t){let n=this.byIno.get(t.ino);return n&&!n.paths.has(e)&&(t.ino===0||t.nlink<=1||n.inode.nlink<=1||(n.inode.mode^t.mode)&61440)&&(n=this.byPath.get(e),n&&(n.inode.mode^t.mode)&61440&&(n=void 0)),n?(n.paths.add(e),!n.dirty&&t!==n.inode&&Object.assign(n.inode,t)):(n=new yr(this.fs,e,t),this.byIno.set(t.ino,n)),this.byPath.set(e,n),n.refs++,n}unref(e){e.refs--,!(e.refs>0||e.dirty)&&this.evict(e)}evict(e){this.byIno.delete(e.ino);for(let t of e.paths)this.byPath.delete(t)}rename(e,t){for(let[n,r]of this.byPath){if(n!=e&&!n.startsWith(e+`/`))continue;let i=t+n.slice(e.length);this.byPath.delete(n),this.byPath.set(i,r),r.paths.delete(n),r.paths.add(i)}}link(e,t){let n=this.byPath.get(e);n&&(n.paths.add(t),this.byPath.set(t,n))}remove(e){let t=this.byPath.get(e);t&&(this.byPath.delete(e),t.paths.delete(e),!t.paths.size&&!t.refs&&this.evict(t))}async sync(){for(let e of this.byIno.values()){let t={stack:[],error:void 0,hasError:!1};try{if(!e.dirty)continue;br(t,await e.lock(`rw`),!1),await e.sync(),e.refs||this.evict(e)}catch(e){t.error=e,t.hasError=!0}finally{xr(t)}}}syncSync(){for(let e of this.byIno.values()){let t={stack:[],error:void 0,hasError:!1};try{if(!e.dirty)continue;br(t,e.lockSync(`rw`),!1),e.syncSync(),e.refs||this.evict(e)}catch(e){t.error=e,t.hasError=!0}finally{xr(t)}}}},Cr=new Map;function wr(e){let t=Cr.get(e.uuid);return t||(t=new Sr(e),Cr.set(e.uuid,t)),t}async function Tr(e,t,n,r){let i=wr(e);r??=i.get(t)?.inode??await e.stat(t);let a=i.ref(t,r),o=await a.lock(n),s=!1,c=()=>{s||(s=!0,o(),i.unref(a))};return c[Symbol.dispose]=c,c}function Er(e,t,n,r){let i=wr(e);r??=i.get(t)?.inode??e.statSync(t);let a=i.ref(t,r),o;try{o=a.lockSync(n)}catch(e){throw i.unref(a),e}let s=!1,c=()=>{s||(s=!0,o(),i.unref(a))};return c[Symbol.dispose]=c,c}var Dr=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Or=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},kr=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Ar=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),jr=4096,Mr=(()=>{let e=[],t,n;return class{static{let r=typeof Symbol==`function`&&Symbol.metadata?Object.create(null):void 0;Or(this,null,t,{kind:`getter`,name:`inode`,static:!1,private:!1,access:{has:e=>`inode`in e,get:e=>e.inode},metadata:r},null,e),Or(this,null,n,{kind:`getter`,name:`fs`,static:!1,private:!1,access:{has:e=>`fs`in e,get:e=>e.fs},metadata:r},null,e),r&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:r})}context=Dr(this,e);path;internalPath;flag;vnode;_position=0;get position(){return this.flag&1024?this.inode.size:this._position}set position(e){this._position=e}get inode(){return this.vnode.inode}get fs(){return this.vnode.fs}get dirty(){return this.vnode.dirty}closed=!1;get isClosed(){return this.closed}constructor(e,t,n,r,i){this.context=e,this.path=t,this.internalPath=n,this.flag=r,this.vnode=i}get _isSync(){return!!(this.flag&1052672||this.inode.flags&jn.Sync||this.fs.attributes.has(`sync`))}[(t=[b],n=[b],Symbol.dispose)](){this.closeSync()}syncSync(){let e={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`sync`,this.path);if(!this.dirty)return;kr(e,this.vnode.lockSync(`rw`),!1),this.vnode.syncSync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}datasyncSync(){return this.syncSync()}closeSync(){if(this.closed)throw N(`EBADF`,`close`,this.path);this.syncSync(),this.disposeSync(!0)}disposeSync(e){if(this.closed)throw N(`EBADF`,`close`,this.path);if(this.dirty&&!e)throw N(`EBUSY`,`close`,this.path);this.closed=!0,wr(this.fs).unref(this.vnode)}truncateSync(e){let t={stack:[],error:void 0,hasError:!1};try{if(e<0)throw N(`EINVAL`,`truncate`,this.path);if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`truncate`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`truncate`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`truncate`,this.path);kr(t,this.vnode.lockSync(`rw`),!1),this.vnode.truncate(e),this._isSync&&this.vnode.syncSync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}writeSync(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);kr(i,this.vnode.lockSync(`rw`),!1);let a=e.subarray(t,t+n);return this.vnode.writeSync(a,r),this._position=r+a.byteLength,this._isSync&&this.vnode.syncSync(),a.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}readSync(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||this.flag&1)throw N(`EBADF`,`read`,this.path);kr(i,this.vnode.lockSync(`ro`),!1),!(this.inode.flags&jn.NoAtime)&&!this.fs.attributes.has(`no_atime`)&&(this.vnode.metadataDirty=!0,this.inode.atimeMs=Date.now());let a=r+n;!Rn(this.inode)&&!Ln(this.inode)&&a>this.inode.size&&(a=r+Math.max(this.inode.size-r,0)),this._position=a;let o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return this.vnode.readSync(o.subarray(t,t+n),r,a),this._isSync&&this.vnode.syncSync(),a-r}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}chmodSync(e){let t={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(t,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.mode=this.inode.mode&(e>61440?~Xe:Xe)|e,(this._isSync||e>61440)&&this.vnode.syncSync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}chownSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(n,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,Bn(this.inode,e,t),this._isSync&&this.vnode.syncSync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}utimesSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`utimes`,this.path);kr(n,this.vnode.lockSync(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.atimeMs=e,this.inode.mtimeMs=t,this._isSync&&this.vnode.syncSync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}async[Symbol.asyncDispose](){await this.close()}async sync(){let e={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`sync`,this.path);if(!this.dirty)return;kr(e,await this.vnode.lock(`rw`),!1),await this.vnode.sync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}datasync(){return this.sync()}async close(){if(this.closed)throw N(`EBADF`,`close`,this.path);await this.sync(),this.dispose(!0)}dispose(e){if(this.closed)throw N(`EBADF`,`close`,this.path);if(this.dirty&&!e)throw N(`EBUSY`,`close`,this.path);this.closed=!0,wr(this.fs).unref(this.vnode)}stat(){if(this.closed)throw N(`EBADF`,`stat`,this.path);return this.inode}async truncate(e){let t={stack:[],error:void 0,hasError:!1};try{if(e<0)throw N(`EINVAL`,`truncate`,this.path);if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`truncate`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`truncate`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`truncate`,this.path);kr(t,await this.vnode.lock(`rw`),!1),this.vnode.truncate(e),this._isSync&&await this.vnode.sync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}async write(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||!(this.flag&1||this.flag&2))throw N(`EBADF`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);kr(i,await this.vnode.lock(`rw`),!1);let a=e.subarray(t,t+n);return await this.vnode.write(a,r),this._position=r+a.byteLength,this._isSync&&await this.vnode.sync(),a.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}async read(e,t=0,n=e.byteLength-t,r=this.position){let i={stack:[],error:void 0,hasError:!1};try{if(this.closed||this.flag&1)throw N(`EBADF`,`read`,this.path);kr(i,await this.vnode.lock(`ro`),!1),!(this.inode.flags&jn.NoAtime)&&!this.fs.attributes.has(`no_atime`)&&(this.vnode.metadataDirty=!0,this.inode.atimeMs=Date.now());let a=r+n;!Rn(this.inode)&&!Ln(this.inode)&&a>this.inode.size&&(a=r+Math.max(this.inode.size-r,0)),this._position=a;let o=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return await this.vnode.read(o.subarray(t,t+n),r,a),this._isSync&&await this.vnode.sync(),a-r}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}}async chmod(e){let t={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chmod`,this.path);kr(t,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.mode=this.inode.mode&(e>61440?~Xe:Xe)|e,(this._isSync||e>61440)&&await this.vnode.sync()}catch(e){t.error=e,t.hasError=!0}finally{Ar(t)}}async chown(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`chown`,this.path);kr(n,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,Bn(this.inode,e,t),this._isSync&&await this.vnode.sync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}async utimes(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(this.closed)throw N(`EBADF`,`utimes`,this.path);kr(n,await this.vnode.lock(`rw`),!1),this.vnode.metadataDirty=!0,this.inode.atimeMs=e,this.inode.mtimeMs=t,this._isSync&&await this.vnode.sync()}catch(e){n.error=e,n.hasError=!0}finally{Ar(n)}}streamRead(e){if(this.closed)throw N(`EBADF`,`streamRead`,this.path);let{vnode:t}=this;return new ReadableStream({async start(n){let r={stack:[],error:void 0,hasError:!1};try{kr(r,await t.lock(`ro`),!1);let{start:i=0,end:a=t.inode.size}=e;for(let e=i;e<a;e+=jr){let r=e+jr>a?a-e:jr,i=new Uint8Array(r);await t.read(i,e,e+r).catch(n.error.bind(n)),n.enqueue(i)}n.close()}catch(e){r.error=e,r.hasError=!0}finally{Ar(r)}},type:`bytes`})}streamWrite(e){if(this.closed)throw N(`EBADF`,`write`,this.path);if(this.inode.flags&jn.Immutable)throw N(`EPERM`,`write`,this.path);if(this.fs.attributes.has(`readonly`))throw N(`EROFS`,`write`,this.path);let{vnode:t}=this,n=e.start??0;return new WritableStream({async write(e,r){let i={stack:[],error:void 0,hasError:!1};try{kr(i,await t.lock(`rw`),!1),await t.write(e,n).catch(r.error.bind(r)),n+=e.byteLength}catch(e){i.error=e,i.hasError=!0}finally{Ar(i)}},async close(){let e={stack:[],error:void 0,hasError:!1};try{kr(e,await t.lock(`rw`),!1),await t.sync()}catch(t){e.error=t,e.hasError=!0}finally{Ar(e)}}})}}})();function Nr(e){let t=Le(e.context).descriptors,n=Math.max(t.size?Math.max(...t.keys())+1:0,4);return t.set(n,e),n}function Pr(e,t){$t(t);let n=Le(e).descriptors.get(t);if(!n)throw P(`EBADF`);return n}function Fr(e,t){return Le(e).descriptors.delete(t)}var Ir=/[rwasx]{1,2}\+?/;function Lr(e){if(typeof e==`number`)return e;if(!Ir.test(e))throw P(`EINVAL`,`Invalid flag string: `+e);return Rr(e)}function Rr(e){if(!e.includes(`r`)&&!e.includes(`w`)&&!e.includes(`a`))throw P(`EINVAL`,`Invalid flag string: `+e);let t=e.includes(`r`)?0:64;return e.includes(`w`)&&(t|=512),e.includes(`a`)&&(t|=Ve),e.includes(`+`)?t|=2:e.includes(`r`)||(t|=1),e.includes(`s`)&&(t|=Ge),e.includes(`x`)&&(t|=128),t}function zr(e){let t=0;return e&1||(t|=4),(e&1||e&2)&&(t|=2),t}var Br=M;function Vr(e,t){return e.path=t,e}function Hr(e,t,n,r){let i=typeof n==`string`?{path:n,dest:r,syscall:t.endsWith(`Sync`)?t.slice(0,-4):t}:n,a=e[t];if(typeof a!=`function`)throw TypeError(`${t} is not a function`);return function(...t){try{return a.call(e,...t)}catch(e){throw j(Object.assign(e,i))}}}function Ur(e,t){return new Proxy(e,{get(e,n){let r=Reflect.get(e,n);return typeof r==`function`?function n(...i){try{let a=r.apply(e,i);return a instanceof Promise?a.catch(e=>{if(`code`in e)throw j(Object.assign(e,t));if(e in k){let r=N(e,t);Error.captureStackTrace(r,n)}throw e}):a}catch(e){throw j(Object.assign(e,t))}}:r}})}var Wr=new Map;Gr(`/`,er.create({label:`root`}));function Gr(e,t){if(e[0]!=`/`&&(e=`/`+e),e=un.call(this,e),Wr.has(e))throw L(P(`EINVAL`,`Mount point is already in use: `+e));t._mountPoint=e,Wr.set(e,t),Cr.has(t.uuid)||Cr.set(t.uuid,new Sr(t)),pe(`Mounted ${t.name} on ${e}`),me(`${t.name} attributes: ${[...t.attributes].map(([e,t])=>t==null?e:e+`=`+t).join(`, `)}`)}function Kr(e){e[0]!=`/`&&(e=`/`+e),e=un.call(this,e);let t=Wr.get(e);if(!t){R(e+` is already unmounted`);return}let n=()=>{Cr.delete(t.uuid),pe(`Synced all changes to `+e)};try{Cr.get(t.uuid)?.syncSync(),n()}catch{R(`Could not flush to ${e} synchronously.`),Cr.get(t.uuid)?.sync().then(n)}Wr.delete(e),fe(`Unmounted `+e)}function X(e,t,n){let{root:r}=Le(t),i={path:e,...n};e=H(U(r,e),!0),e=un.call(t,e);let a=[...Wr].sort((e,t)=>e[0].length>t[0].length?-1:1);for(let[t,n]of a){if(!Yr(t,e))continue;e=e.slice(t.length>1?t.length:0),e===``&&(e=`/`);let a=n.attributes.get(`case_fold`);return a===`lower`&&(e=e.toLowerCase()),a===`upper`&&(e=e.toUpperCase()),{fs:Ur(n,i),path:e,mountPoint:t,root:r}}throw ue(new M(k.EIO,`No file system for `+e))}function qr(e,t){let n=e.usage(),r=n.blockSize||4096;return{type:(t?BigInt:Number)(e.type),bsize:(t?BigInt:Number)(r),ffree:(t?BigInt:Number)(n.freeNodes||4294967295),files:(t?BigInt:Number)(n.totalNodes||4294967295),bavail:(t?BigInt:Number)(n.freeSpace/r),bfree:(t?BigInt:Number)(n.freeSpace/r),blocks:(t?BigInt:Number)(n.totalSpace/r)}}function Jr(e){let t=Le(this);if(!Pe(t.credentials))throw P(`EPERM`,`Can not chroot() as non-root user`);t.root??=`/`;let n=U(t.root,e);for(let e of t.descriptors?.values()??[]){if(!e.path.startsWith(t.root))throw N(`EBUSY`,`chroot`,e.path);e.path=e.path.slice(t.root.length)}if(n.length>t.root.length)throw P(`EPERM`,`Can not chroot() outside of current root`);t.root=n}function Yr(e,t){return e===`/`||e===t||(e.endsWith(`/`)||(e+=`/`),t.startsWith(e))}var Xr=t({link:()=>ai,mkdir:()=>ni,open:()=>ei,readdir:()=>ri,readlink:()=>ti,rename:()=>ii,resolve:()=>$r,stat:()=>oi}),Zr=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Qr=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});function $r(e,t,n,r){t=un.call(e,t);try{let i=X(t,e),a=wr(i.fs).get(i.path)?.inode??i.fs.statSync(i.path);return!Fn(a)||n?{...i,fullPath:t,stats:a}:$r(e,un.call(e,W(t),ti.call(e,t)),n,r)}catch(e){if(j(Object.assign(e,{syscall:`stat`,path:t,...r})),n)throw e}let{base:i,dir:a}=_n(t),o=a==`/`?`/`:$r(e,a,!1,r).fullPath,s=U(o,i),c=X(s,e),l;try{l=wr(c.fs).get(c.path)?.inode??c.fs.statSync(c.path)}catch(e){if(e.code===`ENOENT`)return{...c,fullPath:s};throw j(Object.assign(e,{syscall:`stat`,path:s,...r}))}return Fn(l)?$r(e,un.call(e,o,ti.call(e,s)),!1,r):{...c,fullPath:s,stats:l}}function ei(e,t){e=H(e);let n=Zt(t.mode,420),r=Lr(t.flag);e=t.preserveSymlinks?e:$r(this,e).fullPath;let{fs:i,path:a}=X(e,this),o;try{o=i.statSync(a)}catch{}if(!o){let o={stack:[],error:void 0,hasError:!1};try{if(!(r&64))throw N(`ENOENT`,`open`,e);let s=W(a),c=i.statSync(s);if(Y&&!J(this,c,2))throw N(`EACCES`,`open`,e);if(!q(c))throw N(`ENOTDIR`,`open`,e);if(!t.allowDirectory&&n&16384)throw N(`EISDIR`,`open`,e);Zr(o,Er(i,s,`rw`,c),!1);let{euid:l,egid:u}=Le(this).credentials,d=i.createFileSync(a,{mode:n,uid:c.mode&2048?c.uid:l,gid:c.mode&1024?c.gid:u});return ua(this,`rename`,e),new Mr(this,e,a,r,wr(i).ref(a,d))}catch(e){o.error=e,o.hasError=!0}finally{Qr(o)}}if(Y&&(!J(this,o,n)||!J(this,o,zr(r))))throw N(`EACCES`,`open`,e);if(r&128)throw N(`EEXIST`,`open`,e);if(!t.allowDirectory&&o.mode&16384)throw N(`EISDIR`,`open`,e);let s=new Mr(this,e,a,r,wr(i).ref(a,o));return r&512&&s.truncateSync(0),s}function ti(e){e=H(e);let{fs:t,stats:n,path:r}=$r(this,e,!0,{syscall:`readlink`});if(!n)throw N(`ENOENT`,`readlink`,e);if(Y&&!J(this,n,4))throw N(`EACCES`,`readlink`,e);if(!Fn(n))throw N(`EINVAL`,`readlink`,e);let i=n.size,a=new Uint8Array(i);return t.readSync(r,a,0,i),E(a)}function ni(e,t={}){let n=H(e),r={syscall:`mkdir`,path:n},{fullPath:i}=$r(this,W(n),!1,r),{fs:a,path:o}=X(U(i,mn(n)),this,r),s=i!=W(n),{euid:c,egid:l}=Le(this).credentials,{mode:u=511,recursive:d}=t,f,p=(e,t)=>{let n={stack:[],error:void 0,hasError:!1};try{let i=W(t),m=d&&i!=`/`?p(W(e),i):a.statSync(i);if(d){let n;try{n=wr(a).get(t)?.inode??a.statSync(t)}catch{}if(n){let i=Fn(n)?$r(this,e,!1,r).stats:n;if(!i)throw N(`ENOENT`,r);if(!q(i))throw N(t==o?`EEXIST`:`ENOTDIR`,r);return n}if(s&&a.existsSync(U(i,mn(e))))throw N(`ENOENT`,r)}if(Y&&!J(this,m,2))throw N(`EACCES`,`mkdir`,e);Zr(n,Er(a,i,`rw`,m),!1);let h=Hr(a,`mkdirSync`,{path:e,syscall:`mkdir`})(t,{mode:u,uid:m.mode&2048?m.uid:c,gid:m.mode&1024?m.gid:l});return d&&(f??=e),ua(this,`rename`,e),h}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}};return p(n,o),f}function ri(e,t={}){e=H(e);let{fs:n,path:r}=$r(this,e),i=wr(n).get(r)?.inode??Hr(n,`statSync`,{path:e,syscall:`scandir`})(r);if(Y&&!J(this,i,4))throw N(`EACCES`,`scandir`,e);if(!q(i))throw N(`ENOTDIR`,`scandir`,e);let a;{let e={stack:[],error:void 0,hasError:!1};try{Zr(e,Er(n,r,`ro`,i),!1),a=n.readdirSync(r)}catch(t){e.error=t,e.hasError=!0}finally{Qr(e)}}let o=[],s=e=>{let i;try{i=n.statSync(U(r,e))}catch(e){if(e.code==`ENOENT`)return;throw e}let a=new mr;if(a.ino=i.ino,a.type=fr(i.mode),a.path=e,a.name=mn(e),o.push(a),!q(i)||!t?.recursive)return;let c=n.readdirSync(U(r,e));for(let t of c)s(U(e,t))};for(let e of a)s(e);return o}function ii(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`rename`,path:e,dest:t},i=$r(this,e,!0,r),a=X(t,this,r);if(i.fs.uuid!==a.fs.uuid)throw N(`EXDEV`,r);if(a.path.startsWith(i.path+`/`))throw N(`EINVAL`,r);if(!i.stats)throw N(`ENOENT`,r);let o=i.fs,s=o.statSync(W(i.path)),c=o.statSync(W(a.path)),l;try{l=o.statSync(a.path)}catch(e){if(e.code!=`ENOENT`)throw e}if(Y&&(!J(this,s,4)||!J(this,c,2)))throw N(`EACCES`,r);if(l&&!q(i.stats)&&q(l))throw N(`EISDIR`,r);if(l&&q(i.stats)&&!q(l))throw N(`ENOTDIR`,r);let u=W(i.path),d=W(a.path),f=[[u,s],[d,c]];s.ino>c.ino&&f.reverse(),Zr(n,Er(o,f[0][0],`rw`,f[0][1]),!1),Zr(n,s.ino==c.ino?null:Er(o,f[1][0],`rw`,f[1][1]),!1),i.fs.renameSync(i.path,a.path),wr(o).rename(i.path,a.path),ua(this,`rename`,e),ua(this,`rename`,t)}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}}function ai(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`link`,path:e,dest:t},{fs:i,path:a}=X(e,this,r),o=X(t,this,r);if(i.uuid!==o.fs.uuid)throw N(`EXDEV`,r);let s=i.statSync(a);if(Y){if(!J(this,s,4))throw N(`EACCES`,r);let e=i.statSync(W(a));if(!J(this,e,4))throw N(`EACCES`,r);let t=i.statSync(W(o.path));if(!J(this,t,2))throw N(`EACCES`,r)}Zr(n,Er(i,W(o.path),`rw`),!1),i.linkSync(a,o.path),wr(i).link(a,o.path)}catch(e){n.error=e,n.hasError=!0}finally{Qr(n)}}function oi(e,t){e=H.call(this,e);let n={syscall:t?`lstat`:`stat`,path:e},r;if(!t)r=$r(this,e,!1,n).stats;else{let{base:t,dir:i}=_n(e),{fs:a,path:o}=$r(this,i,!1,n);try{let e=t?U(o,t):o;r=wr(a).get(e)?.inode??a.statSync(e)}catch(e){throw j(Object.assign(e,n)),e}}if(!r)throw N(`ENOENT`,n);if(Y&&!J(this,r,4))throw N(`EACCES`,n);return r}var si=class e{ino;type;_name;get name(){let e=lr.Buffer.from(this._name);return this._encoding==`buffer`?e:e.toString(this._encoding)}_encoding;_parentPath;get parentPath(){return this._parentPath}get path(){return R(`Dirent.path was removed in Node v24, use parentPath instead`),this._parentPath}static from(t,n,r=`.`){let i=new e,{base:a,dir:o}=_n(t.path);return i._parentPath=U(r,o),i._name=a,i.ino=t.ino,i.type=t.type,i._encoding=n,i}isFile(){return this.type===dr.REG}isDirectory(){return this.type===dr.DIR}isBlockDevice(){return this.type===dr.BLK}isCharacterDevice(){return this.type===dr.CHR}isSymbolicLink(){return this.type===dr.LNK}isFIFO(){return this.type===dr.FIFO}isSocket(){return this.type===dr.SOCK}};function ci(){return Object.assign(Error(`Directory handle was closed`),{code:`ERR_DIR_CLOSED`})}var li=class{path;context;closed=!1;checkClosed(){if(this.closed)throw ci()}_entries;constructor(e,t){this.path=e,this.context=t}close(e){if(this.closed){let t=ci();if(!e)return Promise.reject(t);e(t);return}if(this.closed=!0,!e)return Promise.resolve();e(null)}closeSync(){if(this.closed)throw ci();this.closed=!0}async _read(){return this.checkClosed(),this._entries??=await xo.call(this.context,this.path,{withFileTypes:!0}),this._entries.length?this._entries.shift()??null:null}read(e){if(!e)return this._read();this._read().then(t=>e(null,t))}readSync(){return this.checkClosed(),this._entries??=Fi.call(this.context,this.path,{withFileTypes:!0}),this._entries.length?this._entries.shift()??null:null}async next(){let e=await this._read();return e?{done:!1,value:e}:(await this.close(),{done:!0,value:void 0})}[Symbol.asyncIterator](){return this}[Symbol.dispose](){this.closed||this.closeSync()}async[Symbol.asyncDispose](){this.closed||await this.close()}},ui=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},di=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});function fi(e,t){return ii.call(this,e,t)}function pi(e){e=H(e);try{let{fs:t,path:n}=$r(this,e);return t.existsSync(n)}catch(e){if(e.errno==k.ENOENT)return!1;throw e}}function mi(e,t){let n=oi.call(this,e,!1);return t?.bigint?new Sn(n):new xn(n)}function hi(e,t){let n=oi.call(this,e,!0);return t?.bigint?new Sn(n):new xn(n)}function gi(e,t=0){let n={stack:[],error:void 0,hasError:!1};try{let r=ui(n,ei.call(this,e,{flag:`r+`}),!1);if(t||=0,t<0)throw N(`EINVAL`,`truncate`,e.toString());r.truncateSync(t)}catch(e){n.error=e,n.hasError=!0}finally{di(n)}}function _i(e){e=H(e);let{fs:t,path:n}=X(e,this);try{let e={stack:[],error:void 0,hasError:!1};try{if(Y&&!J(this,t.statSync(n),2))throw N(`EACCES`,`unlink`);ui(e,Er(t,W(n),`rw`),!1),t.unlinkSync(n),wr(t).remove(n)}catch(t){e.error=t,e.hasError=!0}finally{di(e)}}catch(t){throw j(Object.assign(t,{syscall:`unlink`,path:e}))}ua(this,`rename`,e.toString())}function vi(e,t,n=0){return Nr(ei.call(this,e,{flag:t,mode:n}))}function yi(e,t,n){return Nr(ei.call(this,e,{flag:t,mode:n,preserveSymlinks:!0}))}function bi(e,t={}){let n={stack:[],error:void 0,hasError:!1};try{let r=tn(t,null,`r`,420);if(Lr(r.flag)&1)throw N(`EBADF`,`read`,e.toString());let i=ui(n,typeof e==`number`?Pr(this,e):ei.call(this,e.toString(),{flag:r.flag,mode:420,preserveSymlinks:!1}),!1),{size:a}=i.stat(),o=lr.Buffer.alloc(a);return i.readSync(o,0,a,0),r.encoding?o.toString(r.encoding):o}catch(e){n.error=e,n.hasError=!0}finally{di(n)}}function xi(e,t,n={}){let r={stack:[],error:void 0,hasError:!1};try{let i=tn(n,`utf8`,`w+`,420),a=Lr(i.flag);if(!(a&1||a&2))throw new M(k.EINVAL,`Flag passed to writeFile must allow for writing`);if(typeof t!=`string`&&!i.encoding)throw new M(k.EINVAL,`Encoding not specified`);let o=typeof t==`string`?lr.Buffer.from(t,i.encoding):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);if(!o)throw new M(k.EINVAL,`Data not specified`);ui(r,typeof e==`number`?Pr(this,e):ei.call(this,e.toString(),{flag:a,mode:i.mode}),!1).writeSync(o,0,o.byteLength,0),ua(this,`change`,e.toString())}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Si(e,t,n={}){let r=tn(n,`utf8`,`a+`,420),i=Lr(r.flag);if(!(i&1024))throw new M(k.EINVAL,`Flag passed to appendFile must allow for appending`);if(typeof t!=`string`&&!r.encoding)throw new M(k.EINVAL,`Encoding not specified`);let a=typeof t==`string`?lr.Buffer.from(t,r.encoding):new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=typeof e==`number`?Pr(this,e):ei.call(this,H(e),{flag:i,mode:r.mode});o.writeSync(a,0,a.byteLength),typeof o!=`number`&&o.closeSync()}function Ci(e,t){let n=Pr(this,e).stat();return t?.bigint?new Sn(n):new xn(n)}function wi(e){Pr(this,e).closeSync(),Fr(this,e)}function Ti(e,t=0){if(t||=0,t<0)throw new M(k.EINVAL);Pr(this,e).truncateSync(t)}function Ei(e){Pr(this,e).syncSync()}function Di(e){Pr(this,e).datasyncSync()}function Oi(e,t,n,r,i){let a,o,s,c;if(typeof t==`string`){c=typeof n==`number`?n:null;let e=typeof r==`string`?r:`utf8`;o=0,a=lr.Buffer.from(t,e),s=a.byteLength}else a=new Uint8Array(t.buffer,t.byteOffset,t.byteLength),o=n,s=r,c=typeof i==`number`?i:null;let l=Pr(this,e);c??=l.position;let u=l.writeSync(a,o,s,c);return ua(this,`change`,l.path),u}function ki(e,t,n,r,i){let a=Pr(this,e),o=typeof n==`object`?n.offset:n;if(typeof n==`object`&&(r=n.length,i=n.position),i&&i>2**53-1)throw N(`EINVAL`);return typeof i==`bigint`&&(i=Number(i)),i=Number.isSafeInteger(i)?i:a.position,a.readSync(t,o,r,i)}function Ai(e,t,n){Pr(this,e).chownSync(t,n)}function ji(e,t){let n=Zt(t,-1);if(n<0)throw new M(k.EINVAL,`Invalid mode.`);Pr(this,e).chmodSync(n)}function Mi(e,t,n){Pr(this,e).utimesSync(en(t),en(n))}function Ni(e){let t={stack:[],error:void 0,hasError:!1};try{e=H(e);let{fs:n,path:r}=$r(this,e),i=Hr(n,`statSync`,{path:e,syscall:`rmdir`})(r);if(!q(i))throw N(`ENOTDIR`,`rmdir`,e);if(Y&&!J(this,i,2))throw N(`EACCES`,`rmdir`,e);ui(t,Er(n,W(r),`rw`),!1),Hr(n,`rmdirSync`,e)(r),wr(n).remove(r),ua(this,`rename`,e.toString())}catch(e){t.error=e,t.hasError=!0}finally{di(t)}}function Pi(e,t){t=typeof t==`object`?t:{mode:t};let n=Zt(t?.mode,511);return ni.call(this,e,{...t,mode:n})}function Fi(e,t){t=typeof t==`object`?t:{encoding:t},e=H(e);let n=[],r=ri.call(this,e,t??void 0);for(let i of r)t?.withFileTypes?n.push(si.from(i,t.encoding,e)):t?.encoding==`buffer`?n.push(lr.Buffer.from(i.path)):n.push(i.path);return n}function Ii(e,t){return ai.call(this,e,t)}function Li(e,t,n=`file`){let r={stack:[],error:void 0,hasError:!1};try{if(![`file`,`dir`,`junction`].includes(n))throw TypeError(`Invalid symlink type: `+n);t=H(t);let i=ui(r,ei.call(this,t,{flag:`wx`,mode:420}),!1);i.writeSync(T(H(e,!0))),i.chmodSync(Qe)}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Ri(e,t){let n=lr.Buffer.from(ti.call(this,e)),r=typeof t==`object`?t?.encoding:t;return r==`buffer`?n:n.toString(r??`utf-8`)}function zi(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{ui(r,ei.call(this,e,{flag:`r+`,mode:0}),!1).chownSync(t,n)}catch(e){r.error=e,r.hasError=!0}finally{di(r)}}function Bi(e,t,n){let r=yi.call(this,e,`r+`);Ai.call(this,r,t,n),wi.call(this,r)}function Vi(e,t){let n;try{n=vi.call(this,e,`r+`)}catch(t){throw j(Object.assign(t,{syscall:`chmod`,path:H(e)}))}ji.call(this,n,t),wi.call(this,n)}function Hi(e,t){let n=yi.call(this,e,`r+`);ji.call(this,n,t),wi.call(this,n)}function Ui(e,t,n){let r=vi.call(this,e,`r+`);Mi.call(this,r,t,n),wi.call(this,r)}function Wi(e,t,n){let r=yi.call(this,e,`r+`);Mi.call(this,r,t,n),wi.call(this,r)}function Gi(e,t){let n=typeof t==`string`?t:t?.encoding??`utf8`;e=H(e,!0);let{fullPath:r}=$r(this,e);if(n==`utf8`||n==`utf-8`)return r;let i=lr.Buffer.from(r,`utf-8`);return n==`buffer`?i:i.toString(n)}function Ki(e,t=384){if(Y&&!J(this,mi.call(this,e),t))throw new M(k.EACCES)}function qi(e,t){e=H(e);let n;try{n=hi.bind(this)(e)}catch(e){if(e.code!=`ENOENT`||!t?.force)throw e}if(n)switch(n.mode&Xe){case tt:if(t?.recursive)for(let n of Fi.call(this,e))qi.call(this,U(e,n),t);Ni.call(this,e);break;case $e:case Qe:case et:case nt:_i.call(this,e);break;case rt:case Ze:default:throw N(`ENOSYS`,`rm`,e)}}function Ji(e,t){let n=typeof t==`object`?t?.encoding:t||`utf8`,r=an(e);return Pi.call(this,r),n==`buffer`?lr.Buffer.from(r):r}function Yi(e,t){let n=an(e);Pi.call(this,n);let r=()=>qi(n,{recursive:!0,force:!0});return{path:n,remove:r,[Symbol.dispose]:r}}function Xi(e,t,n){if(e=H(e),t=H(t),n&&n&1&&pi.call(this,t))throw N(`EEXIST`,`copyFile`,t);xi.call(this,t,bi.call(this,e)),ua(this,`rename`,t.toString())}function Zi(e,t,n){let r=Pr(this,e),i=0;for(let e of t)i+=r.readSync(e,0,e.byteLength,n+i);return i}function Qi(e,t,n){let r=Pr(this,e),i=0;for(let e of t)i+=r.writeSync(new Uint8Array(e.buffer),0,e.byteLength,n+i);return i}function $i(e,t){return e=H(e),new li(e,this)}function ea(e,t,n){e=H(e),t=H(t);let r=hi.call(this,e);if(n?.errorOnExist&&pi.call(this,t))throw N(`EEXIST`,`cp`,t);switch(r.mode&Xe){case tt:if(!n?.recursive)throw N(`EISDIR`,`cp`,e);Pi.call(this,t,{recursive:!0});for(let r of Fi.call(this,e,{withFileTypes:!0}))n.filter&&!n.filter(U(e,r.name),U(t,r.name))||ea.call(this,U(e,r.name),U(t,r.name),n);break;case Qe:if(n?.dereference)Xi.call(this,e,t);else{let r=Ri.call(this,e,`utf8`);Li.call(this,n?.verbatimSymlinks?r:un.call(this,W(e),r),t)}break;case $e:Xi.call(this,e,t);break;case et:case nt:case rt:case Ze:default:throw N(`ENOSYS`,`cp`,e)}n?.preserveTimestamps&&Ui.call(this,t,r.atime,r.mtime)}function ta(e,t){e=H(e);let{fs:n}=X(e,this);return qr(n,t?.bigint)}function na(e,t={}){e=Array.isArray(e)?e:[e];let{cwd:n=`/`,withFileTypes:r=!1,exclude:i=()=>!1}=t,a=e.map(e=>e.replace(/^\/+/g,``)),o=a.some(e=>e.includes(`**`)),s=a.map(e=>{let t=e.search(/[*?[\]{]/);if(t===-1)return e;let n=e.lastIndexOf(`/`,t);return n===-1?``:e.slice(0,n)}),c=a.map(nn),l=[];function u(e){let t=Fi(e,{withFileTypes:r,encoding:`utf8`});for(let n of t){let t=U(e,r?n.name:n);if(typeof i==`function`?i(r?n:t):i.some(e=>vn(e,t)))continue;let a=t.replace(/^\/+/g,``);mi(t).isDirectory()&&(o||s.some(e=>a===e||e.startsWith(a+`/`)))&&u(t),c.some(e=>e.test(a))&&l.push(r?n:a)}}return u(n instanceof URL?n.pathname:n),l}var ra=mi,ia=class extends u.default{_context;path;off(e,t,n,r){return super.off(e,t,n,r)}removeListener(e,t,n,r){return super.removeListener(e,t,n,r)}constructor(e,t){super(),this._context=e,this.path=t}setMaxListeners(){throw N(`ENOSYS`,`Watcher.setMaxListeners`)}getMaxListeners(){throw N(`ENOSYS`,`Watcher.getMaxListeners`)}prependListener(){throw N(`ENOSYS`,`Watcher.prependListener`)}prependOnceListener(){throw N(`ENOSYS`,`Watcher.prependOnceListener`)}rawListeners(){throw N(`ENOSYS`,`Watcher.rawListeners`)}ref(){return this}unref(){return this}},aa=class extends ia{options;realpath;constructor(e,t,n){let r=Le(e);super(r,t),this.options=n,this.realpath=U(r.root,t),ca(this.realpath,this)}close(){super.emit(`close`),la(this.realpath,this)}[Symbol.dispose](){this.close()}},oa=class extends ia{options;intervalId;previous;constructor(e,t,n){super(e,t),this.options=n,this.start()}onInterval(){try{let e=ra.call(this._context,this.path);Cn(this.previous,e)||(this.emit(`change`,e,this.previous),this.previous=e)}catch(e){this.emit(`error`,e)}}start(){let e=this.options.interval||5e3;try{this.previous=ra.call(this._context,this.path)}catch(e){this.emit(`error`,e);return}this.intervalId=setInterval(this.onInterval.bind(this),e),!this.options.persistent&&typeof this.intervalId==`object`&&this.intervalId.unref()}stop(){this.intervalId&&=(clearInterval(this.intervalId),void 0),this.removeAllListeners()}},sa=new Map;function ca(e,t){let n=H(e);sa.has(n)||sa.set(n,new Set),sa.get(n).add(t)}function la(e,t){let n=H(e);sa.has(n)&&(sa.get(n).delete(t),sa.get(n).size===0&&sa.delete(n))}function ua(e,t,n){let r=Le(e);r&&(n=U(r.root??`/`,n)),n=H(n);for(let e=n;;e=W(e)){let r=sa.get(e);if(r)for(let i of r)i.emit(`change`,t,pn.call(i._context,e,n)||mn(n));if(e===`/`)break}}var da=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},fa=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});async function pa(e,t,n,r){if(t=un.call(e,t),n){let n=X(t,e,r),i=wr(n.fs).get(n.path)?.inode??await n.fs.stat(n.path).catch(()=>void 0);return{...n,fullPath:t,stats:i}}try{let i=X(t,e),a=wr(i.fs).get(i.path)?.inode??await i.fs.stat(i.path);return Fn(a)?await pa(e,un.call(e,W(t),await ha.call(e,t)),n,r):{...i,fullPath:t,stats:a}}catch{}let{base:i,dir:a}=_n(t),o=a==`/`?`/`:(await pa(e,a,!1,r)).fullPath,s=U(o,i),c=X(s,e),l=wr(c.fs).get(c.path)?.inode??await c.fs.stat(c.path).catch(e=>{if(e.code!=`ENOENT`)throw j(Object.assign(e,{syscall:`stat`,path:s,...r}))});return l?Fn(l)?await pa(e,un.call(e,o,await ha.call(e,s)),!1,r):{...c,fullPath:s,stats:l}:{...c,fullPath:s}}async function ma(e,t,n){t=H(t);let r=Zt(n.mode,420),i=Lr(n.flag),a={syscall:`open`,path:t},{fs:o,path:s,stats:c}=await pa(e,t,n.preserveSymlinks,a);if(!c){let l={stack:[],error:void 0,hasError:!1};try{if(!(i&64))throw N(`ENOENT`,a);let u=W(s),d=await o.stat(u);if(Y&&!J(e,d,2))throw N(`EACCES`,`open`,W(t));if(!q(d))throw N(`ENOTDIR`,`open`,W(t));if(!n.allowDirectory&&r&16384)throw N(`EISDIR`,`open`,t);if(da(l,await Tr(o,u,`rw`,d),!1),c=wr(o).get(s)?.inode??await o.stat(s).catch(()=>void 0),!c){let{euid:n,egid:a}=Le(e).credentials,c=await o.createFile(s,{mode:r,uid:d.mode&2048?d.uid:n,gid:d.mode&1024?d.gid:a});return ua(e,`rename`,t),new Mr(e,t,s,i,wr(o).ref(s,c))}}catch(e){l.error=e,l.hasError=!0}finally{fa(l)}}if(Y&&!J(e,c,zr(i)))throw N(`EACCES`,a);if(i&128)throw N(`EEXIST`,a);if(!n.allowDirectory&&r&16384)throw N(`EISDIR`,`open`,t);let l=new Mr(e,t,s,i,wr(o).ref(s,c));return i&512&&await l.truncate(0),l}async function ha(e){e=H(e);let t={syscall:`readlink`,path:e},{fs:n,stats:r,path:i}=await pa(this,e,!0,t);if(!r)throw N(`ENOENT`,t);if(Y&&!J(this,r,4))throw N(`EACCES`,t);if(!Fn(r))throw N(`EINVAL`,t);let a=r.size,o=new Uint8Array(a);return await n.read(i,o,0,a),E(o)}async function ga(e,t={}){let n=H(e),{euid:r,egid:i}=Le(this).credentials,{mode:a=511,recursive:o}=t,s={syscall:`mkdir`,path:n},{fullPath:c}=await pa(this,W(n),!1,s),{fs:l,path:u}=X(U(c,mn(n)),this,s),d=c!=W(n),f,p=async(e,t)=>{let n={stack:[],error:void 0,hasError:!1};try{let c=W(t),m=o&&c!=`/`?await p(W(e),c):await l.stat(c);if(da(n,await Tr(l,c,`rw`,m),!1),o){let n=wr(l).get(t)?.inode??await l.stat(t).catch(()=>null);if(n){let r=Fn(n)?(await pa(this,e,!1,s)).stats:n;if(!r)throw N(`ENOENT`,s);if(!q(r))throw N(t==u?`EEXIST`:`ENOTDIR`,s);return n}if(d&&await l.exists(U(c,mn(e))))throw N(`ENOTDIR`,`mkdir`,e)}if(Y&&!J(this,m,2))throw N(`EACCES`,`mkdir`,e);let h=await l.mkdir(t,{mode:a,uid:m.mode&2048?m.uid:r,gid:m.mode&1024?m.gid:i}).catch(F({syscall:`mkdir`,path:e}));return o&&(f??=e),ua(this,`rename`,e),h}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}};return await p(n,u),f}async function _a(e,t={}){e=H(e);let n={syscall:`scandir`,path:e},{fs:r,path:i,stats:a}=await pa(this,e,!1,n);if(!a)throw N(`ENOENT`,n);if(Y&&!J(this,a,4))throw N(`EACCES`,n);if(!q(a))throw N(`ENOTDIR`,n);let o;{let e={stack:[],error:void 0,hasError:!1};try{da(e,await Tr(r,i,`ro`,a),!1),o=await r.readdir(i)}catch(t){e.error=t,e.hasError=!0}finally{fa(e)}}let s=[],c=async e=>{let n=await r.stat(U(i,e)).catch(e=>{if(e.code!=`ENOENT`)throw e});if(!n)return;let a=new mr;if(a.ino=n.ino,a.type=fr(n.mode),a.path=e,a.name=mn(e),s.push(a),!t.recursive||!q(n))return;let o=await r.readdir(U(i,e));for(let t of o)await c(U(e,t))};return await Promise.all(o.map(c)),s}async function va(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`rename`,path:e,dest:t},i=await pa(this,e,!0,r),a=X(t,this,r);if(i.fs.uuid!==a.fs.uuid)throw N(`EXDEV`,r);if(a.path.startsWith(i.path+`/`))throw N(`EINVAL`,r);if(!i.stats)throw N(`ENOENT`,r);let o=i.fs,s=await o.stat(W(i.path)),c=await o.stat(W(a.path)),l=await o.stat(a.path).catch(e=>{if(e.code==`ENOENT`)return null;throw e});if(Y&&(!J(this,s,4)||!J(this,c,2)))throw N(`EACCES`,r);if(l&&!q(i.stats)&&q(l))throw N(`EISDIR`,r);if(l&&q(i.stats)&&!q(l))throw N(`ENOTDIR`,r);let u=W(i.path),d=W(a.path),f=[[u,s],[d,c]];s.ino>c.ino&&f.reverse(),da(n,await Tr(o,f[0][0],`rw`,f[0][1]),!1),da(n,s.ino==c.ino?null:await Tr(o,f[1][0],`rw`,f[1][1]),!1),await i.fs.rename(i.path,a.path),wr(o).rename(i.path,a.path),ua(this,`rename`,e),ua(this,`rename`,t)}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}}async function ya(e,t){let n={stack:[],error:void 0,hasError:!1};try{e=H(e),t=H(t);let r={syscall:`link`,path:e,dest:t},{fs:i,path:a}=X(e,this,r),o=X(t,this,r);if(i.uuid!=o.fs.uuid)throw N(`EXDEV`,r);let s=await i.stat(a);if(Y){if(!J(this,s,4))throw N(`EACCES`,r);let e=await i.stat(W(a));if(!J(this,e,4))throw N(`EACCES`,r);let t=await i.stat(W(o.path));if(!J(this,t,2))throw N(`EACCES`,r)}da(n,await Tr(i,W(o.path),`rw`),!1),await i.link(a,o.path),wr(i).link(a,o.path)}catch(e){n.error=e,n.hasError=!0}finally{fa(n)}}async function ba(e,t){e=H.call(this,e);let n={syscall:t?`lstat`:`stat`,path:e},r;if(!t)r=(await pa(this,e,!1,n)).stats;else{let{base:t,dir:i}=_n(e),{fs:a,path:o}=await pa(this,i,!1,n),s=t?U(o,t):o;r=wr(a).get(s)?.inode??await a.stat(s).catch(F(n))}if(!r)throw N(`ENOENT`,n);if(Y&&!J(this,r,4))throw N(`EACCES`,n);return r}var xa=class extends u.default{input;output;terminal;line=``;_cursor=0;get cursor(){return this._cursor}_buffer=``;_closed=!1;_paused=!1;_prompt=``;_history=[];_historyIndex=-1;_currentLine=``;constructor(e,t,n,r=!1){super(),this.input=e,this.output=t,this.terminal=r,this.input.on(`data`,this._onData),this.input.on(`end`,this.close.bind(this)),this.input.on(`close`,this.close.bind(this))}_onData=e=>{if(!(this._paused||this._closed)){this._buffer+=typeof e==`string`?e:e.toString(`utf8`);for(let e=this._buffer.indexOf(`
2
2
  `);e>=0;e=this._buffer.indexOf(`
3
3
  `)){let t=this._buffer.substring(0,e);t.endsWith(`\r`)&&(t=t.substring(0,t.length-1)),this._buffer=this._buffer.substring(e+1),this.line=t,t.trim()&&!t.trim().match(/^\s*$/)&&this._history.at(-1)!=t&&(this._history.push(t),this._historyIndex=this._history.length,this.emit(`history`,this._history)),this.emit(`line`,t)}}};close(){if(!this._closed){if(this._closed=!0,this.input?.removeAllListeners?.(),this._buffer.length){let e=this._buffer;this._buffer=``,this.line=e,this.emit(`line`,e)}this.emit(`history`,this._history),this.emit(`close`),this.removeAllListeners()}}pause(){return this._paused?this:(this._paused=!0,`pause`in this.input&&this.input.pause(),this.emit(`pause`),this)}resume(){return this._paused?(this._paused=!1,`resume`in this.input&&this.input.resume(),this.emit(`resume`),this):this}setPrompt(e){this._prompt=e}getPrompt(){return this._prompt}prompt(e){if(!this.output)return;if(!e){this.output.write(this._prompt);return}let{cols:t}=this.getCursorPos();this.output.write(this._prompt),this._cursor=t}write(e,t){if(!this._closed){if(e){let t=typeof e==`string`?e:e.toString(`utf8`);this._onData(t)}if(!(!t||!this.terminal))switch((t.ctrl?`^`:``)+t.name){case`^c`:this.emit(`SIGINT`);break;case`^z`:this.emit(`SIGTSTP`);break;case`^q`:this.emit(`SIGCONT`);break;case`home`:case`^a`:if(!this.output)return;wa(this.output,-this._cursor,0),this._cursor=0,this._cursor=0;break;case`^e`:case`end`:{if(!this.output)return;let e=this.line.length-this._cursor;if(!e)return;wa(this.output,e,0),this._cursor=this.line.length,this._cursor=this.line.length;break}case`^k`:{if(!this.output||this._cursor>=this.line.length)return;let e=this.line.slice(0,this._cursor);Ca(this.output,1),this.line=e;break}case`^u`:{if(!this.output||!this._cursor)return;let e=this.line.slice(this._cursor);Ca(this.output,0),wa(this.output,0,0),this.output.write(this._prompt+e),this.line=e,this._cursor=0,this._cursor=0;break}case`^w`:{if(!this.output||!this._cursor)return;let e=this._cursor-1;for(;e>=0&&this.line[e]===` `;)e--;for(;e>=0&&this.line[e]!==` `;)e--;let t=this.line.slice(0,e+1)+this.line.slice(this._cursor),n=e+1;this._renderLine(t),this._cursor=n,this._cursor=n,wa(this.output,-t.length,0),wa(this.output,n,0);break}case`^return`:case`^enter`:this._onData(`
4
4
  `);break;case`return`:case`enter`:this._onData((e?typeof e==`string`?e:e.toString(`utf8`):``)+`
@@ -9,4 +9,4 @@ import{i as e,n as t,t as n}from"./rolldown-runtime-Dd_uD5pT.js";import{n as r,t
9
9
  `+Error().stack.slice(6);if(!t)throw L(P(`EINVAL`,`Can not make an RPC request without a port`));let{resolve:a,reject:o,promise:s}=Promise.withResolvers(),c=Math.random().toString(16).slice(5),l={resolve:a,reject:o,promise:s,fs:r,timeout:setTimeout(()=>{let e=L(P(`ETIMEDOUT`,`RPC request timed out`));e.stack+=i,Ns(c),o(e)},n)};return Ps.set(c,l),t.send({...e,_zenfs:!0,id:c,stack:i}),s}function Is(e,...t){return t.includes(e.method)}function Ls(e){if(!Ms(e))return;if(!Ps.has(e.id)){let t=L(P(`EIO`,`Invalid RPC id: `+e.id));throw t.stack+=e.stack,t}let{resolve:t,reject:n}=Ps.get(e.id);if(e.error){let t=M.fromJSON({code:`EIO`,errno:k.EIO,...e.error});t.stack+=e.stack,Ns(e.id),n(t);return}Ns(e.id),t(Is(e,`stat`,`createFile`,`mkdir`)?new K(e.value):e.value)}function Rs(e,t){if(!e)throw L(P(`EINVAL`,`Cannot attach to non-existent port`));pe(`Attached handler to port: `+t.name),e.addHandler(t)}function zs(e,t){if(!e)throw L(P(`EINVAL`,`Cannot detach from non-existent port`));pe(`Detached handler from port: `+t.name),e.removeHandler(t)}function Bs(e){let t=[],n=t.push.bind(t);return Rs(e,n),async function(r){zs(e,n);for(let n of t)await Vs(e,r,`data`in n?n.data:n)}}async function Vs(e,t,n){if(!Ms(n))return;let r,i,a=[];try{switch(n.method){case`read`:{let[e,i,a,o]=n.args;await t.read(e,i,a,o),r=i;break}case`stat`:case`createFile`:case`mkdir`:{let e=await t[n.method](...n.args),i=e instanceof K?e:new K(e);r=new Uint8Array(i.buffer,i.byteOffset,i.byteLength);break}case`touch`:{let[e,i]=n.args;await t.touch(e,new K(i)),r=void 0;break}default:r=await t[n.method](...n.args)}}catch(e){i=e instanceof M?e.toJSON():p(e,`message`,`stack`)}e.send({_zenfs:!0,...p(n,`id`,`method`,`stack`),error:i,value:r},a)}var Hs=[`rename`,`stat`,`touch`,`createFile`,`unlink`,`rmdir`,`mkdir`,`readdir`,`exists`,`link`,`sync`,`read`,`write`];function Us(e){class t extends e{async done(){return this.sync()}queueDone(){return this.sync()}_promise=Promise.resolve();_async(e){this._promise=this._promise.finally(()=>e())}_isInitialized=!1;_skippedCacheUpdates=0;constructor(...e){super(...e),this._patchAsync()}async ready(){if(await super.ready(),!(this._isInitialized||this.attributes.has(`no_async_preload`))){if(await this._promise,this.checkSync(),await this._sync.ready(),this._sync instanceof Xn&&this instanceof Xn){let e=this._sync.transaction(),t=this.transaction(),n=[];for(let r of await t.keys())n.push(t.get(r).then(t=>e.setSync(r,t)));await Promise.all(n),this._isInitialized=!0;return}try{await this.crossCopy(`/`),me(`Skipped ${this._skippedCacheUpdates} updates to the sync cache during initialization`),this._isInitialized=!0}catch(e){throw this._isInitialized=!1,de(e)}}}checkSync(){if(this.attributes.has(`no_async_preload`))throw P(`ENOTSUP`,`Sync preloading has been disabled for this async file system`);if(!this._sync)throw de(P(`ENOTSUP`,`No sync cache is attached to this async file system`))}renameSync(e,t){this.checkSync(),this._sync.renameSync(e,t),this._async(()=>this.rename(e,t))}statSync(e){return this.checkSync(),this._sync.statSync(e)}touchSync(e,t){this.checkSync(),this._sync.touchSync(e,t),this._async(()=>this.touch(e,t))}createFileSync(e,t){this.checkSync();let n=this._sync.createFileSync(e,t);return this._async(()=>this.createFile(e,t)),n}unlinkSync(e){this.checkSync(),this._sync.unlinkSync(e),this._async(()=>this.unlink(e))}rmdirSync(e){this.checkSync(),this._sync.rmdirSync(e),this._async(()=>this.rmdir(e))}mkdirSync(e,t){this.checkSync();let n=this._sync.mkdirSync(e,t);return this._async(()=>this.mkdir(e,t)),n}readdirSync(e){return this.checkSync(),this._sync.readdirSync(e)}linkSync(e,t){this.checkSync(),this._sync.linkSync(e,t),this._async(()=>this.link(e,t))}async sync(){!this.attributes.has(`no_async_preload`)&&this._sync&&this._sync.syncSync(),await this._promise.catch(()=>{})}syncSync(){this.checkSync(),this._sync.syncSync()}existsSync(e){return this.checkSync(),this._sync.existsSync(e)}readSync(e,t,n,r){this.checkSync(),this._sync.readSync(e,t,n,r)}writeSync(e,t,n){this.checkSync(),this._sync.writeSync(e,t,n),this._async(()=>this.write(e,t,n))}streamWrite(e,t){this.checkSync();let n=this._sync.streamWrite(e,t).getWriter(),r=super.streamWrite(e,t).getWriter();return new WritableStream({async write(e,t){await Promise.all([n.write(e),r.write(e)]).catch(t.error.bind(t))},async close(){await Promise.all([n.close(),r.close()])},async abort(e){await Promise.all([n.abort(e),r.abort(e)])}})}async crossCopy(e){this.checkSync();let t=await this.stat(e);if(!q(t)){this._sync.createFileSync(e,t);let n=new Uint8Array(t.size);await this.read(e,n,0,t.size),this._sync.writeSync(e,n,0),this._sync.touchSync(e,t);return}e!==`/`&&(this._sync.mkdirSync(e,t),this._sync.touchSync(e,t));let n=[];for(let t of await this.readdir(e))n.push(this.crossCopy(U(e,t)));await Promise.all(n)}_patchAsync(){let e=[`read`,`readdir`,`stat`,`exists`],t=Hs.filter(t=>!e.includes(t));for(let e of t){let t=this[e].bind(this);function n(t,r){if(r||(r=Error(),Error.captureStackTrace(r,n)),!r.stack)return!1;let i=r.stack.split(`
10
10
  `).slice(t).join(`
11
11
  `);return i.includes(`at <computed> [as ${e}]`)||i.includes(`at async <computed> [as ${e}]`)||i.includes(`${e}Sync `)}this[e]=async(...r)=>{let i=await t(...r);if(n(2))return i;if(!this._isInitialized)return this._skippedCacheUpdates++,i;try{this._sync?.[`${e}Sync`]?.(...r)}catch(e){if(n(3,e))return i;throw e.message+=` (Out of sync!)`,L(e)}return i}}me(`Async: patched ${t.length} methods`)}}return t}var Ws=class extends Us(Un){channel;timeout;port;_sync=er.create({label:`tmpfs:port`});constructor(e,t=250){super(1886351988,`portfs`),this.channel=e,this.timeout=t,this.port=Os(e),Rs(this.port,Ls)}rpc(e,...t){return Fs({method:e,args:t},{port:this.port,timeout:this.timeout,fs:this})}async ready(){await this.rpc(`ready`),await super.ready()}rename(e,t){return this.rpc(`rename`,e,t)}async stat(e){let t=await this.rpc(`stat`,e);return t instanceof K?t:new K(t)}async touch(e,t){let n=t instanceof K?t:new K(t);await this.rpc(`touch`,e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength))}async sync(){await super.sync(),await this.rpc(`sync`)}async createFile(e,t){t instanceof K&&(t=t.toJSON());let n=await this.rpc(`createFile`,e,t);return n instanceof K?n:new K(n)}unlink(e){return this.rpc(`unlink`,e)}rmdir(e){return this.rpc(`rmdir`,e)}async mkdir(e,t){t instanceof K&&(t=t.toJSON());let n=await this.rpc(`mkdir`,e,t);return n instanceof K?n:new K(n)}readdir(e){return this.rpc(`readdir`,e)}exists(e){return this.rpc(`exists`,e)}link(e,t){return this.rpc(`link`,e,t)}async read(e,t,n,r){t.set(await this.rpc(`read`,e,t,n,r))}write(e,t,n){return this.rpc(`write`,e,t,n)}};function Gs(e,t){let n=Os(e);Rs(n,e=>Vs(n,t,e))}function Ks(e,t){let n=Os(e);zs(n,e=>Vs(n,t,e))}var qs={name:`Port`,options:{port:{type:[EventTarget,function(e){return typeof e==`object`&&`on`in e}],required:!0},timeout:{type:`number`,required:!1}},create(e){return new Ws(e.port,e.timeout)}};async function Js(e,t,n=0){let r=Os(e),i=Bs(r),a=await Go(t,n);return Gs(r,a),await i(a),pe(`Resolved remote mount: `+a.toString()),a}var Ys=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},Z=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Xs=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Zs=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Qs=e=>`0x`+e.toString(16).padStart(8,`0`),{format:$s}=new Intl.NumberFormat(`en-US`,{notation:`compact`,maximumFractionDigits:2,unit:`byte`,unitDisplay:`narrow`}),ec=(()=>{var e,t,n,r;let i=[Ht.packed()],a,s=[],c,l=Gt(o),u,d=[],f=[],p,m=[],h=[],g,_=[],v=[],y,b=[],x=[];var S=class extends l{static{c=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(l[Symbol.metadata]??null):void 0;u=[(e=V).uint32.bind(e)],p=[(t=V).uint32.bind(t)],g=[(n=V).uint32.bind(n)],y=[(r=V).uint32.bind(r)],Ys(this,null,u,{kind:`accessor`,name:`id`,static:!1,private:!1,access:{has:e=>`id`in e,get:e=>e.id,set:(e,t)=>{e.id=t}},metadata:o},d,f),Ys(this,null,p,{kind:`accessor`,name:`offset_`,static:!1,private:!1,access:{has:e=>`offset_`in e,get:e=>e.offset_,set:(e,t)=>{e.offset_=t}},metadata:o},m,h),Ys(this,null,g,{kind:`accessor`,name:`offset`,static:!1,private:!1,access:{has:e=>`offset`in e,get:e=>e.offset,set:(e,t)=>{e.offset=t}},metadata:o},_,v),Ys(this,null,y,{kind:`accessor`,name:`size`,static:!1,private:!1,access:{has:e=>`size`in e,get:e=>e.size,set:(e,t)=>{e.size=t}},metadata:o},b,x),Ys(null,a={value:c},i,{kind:`class`,name:c.name,metadata:o},null,s),S=c=a.value,o&&Object.defineProperty(c,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`MetadataEntry`;#e=Z(this,d,void 0);get id(){return this.#e}set id(e){this.#e=e}#t=(Z(this,f),Z(this,m,void 0));get offset_(){return this.#t}set offset_(e){this.#t=e}#n=(Z(this,h),Z(this,_,void 0));get offset(){return this.#n}set offset(e){this.#n=e}#r=(Z(this,v),Z(this,b,void 0));get size(){return this.#r}set size(e){this.#r=e}toString(){return`<MetadataEntry @ ${Qs(this.byteOffset)}>`}constructor(){super(...arguments),Z(this,x)}static{Z(c,s)}};return c})(),tc=255,nc=5,rc=(()=>{var e,t,n,r;let i=[Ht.packed()],a,o=[],s,c=Gt.typed(Int32Array),l,u=[],d=[],f,p=[],m=[],h,g=[],_=[],v,y=[],b=[],x,S=[],C=[];var w=class extends c{static{s=this}static{let T=typeof Symbol==`function`&&Symbol.metadata?Object.create(c[Symbol.metadata]??null):void 0;l=[(e=V).uint32.bind(e)],f=[(t=V).uint64.bind(t)],h=[(n=V).uint32.bind(n)],v=[Ut(qt(ec,tc))],x=[(r=V).int32.bind(r)],Ys(this,null,l,{kind:`accessor`,name:`checksum`,static:!1,private:!1,access:{has:e=>`checksum`in e,get:e=>e.checksum,set:(e,t)=>{e.checksum=t}},metadata:T},u,d),Ys(this,null,f,{kind:`accessor`,name:`timestamp`,static:!1,private:!1,access:{has:e=>`timestamp`in e,get:e=>e.timestamp,set:(e,t)=>{e.timestamp=t}},metadata:T},p,m),Ys(this,null,h,{kind:`accessor`,name:`previous_offset`,static:!1,private:!1,access:{has:e=>`previous_offset`in e,get:e=>e.previous_offset,set:(e,t)=>{e.previous_offset=t}},metadata:T},g,_),Ys(this,null,v,{kind:`accessor`,name:`items`,static:!1,private:!1,access:{has:e=>`items`in e,get:e=>e.items,set:(e,t)=>{e.items=t}},metadata:T},y,b),Ys(this,null,x,{kind:`accessor`,name:`locked`,static:!1,private:!1,access:{has:e=>`locked`in e,get:e=>e.locked,set:(e,t)=>{e.locked=t}},metadata:T},S,C),Ys(null,a={value:s},i,{kind:`class`,name:s.name,metadata:T},null,o),w=s=a.value,T&&Object.defineProperty(s,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:T})}static name=`MetadataBlock`;static lockIndex;#e=Z(this,u,void 0);get checksum(){return this.#e}set checksum(e){this.#e=e}#t=(Z(this,d),Z(this,p,BigInt(Date.now())));get timestamp(){return this.#t}set timestamp(e){this.#t=e}#n=(Z(this,m),Z(this,g,void 0));get previous_offset(){return this.#n}set previous_offset(e){this.#n=e}_previous=Z(this,_);get previous(){if(this.previous_offset)return this._previous??=new w(this.buffer,this.previous_offset),this._previous}#r=Z(this,y,void 0);get items(){return this.#r}set items(e){this.#r=e}toString(e=!1){if(!e)return`<MetadataBlock @ ${Qs(this.byteOffset)}>`;let t=[`---- Metadata block at ${Qs(this.byteOffset)} ----`,`Checksum: ${Qs(this.checksum)}`,`Last updated: ${new Date(Number(this.timestamp)).toLocaleString()}`,`Previous block: ${Qs(this.previous_offset)}`,`Entries:`].join(`
12
- `);for(let e of this.items)e.offset&&(t+=`\n\t${Qs(e.id)}: ${$s(e.size).padStart(5)} at ${Qs(e.offset)}`);return t}#i=(Z(this,b),Z(this,S,void 0));get locked(){return this.#i}set locked(e){this.#i=e}waitUnlocked(e=0){if(e>nc)throw de(P(`EBUSY`,`sbfs: exceeded max attempts waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked`));if(Atomics.load(this,w.lockIndex))switch(Atomics.wait(this,w.lockIndex,1)){case`ok`:break;case`not-equal`:return e++,L(`sbfs: waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked (${e}/${nc})`),this.waitUnlocked(e);case`timed-out`:throw de(P(`EBUSY`,`sbfs: timed out waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked`))}}lock(){this.waitUnlocked(),Atomics.store(this,w.lockIndex,1);let e=()=>{Atomics.store(this,w.lockIndex,0),Atomics.notify(this,w.lockIndex,1)};return e[Symbol.dispose]=e,e}constructor(){super(...arguments),Z(this,C)}static{Z(s,o)}};return w=s})();Object.assign(rc,{lockIndex:Lt(rc,`locked`)/Int32Array.BYTES_PER_ELEMENT});var ic=1651715706,ac=2,oc=(()=>{var e,t,n,r,i,a,o,s,c,l;let u=[Ht.packed()],d,f=[],p,m=Gt.typed(BigUint64Array),h,g=[],_=[],v,y=[],b=[],x,S=[],C=[],w,T=[],ee=[],E,te=[],ne=[],D,k=[],A=[],j,M=[],N=[],F,re=[],I=[],ie,ae=[],oe=[],se,ce=[],le=[],ue,L=[],fe=[],pe,he=[],ge=[],_e,ve=[],ye=[];var be=class extends m{static{p=this}static{let O=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;h=[(e=V).uint32.bind(e)],v=[(t=V).uint32.bind(t)],x=[(n=V).uint16.bind(n)],w=[(r=V).uint16.bind(r)],E=[(i=V).uint32.bind(i)],D=[(a=V).uint64.bind(a)],j=[(o=V).uint64.bind(o)],F=[V.uint8(16)],ie=[(s=V).uint32.bind(s)],se=[(c=V).uint32.bind(c)],ue=[(l=V).uint32.bind(l)],pe=[V.char(64)],_e=[V.char(132)],Ys(this,null,h,{kind:`accessor`,name:`checksum`,static:!1,private:!1,access:{has:e=>`checksum`in e,get:e=>e.checksum,set:(e,t)=>{e.checksum=t}},metadata:O},g,_),Ys(this,null,v,{kind:`accessor`,name:`magic`,static:!1,private:!1,access:{has:e=>`magic`in e,get:e=>e.magic,set:(e,t)=>{e.magic=t}},metadata:O},y,b),Ys(this,null,x,{kind:`accessor`,name:`version`,static:!1,private:!1,access:{has:e=>`version`in e,get:e=>e.version,set:(e,t)=>{e.version=t}},metadata:O},S,C),Ys(this,null,w,{kind:`accessor`,name:`inode_format`,static:!1,private:!1,access:{has:e=>`inode_format`in e,get:e=>e.inode_format,set:(e,t)=>{e.inode_format=t}},metadata:O},T,ee),Ys(this,null,E,{kind:`accessor`,name:`flags`,static:!1,private:!1,access:{has:e=>`flags`in e,get:e=>e.flags,set:(e,t)=>{e.flags=t}},metadata:O},te,ne),Ys(this,null,D,{kind:`accessor`,name:`used_bytes`,static:!1,private:!1,access:{has:e=>`used_bytes`in e,get:e=>e.used_bytes,set:(e,t)=>{e.used_bytes=t}},metadata:O},k,A),Ys(this,null,j,{kind:`accessor`,name:`total_bytes`,static:!1,private:!1,access:{has:e=>`total_bytes`in e,get:e=>e.total_bytes,set:(e,t)=>{e.total_bytes=t}},metadata:O},M,N),Ys(this,null,F,{kind:`accessor`,name:`uuid`,static:!1,private:!1,access:{has:e=>`uuid`in e,get:e=>e.uuid,set:(e,t)=>{e.uuid=t}},metadata:O},re,I),Ys(this,null,ie,{kind:`accessor`,name:`metadata_block_size`,static:!1,private:!1,access:{has:e=>`metadata_block_size`in e,get:e=>e.metadata_block_size,set:(e,t)=>{e.metadata_block_size=t}},metadata:O},ae,oe),Ys(this,null,se,{kind:`accessor`,name:`metadata_offset_`,static:!1,private:!1,access:{has:e=>`metadata_offset_`in e,get:e=>e.metadata_offset_,set:(e,t)=>{e.metadata_offset_=t}},metadata:O},ce,le),Ys(this,null,ue,{kind:`accessor`,name:`metadata_offset`,static:!1,private:!1,access:{has:e=>`metadata_offset`in e,get:e=>e.metadata_offset,set:(e,t)=>{e.metadata_offset=t}},metadata:O},L,fe),Ys(this,null,pe,{kind:`accessor`,name:`label`,static:!1,private:!1,access:{has:e=>`label`in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:O},he,ge),Ys(this,null,_e,{kind:`accessor`,name:`_padding`,static:!1,private:!1,access:{has:e=>`_padding`in e,get:e=>e._padding,set:(e,t)=>{e._padding=t}},metadata:O},ve,ye),Ys(null,d={value:p},u,{kind:`class`,name:p.name,metadata:O},null,f),be=p=d.value,O&&Object.defineProperty(p,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:O})}static name=`SuperBlock`;constructor(...e){if(super(...e),Z(this,ye),this.magic!=ic){R(`sbfs: Invalid magic value, assuming this is a fresh super block`);let e=new rc(this.buffer,B(be));Object.assign(this,{metadata:e,metadata_offset:e.byteOffset,used_bytes:BigInt(B(be)+B(rc)),total_bytes:BigInt(this.buffer.byteLength),magic:ic,version:1,inode_format:5,metadata_block_size:B(rc),uuid:O(crypto.randomUUID())}),cc(this),cc(e);return}if(this.checksum!==sc(this))throw de(P(`EIO`,`sbfs: checksum mismatch for super block`));if(this.metadata=new rc(this.buffer,this.metadata_offset),this.metadata.checksum!==sc(this.metadata))throw de(P(`EIO`,`sbfs: checksum mismatch for metadata block (saved ${Qs(this.metadata.checksum)}, computed ${Qs(sc(this.metadata))})`));if(this.inode_format!=5)throw de(P(`EIO`,`sbfs: inode format mismatch`));if(this.metadata_block_size!=B(rc))throw de(P(`EIO`,`sbfs: metadata block size mismatch`))}#e=Z(this,g,void 0);get checksum(){return this.#e}set checksum(e){this.#e=e}#t=(Z(this,_),Z(this,y,void 0));get magic(){return this.#t}set magic(e){this.#t=e}#n=(Z(this,b),Z(this,S,void 0));get version(){return this.#n}set version(e){this.#n=e}#r=(Z(this,C),Z(this,T,void 0));get inode_format(){return this.#r}set inode_format(e){this.#r=e}#i=(Z(this,ee),Z(this,te,void 0));get flags(){return this.#i}set flags(e){this.#i=e}#a=(Z(this,ne),Z(this,k,void 0));get used_bytes(){return this.#a}set used_bytes(e){this.#a=e}#o=(Z(this,A),Z(this,M,void 0));get total_bytes(){return this.#o}set total_bytes(e){this.#o=e}#s=(Z(this,N),Z(this,re,void 0));get uuid(){return this.#s}set uuid(e){this.#s=e}#c=(Z(this,I),Z(this,ae,void 0));get metadata_block_size(){return this.#c}set metadata_block_size(e){this.#c=e}#l=(Z(this,oe),Z(this,ce,void 0));get metadata_offset_(){return this.#l}set metadata_offset_(e){this.#l=e}#u=(Z(this,le),Z(this,L,void 0));get metadata_offset(){return this.#u}set metadata_offset(e){this.#u=e}metadata=Z(this,fe);#d=Z(this,he,void 0);get label(){return this.#d}set label(e){this.#d=e}#f=(Z(this,ge),Z(this,ve,void 0));get _padding(){return this.#f}set _padding(e){this.#f=e}rotateMetadata(){let e=this.used_bytes%BigInt(4);Atomics.add(this,ac,e);let t=Number(Atomics.add(this,ac,BigInt(B(rc)))),n=new rc(this.buffer,t);return n.previous_offset=this.metadata_offset,this.metadata=n,this.metadata_offset=n.byteOffset,cc(n),cc(this),me(`sbfs: rotated metadata block at ${Qs(n.previous_offset)} with new block at ${Qs(t)}`),n}isUnused(e,t){if(!t)return!0;if(e+t>this.total_bytes||e<B(be))return!1;for(let n=this.metadata;n;n=n.previous){if(e<n.byteOffset+B(rc)&&e+t>n.byteOffset)return!1;for(let r of n.items)if(r.offset&&(e>=r.offset&&e<r.offset+r.size||e+t>r.offset&&e+t<=r.offset+r.size||e<=r.offset&&e+t>=r.offset+r.size))return!1}return!0}static{Z(p,f)}};return be=p})();function sc(e){let t=B(e)-4;return e instanceof rc&&(t-=Int32Array.BYTES_PER_ELEMENT),l(new Uint8Array(e.buffer,e.byteOffset+4,t))}function cc(e){e instanceof rc&&(e.timestamp=BigInt(Date.now())),e.checksum=sc(e)}var lc=class extends o{flags=[];name=`sbfs`;type=1935828595;get uuid(){return D(this.superblock.uuid)}superblock;_view;_u8;constructor(...e){if(super(...e),this.byteLength<B(oc)+B(rc))throw de(P(`EINVAL`,`sbfs: Buffer is too small for a file system`));this._view=new DataView(this.buffer,this.byteOffset,this.byteLength),this._u8=new Uint8Array(this.buffer,this.byteOffset,this.byteLength),this.superblock=new oc(this.buffer,this.byteOffset)}*keys(){let e=new Set;for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items)!n.offset||e.has(n.id)||(e.add(n.id),yield n.id)}}get(e){for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items){if(!n.offset||n.id!=e)continue;let t=this.byteOffset+n.offset;return new Uint8Array(this.buffer.slice(t,t+n.size))}}}set(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(e===0&&t.length<B(K))throw ue(P(`EIO`,`sbfs: tried to set ${t.length} bytes for id 0!`));for(let n=this.superblock.metadata;n;n=n.previous){n.waitUnlocked();for(let r of n.items){let i={stack:[],error:void 0,hasError:!1};try{if(!r.offset||r.id!=e)continue;if(Xs(i,n.lock(),!1),t.length==r.size){this._u8.set(t,r.offset);return}if(t.length<r.size||this.superblock.isUnused(r.offset,t.length)){this._u8.set(t,r.offset),r.size=t.length,cc(n);return}r.offset=Number(Atomics.add(this.superblock,ac,BigInt(t.length))),r.size=t.length,this._u8.set(t,r.offset),cc(n),cc(this.superblock);return}catch(e){i.error=e,i.hasError=!0}finally{Zs(i)}}}let r=Array.from(this.superblock.metadata.items).find(e=>!e.offset);r||=(this.superblock.rotateMetadata(),this.superblock.metadata.items[0]),Xs(n,this.superblock.metadata.lock(),!1);let i=Number(Atomics.add(this.superblock,ac,BigInt(t.length)));r.id=e,r.offset=i,r.size=t.length,this._u8.set(t,i),cc(this.superblock.metadata),cc(this.superblock)}catch(e){n.error=e,n.hasError=!0}finally{Zs(n)}}delete(e){for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items)if(n.id==e){n.offset=0,n.size=0,n.id=0,cc(t);return}}}_fs;get fs(){return this._fs}set fs(e){this.buffer.constructor.name===`SharedArrayBuffer`&&e?.attributes.set(`no_id_tables`,!0),this._fs=e}sync(){return Promise.resolve()}usage(){return{totalSpace:Number(this.superblock.total_bytes),freeSpace:Number(this.superblock.total_bytes-this.superblock.used_bytes)}}transaction(){return new Zn(this)}},uc={name:`SingleBuffer`,options:{buffer:{type:`object`,required:!0}},create(e){let t=new Xn(ArrayBuffer.isView(e.buffer)?new lc(e.buffer.buffer,e.buffer.byteOffset,e.buffer.byteLength):new lc(e.buffer));return t.checkRootSync(),t}},Q=()=>{};async function dc(e){let t=[];for await(let n of e)t.push(n);return t}function fc(e,t,n=Q){co.call(this,e,t).then(()=>n(null)).catch(n)}function pc(e,t=Q){lo.call(this,e).then(t).catch(()=>t(!1))}function mc(e,t,n=Q){n=typeof t==`function`?t:n,uo.call(this,e,typeof t==`function`?{}:t).then(e=>n(null,e)).catch(n)}function hc(e,t,n=Q){n=typeof t==`function`?t:n,fo.call(this,e,typeof t==`function`?{}:t).then(e=>n(null,e)).catch(n)}function gc(e,t=0,n=Q){n=typeof t==`function`?t:n;let r=typeof t==`number`?t:0;po.call(this,e,r).then(()=>n(null)).catch(n)}function _c(e,t=Q){mo.call(this,e).then(()=>t(null)).catch(t)}function vc(e,t,n,r=Q){let i=Zt(n,420);r=typeof n==`function`?n:r,ho.call(this,e,t,i).then(e=>r(null,e.fd)).catch(r)}function yc(e,t,n=Q){n=typeof t==`function`?t:n,go.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function bc(e,t,n,r=Q){r=typeof n==`function`?n:r,_o.call(this,e,t,typeof n==`function`?null:n).then(()=>r(null)).catch(r)}function xc(e,t,n,r=Q){let i=typeof n==`function`?void 0:n;r=typeof n==`function`?n:r,vo.call(this,e,t,i).then(()=>r(null)).catch(r)}function Sc(e,t,n=Q){n=typeof t==`function`?t:n,new so(this,e).stat().then(e=>n(null,typeof t==`object`&&t?.bigint?new Sn(e):e)).catch(n)}function Cc(e,t=Q){new so(this,e).close().then(()=>t(null)).catch(t)}function wc(e,t,n=Q){let r=typeof t==`number`?t:0;n=typeof t==`function`?t:n;let i=new so(this,e);if(r<0)throw P(`EINVAL`);i.truncate(r).then(()=>n(null)).catch(n)}function Tc(e,t=Q){new so(this,e).sync().then(()=>t(null)).catch(t)}function Ec(e,t=Q){new so(this,e).datasync().then(()=>t(null)).catch(t)}function Dc(e,t,n,r,i,a=Q){let o,s,c,l,u,d=new so(this,e);if(typeof t==`string`){switch(u=`utf8`,typeof n){case`function`:a=n;break;case`number`:l=n,u=typeof r==`string`?r:`utf8`,a=typeof i==`function`?i:a;break;default:a=typeof r==`function`?r:typeof i==`function`?i:a,a(P(`EINVAL`));return}o=lr.Buffer.from(t),s=0,c=o.length;let e=a;d.write(o,s,c,l).then(({bytesWritten:t})=>e(null,t,o.toString(u))).catch(e)}else{o=lr.Buffer.from(t.buffer),s=n,c=r,l=typeof i==`number`?i:null;let e=typeof i==`function`?i:a;d.write(o,s,c,l).then(({bytesWritten:t})=>e(null,t,o)).catch(e)}}function Oc(e,t,n,r,i,a=Q){new so(this,e).read(t,n,r,i).then(({bytesRead:e,buffer:t})=>a(null,e,t)).catch(a)}function kc(e,t,n,r=Q){new so(this,e).chown(t,n).then(()=>r(null)).catch(r)}function Ac(e,t,n){new so(this,e).chmod(t).then(()=>n(null)).catch(n)}function jc(e,t,n,r=Q){new so(this,e).utimes(t,n).then(()=>r(null)).catch(r)}function Mc(e,t=Q){yo.call(this,e).then(()=>t(null)).catch(t)}function Nc(e,t,n=Q){bo.call(this,e,t).then(()=>n(null)).catch(n)}function Pc(e,t,n=Q){n=typeof t==`function`?t:n;let r=typeof t==`function`?{}:t;xo.call(this,e,r).then(e=>n(null,e)).catch(n)}function Fc(e,t,n=Q){So.call(this,e,t).then(()=>n(null)).catch(n)}function Ic(e,t,n,r=Q){let i=typeof n==`string`?n:`file`;r=typeof n==`function`?n:r,Co.call(this,e,t,i).then(()=>r(null)).catch(r)}function Lc(e,t,n=Q){n=typeof t==`function`?t:n,wo.call(this,e).then(e=>n(null,e)).catch(n)}function Rc(e,t,n,r=Q){To.call(this,e,t,n).then(()=>r(null)).catch(r)}function zc(e,t,n,r=Q){Eo.call(this,e,t,n).then(()=>r(null)).catch(r)}function Bc(e,t,n=Q){Do.call(this,e,t).then(()=>n(null)).catch(n)}function Vc(e,t,n=Q){Oo.call(this,e,t).then(()=>n(null)).catch(n)}function Hc(e,t,n,r=Q){ko.call(this,e,t,n).then(()=>r(null)).catch(r)}function Uc(e,t,n,r=Q){Ao.call(this,e,t,n).then(()=>r(null)).catch(r)}function Wc(e,t,n=Q){n=typeof t==`function`?t:n,jo.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function Gc(e,t,n=Q){let r=typeof t==`number`?t:4;n=typeof t==`function`?t:n,No.call(this,e,r).then(()=>n(null)).catch(n)}var Kc=new Map;function qc(e,t,n){let r=H(e),i=typeof t==`function`?{}:t;if(typeof t==`function`&&(n=t),!n)throw N(`EINVAL`,`watch`,e.toString());if(Kc.has(r)){let e=Kc.get(r);e&&e.listeners.add(n);return}let a=new oa(this,r,i);a.on(`change`,(e,t)=>{let n=Kc.get(r);if(n)for(let r of n.listeners)r(e,t)}),Kc.set(r,{watcher:a,listeners:new Set([n])})}function Jc(e,t=Q){let n=H(e),r=Kc.get(n);r&&(t&&t!==Q?r.listeners.delete(t):r.listeners.clear(),r.listeners.size===0&&(r.watcher.stop(),Kc.delete(n)))}function Yc(e,t,n){let r=new aa(this,H(e),typeof t==`object`?t:{});return n=typeof t==`function`?t:n,r.on(`change`,n||Q),r}function Xc(e,t){t=typeof t==`object`?t:{encoding:t};let n=ho.call(this,e,`r`,t?.mode);return new eo({...t,autoClose:!0},n)}function Zc(e,t){t=typeof t==`object`?t:{encoding:t};let n=ho.call(this,e,`w`,t?.mode);return new to(t,n)}function Qc(e,t,n=Q){n=typeof t==`function`?t:n,Po.call(this,e,typeof t==`function`?void 0:t).then(()=>n(null)).catch(n)}function $c(e,t,n=Q){n=typeof t==`function`?t:n,Fo.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function el(e,t,n,r=Q){r=typeof n==`function`?n:r,Lo.call(this,e,t,typeof n==`function`?void 0:n).then(()=>r(null)).catch(r)}function tl(e,t,n,r=Q){r=typeof n==`function`?n:r,new so(this,e).readv(t,typeof n==`function`?void 0:n).then(({buffers:e,bytesRead:t})=>r(null,t,e)).catch(r)}function nl(e,t,n,r=Q){r=typeof n==`function`?n:r,new so(this,e).writev(t,typeof n==`function`?void 0:n).then(({buffers:e,bytesWritten:t})=>r(null,t,e)).catch(r)}function rl(e,t,n=Q){n=typeof t==`function`?t:n,Ro.call(this,e,typeof t==`function`?void 0:t).then(e=>n(null,e)).catch(n)}function il(e,t,n,r=Q){r=typeof n==`function`?n:r,zo.call(this,e,t,typeof n==`function`?void 0:n).then(()=>r(null)).catch(r)}function al(e,t,n=Q){n=typeof t==`function`?t:n,Bo.call(this,e,typeof t==`function`?void 0:t).then(e=>n(null,e)).catch(n)}async function ol(e,t){let n=await ho.call(this,e.toString(),`r`),r=await n.readFile();return await n.close(),new Blob([r],t)}function sl(e,t,n=Q){n=typeof t==`function`?t:n,dc(Vo.call(this,e,typeof t==`function`?void 0:t)).then(e=>n(null,e??[])).catch(e=>n(e))}var cl=t({BigIntStatsFs:()=>Tn,Dir:()=>li,Dirent:()=>si,ReadStream:()=>eo,Stats:()=>xn,StatsFs:()=>wn,WriteStream:()=>to,access:()=>Gc,accessSync:()=>Ki,appendFile:()=>xc,appendFileSync:()=>Si,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,close:()=>Cc,closeSync:()=>wi,constants:()=>Be,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createReadStream:()=>Xc,createWriteStream:()=>Zc,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,truncate:()=>gc,truncateSync:()=>gi,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,utimes:()=>Hc,utimesSync:()=>Ui,watch:()=>Yc,watchFile:()=>qc,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi}),ll=t({get:()=>fl,getSync:()=>pl,list:()=>vl,listSync:()=>yl,remove:()=>gl,removeSync:()=>_l,set:()=>ml,setSync:()=>hl}),ul=[];function dl(e,t,n,r){if(!t.startsWith(`user.`)&&!ul.includes(t))throw N(`ENOTSUP`,r,n)}async function fl(e,t,n={}){e=H(e);let{fs:r,path:i}=X(e,this);dl(this,t,e,`xattr.get`);let a=await r.stat(i).catch(F(`xattr.get`,e));if(Y&&!J(this,a,4))throw N(`EACCES`,`xattr.get`,e);a.attributes??=new kn;let o=a.attributes.get(t);if(!o)throw N(`ENODATA`,`xattr.get`,e);let s=lr.Buffer.from(o);return n.encoding==`buffer`||!n.encoding?s:s.toString(n.encoding)}function pl(e,t,n={}){e=H(e),dl(this,t,e,`xattr.get`);let{fs:r,path:i}=X(e,this),a;try{a=r.statSync(i)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,a,4))throw N(`EACCES`,`xattr.get`,e);a.attributes??=new kn;let o=a.attributes.get(t);if(!o)throw N(`ENODATA`,`xattr.get`,e);let s=lr.Buffer.from(o);return n.encoding==`buffer`||!n.encoding?s:s.toString(n.encoding)}async function ml(e,t,n,r={}){e=H(e);let{fs:i,path:a}=X(e,this);dl(this,t,e,`xattr.set`);let o=await i.stat(a).catch(F(`xattr.set`,e));if(Y&&!J(this,o,2))throw N(`EACCES`,`xattr.set`,e);o.attributes??=new kn;let s=o.attributes.get(t);if(r.create&&s)throw N(`EEXIST`,`xattr.set`,e);if(r.replace&&!s)throw N(`ENODATA`,`xattr.set`,e);o.attributes.set(t,lr.Buffer.from(n)),await i.touch(a,o).catch(F(`xattr.set`,e))}function hl(e,t,n,r={}){e=H(e);let{fs:i,path:a}=X(e,this);dl(this,t,e,`xattr.set`);let o;try{o=i.statSync(a)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,o,2))throw N(`EACCES`,`xattr.set`,e);o.attributes??=new kn;let s=o.attributes.get(t);if(r.create&&s)throw N(`EEXIST`,`xattr.set`,e);if(r.replace&&!s)throw N(`ENODATA`,`xattr.set`,e);o.attributes.set(t,lr.Buffer.from(n));try{i.touchSync(a,o)}catch(t){throw j(Object.assign(t,{path:e}))}}async function gl(e,t){e=H(e);let{fs:n,path:r}=X(e,this);dl(this,t,e,`xattr.remove`);let i=await n.stat(r).catch(F(`xattr.remove`,e));if(Y&&!J(this,i,2))throw N(`EACCES`,`xattr.remove`,e);if(i.attributes??=new kn,!i.attributes.get(t))throw N(`ENODATA`,`xattr.remove`,e);i.attributes.remove(t),await n.touch(r,i)}function _l(e,t){e=H(e);let{fs:n,path:r}=X(e,this);dl(this,t,e,`xattr.remove`);let i;try{i=n.statSync(r)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,i,2))throw N(`EACCES`,`xattr.remove`,e);if(i.attributes??=new kn,!i.attributes.get(t))throw N(`ENODATA`,`xattr.remove`,e);i.attributes.remove(t);try{n.touchSync(r,i)}catch(t){throw j(Object.assign(t,{path:e}))}}async function vl(e){e=H(e);let{fs:t,path:n}=X(e,this),r=await t.stat(n).catch(F(`xattr.list`,e));return r.attributes?[...r.attributes.keys()]:[]}function yl(e){e=H(e);let{fs:t,path:n}=X(e,this),r;try{r=t.statSync(n)}catch(t){throw j(Object.assign(t,{path:e}))}return r.attributes?[...r.attributes.keys()]:[]}var bl=new Map;function xl(e={}){let t=Le(this);if(!mi.call(this,t.root).isDirectory())throw N(`ENOTDIR`,{syscall:`chroot`,path:t.root});let n=ze(t,e),r=Object.assign(n,{fs:{..._(cl,n),promises:_(no,n),xattr:_(ll,n)},path:_(on,n),bind:e=>{let t=xl.call(n,e);return n.children.push(t),t}});return bl.set(n.id,r),r}var $=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Sl=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Cl=class{previous;current=Promise.withResolvers();_isLocked=!0;get isLocked(){return this._isLocked}constructor(e){this.previous=e}async done(){await this.previous?.done(),await this.current.promise}unlock(){this.current.resolve(),this._isLocked=!1}[Symbol.dispose](){this.unlock()}},wl=class{_fs;get type(){return this._fs.type}get name(){return this._fs.name}get label(){return this._fs.label}set label(e){this._fs.label=e}get attributes(){return this._fs.attributes}get _uuid(){return this._fs._uuid}set _uuid(e){this._fs._uuid=e}get uuid(){return this._fs.uuid}async ready(){return await this._fs.ready()}readySync(){return this._fs.readySync()}usage(){return this._fs.usage()}currentLock;addLock(){let e=new Cl(this.currentLock);return this.currentLock=e,e}async lock(e=5e3){let t=this.currentLock,n=this.addLock(),r=Error().stack;return setTimeout(()=>{if(n.isLocked){let e=P(`EDEADLK`);throw e.stack+=r?.slice(5),L(e)}},e),await t?.done(),n}lockSync(){if(this.currentLock?.isLocked)throw L(P(`EBUSY`));return this.addLock()}get isLocked(){return!!this.currentLock?.isLocked}async rename(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.rename(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}renameSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.renameSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async stat(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.stat(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}statSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.statSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async touch(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.touch(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}touchSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,this.lockSync(),!1),this._fs.touchSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async createFile(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,await this.lock(),!1),await this._fs.createFile(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}createFileSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.createFileSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async unlink(e){let t={stack:[],error:void 0,hasError:!1};try{$(t,await this.lock(),!1),await this._fs.unlink(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}unlinkSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.unlinkSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async rmdir(e){let t={stack:[],error:void 0,hasError:!1};try{$(t,await this.lock(),!1),await this._fs.rmdir(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}rmdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.rmdirSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async mkdir(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,await this.lock(),!1),await this._fs.mkdir(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}mkdirSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.mkdirSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async readdir(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.readdir(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}readdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.readdirSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async exists(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.exists(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}existsSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.existsSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async link(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.link(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}linkSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.linkSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async sync(){let e={stack:[],error:void 0,hasError:!1};try{$(e,await this.lock(),!1),await this._fs.sync()}catch(t){e.error=t,e.hasError=!0}finally{Sl(e)}}syncSync(){let e={stack:[],error:void 0,hasError:!1};try{return $(e,this.lockSync(),!1),this._fs.syncSync()}catch(t){e.error=t,e.hasError=!0}finally{Sl(e)}}async read(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{return $(i,await this.lock(),!1),await this._fs.read(e,t,n,r)}catch(e){i.error=e,i.hasError=!0}finally{Sl(i)}}readSync(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{return $(i,this.lockSync(),!1),this._fs.readSync(e,t,n,r)}catch(e){i.error=e,i.hasError=!0}finally{Sl(i)}}async write(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{return $(r,await this.lock(),!1),await this._fs.write(e,t,n)}catch(e){r.error=e,r.hasError=!0}finally{Sl(r)}}writeSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{return $(r,this.lockSync(),!1),this._fs.writeSync(e,t,n)}catch(e){r.error=e,r.hasError=!0}finally{Sl(r)}}streamRead(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.streamRead(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}streamWrite(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.streamWrite(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}};function Tl(e){class t extends wl{constructor(...t){super(),this._fs=new e(...t)}}return t}function El(e){class t extends e{constructor(...e){super(...e),this.attributes.set(`no_write`)}async rename(){throw P(`EROFS`)}renameSync(){throw P(`EROFS`)}async createFile(){throw P(`EROFS`)}createFileSync(){throw P(`EROFS`)}async unlink(){throw P(`EROFS`)}unlinkSync(){throw P(`EROFS`)}async rmdir(){throw P(`EROFS`)}rmdirSync(){throw P(`EROFS`)}async mkdir(){throw P(`EROFS`)}mkdirSync(){throw P(`EROFS`)}async link(){throw P(`EROFS`)}linkSync(){throw P(`EROFS`)}async touch(){throw P(`EROFS`)}touchSync(){throw P(`EROFS`)}async sync(){throw P(`EROFS`)}syncSync(){throw P(`EROFS`)}async write(){throw P(`EROFS`)}writeSync(){throw P(`EROFS`)}streamWrite(){throw P(`EROFS`)}}return t}function Dl(e){class t extends e{async exists(e){return this.existsSync(e)}async rename(e,t){return this.renameSync(e,t)}async stat(e){return this.statSync(e)}async touch(e,t){return this.touchSync(e,t)}async createFile(e,t){return this.createFileSync(e,t)}async unlink(e){return this.unlinkSync(e)}async rmdir(e){return this.rmdirSync(e)}async mkdir(e,t){return this.mkdirSync(e,t)}async readdir(e){return this.readdirSync(e)}async link(e,t){return this.linkSync(e,t)}async sync(){return this.syncSync()}async read(e,t,n,r){return this.readSync(e,t,n,r)}async write(e,t,n){return this.writeSync(e,t,n)}}return t}var Ol=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},kl=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Al;(function(e){e[e.RealTime=1]=`RealTime`,e[e.PreAlloc=2]=`PreAlloc`,e[e.Immutable=8]=`Immutable`,e[e.Append=16]=`Append`,e[e.Sync=32]=`Sync`,e[e.NoAtime=64]=`NoAtime`,e[e.NoDump=128]=`NoDump`,e[e.RtInherit=256]=`RtInherit`,e[e.ProjInherit=512]=`ProjInherit`,e[e.NoSymlinks=1024]=`NoSymlinks`,e[e.ExtSize=2048]=`ExtSize`,e[e.ExtSzInherit=4096]=`ExtSzInherit`,e[e.NoDefrag=8192]=`NoDefrag`,e[e.FileStream=16384]=`FileStream`,e[e.Dax=32768]=`Dax`,e[e.CowExtSize=65536]=`CowExtSize`,e[e.HasAttr=2147483648]=`HasAttr`})(Al||={});var jl=(()=>{var e,t,n,r,i;let a=[Ht()],s,c=[],l,u=Gt(o),d,f=[],p=[],m,h=[],g=[],_,v=[],b=[],x,S=[],C=[],w,T=[],ee=[],E,te=[],ne=[];var D=class extends u{static{l=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(u[Symbol.metadata]??null):void 0;d=[(e=V).uint32.bind(e)],m=[(t=V).uint32.bind(t)],_=[(n=V).uint32.bind(n)],x=[(r=V).uint32.bind(r)],w=[(i=V).uint32.bind(i)],E=[V.char(8)],Ol(this,null,d,{kind:`accessor`,name:`xflags`,static:!1,private:!1,access:{has:e=>`xflags`in e,get:e=>e.xflags,set:(e,t)=>{e.xflags=t}},metadata:o},f,p),Ol(this,null,m,{kind:`accessor`,name:`extsize`,static:!1,private:!1,access:{has:e=>`extsize`in e,get:e=>e.extsize,set:(e,t)=>{e.extsize=t}},metadata:o},h,g),Ol(this,null,_,{kind:`accessor`,name:`nextents`,static:!1,private:!1,access:{has:e=>`nextents`in e,get:e=>e.nextents,set:(e,t)=>{e.nextents=t}},metadata:o},v,b),Ol(this,null,x,{kind:`accessor`,name:`projid`,static:!1,private:!1,access:{has:e=>`projid`in e,get:e=>e.projid,set:(e,t)=>{e.projid=t}},metadata:o},S,C),Ol(this,null,w,{kind:`accessor`,name:`cowextsize`,static:!1,private:!1,access:{has:e=>`cowextsize`in e,get:e=>e.cowextsize,set:(e,t)=>{e.cowextsize=t}},metadata:o},T,ee),Ol(this,null,E,{kind:`accessor`,name:`pad`,static:!1,private:!1,access:{has:e=>`pad`in e,get:e=>e.pad,set:(e,t)=>{e.pad=t}},metadata:o},te,ne),Ol(null,s={value:l},a,{kind:`class`,name:l.name,metadata:o},null,c),D=l=s.value,o&&Object.defineProperty(l,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`fsxattr`;#e=kl(this,f,void 0);get xflags(){return this.#e}set xflags(e){this.#e=e}#t=(kl(this,p),kl(this,h,void 0));get extsize(){return this.#t}set extsize(e){this.#t=e}#n=(kl(this,g),kl(this,v,void 0));get nextents(){return this.#n}set nextents(e){this.#n=e}#r=(kl(this,b),kl(this,S,void 0));get projid(){return this.#r}set projid(e){this.#r=e}#i=(kl(this,C),kl(this,T,void 0));get cowextsize(){return this.#i}set cowextsize(e){this.#i=e}#a=(kl(this,ee),kl(this,te,[]));get pad(){return this.#a}set pad(e){this.#a=e}constructor(e=y(new M(k.EINVAL,`fsxattr must be initialized with an inode`))){super(new ArrayBuffer(B(D))),kl(this,ne),this.extsize=e.size,this.nextents=1,this.projid=e.uid,this.cowextsize=e.size;for(let t of Object.keys(jn))e.flags&jn[t]&&t in Al&&(this.xflags|=Al[t])}static{kl(l,c)}};return D=l})(),Ml;(function(e){e[e.SecureRm=1]=`SecureRm`,e[e.Undelete=2]=`Undelete`,e[e.Compress=4]=`Compress`,e[e.Sync=8]=`Sync`,e[e.Immutable=16]=`Immutable`,e[e.Append=32]=`Append`,e[e.NoDump=64]=`NoDump`,e[e.NoAtime=128]=`NoAtime`,e[e.Dirty=256]=`Dirty`,e[e.CompressBlk=512]=`CompressBlk`,e[e.NoCompress=1024]=`NoCompress`,e[e.Encrypt=2048]=`Encrypt`,e[e.Btree=4096]=`Btree`,e[e.Index=4096]=`Index`,e[e.IMagic=8192]=`IMagic`,e[e.JournalData=16384]=`JournalData`,e[e.NoTail=32768]=`NoTail`,e[e.DirSync=65536]=`DirSync`,e[e.TopDir=131072]=`TopDir`,e[e.HugeFile=262144]=`HugeFile`,e[e.Extent=524288]=`Extent`,e[e.Verity=1048576]=`Verity`,e[e.EaInode=2097152]=`EaInode`,e[e.EofBlocks=4194304]=`EofBlocks`,e[e.NoCow=8388608]=`NoCow`,e[e.Dax=33554432]=`Dax`,e[e.InlineData=268435456]=`InlineData`,e[e.ProjInherit=536870912]=`ProjInherit`,e[e.CaseFold=1073741824]=`CaseFold`,e[e.Reserved=2147483648]=`Reserved`})(Ml||={});var Nl;(function(e){e[e.GetFlags=2148034049]=`GetFlags`,e[e.SetFlags=1074292226]=`SetFlags`,e[e.GetVersion=2148038145]=`GetVersion`,e[e.SetVersion=1074296322]=`SetVersion`,e[e.Fiemap=3223348747]=`Fiemap`,e[e.GetXattr=2149341215]=`GetXattr`,e[e.SetXattr=1075599392]=`SetXattr`,e[e.GetLabel=2164298801]=`GetLabel`,e[e.SetLabel=1090556978]=`SetLabel`,e[e.GetUUID=2148603136]=`GetUUID`,e[e.GetSysfsPath=2155943169]=`GetSysfsPath`})(Nl||={});var Pl;(function(e){e[e.GetFlags=2147771905]=`GetFlags`,e[e.SetFlags=1074030082]=`SetFlags`,e[e.GetVersion=2147776001]=`GetVersion`,e[e.SetVersion=1074034178]=`SetVersion`})(Pl||={});async function Fl(e,t,...n){e=H(e);let{fs:r,path:i}=X(e,this);try{let e=new K(await r.stat(i));switch(t){case Nl.GetFlags:case Pl.GetFlags:return e.flags;case Nl.SetFlags:case Pl.SetFlags:e.flags=n[0],await r.touch(i,e);return;case Nl.GetVersion:case Pl.GetVersion:return e.version;case Nl.SetVersion:case Pl.SetVersion:e.version=n[0],await r.touch(i,e);return;case Nl.Fiemap:break;case Nl.GetXattr:return new jl(e);case Nl.SetXattr:break;case Nl.GetLabel:return r.label;case Nl.SetLabel:r.label=n[0];return;case Nl.GetUUID:return r.uuid;case Nl.GetSysfsPath:return`/sys/fs/${r.name}/${r.uuid}`}}catch(t){throw j(Object.assign(t,{syscall:`ioctl`,path:e}))}throw N(`ENOTSUP`,`ioctl`,e)}function Il(e,t,...n){e=H(e);let{fs:r,path:i}=X(e,this);try{let e=new K(r.statSync(i));switch(t){case Nl.GetFlags:case Pl.GetFlags:return e.flags;case Nl.SetFlags:case Pl.SetFlags:e.flags=n[0],r.touchSync(i,e);return;case Nl.GetVersion:case Pl.GetVersion:return e.version;case Nl.SetVersion:case Pl.SetVersion:e.version=n[0],r.touchSync(i,e);return;case Nl.Fiemap:break;case Nl.GetXattr:return new jl(e);case Nl.SetXattr:break;case Nl.GetLabel:return r.label;case Nl.SetLabel:r.label=n[0];return;case Nl.GetUUID:return r.uuid;case Nl.GetSysfsPath:return`/sys/fs/${r.name}/${r.uuid}`}}catch(t){throw j(Object.assign(t,{syscall:`ioctl`,path:e}))}throw N(`ENOTSUP`,`ioctl`,e)}var Ll={name:`@zenfs/core`,version:`2.6.2`,description:`A filesystem, anywhere`,funding:{type:`individual`,url:`https://github.com/sponsors/james-pre`},main:`dist/index.js`,types:`dist/index.d.ts`,keywords:[`filesystem`,`node`,`storage`],bin:{"make-index":`scripts/make-index.js`,"zenfs-test":`scripts/test.js`,zci:`scripts/ci-cli.js`},files:[`dist`,`tests`,`types`,`license.md`,`eslint.shared.js`],type:`module`,homepage:`https://zenfs.dev/core`,author:`James Prevett <jp@jamespre.dev> (https://jamespre.dev)`,contributors:[`John Vilk <jvilk@cs.umass.edu>`],license:`LGPL-3.0-or-later`,repository:{type:`git`,url:`git+https://github.com/zen-fs/core.git`},bugs:{url:`https://github.com/zen-fs/core/issues`},engines:{node:`>= 18`},exports:{".":`./dist/index.js`,"./*":`./dist/*`,"./emulation/*":`./dist/node/*`,"./promises":`./dist/node/promises.js`,"./readline":`./dist/node/readline.js`,"./constants":`./dist/constants.js`,"./path":`./dist/path.js`,"./eslint":`./eslint.shared.js`,"./tests/*":`./tests/*`,"./types/*":`./types/*`},publishConfig:{access:`public`,provenance:!0},scripts:{format:`prettier --write .`,"format:check":`prettier --check .`,"spdx:check":`npx lice -a src tests/*.ts tests/**/*.test.ts`,"spdx:fix":`npx lice -aw src tests/*.ts tests/**/*.test.ts`,lint:`eslint src tests`,test:`npx --silent zenfs-test --clean; npx --silent zenfs-test -abcp; tests/fetch/run.sh; npx --silent zenfs-test --report`,build:`tsc -p tsconfig.json`,"build:docs":`typedoc`,dev:`tsc -p tsconfig.json --watch`,prepublishOnly:`npm run build`},dependencies:{"@types/node":`^25.2.0`,buffer:`^6.0.3`,eventemitter3:`^5.0.1`,kerium:`^1.4.2`,memium:`^0.4.0`,"readable-stream":`^4.5.2`,utilium:`^3.0.0`},devDependencies:{"@eslint/js":`^10.0.1`,"@octokit/action":`^8.0.4`,c8:`^11.0.0`,eslint:`^10.1.0`,globals:`^17.3.0`,prettier:`^3.2.5`,tsx:`^4.19.1`,typedoc:`^0.28.18`,typescript:`^6.0.0`,"typescript-eslint":`^8.58.0`},allowScripts:{esbuild:!0}},Rl=t({BigIntStatsFs:()=>Tn,Dir:()=>li,Dirent:()=>si,IOC:()=>Nl,IOC32:()=>Pl,ReadStream:()=>eo,Stats:()=>xn,StatsFs:()=>wn,WriteStream:()=>to,_version:()=>zl,access:()=>Gc,accessSync:()=>Ki,appendFile:()=>xc,appendFileSync:()=>Si,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,chroot:()=>Jr,close:()=>Cc,closeSync:()=>wi,constants:()=>Be,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createReadStream:()=>Xc,createWriteStream:()=>Zc,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,ioctl:()=>Fl,ioctlSync:()=>Il,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,mount:()=>Gr,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,truncate:()=>gc,truncateSync:()=>gi,umount:()=>Kr,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,utimes:()=>Hc,utimesSync:()=>Ui,watch:()=>Yc,watchFile:()=>qc,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi,xattr:()=>ll}),zl=Ll.version,Bl=t({DirType:()=>dr,Dirent:()=>mr,Handle:()=>Mr,IOC:()=>Nl,IOC32:()=>Pl,chroot:()=>Jr,deleteFD:()=>Fr,dtToIf:()=>pr,fromFD:()=>Pr,ifToDt:()=>fr,ioctl:()=>Fl,ioctlSync:()=>Il,link:()=>ya,mkdir:()=>ga,mount:()=>Gr,open:()=>ma,readdir:()=>_a,readlink:()=>ha,rename:()=>va,resolve:()=>pa,stat:()=>ba,sync:()=>Xr,toFD:()=>Nr,umount:()=>Kr,xattr:()=>ll}),Vl=t({Async:()=>Us,AsyncMapTransaction:()=>Qn,AsyncTransaction:()=>Kn,Attributes:()=>kn,BigIntStatsFs:()=>Tn,CopyOnWrite:()=>cs,CopyOnWriteFS:()=>ss,DeviceFS:()=>tr,Dir:()=>li,Dirent:()=>si,ErrnoError:()=>Br,Fetch:()=>vs,FetchFS:()=>_s,FileSystem:()=>Un,IOC:()=>Nl,IOC32:()=>Pl,InMemory:()=>er,InMemoryStore:()=>$n,Index:()=>Vn,IndexFS:()=>hs,Inode:()=>K,InodeFlags:()=>jn,Journal:()=>os,MetadataBlock:()=>rc,MutexLock:()=>Cl,Mutexed:()=>Tl,Passthrough:()=>Ss,PassthroughFS:()=>xs,Port:()=>qs,PortFS:()=>Ws,RPC:()=>Cs,ReadStream:()=>eo,Readonly:()=>El,SingleBuffer:()=>uc,SingleBufferStore:()=>lc,Stats:()=>xn,StatsFs:()=>wn,StoreFS:()=>Xn,SuperBlock:()=>oc,Sync:()=>Dl,SyncMapTransaction:()=>Zn,SyncTransaction:()=>Gn,Transaction:()=>Wn,WrappedTransaction:()=>qn,WriteStream:()=>to,_MutexedFS:()=>wl,_asyncFSKeys:()=>Hs,_chown:()=>Bn,_fnOpt:()=>ke,_inode_fields:()=>An,_inode_version:()=>5,_tempDirName:()=>an,_version:()=>zl,access:()=>Gc,accessSync:()=>Ki,addDevice:()=>Zo,appendFile:()=>xc,appendFileSync:()=>Si,attachFS:()=>Gs,bindContext:()=>xl,boundContexts:()=>bl,checkOptions:()=>je,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,chroot:()=>Jr,close:()=>Cc,closeSync:()=>wi,configure:()=>$o,configureFileSystem:()=>Ho,configureSingle:()=>qo,configureSingleSync:()=>Jo,configureSync:()=>es,constants:()=>Be,contextOf:()=>Le,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createChildContext:()=>ze,createCredentials:()=>Ne,createReadStream:()=>Xc,createWriteStream:()=>Zc,credentialsAllowRoot:()=>Pe,decodeDirListing:()=>Yt,default:()=>Hl,defaultContext:()=>Ie,detachFS:()=>Ks,devices:()=>cr,encodeDirListing:()=>Xt,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fs:()=>Rl,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,fullDevice:()=>ar,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,globToRegex:()=>nn,hasAccess:()=>J,ioctl:()=>Fl,ioctlSync:()=>Il,isBackend:()=>Oe,isBackendConfig:()=>Me,isBlockDevice:()=>Ln,isCharacterDevice:()=>Rn,isDirectory:()=>q,isFIFO:()=>zn,isFile:()=>Pn,isSocket:()=>In,isSymbolicLink:()=>Fn,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,log:()=>re,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,mount:()=>Gr,mounts:()=>Wr,normalizeMode:()=>Zt,normalizeOptions:()=>tn,normalizePath:()=>H,normalizeTime:()=>en,nullDevice:()=>rr,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,randomDevice:()=>or,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,resolveMountConfig:()=>Go,resolveMountConfigSync:()=>Ko,resolveRemoteMount:()=>Js,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,rootIno:()=>0,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,sync:()=>ts,truncate:()=>gc,truncateSync:()=>gi,umount:()=>Kr,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,userModifiableFlags:()=>Nn,userVisibleFlags:()=>Mn,utimes:()=>Hc,utimesSync:()=>Ui,validateFD:()=>$t,version:()=>1,vfs:()=>Bl,waitOnline:()=>rn,watch:()=>Yc,watchFile:()=>qc,withExceptionContext:()=>Ur,withPath:()=>Vr,wrap:()=>Hr,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi,xattr:()=>ll,zeroDevice:()=>ir}),Hl=Rl;globalThis.__zenfs__=Object.assign(Object.create(null),Rl);export{R as C,ne as D,P as E,te as O,fe as S,M as T,$e as _,er as a,ue as b,Wn as c,An as d,mn as f,Xe as g,tt as h,hs as i,y as k,Un as l,U as m,Dl as n,Zn as o,W as p,Us as r,Xn as s,Vl as t,K as u,at as v,k as w,de as x,it as y};
12
+ `);for(let e of this.items)e.offset&&(t+=`\n\t${Qs(e.id)}: ${$s(e.size).padStart(5)} at ${Qs(e.offset)}`);return t}#i=(Z(this,b),Z(this,S,void 0));get locked(){return this.#i}set locked(e){this.#i=e}waitUnlocked(e=0){if(e>nc)throw de(P(`EBUSY`,`sbfs: exceeded max attempts waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked`));if(Atomics.load(this,w.lockIndex))switch(Atomics.wait(this,w.lockIndex,1)){case`ok`:break;case`not-equal`:return e++,L(`sbfs: waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked (${e}/${nc})`),this.waitUnlocked(e);case`timed-out`:throw de(P(`EBUSY`,`sbfs: timed out waiting for metadata block at ${Qs(this.byteOffset)} to be unlocked`))}}lock(){this.waitUnlocked(),Atomics.store(this,w.lockIndex,1);let e=()=>{Atomics.store(this,w.lockIndex,0),Atomics.notify(this,w.lockIndex,1)};return e[Symbol.dispose]=e,e}constructor(){super(...arguments),Z(this,C)}static{Z(s,o)}};return w=s})();Object.assign(rc,{lockIndex:Lt(rc,`locked`)/Int32Array.BYTES_PER_ELEMENT});var ic=1651715706,ac=2,oc=(()=>{var e,t,n,r,i,a,o,s,c,l;let u=[Ht.packed()],d,f=[],p,m=Gt.typed(BigUint64Array),h,g=[],_=[],v,y=[],b=[],x,S=[],C=[],w,T=[],ee=[],E,te=[],ne=[],D,k=[],A=[],j,M=[],N=[],F,re=[],I=[],ie,ae=[],oe=[],se,ce=[],le=[],ue,L=[],fe=[],pe,he=[],ge=[],_e,ve=[],ye=[];var be=class extends m{static{p=this}static{let O=typeof Symbol==`function`&&Symbol.metadata?Object.create(m[Symbol.metadata]??null):void 0;h=[(e=V).uint32.bind(e)],v=[(t=V).uint32.bind(t)],x=[(n=V).uint16.bind(n)],w=[(r=V).uint16.bind(r)],E=[(i=V).uint32.bind(i)],D=[(a=V).uint64.bind(a)],j=[(o=V).uint64.bind(o)],F=[V.uint8(16)],ie=[(s=V).uint32.bind(s)],se=[(c=V).uint32.bind(c)],ue=[(l=V).uint32.bind(l)],pe=[V.char(64)],_e=[V.char(132)],Ys(this,null,h,{kind:`accessor`,name:`checksum`,static:!1,private:!1,access:{has:e=>`checksum`in e,get:e=>e.checksum,set:(e,t)=>{e.checksum=t}},metadata:O},g,_),Ys(this,null,v,{kind:`accessor`,name:`magic`,static:!1,private:!1,access:{has:e=>`magic`in e,get:e=>e.magic,set:(e,t)=>{e.magic=t}},metadata:O},y,b),Ys(this,null,x,{kind:`accessor`,name:`version`,static:!1,private:!1,access:{has:e=>`version`in e,get:e=>e.version,set:(e,t)=>{e.version=t}},metadata:O},S,C),Ys(this,null,w,{kind:`accessor`,name:`inode_format`,static:!1,private:!1,access:{has:e=>`inode_format`in e,get:e=>e.inode_format,set:(e,t)=>{e.inode_format=t}},metadata:O},T,ee),Ys(this,null,E,{kind:`accessor`,name:`flags`,static:!1,private:!1,access:{has:e=>`flags`in e,get:e=>e.flags,set:(e,t)=>{e.flags=t}},metadata:O},te,ne),Ys(this,null,D,{kind:`accessor`,name:`used_bytes`,static:!1,private:!1,access:{has:e=>`used_bytes`in e,get:e=>e.used_bytes,set:(e,t)=>{e.used_bytes=t}},metadata:O},k,A),Ys(this,null,j,{kind:`accessor`,name:`total_bytes`,static:!1,private:!1,access:{has:e=>`total_bytes`in e,get:e=>e.total_bytes,set:(e,t)=>{e.total_bytes=t}},metadata:O},M,N),Ys(this,null,F,{kind:`accessor`,name:`uuid`,static:!1,private:!1,access:{has:e=>`uuid`in e,get:e=>e.uuid,set:(e,t)=>{e.uuid=t}},metadata:O},re,I),Ys(this,null,ie,{kind:`accessor`,name:`metadata_block_size`,static:!1,private:!1,access:{has:e=>`metadata_block_size`in e,get:e=>e.metadata_block_size,set:(e,t)=>{e.metadata_block_size=t}},metadata:O},ae,oe),Ys(this,null,se,{kind:`accessor`,name:`metadata_offset_`,static:!1,private:!1,access:{has:e=>`metadata_offset_`in e,get:e=>e.metadata_offset_,set:(e,t)=>{e.metadata_offset_=t}},metadata:O},ce,le),Ys(this,null,ue,{kind:`accessor`,name:`metadata_offset`,static:!1,private:!1,access:{has:e=>`metadata_offset`in e,get:e=>e.metadata_offset,set:(e,t)=>{e.metadata_offset=t}},metadata:O},L,fe),Ys(this,null,pe,{kind:`accessor`,name:`label`,static:!1,private:!1,access:{has:e=>`label`in e,get:e=>e.label,set:(e,t)=>{e.label=t}},metadata:O},he,ge),Ys(this,null,_e,{kind:`accessor`,name:`_padding`,static:!1,private:!1,access:{has:e=>`_padding`in e,get:e=>e._padding,set:(e,t)=>{e._padding=t}},metadata:O},ve,ye),Ys(null,d={value:p},u,{kind:`class`,name:p.name,metadata:O},null,f),be=p=d.value,O&&Object.defineProperty(p,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:O})}static name=`SuperBlock`;constructor(...e){if(super(...e),Z(this,ye),this.magic!=ic){R(`sbfs: Invalid magic value, assuming this is a fresh super block`);let e=new rc(this.buffer,B(be));Object.assign(this,{metadata:e,metadata_offset:e.byteOffset,used_bytes:BigInt(B(be)+B(rc)),total_bytes:BigInt(this.buffer.byteLength),magic:ic,version:1,inode_format:5,metadata_block_size:B(rc),uuid:O(crypto.randomUUID())}),cc(this),cc(e);return}if(this.checksum!==sc(this))throw de(P(`EIO`,`sbfs: checksum mismatch for super block`));if(this.metadata=new rc(this.buffer,this.metadata_offset),this.metadata.checksum!==sc(this.metadata))throw de(P(`EIO`,`sbfs: checksum mismatch for metadata block (saved ${Qs(this.metadata.checksum)}, computed ${Qs(sc(this.metadata))})`));if(this.inode_format!=5)throw de(P(`EIO`,`sbfs: inode format mismatch`));if(this.metadata_block_size!=B(rc))throw de(P(`EIO`,`sbfs: metadata block size mismatch`))}#e=Z(this,g,void 0);get checksum(){return this.#e}set checksum(e){this.#e=e}#t=(Z(this,_),Z(this,y,void 0));get magic(){return this.#t}set magic(e){this.#t=e}#n=(Z(this,b),Z(this,S,void 0));get version(){return this.#n}set version(e){this.#n=e}#r=(Z(this,C),Z(this,T,void 0));get inode_format(){return this.#r}set inode_format(e){this.#r=e}#i=(Z(this,ee),Z(this,te,void 0));get flags(){return this.#i}set flags(e){this.#i=e}#a=(Z(this,ne),Z(this,k,void 0));get used_bytes(){return this.#a}set used_bytes(e){this.#a=e}#o=(Z(this,A),Z(this,M,void 0));get total_bytes(){return this.#o}set total_bytes(e){this.#o=e}#s=(Z(this,N),Z(this,re,void 0));get uuid(){return this.#s}set uuid(e){this.#s=e}#c=(Z(this,I),Z(this,ae,void 0));get metadata_block_size(){return this.#c}set metadata_block_size(e){this.#c=e}#l=(Z(this,oe),Z(this,ce,void 0));get metadata_offset_(){return this.#l}set metadata_offset_(e){this.#l=e}#u=(Z(this,le),Z(this,L,void 0));get metadata_offset(){return this.#u}set metadata_offset(e){this.#u=e}metadata=Z(this,fe);#d=Z(this,he,void 0);get label(){return this.#d}set label(e){this.#d=e}#f=(Z(this,ge),Z(this,ve,void 0));get _padding(){return this.#f}set _padding(e){this.#f=e}rotateMetadata(){let e=this.used_bytes%BigInt(4);Atomics.add(this,ac,e);let t=Number(Atomics.add(this,ac,BigInt(B(rc)))),n=new rc(this.buffer,t);return n.previous_offset=this.metadata_offset,this.metadata=n,this.metadata_offset=n.byteOffset,cc(n),cc(this),me(`sbfs: rotated metadata block at ${Qs(n.previous_offset)} with new block at ${Qs(t)}`),n}isUnused(e,t){if(!t)return!0;if(e+t>this.total_bytes||e<B(be))return!1;for(let n=this.metadata;n;n=n.previous){if(e<n.byteOffset+B(rc)&&e+t>n.byteOffset)return!1;for(let r of n.items)if(r.offset&&(e>=r.offset&&e<r.offset+r.size||e+t>r.offset&&e+t<=r.offset+r.size||e<=r.offset&&e+t>=r.offset+r.size))return!1}return!0}static{Z(p,f)}};return be=p})();function sc(e){let t=B(e)-4;return e instanceof rc&&(t-=Int32Array.BYTES_PER_ELEMENT),l(new Uint8Array(e.buffer,e.byteOffset+4,t))}function cc(e){e instanceof rc&&(e.timestamp=BigInt(Date.now())),e.checksum=sc(e)}var lc=class extends o{flags=[];name=`sbfs`;type=1935828595;get uuid(){return D(this.superblock.uuid)}superblock;_view;_u8;constructor(...e){if(super(...e),this.byteLength<B(oc)+B(rc))throw de(P(`EINVAL`,`sbfs: Buffer is too small for a file system`));this._view=new DataView(this.buffer,this.byteOffset,this.byteLength),this._u8=new Uint8Array(this.buffer,this.byteOffset,this.byteLength),this.superblock=new oc(this.buffer,this.byteOffset)}*keys(){let e=new Set;for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items)!n.offset||e.has(n.id)||(e.add(n.id),yield n.id)}}get(e){for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items){if(!n.offset||n.id!=e)continue;let t=this.byteOffset+n.offset;return new Uint8Array(this.buffer.slice(t,t+n.size))}}}set(e,t){let n={stack:[],error:void 0,hasError:!1};try{if(e===0&&t.length<B(K))throw ue(P(`EIO`,`sbfs: tried to set ${t.length} bytes for id 0!`));for(let n=this.superblock.metadata;n;n=n.previous){n.waitUnlocked();for(let r of n.items){let i={stack:[],error:void 0,hasError:!1};try{if(!r.offset||r.id!=e)continue;if(Xs(i,n.lock(),!1),t.length==r.size){this._u8.set(t,r.offset);return}if(t.length<r.size||this.superblock.isUnused(r.offset,t.length)){this._u8.set(t,r.offset),r.size=t.length,cc(n);return}r.offset=Number(Atomics.add(this.superblock,ac,BigInt(t.length))),r.size=t.length,this._u8.set(t,r.offset),cc(n),cc(this.superblock);return}catch(e){i.error=e,i.hasError=!0}finally{Zs(i)}}}let r=Array.from(this.superblock.metadata.items).find(e=>!e.offset);r||=(this.superblock.rotateMetadata(),this.superblock.metadata.items[0]),Xs(n,this.superblock.metadata.lock(),!1);let i=Number(Atomics.add(this.superblock,ac,BigInt(t.length)));r.id=e,r.offset=i,r.size=t.length,this._u8.set(t,i),cc(this.superblock.metadata),cc(this.superblock)}catch(e){n.error=e,n.hasError=!0}finally{Zs(n)}}delete(e){for(let t=this.superblock.metadata;t;t=t.previous){t.waitUnlocked();for(let n of t.items)if(n.id==e){n.offset=0,n.size=0,n.id=0,cc(t);return}}}_fs;get fs(){return this._fs}set fs(e){this.buffer.constructor.name===`SharedArrayBuffer`&&e?.attributes.set(`no_id_tables`,!0),this._fs=e}sync(){return Promise.resolve()}usage(){return{totalSpace:Number(this.superblock.total_bytes),freeSpace:Number(this.superblock.total_bytes-this.superblock.used_bytes)}}transaction(){return new Zn(this)}},uc={name:`SingleBuffer`,options:{buffer:{type:`object`,required:!0}},create(e){let t=new Xn(ArrayBuffer.isView(e.buffer)?new lc(e.buffer.buffer,e.buffer.byteOffset,e.buffer.byteLength):new lc(e.buffer));return t.checkRootSync(),t}},Q=()=>{};async function dc(e){let t=[];for await(let n of e)t.push(n);return t}function fc(e,t,n=Q){co.call(this,e,t).then(()=>n(null)).catch(n)}function pc(e,t=Q){lo.call(this,e).then(t).catch(()=>t(!1))}function mc(e,t,n=Q){n=typeof t==`function`?t:n,uo.call(this,e,typeof t==`function`?{}:t).then(e=>n(null,e)).catch(n)}function hc(e,t,n=Q){n=typeof t==`function`?t:n,fo.call(this,e,typeof t==`function`?{}:t).then(e=>n(null,e)).catch(n)}function gc(e,t=0,n=Q){n=typeof t==`function`?t:n;let r=typeof t==`number`?t:0;po.call(this,e,r).then(()=>n(null)).catch(n)}function _c(e,t=Q){mo.call(this,e).then(()=>t(null)).catch(t)}function vc(e,t,n,r=Q){let i=Zt(n,420);r=typeof n==`function`?n:r,ho.call(this,e,t,i).then(e=>r(null,e.fd)).catch(r)}function yc(e,t,n=Q){n=typeof t==`function`?t:n,go.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function bc(e,t,n,r=Q){r=typeof n==`function`?n:r,_o.call(this,e,t,typeof n==`function`?null:n).then(()=>r(null)).catch(r)}function xc(e,t,n,r=Q){let i=typeof n==`function`?void 0:n;r=typeof n==`function`?n:r,vo.call(this,e,t,i).then(()=>r(null)).catch(r)}function Sc(e,t,n=Q){n=typeof t==`function`?t:n,new so(this,e).stat().then(e=>n(null,typeof t==`object`&&t?.bigint?new Sn(e):e)).catch(n)}function Cc(e,t=Q){new so(this,e).close().then(()=>t(null)).catch(t)}function wc(e,t,n=Q){let r=typeof t==`number`?t:0;n=typeof t==`function`?t:n;let i=new so(this,e);if(r<0)throw P(`EINVAL`);i.truncate(r).then(()=>n(null)).catch(n)}function Tc(e,t=Q){new so(this,e).sync().then(()=>t(null)).catch(t)}function Ec(e,t=Q){new so(this,e).datasync().then(()=>t(null)).catch(t)}function Dc(e,t,n,r,i,a=Q){let o,s,c,l,u,d=new so(this,e);if(typeof t==`string`){switch(u=`utf8`,typeof n){case`function`:a=n;break;case`number`:l=n,u=typeof r==`string`?r:`utf8`,a=typeof i==`function`?i:a;break;default:a=typeof r==`function`?r:typeof i==`function`?i:a,a(P(`EINVAL`));return}o=lr.Buffer.from(t),s=0,c=o.length;let e=a;d.write(o,s,c,l).then(({bytesWritten:t})=>e(null,t,o.toString(u))).catch(e)}else{o=lr.Buffer.from(t.buffer),s=n,c=r,l=typeof i==`number`?i:null;let e=typeof i==`function`?i:a;d.write(o,s,c,l).then(({bytesWritten:t})=>e(null,t,o)).catch(e)}}function Oc(e,t,n,r,i,a=Q){new so(this,e).read(t,n,r,i).then(({bytesRead:e,buffer:t})=>a(null,e,t)).catch(a)}function kc(e,t,n,r=Q){new so(this,e).chown(t,n).then(()=>r(null)).catch(r)}function Ac(e,t,n){new so(this,e).chmod(t).then(()=>n(null)).catch(n)}function jc(e,t,n,r=Q){new so(this,e).utimes(t,n).then(()=>r(null)).catch(r)}function Mc(e,t=Q){yo.call(this,e).then(()=>t(null)).catch(t)}function Nc(e,t,n=Q){bo.call(this,e,t).then(()=>n(null)).catch(n)}function Pc(e,t,n=Q){n=typeof t==`function`?t:n;let r=typeof t==`function`?{}:t;xo.call(this,e,r).then(e=>n(null,e)).catch(n)}function Fc(e,t,n=Q){So.call(this,e,t).then(()=>n(null)).catch(n)}function Ic(e,t,n,r=Q){let i=typeof n==`string`?n:`file`;r=typeof n==`function`?n:r,Co.call(this,e,t,i).then(()=>r(null)).catch(r)}function Lc(e,t,n=Q){n=typeof t==`function`?t:n,wo.call(this,e).then(e=>n(null,e)).catch(n)}function Rc(e,t,n,r=Q){To.call(this,e,t,n).then(()=>r(null)).catch(r)}function zc(e,t,n,r=Q){Eo.call(this,e,t,n).then(()=>r(null)).catch(r)}function Bc(e,t,n=Q){Do.call(this,e,t).then(()=>n(null)).catch(n)}function Vc(e,t,n=Q){Oo.call(this,e,t).then(()=>n(null)).catch(n)}function Hc(e,t,n,r=Q){ko.call(this,e,t,n).then(()=>r(null)).catch(r)}function Uc(e,t,n,r=Q){Ao.call(this,e,t,n).then(()=>r(null)).catch(r)}function Wc(e,t,n=Q){n=typeof t==`function`?t:n,jo.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function Gc(e,t,n=Q){let r=typeof t==`number`?t:4;n=typeof t==`function`?t:n,No.call(this,e,r).then(()=>n(null)).catch(n)}var Kc=new Map;function qc(e,t,n){let r=H(e),i=typeof t==`function`?{}:t;if(typeof t==`function`&&(n=t),!n)throw N(`EINVAL`,`watch`,e.toString());if(Kc.has(r)){let e=Kc.get(r);e&&e.listeners.add(n);return}let a=new oa(this,r,i);a.on(`change`,(e,t)=>{let n=Kc.get(r);if(n)for(let r of n.listeners)r(e,t)}),Kc.set(r,{watcher:a,listeners:new Set([n])})}function Jc(e,t=Q){let n=H(e),r=Kc.get(n);r&&(t&&t!==Q?r.listeners.delete(t):r.listeners.clear(),r.listeners.size===0&&(r.watcher.stop(),Kc.delete(n)))}function Yc(e,t,n){let r=new aa(this,H(e),typeof t==`object`?t:{});return n=typeof t==`function`?t:n,r.on(`change`,n||Q),r}function Xc(e,t){t=typeof t==`object`?t:{encoding:t};let n=ho.call(this,e,`r`,t?.mode);return new eo({...t,autoClose:!0},n)}function Zc(e,t){t=typeof t==`object`?t:{encoding:t};let n=ho.call(this,e,`w`,t?.mode);return new to(t,n)}function Qc(e,t,n=Q){n=typeof t==`function`?t:n,Po.call(this,e,typeof t==`function`?void 0:t).then(()=>n(null)).catch(n)}function $c(e,t,n=Q){n=typeof t==`function`?t:n,Fo.call(this,e,typeof t==`function`?null:t).then(e=>n(null,e)).catch(n)}function el(e,t,n,r=Q){r=typeof n==`function`?n:r,Lo.call(this,e,t,typeof n==`function`?void 0:n).then(()=>r(null)).catch(r)}function tl(e,t,n,r=Q){r=typeof n==`function`?n:r,new so(this,e).readv(t,typeof n==`function`?void 0:n).then(({buffers:e,bytesRead:t})=>r(null,t,e)).catch(r)}function nl(e,t,n,r=Q){r=typeof n==`function`?n:r,new so(this,e).writev(t,typeof n==`function`?void 0:n).then(({buffers:e,bytesWritten:t})=>r(null,t,e)).catch(r)}function rl(e,t,n=Q){n=typeof t==`function`?t:n,Ro.call(this,e,typeof t==`function`?void 0:t).then(e=>n(null,e)).catch(n)}function il(e,t,n,r=Q){r=typeof n==`function`?n:r,zo.call(this,e,t,typeof n==`function`?void 0:n).then(()=>r(null)).catch(r)}function al(e,t,n=Q){n=typeof t==`function`?t:n,Bo.call(this,e,typeof t==`function`?void 0:t).then(e=>n(null,e)).catch(n)}async function ol(e,t){let n=await ho.call(this,e.toString(),`r`),r=await n.readFile();return await n.close(),new Blob([r],t)}function sl(e,t,n=Q){n=typeof t==`function`?t:n,dc(Vo.call(this,e,typeof t==`function`?void 0:t)).then(e=>n(null,e??[])).catch(e=>n(e))}var cl=t({BigIntStatsFs:()=>Tn,Dir:()=>li,Dirent:()=>si,ReadStream:()=>eo,Stats:()=>xn,StatsFs:()=>wn,WriteStream:()=>to,access:()=>Gc,accessSync:()=>Ki,appendFile:()=>xc,appendFileSync:()=>Si,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,close:()=>Cc,closeSync:()=>wi,constants:()=>Be,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createReadStream:()=>Xc,createWriteStream:()=>Zc,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,truncate:()=>gc,truncateSync:()=>gi,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,utimes:()=>Hc,utimesSync:()=>Ui,watch:()=>Yc,watchFile:()=>qc,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi}),ll=t({get:()=>fl,getSync:()=>pl,list:()=>vl,listSync:()=>yl,remove:()=>gl,removeSync:()=>_l,set:()=>ml,setSync:()=>hl}),ul=[];function dl(e,t,n,r){if(!t.startsWith(`user.`)&&!ul.includes(t))throw N(`ENOTSUP`,r,n)}async function fl(e,t,n={}){e=H(e);let{fs:r,path:i}=X(e,this);dl(this,t,e,`xattr.get`);let a=await r.stat(i).catch(F(`xattr.get`,e));if(Y&&!J(this,a,4))throw N(`EACCES`,`xattr.get`,e);a.attributes??=new kn;let o=a.attributes.get(t);if(!o)throw N(`ENODATA`,`xattr.get`,e);let s=lr.Buffer.from(o);return n.encoding==`buffer`||!n.encoding?s:s.toString(n.encoding)}function pl(e,t,n={}){e=H(e),dl(this,t,e,`xattr.get`);let{fs:r,path:i}=X(e,this),a;try{a=r.statSync(i)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,a,4))throw N(`EACCES`,`xattr.get`,e);a.attributes??=new kn;let o=a.attributes.get(t);if(!o)throw N(`ENODATA`,`xattr.get`,e);let s=lr.Buffer.from(o);return n.encoding==`buffer`||!n.encoding?s:s.toString(n.encoding)}async function ml(e,t,n,r={}){e=H(e);let{fs:i,path:a}=X(e,this);dl(this,t,e,`xattr.set`);let o=await i.stat(a).catch(F(`xattr.set`,e));if(Y&&!J(this,o,2))throw N(`EACCES`,`xattr.set`,e);o.attributes??=new kn;let s=o.attributes.get(t);if(r.create&&s)throw N(`EEXIST`,`xattr.set`,e);if(r.replace&&!s)throw N(`ENODATA`,`xattr.set`,e);o.attributes.set(t,lr.Buffer.from(n)),await i.touch(a,o).catch(F(`xattr.set`,e))}function hl(e,t,n,r={}){e=H(e);let{fs:i,path:a}=X(e,this);dl(this,t,e,`xattr.set`);let o;try{o=i.statSync(a)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,o,2))throw N(`EACCES`,`xattr.set`,e);o.attributes??=new kn;let s=o.attributes.get(t);if(r.create&&s)throw N(`EEXIST`,`xattr.set`,e);if(r.replace&&!s)throw N(`ENODATA`,`xattr.set`,e);o.attributes.set(t,lr.Buffer.from(n));try{i.touchSync(a,o)}catch(t){throw j(Object.assign(t,{path:e}))}}async function gl(e,t){e=H(e);let{fs:n,path:r}=X(e,this);dl(this,t,e,`xattr.remove`);let i=await n.stat(r).catch(F(`xattr.remove`,e));if(Y&&!J(this,i,2))throw N(`EACCES`,`xattr.remove`,e);if(i.attributes??=new kn,!i.attributes.get(t))throw N(`ENODATA`,`xattr.remove`,e);i.attributes.remove(t),await n.touch(r,i)}function _l(e,t){e=H(e);let{fs:n,path:r}=X(e,this);dl(this,t,e,`xattr.remove`);let i;try{i=n.statSync(r)}catch(t){throw j(Object.assign(t,{path:e}))}if(Y&&!J(this,i,2))throw N(`EACCES`,`xattr.remove`,e);if(i.attributes??=new kn,!i.attributes.get(t))throw N(`ENODATA`,`xattr.remove`,e);i.attributes.remove(t);try{n.touchSync(r,i)}catch(t){throw j(Object.assign(t,{path:e}))}}async function vl(e){e=H(e);let{fs:t,path:n}=X(e,this),r=await t.stat(n).catch(F(`xattr.list`,e));return r.attributes?[...r.attributes.keys()]:[]}function yl(e){e=H(e);let{fs:t,path:n}=X(e,this),r;try{r=t.statSync(n)}catch(t){throw j(Object.assign(t,{path:e}))}return r.attributes?[...r.attributes.keys()]:[]}var bl=new Map;function xl(e={}){let t=Le(this);if(!mi.call(this,t.root).isDirectory())throw N(`ENOTDIR`,{syscall:`chroot`,path:t.root});let n=ze(t,e),r=Object.assign(n,{fs:{..._(cl,n),promises:_(no,n),xattr:_(ll,n)},path:_(on,n),bind:e=>{let t=xl.call(n,e);return n.children.push(t),t}});return bl.set(n.id,r),r}var $=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},Sl=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),Cl=class{previous;current=Promise.withResolvers();_isLocked=!0;get isLocked(){return this._isLocked}constructor(e){this.previous=e}async done(){await this.previous?.done(),await this.current.promise}unlock(){this.current.resolve(),this._isLocked=!1}[Symbol.dispose](){this.unlock()}},wl=class{_fs;get type(){return this._fs.type}get name(){return this._fs.name}get label(){return this._fs.label}set label(e){this._fs.label=e}get attributes(){return this._fs.attributes}get _uuid(){return this._fs._uuid}set _uuid(e){this._fs._uuid=e}get uuid(){return this._fs.uuid}async ready(){return await this._fs.ready()}readySync(){return this._fs.readySync()}usage(){return this._fs.usage()}currentLock;addLock(){let e=new Cl(this.currentLock);return this.currentLock=e,e}async lock(e=5e3){let t=this.currentLock,n=this.addLock(),r=Error().stack;return setTimeout(()=>{if(n.isLocked){let e=P(`EDEADLK`);throw e.stack+=r?.slice(5),L(e)}},e),await t?.done(),n}lockSync(){if(this.currentLock?.isLocked)throw L(P(`EBUSY`));return this.addLock()}get isLocked(){return!!this.currentLock?.isLocked}async rename(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.rename(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}renameSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.renameSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async stat(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.stat(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}statSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.statSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async touch(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.touch(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}touchSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,this.lockSync(),!1),this._fs.touchSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async createFile(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,await this.lock(),!1),await this._fs.createFile(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}createFileSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.createFileSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async unlink(e){let t={stack:[],error:void 0,hasError:!1};try{$(t,await this.lock(),!1),await this._fs.unlink(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}unlinkSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.unlinkSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async rmdir(e){let t={stack:[],error:void 0,hasError:!1};try{$(t,await this.lock(),!1),await this._fs.rmdir(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}rmdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.rmdirSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async mkdir(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,await this.lock(),!1),await this._fs.mkdir(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}mkdirSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.mkdirSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async readdir(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.readdir(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}readdirSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.readdirSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async exists(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,await this.lock(),!1),await this._fs.exists(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}existsSync(e){let t={stack:[],error:void 0,hasError:!1};try{return $(t,this.lockSync(),!1),this._fs.existsSync(e)}catch(e){t.error=e,t.hasError=!0}finally{Sl(t)}}async link(e,t){let n={stack:[],error:void 0,hasError:!1};try{$(n,await this.lock(),!1),await this._fs.link(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}linkSync(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.linkSync(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}async sync(){let e={stack:[],error:void 0,hasError:!1};try{$(e,await this.lock(),!1),await this._fs.sync()}catch(t){e.error=t,e.hasError=!0}finally{Sl(e)}}syncSync(){let e={stack:[],error:void 0,hasError:!1};try{return $(e,this.lockSync(),!1),this._fs.syncSync()}catch(t){e.error=t,e.hasError=!0}finally{Sl(e)}}async read(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{return $(i,await this.lock(),!1),await this._fs.read(e,t,n,r)}catch(e){i.error=e,i.hasError=!0}finally{Sl(i)}}readSync(e,t,n,r){let i={stack:[],error:void 0,hasError:!1};try{return $(i,this.lockSync(),!1),this._fs.readSync(e,t,n,r)}catch(e){i.error=e,i.hasError=!0}finally{Sl(i)}}async write(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{return $(r,await this.lock(),!1),await this._fs.write(e,t,n)}catch(e){r.error=e,r.hasError=!0}finally{Sl(r)}}writeSync(e,t,n){let r={stack:[],error:void 0,hasError:!1};try{return $(r,this.lockSync(),!1),this._fs.writeSync(e,t,n)}catch(e){r.error=e,r.hasError=!0}finally{Sl(r)}}streamRead(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.streamRead(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}streamWrite(e,t){let n={stack:[],error:void 0,hasError:!1};try{return $(n,this.lockSync(),!1),this._fs.streamWrite(e,t)}catch(e){n.error=e,n.hasError=!0}finally{Sl(n)}}};function Tl(e){class t extends wl{constructor(...t){super(),this._fs=new e(...t)}}return t}function El(e){class t extends e{constructor(...e){super(...e),this.attributes.set(`no_write`)}async rename(){throw P(`EROFS`)}renameSync(){throw P(`EROFS`)}async createFile(){throw P(`EROFS`)}createFileSync(){throw P(`EROFS`)}async unlink(){throw P(`EROFS`)}unlinkSync(){throw P(`EROFS`)}async rmdir(){throw P(`EROFS`)}rmdirSync(){throw P(`EROFS`)}async mkdir(){throw P(`EROFS`)}mkdirSync(){throw P(`EROFS`)}async link(){throw P(`EROFS`)}linkSync(){throw P(`EROFS`)}async touch(){throw P(`EROFS`)}touchSync(){throw P(`EROFS`)}async sync(){throw P(`EROFS`)}syncSync(){throw P(`EROFS`)}async write(){throw P(`EROFS`)}writeSync(){throw P(`EROFS`)}streamWrite(){throw P(`EROFS`)}}return t}function Dl(e){class t extends e{async exists(e){return this.existsSync(e)}async rename(e,t){return this.renameSync(e,t)}async stat(e){return this.statSync(e)}async touch(e,t){return this.touchSync(e,t)}async createFile(e,t){return this.createFileSync(e,t)}async unlink(e){return this.unlinkSync(e)}async rmdir(e){return this.rmdirSync(e)}async mkdir(e,t){return this.mkdirSync(e,t)}async readdir(e){return this.readdirSync(e)}async link(e,t){return this.linkSync(e,t)}async sync(){return this.syncSync()}async read(e,t,n,r){return this.readSync(e,t,n,r)}async write(e,t,n){return this.writeSync(e,t,n)}}return t}var Ol=function(e,t,n,r,i,a){function o(e){if(e!==void 0&&typeof e!=`function`)throw TypeError(`Function expected`);return e}for(var s=r.kind,c=s===`getter`?`get`:s===`setter`?`set`:`value`,l=!t&&e?r.static?e:e.prototype:null,u=t||(l?Object.getOwnPropertyDescriptor(l,r.name):{}),d,f=!1,p=n.length-1;p>=0;p--){var m={};for(var h in r)m[h]=h===`access`?{}:r[h];for(var h in r.access)m.access[h]=r.access[h];m.addInitializer=function(e){if(f)throw TypeError(`Cannot add initializers after decoration has completed`);a.push(o(e||null))};var g=(0,n[p])(s===`accessor`?{get:u.get,set:u.set}:u[c],m);if(s===`accessor`){if(g===void 0)continue;if(typeof g!=`object`||!g)throw TypeError(`Object expected`);(d=o(g.get))&&(u.get=d),(d=o(g.set))&&(u.set=d),(d=o(g.init))&&i.unshift(d)}else(d=o(g))&&(s===`field`?i.unshift(d):u[c]=d)}l&&Object.defineProperty(l,r.name,u),f=!0},kl=function(e,t,n){for(var r=arguments.length>2,i=0;i<t.length;i++)n=r?t[i].call(e,n):t[i].call(e);return r?n:void 0},Al;(function(e){e[e.RealTime=1]=`RealTime`,e[e.PreAlloc=2]=`PreAlloc`,e[e.Immutable=8]=`Immutable`,e[e.Append=16]=`Append`,e[e.Sync=32]=`Sync`,e[e.NoAtime=64]=`NoAtime`,e[e.NoDump=128]=`NoDump`,e[e.RtInherit=256]=`RtInherit`,e[e.ProjInherit=512]=`ProjInherit`,e[e.NoSymlinks=1024]=`NoSymlinks`,e[e.ExtSize=2048]=`ExtSize`,e[e.ExtSzInherit=4096]=`ExtSzInherit`,e[e.NoDefrag=8192]=`NoDefrag`,e[e.FileStream=16384]=`FileStream`,e[e.Dax=32768]=`Dax`,e[e.CowExtSize=65536]=`CowExtSize`,e[e.HasAttr=2147483648]=`HasAttr`})(Al||={});var jl=(()=>{var e,t,n,r,i;let a=[Ht()],s,c=[],l,u=Gt(o),d,f=[],p=[],m,h=[],g=[],_,v=[],b=[],x,S=[],C=[],w,T=[],ee=[],E,te=[],ne=[];var D=class extends u{static{l=this}static{let o=typeof Symbol==`function`&&Symbol.metadata?Object.create(u[Symbol.metadata]??null):void 0;d=[(e=V).uint32.bind(e)],m=[(t=V).uint32.bind(t)],_=[(n=V).uint32.bind(n)],x=[(r=V).uint32.bind(r)],w=[(i=V).uint32.bind(i)],E=[V.char(8)],Ol(this,null,d,{kind:`accessor`,name:`xflags`,static:!1,private:!1,access:{has:e=>`xflags`in e,get:e=>e.xflags,set:(e,t)=>{e.xflags=t}},metadata:o},f,p),Ol(this,null,m,{kind:`accessor`,name:`extsize`,static:!1,private:!1,access:{has:e=>`extsize`in e,get:e=>e.extsize,set:(e,t)=>{e.extsize=t}},metadata:o},h,g),Ol(this,null,_,{kind:`accessor`,name:`nextents`,static:!1,private:!1,access:{has:e=>`nextents`in e,get:e=>e.nextents,set:(e,t)=>{e.nextents=t}},metadata:o},v,b),Ol(this,null,x,{kind:`accessor`,name:`projid`,static:!1,private:!1,access:{has:e=>`projid`in e,get:e=>e.projid,set:(e,t)=>{e.projid=t}},metadata:o},S,C),Ol(this,null,w,{kind:`accessor`,name:`cowextsize`,static:!1,private:!1,access:{has:e=>`cowextsize`in e,get:e=>e.cowextsize,set:(e,t)=>{e.cowextsize=t}},metadata:o},T,ee),Ol(this,null,E,{kind:`accessor`,name:`pad`,static:!1,private:!1,access:{has:e=>`pad`in e,get:e=>e.pad,set:(e,t)=>{e.pad=t}},metadata:o},te,ne),Ol(null,s={value:l},a,{kind:`class`,name:l.name,metadata:o},null,c),D=l=s.value,o&&Object.defineProperty(l,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:o})}static name=`fsxattr`;#e=kl(this,f,void 0);get xflags(){return this.#e}set xflags(e){this.#e=e}#t=(kl(this,p),kl(this,h,void 0));get extsize(){return this.#t}set extsize(e){this.#t=e}#n=(kl(this,g),kl(this,v,void 0));get nextents(){return this.#n}set nextents(e){this.#n=e}#r=(kl(this,b),kl(this,S,void 0));get projid(){return this.#r}set projid(e){this.#r=e}#i=(kl(this,C),kl(this,T,void 0));get cowextsize(){return this.#i}set cowextsize(e){this.#i=e}#a=(kl(this,ee),kl(this,te,[]));get pad(){return this.#a}set pad(e){this.#a=e}constructor(e=y(new M(k.EINVAL,`fsxattr must be initialized with an inode`))){super(new ArrayBuffer(B(D))),kl(this,ne),this.extsize=e.size,this.nextents=1,this.projid=e.uid,this.cowextsize=e.size;for(let t of Object.keys(jn))e.flags&jn[t]&&t in Al&&(this.xflags|=Al[t])}static{kl(l,c)}};return D=l})(),Ml;(function(e){e[e.SecureRm=1]=`SecureRm`,e[e.Undelete=2]=`Undelete`,e[e.Compress=4]=`Compress`,e[e.Sync=8]=`Sync`,e[e.Immutable=16]=`Immutable`,e[e.Append=32]=`Append`,e[e.NoDump=64]=`NoDump`,e[e.NoAtime=128]=`NoAtime`,e[e.Dirty=256]=`Dirty`,e[e.CompressBlk=512]=`CompressBlk`,e[e.NoCompress=1024]=`NoCompress`,e[e.Encrypt=2048]=`Encrypt`,e[e.Btree=4096]=`Btree`,e[e.Index=4096]=`Index`,e[e.IMagic=8192]=`IMagic`,e[e.JournalData=16384]=`JournalData`,e[e.NoTail=32768]=`NoTail`,e[e.DirSync=65536]=`DirSync`,e[e.TopDir=131072]=`TopDir`,e[e.HugeFile=262144]=`HugeFile`,e[e.Extent=524288]=`Extent`,e[e.Verity=1048576]=`Verity`,e[e.EaInode=2097152]=`EaInode`,e[e.EofBlocks=4194304]=`EofBlocks`,e[e.NoCow=8388608]=`NoCow`,e[e.Dax=33554432]=`Dax`,e[e.InlineData=268435456]=`InlineData`,e[e.ProjInherit=536870912]=`ProjInherit`,e[e.CaseFold=1073741824]=`CaseFold`,e[e.Reserved=2147483648]=`Reserved`})(Ml||={});var Nl;(function(e){e[e.GetFlags=2148034049]=`GetFlags`,e[e.SetFlags=1074292226]=`SetFlags`,e[e.GetVersion=2148038145]=`GetVersion`,e[e.SetVersion=1074296322]=`SetVersion`,e[e.Fiemap=3223348747]=`Fiemap`,e[e.GetXattr=2149341215]=`GetXattr`,e[e.SetXattr=1075599392]=`SetXattr`,e[e.GetLabel=2164298801]=`GetLabel`,e[e.SetLabel=1090556978]=`SetLabel`,e[e.GetUUID=2148603136]=`GetUUID`,e[e.GetSysfsPath=2155943169]=`GetSysfsPath`})(Nl||={});var Pl;(function(e){e[e.GetFlags=2147771905]=`GetFlags`,e[e.SetFlags=1074030082]=`SetFlags`,e[e.GetVersion=2147776001]=`GetVersion`,e[e.SetVersion=1074034178]=`SetVersion`})(Pl||={});async function Fl(e,t,...n){e=H(e);let{fs:r,path:i}=X(e,this);try{let e=new K(await r.stat(i));switch(t){case Nl.GetFlags:case Pl.GetFlags:return e.flags;case Nl.SetFlags:case Pl.SetFlags:e.flags=n[0],await r.touch(i,e);return;case Nl.GetVersion:case Pl.GetVersion:return e.version;case Nl.SetVersion:case Pl.SetVersion:e.version=n[0],await r.touch(i,e);return;case Nl.Fiemap:break;case Nl.GetXattr:return new jl(e);case Nl.SetXattr:break;case Nl.GetLabel:return r.label;case Nl.SetLabel:r.label=n[0];return;case Nl.GetUUID:return r.uuid;case Nl.GetSysfsPath:return`/sys/fs/${r.name}/${r.uuid}`}}catch(t){throw j(Object.assign(t,{syscall:`ioctl`,path:e}))}throw N(`ENOTSUP`,`ioctl`,e)}function Il(e,t,...n){e=H(e);let{fs:r,path:i}=X(e,this);try{let e=new K(r.statSync(i));switch(t){case Nl.GetFlags:case Pl.GetFlags:return e.flags;case Nl.SetFlags:case Pl.SetFlags:e.flags=n[0],r.touchSync(i,e);return;case Nl.GetVersion:case Pl.GetVersion:return e.version;case Nl.SetVersion:case Pl.SetVersion:e.version=n[0],r.touchSync(i,e);return;case Nl.Fiemap:break;case Nl.GetXattr:return new jl(e);case Nl.SetXattr:break;case Nl.GetLabel:return r.label;case Nl.SetLabel:r.label=n[0];return;case Nl.GetUUID:return r.uuid;case Nl.GetSysfsPath:return`/sys/fs/${r.name}/${r.uuid}`}}catch(t){throw j(Object.assign(t,{syscall:`ioctl`,path:e}))}throw N(`ENOTSUP`,`ioctl`,e)}var Ll={name:`@zenfs/core`,version:`2.6.2`,description:`A filesystem, anywhere`,funding:{type:`individual`,url:`https://github.com/sponsors/james-pre`},main:`dist/index.js`,types:`dist/index.d.ts`,keywords:[`filesystem`,`node`,`storage`],bin:{"make-index":`scripts/make-index.js`,"zenfs-test":`scripts/test.js`,zci:`scripts/ci-cli.js`},files:[`dist`,`tests`,`types`,`license.md`,`eslint.shared.js`],type:`module`,homepage:`https://zenfs.dev/core`,author:`James Prevett <jp@jamespre.dev> (https://jamespre.dev)`,contributors:[`John Vilk <jvilk@cs.umass.edu>`],license:`LGPL-3.0-or-later`,repository:{type:`git`,url:`git+https://github.com/zen-fs/core.git`},bugs:{url:`https://github.com/zen-fs/core/issues`},engines:{node:`>= 18`},exports:{".":`./dist/index.js`,"./*":`./dist/*`,"./emulation/*":`./dist/node/*`,"./promises":`./dist/node/promises.js`,"./readline":`./dist/node/readline.js`,"./constants":`./dist/constants.js`,"./path":`./dist/path.js`,"./eslint":`./eslint.shared.js`,"./tests/*":`./tests/*`,"./types/*":`./types/*`},publishConfig:{access:`public`,provenance:!0},scripts:{format:`prettier --write .`,"format:check":`prettier --check .`,"spdx:check":`npx lice -a src tests/*.ts tests/**/*.test.ts`,"spdx:fix":`npx lice -aw src tests/*.ts tests/**/*.test.ts`,lint:`eslint src tests`,test:`npx --silent zenfs-test --clean; npx --silent zenfs-test -abcp; tests/fetch/run.sh; npx --silent zenfs-test --report`,build:`tsc -p tsconfig.json`,"build:docs":`typedoc`,dev:`tsc -p tsconfig.json --watch`,prepublishOnly:`npm run build`},dependencies:{"@types/node":`^25.2.0`,buffer:`^6.0.3`,eventemitter3:`^5.0.1`,kerium:`^1.4.2`,memium:`^0.4.0`,"readable-stream":`^4.5.2`,utilium:`^3.0.0`},devDependencies:{"@eslint/js":`^10.0.1`,"@octokit/action":`^8.0.4`,c8:`^11.0.0`,eslint:`^10.1.0`,globals:`^17.3.0`,prettier:`^3.2.5`,tsx:`^4.19.1`,typedoc:`^0.28.18`,typescript:`^6.0.0`,"typescript-eslint":`^8.58.0`},allowScripts:{esbuild:!0}},Rl=t({BigIntStatsFs:()=>Tn,Dir:()=>li,Dirent:()=>si,IOC:()=>Nl,IOC32:()=>Pl,ReadStream:()=>eo,Stats:()=>xn,StatsFs:()=>wn,WriteStream:()=>to,_version:()=>zl,access:()=>Gc,accessSync:()=>Ki,appendFile:()=>xc,appendFileSync:()=>Si,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,chroot:()=>Jr,close:()=>Cc,closeSync:()=>wi,constants:()=>Be,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createReadStream:()=>Xc,createWriteStream:()=>Zc,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,ioctl:()=>Fl,ioctlSync:()=>Il,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,mount:()=>Gr,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,truncate:()=>gc,truncateSync:()=>gi,umount:()=>Kr,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,utimes:()=>Hc,utimesSync:()=>Ui,watch:()=>Yc,watchFile:()=>qc,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi,xattr:()=>ll}),zl=Ll.version,Bl=t({DirType:()=>dr,Dirent:()=>mr,Handle:()=>Mr,IOC:()=>Nl,IOC32:()=>Pl,chroot:()=>Jr,deleteFD:()=>Fr,dtToIf:()=>pr,fromFD:()=>Pr,ifToDt:()=>fr,ioctl:()=>Fl,ioctlSync:()=>Il,link:()=>ya,mkdir:()=>ga,mount:()=>Gr,open:()=>ma,readdir:()=>_a,readlink:()=>ha,rename:()=>va,resolve:()=>pa,stat:()=>ba,sync:()=>Xr,toFD:()=>Nr,umount:()=>Kr,xattr:()=>ll}),Vl=t({Async:()=>Us,AsyncMapTransaction:()=>Qn,AsyncTransaction:()=>Kn,Attributes:()=>kn,BigIntStatsFs:()=>Tn,CopyOnWrite:()=>cs,CopyOnWriteFS:()=>ss,DeviceFS:()=>tr,Dir:()=>li,Dirent:()=>si,ErrnoError:()=>Br,Fetch:()=>vs,FetchFS:()=>_s,FileSystem:()=>Un,IOC:()=>Nl,IOC32:()=>Pl,InMemory:()=>er,InMemoryStore:()=>$n,Index:()=>Vn,IndexFS:()=>hs,Inode:()=>K,InodeFlags:()=>jn,Journal:()=>os,MetadataBlock:()=>rc,MutexLock:()=>Cl,Mutexed:()=>Tl,Passthrough:()=>Ss,PassthroughFS:()=>xs,Port:()=>qs,PortFS:()=>Ws,RPC:()=>Cs,ReadStream:()=>eo,Readonly:()=>El,SingleBuffer:()=>uc,SingleBufferStore:()=>lc,Stats:()=>xn,StatsFs:()=>wn,StoreFS:()=>Xn,SuperBlock:()=>oc,Sync:()=>Dl,SyncMapTransaction:()=>Zn,SyncTransaction:()=>Gn,Transaction:()=>Wn,WrappedTransaction:()=>qn,WriteStream:()=>to,_MutexedFS:()=>wl,_asyncFSKeys:()=>Hs,_chown:()=>Bn,_fnOpt:()=>ke,_inode_fields:()=>An,_inode_version:()=>5,_tempDirName:()=>an,_version:()=>zl,access:()=>Gc,accessSync:()=>Ki,addDevice:()=>Zo,appendFile:()=>xc,appendFileSync:()=>Si,attachFS:()=>Gs,bindContext:()=>xl,boundContexts:()=>bl,checkOptions:()=>je,chmod:()=>Bc,chmodSync:()=>Vi,chown:()=>Rc,chownSync:()=>zi,chroot:()=>Jr,close:()=>Cc,closeSync:()=>wi,configure:()=>$o,configureFileSystem:()=>Ho,configureSingle:()=>qo,configureSingleSync:()=>Jo,configureSync:()=>es,constants:()=>Be,contextOf:()=>Le,copyFile:()=>el,copyFileSync:()=>Xi,cp:()=>il,cpSync:()=>ea,createChildContext:()=>ze,createCredentials:()=>Ne,createReadStream:()=>Xc,createWriteStream:()=>Zc,credentialsAllowRoot:()=>Pe,decodeDirListing:()=>Yt,default:()=>Hl,defaultContext:()=>Ie,detachFS:()=>Ks,devices:()=>cr,encodeDirListing:()=>Xt,exists:()=>pc,existsSync:()=>pi,fchmod:()=>Ac,fchmodSync:()=>ji,fchown:()=>kc,fchownSync:()=>Ai,fdatasync:()=>Ec,fdatasyncSync:()=>Di,fs:()=>Rl,fstat:()=>Sc,fstatSync:()=>Ci,fsync:()=>Tc,fsyncSync:()=>Ei,ftruncate:()=>wc,ftruncateSync:()=>Ti,fullDevice:()=>ar,futimes:()=>jc,futimesSync:()=>Mi,glob:()=>sl,globSync:()=>na,globToRegex:()=>nn,hasAccess:()=>J,ioctl:()=>Fl,ioctlSync:()=>Il,isBackend:()=>Oe,isBackendConfig:()=>Me,isBlockDevice:()=>Ln,isCharacterDevice:()=>Rn,isDirectory:()=>q,isFIFO:()=>zn,isFile:()=>Pn,isSocket:()=>In,isSymbolicLink:()=>Fn,lchmod:()=>Vc,lchmodSync:()=>Hi,lchown:()=>zc,lchownSync:()=>Bi,link:()=>Fc,linkSync:()=>Ii,log:()=>re,lopenSync:()=>yi,lstat:()=>hc,lstatSync:()=>hi,lutimes:()=>Uc,lutimesSync:()=>Wi,mkdir:()=>Nc,mkdirSync:()=>Pi,mkdtemp:()=>$c,mkdtempDisposableSync:()=>Yi,mkdtempSync:()=>Ji,mount:()=>Gr,mounts:()=>Wr,normalizeMode:()=>Zt,normalizeOptions:()=>tn,normalizePath:()=>H,normalizeTime:()=>en,nullDevice:()=>rr,open:()=>vc,openAsBlob:()=>ol,openSync:()=>vi,opendir:()=>rl,opendirSync:()=>$i,promises:()=>no,randomDevice:()=>or,read:()=>Oc,readFile:()=>yc,readFileSync:()=>bi,readSync:()=>ki,readdir:()=>Pc,readdirSync:()=>Fi,readlink:()=>Lc,readlinkSync:()=>Ri,readv:()=>tl,readvSync:()=>Zi,realpath:()=>Wc,realpathSync:()=>Gi,rename:()=>fc,renameSync:()=>fi,resolveMountConfig:()=>Go,resolveMountConfigSync:()=>Ko,resolveRemoteMount:()=>Js,rm:()=>Qc,rmSync:()=>qi,rmdir:()=>Mc,rmdirSync:()=>Ni,rootIno:()=>0,stat:()=>mc,statSync:()=>mi,statfs:()=>al,statfsSync:()=>ta,symlink:()=>Ic,symlinkSync:()=>Li,sync:()=>ts,truncate:()=>gc,truncateSync:()=>gi,umount:()=>Kr,unlink:()=>_c,unlinkSync:()=>_i,unwatchFile:()=>Jc,userModifiableFlags:()=>Nn,userVisibleFlags:()=>Mn,utimes:()=>Hc,utimesSync:()=>Ui,validateFD:()=>$t,version:()=>1,vfs:()=>Bl,waitOnline:()=>rn,watch:()=>Yc,watchFile:()=>qc,withExceptionContext:()=>Ur,withPath:()=>Vr,wrap:()=>Hr,write:()=>Dc,writeFile:()=>bc,writeFileSync:()=>xi,writeSync:()=>Oi,writev:()=>nl,writevSync:()=>Qi,xattr:()=>ll,zeroDevice:()=>ir}),Hl=Rl;globalThis.__zenfs__=Object.create(Rl);export{R as C,ne as D,P as E,te as O,fe as S,M as T,$e as _,er as a,ue as b,Wn as c,An as d,mn as f,Xe as g,tt as h,hs as i,y as k,Un as l,U as m,Dl as n,Zn as o,W as p,Us as r,Xn as s,Vl as t,K as u,at as v,k as w,de as x,it as y};