@myrialabs/clopen 0.4.39 → 0.4.40

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 (88) hide show
  1. package/backend/auth/permissions.ts +23 -0
  2. package/backend/database/crypto/secret-columns.ts +5 -1
  3. package/backend/database/migrations/078_create_worktree_branch_tables.ts +158 -0
  4. package/backend/database/migrations/index.ts +7 -0
  5. package/backend/database/queries/index.ts +6 -0
  6. package/backend/database/queries/worktree-branch-queries.ts +331 -0
  7. package/backend/db-client/cloning.test.ts +161 -0
  8. package/backend/db-client/cloning.ts +672 -0
  9. package/backend/db-client/connection-url.test.ts +117 -0
  10. package/backend/db-client/connection-url.ts +126 -0
  11. package/backend/db-client/drivers/mongodb.ts +2 -14
  12. package/backend/db-client/drivers/mysql.ts +2 -8
  13. package/backend/db-client/drivers/postgres.ts +10 -13
  14. package/backend/db-client/drivers/redis.ts +2 -6
  15. package/backend/db-client/env/detect.ts +438 -0
  16. package/backend/db-client/env/diff.ts +94 -0
  17. package/backend/db-client/env/env.test.ts +574 -0
  18. package/backend/db-client/env/index.ts +15 -0
  19. package/backend/db-client/env/naming.ts +202 -0
  20. package/backend/db-client/env/service.ts +487 -0
  21. package/backend/db-client/integrations/index.ts +7 -0
  22. package/backend/db-client/integrations/links.ts +41 -10
  23. package/backend/db-client/providers/neon/adapter.ts +522 -0
  24. package/backend/db-client/providers/neon/api-types.ts +182 -0
  25. package/backend/db-client/providers/neon/client.ts +298 -0
  26. package/backend/db-client/providers/neon/endpoints.test.ts +201 -0
  27. package/backend/db-client/providers/neon/endpoints.ts +314 -0
  28. package/backend/db-client/providers/neon/list.test.ts +181 -0
  29. package/backend/db-client/providers/supabase/adapter.ts +25 -2
  30. package/backend/db-client/providers/types.ts +57 -0
  31. package/backend/env-files/discovery.ts +48 -0
  32. package/backend/env-files/edit.ts +213 -0
  33. package/backend/env-files/env-files.test.ts +515 -0
  34. package/backend/env-files/git.ts +27 -0
  35. package/backend/env-files/index.ts +44 -0
  36. package/backend/env-files/keys.ts +69 -0
  37. package/backend/env-files/parse.ts +157 -0
  38. package/backend/env-files/write.ts +229 -0
  39. package/backend/integrations/health.ts +18 -4
  40. package/backend/integrations/projections/types.ts +9 -2
  41. package/backend/integrations/registry/index.ts +3 -0
  42. package/backend/integrations/registry/providers/context7.ts +1 -0
  43. package/backend/integrations/registry/providers/firecrawl.ts +1 -0
  44. package/backend/integrations/registry/providers/github.ts +1 -0
  45. package/backend/integrations/registry/providers/neon.ts +55 -0
  46. package/backend/integrations/registry/providers/supabase.ts +1 -0
  47. package/backend/integrations/registry/providers/vercel.ts +1 -0
  48. package/backend/integrations/registry/types.ts +2 -0
  49. package/backend/work/start-work.ts +4 -0
  50. package/backend/worktrees/branching/engine.ts +557 -0
  51. package/backend/worktrees/branching/index.ts +56 -0
  52. package/backend/worktrees/branching/naming.test.ts +118 -0
  53. package/backend/worktrees/branching/naming.ts +97 -0
  54. package/backend/worktrees/branching/projector.test.ts +229 -0
  55. package/backend/worktrees/branching/projector.ts +139 -0
  56. package/backend/worktrees/branching/providers/neon.ts +220 -0
  57. package/backend/worktrees/branching/registry.ts +27 -0
  58. package/backend/worktrees/branching/service.ts +620 -0
  59. package/backend/worktrees/branching/suggest.test.ts +154 -0
  60. package/backend/worktrees/branching/suggest.ts +202 -0
  61. package/backend/worktrees/branching/types.ts +88 -0
  62. package/backend/worktrees/index.ts +7 -0
  63. package/backend/worktrees/service.ts +48 -1
  64. package/backend/ws/db-client/env.ts +142 -0
  65. package/backend/ws/db-client/index.ts +2 -0
  66. package/backend/ws/projects/index.ts +6 -1
  67. package/backend/ws/projects/info.ts +70 -6
  68. package/backend/ws/projects/overview.test.ts +108 -0
  69. package/backend/ws/projects/overview.ts +300 -0
  70. package/backend/ws/system/device-info.ts +307 -76
  71. package/backend/ws/worktrees/branching.ts +212 -0
  72. package/backend/ws/worktrees/crud.ts +33 -7
  73. package/backend/ws/worktrees/index.ts +14 -0
  74. package/dist/assets/{index-C8Gi-b6U.js → index-D4igjF6e.js} +1 -1
  75. package/dist/assets/{index-BrF6nqld.js → index-DONNwiXm.js} +1 -1
  76. package/dist/assets/main-BrfXH1bL.js +1205 -0
  77. package/dist/assets/main-CT1PygsW.css +1 -0
  78. package/dist/index.html +2 -2
  79. package/package.json +1 -1
  80. package/shared/constants/tool-icons.ts +6 -2
  81. package/shared/types/db-client/env.ts +192 -0
  82. package/shared/types/db-client/index.ts +1 -0
  83. package/shared/types/db-client/integrations.ts +30 -0
  84. package/shared/types/integrations.ts +9 -0
  85. package/shared/types/worktree-branching.ts +315 -0
  86. package/shared/utils/logger.ts +1 -0
  87. package/dist/assets/main-Bd3gb79F.css +0 -1
  88. package/dist/assets/main-Bo1hD7mt.js +0 -1191
@@ -14,7 +14,8 @@ import {
14
14
  countPendingChanges,
15
15
  createWorktree,
16
16
  getWorktreeDiskUsage,
17
- removeWorktree
17
+ removeWorktree,
18
+ worktreeBranching
18
19
  } from '../../worktrees';
19
20
  import { ws } from '$backend/utils/ws';
20
21
  import { debug } from '$shared/utils/logger';
