@beeintel/batch-image 0.0.0-stage → 1.0.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.
- package/FONT-LICENSE.txt +93 -0
- package/README.md +181 -2
- package/dist/assets/11st-D7qGO5e4.webp +0 -0
- package/dist/assets/UPNG-CPfdwFSy.js +2298 -0
- package/dist/assets/adjust-card-B63b81iV.webp +0 -0
- package/dist/assets/adjust-final.worker-C2JbTvv5.js +6945 -0
- package/dist/assets/amazon-CjTtpZTq.webp +0 -0
- package/dist/assets/ascii_art-B4UGbtGs.webp +0 -0
- package/dist/assets/auction-j26eVUQO.webp +0 -0
- package/dist/assets/background-DGdZUdkL.webp +0 -0
- package/dist/assets/background-card-wK7DRpvM.png +0 -0
- package/dist/assets/body-CUFdRg8w.webp +0 -0
- package/dist/assets/bounded-cutout.worker-BZR6mbaI.js +9615 -0
- package/dist/assets/brand-mark-card-cFUeDeO2.webp +0 -0
- package/dist/assets/buyma-dAxYNjow.webp +0 -0
- package/dist/assets/codec.worker-7W6hmsm6.js +7349 -0
- package/dist/assets/contour_lines-C_CqrgV1.webp +0 -0
- package/dist/assets/creema-B1tWyCPx.webp +0 -0
- package/dist/assets/crop-final.worker-Owin7TvX.js +7035 -0
- package/dist/assets/cutout-CzMvV5An.webp +0 -0
- package/dist/assets/cutout-card-CN4gNFBz.png +0 -0
- package/dist/assets/cutout.worker-DyH6Prbn.js +3894 -0
- package/dist/assets/depop-CkVC5Fn1.webp +0 -0
- package/dist/assets/dewrinkle-kFzP6LqD.webp +0 -0
- package/dist/assets/dither-CcxmO2e6.webp +0 -0
- package/dist/assets/douyin-CP_HwBDF.webp +0 -0
- package/dist/assets/download.worker-DnGSB6P_.js +17779 -0
- package/dist/assets/duotone-Cdg_3fQf.webp +0 -0
- package/dist/assets/ebay-CxLfrRAf.webp +0 -0
- package/dist/assets/edit-Cv-txfZm.webp +0 -0
- package/dist/assets/effect.worker-qu1eCcII.js +9227 -0
- package/dist/assets/engraving-BENh1O2O.webp +0 -0
- package/dist/assets/etsy-CSvz9GpY.webp +0 -0
- package/dist/assets/expand-C60VE9nK.webp +0 -0
- package/dist/assets/facebook-Ca2nJJiQ.webp +0 -0
- package/dist/assets/film_stock-Bqauwcq4.webp +0 -0
- package/dist/assets/final.worker-BnzJ3N5C.js +7035 -0
- package/dist/assets/final.worker-Csc1zoYS.js +7054 -0
- package/dist/assets/final.worker-DzBFT9xk.js +6922 -0
- package/dist/assets/final.worker-XpgKnlaz.js +7217 -0
- package/dist/assets/flatlay-CPiVmlAa.webp +0 -0
- package/dist/assets/flatlay-fold-B-CRYy87.webp +0 -0
- package/dist/assets/flatlay-open-Dzas8okC.webp +0 -0
- package/dist/assets/g-market-DXuYK_JH.webp +0 -0
- package/dist/assets/ghost-BCEAx_Zx.webp +0 -0
- package/dist/assets/ghost-front-WFgA4sUo.webp +0 -0
- package/dist/assets/ghost-three-quarter-Rt8cXj34.webp +0 -0
- package/dist/assets/gif-CObOIITx.js +303 -0
- package/dist/assets/glass_tiles-3IXP-Hmg.webp +0 -0
- package/dist/assets/glitch_art-D1i3qben.webp +0 -0
- package/dist/assets/glitch_blur-C4q_9zyq.webp +0 -0
- package/dist/assets/glow-Bv9EHBU5.webp +0 -0
- package/dist/assets/gradient_map-BR-UVYMP.webp +0 -0
- package/dist/assets/halftone-CWdKu2_6.webp +0 -0
- package/dist/assets/holo_sticker-BQDikLg2.webp +0 -0
- package/dist/assets/idus-7diqRNPs.webp +0 -0
- package/dist/assets/imagetracer.worker-CgunQTPG.js +7096 -0
- package/dist/assets/instagram-Bf0IVidT.webp +0 -0
- package/dist/assets/kakao-talk-Df79L_Mv.webp +0 -0
- package/dist/assets/kaleidoscope-BxqMZuWo.webp +0 -0
- package/dist/assets/karrot-BXFPhDwt.webp +0 -0
- package/dist/assets/kaufland-BDDy6e0C.webp +0 -0
- package/dist/assets/lazada-ConR4e1O.webp +0 -0
- package/dist/assets/lens_flare-DgyiAv_j.webp +0 -0
- package/dist/assets/light_leak-kUdpoFuC.webp +0 -0
- package/dist/assets/line-Dr1j___B.webp +0 -0
- package/dist/assets/linkedin-4s_9Wh03.webp +0 -0
- package/dist/assets/lo_fi-DSdl3yY_.webp +0 -0
- package/dist/assets/logo-preparation.worker-D9oa7SME.js +420 -0
- package/dist/assets/mercado-libre-C8CskEiS.webp +0 -0
- package/dist/assets/mercari-jp-DHj7nz4O.webp +0 -0
- package/dist/assets/metadata.worker-B_9_BgN1.js +6456 -0
- package/dist/assets/mirror_collage-JtSKCeSh.webp +0 -0
- package/dist/assets/model-BbeF-fsf.webp +0 -0
- package/dist/assets/model-BjWhieit.webp +0 -0
- package/dist/assets/momo-BWXO_8Df.webp +0 -0
- package/dist/assets/motion_blur-B8YUHeSg.webp +0 -0
- package/dist/assets/naver-xQKL8lWg.webp +0 -0
- package/dist/assets/nuvemshop-DPt6rnA-.webp +0 -0
- package/dist/assets/olx-B87gp-Il.webp +0 -0
- package/dist/assets/orient-card-Da0ii6mX.webp +0 -0
- package/dist/assets/orient-final.worker-CdF5Y5zD.js +6909 -0
- package/dist/assets/orientation-preview.worker-B7uFzz3J.js +6865 -0
- package/dist/assets/ort.bundle.min-CreFV8V1.js +9311 -0
- package/dist/assets/ort.webgpu.bundle.min-CAudaHZO.js +9311 -0
- package/dist/assets/otto-market-DWZyNKJn.webp +0 -0
- package/dist/assets/paper_texture-CXphyIrs.webp +0 -0
- package/dist/assets/pinterest-ByZqih2J.webp +0 -0
- package/dist/assets/polish-DFy6LNG7.webp +0 -0
- package/dist/assets/poshmark-DnZi2vA1.webp +0 -0
- package/dist/assets/posterize-SpLVGq1s.webp +0 -0
- package/dist/assets/preview.worker-DcrCKKWl.js +380 -0
- package/dist/assets/qoo10-C1pq81Jx.webp +0 -0
- package/dist/assets/rakuten-ulYog1hL.webp +0 -0
- package/dist/assets/recolor-mBX7vdFT.webp +0 -0
- package/dist/assets/resize-DVEAl0Um.webp +0 -0
- package/dist/assets/runtime-0663b902fb3937883a34.wasm +0 -0
- package/dist/assets/runtime-355a5c80c7bfdf8737de.mjs +2817 -0
- package/dist/assets/runtime-49871f5a4409519797e1.wasm +0 -0
- package/dist/assets/runtime-74cf72f9a2b7befc115a.mjs +2817 -0
- package/dist/assets/shadow-card-DTZEH60r.png +0 -0
- package/dist/assets/shopee-Bxfei6sj.webp +0 -0
- package/dist/assets/shopify-wVaBafcF.webp +0 -0
- package/dist/assets/shopline-DMoaJ7Bh.webp +0 -0
- package/dist/assets/sparkle-CD5GSGip.webp +0 -0
- package/dist/assets/ssg-DQoFx5u5.webp +0 -0
- package/dist/assets/staging-CIc8pQJ6.webp +0 -0
- package/dist/assets/standard-cutout.worker-BYLzdpR-.js +1261 -0
- package/dist/assets/text-DQW2mBGp.webp +0 -0
- package/dist/assets/textured_glass-D2coxp7n.webp +0 -0
- package/dist/assets/tga-VGxWDes0.js +752 -0
- package/dist/assets/tilt_shift-BKs46yeX.webp +0 -0
- package/dist/assets/transformers.web-DB57cIO5.js +28891 -0
- package/dist/assets/tritone-CcR4qizk.webp +0 -0
- package/dist/assets/upscale-BrLadyUk.webp +0 -0
- package/dist/assets/upscale-creative-DnZnQufJ.webp +0 -0
- package/dist/assets/upscale-crisp-Ckdmbsnn.webp +0 -0
- package/dist/assets/vinted-1QDsxvC6.webp +0 -0
- package/dist/assets/watercolor-CV67zYNE.webp +0 -0
- package/dist/assets/watermark-CpPrxaT5.webp +0 -0
- package/dist/assets/wave_distortion-CV5jVfK4.webp +0 -0
- package/dist/assets/whatsapp-CWJxqzR6.webp +0 -0
- package/dist/assets/worker-DfrCFP3O.js +55 -0
- package/dist/assets/xerox_noise-CbbHY1S1.webp +0 -0
- package/dist/assets/youtube-DS12d5mi.webp +0 -0
- package/dist/assets/zalando-CenfWOwz.webp +0 -0
- package/dist/browser-adapter.d.ts +4 -0
- package/dist/browser-cutout-capability.d.ts +4 -0
- package/dist/browser-cutout-resources.d.ts +3 -0
- package/dist/browser-local-capabilities.d.ts +5 -0
- package/dist/capabilities.d.ts +18 -0
- package/dist/chunks/AdjustToolPanel-B6dtlFlj.js +195 -0
- package/dist/chunks/BackgroundToolPanel-C3Rr9d4S.js +41 -0
- package/dist/chunks/BatchMaterials-DDoJTaS5.js +806 -0
- package/dist/chunks/BatchModeChoices-DeBARgvY.js +111 -0
- package/dist/chunks/BatchOutputColorPicker-D7WIDS4_.js +75 -0
- package/dist/chunks/BatchReferenceFields-Cr5WgFRJ.js +316 -0
- package/dist/chunks/BeautifyToolPanel-DDZXDQKM.js +215 -0
- package/dist/chunks/BrandMarkToolPanel-vKobk_R3.js +1179 -0
- package/dist/chunks/ContentTrimControl-BKCJEst5.js +297 -0
- package/dist/chunks/CropToolPanel-C_sW5tWL.js +218 -0
- package/dist/chunks/CutoutToolPanel-B7ObmiWd.js +73 -0
- package/dist/chunks/DisclosureToolPanel-F3ccFJIF.js +76 -0
- package/dist/chunks/ExpandToolPanel-BKjj5UJA.js +67 -0
- package/dist/chunks/ImageEffectsToolPanel-CsDIBpT6.js +966 -0
- package/dist/chunks/IpAuditToolPanel-CduDfFh-.js +96 -0
- package/dist/chunks/ListingToolPanel-8pJ2_zvI.js +783 -0
- package/dist/chunks/MaterialSelectionPlate-CW7HaS6v.js +30 -0
- package/dist/chunks/MetadataToolPanel-C8XJOamN.js +104 -0
- package/dist/chunks/OrientToolPanel-C1AzQchm.js +161 -0
- package/dist/chunks/PluginActionFooter.vue_vue_type_script_setup_true_lang-BGe419qz.js +102 -0
- package/dist/chunks/ResizeToolPanel-DWikcj2G.js +1178 -0
- package/dist/chunks/RetouchToolPanel-B4eQKk2W.js +350 -0
- package/dist/chunks/ShadowToolPanel-Bbj76hQd.js +254 -0
- package/dist/chunks/SvgExportToolPanel-BRxpzd7q.js +219 -0
- package/dist/chunks/TranslationToolPanel-Bxv8U2WY.js +125 -0
- package/dist/chunks/UpscaleToolPanel-BRIgpszs.js +127 -0
- package/dist/chunks/engine-D-T-1RSx.js +69 -0
- package/dist/chunks/entry-CboOSe2r.js +42945 -0
- package/dist/chunks/gpu-CScw5MNG.js +231 -0
- package/dist/chunks/hosted-resources-COzZ7nZY.js +8196 -0
- package/dist/chunks/loader-circle-CylCgDqP.js +16 -0
- package/dist/chunks/motionFeatures-D67ghPG1.js +4405 -0
- package/dist/chunks/search-BwsDnulU.js +18 -0
- package/dist/chunks/standard-cutout-vPpP6xBc.js +45 -0
- package/dist/chunks/static-logo-2F9ORZWc.js +34 -0
- package/dist/config.d.ts +66 -0
- package/dist/contracts.d.ts +272 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +13 -0
- package/dist/node/catalog.mjs +45 -0
- package/dist/node/cli.mjs +11 -0
- package/dist/node/index.d.mts +20 -0
- package/dist/node/index.mjs +2 -0
- package/dist/node/prepare.mjs +114 -0
- package/dist/node/vite.mjs +46 -0
- package/dist/processing.d.ts +1 -0
- package/dist/processing.js +12105 -0
- package/dist/remote-contracts.d.ts +114 -0
- package/dist/resource-contracts.d.ts +40 -0
- package/dist/resources/cutout/9ae2e5375a34fa413530954dc20d085d175faffc86108c13619220d0557f80bf.json +1 -0
- package/dist/resources/cutout/f119dabecc64bc436d3d08425dde96ec2598fd40541eba97d8d53a4e8bbdcaea.json +1 -0
- package/dist/resources/cutout/resources.json +195 -0
- package/dist/resources/cutout/sources.json +294 -0
- package/dist/resources.json +1191 -0
- package/dist/service-contracts.d.ts +43 -0
- package/dist/slots.d.ts +21 -0
- package/dist/style.css +1 -0
- package/dist/types/batch/api.d.ts +89 -0
- package/dist/types/batch/cutout-output.d.ts +2 -0
- package/dist/types/batch/features/background/engine.d.mts +12 -0
- package/dist/types/batch/features/basic-edit/contracts.d.ts +87 -0
- package/dist/types/batch/features/basic-edit/engine.d.mts +96 -0
- package/dist/types/batch/features/brand-mark/contracts.d.ts +84 -0
- package/dist/types/batch/features/brand-mark/engine.d.mts +68 -0
- package/dist/types/batch/features/export-compression/contracts.d.ts +44 -0
- package/dist/types/batch/features/export-compression/gifenc.d.ts +33 -0
- package/dist/types/batch/features/export-compression/plan.d.ts +45 -0
- package/dist/types/batch/features/export-compression/presentation.d.ts +70 -0
- package/dist/types/batch/features/export-compression/upng.d.ts +6 -0
- package/dist/types/batch/features/final-image/resize.d.mts +15 -0
- package/dist/types/batch/features/image-effects/contracts.d.ts +58 -0
- package/dist/types/batch/features/image-effects/gpu-pixel-runtime.d.ts +15 -0
- package/dist/types/batch/features/image-effects/photo-audit.d.ts +21 -0
- package/dist/types/batch/features/image-effects/photo-v7-cpu.d.ts +9 -0
- package/dist/types/batch/features/image-effects/profiles-v4.d.ts +157 -0
- package/dist/types/batch/features/image-effects/profiles-v5.d.ts +20 -0
- package/dist/types/batch/features/image-effects/profiles-v6.d.ts +14 -0
- package/dist/types/batch/features/image-effects/profiles-v7.d.ts +53 -0
- package/dist/types/batch/features/image-effects/profiles-v8.d.ts +113 -0
- package/dist/types/batch/features/image-effects/profiles-v9.d.ts +20 -0
- package/dist/types/batch/features/image-translation/params.d.ts +257 -0
- package/dist/types/batch/features/listing-remake/transport.d.ts +21 -0
- package/dist/types/batch/features/metadata/bytes.d.mts +13 -0
- package/dist/types/batch/features/metadata/containers.d.mts +20 -0
- package/dist/types/batch/features/metadata/declaration.d.mts +5 -0
- package/dist/types/batch/features/metadata/engine.d.mts +9 -0
- package/dist/types/batch/features/metadata/exchange.d.mts +48 -0
- package/dist/types/batch/features/shadow/contracts.d.ts +43 -0
- package/dist/types/batch/features/shadow/engine.d.mts +33 -0
- package/dist/types/batch/features/svg-export/download-contract.d.ts +33 -0
- package/dist/types/batch/features/svg-export/download-prepare.d.ts +2 -0
- package/dist/types/batch/features/svg-export/download.d.ts +7 -0
- package/dist/types/batch/features/svg-export/imagetracer.d.ts +6 -0
- package/dist/types/batch/features/svg-export/optimizer.d.ts +2 -0
- package/dist/types/batch/ids.d.ts +1 -0
- package/dist/types/batch/model.d.ts +317 -0
- package/dist/types/batch/public/config.d.ts +66 -0
- package/dist/types/batch/public/contracts.d.ts +272 -0
- package/dist/types/batch/public/remote-contracts.d.ts +114 -0
- package/dist/types/batch/public/resource-contracts.d.ts +40 -0
- package/dist/types/batch/public/service-contracts.d.ts +43 -0
- package/dist/types/batch/queue.d.ts +34 -0
- package/dist/types/batch/receipts.d.ts +85 -0
- package/dist/types/batch/retention.d.ts +13 -0
- package/dist/types/onnxruntime-web.d.ts +5 -0
- package/dist/types/plugins/cutout/core/hosted-resources.d.ts +11 -0
- package/dist/types/processing.d.ts +18 -0
- package/dist/types/shared/svg-security.d.mts +4 -0
- package/dist/types/workspace-worker.d.ts +2 -0
- package/package.json +91 -3
|
@@ -0,0 +1,3894 @@
|
|
|
1
|
+
var ar = Object.create, Ct = Object.defineProperty, nr = Object.getOwnPropertyDescriptor, Ot = Object.getOwnPropertyNames, sr = Object.getPrototypeOf, ir = Object.prototype.hasOwnProperty, ct = (t, e) => function() {
|
|
2
|
+
return e || (0, t[Ot(t)[0]])((e = { exports: {} }).exports, e), e.exports;
|
|
3
|
+
}, or = (t, e, r, a) => {
|
|
4
|
+
if (e && typeof e == "object" || typeof e == "function")
|
|
5
|
+
for (let n of Ot(e))
|
|
6
|
+
!ir.call(t, n) && n !== r && Ct(t, n, { get: () => e[n], enumerable: !(a = nr(e, n)) || a.enumerable });
|
|
7
|
+
return t;
|
|
8
|
+
}, Ve = (t, e, r) => (r = t != null ? ar(sr(t)) : {}, or(
|
|
9
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
10
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
11
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
12
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
13
|
+
!t || !t.__esModule ? Ct(r, "default", { value: t, enumerable: !0 }) : r,
|
|
14
|
+
t
|
|
15
|
+
)), cr = ct({
|
|
16
|
+
"../../node_modules/.pnpm/iota-array@1.0.0/node_modules/iota-array/iota.js"(t, e) {
|
|
17
|
+
function r(a) {
|
|
18
|
+
for (var n = new Array(a), s = 0; s < a; ++s)
|
|
19
|
+
n[s] = s;
|
|
20
|
+
return n;
|
|
21
|
+
}
|
|
22
|
+
e.exports = r;
|
|
23
|
+
}
|
|
24
|
+
}), ur = ct({
|
|
25
|
+
"../../node_modules/.pnpm/is-buffer@1.1.6/node_modules/is-buffer/index.js"(t, e) {
|
|
26
|
+
e.exports = function(n) {
|
|
27
|
+
return n != null && (r(n) || a(n) || !!n._isBuffer);
|
|
28
|
+
};
|
|
29
|
+
function r(n) {
|
|
30
|
+
return !!n.constructor && typeof n.constructor.isBuffer == "function" && n.constructor.isBuffer(n);
|
|
31
|
+
}
|
|
32
|
+
function a(n) {
|
|
33
|
+
return typeof n.readFloatLE == "function" && typeof n.slice == "function" && r(n.slice(0, 0));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}), Be = ct({
|
|
37
|
+
"../../node_modules/.pnpm/ndarray@1.0.19/node_modules/ndarray/ndarray.js"(t, e) {
|
|
38
|
+
var r = cr(), a = ur(), n = typeof Float64Array < "u";
|
|
39
|
+
function s(p, g) {
|
|
40
|
+
return p[0] - g[0];
|
|
41
|
+
}
|
|
42
|
+
function i() {
|
|
43
|
+
var p = this.stride, g = new Array(p.length), m;
|
|
44
|
+
for (m = 0; m < g.length; ++m)
|
|
45
|
+
g[m] = [Math.abs(p[m]), m];
|
|
46
|
+
g.sort(s);
|
|
47
|
+
var j = new Array(g.length);
|
|
48
|
+
for (m = 0; m < j.length; ++m)
|
|
49
|
+
j[m] = g[m][1];
|
|
50
|
+
return j;
|
|
51
|
+
}
|
|
52
|
+
function o(p, g) {
|
|
53
|
+
var m = ["View", g, "d", p].join("");
|
|
54
|
+
g < 0 && (m = "View_Nil" + p);
|
|
55
|
+
var j = p === "generic";
|
|
56
|
+
if (g === -1) {
|
|
57
|
+
var b = "function " + m + "(a){this.data=a;};var proto=" + m + ".prototype;proto.dtype='" + p + "';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new " + m + "(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_" + m + "(a){return new " + m + "(a);}", ne = new Function(b);
|
|
58
|
+
return ne();
|
|
59
|
+
} else if (g === 0) {
|
|
60
|
+
var b = "function " + m + "(a,d) {this.data = a;this.offset = d};var proto=" + m + ".prototype;proto.dtype='" + p + "';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function " + m + "_copy() {return new " + m + "(this.data,this.offset)};proto.pick=function " + m + "_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function " + m + "_get(){return " + (j ? "this.data.get(this.offset)" : "this.data[this.offset]") + "};proto.set=function " + m + "_set(v){return " + (j ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v") + "};return function construct_" + m + "(a,b,c,d){return new " + m + "(a,d)}", ne = new Function("TrivialArray", b);
|
|
61
|
+
return ne(u[p][0]);
|
|
62
|
+
}
|
|
63
|
+
var b = ["'use strict'"], O = r(g), A = O.map(function(w) {
|
|
64
|
+
return "i" + w;
|
|
65
|
+
}), R = "this.offset+" + O.map(function(w) {
|
|
66
|
+
return "this.stride[" + w + "]*i" + w;
|
|
67
|
+
}).join("+"), N = O.map(function(w) {
|
|
68
|
+
return "b" + w;
|
|
69
|
+
}).join(","), I = O.map(function(w) {
|
|
70
|
+
return "c" + w;
|
|
71
|
+
}).join(",");
|
|
72
|
+
b.push(
|
|
73
|
+
"function " + m + "(a," + N + "," + I + ",d){this.data=a",
|
|
74
|
+
"this.shape=[" + N + "]",
|
|
75
|
+
"this.stride=[" + I + "]",
|
|
76
|
+
"this.offset=d|0}",
|
|
77
|
+
"var proto=" + m + ".prototype",
|
|
78
|
+
"proto.dtype='" + p + "'",
|
|
79
|
+
"proto.dimension=" + g
|
|
80
|
+
), b.push(
|
|
81
|
+
"Object.defineProperty(proto,'size',{get:function " + m + "_size(){return " + O.map(function(w) {
|
|
82
|
+
return "this.shape[" + w + "]";
|
|
83
|
+
}).join("*"),
|
|
84
|
+
"}})"
|
|
85
|
+
), g === 1 ? b.push("proto.order=[0]") : (b.push("Object.defineProperty(proto,'order',{get:"), g < 4 ? (b.push("function " + m + "_order(){"), g === 2 ? b.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})") : g === 3 && b.push(
|
|
86
|
+
"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})"
|
|
87
|
+
)) : b.push("ORDER})")), b.push(
|
|
88
|
+
"proto.set=function " + m + "_set(" + A.join(",") + ",v){"
|
|
89
|
+
), j ? b.push("return this.data.set(" + R + ",v)}") : b.push("return this.data[" + R + "]=v}"), b.push("proto.get=function " + m + "_get(" + A.join(",") + "){"), j ? b.push("return this.data.get(" + R + ")}") : b.push("return this.data[" + R + "]}"), b.push(
|
|
90
|
+
"proto.index=function " + m + "_index(",
|
|
91
|
+
A.join(),
|
|
92
|
+
"){return " + R + "}"
|
|
93
|
+
), b.push("proto.hi=function " + m + "_hi(" + A.join(",") + "){return new " + m + "(this.data," + O.map(function(w) {
|
|
94
|
+
return ["(typeof i", w, "!=='number'||i", w, "<0)?this.shape[", w, "]:i", w, "|0"].join("");
|
|
95
|
+
}).join(",") + "," + O.map(function(w) {
|
|
96
|
+
return "this.stride[" + w + "]";
|
|
97
|
+
}).join(",") + ",this.offset)}");
|
|
98
|
+
var We = O.map(function(w) {
|
|
99
|
+
return "a" + w + "=this.shape[" + w + "]";
|
|
100
|
+
}), qe = O.map(function(w) {
|
|
101
|
+
return "c" + w + "=this.stride[" + w + "]";
|
|
102
|
+
});
|
|
103
|
+
b.push("proto.lo=function " + m + "_lo(" + A.join(",") + "){var b=this.offset,d=0," + We.join(",") + "," + qe.join(","));
|
|
104
|
+
for (var T = 0; T < g; ++T)
|
|
105
|
+
b.push(
|
|
106
|
+
"if(typeof i" + T + "==='number'&&i" + T + ">=0){d=i" + T + "|0;b+=c" + T + "*d;a" + T + "-=d}"
|
|
107
|
+
);
|
|
108
|
+
b.push("return new " + m + "(this.data," + O.map(function(w) {
|
|
109
|
+
return "a" + w;
|
|
110
|
+
}).join(",") + "," + O.map(function(w) {
|
|
111
|
+
return "c" + w;
|
|
112
|
+
}).join(",") + ",b)}"), b.push("proto.step=function " + m + "_step(" + A.join(",") + "){var " + O.map(function(w) {
|
|
113
|
+
return "a" + w + "=this.shape[" + w + "]";
|
|
114
|
+
}).join(",") + "," + O.map(function(w) {
|
|
115
|
+
return "b" + w + "=this.stride[" + w + "]";
|
|
116
|
+
}).join(",") + ",c=this.offset,d=0,ceil=Math.ceil");
|
|
117
|
+
for (var T = 0; T < g; ++T)
|
|
118
|
+
b.push(
|
|
119
|
+
"if(typeof i" + T + "==='number'){d=i" + T + "|0;if(d<0){c+=b" + T + "*(a" + T + "-1);a" + T + "=ceil(-a" + T + "/d)}else{a" + T + "=ceil(a" + T + "/d)}b" + T + "*=d}"
|
|
120
|
+
);
|
|
121
|
+
b.push("return new " + m + "(this.data," + O.map(function(w) {
|
|
122
|
+
return "a" + w;
|
|
123
|
+
}).join(",") + "," + O.map(function(w) {
|
|
124
|
+
return "b" + w;
|
|
125
|
+
}).join(",") + ",c)}");
|
|
126
|
+
for (var je = new Array(g), Se = new Array(g), T = 0; T < g; ++T)
|
|
127
|
+
je[T] = "a[i" + T + "]", Se[T] = "b[i" + T + "]";
|
|
128
|
+
b.push(
|
|
129
|
+
"proto.transpose=function " + m + "_transpose(" + A + "){" + A.map(function(w, rr) {
|
|
130
|
+
return w + "=(" + w + "===undefined?" + rr + ":" + w + "|0)";
|
|
131
|
+
}).join(";"),
|
|
132
|
+
"var a=this.shape,b=this.stride;return new " + m + "(this.data," + je.join(",") + "," + Se.join(",") + ",this.offset)}"
|
|
133
|
+
), b.push("proto.pick=function " + m + "_pick(" + A + "){var a=[],b=[],c=this.offset");
|
|
134
|
+
for (var T = 0; T < g; ++T)
|
|
135
|
+
b.push("if(typeof i" + T + "==='number'&&i" + T + ">=0){c=(c+this.stride[" + T + "]*i" + T + ")|0}else{a.push(this.shape[" + T + "]);b.push(this.stride[" + T + "])}");
|
|
136
|
+
b.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"), b.push("return function construct_" + m + "(data,shape,stride,offset){return new " + m + "(data," + O.map(function(w) {
|
|
137
|
+
return "shape[" + w + "]";
|
|
138
|
+
}).join(",") + "," + O.map(function(w) {
|
|
139
|
+
return "stride[" + w + "]";
|
|
140
|
+
}).join(",") + ",offset)}");
|
|
141
|
+
var ne = new Function("CTOR_LIST", "ORDER", b.join(`
|
|
142
|
+
`));
|
|
143
|
+
return ne(u[p], i);
|
|
144
|
+
}
|
|
145
|
+
function c(p) {
|
|
146
|
+
if (a(p))
|
|
147
|
+
return "buffer";
|
|
148
|
+
if (n)
|
|
149
|
+
switch (Object.prototype.toString.call(p)) {
|
|
150
|
+
case "[object Float64Array]":
|
|
151
|
+
return "float64";
|
|
152
|
+
case "[object Float32Array]":
|
|
153
|
+
return "float32";
|
|
154
|
+
case "[object Int8Array]":
|
|
155
|
+
return "int8";
|
|
156
|
+
case "[object Int16Array]":
|
|
157
|
+
return "int16";
|
|
158
|
+
case "[object Int32Array]":
|
|
159
|
+
return "int32";
|
|
160
|
+
case "[object Uint8Array]":
|
|
161
|
+
return "uint8";
|
|
162
|
+
case "[object Uint16Array]":
|
|
163
|
+
return "uint16";
|
|
164
|
+
case "[object Uint32Array]":
|
|
165
|
+
return "uint32";
|
|
166
|
+
case "[object Uint8ClampedArray]":
|
|
167
|
+
return "uint8_clamped";
|
|
168
|
+
case "[object BigInt64Array]":
|
|
169
|
+
return "bigint64";
|
|
170
|
+
case "[object BigUint64Array]":
|
|
171
|
+
return "biguint64";
|
|
172
|
+
}
|
|
173
|
+
return Array.isArray(p) ? "array" : "generic";
|
|
174
|
+
}
|
|
175
|
+
var u = {
|
|
176
|
+
float32: [],
|
|
177
|
+
float64: [],
|
|
178
|
+
int8: [],
|
|
179
|
+
int16: [],
|
|
180
|
+
int32: [],
|
|
181
|
+
uint8: [],
|
|
182
|
+
uint16: [],
|
|
183
|
+
uint32: [],
|
|
184
|
+
array: [],
|
|
185
|
+
uint8_clamped: [],
|
|
186
|
+
bigint64: [],
|
|
187
|
+
biguint64: [],
|
|
188
|
+
buffer: [],
|
|
189
|
+
generic: []
|
|
190
|
+
};
|
|
191
|
+
function l(p, g, m, j) {
|
|
192
|
+
if (p === void 0) {
|
|
193
|
+
var I = u.array[0];
|
|
194
|
+
return I([]);
|
|
195
|
+
} else typeof p == "number" && (p = [p]);
|
|
196
|
+
g === void 0 && (g = [p.length]);
|
|
197
|
+
var b = g.length;
|
|
198
|
+
if (m === void 0) {
|
|
199
|
+
m = new Array(b);
|
|
200
|
+
for (var O = b - 1, A = 1; O >= 0; --O)
|
|
201
|
+
m[O] = A, A *= g[O];
|
|
202
|
+
}
|
|
203
|
+
if (j === void 0) {
|
|
204
|
+
j = 0;
|
|
205
|
+
for (var O = 0; O < b; ++O)
|
|
206
|
+
m[O] < 0 && (j -= (g[O] - 1) * m[O]);
|
|
207
|
+
}
|
|
208
|
+
for (var R = c(p), N = u[R]; N.length <= b + 1; )
|
|
209
|
+
N.push(o(R, N.length - 1));
|
|
210
|
+
var I = N[b + 1];
|
|
211
|
+
return I(p, g, m, j);
|
|
212
|
+
}
|
|
213
|
+
e.exports = l;
|
|
214
|
+
}
|
|
215
|
+
}), dr = typeof global == "object" && global && global.Object === Object && global, lr = dr, fr = typeof self == "object" && self && self.Object === Object && self, hr = lr || fr || Function("return this")(), ut = hr, pr = ut.Symbol, Ze = pr, jt = Object.prototype, mr = jt.hasOwnProperty, vr = jt.toString, se = Ze ? Ze.toStringTag : void 0;
|
|
216
|
+
function gr(t) {
|
|
217
|
+
var e = mr.call(t, se), r = t[se];
|
|
218
|
+
try {
|
|
219
|
+
t[se] = void 0;
|
|
220
|
+
var a = !0;
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
var n = vr.call(t);
|
|
224
|
+
return a && (e ? t[se] = r : delete t[se]), n;
|
|
225
|
+
}
|
|
226
|
+
var yr = gr, _r = Object.prototype, br = _r.toString;
|
|
227
|
+
function wr(t) {
|
|
228
|
+
return br.call(t);
|
|
229
|
+
}
|
|
230
|
+
var xr = wr, kr = "[object Null]", Tr = "[object Undefined]", pt = Ze ? Ze.toStringTag : void 0;
|
|
231
|
+
function Cr(t) {
|
|
232
|
+
return t == null ? t === void 0 ? Tr : kr : pt && pt in Object(t) ? yr(t) : xr(t);
|
|
233
|
+
}
|
|
234
|
+
var Or = Cr;
|
|
235
|
+
function jr(t) {
|
|
236
|
+
var e = typeof t;
|
|
237
|
+
return t != null && (e == "object" || e == "function");
|
|
238
|
+
}
|
|
239
|
+
var St = jr, Sr = "[object AsyncFunction]", Ar = "[object Function]", Er = "[object GeneratorFunction]", Ir = "[object Proxy]";
|
|
240
|
+
function Zr(t) {
|
|
241
|
+
if (!St(t))
|
|
242
|
+
return !1;
|
|
243
|
+
var e = Or(t);
|
|
244
|
+
return e == Ar || e == Er || e == Sr || e == Ir;
|
|
245
|
+
}
|
|
246
|
+
var Rr = Zr, Nr = ut["__core-js_shared__"], Ge = Nr, mt = (function() {
|
|
247
|
+
var t = /[^.]+$/.exec(Ge && Ge.keys && Ge.keys.IE_PROTO || "");
|
|
248
|
+
return t ? "Symbol(src)_1." + t : "";
|
|
249
|
+
})();
|
|
250
|
+
function Pr(t) {
|
|
251
|
+
return !!mt && mt in t;
|
|
252
|
+
}
|
|
253
|
+
var Mr = Pr, $r = Function.prototype, zr = $r.toString;
|
|
254
|
+
function Dr(t) {
|
|
255
|
+
if (t != null) {
|
|
256
|
+
try {
|
|
257
|
+
return zr.call(t);
|
|
258
|
+
} catch {
|
|
259
|
+
}
|
|
260
|
+
try {
|
|
261
|
+
return t + "";
|
|
262
|
+
} catch {
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return "";
|
|
266
|
+
}
|
|
267
|
+
var Ur = Dr, Vr = /[\\^$.*+?()[\]{}|]/g, Br = /^\[object .+?Constructor\]$/, Fr = Function.prototype, Lr = Object.prototype, Wr = Fr.toString, qr = Lr.hasOwnProperty, Gr = RegExp(
|
|
268
|
+
"^" + Wr.call(qr).replace(Vr, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
269
|
+
);
|
|
270
|
+
function Hr(t) {
|
|
271
|
+
if (!St(t) || Mr(t))
|
|
272
|
+
return !1;
|
|
273
|
+
var e = Rr(t) ? Gr : Br;
|
|
274
|
+
return e.test(Ur(t));
|
|
275
|
+
}
|
|
276
|
+
var Jr = Hr;
|
|
277
|
+
function Yr(t, e) {
|
|
278
|
+
return t?.[e];
|
|
279
|
+
}
|
|
280
|
+
var Kr = Yr;
|
|
281
|
+
function Xr(t, e) {
|
|
282
|
+
var r = Kr(t, e);
|
|
283
|
+
return Jr(r) ? r : void 0;
|
|
284
|
+
}
|
|
285
|
+
var At = Xr, Qr = At(Object, "create"), de = Qr;
|
|
286
|
+
function ea() {
|
|
287
|
+
this.__data__ = de ? de(null) : {}, this.size = 0;
|
|
288
|
+
}
|
|
289
|
+
var ta = ea;
|
|
290
|
+
function ra(t) {
|
|
291
|
+
var e = this.has(t) && delete this.__data__[t];
|
|
292
|
+
return this.size -= e ? 1 : 0, e;
|
|
293
|
+
}
|
|
294
|
+
var aa = ra, na = "__lodash_hash_undefined__", sa = Object.prototype, ia = sa.hasOwnProperty;
|
|
295
|
+
function oa(t) {
|
|
296
|
+
var e = this.__data__;
|
|
297
|
+
if (de) {
|
|
298
|
+
var r = e[t];
|
|
299
|
+
return r === na ? void 0 : r;
|
|
300
|
+
}
|
|
301
|
+
return ia.call(e, t) ? e[t] : void 0;
|
|
302
|
+
}
|
|
303
|
+
var ca = oa, ua = Object.prototype, da = ua.hasOwnProperty;
|
|
304
|
+
function la(t) {
|
|
305
|
+
var e = this.__data__;
|
|
306
|
+
return de ? e[t] !== void 0 : da.call(e, t);
|
|
307
|
+
}
|
|
308
|
+
var fa = la, ha = "__lodash_hash_undefined__";
|
|
309
|
+
function pa(t, e) {
|
|
310
|
+
var r = this.__data__;
|
|
311
|
+
return this.size += this.has(t) ? 0 : 1, r[t] = de && e === void 0 ? ha : e, this;
|
|
312
|
+
}
|
|
313
|
+
var ma = pa;
|
|
314
|
+
function te(t) {
|
|
315
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
316
|
+
for (this.clear(); ++e < r; ) {
|
|
317
|
+
var a = t[e];
|
|
318
|
+
this.set(a[0], a[1]);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
te.prototype.clear = ta;
|
|
322
|
+
te.prototype.delete = aa;
|
|
323
|
+
te.prototype.get = ca;
|
|
324
|
+
te.prototype.has = fa;
|
|
325
|
+
te.prototype.set = ma;
|
|
326
|
+
var vt = te;
|
|
327
|
+
function va() {
|
|
328
|
+
this.__data__ = [], this.size = 0;
|
|
329
|
+
}
|
|
330
|
+
var ga = va;
|
|
331
|
+
function ya(t, e) {
|
|
332
|
+
return t === e || t !== t && e !== e;
|
|
333
|
+
}
|
|
334
|
+
var _a = ya;
|
|
335
|
+
function ba(t, e) {
|
|
336
|
+
for (var r = t.length; r--; )
|
|
337
|
+
if (_a(t[r][0], e))
|
|
338
|
+
return r;
|
|
339
|
+
return -1;
|
|
340
|
+
}
|
|
341
|
+
var Fe = ba, wa = Array.prototype, xa = wa.splice;
|
|
342
|
+
function ka(t) {
|
|
343
|
+
var e = this.__data__, r = Fe(e, t);
|
|
344
|
+
if (r < 0)
|
|
345
|
+
return !1;
|
|
346
|
+
var a = e.length - 1;
|
|
347
|
+
return r == a ? e.pop() : xa.call(e, r, 1), --this.size, !0;
|
|
348
|
+
}
|
|
349
|
+
var Ta = ka;
|
|
350
|
+
function Ca(t) {
|
|
351
|
+
var e = this.__data__, r = Fe(e, t);
|
|
352
|
+
return r < 0 ? void 0 : e[r][1];
|
|
353
|
+
}
|
|
354
|
+
var Oa = Ca;
|
|
355
|
+
function ja(t) {
|
|
356
|
+
return Fe(this.__data__, t) > -1;
|
|
357
|
+
}
|
|
358
|
+
var Sa = ja;
|
|
359
|
+
function Aa(t, e) {
|
|
360
|
+
var r = this.__data__, a = Fe(r, t);
|
|
361
|
+
return a < 0 ? (++this.size, r.push([t, e])) : r[a][1] = e, this;
|
|
362
|
+
}
|
|
363
|
+
var Ea = Aa;
|
|
364
|
+
function re(t) {
|
|
365
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
366
|
+
for (this.clear(); ++e < r; ) {
|
|
367
|
+
var a = t[e];
|
|
368
|
+
this.set(a[0], a[1]);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
re.prototype.clear = ga;
|
|
372
|
+
re.prototype.delete = Ta;
|
|
373
|
+
re.prototype.get = Oa;
|
|
374
|
+
re.prototype.has = Sa;
|
|
375
|
+
re.prototype.set = Ea;
|
|
376
|
+
var Ia = re, Za = At(ut, "Map"), Ra = Za;
|
|
377
|
+
function Na() {
|
|
378
|
+
this.size = 0, this.__data__ = {
|
|
379
|
+
hash: new vt(),
|
|
380
|
+
map: new (Ra || Ia)(),
|
|
381
|
+
string: new vt()
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
var Pa = Na;
|
|
385
|
+
function Ma(t) {
|
|
386
|
+
var e = typeof t;
|
|
387
|
+
return e == "string" || e == "number" || e == "symbol" || e == "boolean" ? t !== "__proto__" : t === null;
|
|
388
|
+
}
|
|
389
|
+
var $a = Ma;
|
|
390
|
+
function za(t, e) {
|
|
391
|
+
var r = t.__data__;
|
|
392
|
+
return $a(e) ? r[typeof e == "string" ? "string" : "hash"] : r.map;
|
|
393
|
+
}
|
|
394
|
+
var Le = za;
|
|
395
|
+
function Da(t) {
|
|
396
|
+
var e = Le(this, t).delete(t);
|
|
397
|
+
return this.size -= e ? 1 : 0, e;
|
|
398
|
+
}
|
|
399
|
+
var Ua = Da;
|
|
400
|
+
function Va(t) {
|
|
401
|
+
return Le(this, t).get(t);
|
|
402
|
+
}
|
|
403
|
+
var Ba = Va;
|
|
404
|
+
function Fa(t) {
|
|
405
|
+
return Le(this, t).has(t);
|
|
406
|
+
}
|
|
407
|
+
var La = Fa;
|
|
408
|
+
function Wa(t, e) {
|
|
409
|
+
var r = Le(this, t), a = r.size;
|
|
410
|
+
return r.set(t, e), this.size += r.size == a ? 0 : 1, this;
|
|
411
|
+
}
|
|
412
|
+
var qa = Wa;
|
|
413
|
+
function ae(t) {
|
|
414
|
+
var e = -1, r = t == null ? 0 : t.length;
|
|
415
|
+
for (this.clear(); ++e < r; ) {
|
|
416
|
+
var a = t[e];
|
|
417
|
+
this.set(a[0], a[1]);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
ae.prototype.clear = Pa;
|
|
421
|
+
ae.prototype.delete = Ua;
|
|
422
|
+
ae.prototype.get = Ba;
|
|
423
|
+
ae.prototype.has = La;
|
|
424
|
+
ae.prototype.set = qa;
|
|
425
|
+
var Et = ae, Ga = "Expected a function";
|
|
426
|
+
function dt(t, e) {
|
|
427
|
+
if (typeof t != "function" || e != null && typeof e != "function")
|
|
428
|
+
throw new TypeError(Ga);
|
|
429
|
+
var r = function() {
|
|
430
|
+
var a = arguments, n = e ? e.apply(this, a) : a[0], s = r.cache;
|
|
431
|
+
if (s.has(n))
|
|
432
|
+
return s.get(n);
|
|
433
|
+
var i = t.apply(this, a);
|
|
434
|
+
return r.cache = s.set(n, i) || s, i;
|
|
435
|
+
};
|
|
436
|
+
return r.cache = new (dt.Cache || Et)(), r;
|
|
437
|
+
}
|
|
438
|
+
dt.Cache = Et;
|
|
439
|
+
var Ha = dt, lt = Ve(Be()), It = class Ke {
|
|
440
|
+
constructor(e, r) {
|
|
441
|
+
this.type = "application/octet-stream", this.params = {}, this.type = e, this.params = r;
|
|
442
|
+
}
|
|
443
|
+
toString() {
|
|
444
|
+
const e = [];
|
|
445
|
+
for (const r in this.params) {
|
|
446
|
+
const a = this.params[r];
|
|
447
|
+
e.push(`${r}=${a}`);
|
|
448
|
+
}
|
|
449
|
+
return [this.type, ...e].join(";");
|
|
450
|
+
}
|
|
451
|
+
static create(e, r) {
|
|
452
|
+
return new Ke(e, r);
|
|
453
|
+
}
|
|
454
|
+
isIdentical(e) {
|
|
455
|
+
return this.type === e.type && this.params === e.params;
|
|
456
|
+
}
|
|
457
|
+
isEqual(e) {
|
|
458
|
+
return this.type === e.type;
|
|
459
|
+
}
|
|
460
|
+
static fromString(e) {
|
|
461
|
+
const [r, ...a] = e.split(";"), n = {};
|
|
462
|
+
for (const s of a) {
|
|
463
|
+
const [i, o] = s.split("=");
|
|
464
|
+
n[i.trim()] = o.trim();
|
|
465
|
+
}
|
|
466
|
+
return new Ke(r, n);
|
|
467
|
+
}
|
|
468
|
+
}, He = Ve(Be());
|
|
469
|
+
async function Ja(t) {
|
|
470
|
+
const e = It.fromString(t.type);
|
|
471
|
+
switch (e.type) {
|
|
472
|
+
case "image/x-alpha8": {
|
|
473
|
+
const r = parseInt(e.params.width), a = parseInt(e.params.height);
|
|
474
|
+
return (0, He.default)(new Uint8Array(await t.arrayBuffer()), [
|
|
475
|
+
a,
|
|
476
|
+
r,
|
|
477
|
+
1
|
|
478
|
+
]);
|
|
479
|
+
}
|
|
480
|
+
case "image/x-rgba8": {
|
|
481
|
+
const r = parseInt(e.params.width), a = parseInt(e.params.height);
|
|
482
|
+
return (0, He.default)(new Uint8Array(await t.arrayBuffer()), [
|
|
483
|
+
a,
|
|
484
|
+
r,
|
|
485
|
+
4
|
|
486
|
+
]);
|
|
487
|
+
}
|
|
488
|
+
case "application/octet-stream":
|
|
489
|
+
case "image/png":
|
|
490
|
+
case "image/jpeg":
|
|
491
|
+
case "image/jpg":
|
|
492
|
+
case "image/webp": {
|
|
493
|
+
const r = await createImageBitmap(t), a = Qa(r);
|
|
494
|
+
return (0, He.default)(new Uint8Array(a.data), [
|
|
495
|
+
a.height,
|
|
496
|
+
a.width,
|
|
497
|
+
4
|
|
498
|
+
]);
|
|
499
|
+
}
|
|
500
|
+
default:
|
|
501
|
+
throw new Error(
|
|
502
|
+
`Invalid format: ${e.type} with params: ${e.params}`
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
async function Ya(t, e = 0.8, r = "image/png") {
|
|
507
|
+
const [a, n, s] = t.shape;
|
|
508
|
+
switch (r) {
|
|
509
|
+
case "image/x-alpha8":
|
|
510
|
+
case "image/x-rgba8": {
|
|
511
|
+
const c = It.create(r, {
|
|
512
|
+
width: n.toString(),
|
|
513
|
+
height: a.toString()
|
|
514
|
+
});
|
|
515
|
+
return new Blob([t.data], { type: c.toString() });
|
|
516
|
+
}
|
|
517
|
+
case "image/png":
|
|
518
|
+
case "image/jpeg":
|
|
519
|
+
case "image/webp": {
|
|
520
|
+
const c = new ImageData(
|
|
521
|
+
new Uint8ClampedArray(t.data),
|
|
522
|
+
n,
|
|
523
|
+
a
|
|
524
|
+
);
|
|
525
|
+
var i = Zt(c.width, c.height), o = i.getContext("2d");
|
|
526
|
+
return o.putImageData(c, 0, 0), i.convertToBlob({ quality: e, type: r });
|
|
527
|
+
}
|
|
528
|
+
default:
|
|
529
|
+
throw new Error(`Invalid format: ${r}`);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
function Ka(t) {
|
|
533
|
+
return new RegExp("^(?:[a-z+]+:)?//", "i").test(t);
|
|
534
|
+
}
|
|
535
|
+
function Xa(t, e) {
|
|
536
|
+
return Ka(t) ? t : new URL(t, e).href;
|
|
537
|
+
}
|
|
538
|
+
function Qa(t) {
|
|
539
|
+
var e = Zt(t.width, t.height), r = e.getContext("2d");
|
|
540
|
+
return r.drawImage(t, 0, 0), r.getImageData(0, 0, e.width, e.height);
|
|
541
|
+
}
|
|
542
|
+
function en(t) {
|
|
543
|
+
if (typeof Uint8Array < "u")
|
|
544
|
+
return new Uint8Array(t);
|
|
545
|
+
if (typeof Uint8ClampedArray < "u")
|
|
546
|
+
return new Uint8ClampedArray(t);
|
|
547
|
+
if (typeof Uint16Array < "u")
|
|
548
|
+
return new Uint16Array(t);
|
|
549
|
+
if (typeof Uint32Array < "u")
|
|
550
|
+
return new Uint32Array(t);
|
|
551
|
+
if (typeof Float32Array < "u")
|
|
552
|
+
return new Float32Array(t);
|
|
553
|
+
if (typeof Float64Array < "u")
|
|
554
|
+
return new Float64Array(t);
|
|
555
|
+
throw new Error("TypedArray not supported");
|
|
556
|
+
}
|
|
557
|
+
function gt(t, e, r, a = !1) {
|
|
558
|
+
const [n, s, i] = t.shape;
|
|
559
|
+
let o = s / e, c = n / r;
|
|
560
|
+
a && (o = c = Math.max(o, c) > 1 ? Math.max(o, c) : Math.min(o, c));
|
|
561
|
+
const u = (0, lt.default)(
|
|
562
|
+
en(i * e * r),
|
|
563
|
+
[r, e, i]
|
|
564
|
+
);
|
|
565
|
+
for (let l = 0; l < r; l++)
|
|
566
|
+
for (let p = 0; p < e; p++) {
|
|
567
|
+
const g = p * o, m = l * c, j = Math.max(Math.floor(g), 0), b = Math.min(Math.ceil(g), s - 1), O = Math.max(Math.floor(m), 0), A = Math.min(Math.ceil(m), n - 1), R = g - j, N = m - O;
|
|
568
|
+
for (let I = 0; I < i; I++) {
|
|
569
|
+
const We = t.get(O, j, I), qe = t.get(O, b, I), T = t.get(A, j, I), je = t.get(A, b, I), Se = (1 - R) * (1 - N) * We + R * (1 - N) * qe + (1 - R) * N * T + R * N * je;
|
|
570
|
+
u.set(l, p, I, Se);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
return u;
|
|
574
|
+
}
|
|
575
|
+
function tn(t, e = [128, 128, 128], r = [256, 256, 256]) {
|
|
576
|
+
var a = t.data;
|
|
577
|
+
const [n, s, i] = t.shape, o = n * s, c = new Float32Array(3 * o);
|
|
578
|
+
for (let u = 0, l = 0; u < a.length; u += 4, l += 1)
|
|
579
|
+
c[l] = (a[u] - e[0]) / r[0], c[l + o] = (a[u + 1] - e[1]) / r[1], c[l + o + o] = (a[u + 2] - e[2]) / r[2];
|
|
580
|
+
return (0, lt.default)(c, [1, 3, n, s]);
|
|
581
|
+
}
|
|
582
|
+
async function rn(t, e) {
|
|
583
|
+
return typeof t == "string" && (t = Xa(t, e.publicPath), t = new URL(t)), t instanceof URL && (t = await (await fetch(t, {})).blob()), (t instanceof ArrayBuffer || ArrayBuffer.isView(t)) && (t = new Blob([t])), t instanceof Blob && (t = await Ja(t)), t;
|
|
584
|
+
}
|
|
585
|
+
function an(t) {
|
|
586
|
+
const e = new Uint8Array(t.data.length);
|
|
587
|
+
for (let r = 0; r < t.data.length; r++)
|
|
588
|
+
e[r] = t.data[r] * 255;
|
|
589
|
+
return (0, lt.default)(e, t.shape);
|
|
590
|
+
}
|
|
591
|
+
function Zt(t, e) {
|
|
592
|
+
let r;
|
|
593
|
+
if (typeof OffscreenCanvas < "u" ? r = new OffscreenCanvas(t, e) : r = document.createElement("canvas"), !r)
|
|
594
|
+
throw new Error(
|
|
595
|
+
"Canvas nor OffscreenCanvas are available in the current context."
|
|
596
|
+
);
|
|
597
|
+
return r;
|
|
598
|
+
}
|
|
599
|
+
var nn = Ve(Be()), Rt = async () => navigator.gpu === void 0 ? !1 : await navigator.gpu.requestAdapter() !== null, sn = () => navigator.hardwareConcurrency ?? 4;
|
|
600
|
+
async function yt(t, e) {
|
|
601
|
+
return URL.createObjectURL(await Nt(t, e));
|
|
602
|
+
}
|
|
603
|
+
async function Nt(t, e) {
|
|
604
|
+
const r = new URL("resources.json", e.publicPath), a = await fetch(r);
|
|
605
|
+
if (!a.ok)
|
|
606
|
+
throw new Error(
|
|
607
|
+
"Resource metadata not found. Ensure that the config.publicPath is configured correctly."
|
|
608
|
+
);
|
|
609
|
+
const s = (await a.json())[t];
|
|
610
|
+
if (!s)
|
|
611
|
+
throw new Error(
|
|
612
|
+
`Resource ${t} not found. Ensure that the config.publicPath is configured correctly.`
|
|
613
|
+
);
|
|
614
|
+
const i = s.chunks;
|
|
615
|
+
let o = 0;
|
|
616
|
+
const c = i.map(async (p) => {
|
|
617
|
+
const g = p.offsets[1] - p.offsets[0], m = e.publicPath ? new URL(p.name, e.publicPath).toString() : p.name, b = await (await fetch(m, e.fetchArgs)).blob();
|
|
618
|
+
if (g !== b.size)
|
|
619
|
+
throw new Error(
|
|
620
|
+
`Failed to fetch ${t} with size ${g} but got ${b.size}`
|
|
621
|
+
);
|
|
622
|
+
return e.progress && (o += g, e.progress(`fetch:${t}`, o, s.size)), b;
|
|
623
|
+
}), u = await Promise.all(c), l = new Blob(u, { type: s.mime });
|
|
624
|
+
if (l.size !== s.size)
|
|
625
|
+
throw new Error(
|
|
626
|
+
`Failed to fetch ${t} with size ${s.size} but got ${l.size}`
|
|
627
|
+
);
|
|
628
|
+
return l;
|
|
629
|
+
}
|
|
630
|
+
var ie = null, Pt = async (t) => (ie !== null || (t ? ie = (await import("./ort.webgpu.bundle.min-CAudaHZO.js")).default : ie = (await import("./ort.bundle.min-CreFV8V1.js")).default), ie);
|
|
631
|
+
async function on(t, e) {
|
|
632
|
+
const r = e.device === "gpu" && await Rt(), a = r && e.proxyToWorker, n = [r ? "webgpu" : "wasm"], s = await Pt(r);
|
|
633
|
+
e.debug && (console.debug(" Using WebGPU:", r), console.debug(" Proxy to Worker:", a), s.env.debug = !0, s.env.logLevel = "verbose"), s.env.wasm.numThreads = sn(), s.env.wasm.proxy = a;
|
|
634
|
+
const i = r ? "/onnxruntime-web/ort-wasm-simd-threaded.jsep" : "/onnxruntime-web/ort-wasm-simd-threaded", o = await yt(`${i}.wasm`, e), c = await yt(`${i}.mjs`, e);
|
|
635
|
+
s.env.wasm.wasmPaths = {
|
|
636
|
+
mjs: c,
|
|
637
|
+
wasm: o
|
|
638
|
+
}, e.debug && console.debug("ort.env.wasm:", s.env.wasm);
|
|
639
|
+
const u = {
|
|
640
|
+
executionProviders: n,
|
|
641
|
+
graphOptimizationLevel: "all",
|
|
642
|
+
executionMode: "parallel",
|
|
643
|
+
enableCpuMemArena: !0
|
|
644
|
+
};
|
|
645
|
+
return await s.InferenceSession.create(t, u).catch(
|
|
646
|
+
(p) => {
|
|
647
|
+
throw new Error(
|
|
648
|
+
`Failed to create session: "${p}". Please check if the publicPath is set correctly.`
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
}
|
|
653
|
+
async function cn(t, e, r, a) {
|
|
654
|
+
const n = a.device === "gpu" && await Rt(), s = await Pt(n), i = {};
|
|
655
|
+
for (const [u, l] of e)
|
|
656
|
+
i[u] = new s.Tensor(
|
|
657
|
+
"float32",
|
|
658
|
+
new Float32Array(l.data),
|
|
659
|
+
l.shape
|
|
660
|
+
);
|
|
661
|
+
const o = await t.run(i, {}), c = [];
|
|
662
|
+
for (const u of r) {
|
|
663
|
+
const l = o[u], p = l.dims, g = l.data, m = (0, nn.default)(g, p);
|
|
664
|
+
c.push(m);
|
|
665
|
+
}
|
|
666
|
+
return c;
|
|
667
|
+
}
|
|
668
|
+
var C;
|
|
669
|
+
(function(t) {
|
|
670
|
+
t.assertEqual = (n) => n;
|
|
671
|
+
function e(n) {
|
|
672
|
+
}
|
|
673
|
+
t.assertIs = e;
|
|
674
|
+
function r(n) {
|
|
675
|
+
throw new Error();
|
|
676
|
+
}
|
|
677
|
+
t.assertNever = r, t.arrayToEnum = (n) => {
|
|
678
|
+
const s = {};
|
|
679
|
+
for (const i of n)
|
|
680
|
+
s[i] = i;
|
|
681
|
+
return s;
|
|
682
|
+
}, t.getValidEnumValues = (n) => {
|
|
683
|
+
const s = t.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
684
|
+
for (const o of s)
|
|
685
|
+
i[o] = n[o];
|
|
686
|
+
return t.objectValues(i);
|
|
687
|
+
}, t.objectValues = (n) => t.objectKeys(n).map(function(s) {
|
|
688
|
+
return n[s];
|
|
689
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
690
|
+
const s = [];
|
|
691
|
+
for (const i in n)
|
|
692
|
+
Object.prototype.hasOwnProperty.call(n, i) && s.push(i);
|
|
693
|
+
return s;
|
|
694
|
+
}, t.find = (n, s) => {
|
|
695
|
+
for (const i of n)
|
|
696
|
+
if (s(i))
|
|
697
|
+
return i;
|
|
698
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
699
|
+
function a(n, s = " | ") {
|
|
700
|
+
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(s);
|
|
701
|
+
}
|
|
702
|
+
t.joinValues = a, t.jsonStringifyReplacer = (n, s) => typeof s == "bigint" ? s.toString() : s;
|
|
703
|
+
})(C || (C = {}));
|
|
704
|
+
var Xe;
|
|
705
|
+
(function(t) {
|
|
706
|
+
t.mergeShapes = (e, r) => ({
|
|
707
|
+
...e,
|
|
708
|
+
...r
|
|
709
|
+
// second overwrites first
|
|
710
|
+
});
|
|
711
|
+
})(Xe || (Xe = {}));
|
|
712
|
+
var h = C.arrayToEnum([
|
|
713
|
+
"string",
|
|
714
|
+
"nan",
|
|
715
|
+
"number",
|
|
716
|
+
"integer",
|
|
717
|
+
"float",
|
|
718
|
+
"boolean",
|
|
719
|
+
"date",
|
|
720
|
+
"bigint",
|
|
721
|
+
"symbol",
|
|
722
|
+
"function",
|
|
723
|
+
"undefined",
|
|
724
|
+
"null",
|
|
725
|
+
"array",
|
|
726
|
+
"object",
|
|
727
|
+
"unknown",
|
|
728
|
+
"promise",
|
|
729
|
+
"void",
|
|
730
|
+
"never",
|
|
731
|
+
"map",
|
|
732
|
+
"set"
|
|
733
|
+
]), B = (t) => {
|
|
734
|
+
switch (typeof t) {
|
|
735
|
+
case "undefined":
|
|
736
|
+
return h.undefined;
|
|
737
|
+
case "string":
|
|
738
|
+
return h.string;
|
|
739
|
+
case "number":
|
|
740
|
+
return isNaN(t) ? h.nan : h.number;
|
|
741
|
+
case "boolean":
|
|
742
|
+
return h.boolean;
|
|
743
|
+
case "function":
|
|
744
|
+
return h.function;
|
|
745
|
+
case "bigint":
|
|
746
|
+
return h.bigint;
|
|
747
|
+
case "symbol":
|
|
748
|
+
return h.symbol;
|
|
749
|
+
case "object":
|
|
750
|
+
return Array.isArray(t) ? h.array : t === null ? h.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? h.promise : typeof Map < "u" && t instanceof Map ? h.map : typeof Set < "u" && t instanceof Set ? h.set : typeof Date < "u" && t instanceof Date ? h.date : h.object;
|
|
751
|
+
default:
|
|
752
|
+
return h.unknown;
|
|
753
|
+
}
|
|
754
|
+
}, d = C.arrayToEnum([
|
|
755
|
+
"invalid_type",
|
|
756
|
+
"invalid_literal",
|
|
757
|
+
"custom",
|
|
758
|
+
"invalid_union",
|
|
759
|
+
"invalid_union_discriminator",
|
|
760
|
+
"invalid_enum_value",
|
|
761
|
+
"unrecognized_keys",
|
|
762
|
+
"invalid_arguments",
|
|
763
|
+
"invalid_return_type",
|
|
764
|
+
"invalid_date",
|
|
765
|
+
"invalid_string",
|
|
766
|
+
"too_small",
|
|
767
|
+
"too_big",
|
|
768
|
+
"invalid_intersection_types",
|
|
769
|
+
"not_multiple_of",
|
|
770
|
+
"not_finite"
|
|
771
|
+
]), un = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:"), $ = class Mt extends Error {
|
|
772
|
+
get errors() {
|
|
773
|
+
return this.issues;
|
|
774
|
+
}
|
|
775
|
+
constructor(e) {
|
|
776
|
+
super(), this.issues = [], this.addIssue = (a) => {
|
|
777
|
+
this.issues = [...this.issues, a];
|
|
778
|
+
}, this.addIssues = (a = []) => {
|
|
779
|
+
this.issues = [...this.issues, ...a];
|
|
780
|
+
};
|
|
781
|
+
const r = new.target.prototype;
|
|
782
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
|
|
783
|
+
}
|
|
784
|
+
format(e) {
|
|
785
|
+
const r = e || function(s) {
|
|
786
|
+
return s.message;
|
|
787
|
+
}, a = { _errors: [] }, n = (s) => {
|
|
788
|
+
for (const i of s.issues)
|
|
789
|
+
if (i.code === "invalid_union")
|
|
790
|
+
i.unionErrors.map(n);
|
|
791
|
+
else if (i.code === "invalid_return_type")
|
|
792
|
+
n(i.returnTypeError);
|
|
793
|
+
else if (i.code === "invalid_arguments")
|
|
794
|
+
n(i.argumentsError);
|
|
795
|
+
else if (i.path.length === 0)
|
|
796
|
+
a._errors.push(r(i));
|
|
797
|
+
else {
|
|
798
|
+
let o = a, c = 0;
|
|
799
|
+
for (; c < i.path.length; ) {
|
|
800
|
+
const u = i.path[c];
|
|
801
|
+
c === i.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(r(i))) : o[u] = o[u] || { _errors: [] }, o = o[u], c++;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
return n(this), a;
|
|
806
|
+
}
|
|
807
|
+
static assert(e) {
|
|
808
|
+
if (!(e instanceof Mt))
|
|
809
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
810
|
+
}
|
|
811
|
+
toString() {
|
|
812
|
+
return this.message;
|
|
813
|
+
}
|
|
814
|
+
get message() {
|
|
815
|
+
return JSON.stringify(this.issues, C.jsonStringifyReplacer, 2);
|
|
816
|
+
}
|
|
817
|
+
get isEmpty() {
|
|
818
|
+
return this.issues.length === 0;
|
|
819
|
+
}
|
|
820
|
+
flatten(e = (r) => r.message) {
|
|
821
|
+
const r = {}, a = [];
|
|
822
|
+
for (const n of this.issues)
|
|
823
|
+
n.path.length > 0 ? (r[n.path[0]] = r[n.path[0]] || [], r[n.path[0]].push(e(n))) : a.push(e(n));
|
|
824
|
+
return { formErrors: a, fieldErrors: r };
|
|
825
|
+
}
|
|
826
|
+
get formErrors() {
|
|
827
|
+
return this.flatten();
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
$.create = (t) => new $(t);
|
|
831
|
+
var K = (t, e) => {
|
|
832
|
+
let r;
|
|
833
|
+
switch (t.code) {
|
|
834
|
+
case d.invalid_type:
|
|
835
|
+
t.received === h.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
|
|
836
|
+
break;
|
|
837
|
+
case d.invalid_literal:
|
|
838
|
+
r = `Invalid literal value, expected ${JSON.stringify(t.expected, C.jsonStringifyReplacer)}`;
|
|
839
|
+
break;
|
|
840
|
+
case d.unrecognized_keys:
|
|
841
|
+
r = `Unrecognized key(s) in object: ${C.joinValues(t.keys, ", ")}`;
|
|
842
|
+
break;
|
|
843
|
+
case d.invalid_union:
|
|
844
|
+
r = "Invalid input";
|
|
845
|
+
break;
|
|
846
|
+
case d.invalid_union_discriminator:
|
|
847
|
+
r = `Invalid discriminator value. Expected ${C.joinValues(t.options)}`;
|
|
848
|
+
break;
|
|
849
|
+
case d.invalid_enum_value:
|
|
850
|
+
r = `Invalid enum value. Expected ${C.joinValues(t.options)}, received '${t.received}'`;
|
|
851
|
+
break;
|
|
852
|
+
case d.invalid_arguments:
|
|
853
|
+
r = "Invalid function arguments";
|
|
854
|
+
break;
|
|
855
|
+
case d.invalid_return_type:
|
|
856
|
+
r = "Invalid function return type";
|
|
857
|
+
break;
|
|
858
|
+
case d.invalid_date:
|
|
859
|
+
r = "Invalid date";
|
|
860
|
+
break;
|
|
861
|
+
case d.invalid_string:
|
|
862
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : C.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
|
|
863
|
+
break;
|
|
864
|
+
case d.too_small:
|
|
865
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
|
|
866
|
+
break;
|
|
867
|
+
case d.too_big:
|
|
868
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
|
|
869
|
+
break;
|
|
870
|
+
case d.custom:
|
|
871
|
+
r = "Invalid input";
|
|
872
|
+
break;
|
|
873
|
+
case d.invalid_intersection_types:
|
|
874
|
+
r = "Intersection results could not be merged";
|
|
875
|
+
break;
|
|
876
|
+
case d.not_multiple_of:
|
|
877
|
+
r = `Number must be a multiple of ${t.multipleOf}`;
|
|
878
|
+
break;
|
|
879
|
+
case d.not_finite:
|
|
880
|
+
r = "Number must be finite";
|
|
881
|
+
break;
|
|
882
|
+
default:
|
|
883
|
+
r = e.defaultError, C.assertNever(t);
|
|
884
|
+
}
|
|
885
|
+
return { message: r };
|
|
886
|
+
}, $t = K;
|
|
887
|
+
function dn(t) {
|
|
888
|
+
$t = t;
|
|
889
|
+
}
|
|
890
|
+
function Re() {
|
|
891
|
+
return $t;
|
|
892
|
+
}
|
|
893
|
+
var Ne = (t) => {
|
|
894
|
+
const { data: e, path: r, errorMaps: a, issueData: n } = t, s = [...r, ...n.path || []], i = {
|
|
895
|
+
...n,
|
|
896
|
+
path: s
|
|
897
|
+
};
|
|
898
|
+
if (n.message !== void 0)
|
|
899
|
+
return {
|
|
900
|
+
...n,
|
|
901
|
+
path: s,
|
|
902
|
+
message: n.message
|
|
903
|
+
};
|
|
904
|
+
let o = "";
|
|
905
|
+
const c = a.filter((u) => !!u).slice().reverse();
|
|
906
|
+
for (const u of c)
|
|
907
|
+
o = u(i, { data: e, defaultError: o }).message;
|
|
908
|
+
return {
|
|
909
|
+
...n,
|
|
910
|
+
path: s,
|
|
911
|
+
message: o
|
|
912
|
+
};
|
|
913
|
+
}, ln = [];
|
|
914
|
+
function f(t, e) {
|
|
915
|
+
const r = Re(), a = Ne({
|
|
916
|
+
issueData: e,
|
|
917
|
+
data: t.data,
|
|
918
|
+
path: t.path,
|
|
919
|
+
errorMaps: [
|
|
920
|
+
t.common.contextualErrorMap,
|
|
921
|
+
// contextual error map is first priority
|
|
922
|
+
t.schemaErrorMap,
|
|
923
|
+
// then schema-bound map if available
|
|
924
|
+
r,
|
|
925
|
+
// then global override map
|
|
926
|
+
r === K ? void 0 : K
|
|
927
|
+
// then global default map
|
|
928
|
+
].filter((n) => !!n)
|
|
929
|
+
});
|
|
930
|
+
t.common.issues.push(a);
|
|
931
|
+
}
|
|
932
|
+
var Z = class zt {
|
|
933
|
+
constructor() {
|
|
934
|
+
this.value = "valid";
|
|
935
|
+
}
|
|
936
|
+
dirty() {
|
|
937
|
+
this.value === "valid" && (this.value = "dirty");
|
|
938
|
+
}
|
|
939
|
+
abort() {
|
|
940
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
941
|
+
}
|
|
942
|
+
static mergeArray(e, r) {
|
|
943
|
+
const a = [];
|
|
944
|
+
for (const n of r) {
|
|
945
|
+
if (n.status === "aborted")
|
|
946
|
+
return _;
|
|
947
|
+
n.status === "dirty" && e.dirty(), a.push(n.value);
|
|
948
|
+
}
|
|
949
|
+
return { status: e.value, value: a };
|
|
950
|
+
}
|
|
951
|
+
static async mergeObjectAsync(e, r) {
|
|
952
|
+
const a = [];
|
|
953
|
+
for (const n of r) {
|
|
954
|
+
const s = await n.key, i = await n.value;
|
|
955
|
+
a.push({
|
|
956
|
+
key: s,
|
|
957
|
+
value: i
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return zt.mergeObjectSync(e, a);
|
|
961
|
+
}
|
|
962
|
+
static mergeObjectSync(e, r) {
|
|
963
|
+
const a = {};
|
|
964
|
+
for (const n of r) {
|
|
965
|
+
const { key: s, value: i } = n;
|
|
966
|
+
if (s.status === "aborted" || i.status === "aborted")
|
|
967
|
+
return _;
|
|
968
|
+
s.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), s.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (a[s.value] = i.value);
|
|
969
|
+
}
|
|
970
|
+
return { status: e.value, value: a };
|
|
971
|
+
}
|
|
972
|
+
}, _ = Object.freeze({
|
|
973
|
+
status: "aborted"
|
|
974
|
+
}), Y = (t) => ({ status: "dirty", value: t }), E = (t) => ({ status: "valid", value: t }), Qe = (t) => t.status === "aborted", et = (t) => t.status === "dirty", G = (t) => t.status === "valid", le = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
975
|
+
function Pe(t, e, r, a) {
|
|
976
|
+
if (typeof e == "function" ? t !== e || !0 : !e.has(t))
|
|
977
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
978
|
+
return e.get(t);
|
|
979
|
+
}
|
|
980
|
+
function Dt(t, e, r, a, n) {
|
|
981
|
+
if (typeof e == "function" ? t !== e || !0 : !e.has(t))
|
|
982
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
983
|
+
return e.set(t, r), r;
|
|
984
|
+
}
|
|
985
|
+
var v;
|
|
986
|
+
(function(t) {
|
|
987
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
988
|
+
})(v || (v = {}));
|
|
989
|
+
var oe, ce, U = class {
|
|
990
|
+
constructor(t, e, r, a) {
|
|
991
|
+
this._cachedPath = [], this.parent = t, this.data = e, this._path = r, this._key = a;
|
|
992
|
+
}
|
|
993
|
+
get path() {
|
|
994
|
+
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
995
|
+
}
|
|
996
|
+
}, _t = (t, e) => {
|
|
997
|
+
if (G(e))
|
|
998
|
+
return { success: !0, data: e.value };
|
|
999
|
+
if (!t.common.issues.length)
|
|
1000
|
+
throw new Error("Validation failed but no issues detected.");
|
|
1001
|
+
return {
|
|
1002
|
+
success: !1,
|
|
1003
|
+
get error() {
|
|
1004
|
+
if (this._error)
|
|
1005
|
+
return this._error;
|
|
1006
|
+
const r = new $(t.common.issues);
|
|
1007
|
+
return this._error = r, this._error;
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
function x(t) {
|
|
1012
|
+
if (!t)
|
|
1013
|
+
return {};
|
|
1014
|
+
const { errorMap: e, invalid_type_error: r, required_error: a, description: n } = t;
|
|
1015
|
+
if (e && (r || a))
|
|
1016
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1017
|
+
return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
|
|
1018
|
+
var c, u;
|
|
1019
|
+
const { message: l } = t;
|
|
1020
|
+
return i.code === "invalid_enum_value" ? { message: l ?? o.defaultError } : typeof o.data > "u" ? { message: (c = l ?? a) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (u = l ?? r) !== null && u !== void 0 ? u : o.defaultError };
|
|
1021
|
+
}, description: n };
|
|
1022
|
+
}
|
|
1023
|
+
var k = class {
|
|
1024
|
+
get description() {
|
|
1025
|
+
return this._def.description;
|
|
1026
|
+
}
|
|
1027
|
+
_getType(t) {
|
|
1028
|
+
return B(t.data);
|
|
1029
|
+
}
|
|
1030
|
+
_getOrReturnCtx(t, e) {
|
|
1031
|
+
return e || {
|
|
1032
|
+
common: t.parent.common,
|
|
1033
|
+
data: t.data,
|
|
1034
|
+
parsedType: B(t.data),
|
|
1035
|
+
schemaErrorMap: this._def.errorMap,
|
|
1036
|
+
path: t.path,
|
|
1037
|
+
parent: t.parent
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
_processInputParams(t) {
|
|
1041
|
+
return {
|
|
1042
|
+
status: new Z(),
|
|
1043
|
+
ctx: {
|
|
1044
|
+
common: t.parent.common,
|
|
1045
|
+
data: t.data,
|
|
1046
|
+
parsedType: B(t.data),
|
|
1047
|
+
schemaErrorMap: this._def.errorMap,
|
|
1048
|
+
path: t.path,
|
|
1049
|
+
parent: t.parent
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
}
|
|
1053
|
+
_parseSync(t) {
|
|
1054
|
+
const e = this._parse(t);
|
|
1055
|
+
if (le(e))
|
|
1056
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
1057
|
+
return e;
|
|
1058
|
+
}
|
|
1059
|
+
_parseAsync(t) {
|
|
1060
|
+
const e = this._parse(t);
|
|
1061
|
+
return Promise.resolve(e);
|
|
1062
|
+
}
|
|
1063
|
+
parse(t, e) {
|
|
1064
|
+
const r = this.safeParse(t, e);
|
|
1065
|
+
if (r.success)
|
|
1066
|
+
return r.data;
|
|
1067
|
+
throw r.error;
|
|
1068
|
+
}
|
|
1069
|
+
safeParse(t, e) {
|
|
1070
|
+
var r;
|
|
1071
|
+
const a = {
|
|
1072
|
+
common: {
|
|
1073
|
+
issues: [],
|
|
1074
|
+
async: (r = e?.async) !== null && r !== void 0 ? r : !1,
|
|
1075
|
+
contextualErrorMap: e?.errorMap
|
|
1076
|
+
},
|
|
1077
|
+
path: e?.path || [],
|
|
1078
|
+
schemaErrorMap: this._def.errorMap,
|
|
1079
|
+
parent: null,
|
|
1080
|
+
data: t,
|
|
1081
|
+
parsedType: B(t)
|
|
1082
|
+
}, n = this._parseSync({ data: t, path: a.path, parent: a });
|
|
1083
|
+
return _t(a, n);
|
|
1084
|
+
}
|
|
1085
|
+
"~validate"(t) {
|
|
1086
|
+
var e, r;
|
|
1087
|
+
const a = {
|
|
1088
|
+
common: {
|
|
1089
|
+
issues: [],
|
|
1090
|
+
async: !!this["~standard"].async
|
|
1091
|
+
},
|
|
1092
|
+
path: [],
|
|
1093
|
+
schemaErrorMap: this._def.errorMap,
|
|
1094
|
+
parent: null,
|
|
1095
|
+
data: t,
|
|
1096
|
+
parsedType: B(t)
|
|
1097
|
+
};
|
|
1098
|
+
if (!this["~standard"].async)
|
|
1099
|
+
try {
|
|
1100
|
+
const n = this._parseSync({ data: t, path: [], parent: a });
|
|
1101
|
+
return G(n) ? {
|
|
1102
|
+
value: n.value
|
|
1103
|
+
} : {
|
|
1104
|
+
issues: a.common.issues
|
|
1105
|
+
};
|
|
1106
|
+
} catch (n) {
|
|
1107
|
+
!((r = (e = n?.message) === null || e === void 0 ? void 0 : e.toLowerCase()) === null || r === void 0) && r.includes("encountered") && (this["~standard"].async = !0), a.common = {
|
|
1108
|
+
issues: [],
|
|
1109
|
+
async: !0
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
return this._parseAsync({ data: t, path: [], parent: a }).then((n) => G(n) ? {
|
|
1113
|
+
value: n.value
|
|
1114
|
+
} : {
|
|
1115
|
+
issues: a.common.issues
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
async parseAsync(t, e) {
|
|
1119
|
+
const r = await this.safeParseAsync(t, e);
|
|
1120
|
+
if (r.success)
|
|
1121
|
+
return r.data;
|
|
1122
|
+
throw r.error;
|
|
1123
|
+
}
|
|
1124
|
+
async safeParseAsync(t, e) {
|
|
1125
|
+
const r = {
|
|
1126
|
+
common: {
|
|
1127
|
+
issues: [],
|
|
1128
|
+
contextualErrorMap: e?.errorMap,
|
|
1129
|
+
async: !0
|
|
1130
|
+
},
|
|
1131
|
+
path: e?.path || [],
|
|
1132
|
+
schemaErrorMap: this._def.errorMap,
|
|
1133
|
+
parent: null,
|
|
1134
|
+
data: t,
|
|
1135
|
+
parsedType: B(t)
|
|
1136
|
+
}, a = this._parse({ data: t, path: r.path, parent: r }), n = await (le(a) ? a : Promise.resolve(a));
|
|
1137
|
+
return _t(r, n);
|
|
1138
|
+
}
|
|
1139
|
+
refine(t, e) {
|
|
1140
|
+
const r = (a) => typeof e == "string" || typeof e > "u" ? { message: e } : typeof e == "function" ? e(a) : e;
|
|
1141
|
+
return this._refinement((a, n) => {
|
|
1142
|
+
const s = t(a), i = () => n.addIssue({
|
|
1143
|
+
code: d.custom,
|
|
1144
|
+
...r(a)
|
|
1145
|
+
});
|
|
1146
|
+
return typeof Promise < "u" && s instanceof Promise ? s.then((o) => o ? !0 : (i(), !1)) : s ? !0 : (i(), !1);
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
refinement(t, e) {
|
|
1150
|
+
return this._refinement((r, a) => t(r) ? !0 : (a.addIssue(typeof e == "function" ? e(r, a) : e), !1));
|
|
1151
|
+
}
|
|
1152
|
+
_refinement(t) {
|
|
1153
|
+
return new z({
|
|
1154
|
+
schema: this,
|
|
1155
|
+
typeName: y.ZodEffects,
|
|
1156
|
+
effect: { type: "refinement", refinement: t }
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
superRefine(t) {
|
|
1160
|
+
return this._refinement(t);
|
|
1161
|
+
}
|
|
1162
|
+
constructor(t) {
|
|
1163
|
+
this.spa = this.safeParseAsync, this._def = t, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
1164
|
+
version: 1,
|
|
1165
|
+
vendor: "zod",
|
|
1166
|
+
validate: (e) => this["~validate"](e)
|
|
1167
|
+
};
|
|
1168
|
+
}
|
|
1169
|
+
optional() {
|
|
1170
|
+
return D.create(this, this._def);
|
|
1171
|
+
}
|
|
1172
|
+
nullable() {
|
|
1173
|
+
return W.create(this, this._def);
|
|
1174
|
+
}
|
|
1175
|
+
nullish() {
|
|
1176
|
+
return this.nullable().optional();
|
|
1177
|
+
}
|
|
1178
|
+
array() {
|
|
1179
|
+
return H.create(this);
|
|
1180
|
+
}
|
|
1181
|
+
promise() {
|
|
1182
|
+
return ee.create(this, this._def);
|
|
1183
|
+
}
|
|
1184
|
+
or(t) {
|
|
1185
|
+
return ye.create([this, t], this._def);
|
|
1186
|
+
}
|
|
1187
|
+
and(t) {
|
|
1188
|
+
return _e.create(this, t, this._def);
|
|
1189
|
+
}
|
|
1190
|
+
transform(t) {
|
|
1191
|
+
return new z({
|
|
1192
|
+
...x(this._def),
|
|
1193
|
+
schema: this,
|
|
1194
|
+
typeName: y.ZodEffects,
|
|
1195
|
+
effect: { type: "transform", transform: t }
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
default(t) {
|
|
1199
|
+
const e = typeof t == "function" ? t : () => t;
|
|
1200
|
+
return new ke({
|
|
1201
|
+
...x(this._def),
|
|
1202
|
+
innerType: this,
|
|
1203
|
+
defaultValue: e,
|
|
1204
|
+
typeName: y.ZodDefault
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
brand() {
|
|
1208
|
+
return new ft({
|
|
1209
|
+
typeName: y.ZodBranded,
|
|
1210
|
+
type: this,
|
|
1211
|
+
...x(this._def)
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
catch(t) {
|
|
1215
|
+
const e = typeof t == "function" ? t : () => t;
|
|
1216
|
+
return new Te({
|
|
1217
|
+
...x(this._def),
|
|
1218
|
+
innerType: this,
|
|
1219
|
+
catchValue: e,
|
|
1220
|
+
typeName: y.ZodCatch
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
describe(t) {
|
|
1224
|
+
const e = this.constructor;
|
|
1225
|
+
return new e({
|
|
1226
|
+
...this._def,
|
|
1227
|
+
description: t
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
pipe(t) {
|
|
1231
|
+
return ht.create(this, t);
|
|
1232
|
+
}
|
|
1233
|
+
readonly() {
|
|
1234
|
+
return Ce.create(this);
|
|
1235
|
+
}
|
|
1236
|
+
isOptional() {
|
|
1237
|
+
return this.safeParse(void 0).success;
|
|
1238
|
+
}
|
|
1239
|
+
isNullable() {
|
|
1240
|
+
return this.safeParse(null).success;
|
|
1241
|
+
}
|
|
1242
|
+
}, fn = /^c[^\s-]{8,}$/i, hn = /^[0-9a-z]+$/, pn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, mn = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, vn = /^[a-z0-9_-]{21}$/i, gn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, yn = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, _n = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, bn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", Je, wn = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, xn = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, kn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Tn = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Cn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, On = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ut = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", jn = new RegExp(`^${Ut}$`);
|
|
1243
|
+
function Vt(t) {
|
|
1244
|
+
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
1245
|
+
return t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
1246
|
+
}
|
|
1247
|
+
function Sn(t) {
|
|
1248
|
+
return new RegExp(`^${Vt(t)}$`);
|
|
1249
|
+
}
|
|
1250
|
+
function Bt(t) {
|
|
1251
|
+
let e = `${Ut}T${Vt(t)}`;
|
|
1252
|
+
const r = [];
|
|
1253
|
+
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
|
|
1254
|
+
}
|
|
1255
|
+
function An(t, e) {
|
|
1256
|
+
return !!((e === "v4" || !e) && wn.test(t) || (e === "v6" || !e) && kn.test(t));
|
|
1257
|
+
}
|
|
1258
|
+
function En(t, e) {
|
|
1259
|
+
if (!gn.test(t))
|
|
1260
|
+
return !1;
|
|
1261
|
+
try {
|
|
1262
|
+
const [r] = t.split("."), a = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), n = JSON.parse(atob(a));
|
|
1263
|
+
return !(typeof n != "object" || n === null || !n.typ || !n.alg || e && n.alg !== e);
|
|
1264
|
+
} catch {
|
|
1265
|
+
return !1;
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
function In(t, e) {
|
|
1269
|
+
return !!((e === "v4" || !e) && xn.test(t) || (e === "v6" || !e) && Tn.test(t));
|
|
1270
|
+
}
|
|
1271
|
+
var X = class ue extends k {
|
|
1272
|
+
_parse(e) {
|
|
1273
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
1274
|
+
const s = this._getOrReturnCtx(e);
|
|
1275
|
+
return f(s, {
|
|
1276
|
+
code: d.invalid_type,
|
|
1277
|
+
expected: h.string,
|
|
1278
|
+
received: s.parsedType
|
|
1279
|
+
}), _;
|
|
1280
|
+
}
|
|
1281
|
+
const a = new Z();
|
|
1282
|
+
let n;
|
|
1283
|
+
for (const s of this._def.checks)
|
|
1284
|
+
if (s.kind === "min")
|
|
1285
|
+
e.data.length < s.value && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1286
|
+
code: d.too_small,
|
|
1287
|
+
minimum: s.value,
|
|
1288
|
+
type: "string",
|
|
1289
|
+
inclusive: !0,
|
|
1290
|
+
exact: !1,
|
|
1291
|
+
message: s.message
|
|
1292
|
+
}), a.dirty());
|
|
1293
|
+
else if (s.kind === "max")
|
|
1294
|
+
e.data.length > s.value && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1295
|
+
code: d.too_big,
|
|
1296
|
+
maximum: s.value,
|
|
1297
|
+
type: "string",
|
|
1298
|
+
inclusive: !0,
|
|
1299
|
+
exact: !1,
|
|
1300
|
+
message: s.message
|
|
1301
|
+
}), a.dirty());
|
|
1302
|
+
else if (s.kind === "length") {
|
|
1303
|
+
const i = e.data.length > s.value, o = e.data.length < s.value;
|
|
1304
|
+
(i || o) && (n = this._getOrReturnCtx(e, n), i ? f(n, {
|
|
1305
|
+
code: d.too_big,
|
|
1306
|
+
maximum: s.value,
|
|
1307
|
+
type: "string",
|
|
1308
|
+
inclusive: !0,
|
|
1309
|
+
exact: !0,
|
|
1310
|
+
message: s.message
|
|
1311
|
+
}) : o && f(n, {
|
|
1312
|
+
code: d.too_small,
|
|
1313
|
+
minimum: s.value,
|
|
1314
|
+
type: "string",
|
|
1315
|
+
inclusive: !0,
|
|
1316
|
+
exact: !0,
|
|
1317
|
+
message: s.message
|
|
1318
|
+
}), a.dirty());
|
|
1319
|
+
} else if (s.kind === "email")
|
|
1320
|
+
_n.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1321
|
+
validation: "email",
|
|
1322
|
+
code: d.invalid_string,
|
|
1323
|
+
message: s.message
|
|
1324
|
+
}), a.dirty());
|
|
1325
|
+
else if (s.kind === "emoji")
|
|
1326
|
+
Je || (Je = new RegExp(bn, "u")), Je.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1327
|
+
validation: "emoji",
|
|
1328
|
+
code: d.invalid_string,
|
|
1329
|
+
message: s.message
|
|
1330
|
+
}), a.dirty());
|
|
1331
|
+
else if (s.kind === "uuid")
|
|
1332
|
+
mn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1333
|
+
validation: "uuid",
|
|
1334
|
+
code: d.invalid_string,
|
|
1335
|
+
message: s.message
|
|
1336
|
+
}), a.dirty());
|
|
1337
|
+
else if (s.kind === "nanoid")
|
|
1338
|
+
vn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1339
|
+
validation: "nanoid",
|
|
1340
|
+
code: d.invalid_string,
|
|
1341
|
+
message: s.message
|
|
1342
|
+
}), a.dirty());
|
|
1343
|
+
else if (s.kind === "cuid")
|
|
1344
|
+
fn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1345
|
+
validation: "cuid",
|
|
1346
|
+
code: d.invalid_string,
|
|
1347
|
+
message: s.message
|
|
1348
|
+
}), a.dirty());
|
|
1349
|
+
else if (s.kind === "cuid2")
|
|
1350
|
+
hn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1351
|
+
validation: "cuid2",
|
|
1352
|
+
code: d.invalid_string,
|
|
1353
|
+
message: s.message
|
|
1354
|
+
}), a.dirty());
|
|
1355
|
+
else if (s.kind === "ulid")
|
|
1356
|
+
pn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1357
|
+
validation: "ulid",
|
|
1358
|
+
code: d.invalid_string,
|
|
1359
|
+
message: s.message
|
|
1360
|
+
}), a.dirty());
|
|
1361
|
+
else if (s.kind === "url")
|
|
1362
|
+
try {
|
|
1363
|
+
new URL(e.data);
|
|
1364
|
+
} catch {
|
|
1365
|
+
n = this._getOrReturnCtx(e, n), f(n, {
|
|
1366
|
+
validation: "url",
|
|
1367
|
+
code: d.invalid_string,
|
|
1368
|
+
message: s.message
|
|
1369
|
+
}), a.dirty();
|
|
1370
|
+
}
|
|
1371
|
+
else s.kind === "regex" ? (s.regex.lastIndex = 0, s.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1372
|
+
validation: "regex",
|
|
1373
|
+
code: d.invalid_string,
|
|
1374
|
+
message: s.message
|
|
1375
|
+
}), a.dirty())) : s.kind === "trim" ? e.data = e.data.trim() : s.kind === "includes" ? e.data.includes(s.value, s.position) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1376
|
+
code: d.invalid_string,
|
|
1377
|
+
validation: { includes: s.value, position: s.position },
|
|
1378
|
+
message: s.message
|
|
1379
|
+
}), a.dirty()) : s.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : s.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : s.kind === "startsWith" ? e.data.startsWith(s.value) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1380
|
+
code: d.invalid_string,
|
|
1381
|
+
validation: { startsWith: s.value },
|
|
1382
|
+
message: s.message
|
|
1383
|
+
}), a.dirty()) : s.kind === "endsWith" ? e.data.endsWith(s.value) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1384
|
+
code: d.invalid_string,
|
|
1385
|
+
validation: { endsWith: s.value },
|
|
1386
|
+
message: s.message
|
|
1387
|
+
}), a.dirty()) : s.kind === "datetime" ? Bt(s).test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1388
|
+
code: d.invalid_string,
|
|
1389
|
+
validation: "datetime",
|
|
1390
|
+
message: s.message
|
|
1391
|
+
}), a.dirty()) : s.kind === "date" ? jn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1392
|
+
code: d.invalid_string,
|
|
1393
|
+
validation: "date",
|
|
1394
|
+
message: s.message
|
|
1395
|
+
}), a.dirty()) : s.kind === "time" ? Sn(s).test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1396
|
+
code: d.invalid_string,
|
|
1397
|
+
validation: "time",
|
|
1398
|
+
message: s.message
|
|
1399
|
+
}), a.dirty()) : s.kind === "duration" ? yn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1400
|
+
validation: "duration",
|
|
1401
|
+
code: d.invalid_string,
|
|
1402
|
+
message: s.message
|
|
1403
|
+
}), a.dirty()) : s.kind === "ip" ? An(e.data, s.version) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1404
|
+
validation: "ip",
|
|
1405
|
+
code: d.invalid_string,
|
|
1406
|
+
message: s.message
|
|
1407
|
+
}), a.dirty()) : s.kind === "jwt" ? En(e.data, s.alg) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1408
|
+
validation: "jwt",
|
|
1409
|
+
code: d.invalid_string,
|
|
1410
|
+
message: s.message
|
|
1411
|
+
}), a.dirty()) : s.kind === "cidr" ? In(e.data, s.version) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1412
|
+
validation: "cidr",
|
|
1413
|
+
code: d.invalid_string,
|
|
1414
|
+
message: s.message
|
|
1415
|
+
}), a.dirty()) : s.kind === "base64" ? Cn.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1416
|
+
validation: "base64",
|
|
1417
|
+
code: d.invalid_string,
|
|
1418
|
+
message: s.message
|
|
1419
|
+
}), a.dirty()) : s.kind === "base64url" ? On.test(e.data) || (n = this._getOrReturnCtx(e, n), f(n, {
|
|
1420
|
+
validation: "base64url",
|
|
1421
|
+
code: d.invalid_string,
|
|
1422
|
+
message: s.message
|
|
1423
|
+
}), a.dirty()) : C.assertNever(s);
|
|
1424
|
+
return { status: a.value, value: e.data };
|
|
1425
|
+
}
|
|
1426
|
+
_regex(e, r, a) {
|
|
1427
|
+
return this.refinement((n) => e.test(n), {
|
|
1428
|
+
validation: r,
|
|
1429
|
+
code: d.invalid_string,
|
|
1430
|
+
...v.errToObj(a)
|
|
1431
|
+
});
|
|
1432
|
+
}
|
|
1433
|
+
_addCheck(e) {
|
|
1434
|
+
return new ue({
|
|
1435
|
+
...this._def,
|
|
1436
|
+
checks: [...this._def.checks, e]
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
email(e) {
|
|
1440
|
+
return this._addCheck({ kind: "email", ...v.errToObj(e) });
|
|
1441
|
+
}
|
|
1442
|
+
url(e) {
|
|
1443
|
+
return this._addCheck({ kind: "url", ...v.errToObj(e) });
|
|
1444
|
+
}
|
|
1445
|
+
emoji(e) {
|
|
1446
|
+
return this._addCheck({ kind: "emoji", ...v.errToObj(e) });
|
|
1447
|
+
}
|
|
1448
|
+
uuid(e) {
|
|
1449
|
+
return this._addCheck({ kind: "uuid", ...v.errToObj(e) });
|
|
1450
|
+
}
|
|
1451
|
+
nanoid(e) {
|
|
1452
|
+
return this._addCheck({ kind: "nanoid", ...v.errToObj(e) });
|
|
1453
|
+
}
|
|
1454
|
+
cuid(e) {
|
|
1455
|
+
return this._addCheck({ kind: "cuid", ...v.errToObj(e) });
|
|
1456
|
+
}
|
|
1457
|
+
cuid2(e) {
|
|
1458
|
+
return this._addCheck({ kind: "cuid2", ...v.errToObj(e) });
|
|
1459
|
+
}
|
|
1460
|
+
ulid(e) {
|
|
1461
|
+
return this._addCheck({ kind: "ulid", ...v.errToObj(e) });
|
|
1462
|
+
}
|
|
1463
|
+
base64(e) {
|
|
1464
|
+
return this._addCheck({ kind: "base64", ...v.errToObj(e) });
|
|
1465
|
+
}
|
|
1466
|
+
base64url(e) {
|
|
1467
|
+
return this._addCheck({
|
|
1468
|
+
kind: "base64url",
|
|
1469
|
+
...v.errToObj(e)
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
jwt(e) {
|
|
1473
|
+
return this._addCheck({ kind: "jwt", ...v.errToObj(e) });
|
|
1474
|
+
}
|
|
1475
|
+
ip(e) {
|
|
1476
|
+
return this._addCheck({ kind: "ip", ...v.errToObj(e) });
|
|
1477
|
+
}
|
|
1478
|
+
cidr(e) {
|
|
1479
|
+
return this._addCheck({ kind: "cidr", ...v.errToObj(e) });
|
|
1480
|
+
}
|
|
1481
|
+
datetime(e) {
|
|
1482
|
+
var r, a;
|
|
1483
|
+
return typeof e == "string" ? this._addCheck({
|
|
1484
|
+
kind: "datetime",
|
|
1485
|
+
precision: null,
|
|
1486
|
+
offset: !1,
|
|
1487
|
+
local: !1,
|
|
1488
|
+
message: e
|
|
1489
|
+
}) : this._addCheck({
|
|
1490
|
+
kind: "datetime",
|
|
1491
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1492
|
+
offset: (r = e?.offset) !== null && r !== void 0 ? r : !1,
|
|
1493
|
+
local: (a = e?.local) !== null && a !== void 0 ? a : !1,
|
|
1494
|
+
...v.errToObj(e?.message)
|
|
1495
|
+
});
|
|
1496
|
+
}
|
|
1497
|
+
date(e) {
|
|
1498
|
+
return this._addCheck({ kind: "date", message: e });
|
|
1499
|
+
}
|
|
1500
|
+
time(e) {
|
|
1501
|
+
return typeof e == "string" ? this._addCheck({
|
|
1502
|
+
kind: "time",
|
|
1503
|
+
precision: null,
|
|
1504
|
+
message: e
|
|
1505
|
+
}) : this._addCheck({
|
|
1506
|
+
kind: "time",
|
|
1507
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
1508
|
+
...v.errToObj(e?.message)
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
duration(e) {
|
|
1512
|
+
return this._addCheck({ kind: "duration", ...v.errToObj(e) });
|
|
1513
|
+
}
|
|
1514
|
+
regex(e, r) {
|
|
1515
|
+
return this._addCheck({
|
|
1516
|
+
kind: "regex",
|
|
1517
|
+
regex: e,
|
|
1518
|
+
...v.errToObj(r)
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
includes(e, r) {
|
|
1522
|
+
return this._addCheck({
|
|
1523
|
+
kind: "includes",
|
|
1524
|
+
value: e,
|
|
1525
|
+
position: r?.position,
|
|
1526
|
+
...v.errToObj(r?.message)
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
startsWith(e, r) {
|
|
1530
|
+
return this._addCheck({
|
|
1531
|
+
kind: "startsWith",
|
|
1532
|
+
value: e,
|
|
1533
|
+
...v.errToObj(r)
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
endsWith(e, r) {
|
|
1537
|
+
return this._addCheck({
|
|
1538
|
+
kind: "endsWith",
|
|
1539
|
+
value: e,
|
|
1540
|
+
...v.errToObj(r)
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
min(e, r) {
|
|
1544
|
+
return this._addCheck({
|
|
1545
|
+
kind: "min",
|
|
1546
|
+
value: e,
|
|
1547
|
+
...v.errToObj(r)
|
|
1548
|
+
});
|
|
1549
|
+
}
|
|
1550
|
+
max(e, r) {
|
|
1551
|
+
return this._addCheck({
|
|
1552
|
+
kind: "max",
|
|
1553
|
+
value: e,
|
|
1554
|
+
...v.errToObj(r)
|
|
1555
|
+
});
|
|
1556
|
+
}
|
|
1557
|
+
length(e, r) {
|
|
1558
|
+
return this._addCheck({
|
|
1559
|
+
kind: "length",
|
|
1560
|
+
value: e,
|
|
1561
|
+
...v.errToObj(r)
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
/**
|
|
1565
|
+
* Equivalent to `.min(1)`
|
|
1566
|
+
*/
|
|
1567
|
+
nonempty(e) {
|
|
1568
|
+
return this.min(1, v.errToObj(e));
|
|
1569
|
+
}
|
|
1570
|
+
trim() {
|
|
1571
|
+
return new ue({
|
|
1572
|
+
...this._def,
|
|
1573
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1574
|
+
});
|
|
1575
|
+
}
|
|
1576
|
+
toLowerCase() {
|
|
1577
|
+
return new ue({
|
|
1578
|
+
...this._def,
|
|
1579
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
toUpperCase() {
|
|
1583
|
+
return new ue({
|
|
1584
|
+
...this._def,
|
|
1585
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
get isDatetime() {
|
|
1589
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1590
|
+
}
|
|
1591
|
+
get isDate() {
|
|
1592
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1593
|
+
}
|
|
1594
|
+
get isTime() {
|
|
1595
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1596
|
+
}
|
|
1597
|
+
get isDuration() {
|
|
1598
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1599
|
+
}
|
|
1600
|
+
get isEmail() {
|
|
1601
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1602
|
+
}
|
|
1603
|
+
get isURL() {
|
|
1604
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1605
|
+
}
|
|
1606
|
+
get isEmoji() {
|
|
1607
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1608
|
+
}
|
|
1609
|
+
get isUUID() {
|
|
1610
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1611
|
+
}
|
|
1612
|
+
get isNANOID() {
|
|
1613
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1614
|
+
}
|
|
1615
|
+
get isCUID() {
|
|
1616
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1617
|
+
}
|
|
1618
|
+
get isCUID2() {
|
|
1619
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1620
|
+
}
|
|
1621
|
+
get isULID() {
|
|
1622
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1623
|
+
}
|
|
1624
|
+
get isIP() {
|
|
1625
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1626
|
+
}
|
|
1627
|
+
get isCIDR() {
|
|
1628
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1629
|
+
}
|
|
1630
|
+
get isBase64() {
|
|
1631
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1632
|
+
}
|
|
1633
|
+
get isBase64url() {
|
|
1634
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1635
|
+
}
|
|
1636
|
+
get minLength() {
|
|
1637
|
+
let e = null;
|
|
1638
|
+
for (const r of this._def.checks)
|
|
1639
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1640
|
+
return e;
|
|
1641
|
+
}
|
|
1642
|
+
get maxLength() {
|
|
1643
|
+
let e = null;
|
|
1644
|
+
for (const r of this._def.checks)
|
|
1645
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1646
|
+
return e;
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
X.create = (t) => {
|
|
1650
|
+
var e;
|
|
1651
|
+
return new X({
|
|
1652
|
+
checks: [],
|
|
1653
|
+
typeName: y.ZodString,
|
|
1654
|
+
coerce: (e = t?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1655
|
+
...x(t)
|
|
1656
|
+
});
|
|
1657
|
+
};
|
|
1658
|
+
function Zn(t, e) {
|
|
1659
|
+
const r = (t.toString().split(".")[1] || "").length, a = (e.toString().split(".")[1] || "").length, n = r > a ? r : a, s = parseInt(t.toFixed(n).replace(".", "")), i = parseInt(e.toFixed(n).replace(".", ""));
|
|
1660
|
+
return s % i / Math.pow(10, n);
|
|
1661
|
+
}
|
|
1662
|
+
var fe = class tt extends k {
|
|
1663
|
+
constructor() {
|
|
1664
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1665
|
+
}
|
|
1666
|
+
_parse(e) {
|
|
1667
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1668
|
+
const s = this._getOrReturnCtx(e);
|
|
1669
|
+
return f(s, {
|
|
1670
|
+
code: d.invalid_type,
|
|
1671
|
+
expected: h.number,
|
|
1672
|
+
received: s.parsedType
|
|
1673
|
+
}), _;
|
|
1674
|
+
}
|
|
1675
|
+
let a;
|
|
1676
|
+
const n = new Z();
|
|
1677
|
+
for (const s of this._def.checks)
|
|
1678
|
+
s.kind === "int" ? C.isInteger(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1679
|
+
code: d.invalid_type,
|
|
1680
|
+
expected: "integer",
|
|
1681
|
+
received: "float",
|
|
1682
|
+
message: s.message
|
|
1683
|
+
}), n.dirty()) : s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1684
|
+
code: d.too_small,
|
|
1685
|
+
minimum: s.value,
|
|
1686
|
+
type: "number",
|
|
1687
|
+
inclusive: s.inclusive,
|
|
1688
|
+
exact: !1,
|
|
1689
|
+
message: s.message
|
|
1690
|
+
}), n.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1691
|
+
code: d.too_big,
|
|
1692
|
+
maximum: s.value,
|
|
1693
|
+
type: "number",
|
|
1694
|
+
inclusive: s.inclusive,
|
|
1695
|
+
exact: !1,
|
|
1696
|
+
message: s.message
|
|
1697
|
+
}), n.dirty()) : s.kind === "multipleOf" ? Zn(e.data, s.value) !== 0 && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1698
|
+
code: d.not_multiple_of,
|
|
1699
|
+
multipleOf: s.value,
|
|
1700
|
+
message: s.message
|
|
1701
|
+
}), n.dirty()) : s.kind === "finite" ? Number.isFinite(e.data) || (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1702
|
+
code: d.not_finite,
|
|
1703
|
+
message: s.message
|
|
1704
|
+
}), n.dirty()) : C.assertNever(s);
|
|
1705
|
+
return { status: n.value, value: e.data };
|
|
1706
|
+
}
|
|
1707
|
+
gte(e, r) {
|
|
1708
|
+
return this.setLimit("min", e, !0, v.toString(r));
|
|
1709
|
+
}
|
|
1710
|
+
gt(e, r) {
|
|
1711
|
+
return this.setLimit("min", e, !1, v.toString(r));
|
|
1712
|
+
}
|
|
1713
|
+
lte(e, r) {
|
|
1714
|
+
return this.setLimit("max", e, !0, v.toString(r));
|
|
1715
|
+
}
|
|
1716
|
+
lt(e, r) {
|
|
1717
|
+
return this.setLimit("max", e, !1, v.toString(r));
|
|
1718
|
+
}
|
|
1719
|
+
setLimit(e, r, a, n) {
|
|
1720
|
+
return new tt({
|
|
1721
|
+
...this._def,
|
|
1722
|
+
checks: [
|
|
1723
|
+
...this._def.checks,
|
|
1724
|
+
{
|
|
1725
|
+
kind: e,
|
|
1726
|
+
value: r,
|
|
1727
|
+
inclusive: a,
|
|
1728
|
+
message: v.toString(n)
|
|
1729
|
+
}
|
|
1730
|
+
]
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
_addCheck(e) {
|
|
1734
|
+
return new tt({
|
|
1735
|
+
...this._def,
|
|
1736
|
+
checks: [...this._def.checks, e]
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
int(e) {
|
|
1740
|
+
return this._addCheck({
|
|
1741
|
+
kind: "int",
|
|
1742
|
+
message: v.toString(e)
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
positive(e) {
|
|
1746
|
+
return this._addCheck({
|
|
1747
|
+
kind: "min",
|
|
1748
|
+
value: 0,
|
|
1749
|
+
inclusive: !1,
|
|
1750
|
+
message: v.toString(e)
|
|
1751
|
+
});
|
|
1752
|
+
}
|
|
1753
|
+
negative(e) {
|
|
1754
|
+
return this._addCheck({
|
|
1755
|
+
kind: "max",
|
|
1756
|
+
value: 0,
|
|
1757
|
+
inclusive: !1,
|
|
1758
|
+
message: v.toString(e)
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
nonpositive(e) {
|
|
1762
|
+
return this._addCheck({
|
|
1763
|
+
kind: "max",
|
|
1764
|
+
value: 0,
|
|
1765
|
+
inclusive: !0,
|
|
1766
|
+
message: v.toString(e)
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
nonnegative(e) {
|
|
1770
|
+
return this._addCheck({
|
|
1771
|
+
kind: "min",
|
|
1772
|
+
value: 0,
|
|
1773
|
+
inclusive: !0,
|
|
1774
|
+
message: v.toString(e)
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
multipleOf(e, r) {
|
|
1778
|
+
return this._addCheck({
|
|
1779
|
+
kind: "multipleOf",
|
|
1780
|
+
value: e,
|
|
1781
|
+
message: v.toString(r)
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
finite(e) {
|
|
1785
|
+
return this._addCheck({
|
|
1786
|
+
kind: "finite",
|
|
1787
|
+
message: v.toString(e)
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
safe(e) {
|
|
1791
|
+
return this._addCheck({
|
|
1792
|
+
kind: "min",
|
|
1793
|
+
inclusive: !0,
|
|
1794
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1795
|
+
message: v.toString(e)
|
|
1796
|
+
})._addCheck({
|
|
1797
|
+
kind: "max",
|
|
1798
|
+
inclusive: !0,
|
|
1799
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1800
|
+
message: v.toString(e)
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
get minValue() {
|
|
1804
|
+
let e = null;
|
|
1805
|
+
for (const r of this._def.checks)
|
|
1806
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1807
|
+
return e;
|
|
1808
|
+
}
|
|
1809
|
+
get maxValue() {
|
|
1810
|
+
let e = null;
|
|
1811
|
+
for (const r of this._def.checks)
|
|
1812
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1813
|
+
return e;
|
|
1814
|
+
}
|
|
1815
|
+
get isInt() {
|
|
1816
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && C.isInteger(e.value));
|
|
1817
|
+
}
|
|
1818
|
+
get isFinite() {
|
|
1819
|
+
let e = null, r = null;
|
|
1820
|
+
for (const a of this._def.checks) {
|
|
1821
|
+
if (a.kind === "finite" || a.kind === "int" || a.kind === "multipleOf")
|
|
1822
|
+
return !0;
|
|
1823
|
+
a.kind === "min" ? (r === null || a.value > r) && (r = a.value) : a.kind === "max" && (e === null || a.value < e) && (e = a.value);
|
|
1824
|
+
}
|
|
1825
|
+
return Number.isFinite(r) && Number.isFinite(e);
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
fe.create = (t) => new fe({
|
|
1829
|
+
checks: [],
|
|
1830
|
+
typeName: y.ZodNumber,
|
|
1831
|
+
coerce: t?.coerce || !1,
|
|
1832
|
+
...x(t)
|
|
1833
|
+
});
|
|
1834
|
+
var he = class rt extends k {
|
|
1835
|
+
constructor() {
|
|
1836
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1837
|
+
}
|
|
1838
|
+
_parse(e) {
|
|
1839
|
+
if (this._def.coerce)
|
|
1840
|
+
try {
|
|
1841
|
+
e.data = BigInt(e.data);
|
|
1842
|
+
} catch {
|
|
1843
|
+
return this._getInvalidInput(e);
|
|
1844
|
+
}
|
|
1845
|
+
if (this._getType(e) !== h.bigint)
|
|
1846
|
+
return this._getInvalidInput(e);
|
|
1847
|
+
let a;
|
|
1848
|
+
const n = new Z();
|
|
1849
|
+
for (const s of this._def.checks)
|
|
1850
|
+
s.kind === "min" ? (s.inclusive ? e.data < s.value : e.data <= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1851
|
+
code: d.too_small,
|
|
1852
|
+
type: "bigint",
|
|
1853
|
+
minimum: s.value,
|
|
1854
|
+
inclusive: s.inclusive,
|
|
1855
|
+
message: s.message
|
|
1856
|
+
}), n.dirty()) : s.kind === "max" ? (s.inclusive ? e.data > s.value : e.data >= s.value) && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1857
|
+
code: d.too_big,
|
|
1858
|
+
type: "bigint",
|
|
1859
|
+
maximum: s.value,
|
|
1860
|
+
inclusive: s.inclusive,
|
|
1861
|
+
message: s.message
|
|
1862
|
+
}), n.dirty()) : s.kind === "multipleOf" ? e.data % s.value !== BigInt(0) && (a = this._getOrReturnCtx(e, a), f(a, {
|
|
1863
|
+
code: d.not_multiple_of,
|
|
1864
|
+
multipleOf: s.value,
|
|
1865
|
+
message: s.message
|
|
1866
|
+
}), n.dirty()) : C.assertNever(s);
|
|
1867
|
+
return { status: n.value, value: e.data };
|
|
1868
|
+
}
|
|
1869
|
+
_getInvalidInput(e) {
|
|
1870
|
+
const r = this._getOrReturnCtx(e);
|
|
1871
|
+
return f(r, {
|
|
1872
|
+
code: d.invalid_type,
|
|
1873
|
+
expected: h.bigint,
|
|
1874
|
+
received: r.parsedType
|
|
1875
|
+
}), _;
|
|
1876
|
+
}
|
|
1877
|
+
gte(e, r) {
|
|
1878
|
+
return this.setLimit("min", e, !0, v.toString(r));
|
|
1879
|
+
}
|
|
1880
|
+
gt(e, r) {
|
|
1881
|
+
return this.setLimit("min", e, !1, v.toString(r));
|
|
1882
|
+
}
|
|
1883
|
+
lte(e, r) {
|
|
1884
|
+
return this.setLimit("max", e, !0, v.toString(r));
|
|
1885
|
+
}
|
|
1886
|
+
lt(e, r) {
|
|
1887
|
+
return this.setLimit("max", e, !1, v.toString(r));
|
|
1888
|
+
}
|
|
1889
|
+
setLimit(e, r, a, n) {
|
|
1890
|
+
return new rt({
|
|
1891
|
+
...this._def,
|
|
1892
|
+
checks: [
|
|
1893
|
+
...this._def.checks,
|
|
1894
|
+
{
|
|
1895
|
+
kind: e,
|
|
1896
|
+
value: r,
|
|
1897
|
+
inclusive: a,
|
|
1898
|
+
message: v.toString(n)
|
|
1899
|
+
}
|
|
1900
|
+
]
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
_addCheck(e) {
|
|
1904
|
+
return new rt({
|
|
1905
|
+
...this._def,
|
|
1906
|
+
checks: [...this._def.checks, e]
|
|
1907
|
+
});
|
|
1908
|
+
}
|
|
1909
|
+
positive(e) {
|
|
1910
|
+
return this._addCheck({
|
|
1911
|
+
kind: "min",
|
|
1912
|
+
value: BigInt(0),
|
|
1913
|
+
inclusive: !1,
|
|
1914
|
+
message: v.toString(e)
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
negative(e) {
|
|
1918
|
+
return this._addCheck({
|
|
1919
|
+
kind: "max",
|
|
1920
|
+
value: BigInt(0),
|
|
1921
|
+
inclusive: !1,
|
|
1922
|
+
message: v.toString(e)
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
nonpositive(e) {
|
|
1926
|
+
return this._addCheck({
|
|
1927
|
+
kind: "max",
|
|
1928
|
+
value: BigInt(0),
|
|
1929
|
+
inclusive: !0,
|
|
1930
|
+
message: v.toString(e)
|
|
1931
|
+
});
|
|
1932
|
+
}
|
|
1933
|
+
nonnegative(e) {
|
|
1934
|
+
return this._addCheck({
|
|
1935
|
+
kind: "min",
|
|
1936
|
+
value: BigInt(0),
|
|
1937
|
+
inclusive: !0,
|
|
1938
|
+
message: v.toString(e)
|
|
1939
|
+
});
|
|
1940
|
+
}
|
|
1941
|
+
multipleOf(e, r) {
|
|
1942
|
+
return this._addCheck({
|
|
1943
|
+
kind: "multipleOf",
|
|
1944
|
+
value: e,
|
|
1945
|
+
message: v.toString(r)
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
get minValue() {
|
|
1949
|
+
let e = null;
|
|
1950
|
+
for (const r of this._def.checks)
|
|
1951
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
1952
|
+
return e;
|
|
1953
|
+
}
|
|
1954
|
+
get maxValue() {
|
|
1955
|
+
let e = null;
|
|
1956
|
+
for (const r of this._def.checks)
|
|
1957
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
1958
|
+
return e;
|
|
1959
|
+
}
|
|
1960
|
+
};
|
|
1961
|
+
he.create = (t) => {
|
|
1962
|
+
var e;
|
|
1963
|
+
return new he({
|
|
1964
|
+
checks: [],
|
|
1965
|
+
typeName: y.ZodBigInt,
|
|
1966
|
+
coerce: (e = t?.coerce) !== null && e !== void 0 ? e : !1,
|
|
1967
|
+
...x(t)
|
|
1968
|
+
});
|
|
1969
|
+
};
|
|
1970
|
+
var pe = class extends k {
|
|
1971
|
+
_parse(t) {
|
|
1972
|
+
if (this._def.coerce && (t.data = !!t.data), this._getType(t) !== h.boolean) {
|
|
1973
|
+
const r = this._getOrReturnCtx(t);
|
|
1974
|
+
return f(r, {
|
|
1975
|
+
code: d.invalid_type,
|
|
1976
|
+
expected: h.boolean,
|
|
1977
|
+
received: r.parsedType
|
|
1978
|
+
}), _;
|
|
1979
|
+
}
|
|
1980
|
+
return E(t.data);
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
pe.create = (t) => new pe({
|
|
1984
|
+
typeName: y.ZodBoolean,
|
|
1985
|
+
coerce: t?.coerce || !1,
|
|
1986
|
+
...x(t)
|
|
1987
|
+
});
|
|
1988
|
+
var me = class Ft extends k {
|
|
1989
|
+
_parse(e) {
|
|
1990
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1991
|
+
const s = this._getOrReturnCtx(e);
|
|
1992
|
+
return f(s, {
|
|
1993
|
+
code: d.invalid_type,
|
|
1994
|
+
expected: h.date,
|
|
1995
|
+
received: s.parsedType
|
|
1996
|
+
}), _;
|
|
1997
|
+
}
|
|
1998
|
+
if (isNaN(e.data.getTime())) {
|
|
1999
|
+
const s = this._getOrReturnCtx(e);
|
|
2000
|
+
return f(s, {
|
|
2001
|
+
code: d.invalid_date
|
|
2002
|
+
}), _;
|
|
2003
|
+
}
|
|
2004
|
+
const a = new Z();
|
|
2005
|
+
let n;
|
|
2006
|
+
for (const s of this._def.checks)
|
|
2007
|
+
s.kind === "min" ? e.data.getTime() < s.value && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
2008
|
+
code: d.too_small,
|
|
2009
|
+
message: s.message,
|
|
2010
|
+
inclusive: !0,
|
|
2011
|
+
exact: !1,
|
|
2012
|
+
minimum: s.value,
|
|
2013
|
+
type: "date"
|
|
2014
|
+
}), a.dirty()) : s.kind === "max" ? e.data.getTime() > s.value && (n = this._getOrReturnCtx(e, n), f(n, {
|
|
2015
|
+
code: d.too_big,
|
|
2016
|
+
message: s.message,
|
|
2017
|
+
inclusive: !0,
|
|
2018
|
+
exact: !1,
|
|
2019
|
+
maximum: s.value,
|
|
2020
|
+
type: "date"
|
|
2021
|
+
}), a.dirty()) : C.assertNever(s);
|
|
2022
|
+
return {
|
|
2023
|
+
status: a.value,
|
|
2024
|
+
value: new Date(e.data.getTime())
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
_addCheck(e) {
|
|
2028
|
+
return new Ft({
|
|
2029
|
+
...this._def,
|
|
2030
|
+
checks: [...this._def.checks, e]
|
|
2031
|
+
});
|
|
2032
|
+
}
|
|
2033
|
+
min(e, r) {
|
|
2034
|
+
return this._addCheck({
|
|
2035
|
+
kind: "min",
|
|
2036
|
+
value: e.getTime(),
|
|
2037
|
+
message: v.toString(r)
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
max(e, r) {
|
|
2041
|
+
return this._addCheck({
|
|
2042
|
+
kind: "max",
|
|
2043
|
+
value: e.getTime(),
|
|
2044
|
+
message: v.toString(r)
|
|
2045
|
+
});
|
|
2046
|
+
}
|
|
2047
|
+
get minDate() {
|
|
2048
|
+
let e = null;
|
|
2049
|
+
for (const r of this._def.checks)
|
|
2050
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2051
|
+
return e != null ? new Date(e) : null;
|
|
2052
|
+
}
|
|
2053
|
+
get maxDate() {
|
|
2054
|
+
let e = null;
|
|
2055
|
+
for (const r of this._def.checks)
|
|
2056
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2057
|
+
return e != null ? new Date(e) : null;
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
me.create = (t) => new me({
|
|
2061
|
+
checks: [],
|
|
2062
|
+
coerce: t?.coerce || !1,
|
|
2063
|
+
typeName: y.ZodDate,
|
|
2064
|
+
...x(t)
|
|
2065
|
+
});
|
|
2066
|
+
var Me = class extends k {
|
|
2067
|
+
_parse(t) {
|
|
2068
|
+
if (this._getType(t) !== h.symbol) {
|
|
2069
|
+
const r = this._getOrReturnCtx(t);
|
|
2070
|
+
return f(r, {
|
|
2071
|
+
code: d.invalid_type,
|
|
2072
|
+
expected: h.symbol,
|
|
2073
|
+
received: r.parsedType
|
|
2074
|
+
}), _;
|
|
2075
|
+
}
|
|
2076
|
+
return E(t.data);
|
|
2077
|
+
}
|
|
2078
|
+
};
|
|
2079
|
+
Me.create = (t) => new Me({
|
|
2080
|
+
typeName: y.ZodSymbol,
|
|
2081
|
+
...x(t)
|
|
2082
|
+
});
|
|
2083
|
+
var ve = class extends k {
|
|
2084
|
+
_parse(t) {
|
|
2085
|
+
if (this._getType(t) !== h.undefined) {
|
|
2086
|
+
const r = this._getOrReturnCtx(t);
|
|
2087
|
+
return f(r, {
|
|
2088
|
+
code: d.invalid_type,
|
|
2089
|
+
expected: h.undefined,
|
|
2090
|
+
received: r.parsedType
|
|
2091
|
+
}), _;
|
|
2092
|
+
}
|
|
2093
|
+
return E(t.data);
|
|
2094
|
+
}
|
|
2095
|
+
};
|
|
2096
|
+
ve.create = (t) => new ve({
|
|
2097
|
+
typeName: y.ZodUndefined,
|
|
2098
|
+
...x(t)
|
|
2099
|
+
});
|
|
2100
|
+
var ge = class extends k {
|
|
2101
|
+
_parse(t) {
|
|
2102
|
+
if (this._getType(t) !== h.null) {
|
|
2103
|
+
const r = this._getOrReturnCtx(t);
|
|
2104
|
+
return f(r, {
|
|
2105
|
+
code: d.invalid_type,
|
|
2106
|
+
expected: h.null,
|
|
2107
|
+
received: r.parsedType
|
|
2108
|
+
}), _;
|
|
2109
|
+
}
|
|
2110
|
+
return E(t.data);
|
|
2111
|
+
}
|
|
2112
|
+
};
|
|
2113
|
+
ge.create = (t) => new ge({
|
|
2114
|
+
typeName: y.ZodNull,
|
|
2115
|
+
...x(t)
|
|
2116
|
+
});
|
|
2117
|
+
var Q = class extends k {
|
|
2118
|
+
constructor() {
|
|
2119
|
+
super(...arguments), this._any = !0;
|
|
2120
|
+
}
|
|
2121
|
+
_parse(t) {
|
|
2122
|
+
return E(t.data);
|
|
2123
|
+
}
|
|
2124
|
+
};
|
|
2125
|
+
Q.create = (t) => new Q({
|
|
2126
|
+
typeName: y.ZodAny,
|
|
2127
|
+
...x(t)
|
|
2128
|
+
});
|
|
2129
|
+
var q = class extends k {
|
|
2130
|
+
constructor() {
|
|
2131
|
+
super(...arguments), this._unknown = !0;
|
|
2132
|
+
}
|
|
2133
|
+
_parse(t) {
|
|
2134
|
+
return E(t.data);
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
q.create = (t) => new q({
|
|
2138
|
+
typeName: y.ZodUnknown,
|
|
2139
|
+
...x(t)
|
|
2140
|
+
});
|
|
2141
|
+
var F = class extends k {
|
|
2142
|
+
_parse(t) {
|
|
2143
|
+
const e = this._getOrReturnCtx(t);
|
|
2144
|
+
return f(e, {
|
|
2145
|
+
code: d.invalid_type,
|
|
2146
|
+
expected: h.never,
|
|
2147
|
+
received: e.parsedType
|
|
2148
|
+
}), _;
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
F.create = (t) => new F({
|
|
2152
|
+
typeName: y.ZodNever,
|
|
2153
|
+
...x(t)
|
|
2154
|
+
});
|
|
2155
|
+
var $e = class extends k {
|
|
2156
|
+
_parse(t) {
|
|
2157
|
+
if (this._getType(t) !== h.undefined) {
|
|
2158
|
+
const r = this._getOrReturnCtx(t);
|
|
2159
|
+
return f(r, {
|
|
2160
|
+
code: d.invalid_type,
|
|
2161
|
+
expected: h.void,
|
|
2162
|
+
received: r.parsedType
|
|
2163
|
+
}), _;
|
|
2164
|
+
}
|
|
2165
|
+
return E(t.data);
|
|
2166
|
+
}
|
|
2167
|
+
};
|
|
2168
|
+
$e.create = (t) => new $e({
|
|
2169
|
+
typeName: y.ZodVoid,
|
|
2170
|
+
...x(t)
|
|
2171
|
+
});
|
|
2172
|
+
var H = class Ee extends k {
|
|
2173
|
+
_parse(e) {
|
|
2174
|
+
const { ctx: r, status: a } = this._processInputParams(e), n = this._def;
|
|
2175
|
+
if (r.parsedType !== h.array)
|
|
2176
|
+
return f(r, {
|
|
2177
|
+
code: d.invalid_type,
|
|
2178
|
+
expected: h.array,
|
|
2179
|
+
received: r.parsedType
|
|
2180
|
+
}), _;
|
|
2181
|
+
if (n.exactLength !== null) {
|
|
2182
|
+
const i = r.data.length > n.exactLength.value, o = r.data.length < n.exactLength.value;
|
|
2183
|
+
(i || o) && (f(r, {
|
|
2184
|
+
code: i ? d.too_big : d.too_small,
|
|
2185
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
2186
|
+
maximum: i ? n.exactLength.value : void 0,
|
|
2187
|
+
type: "array",
|
|
2188
|
+
inclusive: !0,
|
|
2189
|
+
exact: !0,
|
|
2190
|
+
message: n.exactLength.message
|
|
2191
|
+
}), a.dirty());
|
|
2192
|
+
}
|
|
2193
|
+
if (n.minLength !== null && r.data.length < n.minLength.value && (f(r, {
|
|
2194
|
+
code: d.too_small,
|
|
2195
|
+
minimum: n.minLength.value,
|
|
2196
|
+
type: "array",
|
|
2197
|
+
inclusive: !0,
|
|
2198
|
+
exact: !1,
|
|
2199
|
+
message: n.minLength.message
|
|
2200
|
+
}), a.dirty()), n.maxLength !== null && r.data.length > n.maxLength.value && (f(r, {
|
|
2201
|
+
code: d.too_big,
|
|
2202
|
+
maximum: n.maxLength.value,
|
|
2203
|
+
type: "array",
|
|
2204
|
+
inclusive: !0,
|
|
2205
|
+
exact: !1,
|
|
2206
|
+
message: n.maxLength.message
|
|
2207
|
+
}), a.dirty()), r.common.async)
|
|
2208
|
+
return Promise.all([...r.data].map((i, o) => n.type._parseAsync(new U(r, i, r.path, o)))).then((i) => Z.mergeArray(a, i));
|
|
2209
|
+
const s = [...r.data].map((i, o) => n.type._parseSync(new U(r, i, r.path, o)));
|
|
2210
|
+
return Z.mergeArray(a, s);
|
|
2211
|
+
}
|
|
2212
|
+
get element() {
|
|
2213
|
+
return this._def.type;
|
|
2214
|
+
}
|
|
2215
|
+
min(e, r) {
|
|
2216
|
+
return new Ee({
|
|
2217
|
+
...this._def,
|
|
2218
|
+
minLength: { value: e, message: v.toString(r) }
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
max(e, r) {
|
|
2222
|
+
return new Ee({
|
|
2223
|
+
...this._def,
|
|
2224
|
+
maxLength: { value: e, message: v.toString(r) }
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
length(e, r) {
|
|
2228
|
+
return new Ee({
|
|
2229
|
+
...this._def,
|
|
2230
|
+
exactLength: { value: e, message: v.toString(r) }
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
nonempty(e) {
|
|
2234
|
+
return this.min(1, e);
|
|
2235
|
+
}
|
|
2236
|
+
};
|
|
2237
|
+
H.create = (t, e) => new H({
|
|
2238
|
+
type: t,
|
|
2239
|
+
minLength: null,
|
|
2240
|
+
maxLength: null,
|
|
2241
|
+
exactLength: null,
|
|
2242
|
+
typeName: y.ZodArray,
|
|
2243
|
+
...x(e)
|
|
2244
|
+
});
|
|
2245
|
+
function J(t) {
|
|
2246
|
+
if (t instanceof P) {
|
|
2247
|
+
const e = {};
|
|
2248
|
+
for (const r in t.shape) {
|
|
2249
|
+
const a = t.shape[r];
|
|
2250
|
+
e[r] = D.create(J(a));
|
|
2251
|
+
}
|
|
2252
|
+
return new P({
|
|
2253
|
+
...t._def,
|
|
2254
|
+
shape: () => e
|
|
2255
|
+
});
|
|
2256
|
+
} else return t instanceof H ? new H({
|
|
2257
|
+
...t._def,
|
|
2258
|
+
type: J(t.element)
|
|
2259
|
+
}) : t instanceof D ? D.create(J(t.unwrap())) : t instanceof W ? W.create(J(t.unwrap())) : t instanceof L ? L.create(t.items.map((e) => J(e))) : t;
|
|
2260
|
+
}
|
|
2261
|
+
var P = class M extends k {
|
|
2262
|
+
constructor() {
|
|
2263
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
2264
|
+
}
|
|
2265
|
+
_getCached() {
|
|
2266
|
+
if (this._cached !== null)
|
|
2267
|
+
return this._cached;
|
|
2268
|
+
const e = this._def.shape(), r = C.objectKeys(e);
|
|
2269
|
+
return this._cached = { shape: e, keys: r };
|
|
2270
|
+
}
|
|
2271
|
+
_parse(e) {
|
|
2272
|
+
if (this._getType(e) !== h.object) {
|
|
2273
|
+
const u = this._getOrReturnCtx(e);
|
|
2274
|
+
return f(u, {
|
|
2275
|
+
code: d.invalid_type,
|
|
2276
|
+
expected: h.object,
|
|
2277
|
+
received: u.parsedType
|
|
2278
|
+
}), _;
|
|
2279
|
+
}
|
|
2280
|
+
const { status: a, ctx: n } = this._processInputParams(e), { shape: s, keys: i } = this._getCached(), o = [];
|
|
2281
|
+
if (!(this._def.catchall instanceof F && this._def.unknownKeys === "strip"))
|
|
2282
|
+
for (const u in n.data)
|
|
2283
|
+
i.includes(u) || o.push(u);
|
|
2284
|
+
const c = [];
|
|
2285
|
+
for (const u of i) {
|
|
2286
|
+
const l = s[u], p = n.data[u];
|
|
2287
|
+
c.push({
|
|
2288
|
+
key: { status: "valid", value: u },
|
|
2289
|
+
value: l._parse(new U(n, p, n.path, u)),
|
|
2290
|
+
alwaysSet: u in n.data
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
if (this._def.catchall instanceof F) {
|
|
2294
|
+
const u = this._def.unknownKeys;
|
|
2295
|
+
if (u === "passthrough")
|
|
2296
|
+
for (const l of o)
|
|
2297
|
+
c.push({
|
|
2298
|
+
key: { status: "valid", value: l },
|
|
2299
|
+
value: { status: "valid", value: n.data[l] }
|
|
2300
|
+
});
|
|
2301
|
+
else if (u === "strict")
|
|
2302
|
+
o.length > 0 && (f(n, {
|
|
2303
|
+
code: d.unrecognized_keys,
|
|
2304
|
+
keys: o
|
|
2305
|
+
}), a.dirty());
|
|
2306
|
+
else if (u !== "strip")
|
|
2307
|
+
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
2308
|
+
} else {
|
|
2309
|
+
const u = this._def.catchall;
|
|
2310
|
+
for (const l of o) {
|
|
2311
|
+
const p = n.data[l];
|
|
2312
|
+
c.push({
|
|
2313
|
+
key: { status: "valid", value: l },
|
|
2314
|
+
value: u._parse(
|
|
2315
|
+
new U(n, p, n.path, l)
|
|
2316
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
2317
|
+
),
|
|
2318
|
+
alwaysSet: l in n.data
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
return n.common.async ? Promise.resolve().then(async () => {
|
|
2323
|
+
const u = [];
|
|
2324
|
+
for (const l of c) {
|
|
2325
|
+
const p = await l.key, g = await l.value;
|
|
2326
|
+
u.push({
|
|
2327
|
+
key: p,
|
|
2328
|
+
value: g,
|
|
2329
|
+
alwaysSet: l.alwaysSet
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
return u;
|
|
2333
|
+
}).then((u) => Z.mergeObjectSync(a, u)) : Z.mergeObjectSync(a, c);
|
|
2334
|
+
}
|
|
2335
|
+
get shape() {
|
|
2336
|
+
return this._def.shape();
|
|
2337
|
+
}
|
|
2338
|
+
strict(e) {
|
|
2339
|
+
return v.errToObj, new M({
|
|
2340
|
+
...this._def,
|
|
2341
|
+
unknownKeys: "strict",
|
|
2342
|
+
...e !== void 0 ? {
|
|
2343
|
+
errorMap: (r, a) => {
|
|
2344
|
+
var n, s, i, o;
|
|
2345
|
+
const c = (i = (s = (n = this._def).errorMap) === null || s === void 0 ? void 0 : s.call(n, r, a).message) !== null && i !== void 0 ? i : a.defaultError;
|
|
2346
|
+
return r.code === "unrecognized_keys" ? {
|
|
2347
|
+
message: (o = v.errToObj(e).message) !== null && o !== void 0 ? o : c
|
|
2348
|
+
} : {
|
|
2349
|
+
message: c
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
} : {}
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
strip() {
|
|
2356
|
+
return new M({
|
|
2357
|
+
...this._def,
|
|
2358
|
+
unknownKeys: "strip"
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
passthrough() {
|
|
2362
|
+
return new M({
|
|
2363
|
+
...this._def,
|
|
2364
|
+
unknownKeys: "passthrough"
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
// const AugmentFactory =
|
|
2368
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
2369
|
+
// <Augmentation extends ZodRawShape>(
|
|
2370
|
+
// augmentation: Augmentation
|
|
2371
|
+
// ): ZodObject<
|
|
2372
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
2373
|
+
// Def["unknownKeys"],
|
|
2374
|
+
// Def["catchall"]
|
|
2375
|
+
// > => {
|
|
2376
|
+
// return new ZodObject({
|
|
2377
|
+
// ...def,
|
|
2378
|
+
// shape: () => ({
|
|
2379
|
+
// ...def.shape(),
|
|
2380
|
+
// ...augmentation,
|
|
2381
|
+
// }),
|
|
2382
|
+
// }) as any;
|
|
2383
|
+
// };
|
|
2384
|
+
extend(e) {
|
|
2385
|
+
return new M({
|
|
2386
|
+
...this._def,
|
|
2387
|
+
shape: () => ({
|
|
2388
|
+
...this._def.shape(),
|
|
2389
|
+
...e
|
|
2390
|
+
})
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
/**
|
|
2394
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
2395
|
+
* inferred type of merged objects. Please
|
|
2396
|
+
* upgrade if you are experiencing issues.
|
|
2397
|
+
*/
|
|
2398
|
+
merge(e) {
|
|
2399
|
+
return new M({
|
|
2400
|
+
unknownKeys: e._def.unknownKeys,
|
|
2401
|
+
catchall: e._def.catchall,
|
|
2402
|
+
shape: () => ({
|
|
2403
|
+
...this._def.shape(),
|
|
2404
|
+
...e._def.shape()
|
|
2405
|
+
}),
|
|
2406
|
+
typeName: y.ZodObject
|
|
2407
|
+
});
|
|
2408
|
+
}
|
|
2409
|
+
// merge<
|
|
2410
|
+
// Incoming extends AnyZodObject,
|
|
2411
|
+
// Augmentation extends Incoming["shape"],
|
|
2412
|
+
// NewOutput extends {
|
|
2413
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
2414
|
+
// ? Augmentation[k]["_output"]
|
|
2415
|
+
// : k extends keyof Output
|
|
2416
|
+
// ? Output[k]
|
|
2417
|
+
// : never;
|
|
2418
|
+
// },
|
|
2419
|
+
// NewInput extends {
|
|
2420
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2421
|
+
// ? Augmentation[k]["_input"]
|
|
2422
|
+
// : k extends keyof Input
|
|
2423
|
+
// ? Input[k]
|
|
2424
|
+
// : never;
|
|
2425
|
+
// }
|
|
2426
|
+
// >(
|
|
2427
|
+
// merging: Incoming
|
|
2428
|
+
// ): ZodObject<
|
|
2429
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2430
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2431
|
+
// Incoming["_def"]["catchall"],
|
|
2432
|
+
// NewOutput,
|
|
2433
|
+
// NewInput
|
|
2434
|
+
// > {
|
|
2435
|
+
// const merged: any = new ZodObject({
|
|
2436
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2437
|
+
// catchall: merging._def.catchall,
|
|
2438
|
+
// shape: () =>
|
|
2439
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2440
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2441
|
+
// }) as any;
|
|
2442
|
+
// return merged;
|
|
2443
|
+
// }
|
|
2444
|
+
setKey(e, r) {
|
|
2445
|
+
return this.augment({ [e]: r });
|
|
2446
|
+
}
|
|
2447
|
+
// merge<Incoming extends AnyZodObject>(
|
|
2448
|
+
// merging: Incoming
|
|
2449
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
2450
|
+
// ZodObject<
|
|
2451
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2452
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2453
|
+
// Incoming["_def"]["catchall"]
|
|
2454
|
+
// > {
|
|
2455
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
2456
|
+
// // this._def.shape(),
|
|
2457
|
+
// // merging._def.shape()
|
|
2458
|
+
// // );
|
|
2459
|
+
// const merged: any = new ZodObject({
|
|
2460
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2461
|
+
// catchall: merging._def.catchall,
|
|
2462
|
+
// shape: () =>
|
|
2463
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2464
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2465
|
+
// }) as any;
|
|
2466
|
+
// return merged;
|
|
2467
|
+
// }
|
|
2468
|
+
catchall(e) {
|
|
2469
|
+
return new M({
|
|
2470
|
+
...this._def,
|
|
2471
|
+
catchall: e
|
|
2472
|
+
});
|
|
2473
|
+
}
|
|
2474
|
+
pick(e) {
|
|
2475
|
+
const r = {};
|
|
2476
|
+
return C.objectKeys(e).forEach((a) => {
|
|
2477
|
+
e[a] && this.shape[a] && (r[a] = this.shape[a]);
|
|
2478
|
+
}), new M({
|
|
2479
|
+
...this._def,
|
|
2480
|
+
shape: () => r
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
omit(e) {
|
|
2484
|
+
const r = {};
|
|
2485
|
+
return C.objectKeys(this.shape).forEach((a) => {
|
|
2486
|
+
e[a] || (r[a] = this.shape[a]);
|
|
2487
|
+
}), new M({
|
|
2488
|
+
...this._def,
|
|
2489
|
+
shape: () => r
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
/**
|
|
2493
|
+
* @deprecated
|
|
2494
|
+
*/
|
|
2495
|
+
deepPartial() {
|
|
2496
|
+
return J(this);
|
|
2497
|
+
}
|
|
2498
|
+
partial(e) {
|
|
2499
|
+
const r = {};
|
|
2500
|
+
return C.objectKeys(this.shape).forEach((a) => {
|
|
2501
|
+
const n = this.shape[a];
|
|
2502
|
+
e && !e[a] ? r[a] = n : r[a] = n.optional();
|
|
2503
|
+
}), new M({
|
|
2504
|
+
...this._def,
|
|
2505
|
+
shape: () => r
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
required(e) {
|
|
2509
|
+
const r = {};
|
|
2510
|
+
return C.objectKeys(this.shape).forEach((a) => {
|
|
2511
|
+
if (e && !e[a])
|
|
2512
|
+
r[a] = this.shape[a];
|
|
2513
|
+
else {
|
|
2514
|
+
let s = this.shape[a];
|
|
2515
|
+
for (; s instanceof D; )
|
|
2516
|
+
s = s._def.innerType;
|
|
2517
|
+
r[a] = s;
|
|
2518
|
+
}
|
|
2519
|
+
}), new M({
|
|
2520
|
+
...this._def,
|
|
2521
|
+
shape: () => r
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
keyof() {
|
|
2525
|
+
return Jt(C.objectKeys(this.shape));
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
P.create = (t, e) => new P({
|
|
2529
|
+
shape: () => t,
|
|
2530
|
+
unknownKeys: "strip",
|
|
2531
|
+
catchall: F.create(),
|
|
2532
|
+
typeName: y.ZodObject,
|
|
2533
|
+
...x(e)
|
|
2534
|
+
});
|
|
2535
|
+
P.strictCreate = (t, e) => new P({
|
|
2536
|
+
shape: () => t,
|
|
2537
|
+
unknownKeys: "strict",
|
|
2538
|
+
catchall: F.create(),
|
|
2539
|
+
typeName: y.ZodObject,
|
|
2540
|
+
...x(e)
|
|
2541
|
+
});
|
|
2542
|
+
P.lazycreate = (t, e) => new P({
|
|
2543
|
+
shape: t,
|
|
2544
|
+
unknownKeys: "strip",
|
|
2545
|
+
catchall: F.create(),
|
|
2546
|
+
typeName: y.ZodObject,
|
|
2547
|
+
...x(e)
|
|
2548
|
+
});
|
|
2549
|
+
var ye = class extends k {
|
|
2550
|
+
_parse(t) {
|
|
2551
|
+
const { ctx: e } = this._processInputParams(t), r = this._def.options;
|
|
2552
|
+
function a(n) {
|
|
2553
|
+
for (const i of n)
|
|
2554
|
+
if (i.result.status === "valid")
|
|
2555
|
+
return i.result;
|
|
2556
|
+
for (const i of n)
|
|
2557
|
+
if (i.result.status === "dirty")
|
|
2558
|
+
return e.common.issues.push(...i.ctx.common.issues), i.result;
|
|
2559
|
+
const s = n.map((i) => new $(i.ctx.common.issues));
|
|
2560
|
+
return f(e, {
|
|
2561
|
+
code: d.invalid_union,
|
|
2562
|
+
unionErrors: s
|
|
2563
|
+
}), _;
|
|
2564
|
+
}
|
|
2565
|
+
if (e.common.async)
|
|
2566
|
+
return Promise.all(r.map(async (n) => {
|
|
2567
|
+
const s = {
|
|
2568
|
+
...e,
|
|
2569
|
+
common: {
|
|
2570
|
+
...e.common,
|
|
2571
|
+
issues: []
|
|
2572
|
+
},
|
|
2573
|
+
parent: null
|
|
2574
|
+
};
|
|
2575
|
+
return {
|
|
2576
|
+
result: await n._parseAsync({
|
|
2577
|
+
data: e.data,
|
|
2578
|
+
path: e.path,
|
|
2579
|
+
parent: s
|
|
2580
|
+
}),
|
|
2581
|
+
ctx: s
|
|
2582
|
+
};
|
|
2583
|
+
})).then(a);
|
|
2584
|
+
{
|
|
2585
|
+
let n;
|
|
2586
|
+
const s = [];
|
|
2587
|
+
for (const o of r) {
|
|
2588
|
+
const c = {
|
|
2589
|
+
...e,
|
|
2590
|
+
common: {
|
|
2591
|
+
...e.common,
|
|
2592
|
+
issues: []
|
|
2593
|
+
},
|
|
2594
|
+
parent: null
|
|
2595
|
+
}, u = o._parseSync({
|
|
2596
|
+
data: e.data,
|
|
2597
|
+
path: e.path,
|
|
2598
|
+
parent: c
|
|
2599
|
+
});
|
|
2600
|
+
if (u.status === "valid")
|
|
2601
|
+
return u;
|
|
2602
|
+
u.status === "dirty" && !n && (n = { result: u, ctx: c }), c.common.issues.length && s.push(c.common.issues);
|
|
2603
|
+
}
|
|
2604
|
+
if (n)
|
|
2605
|
+
return e.common.issues.push(...n.ctx.common.issues), n.result;
|
|
2606
|
+
const i = s.map((o) => new $(o));
|
|
2607
|
+
return f(e, {
|
|
2608
|
+
code: d.invalid_union,
|
|
2609
|
+
unionErrors: i
|
|
2610
|
+
}), _;
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
get options() {
|
|
2614
|
+
return this._def.options;
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
ye.create = (t, e) => new ye({
|
|
2618
|
+
options: t,
|
|
2619
|
+
typeName: y.ZodUnion,
|
|
2620
|
+
...x(e)
|
|
2621
|
+
});
|
|
2622
|
+
var V = (t) => t instanceof be ? V(t.schema) : t instanceof z ? V(t.innerType()) : t instanceof we ? [t.value] : t instanceof Oe ? t.options : t instanceof xe ? C.objectValues(t.enum) : t instanceof ke ? V(t._def.innerType) : t instanceof ve ? [void 0] : t instanceof ge ? [null] : t instanceof D ? [void 0, ...V(t.unwrap())] : t instanceof W ? [null, ...V(t.unwrap())] : t instanceof ft || t instanceof Ce ? V(t.unwrap()) : t instanceof Te ? V(t._def.innerType) : [], Lt = class Wt extends k {
|
|
2623
|
+
_parse(e) {
|
|
2624
|
+
const { ctx: r } = this._processInputParams(e);
|
|
2625
|
+
if (r.parsedType !== h.object)
|
|
2626
|
+
return f(r, {
|
|
2627
|
+
code: d.invalid_type,
|
|
2628
|
+
expected: h.object,
|
|
2629
|
+
received: r.parsedType
|
|
2630
|
+
}), _;
|
|
2631
|
+
const a = this.discriminator, n = r.data[a], s = this.optionsMap.get(n);
|
|
2632
|
+
return s ? r.common.async ? s._parseAsync({
|
|
2633
|
+
data: r.data,
|
|
2634
|
+
path: r.path,
|
|
2635
|
+
parent: r
|
|
2636
|
+
}) : s._parseSync({
|
|
2637
|
+
data: r.data,
|
|
2638
|
+
path: r.path,
|
|
2639
|
+
parent: r
|
|
2640
|
+
}) : (f(r, {
|
|
2641
|
+
code: d.invalid_union_discriminator,
|
|
2642
|
+
options: Array.from(this.optionsMap.keys()),
|
|
2643
|
+
path: [a]
|
|
2644
|
+
}), _);
|
|
2645
|
+
}
|
|
2646
|
+
get discriminator() {
|
|
2647
|
+
return this._def.discriminator;
|
|
2648
|
+
}
|
|
2649
|
+
get options() {
|
|
2650
|
+
return this._def.options;
|
|
2651
|
+
}
|
|
2652
|
+
get optionsMap() {
|
|
2653
|
+
return this._def.optionsMap;
|
|
2654
|
+
}
|
|
2655
|
+
/**
|
|
2656
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
2657
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
2658
|
+
* have a different value for each object in the union.
|
|
2659
|
+
* @param discriminator the name of the discriminator property
|
|
2660
|
+
* @param types an array of object schemas
|
|
2661
|
+
* @param params
|
|
2662
|
+
*/
|
|
2663
|
+
static create(e, r, a) {
|
|
2664
|
+
const n = /* @__PURE__ */ new Map();
|
|
2665
|
+
for (const s of r) {
|
|
2666
|
+
const i = V(s.shape[e]);
|
|
2667
|
+
if (!i.length)
|
|
2668
|
+
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2669
|
+
for (const o of i) {
|
|
2670
|
+
if (n.has(o))
|
|
2671
|
+
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2672
|
+
n.set(o, s);
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
return new Wt({
|
|
2676
|
+
typeName: y.ZodDiscriminatedUnion,
|
|
2677
|
+
discriminator: e,
|
|
2678
|
+
options: r,
|
|
2679
|
+
optionsMap: n,
|
|
2680
|
+
...x(a)
|
|
2681
|
+
});
|
|
2682
|
+
}
|
|
2683
|
+
};
|
|
2684
|
+
function at(t, e) {
|
|
2685
|
+
const r = B(t), a = B(e);
|
|
2686
|
+
if (t === e)
|
|
2687
|
+
return { valid: !0, data: t };
|
|
2688
|
+
if (r === h.object && a === h.object) {
|
|
2689
|
+
const n = C.objectKeys(e), s = C.objectKeys(t).filter((o) => n.indexOf(o) !== -1), i = { ...t, ...e };
|
|
2690
|
+
for (const o of s) {
|
|
2691
|
+
const c = at(t[o], e[o]);
|
|
2692
|
+
if (!c.valid)
|
|
2693
|
+
return { valid: !1 };
|
|
2694
|
+
i[o] = c.data;
|
|
2695
|
+
}
|
|
2696
|
+
return { valid: !0, data: i };
|
|
2697
|
+
} else if (r === h.array && a === h.array) {
|
|
2698
|
+
if (t.length !== e.length)
|
|
2699
|
+
return { valid: !1 };
|
|
2700
|
+
const n = [];
|
|
2701
|
+
for (let s = 0; s < t.length; s++) {
|
|
2702
|
+
const i = t[s], o = e[s], c = at(i, o);
|
|
2703
|
+
if (!c.valid)
|
|
2704
|
+
return { valid: !1 };
|
|
2705
|
+
n.push(c.data);
|
|
2706
|
+
}
|
|
2707
|
+
return { valid: !0, data: n };
|
|
2708
|
+
} else return r === h.date && a === h.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
2709
|
+
}
|
|
2710
|
+
var _e = class extends k {
|
|
2711
|
+
_parse(t) {
|
|
2712
|
+
const { status: e, ctx: r } = this._processInputParams(t), a = (n, s) => {
|
|
2713
|
+
if (Qe(n) || Qe(s))
|
|
2714
|
+
return _;
|
|
2715
|
+
const i = at(n.value, s.value);
|
|
2716
|
+
return i.valid ? ((et(n) || et(s)) && e.dirty(), { status: e.value, value: i.data }) : (f(r, {
|
|
2717
|
+
code: d.invalid_intersection_types
|
|
2718
|
+
}), _);
|
|
2719
|
+
};
|
|
2720
|
+
return r.common.async ? Promise.all([
|
|
2721
|
+
this._def.left._parseAsync({
|
|
2722
|
+
data: r.data,
|
|
2723
|
+
path: r.path,
|
|
2724
|
+
parent: r
|
|
2725
|
+
}),
|
|
2726
|
+
this._def.right._parseAsync({
|
|
2727
|
+
data: r.data,
|
|
2728
|
+
path: r.path,
|
|
2729
|
+
parent: r
|
|
2730
|
+
})
|
|
2731
|
+
]).then(([n, s]) => a(n, s)) : a(this._def.left._parseSync({
|
|
2732
|
+
data: r.data,
|
|
2733
|
+
path: r.path,
|
|
2734
|
+
parent: r
|
|
2735
|
+
}), this._def.right._parseSync({
|
|
2736
|
+
data: r.data,
|
|
2737
|
+
path: r.path,
|
|
2738
|
+
parent: r
|
|
2739
|
+
}));
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2742
|
+
_e.create = (t, e, r) => new _e({
|
|
2743
|
+
left: t,
|
|
2744
|
+
right: e,
|
|
2745
|
+
typeName: y.ZodIntersection,
|
|
2746
|
+
...x(r)
|
|
2747
|
+
});
|
|
2748
|
+
var L = class qt extends k {
|
|
2749
|
+
_parse(e) {
|
|
2750
|
+
const { status: r, ctx: a } = this._processInputParams(e);
|
|
2751
|
+
if (a.parsedType !== h.array)
|
|
2752
|
+
return f(a, {
|
|
2753
|
+
code: d.invalid_type,
|
|
2754
|
+
expected: h.array,
|
|
2755
|
+
received: a.parsedType
|
|
2756
|
+
}), _;
|
|
2757
|
+
if (a.data.length < this._def.items.length)
|
|
2758
|
+
return f(a, {
|
|
2759
|
+
code: d.too_small,
|
|
2760
|
+
minimum: this._def.items.length,
|
|
2761
|
+
inclusive: !0,
|
|
2762
|
+
exact: !1,
|
|
2763
|
+
type: "array"
|
|
2764
|
+
}), _;
|
|
2765
|
+
!this._def.rest && a.data.length > this._def.items.length && (f(a, {
|
|
2766
|
+
code: d.too_big,
|
|
2767
|
+
maximum: this._def.items.length,
|
|
2768
|
+
inclusive: !0,
|
|
2769
|
+
exact: !1,
|
|
2770
|
+
type: "array"
|
|
2771
|
+
}), r.dirty());
|
|
2772
|
+
const s = [...a.data].map((i, o) => {
|
|
2773
|
+
const c = this._def.items[o] || this._def.rest;
|
|
2774
|
+
return c ? c._parse(new U(a, i, a.path, o)) : null;
|
|
2775
|
+
}).filter((i) => !!i);
|
|
2776
|
+
return a.common.async ? Promise.all(s).then((i) => Z.mergeArray(r, i)) : Z.mergeArray(r, s);
|
|
2777
|
+
}
|
|
2778
|
+
get items() {
|
|
2779
|
+
return this._def.items;
|
|
2780
|
+
}
|
|
2781
|
+
rest(e) {
|
|
2782
|
+
return new qt({
|
|
2783
|
+
...this._def,
|
|
2784
|
+
rest: e
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
};
|
|
2788
|
+
L.create = (t, e) => {
|
|
2789
|
+
if (!Array.isArray(t))
|
|
2790
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2791
|
+
return new L({
|
|
2792
|
+
items: t,
|
|
2793
|
+
typeName: y.ZodTuple,
|
|
2794
|
+
rest: null,
|
|
2795
|
+
...x(e)
|
|
2796
|
+
});
|
|
2797
|
+
};
|
|
2798
|
+
var Gt = class nt extends k {
|
|
2799
|
+
get keySchema() {
|
|
2800
|
+
return this._def.keyType;
|
|
2801
|
+
}
|
|
2802
|
+
get valueSchema() {
|
|
2803
|
+
return this._def.valueType;
|
|
2804
|
+
}
|
|
2805
|
+
_parse(e) {
|
|
2806
|
+
const { status: r, ctx: a } = this._processInputParams(e);
|
|
2807
|
+
if (a.parsedType !== h.object)
|
|
2808
|
+
return f(a, {
|
|
2809
|
+
code: d.invalid_type,
|
|
2810
|
+
expected: h.object,
|
|
2811
|
+
received: a.parsedType
|
|
2812
|
+
}), _;
|
|
2813
|
+
const n = [], s = this._def.keyType, i = this._def.valueType;
|
|
2814
|
+
for (const o in a.data)
|
|
2815
|
+
n.push({
|
|
2816
|
+
key: s._parse(new U(a, o, a.path, o)),
|
|
2817
|
+
value: i._parse(new U(a, a.data[o], a.path, o)),
|
|
2818
|
+
alwaysSet: o in a.data
|
|
2819
|
+
});
|
|
2820
|
+
return a.common.async ? Z.mergeObjectAsync(r, n) : Z.mergeObjectSync(r, n);
|
|
2821
|
+
}
|
|
2822
|
+
get element() {
|
|
2823
|
+
return this._def.valueType;
|
|
2824
|
+
}
|
|
2825
|
+
static create(e, r, a) {
|
|
2826
|
+
return r instanceof k ? new nt({
|
|
2827
|
+
keyType: e,
|
|
2828
|
+
valueType: r,
|
|
2829
|
+
typeName: y.ZodRecord,
|
|
2830
|
+
...x(a)
|
|
2831
|
+
}) : new nt({
|
|
2832
|
+
keyType: X.create(),
|
|
2833
|
+
valueType: e,
|
|
2834
|
+
typeName: y.ZodRecord,
|
|
2835
|
+
...x(r)
|
|
2836
|
+
});
|
|
2837
|
+
}
|
|
2838
|
+
}, ze = class extends k {
|
|
2839
|
+
get keySchema() {
|
|
2840
|
+
return this._def.keyType;
|
|
2841
|
+
}
|
|
2842
|
+
get valueSchema() {
|
|
2843
|
+
return this._def.valueType;
|
|
2844
|
+
}
|
|
2845
|
+
_parse(t) {
|
|
2846
|
+
const { status: e, ctx: r } = this._processInputParams(t);
|
|
2847
|
+
if (r.parsedType !== h.map)
|
|
2848
|
+
return f(r, {
|
|
2849
|
+
code: d.invalid_type,
|
|
2850
|
+
expected: h.map,
|
|
2851
|
+
received: r.parsedType
|
|
2852
|
+
}), _;
|
|
2853
|
+
const a = this._def.keyType, n = this._def.valueType, s = [...r.data.entries()].map(([i, o], c) => ({
|
|
2854
|
+
key: a._parse(new U(r, i, r.path, [c, "key"])),
|
|
2855
|
+
value: n._parse(new U(r, o, r.path, [c, "value"]))
|
|
2856
|
+
}));
|
|
2857
|
+
if (r.common.async) {
|
|
2858
|
+
const i = /* @__PURE__ */ new Map();
|
|
2859
|
+
return Promise.resolve().then(async () => {
|
|
2860
|
+
for (const o of s) {
|
|
2861
|
+
const c = await o.key, u = await o.value;
|
|
2862
|
+
if (c.status === "aborted" || u.status === "aborted")
|
|
2863
|
+
return _;
|
|
2864
|
+
(c.status === "dirty" || u.status === "dirty") && e.dirty(), i.set(c.value, u.value);
|
|
2865
|
+
}
|
|
2866
|
+
return { status: e.value, value: i };
|
|
2867
|
+
});
|
|
2868
|
+
} else {
|
|
2869
|
+
const i = /* @__PURE__ */ new Map();
|
|
2870
|
+
for (const o of s) {
|
|
2871
|
+
const c = o.key, u = o.value;
|
|
2872
|
+
if (c.status === "aborted" || u.status === "aborted")
|
|
2873
|
+
return _;
|
|
2874
|
+
(c.status === "dirty" || u.status === "dirty") && e.dirty(), i.set(c.value, u.value);
|
|
2875
|
+
}
|
|
2876
|
+
return { status: e.value, value: i };
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
};
|
|
2880
|
+
ze.create = (t, e, r) => new ze({
|
|
2881
|
+
valueType: e,
|
|
2882
|
+
keyType: t,
|
|
2883
|
+
typeName: y.ZodMap,
|
|
2884
|
+
...x(r)
|
|
2885
|
+
});
|
|
2886
|
+
var De = class st extends k {
|
|
2887
|
+
_parse(e) {
|
|
2888
|
+
const { status: r, ctx: a } = this._processInputParams(e);
|
|
2889
|
+
if (a.parsedType !== h.set)
|
|
2890
|
+
return f(a, {
|
|
2891
|
+
code: d.invalid_type,
|
|
2892
|
+
expected: h.set,
|
|
2893
|
+
received: a.parsedType
|
|
2894
|
+
}), _;
|
|
2895
|
+
const n = this._def;
|
|
2896
|
+
n.minSize !== null && a.data.size < n.minSize.value && (f(a, {
|
|
2897
|
+
code: d.too_small,
|
|
2898
|
+
minimum: n.minSize.value,
|
|
2899
|
+
type: "set",
|
|
2900
|
+
inclusive: !0,
|
|
2901
|
+
exact: !1,
|
|
2902
|
+
message: n.minSize.message
|
|
2903
|
+
}), r.dirty()), n.maxSize !== null && a.data.size > n.maxSize.value && (f(a, {
|
|
2904
|
+
code: d.too_big,
|
|
2905
|
+
maximum: n.maxSize.value,
|
|
2906
|
+
type: "set",
|
|
2907
|
+
inclusive: !0,
|
|
2908
|
+
exact: !1,
|
|
2909
|
+
message: n.maxSize.message
|
|
2910
|
+
}), r.dirty());
|
|
2911
|
+
const s = this._def.valueType;
|
|
2912
|
+
function i(c) {
|
|
2913
|
+
const u = /* @__PURE__ */ new Set();
|
|
2914
|
+
for (const l of c) {
|
|
2915
|
+
if (l.status === "aborted")
|
|
2916
|
+
return _;
|
|
2917
|
+
l.status === "dirty" && r.dirty(), u.add(l.value);
|
|
2918
|
+
}
|
|
2919
|
+
return { status: r.value, value: u };
|
|
2920
|
+
}
|
|
2921
|
+
const o = [...a.data.values()].map((c, u) => s._parse(new U(a, c, a.path, u)));
|
|
2922
|
+
return a.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2923
|
+
}
|
|
2924
|
+
min(e, r) {
|
|
2925
|
+
return new st({
|
|
2926
|
+
...this._def,
|
|
2927
|
+
minSize: { value: e, message: v.toString(r) }
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
max(e, r) {
|
|
2931
|
+
return new st({
|
|
2932
|
+
...this._def,
|
|
2933
|
+
maxSize: { value: e, message: v.toString(r) }
|
|
2934
|
+
});
|
|
2935
|
+
}
|
|
2936
|
+
size(e, r) {
|
|
2937
|
+
return this.min(e, r).max(e, r);
|
|
2938
|
+
}
|
|
2939
|
+
nonempty(e) {
|
|
2940
|
+
return this.min(1, e);
|
|
2941
|
+
}
|
|
2942
|
+
};
|
|
2943
|
+
De.create = (t, e) => new De({
|
|
2944
|
+
valueType: t,
|
|
2945
|
+
minSize: null,
|
|
2946
|
+
maxSize: null,
|
|
2947
|
+
typeName: y.ZodSet,
|
|
2948
|
+
...x(e)
|
|
2949
|
+
});
|
|
2950
|
+
var Ht = class Ie extends k {
|
|
2951
|
+
constructor() {
|
|
2952
|
+
super(...arguments), this.validate = this.implement;
|
|
2953
|
+
}
|
|
2954
|
+
_parse(e) {
|
|
2955
|
+
const { ctx: r } = this._processInputParams(e);
|
|
2956
|
+
if (r.parsedType !== h.function)
|
|
2957
|
+
return f(r, {
|
|
2958
|
+
code: d.invalid_type,
|
|
2959
|
+
expected: h.function,
|
|
2960
|
+
received: r.parsedType
|
|
2961
|
+
}), _;
|
|
2962
|
+
function a(o, c) {
|
|
2963
|
+
return Ne({
|
|
2964
|
+
data: o,
|
|
2965
|
+
path: r.path,
|
|
2966
|
+
errorMaps: [
|
|
2967
|
+
r.common.contextualErrorMap,
|
|
2968
|
+
r.schemaErrorMap,
|
|
2969
|
+
Re(),
|
|
2970
|
+
K
|
|
2971
|
+
].filter((u) => !!u),
|
|
2972
|
+
issueData: {
|
|
2973
|
+
code: d.invalid_arguments,
|
|
2974
|
+
argumentsError: c
|
|
2975
|
+
}
|
|
2976
|
+
});
|
|
2977
|
+
}
|
|
2978
|
+
function n(o, c) {
|
|
2979
|
+
return Ne({
|
|
2980
|
+
data: o,
|
|
2981
|
+
path: r.path,
|
|
2982
|
+
errorMaps: [
|
|
2983
|
+
r.common.contextualErrorMap,
|
|
2984
|
+
r.schemaErrorMap,
|
|
2985
|
+
Re(),
|
|
2986
|
+
K
|
|
2987
|
+
].filter((u) => !!u),
|
|
2988
|
+
issueData: {
|
|
2989
|
+
code: d.invalid_return_type,
|
|
2990
|
+
returnTypeError: c
|
|
2991
|
+
}
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
const s = { errorMap: r.common.contextualErrorMap }, i = r.data;
|
|
2995
|
+
if (this._def.returns instanceof ee) {
|
|
2996
|
+
const o = this;
|
|
2997
|
+
return E(async function(...c) {
|
|
2998
|
+
const u = new $([]), l = await o._def.args.parseAsync(c, s).catch((m) => {
|
|
2999
|
+
throw u.addIssue(a(c, m)), u;
|
|
3000
|
+
}), p = await Reflect.apply(i, this, l);
|
|
3001
|
+
return await o._def.returns._def.type.parseAsync(p, s).catch((m) => {
|
|
3002
|
+
throw u.addIssue(n(p, m)), u;
|
|
3003
|
+
});
|
|
3004
|
+
});
|
|
3005
|
+
} else {
|
|
3006
|
+
const o = this;
|
|
3007
|
+
return E(function(...c) {
|
|
3008
|
+
const u = o._def.args.safeParse(c, s);
|
|
3009
|
+
if (!u.success)
|
|
3010
|
+
throw new $([a(c, u.error)]);
|
|
3011
|
+
const l = Reflect.apply(i, this, u.data), p = o._def.returns.safeParse(l, s);
|
|
3012
|
+
if (!p.success)
|
|
3013
|
+
throw new $([n(l, p.error)]);
|
|
3014
|
+
return p.data;
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
}
|
|
3018
|
+
parameters() {
|
|
3019
|
+
return this._def.args;
|
|
3020
|
+
}
|
|
3021
|
+
returnType() {
|
|
3022
|
+
return this._def.returns;
|
|
3023
|
+
}
|
|
3024
|
+
args(...e) {
|
|
3025
|
+
return new Ie({
|
|
3026
|
+
...this._def,
|
|
3027
|
+
args: L.create(e).rest(q.create())
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
returns(e) {
|
|
3031
|
+
return new Ie({
|
|
3032
|
+
...this._def,
|
|
3033
|
+
returns: e
|
|
3034
|
+
});
|
|
3035
|
+
}
|
|
3036
|
+
implement(e) {
|
|
3037
|
+
return this.parse(e);
|
|
3038
|
+
}
|
|
3039
|
+
strictImplement(e) {
|
|
3040
|
+
return this.parse(e);
|
|
3041
|
+
}
|
|
3042
|
+
static create(e, r, a) {
|
|
3043
|
+
return new Ie({
|
|
3044
|
+
args: e || L.create([]).rest(q.create()),
|
|
3045
|
+
returns: r || q.create(),
|
|
3046
|
+
typeName: y.ZodFunction,
|
|
3047
|
+
...x(a)
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
}, be = class extends k {
|
|
3051
|
+
get schema() {
|
|
3052
|
+
return this._def.getter();
|
|
3053
|
+
}
|
|
3054
|
+
_parse(t) {
|
|
3055
|
+
const { ctx: e } = this._processInputParams(t);
|
|
3056
|
+
return this._def.getter()._parse({ data: e.data, path: e.path, parent: e });
|
|
3057
|
+
}
|
|
3058
|
+
};
|
|
3059
|
+
be.create = (t, e) => new be({
|
|
3060
|
+
getter: t,
|
|
3061
|
+
typeName: y.ZodLazy,
|
|
3062
|
+
...x(e)
|
|
3063
|
+
});
|
|
3064
|
+
var we = class extends k {
|
|
3065
|
+
_parse(t) {
|
|
3066
|
+
if (t.data !== this._def.value) {
|
|
3067
|
+
const e = this._getOrReturnCtx(t);
|
|
3068
|
+
return f(e, {
|
|
3069
|
+
received: e.data,
|
|
3070
|
+
code: d.invalid_literal,
|
|
3071
|
+
expected: this._def.value
|
|
3072
|
+
}), _;
|
|
3073
|
+
}
|
|
3074
|
+
return { status: "valid", value: t.data };
|
|
3075
|
+
}
|
|
3076
|
+
get value() {
|
|
3077
|
+
return this._def.value;
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
we.create = (t, e) => new we({
|
|
3081
|
+
value: t,
|
|
3082
|
+
typeName: y.ZodLiteral,
|
|
3083
|
+
...x(e)
|
|
3084
|
+
});
|
|
3085
|
+
function Jt(t, e) {
|
|
3086
|
+
return new Oe({
|
|
3087
|
+
values: t,
|
|
3088
|
+
typeName: y.ZodEnum,
|
|
3089
|
+
...x(e)
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
var Oe = class it extends k {
|
|
3093
|
+
constructor() {
|
|
3094
|
+
super(...arguments), oe.set(this, void 0);
|
|
3095
|
+
}
|
|
3096
|
+
_parse(e) {
|
|
3097
|
+
if (typeof e.data != "string") {
|
|
3098
|
+
const r = this._getOrReturnCtx(e), a = this._def.values;
|
|
3099
|
+
return f(r, {
|
|
3100
|
+
expected: C.joinValues(a),
|
|
3101
|
+
received: r.parsedType,
|
|
3102
|
+
code: d.invalid_type
|
|
3103
|
+
}), _;
|
|
3104
|
+
}
|
|
3105
|
+
if (Pe(this, oe) || Dt(this, oe, new Set(this._def.values)), !Pe(this, oe).has(e.data)) {
|
|
3106
|
+
const r = this._getOrReturnCtx(e), a = this._def.values;
|
|
3107
|
+
return f(r, {
|
|
3108
|
+
received: r.data,
|
|
3109
|
+
code: d.invalid_enum_value,
|
|
3110
|
+
options: a
|
|
3111
|
+
}), _;
|
|
3112
|
+
}
|
|
3113
|
+
return E(e.data);
|
|
3114
|
+
}
|
|
3115
|
+
get options() {
|
|
3116
|
+
return this._def.values;
|
|
3117
|
+
}
|
|
3118
|
+
get enum() {
|
|
3119
|
+
const e = {};
|
|
3120
|
+
for (const r of this._def.values)
|
|
3121
|
+
e[r] = r;
|
|
3122
|
+
return e;
|
|
3123
|
+
}
|
|
3124
|
+
get Values() {
|
|
3125
|
+
const e = {};
|
|
3126
|
+
for (const r of this._def.values)
|
|
3127
|
+
e[r] = r;
|
|
3128
|
+
return e;
|
|
3129
|
+
}
|
|
3130
|
+
get Enum() {
|
|
3131
|
+
const e = {};
|
|
3132
|
+
for (const r of this._def.values)
|
|
3133
|
+
e[r] = r;
|
|
3134
|
+
return e;
|
|
3135
|
+
}
|
|
3136
|
+
extract(e, r = this._def) {
|
|
3137
|
+
return it.create(e, {
|
|
3138
|
+
...this._def,
|
|
3139
|
+
...r
|
|
3140
|
+
});
|
|
3141
|
+
}
|
|
3142
|
+
exclude(e, r = this._def) {
|
|
3143
|
+
return it.create(this.options.filter((a) => !e.includes(a)), {
|
|
3144
|
+
...this._def,
|
|
3145
|
+
...r
|
|
3146
|
+
});
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
oe = /* @__PURE__ */ new WeakMap();
|
|
3150
|
+
Oe.create = Jt;
|
|
3151
|
+
var xe = class extends k {
|
|
3152
|
+
constructor() {
|
|
3153
|
+
super(...arguments), ce.set(this, void 0);
|
|
3154
|
+
}
|
|
3155
|
+
_parse(t) {
|
|
3156
|
+
const e = C.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(t);
|
|
3157
|
+
if (r.parsedType !== h.string && r.parsedType !== h.number) {
|
|
3158
|
+
const a = C.objectValues(e);
|
|
3159
|
+
return f(r, {
|
|
3160
|
+
expected: C.joinValues(a),
|
|
3161
|
+
received: r.parsedType,
|
|
3162
|
+
code: d.invalid_type
|
|
3163
|
+
}), _;
|
|
3164
|
+
}
|
|
3165
|
+
if (Pe(this, ce) || Dt(this, ce, new Set(C.getValidEnumValues(this._def.values))), !Pe(this, ce).has(t.data)) {
|
|
3166
|
+
const a = C.objectValues(e);
|
|
3167
|
+
return f(r, {
|
|
3168
|
+
received: r.data,
|
|
3169
|
+
code: d.invalid_enum_value,
|
|
3170
|
+
options: a
|
|
3171
|
+
}), _;
|
|
3172
|
+
}
|
|
3173
|
+
return E(t.data);
|
|
3174
|
+
}
|
|
3175
|
+
get enum() {
|
|
3176
|
+
return this._def.values;
|
|
3177
|
+
}
|
|
3178
|
+
};
|
|
3179
|
+
ce = /* @__PURE__ */ new WeakMap();
|
|
3180
|
+
xe.create = (t, e) => new xe({
|
|
3181
|
+
values: t,
|
|
3182
|
+
typeName: y.ZodNativeEnum,
|
|
3183
|
+
...x(e)
|
|
3184
|
+
});
|
|
3185
|
+
var ee = class extends k {
|
|
3186
|
+
unwrap() {
|
|
3187
|
+
return this._def.type;
|
|
3188
|
+
}
|
|
3189
|
+
_parse(t) {
|
|
3190
|
+
const { ctx: e } = this._processInputParams(t);
|
|
3191
|
+
if (e.parsedType !== h.promise && e.common.async === !1)
|
|
3192
|
+
return f(e, {
|
|
3193
|
+
code: d.invalid_type,
|
|
3194
|
+
expected: h.promise,
|
|
3195
|
+
received: e.parsedType
|
|
3196
|
+
}), _;
|
|
3197
|
+
const r = e.parsedType === h.promise ? e.data : Promise.resolve(e.data);
|
|
3198
|
+
return E(r.then((a) => this._def.type.parseAsync(a, {
|
|
3199
|
+
path: e.path,
|
|
3200
|
+
errorMap: e.common.contextualErrorMap
|
|
3201
|
+
})));
|
|
3202
|
+
}
|
|
3203
|
+
};
|
|
3204
|
+
ee.create = (t, e) => new ee({
|
|
3205
|
+
type: t,
|
|
3206
|
+
typeName: y.ZodPromise,
|
|
3207
|
+
...x(e)
|
|
3208
|
+
});
|
|
3209
|
+
var z = class extends k {
|
|
3210
|
+
innerType() {
|
|
3211
|
+
return this._def.schema;
|
|
3212
|
+
}
|
|
3213
|
+
sourceType() {
|
|
3214
|
+
return this._def.schema._def.typeName === y.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3215
|
+
}
|
|
3216
|
+
_parse(t) {
|
|
3217
|
+
const { status: e, ctx: r } = this._processInputParams(t), a = this._def.effect || null, n = {
|
|
3218
|
+
addIssue: (s) => {
|
|
3219
|
+
f(r, s), s.fatal ? e.abort() : e.dirty();
|
|
3220
|
+
},
|
|
3221
|
+
get path() {
|
|
3222
|
+
return r.path;
|
|
3223
|
+
}
|
|
3224
|
+
};
|
|
3225
|
+
if (n.addIssue = n.addIssue.bind(n), a.type === "preprocess") {
|
|
3226
|
+
const s = a.transform(r.data, n);
|
|
3227
|
+
if (r.common.async)
|
|
3228
|
+
return Promise.resolve(s).then(async (i) => {
|
|
3229
|
+
if (e.value === "aborted")
|
|
3230
|
+
return _;
|
|
3231
|
+
const o = await this._def.schema._parseAsync({
|
|
3232
|
+
data: i,
|
|
3233
|
+
path: r.path,
|
|
3234
|
+
parent: r
|
|
3235
|
+
});
|
|
3236
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || e.value === "dirty" ? Y(o.value) : o;
|
|
3237
|
+
});
|
|
3238
|
+
{
|
|
3239
|
+
if (e.value === "aborted")
|
|
3240
|
+
return _;
|
|
3241
|
+
const i = this._def.schema._parseSync({
|
|
3242
|
+
data: s,
|
|
3243
|
+
path: r.path,
|
|
3244
|
+
parent: r
|
|
3245
|
+
});
|
|
3246
|
+
return i.status === "aborted" ? _ : i.status === "dirty" || e.value === "dirty" ? Y(i.value) : i;
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
if (a.type === "refinement") {
|
|
3250
|
+
const s = (i) => {
|
|
3251
|
+
const o = a.refinement(i, n);
|
|
3252
|
+
if (r.common.async)
|
|
3253
|
+
return Promise.resolve(o);
|
|
3254
|
+
if (o instanceof Promise)
|
|
3255
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3256
|
+
return i;
|
|
3257
|
+
};
|
|
3258
|
+
if (r.common.async === !1) {
|
|
3259
|
+
const i = this._def.schema._parseSync({
|
|
3260
|
+
data: r.data,
|
|
3261
|
+
path: r.path,
|
|
3262
|
+
parent: r
|
|
3263
|
+
});
|
|
3264
|
+
return i.status === "aborted" ? _ : (i.status === "dirty" && e.dirty(), s(i.value), { status: e.value, value: i.value });
|
|
3265
|
+
} else
|
|
3266
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((i) => i.status === "aborted" ? _ : (i.status === "dirty" && e.dirty(), s(i.value).then(() => ({ status: e.value, value: i.value }))));
|
|
3267
|
+
}
|
|
3268
|
+
if (a.type === "transform")
|
|
3269
|
+
if (r.common.async === !1) {
|
|
3270
|
+
const s = this._def.schema._parseSync({
|
|
3271
|
+
data: r.data,
|
|
3272
|
+
path: r.path,
|
|
3273
|
+
parent: r
|
|
3274
|
+
});
|
|
3275
|
+
if (!G(s))
|
|
3276
|
+
return s;
|
|
3277
|
+
const i = a.transform(s.value, n);
|
|
3278
|
+
if (i instanceof Promise)
|
|
3279
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3280
|
+
return { status: e.value, value: i };
|
|
3281
|
+
} else
|
|
3282
|
+
return this._def.schema._parseAsync({ data: r.data, path: r.path, parent: r }).then((s) => G(s) ? Promise.resolve(a.transform(s.value, n)).then((i) => ({ status: e.value, value: i })) : s);
|
|
3283
|
+
C.assertNever(a);
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
z.create = (t, e, r) => new z({
|
|
3287
|
+
schema: t,
|
|
3288
|
+
typeName: y.ZodEffects,
|
|
3289
|
+
effect: e,
|
|
3290
|
+
...x(r)
|
|
3291
|
+
});
|
|
3292
|
+
z.createWithPreprocess = (t, e, r) => new z({
|
|
3293
|
+
schema: e,
|
|
3294
|
+
effect: { type: "preprocess", transform: t },
|
|
3295
|
+
typeName: y.ZodEffects,
|
|
3296
|
+
...x(r)
|
|
3297
|
+
});
|
|
3298
|
+
var D = class extends k {
|
|
3299
|
+
_parse(t) {
|
|
3300
|
+
return this._getType(t) === h.undefined ? E(void 0) : this._def.innerType._parse(t);
|
|
3301
|
+
}
|
|
3302
|
+
unwrap() {
|
|
3303
|
+
return this._def.innerType;
|
|
3304
|
+
}
|
|
3305
|
+
};
|
|
3306
|
+
D.create = (t, e) => new D({
|
|
3307
|
+
innerType: t,
|
|
3308
|
+
typeName: y.ZodOptional,
|
|
3309
|
+
...x(e)
|
|
3310
|
+
});
|
|
3311
|
+
var W = class extends k {
|
|
3312
|
+
_parse(t) {
|
|
3313
|
+
return this._getType(t) === h.null ? E(null) : this._def.innerType._parse(t);
|
|
3314
|
+
}
|
|
3315
|
+
unwrap() {
|
|
3316
|
+
return this._def.innerType;
|
|
3317
|
+
}
|
|
3318
|
+
};
|
|
3319
|
+
W.create = (t, e) => new W({
|
|
3320
|
+
innerType: t,
|
|
3321
|
+
typeName: y.ZodNullable,
|
|
3322
|
+
...x(e)
|
|
3323
|
+
});
|
|
3324
|
+
var ke = class extends k {
|
|
3325
|
+
_parse(t) {
|
|
3326
|
+
const { ctx: e } = this._processInputParams(t);
|
|
3327
|
+
let r = e.data;
|
|
3328
|
+
return e.parsedType === h.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
|
|
3329
|
+
data: r,
|
|
3330
|
+
path: e.path,
|
|
3331
|
+
parent: e
|
|
3332
|
+
});
|
|
3333
|
+
}
|
|
3334
|
+
removeDefault() {
|
|
3335
|
+
return this._def.innerType;
|
|
3336
|
+
}
|
|
3337
|
+
};
|
|
3338
|
+
ke.create = (t, e) => new ke({
|
|
3339
|
+
innerType: t,
|
|
3340
|
+
typeName: y.ZodDefault,
|
|
3341
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3342
|
+
...x(e)
|
|
3343
|
+
});
|
|
3344
|
+
var Te = class extends k {
|
|
3345
|
+
_parse(t) {
|
|
3346
|
+
const { ctx: e } = this._processInputParams(t), r = {
|
|
3347
|
+
...e,
|
|
3348
|
+
common: {
|
|
3349
|
+
...e.common,
|
|
3350
|
+
issues: []
|
|
3351
|
+
}
|
|
3352
|
+
}, a = this._def.innerType._parse({
|
|
3353
|
+
data: r.data,
|
|
3354
|
+
path: r.path,
|
|
3355
|
+
parent: {
|
|
3356
|
+
...r
|
|
3357
|
+
}
|
|
3358
|
+
});
|
|
3359
|
+
return le(a) ? a.then((n) => ({
|
|
3360
|
+
status: "valid",
|
|
3361
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
3362
|
+
get error() {
|
|
3363
|
+
return new $(r.common.issues);
|
|
3364
|
+
},
|
|
3365
|
+
input: r.data
|
|
3366
|
+
})
|
|
3367
|
+
})) : {
|
|
3368
|
+
status: "valid",
|
|
3369
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
3370
|
+
get error() {
|
|
3371
|
+
return new $(r.common.issues);
|
|
3372
|
+
},
|
|
3373
|
+
input: r.data
|
|
3374
|
+
})
|
|
3375
|
+
};
|
|
3376
|
+
}
|
|
3377
|
+
removeCatch() {
|
|
3378
|
+
return this._def.innerType;
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
Te.create = (t, e) => new Te({
|
|
3382
|
+
innerType: t,
|
|
3383
|
+
typeName: y.ZodCatch,
|
|
3384
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3385
|
+
...x(e)
|
|
3386
|
+
});
|
|
3387
|
+
var Ue = class extends k {
|
|
3388
|
+
_parse(t) {
|
|
3389
|
+
if (this._getType(t) !== h.nan) {
|
|
3390
|
+
const r = this._getOrReturnCtx(t);
|
|
3391
|
+
return f(r, {
|
|
3392
|
+
code: d.invalid_type,
|
|
3393
|
+
expected: h.nan,
|
|
3394
|
+
received: r.parsedType
|
|
3395
|
+
}), _;
|
|
3396
|
+
}
|
|
3397
|
+
return { status: "valid", value: t.data };
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
Ue.create = (t) => new Ue({
|
|
3401
|
+
typeName: y.ZodNaN,
|
|
3402
|
+
...x(t)
|
|
3403
|
+
});
|
|
3404
|
+
var Rn = Symbol("zod_brand"), ft = class extends k {
|
|
3405
|
+
_parse(t) {
|
|
3406
|
+
const { ctx: e } = this._processInputParams(t), r = e.data;
|
|
3407
|
+
return this._def.type._parse({
|
|
3408
|
+
data: r,
|
|
3409
|
+
path: e.path,
|
|
3410
|
+
parent: e
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
unwrap() {
|
|
3414
|
+
return this._def.type;
|
|
3415
|
+
}
|
|
3416
|
+
}, ht = class Yt extends k {
|
|
3417
|
+
_parse(e) {
|
|
3418
|
+
const { status: r, ctx: a } = this._processInputParams(e);
|
|
3419
|
+
if (a.common.async)
|
|
3420
|
+
return (async () => {
|
|
3421
|
+
const s = await this._def.in._parseAsync({
|
|
3422
|
+
data: a.data,
|
|
3423
|
+
path: a.path,
|
|
3424
|
+
parent: a
|
|
3425
|
+
});
|
|
3426
|
+
return s.status === "aborted" ? _ : s.status === "dirty" ? (r.dirty(), Y(s.value)) : this._def.out._parseAsync({
|
|
3427
|
+
data: s.value,
|
|
3428
|
+
path: a.path,
|
|
3429
|
+
parent: a
|
|
3430
|
+
});
|
|
3431
|
+
})();
|
|
3432
|
+
{
|
|
3433
|
+
const n = this._def.in._parseSync({
|
|
3434
|
+
data: a.data,
|
|
3435
|
+
path: a.path,
|
|
3436
|
+
parent: a
|
|
3437
|
+
});
|
|
3438
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (r.dirty(), {
|
|
3439
|
+
status: "dirty",
|
|
3440
|
+
value: n.value
|
|
3441
|
+
}) : this._def.out._parseSync({
|
|
3442
|
+
data: n.value,
|
|
3443
|
+
path: a.path,
|
|
3444
|
+
parent: a
|
|
3445
|
+
});
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
static create(e, r) {
|
|
3449
|
+
return new Yt({
|
|
3450
|
+
in: e,
|
|
3451
|
+
out: r,
|
|
3452
|
+
typeName: y.ZodPipeline
|
|
3453
|
+
});
|
|
3454
|
+
}
|
|
3455
|
+
}, Ce = class extends k {
|
|
3456
|
+
_parse(t) {
|
|
3457
|
+
const e = this._def.innerType._parse(t), r = (a) => (G(a) && (a.value = Object.freeze(a.value)), a);
|
|
3458
|
+
return le(e) ? e.then((a) => r(a)) : r(e);
|
|
3459
|
+
}
|
|
3460
|
+
unwrap() {
|
|
3461
|
+
return this._def.innerType;
|
|
3462
|
+
}
|
|
3463
|
+
};
|
|
3464
|
+
Ce.create = (t, e) => new Ce({
|
|
3465
|
+
innerType: t,
|
|
3466
|
+
typeName: y.ZodReadonly,
|
|
3467
|
+
...x(e)
|
|
3468
|
+
});
|
|
3469
|
+
function bt(t, e) {
|
|
3470
|
+
const r = typeof t == "function" ? t(e) : typeof t == "string" ? { message: t } : t;
|
|
3471
|
+
return typeof r == "string" ? { message: r } : r;
|
|
3472
|
+
}
|
|
3473
|
+
function Kt(t, e = {}, r) {
|
|
3474
|
+
return t ? Q.create().superRefine((a, n) => {
|
|
3475
|
+
var s, i;
|
|
3476
|
+
const o = t(a);
|
|
3477
|
+
if (o instanceof Promise)
|
|
3478
|
+
return o.then((c) => {
|
|
3479
|
+
var u, l;
|
|
3480
|
+
if (!c) {
|
|
3481
|
+
const p = bt(e, a), g = (l = (u = p.fatal) !== null && u !== void 0 ? u : r) !== null && l !== void 0 ? l : !0;
|
|
3482
|
+
n.addIssue({ code: "custom", ...p, fatal: g });
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3485
|
+
if (!o) {
|
|
3486
|
+
const c = bt(e, a), u = (i = (s = c.fatal) !== null && s !== void 0 ? s : r) !== null && i !== void 0 ? i : !0;
|
|
3487
|
+
n.addIssue({ code: "custom", ...c, fatal: u });
|
|
3488
|
+
}
|
|
3489
|
+
}) : Q.create();
|
|
3490
|
+
}
|
|
3491
|
+
var Nn = {
|
|
3492
|
+
object: P.lazycreate
|
|
3493
|
+
}, y;
|
|
3494
|
+
(function(t) {
|
|
3495
|
+
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
3496
|
+
})(y || (y = {}));
|
|
3497
|
+
var Pn = (t, e = {
|
|
3498
|
+
message: `Input not instance of ${t.name}`
|
|
3499
|
+
}) => Kt((r) => r instanceof t, e), Xt = X.create, Qt = fe.create, Mn = Ue.create, $n = he.create, er = pe.create, zn = me.create, Dn = Me.create, Un = ve.create, Vn = ge.create, Bn = Q.create, Fn = q.create, Ln = F.create, Wn = $e.create, qn = H.create, Gn = P.create, Hn = P.strictCreate, Jn = ye.create, Yn = Lt.create, Kn = _e.create, Xn = L.create, Qn = Gt.create, es = ze.create, ts = De.create, rs = Ht.create, as = be.create, ns = we.create, ss = Oe.create, is = xe.create, os = ee.create, wt = z.create, cs = D.create, us = W.create, ds = z.createWithPreprocess, ls = ht.create, fs = () => Xt().optional(), hs = () => Qt().optional(), ps = () => er().optional(), ms = {
|
|
3500
|
+
string: (t) => X.create({ ...t, coerce: !0 }),
|
|
3501
|
+
number: (t) => fe.create({ ...t, coerce: !0 }),
|
|
3502
|
+
boolean: (t) => pe.create({
|
|
3503
|
+
...t,
|
|
3504
|
+
coerce: !0
|
|
3505
|
+
}),
|
|
3506
|
+
bigint: (t) => he.create({ ...t, coerce: !0 }),
|
|
3507
|
+
date: (t) => me.create({ ...t, coerce: !0 })
|
|
3508
|
+
}, vs = _, S = /* @__PURE__ */ Object.freeze({
|
|
3509
|
+
__proto__: null,
|
|
3510
|
+
defaultErrorMap: K,
|
|
3511
|
+
setErrorMap: dn,
|
|
3512
|
+
getErrorMap: Re,
|
|
3513
|
+
makeIssue: Ne,
|
|
3514
|
+
EMPTY_PATH: ln,
|
|
3515
|
+
addIssueToContext: f,
|
|
3516
|
+
ParseStatus: Z,
|
|
3517
|
+
INVALID: _,
|
|
3518
|
+
DIRTY: Y,
|
|
3519
|
+
OK: E,
|
|
3520
|
+
isAborted: Qe,
|
|
3521
|
+
isDirty: et,
|
|
3522
|
+
isValid: G,
|
|
3523
|
+
isAsync: le,
|
|
3524
|
+
get util() {
|
|
3525
|
+
return C;
|
|
3526
|
+
},
|
|
3527
|
+
get objectUtil() {
|
|
3528
|
+
return Xe;
|
|
3529
|
+
},
|
|
3530
|
+
ZodParsedType: h,
|
|
3531
|
+
getParsedType: B,
|
|
3532
|
+
ZodType: k,
|
|
3533
|
+
datetimeRegex: Bt,
|
|
3534
|
+
ZodString: X,
|
|
3535
|
+
ZodNumber: fe,
|
|
3536
|
+
ZodBigInt: he,
|
|
3537
|
+
ZodBoolean: pe,
|
|
3538
|
+
ZodDate: me,
|
|
3539
|
+
ZodSymbol: Me,
|
|
3540
|
+
ZodUndefined: ve,
|
|
3541
|
+
ZodNull: ge,
|
|
3542
|
+
ZodAny: Q,
|
|
3543
|
+
ZodUnknown: q,
|
|
3544
|
+
ZodNever: F,
|
|
3545
|
+
ZodVoid: $e,
|
|
3546
|
+
ZodArray: H,
|
|
3547
|
+
ZodObject: P,
|
|
3548
|
+
ZodUnion: ye,
|
|
3549
|
+
ZodDiscriminatedUnion: Lt,
|
|
3550
|
+
ZodIntersection: _e,
|
|
3551
|
+
ZodTuple: L,
|
|
3552
|
+
ZodRecord: Gt,
|
|
3553
|
+
ZodMap: ze,
|
|
3554
|
+
ZodSet: De,
|
|
3555
|
+
ZodFunction: Ht,
|
|
3556
|
+
ZodLazy: be,
|
|
3557
|
+
ZodLiteral: we,
|
|
3558
|
+
ZodEnum: Oe,
|
|
3559
|
+
ZodNativeEnum: xe,
|
|
3560
|
+
ZodPromise: ee,
|
|
3561
|
+
ZodEffects: z,
|
|
3562
|
+
ZodTransformer: z,
|
|
3563
|
+
ZodOptional: D,
|
|
3564
|
+
ZodNullable: W,
|
|
3565
|
+
ZodDefault: ke,
|
|
3566
|
+
ZodCatch: Te,
|
|
3567
|
+
ZodNaN: Ue,
|
|
3568
|
+
BRAND: Rn,
|
|
3569
|
+
ZodBranded: ft,
|
|
3570
|
+
ZodPipeline: ht,
|
|
3571
|
+
ZodReadonly: Ce,
|
|
3572
|
+
custom: Kt,
|
|
3573
|
+
Schema: k,
|
|
3574
|
+
ZodSchema: k,
|
|
3575
|
+
late: Nn,
|
|
3576
|
+
get ZodFirstPartyTypeKind() {
|
|
3577
|
+
return y;
|
|
3578
|
+
},
|
|
3579
|
+
coerce: ms,
|
|
3580
|
+
any: Bn,
|
|
3581
|
+
array: qn,
|
|
3582
|
+
bigint: $n,
|
|
3583
|
+
boolean: er,
|
|
3584
|
+
date: zn,
|
|
3585
|
+
discriminatedUnion: Yn,
|
|
3586
|
+
effect: wt,
|
|
3587
|
+
enum: ss,
|
|
3588
|
+
function: rs,
|
|
3589
|
+
instanceof: Pn,
|
|
3590
|
+
intersection: Kn,
|
|
3591
|
+
lazy: as,
|
|
3592
|
+
literal: ns,
|
|
3593
|
+
map: es,
|
|
3594
|
+
nan: Mn,
|
|
3595
|
+
nativeEnum: is,
|
|
3596
|
+
never: Ln,
|
|
3597
|
+
null: Vn,
|
|
3598
|
+
nullable: us,
|
|
3599
|
+
number: Qt,
|
|
3600
|
+
object: Gn,
|
|
3601
|
+
oboolean: ps,
|
|
3602
|
+
onumber: hs,
|
|
3603
|
+
optional: cs,
|
|
3604
|
+
ostring: fs,
|
|
3605
|
+
pipeline: ls,
|
|
3606
|
+
preprocess: ds,
|
|
3607
|
+
promise: os,
|
|
3608
|
+
record: Qn,
|
|
3609
|
+
set: ts,
|
|
3610
|
+
strictObject: Hn,
|
|
3611
|
+
string: Xt,
|
|
3612
|
+
symbol: Dn,
|
|
3613
|
+
transformer: wt,
|
|
3614
|
+
tuple: Xn,
|
|
3615
|
+
undefined: Un,
|
|
3616
|
+
union: Jn,
|
|
3617
|
+
unknown: Fn,
|
|
3618
|
+
void: Wn,
|
|
3619
|
+
NEVER: vs,
|
|
3620
|
+
ZodIssueCode: d,
|
|
3621
|
+
quotelessJson: un,
|
|
3622
|
+
ZodError: $
|
|
3623
|
+
}), xt = {
|
|
3624
|
+
name: "@imgly/background-removal",
|
|
3625
|
+
version: "1.7.0"
|
|
3626
|
+
}, gs = S.object({
|
|
3627
|
+
publicPath: S.string().optional().describe("The public path to the wasm files and the onnx model.").default(
|
|
3628
|
+
"https://staticimgly.com/@imgly/background-removal-data/${PACKAGE_VERSION}/dist/"
|
|
3629
|
+
).transform((t) => t.replace("${PACKAGE_NAME}", xt.name).replace("${PACKAGE_VERSION}", xt.version)),
|
|
3630
|
+
debug: S.boolean().default(!1).describe("Whether to enable debug logging."),
|
|
3631
|
+
rescale: S.boolean().default(!0).describe("Whether to rescale the image."),
|
|
3632
|
+
device: S.enum(["cpu", "gpu"]).default("cpu").describe("The device to run the model on."),
|
|
3633
|
+
proxyToWorker: S.boolean().default(!1).describe("Whether to proxy inference to a web worker."),
|
|
3634
|
+
fetchArgs: S.any().default({}).describe("Arguments to pass to fetch when loading the model."),
|
|
3635
|
+
progress: S.function().args(S.string(), S.number(), S.number()).returns(S.void()).describe("Progress callback.").optional(),
|
|
3636
|
+
model: S.preprocess(
|
|
3637
|
+
(t) => {
|
|
3638
|
+
switch (t) {
|
|
3639
|
+
case "large":
|
|
3640
|
+
return "isnet";
|
|
3641
|
+
case "small":
|
|
3642
|
+
return "isnet_quint8";
|
|
3643
|
+
case "medium":
|
|
3644
|
+
return "isnet_fp16";
|
|
3645
|
+
default:
|
|
3646
|
+
return t;
|
|
3647
|
+
}
|
|
3648
|
+
},
|
|
3649
|
+
S.enum(["isnet", "isnet_fp16", "isnet_quint8"])
|
|
3650
|
+
).default("medium"),
|
|
3651
|
+
output: S.object({
|
|
3652
|
+
format: S.enum([
|
|
3653
|
+
"image/png",
|
|
3654
|
+
"image/jpeg",
|
|
3655
|
+
"image/webp",
|
|
3656
|
+
"image/x-rgba8",
|
|
3657
|
+
"image/x-alpha8"
|
|
3658
|
+
]).default("image/png"),
|
|
3659
|
+
quality: S.number().default(0.8)
|
|
3660
|
+
}).default({})
|
|
3661
|
+
}).default({}).transform((t) => (t.debug && console.log("Config:", t), t.debug && !t.progress && (t.progress = t.progress ?? ((e, r, a) => {
|
|
3662
|
+
console.debug(`Downloading ${e}: ${r} of ${a}`);
|
|
3663
|
+
}), crossOriginIsolated || t.debug && console.debug(
|
|
3664
|
+
"Cross-Origin-Isolated is not enabled. Performance will be degraded. Please see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer."
|
|
3665
|
+
)), t));
|
|
3666
|
+
function ys(t) {
|
|
3667
|
+
return gs.parse(t ?? {});
|
|
3668
|
+
}
|
|
3669
|
+
var _s = Ve(Be());
|
|
3670
|
+
async function bs(t) {
|
|
3671
|
+
t.debug && console.debug("Loading model...", t.model);
|
|
3672
|
+
const e = t.model, a = await (await Nt(`/models/${e}`, t)).arrayBuffer();
|
|
3673
|
+
return await on(a, t);
|
|
3674
|
+
}
|
|
3675
|
+
async function ws(t) {
|
|
3676
|
+
t = ys(t);
|
|
3677
|
+
const e = await bs(t);
|
|
3678
|
+
return { config: t, session: { base: e } };
|
|
3679
|
+
}
|
|
3680
|
+
async function xs(t, e, r) {
|
|
3681
|
+
const [n, s, i] = t.shape, o = !1;
|
|
3682
|
+
let c = gt(
|
|
3683
|
+
t,
|
|
3684
|
+
1024,
|
|
3685
|
+
1024,
|
|
3686
|
+
o
|
|
3687
|
+
);
|
|
3688
|
+
const u = tn(c);
|
|
3689
|
+
let l = await cn(
|
|
3690
|
+
r.base,
|
|
3691
|
+
[["input", u]],
|
|
3692
|
+
["output"],
|
|
3693
|
+
e
|
|
3694
|
+
), p = (0, _s.default)(l[0].data, [1024, 1024, 1]), g = an(p);
|
|
3695
|
+
return e.rescale ? (g = gt(
|
|
3696
|
+
g,
|
|
3697
|
+
s,
|
|
3698
|
+
n,
|
|
3699
|
+
o
|
|
3700
|
+
), [g, t]) : [g, c];
|
|
3701
|
+
}
|
|
3702
|
+
var ks = Ha(ws, (t) => JSON.stringify(t));
|
|
3703
|
+
async function Ts(t, e) {
|
|
3704
|
+
const { config: r, session: a } = await ks(e);
|
|
3705
|
+
r.progress && r.progress("compute:decode", 0, 4);
|
|
3706
|
+
const n = await rn(t, r);
|
|
3707
|
+
r.progress?.("compute:inference", 1, 4);
|
|
3708
|
+
const [s, i] = await xs(
|
|
3709
|
+
n,
|
|
3710
|
+
r,
|
|
3711
|
+
a
|
|
3712
|
+
);
|
|
3713
|
+
r.progress?.("compute:mask", 2, 4);
|
|
3714
|
+
const o = i, [c, u] = o.shape, l = c * u;
|
|
3715
|
+
for (let g = 0; g < l; g += 1)
|
|
3716
|
+
o.data[4 * g + 3] = s.data[g];
|
|
3717
|
+
r.progress?.("compute:encode", 3, 4);
|
|
3718
|
+
const p = await Ya(
|
|
3719
|
+
o,
|
|
3720
|
+
r.output.quality,
|
|
3721
|
+
r.output.format
|
|
3722
|
+
);
|
|
3723
|
+
return r.progress?.("compute:encode", 4, 4), p;
|
|
3724
|
+
}
|
|
3725
|
+
/*! Bundled license information:
|
|
3726
|
+
|
|
3727
|
+
is-buffer/index.js:
|
|
3728
|
+
(*!
|
|
3729
|
+
* Determine if an object is a Buffer
|
|
3730
|
+
*
|
|
3731
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
3732
|
+
* @license MIT
|
|
3733
|
+
*)
|
|
3734
|
+
*/
|
|
3735
|
+
function kt(t, e, r, a) {
|
|
3736
|
+
if (!["image/png", "image/jpeg", "image/webp"].includes(t))
|
|
3737
|
+
return "请选择 PNG、JPEG 或 WebP 图片。";
|
|
3738
|
+
if (e <= 0) return "图片为空。";
|
|
3739
|
+
if (e > 25 * 1024 * 1024) return "图片不能超过 25 MB。";
|
|
3740
|
+
if (r !== void 0 && a !== void 0) {
|
|
3741
|
+
if (r <= 0 || a <= 0) return "图片尺寸无效。";
|
|
3742
|
+
if (r * a > 24e6) return "图片不能超过 2400 万像素。";
|
|
3743
|
+
}
|
|
3744
|
+
return null;
|
|
3745
|
+
}
|
|
3746
|
+
function Cs(t, e) {
|
|
3747
|
+
if (t.length !== e.length || t.length % 4) throw new Error("遮罩尺寸不匹配。");
|
|
3748
|
+
const r = new Uint8ClampedArray(t);
|
|
3749
|
+
for (let a = 3; a < r.length; a += 4) r[a] = Math.round(t[a] * e[a] / 255);
|
|
3750
|
+
return r;
|
|
3751
|
+
}
|
|
3752
|
+
function Os(t, e) {
|
|
3753
|
+
if (!t || typeof t != "object" || Object.getPrototypeOf(t) !== Object.prototype && Object.getPrototypeOf(t) !== null)
|
|
3754
|
+
throw new Error("图片参数无效");
|
|
3755
|
+
const r = Reflect.ownKeys(t);
|
|
3756
|
+
if (r.length !== e.length || r.some((a) => !e.includes(a)))
|
|
3757
|
+
throw new Error("图片参数字段无效");
|
|
3758
|
+
}
|
|
3759
|
+
function js(t) {
|
|
3760
|
+
if (!Number.isSafeInteger(t) || t < 0 || t > 4096)
|
|
3761
|
+
throw new Error("透明边距须为0至4096的整数");
|
|
3762
|
+
return t;
|
|
3763
|
+
}
|
|
3764
|
+
function ot(t, e) {
|
|
3765
|
+
if (!Number.isSafeInteger(t) || !Number.isSafeInteger(e) || t < 1 || e < 1 || t * e > 24e6)
|
|
3766
|
+
throw new Error("图片像素尺寸无效或超过24MP");
|
|
3767
|
+
}
|
|
3768
|
+
function tr(t, e, r) {
|
|
3769
|
+
if (ot(e, r), !(t instanceof Uint8ClampedArray) || t.length !== e * r * 4)
|
|
3770
|
+
throw new Error("图片RGBA数据无效");
|
|
3771
|
+
}
|
|
3772
|
+
function Ss(t, e, r) {
|
|
3773
|
+
tr(t, e, r);
|
|
3774
|
+
let a = e, n = r, s = -1, i = -1;
|
|
3775
|
+
for (let o = 0; o < r; o++)
|
|
3776
|
+
for (let c = 0; c < e; c++)
|
|
3777
|
+
t[(o * e + c) * 4 + 3] !== 0 && (a = Math.min(a, c), n = Math.min(n, o), s = Math.max(s, c), i = Math.max(i, o));
|
|
3778
|
+
return s < 0 ? { kind: "skip", reason: "fully-transparent" } : a === 0 && n === 0 && s === e - 1 && i === r - 1 ? { kind: "skip", reason: "no-transparent-border" } : {
|
|
3779
|
+
kind: "crop",
|
|
3780
|
+
rect: { x: a, y: n, width: s - a + 1, height: i - n + 1 }
|
|
3781
|
+
};
|
|
3782
|
+
}
|
|
3783
|
+
function As(t, e, r, a = 0) {
|
|
3784
|
+
if (ot(e, r), js(a), t.kind === "skip" && t.reason === "fully-transparent") return t;
|
|
3785
|
+
const n = t.kind === "crop" ? t.rect : { x: 0, y: 0, width: e, height: r }, s = n.width + 2 * a, i = n.height + 2 * a;
|
|
3786
|
+
return ot(s, i), { kind: "render", sourceRect: n, width: s, height: i, padding: a };
|
|
3787
|
+
}
|
|
3788
|
+
function Es(t, e, r, a) {
|
|
3789
|
+
if (tr(t, e, r), Os(a, ["x", "y", "width", "height"]), ![a.x, a.y, a.width, a.height].every(Number.isSafeInteger) || a.x < 0 || a.y < 0 || a.width < 1 || a.height < 1 || a.x + a.width > e || a.y + a.height > r)
|
|
3790
|
+
throw new Error("裁切框无效或超出图片边界");
|
|
3791
|
+
const n = new Uint8ClampedArray(a.width * a.height * 4), s = a.width * 4;
|
|
3792
|
+
for (let i = 0; i < a.height; i++) {
|
|
3793
|
+
const o = ((a.y + i) * e + a.x) * 4;
|
|
3794
|
+
n.set(t.subarray(o, o + s), i * s);
|
|
3795
|
+
}
|
|
3796
|
+
return n;
|
|
3797
|
+
}
|
|
3798
|
+
function Is(t, e = !1, r = "transparent", a = 0) {
|
|
3799
|
+
if (r !== "transparent" && !/^#[0-9a-f]{6}$/i.test(r))
|
|
3800
|
+
throw new Error("输出底色无效");
|
|
3801
|
+
let n = t, s = 0;
|
|
3802
|
+
if (e) {
|
|
3803
|
+
const i = t.getContext("2d", { willReadFrequently: !0 });
|
|
3804
|
+
if (!i) throw new Error("无法读取抠图alpha");
|
|
3805
|
+
const o = i.getImageData(0, 0, t.width, t.height), c = Ss(o.data, t.width, t.height);
|
|
3806
|
+
if (As(c, t.width, t.height, a).kind === "render" && (s = a), c.kind === "crop") {
|
|
3807
|
+
const l = c.rect;
|
|
3808
|
+
n = new OffscreenCanvas(l.width, l.height);
|
|
3809
|
+
const p = n.getContext("2d");
|
|
3810
|
+
if (!p) throw new Error("无法生成裁边结果");
|
|
3811
|
+
p.putImageData(
|
|
3812
|
+
new ImageData(
|
|
3813
|
+
new Uint8ClampedArray(Es(o.data, t.width, t.height, l)),
|
|
3814
|
+
l.width,
|
|
3815
|
+
l.height
|
|
3816
|
+
),
|
|
3817
|
+
0,
|
|
3818
|
+
0
|
|
3819
|
+
);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
if (r !== "transparent") {
|
|
3823
|
+
const i = n.getContext("2d");
|
|
3824
|
+
if (!i) throw new Error("无法合成输出底色");
|
|
3825
|
+
i.globalCompositeOperation = "destination-over", i.fillStyle = r, i.fillRect(0, 0, n.width, n.height), i.globalCompositeOperation = "source-over";
|
|
3826
|
+
}
|
|
3827
|
+
if (s > 0) {
|
|
3828
|
+
const i = new OffscreenCanvas(n.width + 2 * s, n.height + 2 * s), o = i.getContext("2d");
|
|
3829
|
+
if (!o) throw new Error("无法生成透明边距");
|
|
3830
|
+
o.drawImage(n, s, s), n = i;
|
|
3831
|
+
}
|
|
3832
|
+
return n;
|
|
3833
|
+
}
|
|
3834
|
+
const Ae = self;
|
|
3835
|
+
let Tt = !0, Ye = !1;
|
|
3836
|
+
Ae.onmessage = async ({
|
|
3837
|
+
data: t
|
|
3838
|
+
}) => {
|
|
3839
|
+
if (Ye) return;
|
|
3840
|
+
Ye = !0;
|
|
3841
|
+
const e = performance.now();
|
|
3842
|
+
let r, a;
|
|
3843
|
+
try {
|
|
3844
|
+
if (typeof t.publicPath != "string" || !/^https?:\/\//.test(t.publicPath))
|
|
3845
|
+
throw Error("MISSING_RESOURCE: explicit model base required");
|
|
3846
|
+
if (t.background && t.background !== "transparent" && !/^#[0-9a-f]{6}$/i.test(t.background))
|
|
3847
|
+
throw new Error("输出底色无效");
|
|
3848
|
+
const n = kt(t.blob.type, t.blob.size);
|
|
3849
|
+
if (n) throw new Error(n);
|
|
3850
|
+
r = await createImageBitmap(t.blob);
|
|
3851
|
+
const s = kt(t.blob.type, t.blob.size, r.width, r.height);
|
|
3852
|
+
if (s) throw new Error(s);
|
|
3853
|
+
const i = await Ts(t.blob, {
|
|
3854
|
+
publicPath: t.publicPath,
|
|
3855
|
+
model: t.model,
|
|
3856
|
+
device: "cpu",
|
|
3857
|
+
proxyToWorker: !1,
|
|
3858
|
+
output: { format: "image/png", quality: 1 },
|
|
3859
|
+
progress: (m, j, b) => Ae.postMessage({ type: "progress", key: m, current: j, total: b })
|
|
3860
|
+
});
|
|
3861
|
+
if (a = await createImageBitmap(i), a.width !== r.width || a.height !== r.height)
|
|
3862
|
+
throw new Error("输出尺寸与原图不一致。");
|
|
3863
|
+
const o = new OffscreenCanvas(r.width, r.height), c = o.getContext("2d", { willReadFrequently: !0 });
|
|
3864
|
+
c.drawImage(a, 0, 0);
|
|
3865
|
+
const u = c.getImageData(0, 0, o.width, o.height);
|
|
3866
|
+
c.clearRect(0, 0, o.width, o.height), c.drawImage(r, 0, 0);
|
|
3867
|
+
const l = c.getImageData(0, 0, o.width, o.height);
|
|
3868
|
+
l.data.set(Cs(l.data, u.data)), c.putImageData(l, 0, 0);
|
|
3869
|
+
const p = Is(
|
|
3870
|
+
o,
|
|
3871
|
+
t.trimTransparent === !0,
|
|
3872
|
+
t.background ?? "transparent",
|
|
3873
|
+
t.trimPadding ?? 0
|
|
3874
|
+
), g = await p.convertToBlob({ type: "image/png" });
|
|
3875
|
+
if (g.size > 25 * 1024 * 1024) throw new Error("抠图输出超过25 MiB");
|
|
3876
|
+
Ae.postMessage({
|
|
3877
|
+
type: "result",
|
|
3878
|
+
blob: g,
|
|
3879
|
+
latency_ms: Math.round(performance.now() - e),
|
|
3880
|
+
cold_start: Tt,
|
|
3881
|
+
backend: "wasm",
|
|
3882
|
+
width: p.width,
|
|
3883
|
+
height: p.height,
|
|
3884
|
+
engine_version: "1.7.0"
|
|
3885
|
+
}), Tt = !1;
|
|
3886
|
+
} catch (n) {
|
|
3887
|
+
Ae.postMessage({
|
|
3888
|
+
type: "error",
|
|
3889
|
+
error: n instanceof Error ? n.message : String(n)
|
|
3890
|
+
});
|
|
3891
|
+
} finally {
|
|
3892
|
+
r?.close(), a?.close(), Ye = !1;
|
|
3893
|
+
}
|
|
3894
|
+
};
|