zip-peek 0.1.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.
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureZipServiceWorkerRegistered = ensureZipServiceWorkerRegistered;
4
+ function normalizeScopePath(href) {
5
+ let p = new URL(href).pathname;
6
+ if (p.length > 1 && p.endsWith('/')) {
7
+ p = p.slice(0, -1);
8
+ }
9
+ return p;
10
+ }
11
+ function zipServiceWorkerScriptMatches(scriptURL, expectedWorkerUrl) {
12
+ if (!scriptURL) {
13
+ return false;
14
+ }
15
+ try {
16
+ const expected = new URL(expectedWorkerUrl, window.location.href).href;
17
+ const resolved = new URL(scriptURL, window.location.href).href;
18
+ return resolved === expected;
19
+ }
20
+ catch {
21
+ try {
22
+ return /\/zipServiceWorker(\.[0-9a-f]{8})?\.js(\?|$)/.test(new URL(scriptURL).pathname);
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ }
29
+ /**
30
+ * Removes prior registration that used the same script URL but a different scope, so an old
31
+ * default/narrow scope does not win over the caller-provided package scope.
32
+ */
33
+ async function unregisterMismatchedScopeZipServiceWorkerIfNeeded(expectedWorkerUrl, expectedScopeUrl) {
34
+ const expectedWorkerHref = new URL(expectedWorkerUrl, window.location.href).href;
35
+ const wantScopePath = normalizeScopePath(expectedScopeUrl);
36
+ const registrations = await navigator.serviceWorker.getRegistrations();
37
+ for (const reg of registrations) {
38
+ const scriptURL = reg.installing?.scriptURL ?? reg.waiting?.scriptURL ?? reg.active?.scriptURL;
39
+ if (!scriptURL) {
40
+ continue;
41
+ }
42
+ let scriptHref;
43
+ try {
44
+ scriptHref = new URL(scriptURL, window.location.href).href;
45
+ }
46
+ catch {
47
+ continue;
48
+ }
49
+ if (scriptHref !== expectedWorkerHref) {
50
+ continue;
51
+ }
52
+ const regScopePath = normalizeScopePath(reg.scope);
53
+ if (regScopePath !== wantScopePath) {
54
+ await reg.unregister();
55
+ console.log(`Unregistered zip service worker (scope ${reg.scope}); re-registering with ${expectedScopeUrl}`);
56
+ }
57
+ }
58
+ }
59
+ /**
60
+ * Registers the zip worker script URL with the caller-provided scope.
61
+ *
62
+ * @returns true if the page is reloading and callers should abort init.
63
+ */
64
+ async function ensureZipServiceWorkerRegistered({ workerUrl, scopeUrl, reloadOnFirstInstall = true, }) {
65
+ if (!('serviceWorker' in navigator)) {
66
+ return false;
67
+ }
68
+ await unregisterMismatchedScopeZipServiceWorkerIfNeeded(workerUrl, scopeUrl);
69
+ const existing = await navigator.serviceWorker.getRegistration(scopeUrl);
70
+ const alreadyRegistered = existing &&
71
+ (zipServiceWorkerScriptMatches(existing.active?.scriptURL, workerUrl) ||
72
+ zipServiceWorkerScriptMatches(existing.waiting?.scriptURL, workerUrl) ||
73
+ zipServiceWorkerScriptMatches(existing.installing?.scriptURL, workerUrl));
74
+ if (!alreadyRegistered) {
75
+ await navigator.serviceWorker.register(workerUrl, { scope: scopeUrl });
76
+ console.log('Zip service worker registered successfully');
77
+ }
78
+ else {
79
+ console.log('Zip service worker already registered; skipping register().');
80
+ }
81
+ await navigator.serviceWorker.ready;
82
+ if (reloadOnFirstInstall && !navigator.serviceWorker.controller) {
83
+ window.location.reload();
84
+ return true;
85
+ }
86
+ return false;
87
+ }
@@ -0,0 +1,28 @@
1
+ /** True when the URL points at a `.zip` package (path ends with `.zip`). */
2
+ export declare function isZipPackage(url: string): boolean;
3
+ /**
4
+ * Strip only the `t` cache-buster query param; keep everything else verbatim.
5
+ * Avoids `URL` / `URLSearchParams` so SigV4 values (e.g. `%2F` in credentials)
6
+ * are not re-encoded.
7
+ */
8
+ export declare function stripTParam(urlString: string): string;
9
+ /** Same key the service worker uses for manifests / purge (presigned query kept). */
10
+ export declare const normalizeZipUrlForSw: typeof stripTParam;
11
+ /** Align zip entry names with URL paths under `*.zip/…`. */
12
+ export declare function normalizeZipEntryPath(name: string): string;
13
+ export type ParsedZipAssetRequest = {
14
+ zipUrl: string;
15
+ internalPath: string;
16
+ };
17
+ /**
18
+ * Split a request URL into the zip resource URL and inner path.
19
+ *
20
+ * - Normal: `https://host/pkg.zip/asset.png?t=…`
21
+ * - Presigned: `https://host/pkg.zip?sig…/asset.png?t=…` (first `/` after `?`
22
+ * ends signed params; `/` inside values is `%2F` for AWS.)
23
+ *
24
+ * Returns `null` for bare `.zip` GETs (e.g. manifest bootstrap).
25
+ */
26
+ export declare function parseZipAssetRequest(urlString: string): ParsedZipAssetRequest | null;
27
+ /** Cache key for a zip asset (decoded manifest key + zip URL without `t`). */
28
+ export declare function canonicalZipAssetRequestUrl(zipUrl: string, manifestKey: string): string;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeZipUrlForSw = void 0;
4
+ exports.isZipPackage = isZipPackage;
5
+ exports.stripTParam = stripTParam;
6
+ exports.normalizeZipEntryPath = normalizeZipEntryPath;
7
+ exports.parseZipAssetRequest = parseZipAssetRequest;
8
+ exports.canonicalZipAssetRequestUrl = canonicalZipAssetRequestUrl;
9
+ /** True when the URL points at a `.zip` package (path ends with `.zip`). */
10
+ function isZipPackage(url) {
11
+ try {
12
+ const u = new URL(url);
13
+ return u.pathname.endsWith('.zip');
14
+ }
15
+ catch {
16
+ return url.split('?')[0].endsWith('.zip');
17
+ }
18
+ }
19
+ /**
20
+ * Strip only the `t` cache-buster query param; keep everything else verbatim.
21
+ * Avoids `URL` / `URLSearchParams` so SigV4 values (e.g. `%2F` in credentials)
22
+ * are not re-encoded.
23
+ */
24
+ function stripTParam(urlString) {
25
+ const qIdx = urlString.indexOf('?');
26
+ if (qIdx === -1)
27
+ return urlString.split('#')[0];
28
+ const hashIdx = urlString.indexOf('#', qIdx);
29
+ const prefix = urlString.substring(0, qIdx);
30
+ const querySection = hashIdx === -1 ? urlString.substring(qIdx + 1) : urlString.substring(qIdx + 1, hashIdx);
31
+ const hashSection = hashIdx === -1 ? '' : urlString.substring(hashIdx);
32
+ const filtered = querySection.split('&').filter(p => {
33
+ const eqIdx = p.indexOf('=');
34
+ const k = eqIdx === -1 ? p : p.substring(0, eqIdx);
35
+ return k !== 't';
36
+ });
37
+ if (filtered.length === 0)
38
+ return prefix + hashSection;
39
+ return prefix + '?' + filtered.join('&') + hashSection;
40
+ }
41
+ /** Same key the service worker uses for manifests / purge (presigned query kept). */
42
+ exports.normalizeZipUrlForSw = stripTParam;
43
+ /** Align zip entry names with URL paths under `*.zip/…`. */
44
+ function normalizeZipEntryPath(name) {
45
+ let s = name.replace(/\\/g, '/');
46
+ while (s.startsWith('/'))
47
+ s = s.slice(1);
48
+ return s;
49
+ }
50
+ function safeDecodeSegment(s) {
51
+ try {
52
+ return decodeURIComponent(s);
53
+ }
54
+ catch {
55
+ return s;
56
+ }
57
+ }
58
+ /**
59
+ * Split a request URL into the zip resource URL and inner path.
60
+ *
61
+ * - Normal: `https://host/pkg.zip/asset.png?t=…`
62
+ * - Presigned: `https://host/pkg.zip?sig…/asset.png?t=…` (first `/` after `?`
63
+ * ends signed params; `/` inside values is `%2F` for AWS.)
64
+ *
65
+ * Returns `null` for bare `.zip` GETs (e.g. manifest bootstrap).
66
+ */
67
+ function parseZipAssetRequest(urlString) {
68
+ const match = /\.zip([/?])/.exec(urlString);
69
+ if (!match)
70
+ return null;
71
+ const sepIdx = match.index + 4;
72
+ const separator = match[1];
73
+ const zipUrlBase = urlString.substring(0, sepIdx);
74
+ if (separator === '/') {
75
+ const rest = urlString.substring(sepIdx + 1);
76
+ const qIdx = rest.indexOf('?');
77
+ const rawInternal = qIdx === -1 ? rest : rest.substring(0, qIdx);
78
+ if (rawInternal === '')
79
+ return null;
80
+ return { zipUrl: zipUrlBase, internalPath: safeDecodeSegment(rawInternal) };
81
+ }
82
+ const afterZip = urlString.substring(sepIdx);
83
+ const slashIdx = afterZip.indexOf('/');
84
+ if (slashIdx === -1)
85
+ return null;
86
+ const zipQueryPart = afterZip.substring(0, slashIdx);
87
+ const afterSlash = afterZip.substring(slashIdx + 1);
88
+ const qIdx = afterSlash.indexOf('?');
89
+ const rawInternal = qIdx === -1 ? afterSlash : afterSlash.substring(0, qIdx);
90
+ if (rawInternal === '')
91
+ return null;
92
+ return {
93
+ zipUrl: zipUrlBase + zipQueryPart,
94
+ internalPath: safeDecodeSegment(rawInternal),
95
+ };
96
+ }
97
+ /** Cache key for a zip asset (decoded manifest key + zip URL without `t`). */
98
+ function canonicalZipAssetRequestUrl(zipUrl, manifestKey) {
99
+ return zipUrl + '/' + encodeURI(manifestKey);
100
+ }
@@ -0,0 +1,2 @@
1
+ (()=>{"use strict";var t={183(t,n){function e(t){const n=t.indexOf("?");if(-1===n)return t.split("#")[0];const e=t.indexOf("#",n),i=t.substring(0,n),r=-1===e?t.substring(n+1):t.substring(n+1,e),s=-1===e?"":t.substring(e),a=r.split("&").filter(t=>{const n=t.indexOf("=");return"t"!==(-1===n?t:t.substring(0,n))});return 0===a.length?i+s:i+"?"+a.join("&")+s}function i(t){try{return decodeURIComponent(t)}catch{return t}}Object.defineProperty(n,"__esModule",{value:!0}),n.normalizeZipUrlForSw=void 0,n.isZipPackage=function(t){try{return new URL(t).pathname.endsWith(".zip")}catch{return t.split("?")[0].endsWith(".zip")}},n.stripTParam=e,n.normalizeZipEntryPath=function(t){let n=t.replace(/\\/g,"/");for(;n.startsWith("/");)n=n.slice(1);return n},n.parseZipAssetRequest=function(t){const n=/\.zip([/?])/.exec(t);if(!n)return null;const e=n.index+4,r=n[1],s=t.substring(0,e);if("/"===r){const n=t.substring(e+1),r=n.indexOf("?"),a=-1===r?n:n.substring(0,r);return""===a?null:{zipUrl:s,internalPath:i(a)}}const a=t.substring(e),o=a.indexOf("/");if(-1===o)return null;const u=a.substring(0,o),f=a.substring(o+1),c=f.indexOf("?"),h=-1===c?f:f.substring(0,c);return""===h?null:{zipUrl:s+u,internalPath:i(h)}},n.canonicalZipAssetRequestUrl=function(t,n){return t+"/"+encodeURI(n)},n.normalizeZipUrlForSw=e},845(t,n){var e={},i=function(t,n,i,r,s){var a=new Worker(e[n]||(e[n]=URL.createObjectURL(new Blob([t+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return a.onmessage=function(t){var n=t.data,e=n.$e$;if(e){var i=new Error(e[0]);i.code=e[1],i.stack=e[2],s(i,null)}else s(null,n)},a.postMessage(i,r),a},r=Uint8Array,s=Uint16Array,a=Int32Array,o=new r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),u=new r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),f=new r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=function(t,n){for(var e=new s(31),i=0;i<31;++i)e[i]=n+=1<<t[i-1];var r=new a(e[30]);for(i=1;i<30;++i)for(var o=e[i];o<e[i+1];++o)r[o]=o-e[i]<<5|i;return{b:e,r}},h=c(o,2),l=h.b,p=h.r;l[28]=258,p[258]=28;for(var d=c(u,0),v=d.b,g=d.r,m=new s(32768),y=0;y<32768;++y){var w=(43690&y)>>1|(21845&y)<<1;w=(61680&(w=(52428&w)>>2|(13107&w)<<2))>>4|(3855&w)<<4,m[y]=((65280&w)>>8|(255&w)<<8)>>1}var b=function(t,n,e){for(var i=t.length,r=0,a=new s(n);r<i;++r)t[r]&&++a[t[r]-1];var o,u=new s(n);for(r=1;r<n;++r)u[r]=u[r-1]+a[r-1]<<1;if(e){o=new s(1<<n);var f=15-n;for(r=0;r<i;++r)if(t[r])for(var c=r<<4|t[r],h=n-t[r],l=u[t[r]-1]++<<h,p=l|(1<<h)-1;l<=p;++l)o[m[l]>>f]=c}else for(o=new s(i),r=0;r<i;++r)t[r]&&(o[r]=m[u[t[r]-1]++]>>15-t[r]);return o},z=new r(288);for(y=0;y<144;++y)z[y]=8;for(y=144;y<256;++y)z[y]=9;for(y=256;y<280;++y)z[y]=7;for(y=280;y<288;++y)z[y]=8;var x=new r(32);for(y=0;y<32;++y)x[y]=5;var A=b(z,9,0),S=b(z,9,1),k=b(x,5,0),C=b(x,5,1),U=function(t){for(var n=t[0],e=1;e<t.length;++e)t[e]>n&&(n=t[e]);return n},M=function(t,n,e){var i=n/8|0;return(t[i]|t[i+1]<<8)>>(7&n)&e},T=function(t,n){var e=n/8|0;return(t[e]|t[e+1]<<8|t[e+2]<<16)>>(7&n)},I=function(t){return(t+7)/8|0},P=function(t,n,e){return(null==n||n<0)&&(n=0),(null==e||e>t.length)&&(e=t.length),new r(t.subarray(n,e))};n.FlateErrorCode={UnexpectedEOF:0,InvalidBlockType:1,InvalidLengthLiteral:2,InvalidDistance:3,StreamFinished:4,NoStreamHandler:5,InvalidHeader:6,NoCallback:7,InvalidUTF8:8,ExtraFieldTooLong:9,InvalidDate:10,FilenameTooLong:11,StreamFinishing:12,InvalidZipData:13,UnknownCompressionMethod:14};var Z=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],E=function(t,n,e){var i=new Error(n||Z[t]);if(i.code=t,Error.captureStackTrace&&Error.captureStackTrace(i,E),!e)throw i;return i},_=function(t,n,e,i){var s=t.length,a=i?i.length:0;if(!s||n.f&&!n.l)return e||new r(0);var c=!e,h=c||2!=n.i,p=n.i;c&&(e=new r(3*s));var d=function(t){var n=e.length;if(t>n){var i=new r(Math.max(2*n,t));i.set(e),e=i}},g=n.f||0,m=n.p||0,y=n.b||0,w=n.l,z=n.d,x=n.m,A=n.n,k=8*s;do{if(!w){g=M(t,m,1);var Z=M(t,m+1,3);if(m+=3,!Z){var _=t[($=I(m)+4)-4]|t[$-3]<<8,O=$+_;if(O>s){p&&E(0);break}h&&d(y+_),e.set(t.subarray($,O),y),n.b=y+=_,n.p=m=8*O,n.f=g;continue}if(1==Z)w=S,z=C,x=9,A=5;else if(2==Z){var F=M(t,m,31)+257,R=M(t,m+10,15)+4,q=F+M(t,m+5,31)+1;m+=14;for(var D=new r(q),N=new r(19),j=0;j<R;++j)N[f[j]]=M(t,m+3*j,7);m+=3*R;var L=U(N),W=(1<<L)-1,G=b(N,L,1);for(j=0;j<q;){var $,H=G[M(t,m,W)];if(m+=15&H,($=H>>4)<16)D[j++]=$;else{var B=0,K=0;for(16==$?(K=3+M(t,m,3),m+=2,B=D[j-1]):17==$?(K=3+M(t,m,7),m+=3):18==$&&(K=11+M(t,m,127),m+=7);K--;)D[j++]=B}}var X=D.subarray(0,F),J=D.subarray(F);x=U(X),A=U(J),w=b(X,x,1),z=b(J,A,1)}else E(1);if(m>k){p&&E(0);break}}h&&d(y+131072);for(var V=(1<<x)-1,Y=(1<<A)-1,Q=m;;Q=m){var tt=(B=w[T(t,m)&V])>>4;if((m+=15&B)>k){p&&E(0);break}if(B||E(2),tt<256)e[y++]=tt;else{if(256==tt){Q=m,w=null;break}var nt=tt-254;if(tt>264){var et=o[j=tt-257];nt=M(t,m,(1<<et)-1)+l[j],m+=et}var it=z[T(t,m)&Y],rt=it>>4;if(it||E(3),m+=15&it,J=v[rt],rt>3&&(et=u[rt],J+=T(t,m)&(1<<et)-1,m+=et),m>k){p&&E(0);break}h&&d(y+131072);var st=y+nt;if(y<J){var at=a-J,ot=Math.min(J,st);for(at+y<0&&E(3);y<ot;++y)e[y]=i[at+y]}for(;y<st;++y)e[y]=e[y-J]}}n.l=w,n.p=Q,n.b=y,n.f=g,w&&(g=1,n.m=x,n.d=z,n.n=A)}while(!g);return y!=e.length&&c?P(e,0,y):e.subarray(0,y)},O=function(t,n,e){e<<=7&n;var i=n/8|0;t[i]|=e,t[i+1]|=e>>8},F=function(t,n,e){e<<=7&n;var i=n/8|0;t[i]|=e,t[i+1]|=e>>8,t[i+2]|=e>>16},R=function(t,n){for(var e=[],i=0;i<t.length;++i)t[i]&&e.push({s:i,f:t[i]});var a=e.length,o=e.slice();if(!a)return{t:G,l:0};if(1==a){var u=new r(e[0].s+1);return u[e[0].s]=1,{t:u,l:1}}e.sort(function(t,n){return t.f-n.f}),e.push({s:-1,f:25001});var f=e[0],c=e[1],h=0,l=1,p=2;for(e[0]={s:-1,f:f.f+c.f,l:f,r:c};l!=a-1;)f=e[e[h].f<e[p].f?h++:p++],c=e[h!=l&&e[h].f<e[p].f?h++:p++],e[l++]={s:-1,f:f.f+c.f,l:f,r:c};var d=o[0].s;for(i=1;i<a;++i)o[i].s>d&&(d=o[i].s);var v=new s(d+1),g=q(e[l-1],v,0);if(g>n){i=0;var m=0,y=g-n,w=1<<y;for(o.sort(function(t,n){return v[n.s]-v[t.s]||t.f-n.f});i<a;++i){var b=o[i].s;if(!(v[b]>n))break;m+=w-(1<<g-v[b]),v[b]=n}for(m>>=y;m>0;){var z=o[i].s;v[z]<n?m-=1<<n-v[z]++-1:++i}for(;i>=0&&m;--i){var x=o[i].s;v[x]==n&&(--v[x],++m)}g=n}return{t:new r(v),l:g}},q=function(t,n,e){return-1==t.s?Math.max(q(t.l,n,e+1),q(t.r,n,e+1)):n[t.s]=e},D=function(t){for(var n=t.length;n&&!t[--n];);for(var e=new s(++n),i=0,r=t[0],a=1,o=function(t){e[i++]=t},u=1;u<=n;++u)if(t[u]==r&&u!=n)++a;else{if(!r&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(r),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(r);a=1,r=t[u]}return{c:e.subarray(0,i),n}},N=function(t,n){for(var e=0,i=0;i<n.length;++i)e+=t[i]*n[i];return e},j=function(t,n,e){var i=e.length,r=I(n+2);t[r]=255&i,t[r+1]=i>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var s=0;s<i;++s)t[r+s+4]=e[s];return 8*(r+4+i)},L=function(t,n,e,i,r,a,c,h,l,p,d){O(n,d++,e),++r[256];for(var v=R(r,15),g=v.t,m=v.l,y=R(a,15),w=y.t,S=y.l,C=D(g),U=C.c,M=C.n,T=D(w),I=T.c,P=T.n,Z=new s(19),E=0;E<U.length;++E)++Z[31&U[E]];for(E=0;E<I.length;++E)++Z[31&I[E]];for(var _=R(Z,7),q=_.t,L=_.l,W=19;W>4&&!q[f[W-1]];--W);var G,$,H,B,K=p+5<<3,X=N(r,z)+N(a,x)+c,J=N(r,g)+N(a,w)+c+14+3*W+N(Z,q)+2*Z[16]+3*Z[17]+7*Z[18];if(l>=0&&K<=X&&K<=J)return j(n,d,t.subarray(l,l+p));if(O(n,d,1+(J<X)),d+=2,J<X){G=b(g,m,0),$=g,H=b(w,S,0),B=w;var V=b(q,L,0);for(O(n,d,M-257),O(n,d+5,P-1),O(n,d+10,W-4),d+=14,E=0;E<W;++E)O(n,d+3*E,q[f[E]]);d+=3*W;for(var Y=[U,I],Q=0;Q<2;++Q){var tt=Y[Q];for(E=0;E<tt.length;++E){var nt=31&tt[E];O(n,d,V[nt]),d+=q[nt],nt>15&&(O(n,d,tt[E]>>5&127),d+=tt[E]>>12)}}}else G=A,$=z,H=k,B=x;for(E=0;E<h;++E){var et=i[E];if(et>255){F(n,d,G[257+(nt=et>>18&31)]),d+=$[nt+257],nt>7&&(O(n,d,et>>23&31),d+=o[nt]);var it=31&et;F(n,d,H[it]),d+=B[it],it>3&&(F(n,d,et>>5&8191),d+=u[it])}else F(n,d,G[et]),d+=$[et]}return F(n,d,G[256]),d+$[256]},W=new a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),G=new r(0),$=function(t,n,e,i,f,c){var h=c.z||t.length,l=new r(i+h+5*(1+Math.ceil(h/7e3))+f),d=l.subarray(i,l.length-f),v=c.l,m=7&(c.r||0);if(n){m&&(d[0]=c.r>>3);for(var y=W[n-1],w=y>>13,b=8191&y,z=(1<<e)-1,x=c.p||new s(32768),A=c.h||new s(z+1),S=Math.ceil(e/3),k=2*S,C=function(n){return(t[n]^t[n+1]<<S^t[n+2]<<k)&z},U=new a(25e3),M=new s(288),T=new s(32),Z=0,E=0,_=c.i||0,O=0,F=c.w||0,R=0;_+2<h;++_){var q=C(_),D=32767&_,N=A[q];if(x[D]=N,A[q]=D,F<=_){var G=h-_;if((Z>7e3||O>24576)&&(G>423||!v)){m=L(t,d,0,U,M,T,E,O,R,_-R,m),O=Z=E=0,R=_;for(var $=0;$<286;++$)M[$]=0;for($=0;$<30;++$)T[$]=0}var H=2,B=0,K=b,X=D-N&32767;if(G>2&&q==C(_-X))for(var J=Math.min(w,G)-1,V=Math.min(32767,_),Y=Math.min(258,G);X<=V&&--K&&D!=N;){if(t[_+H]==t[_+H-X]){for(var Q=0;Q<Y&&t[_+Q]==t[_+Q-X];++Q);if(Q>H){if(H=Q,B=X,Q>J)break;var tt=Math.min(X,Q-2),nt=0;for($=0;$<tt;++$){var et=_-X+$&32767,it=et-x[et]&32767;it>nt&&(nt=it,N=et)}}}X+=(D=N)-(N=x[D])&32767}if(B){U[O++]=268435456|p[H]<<18|g[B];var rt=31&p[H],st=31&g[B];E+=o[rt]+u[st],++M[257+rt],++T[st],F=_+H,++Z}else U[O++]=t[_],++M[t[_]]}}for(_=Math.max(_,F);_<h;++_)U[O++]=t[_],++M[t[_]];m=L(t,d,v,U,M,T,E,O,R,_-R,m),v||(c.r=7&m|d[m/8|0]<<3,m-=7,c.h=A,c.p=x,c.i=_,c.w=F)}else{for(_=c.w||0;_<h+v;_+=65535){var at=_+65535;at>=h&&(d[m/8|0]=v,at=h),m=j(d,m+1,t.subarray(_,at))}c.i=h}return P(l,0,i+I(m)+f)},H=function(){for(var t=new Int32Array(256),n=0;n<256;++n){for(var e=n,i=9;--i;)e=(1&e&&-306674912)^e>>>1;t[n]=e}return t}(),B=function(){var t=-1;return{p:function(n){for(var e=t,i=0;i<n.length;++i)e=H[255&e^n[i]]^e>>>8;t=e},d:function(){return~t}}},K=function(){var t=1,n=0;return{p:function(e){for(var i=t,r=n,s=0|e.length,a=0;a!=s;){for(var o=Math.min(a+2655,s);a<o;++a)r+=i+=e[a];i=(65535&i)+15*(i>>16),r=(65535&r)+15*(r>>16)}t=i,n=r},d:function(){return(255&(t%=65521))<<24|(65280&t)<<8|(255&(n%=65521))<<8|n>>8}}},X=function(t,n,e,i,s){if(!s&&(s={l:1},n.dictionary)){var a=n.dictionary.subarray(-32768),o=new r(a.length+t.length);o.set(a),o.set(t,a.length),t=o,s.w=a.length}return $(t,null==n.level?6:n.level,null==n.mem?s.l?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):20:12+n.mem,e,i,s)},J=function(t,n){var e={};for(var i in t)e[i]=t[i];for(var i in n)e[i]=n[i];return e},V=function(t,n,e){for(var i=t(),r=t.toString(),s=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/\s+/g,"").split(","),a=0;a<i.length;++a){var o=i[a],u=s[a];if("function"==typeof o){n+=";"+u+"=";var f=o.toString();if(o.prototype)if(-1!=f.indexOf("[native code]")){var c=f.indexOf(" ",8)+1;n+=f.slice(c,f.indexOf("(",c))}else for(var h in n+=f,o.prototype)n+=";"+u+".prototype."+h+"="+o.prototype[h].toString();else n+=f}else e[u]=o}return n},Y=[],Q=function(t,n,e,r){if(!Y[e]){for(var s="",a={},o=t.length-1,u=0;u<o;++u)s=V(t[u],s,a);Y[e]={c:V(t[o],s,a),e:a}}var f=J({},Y[e].e);return i(Y[e].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",e,f,function(t){var n=[];for(var e in t)t[e].buffer&&n.push((t[e]=new t[e].constructor(t[e])).buffer);return n}(f),r)},tt=function(){return[r,s,a,o,u,f,l,v,S,C,m,Z,b,U,M,T,I,P,E,_,Tt,at,ot]},nt=function(){return[r,s,a,o,u,f,p,g,A,z,k,x,m,W,G,b,O,F,R,q,D,N,j,L,I,P,$,X,kt,at]},et=function(){return[vt,yt,dt,B,H]},it=function(){return[gt,mt]},rt=function(){return[wt,dt,K]},st=function(){return[bt]},at=function(t){return postMessage(t,[t.buffer])},ot=function(t){return t&&{out:t.size&&new r(t.size),dictionary:t.dictionary}},ut=function(t,n,e,i,r,s){var a=Q(e,i,r,function(t,n){a.terminate(),s(t,n)});return a.postMessage([t,n],n.consume?[t.buffer]:[]),function(){a.terminate()}},ft=function(t){return t.ondata=function(t,n){return postMessage([t,n],[t.buffer])},function(n){n.data.length?(t.push(n.data[0],n.data[1]),postMessage([n.data[0].length])):t.flush()}},ct=function(t,n,e,i,r,s,a){var o,u=Q(t,i,r,function(t,e){t?(u.terminate(),n.ondata.call(n,t)):Array.isArray(e)?1==e.length?(n.queuedSize-=e[0],n.ondrain&&n.ondrain(e[0])):(e[1]&&u.terminate(),n.ondata.call(n,t,e[0],e[1])):a(e)});u.postMessage(e),n.queuedSize=0,n.push=function(t,e){n.ondata||E(5),o&&n.ondata(E(4,0,1),null,!!e),n.queuedSize+=t.length,u.postMessage([t,o=e],[t.buffer])},n.terminate=function(){u.terminate()},s&&(n.flush=function(){u.postMessage([])})},ht=function(t,n){return t[n]|t[n+1]<<8},lt=function(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16|t[n+3]<<24)>>>0},pt=function(t,n){return lt(t,n)+4294967296*lt(t,n+4)},dt=function(t,n,e){for(;e;++n)t[n]=e,e>>>=8},vt=function(t,n){var e=n.filename;if(t[0]=31,t[1]=139,t[2]=8,t[8]=n.level<2?4:9==n.level?2:0,t[9]=3,0!=n.mtime&&dt(t,4,Math.floor(new Date(n.mtime||Date.now())/1e3)),e){t[3]=8;for(var i=0;i<=e.length;++i)t[i+10]=e.charCodeAt(i)}},gt=function(t){31==t[0]&&139==t[1]&&8==t[2]||E(6,"invalid gzip data");var n=t[3],e=10;4&n&&(e+=2+(t[10]|t[11]<<8));for(var i=(n>>3&1)+(n>>4&1);i>0;i-=!t[e++]);return e+(2&n)},mt=function(t){var n=t.length;return(t[n-4]|t[n-3]<<8|t[n-2]<<16|t[n-1]<<24)>>>0},yt=function(t){return 10+(t.filename?t.filename.length+1:0)},wt=function(t,n){var e=n.level,i=0==e?0:e<6?1:9==e?3:2;if(t[0]=120,t[1]=i<<6|(n.dictionary&&32),t[1]|=31-(t[0]<<8|t[1])%31,n.dictionary){var r=K();r.p(n.dictionary),dt(t,2,r.d())}},bt=function(t,n){return(8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31)&&E(6,"invalid zlib data"),(t[1]>>5&1)==+!n&&E(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)};function zt(t,n){return"function"==typeof t&&(n=t,t={}),this.ondata=n,t}var xt=function(){function t(t,n){if("function"==typeof t&&(n=t,t={}),this.ondata=n,this.o=t||{},this.s={l:0,i:32768,w:32768,z:32768},this.b=new r(98304),this.o.dictionary){var e=this.o.dictionary.subarray(-32768);this.b.set(e,32768-e.length),this.s.i=32768-e.length}}return t.prototype.p=function(t,n){this.ondata(X(t,this.o,0,0,this.s),n)},t.prototype.push=function(t,n){this.ondata||E(5),this.s.l&&E(4);var e=t.length+this.s.z;if(e>this.b.length){if(e>2*this.b.length-32768){var i=new r(-32768&e);i.set(this.b.subarray(0,this.s.z)),this.b=i}var s=this.b.length-this.s.z;this.b.set(t.subarray(0,s),this.s.z),this.s.z=this.b.length,this.p(this.b,!1),this.b.set(this.b.subarray(-32768)),this.b.set(t.subarray(s),32768),this.s.z=t.length-s+32768,this.s.i=32766,this.s.w=32768}else this.b.set(t,this.s.z),this.s.z+=t.length;this.s.l=1&n,(this.s.z>this.s.w+8191||n)&&(this.p(this.b,n||!1),this.s.w=this.s.i,this.s.i-=2)},t.prototype.flush=function(){this.ondata||E(5),this.s.l&&E(4),this.p(this.b,!1),this.s.w=this.s.i,this.s.i-=2},t}();n.Deflate=xt;var At=function(){return function(t,n){ct([nt,function(){return[ft,xt]}],this,zt.call(this,t,n),function(t){var n=new xt(t.data);onmessage=ft(n)},6,1)}}();function St(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[nt],function(t){return at(kt(t.data[0],t.data[1]))},0,e)}function kt(t,n){return X(t,n||{},0,0)}n.AsyncDeflate=At,n.deflate=St,n.deflateSync=kt;var Ct=function(){function t(t,n){"function"==typeof t&&(n=t,t={}),this.ondata=n;var e=t&&t.dictionary&&t.dictionary.subarray(-32768);this.s={i:0,b:e?e.length:0},this.o=new r(32768),this.p=new r(0),e&&this.o.set(e)}return t.prototype.e=function(t){if(this.ondata||E(5),this.d&&E(4),this.p.length){if(t.length){var n=new r(this.p.length+t.length);n.set(this.p),n.set(t,this.p.length),this.p=n}}else this.p=t},t.prototype.c=function(t){this.s.i=+(this.d=t||!1);var n=this.s.b,e=_(this.p,this.s,this.o);this.ondata(P(e,n,this.s.b),this.d),this.o=P(e,this.s.b-32768),this.s.b=this.o.length,this.p=P(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,n){this.e(t),this.c(n)},t}();n.Inflate=Ct;var Ut=function(){return function(t,n){ct([tt,function(){return[ft,Ct]}],this,zt.call(this,t,n),function(t){var n=new Ct(t.data);onmessage=ft(n)},7,0)}}();function Mt(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[tt],function(t){return at(Tt(t.data[0],ot(t.data[1])))},1,e)}function Tt(t,n){return _(t,{i:2},n&&n.out,n&&n.dictionary)}n.AsyncInflate=Ut,n.inflate=Mt,n.inflateSync=Tt;var It=function(){function t(t,n){this.c=B(),this.l=0,this.v=1,xt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),this.l+=t.length,xt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=X(t,this.o,this.v&&yt(this.o),n&&8,this.s);this.v&&(vt(e,this.o),this.v=0),n&&(dt(e,e.length-8,this.c.d()),dt(e,e.length-4,this.l)),this.ondata(e,n)},t.prototype.flush=function(){xt.prototype.flush.call(this)},t}();n.Gzip=It,n.Compress=It;var Pt=function(){return function(t,n){ct([nt,et,function(){return[ft,xt,It]}],this,zt.call(this,t,n),function(t){var n=new It(t.data);onmessage=ft(n)},8,1)}}();function Zt(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[nt,et,function(){return[Et]}],function(t){return at(Et(t.data[0],t.data[1]))},2,e)}function Et(t,n){n||(n={});var e=B(),i=t.length;e.p(t);var r=X(t,n,yt(n),8),s=r.length;return vt(r,n),dt(r,s-8,e.d()),dt(r,s-4,i),r}n.AsyncGzip=Pt,n.AsyncCompress=Pt,n.gzip=Zt,n.compress=Zt,n.gzipSync=Et,n.compressSync=Et;var _t=function(){function t(t,n){this.v=1,this.r=0,Ct.call(this,t,n)}return t.prototype.push=function(t,n){if(Ct.prototype.e.call(this,t),this.r+=t.length,this.v){var e=this.p.subarray(this.v-1),i=e.length>3?gt(e):4;if(i>e.length){if(!n)return}else this.v>1&&this.onmember&&this.onmember(this.r-e.length);this.p=e.subarray(i),this.v=0}Ct.prototype.c.call(this,n),!this.s.f||this.s.l||n||(this.v=I(this.s.p)+9,this.s={i:0},this.o=new r(0),this.push(new r(0),n))},t}();n.Gunzip=_t;var Ot=function(){return function(t,n){var e=this;ct([tt,it,function(){return[ft,Ct,_t]}],this,zt.call(this,t,n),function(t){var n=new _t(t.data);n.onmember=function(t){return postMessage(t)},onmessage=ft(n)},9,0,function(t){return e.onmember&&e.onmember(t)})}}();function Ft(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[tt,it,function(){return[Rt]}],function(t){return at(Rt(t.data[0],t.data[1]))},3,e)}function Rt(t,n){var e=gt(t);return e+8>t.length&&E(6,"invalid gzip data"),_(t.subarray(e,-8),{i:2},n&&n.out||new r(mt(t)),n&&n.dictionary)}n.AsyncGunzip=Ot,n.gunzip=Ft,n.gunzipSync=Rt;var qt=function(){function t(t,n){this.c=K(),this.v=1,xt.call(this,t,n)}return t.prototype.push=function(t,n){this.c.p(t),xt.prototype.push.call(this,t,n)},t.prototype.p=function(t,n){var e=X(t,this.o,this.v&&(this.o.dictionary?6:2),n&&4,this.s);this.v&&(wt(e,this.o),this.v=0),n&&dt(e,e.length-4,this.c.d()),this.ondata(e,n)},t.prototype.flush=function(){xt.prototype.flush.call(this)},t}();n.Zlib=qt;var Dt=function(){return function(t,n){ct([nt,rt,function(){return[ft,xt,qt]}],this,zt.call(this,t,n),function(t){var n=new qt(t.data);onmessage=ft(n)},10,1)}}();function Nt(t,n){n||(n={});var e=K();e.p(t);var i=X(t,n,n.dictionary?6:2,4);return wt(i,n),dt(i,i.length-4,e.d()),i}n.AsyncZlib=Dt,n.zlib=function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[nt,rt,function(){return[Nt]}],function(t){return at(Nt(t.data[0],t.data[1]))},4,e)},n.zlibSync=Nt;var jt=function(){function t(t,n){Ct.call(this,t,n),this.v=t&&t.dictionary?2:1}return t.prototype.push=function(t,n){if(Ct.prototype.e.call(this,t),this.v){if(this.p.length<6&&!n)return;this.p=this.p.subarray(bt(this.p,this.v-1)),this.v=0}n&&(this.p.length<4&&E(6,"invalid zlib data"),this.p=this.p.subarray(0,-4)),Ct.prototype.c.call(this,n)},t}();n.Unzlib=jt;var Lt=function(){return function(t,n){ct([tt,st,function(){return[ft,Ct,jt]}],this,zt.call(this,t,n),function(t){var n=new jt(t.data);onmessage=ft(n)},11,0)}}();function Wt(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),ut(t,n,[tt,st,function(){return[Gt]}],function(t){return at(Gt(t.data[0],ot(t.data[1])))},5,e)}function Gt(t,n){return _(t.subarray(bt(t,n&&n.dictionary),-4),{i:2},n&&n.out,n&&n.dictionary)}n.AsyncUnzlib=Lt,n.unzlib=Wt,n.unzlibSync=Gt;var $t=function(){function t(t,n){this.o=zt.call(this,t,n)||{},this.G=_t,this.I=Ct,this.Z=jt}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e){t.ondata(n,e)}},t.prototype.push=function(t,n){if(this.ondata||E(5),this.s)this.s.push(t,n);else{if(this.p&&this.p.length){var e=new r(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length)}else this.p=t;this.p.length>2&&(this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(this.o):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(this.o):new this.Z(this.o),this.i(),this.s.push(this.p,n),this.p=null)}},t}();n.Decompress=$t;var Ht=function(){function t(t,n){$t.call(this,t,n),this.queuedSize=0,this.G=Ot,this.I=Ut,this.Z=Lt}return t.prototype.i=function(){var t=this;this.s.ondata=function(n,e,i){t.ondata(n,e,i)},this.s.ondrain=function(n){t.queuedSize-=n,t.ondrain&&t.ondrain(n)}},t.prototype.push=function(t,n){this.queuedSize+=t.length,$t.prototype.push.call(this,t,n)},t}();n.AsyncDecompress=Ht,n.decompress=function(t,n,e){return e||(e=n,n={}),"function"!=typeof e&&E(7),31==t[0]&&139==t[1]&&8==t[2]?Ft(t,n,e):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Mt(t,n,e):Wt(t,n,e)},n.decompressSync=function(t,n){return 31==t[0]&&139==t[1]&&8==t[2]?Rt(t,n):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Tt(t,n):Gt(t,n)};var Bt=function(t,n,e,i){for(var s in t){var a=t[s],o=n+s,u=i;Array.isArray(a)&&(u=J(i,a[1]),a=a[0]),a instanceof r?e[o]=[a,u]:(e[o+="/"]=[new r(0),u],Bt(a,o,e,i))}},Kt="undefined"!=typeof TextEncoder&&new TextEncoder,Xt="undefined"!=typeof TextDecoder&&new TextDecoder,Jt=0;try{Xt.decode(G,{stream:!0}),Jt=1}catch(t){}var Vt=function(t){for(var n="",e=0;;){var i=t[e++],r=(i>127)+(i>223)+(i>239);if(e+r>t.length)return{s:n,r:P(t,e-1)};r?3==r?(i=((15&i)<<18|(63&t[e++])<<12|(63&t[e++])<<6|63&t[e++])-65536,n+=String.fromCharCode(55296|i>>10,56320|1023&i)):n+=1&r?String.fromCharCode((31&i)<<6|63&t[e++]):String.fromCharCode((15&i)<<12|(63&t[e++])<<6|63&t[e++]):n+=String.fromCharCode(i)}},Yt=function(){function t(t){this.ondata=t,Jt?this.t=new TextDecoder:this.p=G}return t.prototype.push=function(t,n){if(this.ondata||E(5),n=!!n,this.t)return this.ondata(this.t.decode(t,{stream:!0}),n),void(n&&(this.t.decode().length&&E(8),this.t=null));this.p||E(4);var e=new r(this.p.length+t.length);e.set(this.p),e.set(t,this.p.length);var i=Vt(e),s=i.s,a=i.r;n?(a.length&&E(8),this.p=null):this.p=a,this.ondata(s,n)},t}();n.DecodeUTF8=Yt;var Qt=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,n){this.ondata||E(5),this.d&&E(4),this.ondata(tn(t),this.d=n||!1)},t}();function tn(t,n){if(n){for(var e=new r(t.length),i=0;i<t.length;++i)e[i]=t.charCodeAt(i);return e}if(Kt)return Kt.encode(t);var s=t.length,a=new r(t.length+(t.length>>1)),o=0,u=function(t){a[o++]=t};for(i=0;i<s;++i){if(o+5>a.length){var f=new r(o+8+(s-i<<1));f.set(a),a=f}var c=t.charCodeAt(i);c<128||n?u(c):c<2048?(u(192|c>>6),u(128|63&c)):c>55295&&c<57344?(u(240|(c=65536+(1047552&c)|1023&t.charCodeAt(++i))>>18),u(128|c>>12&63),u(128|c>>6&63),u(128|63&c)):(u(224|c>>12),u(128|c>>6&63),u(128|63&c))}return P(a,0,o)}function nn(t,n){if(n){for(var e="",i=0;i<t.length;i+=16384)e+=String.fromCharCode.apply(null,t.subarray(i,i+16384));return e}if(Xt)return Xt.decode(t);var r=Vt(t),s=r.s;return(e=r.r).length&&E(8),s}n.EncodeUTF8=Qt,n.strToU8=tn,n.strFromU8=nn;var en=function(t){return 1==t?3:t<6?2:9==t?1:0},rn=function(t,n){return n+30+ht(t,n+26)+ht(t,n+28)},sn=function(t,n,e){var i=ht(t,n+28),r=nn(t.subarray(n+46,n+46+i),!(2048&ht(t,n+8))),s=n+46+i,a=lt(t,n+20),o=e&&4294967295==a?an(t,s):[a,lt(t,n+24),lt(t,n+42)],u=o[0],f=o[1],c=o[2];return[ht(t,n+10),u,f,r,s+ht(t,n+30)+ht(t,n+32),c]},an=function(t,n){for(;1!=ht(t,n);n+=4+ht(t,n+2));return[pt(t,n+12),pt(t,n+4),pt(t,n+20)]},on=function(t){var n=0;if(t)for(var e in t){var i=t[e].length;i>65535&&E(9),n+=i+4}return n},un=function(t,n,e,i,r,s,a,o){var u=i.length,f=e.extra,c=o&&o.length,h=on(f);dt(t,n,null!=a?33639248:67324752),n+=4,null!=a&&(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag<<1|(s<0&&8),t[n++]=r&&8,t[n++]=255&e.compression,t[n++]=e.compression>>8;var l=new Date(null==e.mtime?Date.now():e.mtime),p=l.getFullYear()-1980;if((p<0||p>119)&&E(10),dt(t,n,p<<25|l.getMonth()+1<<21|l.getDate()<<16|l.getHours()<<11|l.getMinutes()<<5|l.getSeconds()>>1),n+=4,-1!=s&&(dt(t,n,e.crc),dt(t,n+4,s<0?-s-2:s),dt(t,n+8,e.size)),dt(t,n+12,u),dt(t,n+14,h),n+=16,null!=a&&(dt(t,n,c),dt(t,n+6,e.attrs),dt(t,n+10,a),n+=14),t.set(i,n),n+=u,h)for(var d in f){var v=f[d],g=v.length;dt(t,n,+d),dt(t,n+2,g),t.set(v,n+4),n+=4+g}return c&&(t.set(o,n),n+=c),n},fn=function(t,n,e,i,r){dt(t,n,101010256),dt(t,n+8,e),dt(t,n+10,e),dt(t,n+12,i),dt(t,n+16,r)},cn=function(){function t(t){this.filename=t,this.c=B(),this.size=0,this.compression=0}return t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||E(5),this.c.p(t),this.size+=t.length,n&&(this.crc=this.c.d()),this.process(t,n||!1)},t}();n.ZipPassThrough=cn;var hn=function(){function t(t,n){var e=this;n||(n={}),cn.call(this,t),this.d=new xt(n,function(t,n){e.ondata(null,t,n)}),this.compression=8,this.flag=en(n.level)}return t.prototype.process=function(t,n){try{this.d.push(t,n)}catch(t){this.ondata(t,null,n)}},t.prototype.push=function(t,n){cn.prototype.push.call(this,t,n)},t}();n.ZipDeflate=hn;var ln=function(){function t(t,n){var e=this;n||(n={}),cn.call(this,t),this.d=new At(n,function(t,n,i){e.ondata(t,n,i)}),this.compression=8,this.flag=en(n.level),this.terminate=this.d.terminate}return t.prototype.process=function(t,n){this.d.push(t,n)},t.prototype.push=function(t,n){cn.prototype.push.call(this,t,n)},t}();n.AsyncZipDeflate=ln;var pn=function(){function t(t){this.ondata=t,this.u=[],this.d=1}return t.prototype.add=function(t){var n=this;if(this.ondata||E(5),2&this.d)this.ondata(E(4+8*(1&this.d),0,1),null,!1);else{var e=tn(t.filename),i=e.length,s=t.comment,a=s&&tn(s),o=i!=t.filename.length||a&&s.length!=a.length,u=i+on(t.extra)+30;i>65535&&this.ondata(E(11,0,1),null,!1);var f=new r(u);un(f,0,t,e,o,-1);var c=[f],h=function(){for(var t=0,e=c;t<e.length;t++){var i=e[t];n.ondata(null,i,!1)}c=[]},l=this.d;this.d=0;var p=this.u.length,d=J(t,{f:e,u:o,o:a,t:function(){t.terminate&&t.terminate()},r:function(){if(h(),l){var t=n.u[p+1];t?t.r():n.d=1}l=1}}),v=0;t.ondata=function(e,i,s){if(e)n.ondata(e,i,s),n.terminate();else if(v+=i.length,c.push(i),s){var a=new r(16);dt(a,0,134695760),dt(a,4,t.crc),dt(a,8,v),dt(a,12,t.size),c.push(a),d.c=v,d.b=u+v+16,d.crc=t.crc,d.size=t.size,l&&d.r(),l=1}else l&&h()},this.u.push(d)}},t.prototype.end=function(){var t=this;2&this.d?this.ondata(E(4+8*(1&this.d),0,1),null,!0):(this.d?this.e():this.u.push({r:function(){1&t.d&&(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var t=0,n=0,e=0,i=0,s=this.u;i<s.length;i++)e+=46+(f=s[i]).f.length+on(f.extra)+(f.o?f.o.length:0);for(var a=new r(e+22),o=0,u=this.u;o<u.length;o++){var f=u[o];un(a,t,f,f.f,f.u,-f.c-2,n,f.o),t+=46+f.f.length+on(f.extra)+(f.o?f.o.length:0),n+=f.b}fn(a,t,this.u.length,e,n),this.ondata(null,a,!0),this.d=2},t.prototype.terminate=function(){for(var t=0,n=this.u;t<n.length;t++)n[t].t();this.d=2},t}();n.Zip=pn,n.zip=function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&E(7);var i={};Bt(t,"",i,n);var s=Object.keys(i),a=s.length,o=0,u=0,f=a,c=new Array(a),h=[],l=function(){for(var t=0;t<h.length;++t)h[t]()},p=function(t,n){yn(function(){e(t,n)})};yn(function(){p=e});var d=function(){var t=new r(u+22),n=o,e=u-o;u=0;for(var i=0;i<f;++i){var s=c[i];try{var a=s.c.length;un(t,u,s,s.f,s.u,a);var h=30+s.f.length+on(s.extra),l=u+h;t.set(s.c,l),un(t,o,s,s.f,s.u,a,u,s.m),o+=16+h+(s.m?s.m.length:0),u=l+a}catch(t){return p(t,null)}}fn(t,o,c.length,e,n),p(null,t)};a||d();for(var v=function(t){var n=s[t],e=i[n],r=e[0],f=e[1],v=B(),g=r.length;v.p(r);var m=tn(n),y=m.length,w=f.comment,b=w&&tn(w),z=b&&b.length,x=on(f.extra),A=0==f.level?0:8,S=function(e,i){if(e)l(),p(e,null);else{var r=i.length;c[t]=J(f,{size:g,crc:v.d(),c:i,f:m,m:b,u:y!=n.length||b&&w.length!=z,compression:A}),o+=30+y+x+r,u+=76+2*(y+x)+(z||0)+r,--a||d()}};if(y>65535&&S(E(11,0,1),null),A)if(g<16e4)try{S(null,kt(r,f))}catch(t){S(t,null)}else h.push(St(r,f,S));else S(null,r)},g=0;g<f;++g)v(g);return l},n.zipSync=function(t,n){n||(n={});var e={},i=[];Bt(t,"",e,n);var s=0,a=0;for(var o in e){var u=e[o],f=u[0],c=u[1],h=0==c.level?0:8,l=(S=tn(o)).length,p=c.comment,d=p&&tn(p),v=d&&d.length,g=on(c.extra);l>65535&&E(11);var m=h?kt(f,c):f,y=m.length,w=B();w.p(f),i.push(J(c,{size:f.length,crc:w.d(),c:m,f:S,m:d,u:l!=o.length||d&&p.length!=v,o:s,compression:h})),s+=30+l+g+y,a+=76+2*(l+g)+(v||0)+y}for(var b=new r(a+22),z=s,x=a-s,A=0;A<i.length;++A){var S=i[A];un(b,S.o,S,S.f,S.u,S.c.length);var k=30+S.f.length+on(S.extra);b.set(S.c,S.o+k),un(b,s,S,S.f,S.u,S.c.length,S.o,S.m),s+=16+k+(S.m?S.m.length:0)}return fn(b,s,i.length,x,z),b};var dn=function(){function t(){}return t.prototype.push=function(t,n){this.ondata(null,t,n)},t.compression=0,t}();n.UnzipPassThrough=dn;var vn=function(){function t(){var t=this;this.i=new Ct(function(n,e){t.ondata(null,n,e)})}return t.prototype.push=function(t,n){try{this.i.push(t,n)}catch(t){this.ondata(t,null,n)}},t.compression=8,t}();n.UnzipInflate=vn;var gn=function(){function t(t,n){var e=this;n<32e4?this.i=new Ct(function(t,n){e.ondata(null,t,n)}):(this.i=new Ut(function(t,n,i){e.ondata(t,n,i)}),this.terminate=this.i.terminate)}return t.prototype.push=function(t,n){this.i.terminate&&(t=P(t,0)),this.i.push(t,n)},t.compression=8,t}();n.AsyncUnzipInflate=gn;var mn=function(){function t(t){this.onfile=t,this.k=[],this.o={0:dn},this.p=G}return t.prototype.push=function(t,n){var e=this;if(this.onfile||E(5),this.p||E(4),this.c>0){var i=Math.min(this.c,t.length),s=t.subarray(0,i);if(this.c-=i,this.d?this.d.push(s,!this.c):this.k[0].push(s),(t=t.subarray(i)).length)return this.push(t,n)}else{var a=0,o=0,u=void 0,f=void 0;this.p.length?t.length?((f=new r(this.p.length+t.length)).set(this.p),f.set(t,this.p.length)):f=this.p:f=t;for(var c=f.length,h=this.c,l=h&&this.d,p=function(){var t,n=lt(f,o);if(67324752==n){a=1,u=o,d.d=null,d.c=0;var i=ht(f,o+6),r=ht(f,o+8),s=2048&i,l=8&i,p=ht(f,o+26),v=ht(f,o+28);if(c>o+30+p+v){var g=[];d.k.unshift(g),a=2;var m,y=lt(f,o+18),w=lt(f,o+22),b=nn(f.subarray(o+30,o+=30+p),!s);4294967295==y?(t=l?[-2]:an(f,o),y=t[0],w=t[1]):l&&(y=-1),o+=v,d.c=y;var z={name:b,compression:r,start:function(){if(z.ondata||E(5),y){var t=e.o[r];t||z.ondata(E(14,"unknown compression type "+r,1),null,!1),(m=y<0?new t(b):new t(b,y,w)).ondata=function(t,n,e){z.ondata(t,n,e)};for(var n=0,i=g;n<i.length;n++){var s=i[n];m.push(s,!1)}e.k[0]==g&&e.c?e.d=m:m.push(G,!0)}else z.ondata(null,G,!0)},terminate:function(){m&&m.terminate&&m.terminate()}};y>=0&&(z.size=y,z.originalSize=w),d.onfile(z)}return"break"}if(h){if(134695760==n)return u=o+=12+(-2==h&&8),a=3,d.c=0,"break";if(33639248==n)return u=o-=4,a=3,d.c=0,"break"}},d=this;o<c-4&&"break"!==p();++o);if(this.p=G,h<0){var v=a?f.subarray(0,u-12-(-2==h&&8)-(134695760==lt(f,u-16)&&4)):f.subarray(0,o);l?l.push(v,!!a):this.k[+(2==a)].push(v)}if(2&a)return this.push(f.subarray(o),n);this.p=f.subarray(o)}n&&(this.c&&E(13),this.p=null)},t.prototype.register=function(t){this.o[t.compression]=t},t}();n.Unzip=mn;var yn="function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout?setTimeout:function(t){t()};n.unzip=function(t,n,e){e||(e=n,n={}),"function"!=typeof e&&E(7);var i=[],s=function(){for(var t=0;t<i.length;++t)i[t]()},a={},o=function(t,n){yn(function(){e(t,n)})};yn(function(){o=e});for(var u=t.length-22;101010256!=lt(t,u);--u)if(!u||t.length-u>65558)return o(E(13,0,1),null),s;var f=ht(t,u+8);if(f){var c=f,h=lt(t,u+16),l=4294967295==h||65535==c;if(l){var p=lt(t,u-12);(l=101075792==lt(t,p))&&(c=f=lt(t,p+32),h=lt(t,p+48))}for(var d=n&&n.filter,v=function(n){var e=sn(t,h,l),u=e[0],c=e[1],p=e[2],v=e[3],g=e[4],m=e[5],y=rn(t,m);h=g;var w=function(t,n){t?(s(),o(t,null)):(n&&(a[v]=n),--f||o(null,a))};if(!d||d({name:v,size:c,originalSize:p,compression:u}))if(u)if(8==u){var b=t.subarray(y,y+c);if(p<524288||c>.8*p)try{w(null,Tt(b,{out:new r(p)}))}catch(t){w(t,null)}else i.push(Mt(b,{size:p},w))}else w(E(14,"unknown compression type "+u,1),null);else w(null,P(t,y,y+c));else w(null,null)},g=0;g<c;++g)v()}else o(null,{});return s},n.unzipSync=function(t,n){for(var e={},i=t.length-22;101010256!=lt(t,i);--i)(!i||t.length-i>65558)&&E(13);var s=ht(t,i+8);if(!s)return{};var a=lt(t,i+16),o=4294967295==a||65535==s;if(o){var u=lt(t,i-12);(o=101075792==lt(t,u))&&(s=lt(t,u+32),a=lt(t,u+48))}for(var f=n&&n.filter,c=0;c<s;++c){var h=sn(t,a,o),l=h[0],p=h[1],d=h[2],v=h[3],g=h[4],m=h[5],y=rn(t,m);a=g,f&&!f({name:v,size:p,originalSize:d,compression:l})||(l?8==l?e[v]=Tt(t.subarray(y,y+p),{out:new r(d)}):E(14,"unknown compression type "+l):e[v]=P(t,y,y+p))}return e}}},n={};function e(i){var r=n[i];if(void 0!==r)return r.exports;var s=n[i]={exports:{}};return t[i](s,s.exports,e),s.exports}(()=>{const t=e(845),n=e(183),i=n.normalizeZipEntryPath;self.addEventListener("install",()=>{self.skipWaiting()}),self.addEventListener("activate",t=>{t.waitUntil(self.clients.claim())});const r=new Map,s="X-ZipSW-Cached-At",a="X-ZipSW-Asset-Source";let o={zipAssetCacheName:"zip-cache-v1",assetCacheTtlMs:72e5,logPrefix:"[zipSW]"};function u(...t){console.log(o.logPrefix,...t)}function f(...t){console.warn(o.logPrefix,...t)}function c(t){return t+(t.includes("?")?"&":"?")+"__zipsw_manifest__=1"}const h=new Map;function l(t,n){return new Response(t,{status:n,headers:{"Access-Control-Allow-Origin":"*"}})}self.addEventListener("message",t=>{if(!t.data)return;const{type:e,zipUrl:s,files:a,config:h}=t.data;if("ZIP_SW_CONFIG"!==e)if("ZIP_MANIFEST"===e){if(s&&a){const e=(0,n.stripTParam)(s),h=new Map;let l=!1;for(const t of a){const n=i(t.filename);""!==n?(h.has(n)&&f("duplicate manifest key after normalize; overwriting",n),h.set(n,t)):l=!0}const p=r.get(e);if(0===h.size)return void f("rejecting empty manifest; keeping existing",{zipUrl:e,existingSize:p?p.size:0,hadEmptyKey:l});if(p&&p.size>h.size)return void f("rejecting smaller manifest; keeping existing",{zipUrl:e,incomingSize:h.size,existingSize:p.size});r.set(e,h),t.waitUntil(async function(t,n){try{const e=await caches.open(o.zipAssetCacheName),i=Array.from(n.values());await e.put(new Request(c(t)),new Response(JSON.stringify(i),{headers:{"Content-Type":"application/json"}}))}catch(t){f("failed to persist manifest",t)}}(e,h));const d=Array.from(h.keys());u("manifest all paths",d);const v=d.slice(0,40);u("ZIP_MANIFEST loaded",{zipUrl:e,entryCount:h.size,sampleKeys:v,replacedExistingSize:p?p.size:0})}}else"PURGE_OTHER_ZIP_ASSETS"===e&&s&&t.waitUntil(async function(t){try{const e=(0,n.stripTParam)(t),i=await caches.open(o.zipAssetCacheName),s=await i.keys();for(const t of s){const r=t.url;if(r.includes("__zipsw_manifest__=1")){const s=m(r);s&&(0,n.stripTParam)(s)!==e&&await i.delete(t);continue}const s=(0,n.parseZipAssetRequest)(r);s&&(0,n.stripTParam)(s.zipUrl)!==e&&await i.delete(t)}for(const t of r.keys())t!==e&&r.delete(t)}catch(t){f("purgeOtherZipAssets failed",t)}}(s));else!function(t){t&&("string"==typeof t.zipAssetCacheName&&t.zipAssetCacheName.trim()&&(o={...o,zipAssetCacheName:t.zipAssetCacheName}),"number"==typeof t.assetCacheTtlMs&&Number.isFinite(t.assetCacheTtlMs)&&(o={...o,assetCacheTtlMs:t.assetCacheTtlMs}),"string"==typeof t.logPrefix&&t.logPrefix.trim()&&(o={...o,logPrefix:t.logPrefix}))}(h)});const p={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",json:"application/json",js:"application/javascript",css:"text/css; charset=utf-8",html:"text/html; charset=utf-8",txt:"text/plain; charset=utf-8",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",wav:"audio/wav",oga:"audio/ogg",ogg:"audio/ogg",xml:"application/xml",wasm:"application/wasm"};function d(t){const n=t.headers.get(s);if(!n)return!0;const e=parseInt(n,10);return!Number.isFinite(e)||Date.now()-e>o.assetCacheTtlMs}const v="&__zipsw_manifest__=1",g="?__zipsw_manifest__=1";function m(t){return t.endsWith(v)?t.slice(0,-v.length):t.endsWith(g)?t.slice(0,-g.length):null}self.addEventListener("fetch",e=>{if("GET"!==e.request.method)return;const v=(0,n.parseZipAssetRequest)(e.request.url);if(!v)return;const g=(0,n.stripTParam)(v.zipUrl),m=v.internalPath,y=i(m);e.respondWith((async()=>{let v=r.get(g);if(v||(v=await function(t){const n=r.get(t);if(n)return Promise.resolve(n);let e=h.get(t);return e||(e=(async()=>{const n=await async function(t){try{const n=await caches.open(o.zipAssetCacheName),e=await n.match(c(t));if(!e)return null;const r=await e.json();if(!Array.isArray(r)||0===r.length)return null;const s=new Map;for(const t of r){const n=i(t.filename);""!==n&&s.set(n,t)}return s.size>0?s:null}catch(t){return f("failed to load persisted manifest",t),null}}(t);return n&&(r.set(t,n),u("rehydrated manifest from cache",{zipUrl:t,entryCount:n.size})),n})().finally(()=>{h.delete(t)}),h.set(t,e),e)}(g)??void 0),!v){const t=Array.from(r.keys());return f("manifest missing for zipUrl",{requestedZipUrl:g,knownZipUrls:t}),l("Zip manifest not loaded",404)}const w=function(t,n){if(t.has(n))return{key:n,info:t.get(n)};const e=[];for(const i of t.keys())i.endsWith("/"+n)&&e.push(i);if(1===e.length){const n=e[0];return{key:n,info:t.get(n)}}if(e.length>1){e.sort((t,n)=>t.length-n.length),f("ambiguous suffix match; using shortest path",{requested:n,picked:e[0],candidates:e.slice(0,8)});const i=e[0];return{key:i,info:t.get(i)}}return null}(v,y);if(!w){const t=Array.from(v.keys()).slice(0,50);return f("file not in manifest",{zipUrl:g,internalPathRaw:m,internalPathNormalized:y,manifestSize:v.size,sampleKeys:t}),l("File not found in zip manifest",404)}const{key:b,info:z}=w;b!==y&&u("resolved via suffix match",{requested:y,manifestKey:b});const x=function(t,e){return new Request((0,n.canonicalZipAssetRequestUrl)(t,e),{method:"GET"})}(g,b);let A=null,S="network";try{const t=await caches.open(o.zipAssetCacheName),n=await t.match(x);if(n)if(d(n))try{await t.delete(x)}catch(t){f("asset cache delete expired failed",t)}else A=await n.blob(),S="cache-api"}catch(t){f("asset cache read failed",t)}if(!A){const n=z.offset,e=z.nextOffset-1;f("fetching zip chunk from",g);const i=await fetch(g,{headers:{Range:`bytes=${n}-${e}`}});if(!i.ok&&206!==i.status)return l("Failed to fetch zip chunk",i.status);const r=await i.arrayBuffer(),a=new DataView(r);if(67324752!==a.getUint32(0,!0))return l("Invalid Local File Header",500);const u=a.getUint16(26,!0),c=a.getUint16(28,!0),h=new Uint8Array(r,30+u+c,z.compressedSize);let v;if(8===z.compression)v=(0,t.inflateSync)(h);else{if(0!==z.compression)return l(`Unsupported compression method: ${z.compression}`,500);v=h}const m=function(t){const n=t.split(".").pop()?.toLowerCase();return n?p[n]??"application/octet-stream":"application/octet-stream"}(b);A=new Blob([v],{type:m}),S="network",await async function(t,n){try{const e=await caches.open(o.zipAssetCacheName),i=await e.match(t);if(i&&!d(i))return;const r=n.type||"application/octet-stream";await e.put(t,new Response(n,{status:200,headers:{"Content-Type":r,"Content-Length":String(n.size),"Access-Control-Allow-Origin":"*",[s]:String(Date.now())}}))}catch(t){f("asset cache put failed",t)}}(x,A)}if(e.request.headers.has("range")){const t=e.request.headers.get("range").replace(/bytes=/,"").split("-"),n=parseInt(t[0],10),i=t[1]?parseInt(t[1],10):A.size-1,r=A.slice(n,i+1);return new Response(r,{status:206,headers:{"Content-Type":A.type,"Content-Range":`bytes ${n}-${i}/${A.size}`,"Content-Length":r.size.toString(),"Accept-Ranges":"bytes","Access-Control-Allow-Origin":"*","Access-Control-Expose-Headers":a,[a]:S}})}return new Response(A,{status:200,headers:{"Content-Type":A.type,"Content-Length":A.size.toString(),"Access-Control-Allow-Origin":"*","Access-Control-Expose-Headers":a,[a]:S}})})())})})()})();
2
+ //# sourceMappingURL=zipServiceWorker.js.map