@@ -32,7 +33,9 @@ export const worktreeSchema = t.Object({
32
33
  created_at: t.String(),
33
34
  last_opened_at: t.Optional(t.String()),
34
35
  last_applied_at: t.Optional(t.String()),
35
- sessionCount: t.Number()
36
+ sessionCount: t.Number(),
37
+ /** The database branch this worktree owns, when the project is branching. */
38
+ branch: t.Optional(t.Any())
36
39
  });
37
40
 
38
41
  /**
@@ -52,7 +55,11 @@ export function serializeWorktree(worktree: Worktree) {
52
55
  created_at: worktree.created_at,
53
56
  last_opened_at: worktree.last_opened_at ?? undefined,
54
57
  last_applied_at: worktree.last_applied_at ?? undefined,
55
- sessionCount: worktreeQueries.countSessions(worktree.id)
58
+ sessionCount: worktreeQueries.countSessions(worktree.id),
59
+ // Carried on the row rather than fetched per worktree: the switcher shows
60
+ // it on every line, and a second round trip per worktree to render one
61
+ // badge would make opening the menu cost a request per tree.
62
+ branch: worktreeBranching.forWorktree(worktree.id) ?? undefined
56
63
  };
57
64
  }
58
65
 
@@ -75,12 +82,27 @@ export const worktreeCrudHandler = createRouter()
75
82
 
76
83
  .http('worktrees:create', {
77
84
  data: t.Object({
78
- name: t.String({ minLength: 1, maxLength: 80 })
85
+ name: t.String({ minLength: 1, maxLength: 80 }),
86
+ /** Skip this project's database branch for this one worktree. */
87
+ skipBranch: t.Optional(t.Boolean()),
88
+ dataMode: t.Optional(
89
+ t.Union([t.Literal('schema-data'), t.Literal('schema'), t.Literal('empty')])
90
+ )
79
91
  }),
80
92
  response: t.Object({
81
93
  worktree: worktreeSchema,
82
94
  fileCount: t.Number(),
83
- carriedIgnoredFiles: t.Boolean()
95
+ carriedIgnoredFiles: t.Boolean(),
96
+ branch: t.Nullable(t.Any()),
97
+ /**
98
+ * Why no branch was cut, when one was expected.
99
+ *
100
+ * Part of a SUCCESSFUL response on purpose. The worktree is what the
101
+ * user asked for and it exists; a provider outage or a branch limit is
102
+ * something they need to know rather than a reason to report the whole
103
+ * action as failed.
104
+ */
105
+ branchError: t.Nullable(t.String())
84
106
  })
85
107
  }, async ({ data, conn }) => {
86
108
  const { projectId, userId } = requireCurrentProjectAccess(conn);
@@ -88,7 +110,9 @@ export const worktreeCrudHandler = createRouter()
88
110
  const result = await createWorktree({
89
111
  projectId,
90
112
  name: data.name,
91
- createdBy: userId
113
+ createdBy: userId,
114
+ skipBranch: data.skipBranch,
115
+ dataMode: data.dataMode
92
116
  });
93
117
 
94
118
  broadcastWorktrees(projectId);
@@ -96,7 +120,9 @@ export const worktreeCrudHandler = createRouter()
96
120
  return {
97
121
  worktree: serializeWorktree(result.worktree),
98
122
  fileCount: result.fileCount,
99
- carriedIgnoredFiles: result.carriedIgnoredFiles
123
+ carriedIgnoredFiles: result.carriedIgnoredFiles,
124
+ branch: result.branch,
125
+ branchError: result.branchError
100
126
  };
101
127
  })
102
128
 
@@ -4,16 +4,19 @@
4
4
  * Structure:
5
5
  * - crud.ts: list/create/rename/delete/status and session binding
6
6
  * - transfer.ts: two-phase apply (worktree → main) and sync (main → worktree)
7
+ * - branching.ts: the database branch a worktree gets, and the ones it leaked
7
8
  */
8
9
 
9
10
  import { t } from 'elysia';
10
11
  import { createRouter } from '$shared/utils/ws-server';
11
12
  import { worktreeCrudHandler } from './crud';
12
13
  import { worktreeTransferHandler } from './transfer';
14
+ import { worktreeBranchingHandler } from './branching';
13
15
 
14
16
  export const worktreesRouter = createRouter()
15
17
  .merge(worktreeCrudHandler)
16
18
  .merge(worktreeTransferHandler)
19
+ .merge(worktreeBranchingHandler)
17
20
  // Collaborative broadcast events (Server → Client)
18
21
  .emit('worktrees:changed', t.Object({
19
22
  projectId: t.String(),
@@ -23,6 +26,17 @@ export const worktreesRouter = createRouter()
23
26
  sessionId: t.String(),
24
27
  worktreeId: t.Union([t.String(), t.Null()])
25
28
  }))
29
+ /**
30
+ * The branching binding or the branch list moved.
31
+ *
32
+ * Carries the whole state rather than a delta: the dialog renders providers,
33
+ * accounts, the binding, the dotenv file list and every branch together, and
34
+ * five separate events would have five orders they could arrive in.
35
+ */
36
+ .emit('worktrees:branching-changed', t.Object({
37
+ projectId: t.String(),
38
+ state: t.Any()
39
+ }))
26
40
  .emit('worktrees:transferred', t.Object({
27
41
  worktreeId: t.String(),
28
42
  projectId: t.String(),
@@ -1 +1 @@
1
- import{_ as ce}from"./main-Bo1hD7mt.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
1
+ import{_ as ce}from"./main-BrfXH1bL.js";async function ot(s={}){var t,e=s,r=!!globalThis.window,i=!!globalThis.WorkerGlobalScope,o=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";if(o){const{createRequire:n}=await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);var l=n(import.meta.url)}var p=(n,c)=>{throw c},m=import.meta.url,z="";function _(n){return e.locateFile?e.locateFile(n,z):z+n}var x,A;if(o){var a=l("node:fs");m.startsWith("file:")&&(z=l("node:path").dirname(l("node:url").fileURLToPath(m))+"/"),A=n=>{n=u(n)?new URL(n):n;var c=a.readFileSync(n);return c},x=async(n,c=!0)=>{n=u(n)?new URL(n):n;var f=a.readFileSync(n,c?void 0:"utf8");return f},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),p=(n,c)=>{throw process.exitCode=n,c}}else if(r||i){try{z=new URL(".",m).href}catch{}x=async n=>{var c=await fetch(n,{credentials:"same-origin"});if(c.ok)return c.arrayBuffer();throw new Error(c.status+" : "+c.url)}}var R=console.log.bind(console),C=console.error.bind(console),U,M=!1,T,u=n=>n.startsWith("file://"),d,D,B=!1;function E(){var n=ae.buffer;e.HEAPU8=V=new Uint8Array(n),P=new Uint32Array(n),Q=new BigInt64Array(n),new BigUint64Array(n)}function te(){if(e.preRun)for(typeof e.preRun=="function"&&(e.preRun=[e.preRun]);e.preRun.length;)Me(e.preRun.shift());ze(ye)}function fe(){B=!0,L.m()}function Y(){if(e.postRun)for(typeof e.postRun=="function"&&(e.postRun=[e.postRun]);e.postRun.length;)Be(e.postRun.shift());ze(ge)}function X(n){e.onAbort?.(n),n=`Aborted(${n})`,C(n),M=!0,n+=". Build with -sASSERTIONS for more info.";var c=new WebAssembly.RuntimeError(n);throw D?.(c),c}var J;function ne(){return e.locateFile?_("zipkit-engine.wasm"):new URL("/assets/zipkit-engine-CaR0t_Uy.wasm",import.meta.url).href}function re(n){if(n==J&&U)return new Uint8Array(U);if(A)return A(n);throw"both async and sync fetching of the wasm failed"}async function K(n){if(!U)try{var c=await x(n);return new Uint8Array(c)}catch{}return re(n)}async function F(n,c){try{var f=await K(n),h=await WebAssembly.instantiate(f,c);return h}catch(b){C(`failed to asynchronously prepare wasm: ${b}`),X(b)}}async function _e(n,c,f){if(!n&&!o)try{var h=fetch(c,{credentials:"same-origin"}),b=await WebAssembly.instantiateStreaming(h,f);return b}catch(v){C(`wasm streaming compile failed: ${v}`),C("falling back to ArrayBuffer instantiation")}return F(c,f)}function se(){var n={a:rt};return n}async function ie(){function n(v,k){return L=v.exports,L=st(L),nt(L),E(),L}function c(v){return n(v.instance)}var f=se();if(e.instantiateWasm)return new Promise((v,k)=>{e.instantiateWasm(f,(I,N)=>{v(n(I))})});J??=ne();var h=await _e(U,J,f),b=c(h);return b}class oe{name="ExitStatus";constructor(c){this.message=`Program terminated with exit(${c})`,this.status=c}}var Q,P,V,ze=n=>{for(;n.length>0;)n.shift()(e)},ge=[],Be=n=>ge.push(n),ye=[],Me=n=>ye.push(n),me=!0,be=globalThis.TextDecoder&&new TextDecoder,Ie=(n,c,f,h)=>{for(var b=c+f;n[c]&&!(c>=b);)++c;return c},we=(n,c=0,f,h)=>{c>>>=0;var b=Ie(n,c,f);if(b-c>16&&n.buffer&&be)return be.decode(n.subarray(c,b));for(var v="";c<b;){var k=n[c++];if(!(k&128)){v+=String.fromCharCode(k);continue}var I=n[c++]&63;if((k&224)==192){v+=String.fromCharCode((k&31)<<6|I);continue}var N=n[c++]&63;if((k&240)==224?k=(k&15)<<12|I<<6|N:k=(k&7)<<18|I<<12|N<<6|n[c++]&63,k<65536)v+=String.fromCharCode(k);else{var Te=k-65536;v+=String.fromCharCode(55296|Te>>10,56320|Te&1023)}}return v},he=(n,c,f)=>(n>>>=0,n?we(V,n,c):"");function We(n,c,f,h){return n>>>=0,c>>>=0,h>>>=0,X(`Assertion failed: ${he(n)}, at: `+[c?he(c):"unknown filename",f,h?he(h):"unknown function"])}var Le=()=>X(""),ve=0,Ne=()=>{me=!1,ve=0},O={},ke=n=>{if(n instanceof oe||n=="unwind")return T;p(1,n)},xe=()=>me||ve>0,Ae=n=>{T=n,xe()||(e.onExit?.(n),M=!0),p(n,new oe(n))},He=(n,c)=>{T=n,Ae(n)},Se=He,Ke=()=>{if(!xe())try{Se(T)}catch(n){ke(n)}},Fe=n=>{if(!M)try{return n()}catch(c){ke(c)}finally{Ke()}},Re=()=>performance.now(),Ve=(n,c)=>{if(O[n]&&(clearTimeout(O[n].id),delete O[n]),!c)return 0;var f=setTimeout(()=>{delete O[n],Fe(()=>Ce(n,Re()))},c);return O[n]={id:f,timeout_ms:c},0},qe=()=>Date.now(),$e=n=>n>=0&&n<=3;function je(n,c,f){if(f>>>=0,!$e(n))return 28;var h;n===0?h=qe():h=Re();var b=Math.round(h*1e3*1e3);return Q[f>>>3>>>0]=BigInt(b),0}var Ze=()=>4294901760,Ge=(n,c)=>Math.ceil(n/c)*c,Ye=n=>{var c=ae.buffer.byteLength,f=(n-c+65535)/65536|0;try{return ae.grow(f),E(),1}catch{}};function Xe(n){n>>>=0;var c=V.length,f=Ze();if(n>f)return!1;for(var h=1;h<=4;h*=2){var b=c*(1+.2/h);b=Math.min(b,n+100663296);var v=Math.min(f,Ge(Math.max(n,b),65536)),k=Ye(v);if(k)return!0}return!1}var Je=n=>52;function Qe(n,c,f,h){return 70}var Oe=[null,[],[]],et=(n,c)=>{var f=Oe[n];c===0||c===10?((n===1?R:C)(we(f)),f.length=0):f.push(c)};function tt(n,c,f,h){c>>>=0,f>>>=0,h>>>=0;for(var b=0,v=0;v<f;v++){var k=P[c>>>2>>>0],I=P[c+4>>>2>>>0];c+=8;for(var N=0;N<I;N++)et(n,V[k+N>>>0]);b+=I}return P[h>>>2>>>0]=b,0}if(e.noExitRuntime&&(me=e.noExitRuntime),e.print&&(R=e.print),e.printErr&&(C=e.printErr),e.wasmBinary&&(U=e.wasmBinary),e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.preInit)for(typeof e.preInit=="function"&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.shift()();var Ce,ae;function nt(n){e._zk_input_ptr=n.n,e._zk_result_ptr=n.o,e._zk_result_len=n.p,e._zk_gzip_compress=n.q,e._zk_gzip_decompress=n.r,e._zk_deflate_compress=n.s,e._zk_deflate_decompress=n.t,e._zk_zlib_compress=n.u,e._zk_zlib_decompress=n.v,e._zk_crc32=n.w,e._zk_lz4_compress=n.x,e._zk_lz4_decompress=n.y,e._zk_zstd_compress=n.z,e._zk_zstd_decompress=n.A,e._zk_brotli_compress=n.B,e._zk_brotli_decompress=n.C,e._zk_snappy_compress=n.D,e._zk_snappy_decompress=n.E,e._zk_zstd_max_compress=n.F,e._zk_set_aux=n.G,e._zk_zstd_train_dict=n.H,e._zk_zstd_compress_dict=n.I,e._zk_zstd_decompress_dict=n.J,e._zk_lzma_compress=n.K,e._zk_lzma_decompress=n.L,e._zk_xz_ok=n.M,e._zk_xz_compress=n.N,e._zk_xz_decompress=n.O,e._zk_lzma2_decompress=n.P,e._zk_bzip2_compress=n.Q,e._zk_bzip2_decompress=n.R,e._zk_qoi_encode=n.S,e._zk_qoi_decode=n.T,e._zk_frame_delta_encode=n.U,e._zk_frame_delta_decode=n.V,Ce=n.W,ae=n.l,n.__indirect_function_table}var rt={a:We,f:Le,e:Ne,k:Ve,h:je,c:Xe,b:Se,j:Je,g:Qe,i:tt,d:Ae};function st(n){n=Object.assign({},n);var c=h=>b=>h(b)>>>0,f=h=>()=>h()>>>0;return n._emscripten_stack_alloc=c(n._emscripten_stack_alloc),n.emscripten_stack_get_current=f(n.emscripten_stack_get_current),n}function it(){te();function n(){e.calledRun=!0,!M&&(fe(),d?.(e),e.onRuntimeInitialized?.(),Y())}e.setStatus?(e.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>e.setStatus(""),1),n()},1)):n()}var L;return L=await ie(),it(),B?t=e:t=new Promise((n,c)=>{d=n,D=c}),t}class ue{m;constructor(t){this.m=t}static async load(){const t=await ot();return new ue(t)}call(t,e){const r=this.m,i=r._zk_input_ptr(e.length);r.HEAPU8.set(e,i),t(e.length);const o=r._zk_result_ptr(),l=r._zk_result_len()>>>0;return r.HEAPU8.slice(o,o+l)}gzipCompress(t,e=9){return this.call(r=>this.m._zk_gzip_compress(r,e),t)}gzipDecompress(t){return this.call(e=>this.m._zk_gzip_decompress(e),t)}deflateCompress(t,e=9){return this.call(r=>this.m._zk_deflate_compress(r,e),t)}deflateDecompress(t){return this.call(e=>this.m._zk_deflate_decompress(e,0),t)}zlibCompress(t,e=9){return this.call(r=>this.m._zk_zlib_compress(r,e),t)}zlibDecompress(t){return this.call(e=>this.m._zk_zlib_decompress(e,0),t)}crc32(t,e=0){const r=this.m,i=r._zk_input_ptr(t.length);return r.HEAPU8.set(t,i),r._zk_crc32(t.length,e>>>0)>>>0}lz4Compress(t){return this.call(e=>this.m._zk_lz4_compress(e),t)}lz4Decompress(t){return this.call(e=>this.m._zk_lz4_decompress(e),t)}zstdCompress(t,e=19){return this.call(r=>this.m._zk_zstd_compress(r,e),t)}zstdDecompress(t){return this.call(e=>this.m._zk_zstd_decompress(e),t)}brotliCompress(t,e=11){return this.call(r=>this.m._zk_brotli_compress(r,e),t)}brotliDecompress(t){return this.call(e=>this.m._zk_brotli_decompress(e),t)}snappyCompress(t){return this.call(e=>this.m._zk_snappy_compress(e),t)}snappyDecompress(t){return this.call(e=>this.m._zk_snappy_decompress(e),t)}zstdMaxCompress(t,e=22){return this.call(r=>this.m._zk_zstd_max_compress(r,e),t)}lzmaCompress(t,e=9){return this.call(r=>this.m._zk_lzma_compress(r,e),t)}lzmaDecompress(t){return this.call(e=>this.m._zk_lzma_decompress(e),t)}lzma2Decompress(t,e,r){return this.call(i=>this.m._zk_lzma2_decompress(i,e,r),t)}xzCompress(t,e=6){const r=this.call(i=>this.m._zk_xz_compress(i,e),t);if(!this.m._zk_xz_ok())throw new Error("xz compression failed");return r}xzDecompress(t){const e=this.call(r=>this.m._zk_xz_decompress(r),t);if(!this.m._zk_xz_ok())throw new Error("xz decompression failed (corrupt stream or unsupported filter)");return e}setAux(t){const e=this.m,r=e._zk_input_ptr(t.length);e.HEAPU8.set(t,r),e._zk_set_aux(t.length)}zstdTrainDict(t,e,r){const i=this.m,o=i._zk_input_ptr(t.length);i.HEAPU8.set(t,o),i._zk_zstd_train_dict(t.length,e,r);const l=i._zk_result_ptr(),p=i._zk_result_len()>>>0;return i.HEAPU8.slice(l,l+p)}zstdCompressDict(t,e=19){return this.call(r=>this.m._zk_zstd_compress_dict(r,e),t)}zstdDecompressDict(t){return this.call(e=>this.m._zk_zstd_decompress_dict(e),t)}bzip2Compress(t,e=9){return this.call(r=>this.m._zk_bzip2_compress(r,e),t)}bzip2Decompress(t){return this.call(e=>this.m._zk_bzip2_decompress(e),t)}qoiEncode(t,e,r,i){return this.call(o=>this.m._zk_qoi_encode(o,e,r,i),t)}qoiDecode(t){return this.call(e=>this.m._zk_qoi_decode(e),t)}frameDeltaEncode(t,e){return this.call(r=>this.m._zk_frame_delta_encode(r,e),t)}frameDeltaDecode(t,e){return this.call(r=>this.m._zk_frame_delta_decode(r,e),t)}}let at;function w(){return at??=ue.load()}const ct=Object.freeze(Object.defineProperty({__proto__:null,ZipKitEngine:ue,getEngine:w},Symbol.toStringTag,{value:"Module"}));class pe extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}class ee extends Error{constructor(t){super(t),this.name="ZipKitError"}}function lt(s,t,e,r){return s===void 0||!Number.isFinite(s)?r:Math.max(t,Math.min(e,Math.round(s)))}function de(s){return s?.mode??"balanced"}function H(s,t,e,r){return lt(s?.level,t,e,r[de(s)])}function W(){return globalThis.Bun}function ut(s){if(s?.aborted)throw new pe}async function y(s,t,e){ut(t?.signal),t?.onProgress?.(0,0);const r=s();return t?.onProgress?.(1,e),r}function ft(s){return de(s)!=="ratio"&&!!W()?.gzipSync}async function _t(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ft(t))return y(()=>r.gzipSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.gzipCompress(s,e),t,s.length)}async function mt(s,t){const e=W();if(e?.gunzipSync)return y(()=>e.gunzipSync(s),t,s.length);const r=await w();return y(()=>r.gzipDecompress(s),t,s.length)}function ht(s){return de(s)!=="ratio"&&!!W()?.deflateSync}async function pt(s,t){const e=H(t,0,9,{speed:1,balanced:6,ratio:9}),r=W();if(ht(t))return y(()=>r.deflateSync(s,{level:e}),t,s.length);const i=await w();return y(()=>i.deflateCompress(s,e),t,s.length)}async function dt(s,t){const e=W();if(e?.inflateSync)return y(()=>e.inflateSync(s),t,s.length);const r=await w();return y(()=>r.deflateDecompress(s),t,s.length)}async function zt(s,t){const e=await w(),r=H(t,0,9,{speed:1,balanced:6,ratio:9});return y(()=>e.zlibCompress(s,r),t,s.length)}async function gt(s,t){const e=await w();return y(()=>e.zlibDecompress(s),t,s.length)}async function yt(s,t){const e=H(t,1,22,{speed:1,balanced:3,ratio:19}),r=W();if(r?.zstdCompressSync)return y(()=>r.zstdCompressSync(s,{level:e}),t,s.length);const i=await w(),o=e>19?()=>i.zstdMaxCompress(s,e):()=>i.zstdCompress(s,e);return y(o,t,s.length)}async function bt(s,t){const e=W();if(e?.zstdDecompressSync)return y(()=>e.zstdDecompressSync(s),t,s.length);const r=await w();return y(()=>r.zstdDecompress(s),t,s.length)}async function wt(s,t){const e=await w();return y(()=>e.lz4Compress(s),t,s.length)}async function vt(s,t){const e=await w();return y(()=>e.lz4Decompress(s),t,s.length)}async function kt(s,t){const e=await w();return y(()=>e.snappyCompress(s),t,s.length)}async function xt(s,t){const e=await w();return y(()=>e.snappyDecompress(s),t,s.length)}async function At(s,t){const e=await w(),r=H(t,0,11,{speed:4,balanced:6,ratio:11});return y(()=>e.brotliCompress(s,r),t,s.length)}async function St(s,t){const e=await w();return y(()=>e.brotliDecompress(s),t,s.length)}async function Rt(s,t){const e=await w(),r=H(t,0,9,{speed:3,balanced:6,ratio:9});return y(()=>e.lzmaCompress(s,r),t,s.length)}async function Ct(s,t){const e=await w();return y(()=>e.lzmaDecompress(s),t,s.length)}async function Tt(s,t){const e=await w(),r=H(t,1,9,{speed:1,balanced:6,ratio:9});return y(()=>e.bzip2Compress(s,r),t,s.length)}async function Dt(s,t){const e=await w();return y(()=>e.bzip2Decompress(s),t,s.length)}const Pt={gzip:_t,deflate:pt,zlib:zt,zstd:yt,lz4:wt,snappy:kt,brotli:At,lzma:Rt,bzip2:Tt},Ut={gzip:mt,deflate:dt,zlib:gt,zstd:bt,lz4:vt,snappy:xt,brotli:St,lzma:Ct,bzip2:Dt};function Et(s,t,e){const r=Pt[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}function Bt(s,t,e){const r=Ut[t];if(!r)throw new ee(`Unknown codec: ${t}`);return r(s,e)}const Mt=Object.freeze(Object.defineProperty({__proto__:null,compress:Et,decompressWith:Bt},Symbol.toStringTag,{value:"Module"})),It=new URL(import.meta.url.endsWith(".ts")?"./worker.ts":"./worker.js",import.meta.url);function Wt(){const s=globalThis.navigator?.hardwareConcurrency??4;return Math.max(1,Math.min(s,8))}async function Lt(){try{return await ce(()=>import("./__vite-browser-external-BIHI7g3E.js"),[])}catch{return}}class Nt{size;workers=[];pending=new Map;next=0;seq=0;ready;usable=!0;refWhileBusy(){const t=this.pending.size>0;for(const e of this.workers)(t?e.ref:e.unref).call(e)}constructor(t={}){this.size=t.size??Wt()}async ensure(){return this.ready?this.ready:(this.ready=(async()=>{const t=await Lt();if(!t){this.usable=!1;return}for(let e=0;e<this.size;e++){const r=new t.Worker(It);r.on("message",i=>this.settle(i)),r.on("error",i=>this.failAll(i)),r.unref(),this.workers.push(r)}})(),this.ready)}settle(t){const e=this.pending.get(t.id);e&&(this.pending.delete(t.id),this.refWhileBusy(),e.signal&&e.onAbort&&e.signal.removeEventListener("abort",e.onAbort),t.ok&&t.result?e.resolve(t.result):e.reject(new Error(t.error??"Worker operation failed")))}failAll(t){for(const[,e]of this.pending)e.reject(t);this.pending.clear(),this.refWhileBusy()}async run(t,e,r,i,o,l,p){if(l?.aborted)throw new pe;if(await this.ensure(),!this.usable){if(t==="zipCompress"){const{getEngine:A}=await ce(async()=>{const{getEngine:R}=await Promise.resolve().then(()=>ct);return{getEngine:R}},void 0),a=await A();return p==="zstd"?a.zstdCompress(e,i??19):a.deflateCompress(e,i??6)}const{compress:_,decompressWith:x}=await ce(async()=>{const{compress:A,decompressWith:a}=await Promise.resolve().then(()=>Mt);return{compress:A,decompressWith:a}},void 0);return t==="compress"?_(e,r,{level:i,mode:o}):x(e,r)}const m=this.seq++,z=this.workers[this.next++%this.workers.length];return new Promise((_,x)=>{const A={resolve:_,reject:x,signal:l};l&&(A.onAbort=()=>{this.pending.delete(m),this.refWhileBusy(),x(new pe)},l.addEventListener("abort",A.onAbort,{once:!0})),this.pending.set(m,A),this.refWhileBusy();const a=e.slice(),R={id:m,kind:t,codec:r,level:i,mode:o,method:p,data:a};z.postMessage(R,[a.buffer])})}compress(t,e,r){return this.run("compress",t,e,r?.level,r?.mode,r?.signal)}decompress(t,e,r){return this.run("decompress",t,e,void 0,void 0,r?.signal)}zipCompress(t,e,r){return this.run("zipCompress",t,e,r,void 0,void 0,e)}async destroy(){this.failAll(new Error("Worker pool destroyed")),await Promise.all(this.workers.map(t=>t.terminate())),this.workers=[],this.ready=void 0}}let Ht;function Kt(){return Ht??=new Nt}function Ft(s){const e=(Math.max(1980,s.getFullYear())-1980&127)<<9|s.getMonth()+1<<5|s.getDate(),r=s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1;return{date:e,time:r}}let g,$,j,Z,G;const Vt=new Uint32Array([16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648,452984832,905969664]);function qt(){g=new Uint8Array(256);const s=new Uint8Array(256);let t=1,e=1;do t=t^t<<1^(t&128?283:0),t&=255,e^=e<<1,e^=e<<2,e^=e<<4,e&=255,e&128&&(e^=9),e&=255,s[t]=e;while(t!==1);g[0]=99;for(let r=0;r<256;r++){let i=s[r],o=i;for(let l=0;l<4;l++)o=(o<<1|o>>>7)&255,i^=o;i^=99,g[r]=r===0?99:i}$=new Uint32Array(256),j=new Uint32Array(256),Z=new Uint32Array(256),G=new Uint32Array(256);for(let r=0;r<256;r++){const i=g[r],o=$t(i),l=o^i;$[r]=(o<<24|i<<16|i<<8|l)>>>0,j[r]=(l<<24|o<<16|i<<8|i)>>>0,Z[r]=(i<<24|l<<16|o<<8|i)>>>0,G[r]=(i<<24|i<<16|l<<8|o)>>>0}}function $t(s){return(s<<1^(s&128?283:0))&255}class jt{rk;rounds;constructor(t){if(g||qt(),t.length!==16&&t.length!==24&&t.length!==32)throw new Error(`AES key must be 16/24/32 bytes, got ${t.length}`);const e=t.length/4;this.rounds=e+6;const r=4*(this.rounds+1),i=new Uint32Array(r);for(let o=0;o<e;o++)i[o]=(t[4*o]<<24|t[4*o+1]<<16|t[4*o+2]<<8|t[4*o+3])>>>0;for(let o=e;o<r;o++){let l=i[o-1];o%e===0?l=(De(l<<8|l>>>24)^Vt[o/e-1])>>>0:e>6&&o%e===4&&(l=De(l)),i[o]=(i[o-e]^l)>>>0}this.rk=i}encryptBlock(t,e,r,i){const o=this.rk;let l=(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])^o[0],p=(t[e+4]<<24|t[e+5]<<16|t[e+6]<<8|t[e+7])^o[1],m=(t[e+8]<<24|t[e+9]<<16|t[e+10]<<8|t[e+11])^o[2],z=(t[e+12]<<24|t[e+13]<<16|t[e+14]<<8|t[e+15])^o[3],_=4;for(let x=1;x<this.rounds;x++){const A=($[l>>>24&255]^j[p>>>16&255]^Z[m>>>8&255]^G[z&255]^o[_])>>>0,a=($[p>>>24&255]^j[m>>>16&255]^Z[z>>>8&255]^G[l&255]^o[_+1])>>>0,R=($[m>>>24&255]^j[z>>>16&255]^Z[l>>>8&255]^G[p&255]^o[_+2])>>>0,C=($[z>>>24&255]^j[l>>>16&255]^Z[p>>>8&255]^G[m&255]^o[_+3])>>>0;l=A,p=a,m=R,z=C,_+=4}r[i]=(g[l>>>24&255]^o[_]>>>24)&255,r[i+1]=(g[p>>>16&255]^o[_]>>>16)&255,r[i+2]=(g[m>>>8&255]^o[_]>>>8)&255,r[i+3]=(g[z&255]^o[_])&255,r[i+4]=(g[p>>>24&255]^o[_+1]>>>24)&255,r[i+5]=(g[m>>>16&255]^o[_+1]>>>16)&255,r[i+6]=(g[z>>>8&255]^o[_+1]>>>8)&255,r[i+7]=(g[l&255]^o[_+1])&255,r[i+8]=(g[m>>>24&255]^o[_+2]>>>24)&255,r[i+9]=(g[z>>>16&255]^o[_+2]>>>16)&255,r[i+10]=(g[l>>>8&255]^o[_+2]>>>8)&255,r[i+11]=(g[p&255]^o[_+2])&255,r[i+12]=(g[z>>>24&255]^o[_+3]>>>24)&255,r[i+13]=(g[l>>>16&255]^o[_+3]>>>16)&255,r[i+14]=(g[p>>>8&255]^o[_+3]>>>8)&255,r[i+15]=(g[m&255]^o[_+3])&255}}function De(s){return(g[s>>>24&255]<<24|g[s>>>16&255]<<16|g[s>>>8&255]<<8|g[s&255])>>>0}function Zt(s,t){const e=new Uint8Array(t.length),r=new Uint8Array(16),i=new Uint8Array(16);let o=1;for(let l=0;l<t.length;l+=16){r[0]=o&255,r[1]=o>>>8&255,r[2]=o>>>16&255,r[3]=o>>>24&255,s.encryptBlock(r,0,i,0);const p=Math.min(16,t.length-l);for(let m=0;m<p;m++)e[l+m]=t[l+m]^i[m];o++}return e}const Gt={1:16,2:24,3:32},Yt={1:8,2:12,3:16},Ee=10,Xt=1e3;function le(){const s=globalThis.crypto;if(!s?.subtle)throw new ee("WebCrypto (crypto.subtle) is required for ZIP AES encryption");return s.subtle}function Jt(s){const t=globalThis.crypto;if(!t?.getRandomValues)throw new ee("crypto.getRandomValues is required to create encrypted ZIPs");return t.getRandomValues(new Uint8Array(s))}async function Qt(s,t,e){const r=Gt[e],i=await le().importKey("raw",new TextEncoder().encode(s),"PBKDF2",!1,["deriveBits"]),o=await le().deriveBits({name:"PBKDF2",salt:t,iterations:Xt,hash:"SHA-1"},i,(r*2+2)*8),l=new Uint8Array(o);return{aesKey:l.subarray(0,r),macKey:l.subarray(r,r*2),verifier:l.subarray(r*2,r*2+2)}}async function Ot(s,t){const e=await le().importKey("raw",s,{name:"HMAC",hash:"SHA-1"},!1,["sign"]),r=await le().sign("HMAC",e,t);return new Uint8Array(r).subarray(0,Ee)}async function en(s,t,e=3){const r=Jt(Yt[e]),{aesKey:i,macKey:o,verifier:l}=await Qt(t,r,e),p=Zt(new jt(i),s),m=await Ot(o,p),z=new Uint8Array(r.length+2+p.length+Ee);return z.set(r,0),z.set(l,r.length),z.set(p,r.length+2),z.set(m,r.length+2+p.length),{payload:z,strength:e}}const tn=256*1024,nn=67324752,rn=33639248,sn=101010256,on=101075792,an=117853008,S=4294967295,q=65535,cn={store:0,deflate:8,zstd:93};class ln{buf=new Uint8Array(1024);view=new DataView(this.buf.buffer);len=0;grow(t){if(this.len+t<=this.buf.length)return;let e=this.buf.length*2;for(;e<this.len+t;)e*=2;const r=new Uint8Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r,this.view=new DataView(this.buf.buffer)}u16(t){this.grow(2),this.view.setUint16(this.len,t,!0),this.len+=2}u32(t){this.grow(4),this.view.setUint32(this.len,t>>>0,!0),this.len+=4}u64(t){this.grow(8),this.view.setBigUint64(this.len,BigInt(t),!0),this.len+=8}bytes(t){this.grow(t.length),this.buf.set(t,this.len),this.len+=t.length}done(){return this.buf.slice(0,this.len)}}function Pe(s,t,e){s.u16(39169),s.u16(7),s.u16(2),s.u16(17729),s.bytes(new Uint8Array([t])),s.u16(e)}async function un(s,t,e){if(t==="store")return s;const r=await w();if(t==="deflate")return r.deflateCompress(s,e??6);if(t==="zstd")return r.zstdCompress(s,e??19);throw new ee(`Unsupported ZIP method: ${t}`)}const Ue=new TextEncoder;async function _n(s,t={}){const e=await w(),r=s.reduce((u,d)=>u+d.data.length,0),o=t.parallel??(s.length>=2&&r>=tn)?Kt():void 0,l=s.map(u=>e.crc32(u.data));let p=0;const m=t.onProgress,z=await Promise.all(s.map(u=>{const d=u.method??"deflate",D=d==="store"?Promise.resolve(u.data):o?o.zipCompress(u.data,d,u.level??(d==="zstd"?19:6)):un(u.data,d,u.level);return m?D.then(B=>(m(++p,s.length),B)):D})),_=3,x=t.password?await Promise.all(z.map(u=>en(u,t.password,_))):void 0,A=x?x.map(u=>u.payload):z,a=new ln,R=[];let C=s.length>q;for(let u=0;u<s.length;u++){const d=s[u],D=d.method??"deflate",B=cn[D],E=x!==void 0,te=E?99:B,fe=2048|(E?1:0),Y=Ue.encode(d.name),X=d.comment?Ue.encode(d.comment):new Uint8Array(0),J=l[u],ne=E?0:J,re=A[u],K=d.data.length,F=re.length,_e=d.mtime===void 0?new Date:new Date(d.mtime),{date:se,time:ie}=Ft(_e),oe=d.unixPermissions!==void 0?(d.unixPermissions&65535)<<16:0,Q=a.len,P=C||K>S||F>S||Q>S;P&&(C=!0);const V=(P?20:0)+(E?11:0);a.u32(nn),a.u16(P?45:20),a.u16(fe),a.u16(te),a.u16(ie),a.u16(se),a.u32(ne),a.u32(P?S:F),a.u32(P?S:K),a.u16(Y.length),a.u16(V),a.bytes(Y),P&&(a.u16(1),a.u16(16),a.u64(K),a.u64(F)),E&&Pe(a,_,B),a.bytes(re),R.push({nameBytes:Y,commentBytes:X,method:te,actualMethod:B,encrypted:E,crc:ne,compSize:F,size:K,dosDate:se,dosTime:ie,offset:Q,externalAttrs:oe,zip64:P})}const U=a.len;for(const u of R){a.u32(rn),a.u16(u.zip64?45:20),a.u16(u.zip64?45:20),a.u16(2048|(u.encrypted?1:0)),a.u16(u.method),a.u16(u.dosTime),a.u16(u.dosDate),a.u32(u.crc);const d=u.zip64;a.u32(d?S:u.compSize),a.u32(d?S:u.size),a.u16(u.nameBytes.length);const D=[];d&&D.push(u.size,u.compSize,u.offset);const B=(d?4+D.length*8:0)+(u.encrypted?11:0);if(a.u16(B),a.u16(u.commentBytes.length),a.u16(0),a.u16(0),a.u32(u.externalAttrs),a.u32(d?S:u.offset),a.bytes(u.nameBytes),d){a.u16(1),a.u16(D.length*8);for(const E of D)a.u64(E)}u.encrypted&&Pe(a,3,u.actualMethod),a.bytes(u.commentBytes)}const M=a.len-U,T=R.length;if(C||T>q||M>S||U>S){const u=a.len;a.u32(on),a.u64(44),a.u16(45),a.u16(45),a.u32(0),a.u32(0),a.u64(T),a.u64(T),a.u64(M),a.u64(U),a.u32(an),a.u32(0),a.u64(u),a.u32(1)}return a.u32(sn),a.u16(0),a.u16(0),a.u16(T>q?q:T),a.u16(T>q?q:T),a.u32(M>S?S:M),a.u32(U>S?S:U),a.u16(0),a.done()}new TextDecoder("utf-8");export{pe as AbortError,Nt as WorkerPool,ue as ZipKitEngine,ee as ZipKitError,At as brotli,Tt as bzip2,Et as compress,Bt as decompressWith,pt as deflate,w as getEngine,mt as gunzip,_t as gzip,dt as inflate,wt as lz4,Rt as lzma,Kt as sharedPool,kt as snappy,St as unbrotli,Dt as unbzip2,vt as unlz4,Ct as unlzma,xt as unsnappy,gt as unzlib,bt as unzstd,_n as zip,zt as zlib,yt as zstd};
@@ -1 +1 @@
1
- import{s as _,_ as d,r as s,a as u}from"./main-Bo1hD7mt.js";import{C as T,P as y,W as E,d as L,b as g,c as v,h as P,l as b,m as k,e as D,n as O,f as R,g as S,t as V}from"./main-Bo1hD7mt.js";async function h(o,e={}){const i=e.loading===!1?void 0:_(o,e.loadingText??"Loading…"),[{Terminal:l},{FitAddon:c}]=await Promise.all([d(()=>import("./xterm-B-qIQCd3.js"),[]),d(()=>import("./addon-fit-DX4qG4td.js"),[])]).catch(r=>{throw i?.(),r}),a=new l({scrollback:e.scrollback??5e3,fontSize:e.fontSize??13,fontFamily:e.fontFamily??"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:e.lineHeight??1,cursorBlink:e.cursorBlink??!1,cursorStyle:e.cursorStyle??"block",disableStdin:e.stdin!==!0,allowProposedApi:!0,convertEol:!0,theme:s(e.theme),...e.cols?{cols:e.cols}:{},...e.rows?{rows:e.rows}:{},...e.terminalOptions??{}}),t=e.fit===!1?void 0:new c;if(t&&a.loadAddon(t),e.clipboard)try{const{ClipboardAddon:r}=await d(()=>import("./addon-clipboard-wHJhZAA4.js"),[]);a.loadAddon(new r)}catch{}if(e.webLinks)try{const{WebLinksAddon:r}=await d(()=>import("./addon-web-links-DIbG5aQx.js"),[]);a.loadAddon(new r)}catch{}if(e.unicode11)try{const{Unicode11Addon:r}=await d(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]);a.loadAddon(new r),a.unicode.activeVersion="11"}catch{}for(const r of e.addons??[])a.loadAddon(r);if(a.open(o),e.ligatures)try{const{LigaturesAddon:r}=await d(()=>import("./addon-ligatures-DpDY8N_X.js"),[]);a.loadAddon(new r)}catch{}const m=t?u({resize:async()=>{}},a,t,{debounceMs:e.fitDebounceMs??100}):void 0;e.onReady?.(a),i?.();let n=!1;return{terminal:a,fitAddon:t,write:r=>a.write(r),clear:()=>{a.clear(),a.reset()},fit:()=>t?.fit(),setTheme:r=>{a.options.theme=s(r)},dispose(){n||(n=!0,m?.(),a.dispose())}}}export{T as ClientSession,y as PtyKitClient,E as WsCore,u as attachFit,L as darkTheme,g as defaultPersistence,v as draculaTheme,P as hostSocket,b as lightTheme,k as matrixTheme,D as mountTerminal,h as mountViewer,O as nordTheme,s as resolveTheme,_ as showLoadingOverlay,R as solarizedDarkTheme,S as solarizedLightTheme,V as themes};
1
+ import{s as _,_ as d,r as s,a as u}from"./main-BrfXH1bL.js";import{C as T,P as y,W as E,d as L,b as g,c as v,h as P,l as b,m as k,e as D,n as O,f as R,g as S,t as V}from"./main-BrfXH1bL.js";async function h(o,e={}){const i=e.loading===!1?void 0:_(o,e.loadingText??"Loading…"),[{Terminal:l},{FitAddon:c}]=await Promise.all([d(()=>import("./xterm-B-qIQCd3.js"),[]),d(()=>import("./addon-fit-DX4qG4td.js"),[])]).catch(r=>{throw i?.(),r}),a=new l({scrollback:e.scrollback??5e3,fontSize:e.fontSize??13,fontFamily:e.fontFamily??"ui-monospace, SFMono-Regular, Menlo, monospace",lineHeight:e.lineHeight??1,cursorBlink:e.cursorBlink??!1,cursorStyle:e.cursorStyle??"block",disableStdin:e.stdin!==!0,allowProposedApi:!0,convertEol:!0,theme:s(e.theme),...e.cols?{cols:e.cols}:{},...e.rows?{rows:e.rows}:{},...e.terminalOptions??{}}),t=e.fit===!1?void 0:new c;if(t&&a.loadAddon(t),e.clipboard)try{const{ClipboardAddon:r}=await d(()=>import("./addon-clipboard-wHJhZAA4.js"),[]);a.loadAddon(new r)}catch{}if(e.webLinks)try{const{WebLinksAddon:r}=await d(()=>import("./addon-web-links-DIbG5aQx.js"),[]);a.loadAddon(new r)}catch{}if(e.unicode11)try{const{Unicode11Addon:r}=await d(()=>import("./addon-unicode11-Bt8F3D7-.js"),[]);a.loadAddon(new r),a.unicode.activeVersion="11"}catch{}for(const r of e.addons??[])a.loadAddon(r);if(a.open(o),e.ligatures)try{const{LigaturesAddon:r}=await d(()=>import("./addon-ligatures-DpDY8N_X.js"),[]);a.loadAddon(new r)}catch{}const m=t?u({resize:async()=>{}},a,t,{debounceMs:e.fitDebounceMs??100}):void 0;e.onReady?.(a),i?.();let n=!1;return{terminal:a,fitAddon:t,write:r=>a.write(r),clear:()=>{a.clear(),a.reset()},fit:()=>t?.fit(),setTheme:r=>{a.options.theme=s(r)},dispose(){n||(n=!0,m?.(),a.dispose())}}}export{T as ClientSession,y as PtyKitClient,E as WsCore,u as attachFit,L as darkTheme,g as defaultPersistence,v as draculaTheme,P as hostSocket,b as lightTheme,k as matrixTheme,D as mountTerminal,h as mountViewer,O as nordTheme,s as resolveTheme,_ as showLoadingOverlay,R as solarizedDarkTheme,S as solarizedLightTheme,V as themes};