@gengage/assistant-fe 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +61 -0
- package/README.md +232 -0
- package/dist/assistant-fe.css +1 -0
- package/dist/chat/api.d.ts +87 -0
- package/dist/chat/api.d.ts.map +1 -0
- package/dist/chat/attachment-utils.d.ts +10 -0
- package/dist/chat/attachment-utils.d.ts.map +1 -0
- package/dist/chat/catalog.d.ts +1114 -0
- package/dist/chat/catalog.d.ts.map +1 -0
- package/dist/chat/components/AIGroupingCards.d.ts +4 -0
- package/dist/chat/components/AIGroupingCards.d.ts.map +1 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts +4 -0
- package/dist/chat/components/AISuggestedSearchCards.d.ts.map +1 -0
- package/dist/chat/components/AITopPicks.d.ts +4 -0
- package/dist/chat/components/AITopPicks.d.ts.map +1 -0
- package/dist/chat/components/CategoriesContainer.d.ts +4 -0
- package/dist/chat/components/CategoriesContainer.d.ts.map +1 -0
- package/dist/chat/components/ChatDrawer.d.ts +140 -0
- package/dist/chat/components/ChatDrawer.d.ts.map +1 -0
- package/dist/chat/components/ChoicePrompter.d.ts +16 -0
- package/dist/chat/components/ChoicePrompter.d.ts.map +1 -0
- package/dist/chat/components/ComparisonTable.d.ts +47 -0
- package/dist/chat/components/ComparisonTable.d.ts.map +1 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts +11 -0
- package/dist/chat/components/FloatingComparisonButton.d.ts.map +1 -0
- package/dist/chat/components/GroundingReviewCard.d.ts +4 -0
- package/dist/chat/components/GroundingReviewCard.d.ts.map +1 -0
- package/dist/chat/components/KvkkBanner.d.ts +6 -0
- package/dist/chat/components/KvkkBanner.d.ts.map +1 -0
- package/dist/chat/components/Launcher.d.ts +25 -0
- package/dist/chat/components/Launcher.d.ts.map +1 -0
- package/dist/chat/components/PanelTopBar.d.ts +20 -0
- package/dist/chat/components/PanelTopBar.d.ts.map +1 -0
- package/dist/chat/components/ProactivePopup.d.ts +11 -0
- package/dist/chat/components/ProactivePopup.d.ts.map +1 -0
- package/dist/chat/components/ProsAndCons.d.ts +9 -0
- package/dist/chat/components/ProsAndCons.d.ts.map +1 -0
- package/dist/chat/components/ReviewHighlights.d.ts +3 -0
- package/dist/chat/components/ReviewHighlights.d.ts.map +1 -0
- package/dist/chat/components/ThumbnailsColumn.d.ts +23 -0
- package/dist/chat/components/ThumbnailsColumn.d.ts.map +1 -0
- package/dist/chat/components/actionClassifier.d.ts +13 -0
- package/dist/chat/components/actionClassifier.d.ts.map +1 -0
- package/dist/chat/components/productMentionLinker.d.ts +26 -0
- package/dist/chat/components/productMentionLinker.d.ts.map +1 -0
- package/dist/chat/components/renderUISpec.d.ts +15 -0
- package/dist/chat/components/renderUISpec.d.ts.map +1 -0
- package/dist/chat/components/typewriter.d.ts +25 -0
- package/dist/chat/components/typewriter.d.ts.map +1 -0
- package/dist/chat/extendedModeManager.d.ts +33 -0
- package/dist/chat/extendedModeManager.d.ts.map +1 -0
- package/dist/chat/index.d.ts +192 -0
- package/dist/chat/index.d.ts.map +1 -0
- package/dist/chat/locales/en.d.ts +3 -0
- package/dist/chat/locales/en.d.ts.map +1 -0
- package/dist/chat/locales/index.d.ts +6 -0
- package/dist/chat/locales/index.d.ts.map +1 -0
- package/dist/chat/locales/tr.d.ts +3 -0
- package/dist/chat/locales/tr.d.ts.map +1 -0
- package/dist/chat/types.d.ts +212 -0
- package/dist/chat/types.d.ts.map +1 -0
- package/dist/chat.cjs +2 -0
- package/dist/chat.cjs.map +1 -0
- package/dist/chat.iife.js +59 -0
- package/dist/chat.iife.js.map +1 -0
- package/dist/chat.js +11 -0
- package/dist/chat.js.map +1 -0
- package/dist/common/action-router.d.ts +30 -0
- package/dist/common/action-router.d.ts.map +1 -0
- package/dist/common/activity-tracker.d.ts +38 -0
- package/dist/common/activity-tracker.d.ts.map +1 -0
- package/dist/common/analytics-events.d.ts +90 -0
- package/dist/common/analytics-events.d.ts.map +1 -0
- package/dist/common/analytics.d.ts +58 -0
- package/dist/common/analytics.d.ts.map +1 -0
- package/dist/common/api-paths.d.ts +14 -0
- package/dist/common/api-paths.d.ts.map +1 -0
- package/dist/common/client.d.ts +20 -0
- package/dist/common/client.d.ts.map +1 -0
- package/dist/common/communication-bridge.d.ts +51 -0
- package/dist/common/communication-bridge.d.ts.map +1 -0
- package/dist/common/config-schema.d.ts +241 -0
- package/dist/common/config-schema.d.ts.map +1 -0
- package/dist/common/context.d.ts +28 -0
- package/dist/common/context.d.ts.map +1 -0
- package/dist/common/customization-factories.d.ts +63 -0
- package/dist/common/customization-factories.d.ts.map +1 -0
- package/dist/common/events.d.ts +47 -0
- package/dist/common/events.d.ts.map +1 -0
- package/dist/common/global-error-toast.d.ts +6 -0
- package/dist/common/global-error-toast.d.ts.map +1 -0
- package/dist/common/index.d.ts +36 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/indexed-db.d.ts +74 -0
- package/dist/common/indexed-db.d.ts.map +1 -0
- package/dist/common/overlay.d.ts +64 -0
- package/dist/common/overlay.d.ts.map +1 -0
- package/dist/common/preflight.d.ts +12 -0
- package/dist/common/preflight.d.ts.map +1 -0
- package/dist/common/renderer/dom.d.ts +4 -0
- package/dist/common/renderer/dom.d.ts.map +1 -0
- package/dist/common/renderer/index.d.ts +5 -0
- package/dist/common/renderer/index.d.ts.map +1 -0
- package/dist/common/renderer/overrides.d.ts +24 -0
- package/dist/common/renderer/overrides.d.ts.map +1 -0
- package/dist/common/renderer/registry.d.ts +3 -0
- package/dist/common/renderer/registry.d.ts.map +1 -0
- package/dist/common/renderer/types.d.ts +20 -0
- package/dist/common/renderer/types.d.ts.map +1 -0
- package/dist/common/safe-html.d.ts +19 -0
- package/dist/common/safe-html.d.ts.map +1 -0
- package/dist/common/streaming.d.ts +32 -0
- package/dist/common/streaming.d.ts.map +1 -0
- package/dist/common/theme-utils.d.ts +16 -0
- package/dist/common/theme-utils.d.ts.map +1 -0
- package/dist/common/types.d.ts +298 -0
- package/dist/common/types.d.ts.map +1 -0
- package/dist/common/ui-theme.d.ts +10 -0
- package/dist/common/ui-theme.d.ts.map +1 -0
- package/dist/common/uuidv7.d.ts +8 -0
- package/dist/common/uuidv7.d.ts.map +1 -0
- package/dist/common/v1-protocol-adapter.d.ts +66 -0
- package/dist/common/v1-protocol-adapter.d.ts.map +1 -0
- package/dist/common/widget-base.d.ts +75 -0
- package/dist/common/widget-base.d.ts.map +1 -0
- package/dist/common.cjs +2 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.js +584 -0
- package/dist/common.js.map +1 -0
- package/dist/index-CFA70IGF.js +3626 -0
- package/dist/index-CFA70IGF.js.map +1 -0
- package/dist/index-Dfl89zpe.cjs +13 -0
- package/dist/index-Dfl89zpe.cjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/qna/api.d.ts +22 -0
- package/dist/qna/api.d.ts.map +1 -0
- package/dist/qna/catalog.d.ts +140 -0
- package/dist/qna/catalog.d.ts.map +1 -0
- package/dist/qna/components/ButtonRow.d.ts +16 -0
- package/dist/qna/components/ButtonRow.d.ts.map +1 -0
- package/dist/qna/components/TextInput.d.ts +12 -0
- package/dist/qna/components/TextInput.d.ts.map +1 -0
- package/dist/qna/components/renderUISpec.d.ts +8 -0
- package/dist/qna/components/renderUISpec.d.ts.map +1 -0
- package/dist/qna/index.d.ts +34 -0
- package/dist/qna/index.d.ts.map +1 -0
- package/dist/qna/locales/en.d.ts +3 -0
- package/dist/qna/locales/en.d.ts.map +1 -0
- package/dist/qna/locales/index.d.ts +6 -0
- package/dist/qna/locales/index.d.ts.map +1 -0
- package/dist/qna/locales/tr.d.ts +3 -0
- package/dist/qna/locales/tr.d.ts.map +1 -0
- package/dist/qna/types.d.ts +62 -0
- package/dist/qna/types.d.ts.map +1 -0
- package/dist/qna.cjs +2 -0
- package/dist/qna.cjs.map +1 -0
- package/dist/qna.css +1 -0
- package/dist/qna.iife.js +48 -0
- package/dist/qna.iife.js.map +1 -0
- package/dist/qna.js +435 -0
- package/dist/qna.js.map +1 -0
- package/dist/simrel/api.d.ts +26 -0
- package/dist/simrel/api.d.ts.map +1 -0
- package/dist/simrel/catalog.d.ts +319 -0
- package/dist/simrel/catalog.d.ts.map +1 -0
- package/dist/simrel/components/GroupTabs.d.ts +17 -0
- package/dist/simrel/components/GroupTabs.d.ts.map +1 -0
- package/dist/simrel/components/ProductCard.d.ts +17 -0
- package/dist/simrel/components/ProductCard.d.ts.map +1 -0
- package/dist/simrel/components/ProductGrid.d.ts +17 -0
- package/dist/simrel/components/ProductGrid.d.ts.map +1 -0
- package/dist/simrel/components/renderUISpec.d.ts +8 -0
- package/dist/simrel/components/renderUISpec.d.ts.map +1 -0
- package/dist/simrel/index.d.ts +36 -0
- package/dist/simrel/index.d.ts.map +1 -0
- package/dist/simrel/locales/en.d.ts +3 -0
- package/dist/simrel/locales/en.d.ts.map +1 -0
- package/dist/simrel/locales/index.d.ts +6 -0
- package/dist/simrel/locales/index.d.ts.map +1 -0
- package/dist/simrel/locales/tr.d.ts +3 -0
- package/dist/simrel/locales/tr.d.ts.map +1 -0
- package/dist/simrel/types.d.ts +111 -0
- package/dist/simrel/types.d.ts.map +1 -0
- package/dist/simrel.cjs +2 -0
- package/dist/simrel.cjs.map +1 -0
- package/dist/simrel.css +1 -0
- package/dist/simrel.iife.js +48 -0
- package/dist/simrel.iife.js.map +1 -0
- package/dist/simrel.js +620 -0
- package/dist/simrel.js.map +1 -0
- package/dist/types-CeON7iBO.cjs +48 -0
- package/dist/types-CeON7iBO.cjs.map +1 -0
- package/dist/types-yxW8WA7u.js +4132 -0
- package/dist/types-yxW8WA7u.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,4132 @@
|
|
|
1
|
+
const Fe = ({ element: t, renderElement: e }) => {
|
|
2
|
+
if (!t.children || t.children.length === 0)
|
|
3
|
+
return null;
|
|
4
|
+
const n = document.createElement("div");
|
|
5
|
+
for (const s of t.children) {
|
|
6
|
+
const i = e(s);
|
|
7
|
+
i && n.appendChild(i);
|
|
8
|
+
}
|
|
9
|
+
return n;
|
|
10
|
+
};
|
|
11
|
+
function bn(t) {
|
|
12
|
+
const e = document.createElement("div");
|
|
13
|
+
if (e.className = t.containerClassName, !t.spec.elements[t.spec.root]) return e;
|
|
14
|
+
const s = t.unknownRenderer ?? Fe, i = (a) => {
|
|
15
|
+
const o = t.spec.elements[a];
|
|
16
|
+
if (!o) return null;
|
|
17
|
+
const c = t.registry[o.type];
|
|
18
|
+
return c ? c({
|
|
19
|
+
elementId: a,
|
|
20
|
+
element: o,
|
|
21
|
+
spec: t.spec,
|
|
22
|
+
context: t.context,
|
|
23
|
+
renderElement: i
|
|
24
|
+
}) : s({
|
|
25
|
+
elementId: a,
|
|
26
|
+
element: o,
|
|
27
|
+
spec: t.spec,
|
|
28
|
+
context: t.context,
|
|
29
|
+
renderElement: i
|
|
30
|
+
});
|
|
31
|
+
}, r = i(t.spec.root);
|
|
32
|
+
return r && e.appendChild(r), e;
|
|
33
|
+
}
|
|
34
|
+
function xn(t, e) {
|
|
35
|
+
if (!e) return t;
|
|
36
|
+
const n = { ...t };
|
|
37
|
+
for (const [s, i] of Object.entries(e))
|
|
38
|
+
i && (n[s] = i);
|
|
39
|
+
return n;
|
|
40
|
+
}
|
|
41
|
+
function Tn(t, e) {
|
|
42
|
+
const n = {
|
|
43
|
+
event_name: "stream.start",
|
|
44
|
+
account_id: t.account_id,
|
|
45
|
+
session_id: t.session_id,
|
|
46
|
+
correlation_id: t.correlation_id,
|
|
47
|
+
payload: {
|
|
48
|
+
endpoint: e.endpoint,
|
|
49
|
+
request_id: e.request_id
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), e.widget !== void 0 && (n.widget = e.widget), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
53
|
+
}
|
|
54
|
+
function Cn(t, e) {
|
|
55
|
+
const n = {
|
|
56
|
+
request_id: e.request_id,
|
|
57
|
+
chunk_index: e.chunk_index
|
|
58
|
+
};
|
|
59
|
+
e.latency_ms !== void 0 && (n.latency_ms = e.latency_ms);
|
|
60
|
+
const s = {
|
|
61
|
+
event_name: "stream.chunk",
|
|
62
|
+
account_id: t.account_id,
|
|
63
|
+
session_id: t.session_id,
|
|
64
|
+
correlation_id: t.correlation_id,
|
|
65
|
+
payload: n
|
|
66
|
+
};
|
|
67
|
+
return t.view_id !== void 0 && (s.view_id = t.view_id), t.user_id !== void 0 && (s.user_id = t.user_id), e.widget !== void 0 && (s.widget = e.widget), t.page_type !== void 0 && (s.page_type = t.page_type), t.sku !== void 0 && (s.sku = t.sku), s;
|
|
68
|
+
}
|
|
69
|
+
function Sn(t, e) {
|
|
70
|
+
const n = {
|
|
71
|
+
event_name: "stream.ui_spec",
|
|
72
|
+
account_id: t.account_id,
|
|
73
|
+
session_id: t.session_id,
|
|
74
|
+
correlation_id: t.correlation_id,
|
|
75
|
+
payload: {
|
|
76
|
+
request_id: e.request_id,
|
|
77
|
+
chunk_index: e.chunk_index,
|
|
78
|
+
component_type: e.component_type
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), e.widget !== void 0 && (n.widget = e.widget), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
82
|
+
}
|
|
83
|
+
function An(t, e) {
|
|
84
|
+
const n = {
|
|
85
|
+
event_name: "stream.done",
|
|
86
|
+
account_id: t.account_id,
|
|
87
|
+
session_id: t.session_id,
|
|
88
|
+
correlation_id: t.correlation_id,
|
|
89
|
+
payload: {
|
|
90
|
+
request_id: e.request_id,
|
|
91
|
+
latency_ms: e.latency_ms,
|
|
92
|
+
chunk_count: e.chunk_count
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), e.widget !== void 0 && (n.widget = e.widget), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
96
|
+
}
|
|
97
|
+
function En(t, e) {
|
|
98
|
+
const n = {
|
|
99
|
+
event_name: "stream.error",
|
|
100
|
+
account_id: t.account_id,
|
|
101
|
+
session_id: t.session_id,
|
|
102
|
+
correlation_id: t.correlation_id,
|
|
103
|
+
payload: {
|
|
104
|
+
request_id: e.request_id,
|
|
105
|
+
error_code: e.error_code,
|
|
106
|
+
error_message: e.error_message
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), e.widget !== void 0 && (n.widget = e.widget), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
110
|
+
}
|
|
111
|
+
function In(t, e) {
|
|
112
|
+
const n = {
|
|
113
|
+
model: e.model,
|
|
114
|
+
prompt_tokens: e.prompt_tokens,
|
|
115
|
+
completion_tokens: e.completion_tokens,
|
|
116
|
+
total_tokens: e.total_tokens
|
|
117
|
+
};
|
|
118
|
+
e.provider !== void 0 && (n.provider = e.provider);
|
|
119
|
+
const s = {
|
|
120
|
+
event_name: "llm.usage",
|
|
121
|
+
account_id: t.account_id,
|
|
122
|
+
session_id: t.session_id,
|
|
123
|
+
correlation_id: t.correlation_id,
|
|
124
|
+
payload: n
|
|
125
|
+
};
|
|
126
|
+
return t.view_id !== void 0 && (s.view_id = t.view_id), t.user_id !== void 0 && (s.user_id = t.user_id), t.page_type !== void 0 && (s.page_type = t.page_type), t.sku !== void 0 && (s.sku = t.sku), s;
|
|
127
|
+
}
|
|
128
|
+
function Nn(t, e) {
|
|
129
|
+
const n = {
|
|
130
|
+
event_name: "metering.increment",
|
|
131
|
+
account_id: t.account_id,
|
|
132
|
+
session_id: t.session_id,
|
|
133
|
+
correlation_id: t.correlation_id,
|
|
134
|
+
payload: {
|
|
135
|
+
meter_key: e.meter_key,
|
|
136
|
+
quantity: e.quantity,
|
|
137
|
+
unit: e.unit
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
141
|
+
}
|
|
142
|
+
function He(t, e) {
|
|
143
|
+
const n = {
|
|
144
|
+
event_name: "metering.summary",
|
|
145
|
+
account_id: t.account_id,
|
|
146
|
+
session_id: t.session_id,
|
|
147
|
+
correlation_id: t.correlation_id,
|
|
148
|
+
payload: {
|
|
149
|
+
meter_key: e.meter_key,
|
|
150
|
+
quantity: e.quantity,
|
|
151
|
+
unit: e.unit
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
155
|
+
}
|
|
156
|
+
function On(t, e) {
|
|
157
|
+
const n = {
|
|
158
|
+
event_name: "chat.history.snapshot",
|
|
159
|
+
account_id: t.account_id,
|
|
160
|
+
session_id: t.session_id,
|
|
161
|
+
correlation_id: t.correlation_id,
|
|
162
|
+
payload: {
|
|
163
|
+
message_count: e.message_count,
|
|
164
|
+
history_ref: e.history_ref,
|
|
165
|
+
redaction_level: e.redaction_level
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
169
|
+
}
|
|
170
|
+
function Rn(t, e) {
|
|
171
|
+
const n = {
|
|
172
|
+
event_name: "widget.history.snapshot",
|
|
173
|
+
account_id: t.account_id,
|
|
174
|
+
session_id: t.session_id,
|
|
175
|
+
correlation_id: t.correlation_id,
|
|
176
|
+
widget: e.widget,
|
|
177
|
+
payload: {
|
|
178
|
+
message_count: e.message_count,
|
|
179
|
+
history_ref: e.history_ref,
|
|
180
|
+
redaction_level: e.redaction_level
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
184
|
+
}
|
|
185
|
+
function Zn(t, e) {
|
|
186
|
+
const n = {
|
|
187
|
+
event_name: "basket.add",
|
|
188
|
+
account_id: t.account_id,
|
|
189
|
+
session_id: t.session_id,
|
|
190
|
+
correlation_id: t.correlation_id,
|
|
191
|
+
widget: e.attribution_source,
|
|
192
|
+
payload: {
|
|
193
|
+
attribution_source: e.attribution_source,
|
|
194
|
+
attribution_action_id: e.attribution_action_id,
|
|
195
|
+
cart_value: e.cart_value,
|
|
196
|
+
currency: e.currency,
|
|
197
|
+
line_items: e.line_items,
|
|
198
|
+
sku: e.sku
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
202
|
+
}
|
|
203
|
+
function Ge(t, e) {
|
|
204
|
+
const n = {
|
|
205
|
+
event_name: "checkout.start",
|
|
206
|
+
account_id: t.account_id,
|
|
207
|
+
session_id: t.session_id,
|
|
208
|
+
correlation_id: t.correlation_id,
|
|
209
|
+
widget: e.attribution_source,
|
|
210
|
+
payload: {
|
|
211
|
+
attribution_source: e.attribution_source,
|
|
212
|
+
attribution_action_id: e.attribution_action_id,
|
|
213
|
+
cart_value: e.cart_value,
|
|
214
|
+
currency: e.currency,
|
|
215
|
+
line_items: e.line_items
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
219
|
+
}
|
|
220
|
+
function Je(t, e) {
|
|
221
|
+
const n = {
|
|
222
|
+
event_name: "checkout.complete",
|
|
223
|
+
account_id: t.account_id,
|
|
224
|
+
session_id: t.session_id,
|
|
225
|
+
correlation_id: t.correlation_id,
|
|
226
|
+
widget: e.attribution_source,
|
|
227
|
+
payload: {
|
|
228
|
+
attribution_source: e.attribution_source,
|
|
229
|
+
attribution_action_id: e.attribution_action_id,
|
|
230
|
+
cart_value: e.cart_value,
|
|
231
|
+
currency: e.currency,
|
|
232
|
+
line_items: e.line_items
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
return t.view_id !== void 0 && (n.view_id = t.view_id), t.user_id !== void 0 && (n.user_id = t.user_id), t.page_type !== void 0 && (n.page_type = t.page_type), t.sku !== void 0 && (n.sku = t.sku), n;
|
|
236
|
+
}
|
|
237
|
+
function Pn(t, e) {
|
|
238
|
+
window.dispatchEvent(new CustomEvent(t, { detail: e, bubbles: !1 }));
|
|
239
|
+
}
|
|
240
|
+
function Q(t, e) {
|
|
241
|
+
const n = (s) => {
|
|
242
|
+
e(s.detail);
|
|
243
|
+
};
|
|
244
|
+
return window.addEventListener(t, n), () => window.removeEventListener(t, n);
|
|
245
|
+
}
|
|
246
|
+
function jn(t) {
|
|
247
|
+
let e = !1;
|
|
248
|
+
function n() {
|
|
249
|
+
return window.gengage?.chat !== void 0 ? !0 : (e || (console.warn(
|
|
250
|
+
"[gengage] QNA tried to open chat, but chat widget is not initialized. Ensure GengageChat is initialized before calling wireQNAToChat()."
|
|
251
|
+
), e = !0), t?.onChatUnavailable?.(), !1);
|
|
252
|
+
}
|
|
253
|
+
const s = Q("gengage:qna:action", (r) => {
|
|
254
|
+
n() && window.gengage?.chat?.openWithAction(r);
|
|
255
|
+
}), i = Q("gengage:qna:open-chat", () => {
|
|
256
|
+
n() && window.gengage?.chat?.open();
|
|
257
|
+
});
|
|
258
|
+
return () => {
|
|
259
|
+
s(), i();
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function Ln() {
|
|
263
|
+
return Q("gengage:similar:product-click", ({ sku: t, url: e, sessionId: n }) => {
|
|
264
|
+
n && window.gengage?.chat?.saveSession(n, t), window.location.href = e;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function Qe() {
|
|
268
|
+
const e = window.__gengageSessionId ?? sessionStorage.getItem("gengage_session_id") ?? null ?? crypto.randomUUID();
|
|
269
|
+
return window.__gengageSessionId = e, sessionStorage.setItem("gengage_session_id", e), window.gengage || (window.gengage = {}), window.gengage.sessionId = e, e;
|
|
270
|
+
}
|
|
271
|
+
function $n() {
|
|
272
|
+
return window.gengage?.pageContext ?? null;
|
|
273
|
+
}
|
|
274
|
+
function Dn(t) {
|
|
275
|
+
window.gengage || (window.gengage = {}), window.gengage.pageContext = {
|
|
276
|
+
pageType: "other",
|
|
277
|
+
...window.gengage.pageContext,
|
|
278
|
+
...t
|
|
279
|
+
}, window.dispatchEvent(new CustomEvent("gengage:context:update", { detail: t }));
|
|
280
|
+
}
|
|
281
|
+
function Ye(t) {
|
|
282
|
+
return {
|
|
283
|
+
sessionId: t?.sessionId ?? Qe(),
|
|
284
|
+
...t
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
const ke = {
|
|
288
|
+
"--gengage-chat-offset": "20px",
|
|
289
|
+
"--gengage-chat-launcher-size": "56px",
|
|
290
|
+
"--gengage-chat-width": "400px",
|
|
291
|
+
"--gengage-chat-shell-radius": "12px",
|
|
292
|
+
"--gengage-chat-header-height": "60px",
|
|
293
|
+
"--gengage-chat-conversation-width": "396px",
|
|
294
|
+
"--gengage-chat-panel-min-width": "320px",
|
|
295
|
+
"--gengage-chat-panel-max-width": "860px",
|
|
296
|
+
"--gengage-chat-input-height": "48px",
|
|
297
|
+
"--gengage-qna-pill-radius": "999px",
|
|
298
|
+
"--gengage-qna-input-radius": "14px",
|
|
299
|
+
"--gengage-simrel-card-radius": "14px"
|
|
300
|
+
};
|
|
301
|
+
function Ke(t) {
|
|
302
|
+
return t ? { ...ke, ...t } : { ...ke };
|
|
303
|
+
}
|
|
304
|
+
const P = "gengage-global-toast-root", we = "gengage-global-toast-style", _e = "gengage-global-toast-root--visible", Xe = 4200, et = 1500, tt = 15e3;
|
|
305
|
+
let be = !1, M = null;
|
|
306
|
+
function Mn(t) {
|
|
307
|
+
return typeof t == "string" && t.toLowerCase().startsWith("tr") ? "Baglanti sorunu olustu. Lutfen tekrar deneyin." : "Connection issue. Please try again.";
|
|
308
|
+
}
|
|
309
|
+
function nt() {
|
|
310
|
+
be || typeof window > "u" || typeof document > "u" || (be = !0, Q("gengage:global:error", (t) => {
|
|
311
|
+
st(t);
|
|
312
|
+
}));
|
|
313
|
+
}
|
|
314
|
+
function st(t) {
|
|
315
|
+
if (typeof document > "u") return;
|
|
316
|
+
const e = t.message.trim();
|
|
317
|
+
if (!e) return;
|
|
318
|
+
dt();
|
|
319
|
+
const n = at();
|
|
320
|
+
n.innerHTML = "";
|
|
321
|
+
const s = document.createElement("section");
|
|
322
|
+
s.className = "gengage-global-toast gengage-global-toast--error", s.setAttribute("role", "status"), s.setAttribute("aria-live", "polite");
|
|
323
|
+
const i = document.createElement("div");
|
|
324
|
+
i.className = "gengage-global-toast-title", i.textContent = rt(t.source);
|
|
325
|
+
const r = document.createElement("div");
|
|
326
|
+
r.className = "gengage-global-toast-message", r.textContent = e, s.appendChild(i), s.appendChild(r), n.appendChild(s), n.classList.add(_e), M && (clearTimeout(M), M = null), M = setTimeout(() => {
|
|
327
|
+
it();
|
|
328
|
+
}, ot(t.durationMs));
|
|
329
|
+
}
|
|
330
|
+
function it() {
|
|
331
|
+
if (typeof document > "u") return;
|
|
332
|
+
const t = document.getElementById(P);
|
|
333
|
+
t && (t.classList.remove(_e), t.innerHTML = "", M && (clearTimeout(M), M = null));
|
|
334
|
+
}
|
|
335
|
+
function rt(t) {
|
|
336
|
+
switch (t) {
|
|
337
|
+
case "chat":
|
|
338
|
+
return "Chat warning";
|
|
339
|
+
case "qna":
|
|
340
|
+
return "QnA warning";
|
|
341
|
+
case "simrel":
|
|
342
|
+
return "Widget warning";
|
|
343
|
+
default:
|
|
344
|
+
return "Connection warning";
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function at() {
|
|
348
|
+
const t = document.getElementById(P);
|
|
349
|
+
if (t instanceof HTMLElement) return t;
|
|
350
|
+
const e = document.createElement("div");
|
|
351
|
+
return e.id = P, e.className = "gengage-global-toast-root", document.body.appendChild(e), e;
|
|
352
|
+
}
|
|
353
|
+
function ot(t) {
|
|
354
|
+
return typeof t != "number" || !Number.isFinite(t) ? Xe : Math.min(tt, Math.max(et, Math.round(t)));
|
|
355
|
+
}
|
|
356
|
+
function dt() {
|
|
357
|
+
if (document.getElementById(we)) return;
|
|
358
|
+
const t = document.createElement("style");
|
|
359
|
+
t.id = we, t.textContent = `
|
|
360
|
+
#${P} {
|
|
361
|
+
position: fixed;
|
|
362
|
+
top: 16px;
|
|
363
|
+
right: 16px;
|
|
364
|
+
z-index: 2147483646;
|
|
365
|
+
pointer-events: none;
|
|
366
|
+
}
|
|
367
|
+
#${P}.${_e} {
|
|
368
|
+
pointer-events: auto;
|
|
369
|
+
}
|
|
370
|
+
#${P} .gengage-global-toast {
|
|
371
|
+
min-width: 260px;
|
|
372
|
+
max-width: min(92vw, 420px);
|
|
373
|
+
border-radius: 12px;
|
|
374
|
+
border: 1px solid #f5c2c7;
|
|
375
|
+
border-left: 4px solid #d93025;
|
|
376
|
+
background: #fff9f9;
|
|
377
|
+
color: #4a1f21;
|
|
378
|
+
box-shadow: 0 10px 30px rgba(38, 18, 18, 0.18);
|
|
379
|
+
padding: 10px 12px;
|
|
380
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
381
|
+
font-size: 13px;
|
|
382
|
+
line-height: 1.4;
|
|
383
|
+
animation: gengage-global-toast-in 180ms ease-out forwards;
|
|
384
|
+
}
|
|
385
|
+
#${P} .gengage-global-toast-title {
|
|
386
|
+
margin: 0 0 4px;
|
|
387
|
+
font-size: 12px;
|
|
388
|
+
font-weight: 700;
|
|
389
|
+
}
|
|
390
|
+
#${P} .gengage-global-toast-message {
|
|
391
|
+
margin: 0;
|
|
392
|
+
font-weight: 500;
|
|
393
|
+
}
|
|
394
|
+
@keyframes gengage-global-toast-in {
|
|
395
|
+
from {
|
|
396
|
+
opacity: 0;
|
|
397
|
+
transform: translateY(-8px);
|
|
398
|
+
}
|
|
399
|
+
to {
|
|
400
|
+
opacity: 1;
|
|
401
|
+
transform: translateY(0);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
`, document.head.appendChild(t);
|
|
405
|
+
}
|
|
406
|
+
class Vn {
|
|
407
|
+
constructor() {
|
|
408
|
+
this.isVisible = !1, this.isInitialised = !1, this._handlers = /* @__PURE__ */ new Map(), this._cleanups = [], this._ownsRoot = !1;
|
|
409
|
+
}
|
|
410
|
+
// ---------------------------------------------------------------------------
|
|
411
|
+
// Public API
|
|
412
|
+
// ---------------------------------------------------------------------------
|
|
413
|
+
async init(e) {
|
|
414
|
+
if (this.isInitialised) {
|
|
415
|
+
console.warn("[gengage] Widget already initialised. Call update() instead.");
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const n = Ke(e.theme);
|
|
419
|
+
this.config = {
|
|
420
|
+
...e,
|
|
421
|
+
theme: n,
|
|
422
|
+
session: Ye(e.session)
|
|
423
|
+
}, this.root = this._resolveMount(e.mountTarget), this._applyTheme(n), nt();
|
|
424
|
+
const s = Q("gengage:context:update", (i) => this.update(i));
|
|
425
|
+
this._cleanups.push(s), await this.onInit(this.config), this.isInitialised = !0, this.emit("ready");
|
|
426
|
+
}
|
|
427
|
+
update(e) {
|
|
428
|
+
this.isInitialised && (this.config.pageContext ? this.config = {
|
|
429
|
+
...this.config,
|
|
430
|
+
pageContext: { ...this.config.pageContext, ...e }
|
|
431
|
+
} : this.config = { ...this.config, pageContext: e }, this.onUpdate(e));
|
|
432
|
+
}
|
|
433
|
+
show() {
|
|
434
|
+
this.isVisible || (this.isVisible = !0, this.root.style.display = "", this.onShow(), this.emit("show"));
|
|
435
|
+
}
|
|
436
|
+
hide() {
|
|
437
|
+
this.isVisible && (this.isVisible = !1, this.root.style.display = "none", this.onHide(), this.emit("hide"));
|
|
438
|
+
}
|
|
439
|
+
destroy() {
|
|
440
|
+
this._cleanups.forEach((e) => e()), this._cleanups.length = 0, this._handlers.clear(), this.onDestroy(), this._ownsRoot ? this.root.remove() : this.root.innerHTML = "", this.isInitialised = !1;
|
|
441
|
+
}
|
|
442
|
+
on(e, n) {
|
|
443
|
+
return this._handlers.has(e) || this._handlers.set(e, /* @__PURE__ */ new Set()), this._handlers.get(e).add(n), () => this._handlers.get(e)?.delete(n);
|
|
444
|
+
}
|
|
445
|
+
/** Track a checkout start event. Called by host page to attribute checkout to widget interaction. */
|
|
446
|
+
trackCheckout(e, n) {
|
|
447
|
+
const s = e === "start" ? Ge : Je;
|
|
448
|
+
this.track(s(this.analyticsContext(), n));
|
|
449
|
+
}
|
|
450
|
+
/** Track a metering summary event. Called by host page for session-level aggregation. */
|
|
451
|
+
flushMeteringSummary(e) {
|
|
452
|
+
this.track(He(this.analyticsContext(), e));
|
|
453
|
+
}
|
|
454
|
+
// ---------------------------------------------------------------------------
|
|
455
|
+
// Protected helpers
|
|
456
|
+
// ---------------------------------------------------------------------------
|
|
457
|
+
/** Emit a widget event to all registered handlers. */
|
|
458
|
+
emit(e, ...n) {
|
|
459
|
+
this._handlers.get(e)?.forEach((s) => s(...n));
|
|
460
|
+
}
|
|
461
|
+
/** Register a cleanup function to run on destroy(). */
|
|
462
|
+
addCleanup(e) {
|
|
463
|
+
this._cleanups.push(e);
|
|
464
|
+
}
|
|
465
|
+
/** Track an analytics event (no-op if analyticsClient is not configured). */
|
|
466
|
+
track(e) {
|
|
467
|
+
this.config.analyticsClient?.track(e);
|
|
468
|
+
}
|
|
469
|
+
/** Build the shared analytics context from widget config. */
|
|
470
|
+
analyticsContext() {
|
|
471
|
+
const e = {
|
|
472
|
+
account_id: this.config.accountId,
|
|
473
|
+
session_id: this.config.session?.sessionId ?? "",
|
|
474
|
+
correlation_id: this.config.session?.sessionId ?? ""
|
|
475
|
+
};
|
|
476
|
+
return this.config.session?.viewId !== void 0 && (e.view_id = this.config.session.viewId), this.config.session?.userId !== void 0 && (e.user_id = this.config.session.userId), this.config.pageContext?.pageType !== void 0 && (e.page_type = this.config.pageContext.pageType), this.config.pageContext?.sku !== void 0 && (e.sku = this.config.pageContext.sku), e;
|
|
477
|
+
}
|
|
478
|
+
// ---------------------------------------------------------------------------
|
|
479
|
+
// Private helpers
|
|
480
|
+
// ---------------------------------------------------------------------------
|
|
481
|
+
_resolveMount(e) {
|
|
482
|
+
if (e instanceof HTMLElement) return e;
|
|
483
|
+
if (typeof e == "string") {
|
|
484
|
+
const s = document.querySelector(e);
|
|
485
|
+
if (!s) throw new Error(`[gengage] Mount target not found: "${e}"`);
|
|
486
|
+
return s;
|
|
487
|
+
}
|
|
488
|
+
const n = document.createElement("div");
|
|
489
|
+
return n.dataset.gengageWidget = this.constructor.name.toLowerCase(), document.body.appendChild(n), this._ownsRoot = !0, n;
|
|
490
|
+
}
|
|
491
|
+
_applyTheme(e) {
|
|
492
|
+
if (e) {
|
|
493
|
+
for (const [n, s] of Object.entries(e))
|
|
494
|
+
if (s !== void 0) {
|
|
495
|
+
const i = n.startsWith("--") ? n : `--gengage-${ct(n)}`;
|
|
496
|
+
this.root.style.setProperty(i, s);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
function ct(t) {
|
|
502
|
+
return t.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
503
|
+
}
|
|
504
|
+
function ut(t) {
|
|
505
|
+
const e = [];
|
|
506
|
+
let n = 0, s = !1, i = !1, r = 0;
|
|
507
|
+
for (let a = 0; a < t.length; a++) {
|
|
508
|
+
const o = t[a];
|
|
509
|
+
if (i) {
|
|
510
|
+
i = !1;
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
if (o === "\\" && s) {
|
|
514
|
+
i = !0;
|
|
515
|
+
continue;
|
|
516
|
+
}
|
|
517
|
+
if (o === '"') {
|
|
518
|
+
s = !s;
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
s || (o === "{" && n++, o === "}" && (n--, n === 0 && (e.push(t.slice(r, a + 1)), r = a + 1)));
|
|
522
|
+
}
|
|
523
|
+
return e.length > 0 ? e : [t];
|
|
524
|
+
}
|
|
525
|
+
function xe(t, e) {
|
|
526
|
+
const n = t.trim();
|
|
527
|
+
if (!n || n.startsWith(":")) return !1;
|
|
528
|
+
const s = n.startsWith("data: ") ? n.slice(6) : n;
|
|
529
|
+
if (s === "[DONE]") return !0;
|
|
530
|
+
try {
|
|
531
|
+
const i = JSON.parse(s);
|
|
532
|
+
return e.onEvent(i), i.type === "done" ? (e.onDone?.(), !0) : !1;
|
|
533
|
+
} catch {
|
|
534
|
+
const i = ut(s);
|
|
535
|
+
if (i.length > 1) {
|
|
536
|
+
for (const r of i)
|
|
537
|
+
try {
|
|
538
|
+
const a = JSON.parse(r);
|
|
539
|
+
if (e.onEvent(a), a.type === "done")
|
|
540
|
+
return e.onDone?.(), !0;
|
|
541
|
+
} catch {
|
|
542
|
+
}
|
|
543
|
+
return !1;
|
|
544
|
+
}
|
|
545
|
+
return !1;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
async function lt(t, e) {
|
|
549
|
+
if (!t.ok) {
|
|
550
|
+
e.onError?.(new Error(`HTTP ${t.status}: ${t.statusText}`));
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
if (!t.body) {
|
|
554
|
+
e.onError?.(new Error("Response body is null — streaming not supported"));
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
const n = t.body.getReader(), s = new TextDecoder("utf-8");
|
|
558
|
+
let i = "";
|
|
559
|
+
try {
|
|
560
|
+
for (; ; ) {
|
|
561
|
+
const { done: r, value: a } = await n.read();
|
|
562
|
+
if (r) break;
|
|
563
|
+
i += s.decode(a, { stream: !0 });
|
|
564
|
+
const o = i.split(`
|
|
565
|
+
`);
|
|
566
|
+
i = o.pop() ?? "";
|
|
567
|
+
for (const c of o)
|
|
568
|
+
if (xe(c, e)) return;
|
|
569
|
+
}
|
|
570
|
+
i.trim() && xe(i, e);
|
|
571
|
+
} catch (r) {
|
|
572
|
+
if (r instanceof DOMException && r.name === "AbortError") return;
|
|
573
|
+
e.onError?.(r instanceof Error ? r : new Error(String(r)));
|
|
574
|
+
} finally {
|
|
575
|
+
n.releaseLock();
|
|
576
|
+
}
|
|
577
|
+
e.onDone?.();
|
|
578
|
+
}
|
|
579
|
+
function zn(t, e, n) {
|
|
580
|
+
const s = new AbortController(), i = n.signal ? ft([n.signal, s.signal]) : s.signal;
|
|
581
|
+
return fetch(t, {
|
|
582
|
+
method: "POST",
|
|
583
|
+
headers: {
|
|
584
|
+
"Content-Type": "application/json",
|
|
585
|
+
...n.headers
|
|
586
|
+
},
|
|
587
|
+
body: JSON.stringify(e),
|
|
588
|
+
signal: i
|
|
589
|
+
}).then((r) => lt(r, { ...n, signal: i })).catch((r) => {
|
|
590
|
+
r instanceof DOMException && r.name === "AbortError" || n.onError?.(r instanceof Error ? r : new Error(String(r)));
|
|
591
|
+
}), s;
|
|
592
|
+
}
|
|
593
|
+
function ft(t) {
|
|
594
|
+
const e = new AbortController();
|
|
595
|
+
for (const n of t) {
|
|
596
|
+
if (n.aborted)
|
|
597
|
+
return e.abort(n.reason), e.signal;
|
|
598
|
+
n.addEventListener("abort", () => e.abort(n.reason), { once: !0 });
|
|
599
|
+
}
|
|
600
|
+
return e.signal;
|
|
601
|
+
}
|
|
602
|
+
function Un(t) {
|
|
603
|
+
if (typeof t.type != "string") return null;
|
|
604
|
+
if (pt(t))
|
|
605
|
+
return t;
|
|
606
|
+
const n = t;
|
|
607
|
+
switch (n.type) {
|
|
608
|
+
case "outputText":
|
|
609
|
+
return ht(n);
|
|
610
|
+
case "suggestedActions":
|
|
611
|
+
return mt(n);
|
|
612
|
+
case "productList":
|
|
613
|
+
return gt(n);
|
|
614
|
+
case "productDetails":
|
|
615
|
+
return _t(n);
|
|
616
|
+
case "productDetailsSimilars":
|
|
617
|
+
return yt(n);
|
|
618
|
+
case "comparisonTable":
|
|
619
|
+
return vt(n);
|
|
620
|
+
case "context":
|
|
621
|
+
return kt(n);
|
|
622
|
+
case "chatStreamEnd":
|
|
623
|
+
return wt();
|
|
624
|
+
case "loading":
|
|
625
|
+
return bt(n);
|
|
626
|
+
case "panelLoading":
|
|
627
|
+
return xt(n);
|
|
628
|
+
case "similarLoading":
|
|
629
|
+
return Tt(n);
|
|
630
|
+
case "redirect":
|
|
631
|
+
return Ct(n);
|
|
632
|
+
case "error":
|
|
633
|
+
return St(n);
|
|
634
|
+
case "dummy":
|
|
635
|
+
return At();
|
|
636
|
+
case "launcherAction":
|
|
637
|
+
return Et(n);
|
|
638
|
+
case "text":
|
|
639
|
+
return ye(n);
|
|
640
|
+
case "productItem":
|
|
641
|
+
return It(n);
|
|
642
|
+
case "text_image":
|
|
643
|
+
return $e(n);
|
|
644
|
+
case "quick_qna":
|
|
645
|
+
return De(n);
|
|
646
|
+
case "reviewHighlights":
|
|
647
|
+
return Nt(n);
|
|
648
|
+
case "aiProductSuggestions":
|
|
649
|
+
return Zt(n);
|
|
650
|
+
case "aiProductGroupings":
|
|
651
|
+
return Pt(n);
|
|
652
|
+
case "aiSuggestedSearches":
|
|
653
|
+
return jt(n);
|
|
654
|
+
case "prosAndCons":
|
|
655
|
+
return Ot(n);
|
|
656
|
+
case "getGroundingReview":
|
|
657
|
+
return Lt(n);
|
|
658
|
+
case "voice":
|
|
659
|
+
return Dt(n);
|
|
660
|
+
case "visitorDataResponse":
|
|
661
|
+
return Rt(n);
|
|
662
|
+
case "productListPreview":
|
|
663
|
+
return $t();
|
|
664
|
+
case "groupList":
|
|
665
|
+
return Mt(n);
|
|
666
|
+
case "formGetInfo":
|
|
667
|
+
case "formTestDrive":
|
|
668
|
+
case "formServiceRequest":
|
|
669
|
+
case "launchFormPage":
|
|
670
|
+
return Vt(n);
|
|
671
|
+
case "launcherContent":
|
|
672
|
+
return zt(n);
|
|
673
|
+
default:
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
function pt(t) {
|
|
678
|
+
const e = t.type;
|
|
679
|
+
if (typeof e != "string") return !1;
|
|
680
|
+
switch (e) {
|
|
681
|
+
case "metadata":
|
|
682
|
+
return typeof t.sessionId == "string" && typeof t.model == "string";
|
|
683
|
+
case "text_chunk":
|
|
684
|
+
return typeof t.content == "string";
|
|
685
|
+
case "ui_spec": {
|
|
686
|
+
const n = t.widget;
|
|
687
|
+
if (n !== "chat" && n !== "qna" && n !== "simrel") return !1;
|
|
688
|
+
const s = V(t.spec);
|
|
689
|
+
return s ? typeof s.root == "string" && V(s.elements) !== null : !1;
|
|
690
|
+
}
|
|
691
|
+
case "action": {
|
|
692
|
+
const n = V(t.action);
|
|
693
|
+
return n !== null && typeof n.kind == "string";
|
|
694
|
+
}
|
|
695
|
+
case "error":
|
|
696
|
+
return typeof t.code == "string" && typeof t.message == "string";
|
|
697
|
+
case "done":
|
|
698
|
+
return !0;
|
|
699
|
+
default:
|
|
700
|
+
return !1;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function ht(t) {
|
|
704
|
+
const e = k(t.payload.text, t.payload.plain_text) ?? "", n = k(t.payload.plain_text, t.payload.text) ?? e;
|
|
705
|
+
if (t.payload.is_error)
|
|
706
|
+
return {
|
|
707
|
+
type: "error",
|
|
708
|
+
code: "BACKEND_ERROR",
|
|
709
|
+
message: n || "Backend returned an error"
|
|
710
|
+
};
|
|
711
|
+
const s = {
|
|
712
|
+
type: "text_chunk",
|
|
713
|
+
content: e,
|
|
714
|
+
final: !0
|
|
715
|
+
}, i = t.payload.product_mentions;
|
|
716
|
+
Array.isArray(i) && i.length > 0 && (s.productMentions = i.filter(
|
|
717
|
+
(o) => typeof o == "object" && o !== null && typeof o.sku == "string" && typeof o.short_name == "string"
|
|
718
|
+
));
|
|
719
|
+
const r = t.payload.sku_to_product_item;
|
|
720
|
+
r && typeof r == "object" && !Array.isArray(r) && (s.skuToProductItem = r);
|
|
721
|
+
const a = t.payload.conversation_mode;
|
|
722
|
+
return typeof a == "string" && a && (s.conversationMode = a), s;
|
|
723
|
+
}
|
|
724
|
+
function mt(t) {
|
|
725
|
+
const e = (t.payload.actions ?? []).map((n) => {
|
|
726
|
+
const s = k(n.title) ?? "", i = $(n.requestDetails, s), r = i ? {
|
|
727
|
+
label: s,
|
|
728
|
+
action: i
|
|
729
|
+
} : null;
|
|
730
|
+
return r ? (typeof n.icon == "string" && (r.icon = n.icon), typeof n.image == "string" && (r.image = n.image), r) : null;
|
|
731
|
+
});
|
|
732
|
+
return Me(e.filter(ze), "chat");
|
|
733
|
+
}
|
|
734
|
+
function gt(t) {
|
|
735
|
+
const e = Ve(t.payload.product_list ?? [], "chat");
|
|
736
|
+
e.panelHint = "panel";
|
|
737
|
+
const n = e.spec.elements[e.spec.root];
|
|
738
|
+
return n && (typeof t.payload.offset == "number" && (n.props = { ...n.props, offset: t.payload.offset }), typeof t.payload.end_of_list == "boolean" && (n.props = { ...n.props, endOfList: t.payload.end_of_list })), e;
|
|
739
|
+
}
|
|
740
|
+
function _t(t) {
|
|
741
|
+
const e = t.payload.productDetails;
|
|
742
|
+
return e ? {
|
|
743
|
+
type: "ui_spec",
|
|
744
|
+
widget: "chat",
|
|
745
|
+
spec: {
|
|
746
|
+
root: "root",
|
|
747
|
+
elements: {
|
|
748
|
+
root: {
|
|
749
|
+
type: "ProductDetailsPanel",
|
|
750
|
+
props: { product: D(e) }
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
panelHint: "panel"
|
|
755
|
+
} : qt("chat");
|
|
756
|
+
}
|
|
757
|
+
function yt(t) {
|
|
758
|
+
const e = Ve(t.payload.similarProducts ?? [], "chat"), n = e.spec.elements[e.spec.root];
|
|
759
|
+
return n && (n.props = { ...n.props, similarsAppend: !0 }), { ...e, panelHint: "panel" };
|
|
760
|
+
}
|
|
761
|
+
function vt(t) {
|
|
762
|
+
const e = t.payload.multiple_product_details ?? [], n = t.payload.product_comparison_framework, s = t.payload.table, i = [];
|
|
763
|
+
for (const b of e) {
|
|
764
|
+
const R = D(b);
|
|
765
|
+
i.push(R);
|
|
766
|
+
}
|
|
767
|
+
const r = [];
|
|
768
|
+
if (s) {
|
|
769
|
+
const b = n?.criteria_view ?? n?.criteria_view_short ?? {}, R = n?.compared_field_names ?? Object.keys(s);
|
|
770
|
+
for (const re of R) {
|
|
771
|
+
const ae = s[re];
|
|
772
|
+
if (!ae || !Array.isArray(ae)) continue;
|
|
773
|
+
const We = b[re] ?? re;
|
|
774
|
+
r.push({ label: We, values: ae.map((oe) => typeof oe == "string" ? oe : String(oe ?? "")) });
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
let a;
|
|
778
|
+
n?.recommended_choice_sku ? a = n.recommended_choice_sku : n?.winner_product && n.winner_product.length > 0 && (a = n.winner_product[0]?.sku);
|
|
779
|
+
const o = a ? i.find((b) => b.sku === a) ?? i[0] : i[0], c = [];
|
|
780
|
+
if (n?.key_differences)
|
|
781
|
+
for (const b of n.key_differences)
|
|
782
|
+
typeof b == "string" && c.push(b);
|
|
783
|
+
const l = [];
|
|
784
|
+
if (n?.special_considerations)
|
|
785
|
+
for (const b of n.special_considerations)
|
|
786
|
+
typeof b == "string" && l.push(b);
|
|
787
|
+
const g = n?.recommended_choice, x = n?.winner_hits, A = {};
|
|
788
|
+
for (const b of i) {
|
|
789
|
+
const R = b.sku;
|
|
790
|
+
R && (A[R] = {
|
|
791
|
+
title: b.name ?? R,
|
|
792
|
+
type: "launchSingleProduct",
|
|
793
|
+
payload: { sku: R }
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
const C = {
|
|
797
|
+
products: i,
|
|
798
|
+
attributes: r,
|
|
799
|
+
highlights: c,
|
|
800
|
+
productActions: A
|
|
801
|
+
};
|
|
802
|
+
return o && (C.recommended = o), l.length > 0 && (C.specialCases = l), g && (C.recommendedText = g), x && (C.winnerHits = x), typeof n?.key_differences == "string" && (C.keyDifferencesHtml = n.key_differences), n?.special_considerations && (C.specialConsiderations = n.special_considerations), {
|
|
803
|
+
type: "ui_spec",
|
|
804
|
+
widget: "chat",
|
|
805
|
+
spec: {
|
|
806
|
+
root: "root",
|
|
807
|
+
elements: {
|
|
808
|
+
root: {
|
|
809
|
+
type: "ComparisonTable",
|
|
810
|
+
props: C
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
},
|
|
814
|
+
panelHint: "panel"
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function kt(t) {
|
|
818
|
+
return {
|
|
819
|
+
type: "metadata",
|
|
820
|
+
sessionId: "",
|
|
821
|
+
model: "",
|
|
822
|
+
meta: {
|
|
823
|
+
panel: t.payload.panel,
|
|
824
|
+
messages: t.payload.messages,
|
|
825
|
+
message_id: t.payload.message_id
|
|
826
|
+
}
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function wt() {
|
|
830
|
+
return { type: "done" };
|
|
831
|
+
}
|
|
832
|
+
function bt(t) {
|
|
833
|
+
return {
|
|
834
|
+
type: "metadata",
|
|
835
|
+
sessionId: "",
|
|
836
|
+
model: "",
|
|
837
|
+
meta: {
|
|
838
|
+
loading: !0,
|
|
839
|
+
loadingText: t.payload.text,
|
|
840
|
+
thinkingMessages: t.payload.thinking_messages,
|
|
841
|
+
dynamicLoading: t.payload.is_dynamic === !0
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
function xt(t) {
|
|
846
|
+
return {
|
|
847
|
+
type: "metadata",
|
|
848
|
+
sessionId: "",
|
|
849
|
+
model: "",
|
|
850
|
+
meta: {
|
|
851
|
+
loading: !0,
|
|
852
|
+
panelLoading: !0,
|
|
853
|
+
panelPendingType: t.payload?.pending_type,
|
|
854
|
+
loadingText: t.payload?.text
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
function Tt(t) {
|
|
859
|
+
return {
|
|
860
|
+
type: "metadata",
|
|
861
|
+
sessionId: "",
|
|
862
|
+
model: "",
|
|
863
|
+
meta: {
|
|
864
|
+
loading: !0,
|
|
865
|
+
similarPanelLoading: !0,
|
|
866
|
+
panelPendingType: t.payload?.pending_type,
|
|
867
|
+
loadingText: t.payload?.text
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
function Ct(t) {
|
|
872
|
+
const e = k(t.payload.url);
|
|
873
|
+
return e ? {
|
|
874
|
+
type: "action",
|
|
875
|
+
action: {
|
|
876
|
+
kind: "navigate",
|
|
877
|
+
url: e,
|
|
878
|
+
newTab: t.payload.new_tab === !0
|
|
879
|
+
}
|
|
880
|
+
} : {
|
|
881
|
+
type: "metadata",
|
|
882
|
+
sessionId: "",
|
|
883
|
+
model: "",
|
|
884
|
+
meta: {
|
|
885
|
+
redirect: t.payload,
|
|
886
|
+
redirectTarget: k(t.payload.to)
|
|
887
|
+
}
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
function St(t) {
|
|
891
|
+
return {
|
|
892
|
+
type: "error",
|
|
893
|
+
code: "BACKEND_ERROR",
|
|
894
|
+
message: k(t.payload?.text, t.payload?.message, t.payload?.error) ?? "Backend returned an error"
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
function At(t) {
|
|
898
|
+
return {
|
|
899
|
+
type: "metadata",
|
|
900
|
+
sessionId: "",
|
|
901
|
+
model: "",
|
|
902
|
+
meta: {
|
|
903
|
+
noop: !0
|
|
904
|
+
}
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
function Et(t) {
|
|
908
|
+
const e = t.payload ?? {};
|
|
909
|
+
if (Array.isArray(e.action_list)) {
|
|
910
|
+
const r = {
|
|
911
|
+
action_list: e.action_list
|
|
912
|
+
}, a = typeof e.type == "string" ? e.type : void 0, o = typeof e.theme == "string" ? e.theme : void 0;
|
|
913
|
+
return a !== void 0 && (r.type = a), o !== void 0 && (r.theme = o), De({
|
|
914
|
+
payload: r
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
const s = V(e.action);
|
|
918
|
+
if (s) {
|
|
919
|
+
const r = {
|
|
920
|
+
action: s
|
|
921
|
+
}, a = typeof e.text == "string" ? e.text : void 0, o = typeof e.image_url == "string" ? e.image_url : void 0, c = typeof e.theme == "string" ? e.theme : void 0;
|
|
922
|
+
return a !== void 0 && (r.text = a), o !== void 0 && (r.image_url = o), c !== void 0 && (r.theme = c), $e({
|
|
923
|
+
payload: r
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
const i = typeof e.text == "string" ? e.text : "";
|
|
927
|
+
if (i) {
|
|
928
|
+
const r = { text: i }, a = typeof e.type == "string" ? e.type : void 0, o = typeof e.theme == "string" ? e.theme : void 0, c = V(e.payload) ?? void 0;
|
|
929
|
+
return a !== void 0 && (r.type = a), c !== void 0 && (r.payload = c), o !== void 0 && (r.theme = o), ye({
|
|
930
|
+
payload: r
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
type: "metadata",
|
|
935
|
+
sessionId: "",
|
|
936
|
+
model: "",
|
|
937
|
+
meta: {
|
|
938
|
+
launcherAction: e
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
function ye(t) {
|
|
943
|
+
const e = {
|
|
944
|
+
text: k(t.payload.text) ?? ""
|
|
945
|
+
};
|
|
946
|
+
return typeof t.payload.theme == "string" && (e.theme = t.payload.theme), t.payload.payload !== void 0 && (e.payload = t.payload.payload), {
|
|
947
|
+
type: "ui_spec",
|
|
948
|
+
widget: "qna",
|
|
949
|
+
spec: {
|
|
950
|
+
root: "root",
|
|
951
|
+
elements: {
|
|
952
|
+
root: {
|
|
953
|
+
type: "QuestionHeading",
|
|
954
|
+
props: e
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
function It(t) {
|
|
961
|
+
return Ut(t.payload, "qna");
|
|
962
|
+
}
|
|
963
|
+
function $e(t) {
|
|
964
|
+
const e = k(t.payload.text) ?? "", n = $(t.payload.action, e);
|
|
965
|
+
if (n) {
|
|
966
|
+
const i = {
|
|
967
|
+
label: e || n.title,
|
|
968
|
+
action: n
|
|
969
|
+
};
|
|
970
|
+
return typeof t.payload.image_url == "string" && (i.image = t.payload.image_url), typeof t.payload.theme == "string" && (i.theme = t.payload.theme), {
|
|
971
|
+
type: "ui_spec",
|
|
972
|
+
widget: "qna",
|
|
973
|
+
spec: {
|
|
974
|
+
root: "root",
|
|
975
|
+
elements: {
|
|
976
|
+
root: {
|
|
977
|
+
type: "ActionButton",
|
|
978
|
+
props: i
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
const s = {
|
|
985
|
+
text: e
|
|
986
|
+
};
|
|
987
|
+
return typeof t.payload.theme == "string" && (s.theme = t.payload.theme), ye({
|
|
988
|
+
payload: s
|
|
989
|
+
});
|
|
990
|
+
}
|
|
991
|
+
function De(t) {
|
|
992
|
+
const e = (t.payload.action_list ?? []).map((n) => {
|
|
993
|
+
const s = k(n.title) ?? "", i = $(n.requestDetails, s), r = i ? {
|
|
994
|
+
label: s,
|
|
995
|
+
action: i
|
|
996
|
+
} : null;
|
|
997
|
+
return r ? (typeof n.icon == "string" && (r.icon = n.icon), typeof n.image == "string" && (r.image = n.image), r) : null;
|
|
998
|
+
});
|
|
999
|
+
return Me(e.filter(ze), "qna");
|
|
1000
|
+
}
|
|
1001
|
+
function Nt(t) {
|
|
1002
|
+
const n = { reviews: (t.payload.reviews ?? []).map((s) => {
|
|
1003
|
+
const i = {};
|
|
1004
|
+
return typeof s.review_class == "string" && (i.review_class = s.review_class), typeof s.review_text == "string" && (i.review_text = s.review_text), (typeof s.review_rating == "string" || typeof s.review_rating == "number") && (i.review_rating = s.review_rating), typeof s.review_tag == "string" && (i.review_tag = s.review_tag), i;
|
|
1005
|
+
}) };
|
|
1006
|
+
return typeof t.payload.sku == "string" && (n.sku = t.payload.sku), {
|
|
1007
|
+
type: "ui_spec",
|
|
1008
|
+
widget: "chat",
|
|
1009
|
+
spec: {
|
|
1010
|
+
root: "root",
|
|
1011
|
+
elements: {
|
|
1012
|
+
root: {
|
|
1013
|
+
type: "ReviewHighlights",
|
|
1014
|
+
props: n
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
}
|
|
1020
|
+
function Ot(t) {
|
|
1021
|
+
const e = {};
|
|
1022
|
+
return Array.isArray(t.payload.pros) && (e.pros = t.payload.pros), Array.isArray(t.payload.cons) && (e.cons = t.payload.cons), typeof t.payload.product_name == "string" && (e.productName = t.payload.product_name), {
|
|
1023
|
+
type: "ui_spec",
|
|
1024
|
+
widget: "chat",
|
|
1025
|
+
spec: {
|
|
1026
|
+
root: "root",
|
|
1027
|
+
elements: {
|
|
1028
|
+
root: {
|
|
1029
|
+
type: "ProsAndCons",
|
|
1030
|
+
props: e
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
function Rt(t) {
|
|
1037
|
+
return {
|
|
1038
|
+
type: "metadata",
|
|
1039
|
+
sessionId: "",
|
|
1040
|
+
model: "",
|
|
1041
|
+
meta: {
|
|
1042
|
+
visitorDataResponse: t.payload
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function Zt(t) {
|
|
1047
|
+
const e = t.payload.product_suggestions ?? [], n = [];
|
|
1048
|
+
for (let s = 0; s < e.length; s++) {
|
|
1049
|
+
const i = e[s];
|
|
1050
|
+
if (!i) continue;
|
|
1051
|
+
const r = Bt(i);
|
|
1052
|
+
if (!r) continue;
|
|
1053
|
+
const a = { product: r }, o = $(i.requestDetails, r.name);
|
|
1054
|
+
o && (a.action = o), typeof i.role == "string" && (a.role = i.role), typeof i.reason == "string" && (a.reason = i.reason), typeof i.review_highlight == "string" && (a.reviewHighlight = i.review_highlight), Array.isArray(i.labels) && (a.labels = i.labels), typeof i.expert_quality_score == "number" && (a.expertQualityScore = i.expert_quality_score), n.push(a);
|
|
1055
|
+
}
|
|
1056
|
+
return n.length === 0 ? {
|
|
1057
|
+
type: "metadata",
|
|
1058
|
+
sessionId: "",
|
|
1059
|
+
model: "",
|
|
1060
|
+
meta: {
|
|
1061
|
+
aiProductSuggestions: t.payload.product_suggestions ?? []
|
|
1062
|
+
}
|
|
1063
|
+
} : {
|
|
1064
|
+
type: "ui_spec",
|
|
1065
|
+
widget: "chat",
|
|
1066
|
+
spec: {
|
|
1067
|
+
root: "root",
|
|
1068
|
+
elements: {
|
|
1069
|
+
root: {
|
|
1070
|
+
type: "AITopPicks",
|
|
1071
|
+
props: { suggestions: n }
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
function Pt(t) {
|
|
1078
|
+
const e = t.payload.product_groupings ?? [], n = [];
|
|
1079
|
+
for (let s = 0; s < e.length; s++) {
|
|
1080
|
+
const i = e[s];
|
|
1081
|
+
if (!i) continue;
|
|
1082
|
+
const r = k(i.name) ?? "", a = i.sku && i.sku.length > 0 ? { type: "findSimilar", payload: { sku: i.sku } } : void 0, o = $(i.requestDetails ?? a, r);
|
|
1083
|
+
if (!o) continue;
|
|
1084
|
+
const c = { name: r, action: o };
|
|
1085
|
+
if (Array.isArray(i.labels)) {
|
|
1086
|
+
const l = i.labels.filter((g) => typeof g == "string");
|
|
1087
|
+
l.length > 0 && (c.labels = l);
|
|
1088
|
+
}
|
|
1089
|
+
typeof i.image == "string" && (c.image = i.image), n.push(c);
|
|
1090
|
+
}
|
|
1091
|
+
return n.length === 0 ? {
|
|
1092
|
+
type: "metadata",
|
|
1093
|
+
sessionId: "",
|
|
1094
|
+
model: "",
|
|
1095
|
+
meta: {
|
|
1096
|
+
aiProductGroupings: t.payload.product_groupings ?? []
|
|
1097
|
+
}
|
|
1098
|
+
} : {
|
|
1099
|
+
type: "ui_spec",
|
|
1100
|
+
widget: "chat",
|
|
1101
|
+
spec: {
|
|
1102
|
+
root: "root",
|
|
1103
|
+
elements: {
|
|
1104
|
+
root: {
|
|
1105
|
+
type: "AIGroupingCards",
|
|
1106
|
+
props: { entries: n }
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
function jt(t) {
|
|
1113
|
+
const e = t.payload.suggested_searches ?? [], n = [];
|
|
1114
|
+
for (let s = 0; s < e.length; s++) {
|
|
1115
|
+
const i = e[s];
|
|
1116
|
+
if (!i) continue;
|
|
1117
|
+
const r = k(i.short_name, i.chosen_attribute, i.detailed_user_message) ?? `Arama ${s + 1}`, a = {}, o = k(i.detailed_user_message);
|
|
1118
|
+
o && (a.text = o), i.group_skus && Array.isArray(i.group_skus) && (a.group_skus = i.group_skus);
|
|
1119
|
+
const c = k(i.sku, i.representative_product_sku);
|
|
1120
|
+
c && (a.sku = c), a.is_suggested_text = 1;
|
|
1121
|
+
const l = { type: "inputText", payload: a }, g = $(i.requestDetails ?? l, r);
|
|
1122
|
+
if (!g) continue;
|
|
1123
|
+
const x = { shortName: r, action: g }, A = k(i.detailed_user_message);
|
|
1124
|
+
A && A !== r && (x.detailedMessage = A);
|
|
1125
|
+
const C = k(i.why_different);
|
|
1126
|
+
C && (x.whyDifferent = C), typeof i.image == "string" && (x.image = i.image), n.push(x);
|
|
1127
|
+
}
|
|
1128
|
+
return n.length === 0 ? {
|
|
1129
|
+
type: "metadata",
|
|
1130
|
+
sessionId: "",
|
|
1131
|
+
model: "",
|
|
1132
|
+
meta: {
|
|
1133
|
+
aiSuggestedSearches: t.payload.suggested_searches ?? []
|
|
1134
|
+
}
|
|
1135
|
+
} : {
|
|
1136
|
+
type: "ui_spec",
|
|
1137
|
+
widget: "chat",
|
|
1138
|
+
spec: {
|
|
1139
|
+
root: "root",
|
|
1140
|
+
elements: {
|
|
1141
|
+
root: {
|
|
1142
|
+
type: "AISuggestedSearchCards",
|
|
1143
|
+
props: { entries: n }
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
};
|
|
1148
|
+
}
|
|
1149
|
+
function Lt(t) {
|
|
1150
|
+
const e = $(
|
|
1151
|
+
t.payload.requestDetails,
|
|
1152
|
+
k(t.payload.review_count, t.payload.text, t.payload.title) ?? "Urun yorumlarini goster"
|
|
1153
|
+
);
|
|
1154
|
+
if (!e)
|
|
1155
|
+
return {
|
|
1156
|
+
type: "metadata",
|
|
1157
|
+
sessionId: "",
|
|
1158
|
+
model: "",
|
|
1159
|
+
meta: {
|
|
1160
|
+
groundingReview: t.payload
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
const n = { action: e };
|
|
1164
|
+
return t.payload.title && (n.title = t.payload.title), t.payload.text && (n.text = t.payload.text), t.payload.review_count && (n.reviewCount = t.payload.review_count), {
|
|
1165
|
+
type: "ui_spec",
|
|
1166
|
+
widget: "chat",
|
|
1167
|
+
spec: {
|
|
1168
|
+
root: "root",
|
|
1169
|
+
elements: {
|
|
1170
|
+
root: {
|
|
1171
|
+
type: "GroundingReviewCard",
|
|
1172
|
+
props: n
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
function $t() {
|
|
1179
|
+
return {
|
|
1180
|
+
type: "metadata",
|
|
1181
|
+
sessionId: "",
|
|
1182
|
+
model: "",
|
|
1183
|
+
meta: {
|
|
1184
|
+
analyzeAnimation: !0
|
|
1185
|
+
}
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
function Dt(t) {
|
|
1189
|
+
return {
|
|
1190
|
+
type: "metadata",
|
|
1191
|
+
sessionId: "",
|
|
1192
|
+
model: "",
|
|
1193
|
+
meta: {
|
|
1194
|
+
voice: t.payload
|
|
1195
|
+
}
|
|
1196
|
+
};
|
|
1197
|
+
}
|
|
1198
|
+
function Mt(t) {
|
|
1199
|
+
const e = t.payload.group_list ?? [], n = [];
|
|
1200
|
+
for (const i of e) {
|
|
1201
|
+
const r = i.group_name ?? "", a = (i.product_list ?? []).map(D);
|
|
1202
|
+
n.push({ groupName: r, products: a });
|
|
1203
|
+
}
|
|
1204
|
+
const s = [];
|
|
1205
|
+
for (const i of t.payload.filter_tags ?? []) {
|
|
1206
|
+
const r = i.title ?? "";
|
|
1207
|
+
if (!r) continue;
|
|
1208
|
+
const a = $(i.requestDetails, r), o = { title: r };
|
|
1209
|
+
a && (o.action = a), s.push(o);
|
|
1210
|
+
}
|
|
1211
|
+
return {
|
|
1212
|
+
type: "ui_spec",
|
|
1213
|
+
widget: "chat",
|
|
1214
|
+
spec: {
|
|
1215
|
+
root: "root",
|
|
1216
|
+
elements: {
|
|
1217
|
+
root: {
|
|
1218
|
+
type: "CategoriesContainer",
|
|
1219
|
+
props: { groups: n, filterTags: s }
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
panelHint: "panel"
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
function Vt(t) {
|
|
1227
|
+
return {
|
|
1228
|
+
type: "metadata",
|
|
1229
|
+
sessionId: "",
|
|
1230
|
+
model: "",
|
|
1231
|
+
meta: {
|
|
1232
|
+
formType: t.type,
|
|
1233
|
+
formPayload: t.payload ?? {}
|
|
1234
|
+
}
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function zt(t) {
|
|
1238
|
+
return {
|
|
1239
|
+
type: "metadata",
|
|
1240
|
+
sessionId: "",
|
|
1241
|
+
model: "",
|
|
1242
|
+
meta: {
|
|
1243
|
+
launcherContent: t.payload ?? {}
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
function Me(t, e) {
|
|
1248
|
+
const n = {}, s = [];
|
|
1249
|
+
for (let i = 0; i < t.length; i++) {
|
|
1250
|
+
const r = t[i];
|
|
1251
|
+
if (!r) continue;
|
|
1252
|
+
const a = `action-${i}`;
|
|
1253
|
+
s.push(a);
|
|
1254
|
+
const o = {
|
|
1255
|
+
label: r.label,
|
|
1256
|
+
action: r.action
|
|
1257
|
+
};
|
|
1258
|
+
r.icon !== void 0 && (o.icon = r.icon), r.image !== void 0 && (o.image = r.image), r.description !== void 0 && (o.description = r.description), n[a] = {
|
|
1259
|
+
type: "ActionButton",
|
|
1260
|
+
props: o
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
return n.root = {
|
|
1264
|
+
type: "ActionButtons",
|
|
1265
|
+
props: {
|
|
1266
|
+
buttons: t.map((i) => {
|
|
1267
|
+
const r = {
|
|
1268
|
+
label: i.label,
|
|
1269
|
+
action: i.action
|
|
1270
|
+
};
|
|
1271
|
+
return i.image !== void 0 && (r.image = i.image), i.description !== void 0 && (r.description = i.description), i.icon !== void 0 && (r.icon = i.icon), r;
|
|
1272
|
+
})
|
|
1273
|
+
},
|
|
1274
|
+
children: s
|
|
1275
|
+
}, {
|
|
1276
|
+
type: "ui_spec",
|
|
1277
|
+
widget: e,
|
|
1278
|
+
spec: { root: "root", elements: n }
|
|
1279
|
+
};
|
|
1280
|
+
}
|
|
1281
|
+
function Ve(t, e) {
|
|
1282
|
+
const n = {}, s = [];
|
|
1283
|
+
for (let i = 0; i < t.length; i++) {
|
|
1284
|
+
const r = t[i];
|
|
1285
|
+
if (!r) continue;
|
|
1286
|
+
const a = `product-${i}`;
|
|
1287
|
+
s.push(a), n[a] = {
|
|
1288
|
+
type: "ProductCard",
|
|
1289
|
+
props: { product: D(r), index: i }
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
return n.root = {
|
|
1293
|
+
type: "ProductGrid",
|
|
1294
|
+
props: { layout: "grid" },
|
|
1295
|
+
children: s
|
|
1296
|
+
}, {
|
|
1297
|
+
type: "ui_spec",
|
|
1298
|
+
widget: e,
|
|
1299
|
+
spec: { root: "root", elements: n }
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1302
|
+
function Ut(t, e) {
|
|
1303
|
+
return {
|
|
1304
|
+
type: "ui_spec",
|
|
1305
|
+
widget: e,
|
|
1306
|
+
spec: {
|
|
1307
|
+
root: "root",
|
|
1308
|
+
elements: {
|
|
1309
|
+
root: {
|
|
1310
|
+
type: "ProductCard",
|
|
1311
|
+
props: { product: D(t), index: 0 }
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
}
|
|
1317
|
+
function qt(t) {
|
|
1318
|
+
return {
|
|
1319
|
+
type: "ui_spec",
|
|
1320
|
+
widget: t,
|
|
1321
|
+
spec: {
|
|
1322
|
+
root: "root",
|
|
1323
|
+
elements: {
|
|
1324
|
+
root: {
|
|
1325
|
+
type: "ActionButtons",
|
|
1326
|
+
props: { buttons: [] },
|
|
1327
|
+
children: []
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
function Bt(t) {
|
|
1334
|
+
const e = k(t.sku), n = k(t.short_name), s = V(t.product_item) ?? t;
|
|
1335
|
+
return Wt(s, e, n);
|
|
1336
|
+
}
|
|
1337
|
+
function Wt(t, e, n) {
|
|
1338
|
+
const s = k(t.sku, e), i = k(t.name, n);
|
|
1339
|
+
if (!s || !i) return null;
|
|
1340
|
+
const r = {
|
|
1341
|
+
sku: s,
|
|
1342
|
+
name: i
|
|
1343
|
+
}, a = k(t.brand);
|
|
1344
|
+
a && (r.brand = a);
|
|
1345
|
+
const o = k(t.url);
|
|
1346
|
+
o && (r.url = o);
|
|
1347
|
+
const c = Ft(t.images);
|
|
1348
|
+
if (c.length > 0)
|
|
1349
|
+
r.images = c;
|
|
1350
|
+
else {
|
|
1351
|
+
const b = k(t.image, t.image_url, t.imageUrl);
|
|
1352
|
+
b && (r.images = [b]);
|
|
1353
|
+
}
|
|
1354
|
+
const l = G(t.price_discounted);
|
|
1355
|
+
l !== void 0 && (r.price_discounted = l);
|
|
1356
|
+
const g = G(t.price);
|
|
1357
|
+
g !== void 0 && (r.price = g);
|
|
1358
|
+
const x = G(t.rating);
|
|
1359
|
+
x !== void 0 && (r.rating = x);
|
|
1360
|
+
const A = G(t.review_count) ?? G(t.reviewCount);
|
|
1361
|
+
A !== void 0 && (r.review_count = A);
|
|
1362
|
+
const C = k(t.cart_code, t.cartCode);
|
|
1363
|
+
return C && (r.cart_code = C), typeof t.in_stock == "boolean" && (r.in_stock = t.in_stock), typeof t.inStock == "boolean" && (r.in_stock = t.inStock), D(r);
|
|
1364
|
+
}
|
|
1365
|
+
function $(t, e) {
|
|
1366
|
+
const n = V(t);
|
|
1367
|
+
if (!n) return null;
|
|
1368
|
+
const s = n.type;
|
|
1369
|
+
if (typeof s != "string" || s.length === 0) return null;
|
|
1370
|
+
const i = {
|
|
1371
|
+
title: e || s,
|
|
1372
|
+
type: s
|
|
1373
|
+
};
|
|
1374
|
+
return n.payload !== void 0 && (i.payload = n.payload), i;
|
|
1375
|
+
}
|
|
1376
|
+
function V(t) {
|
|
1377
|
+
return !t || typeof t != "object" || Array.isArray(t) ? null : t;
|
|
1378
|
+
}
|
|
1379
|
+
function k(...t) {
|
|
1380
|
+
for (const e of t)
|
|
1381
|
+
if (typeof e == "string") {
|
|
1382
|
+
const n = e.trim();
|
|
1383
|
+
if (n.length > 0) return n;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
function Ft(t) {
|
|
1387
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.length > 0) : [];
|
|
1388
|
+
}
|
|
1389
|
+
function G(t) {
|
|
1390
|
+
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
1391
|
+
if (typeof t == "string") {
|
|
1392
|
+
const e = t.replace(",", "."), n = Number(e);
|
|
1393
|
+
if (Number.isFinite(n)) return n;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
function ze(t) {
|
|
1397
|
+
return t != null;
|
|
1398
|
+
}
|
|
1399
|
+
function D(t) {
|
|
1400
|
+
const e = t.price_discounted != null && t.price_discounted > 0 ? t.price_discounted : t.price, n = t.price_discounted != null && t.price_discounted > 0 && t.price != null ? t.price : void 0;
|
|
1401
|
+
let s;
|
|
1402
|
+
n != null && e != null && n > 0 && (s = Math.round((n - e) / n * 100));
|
|
1403
|
+
const i = k(t.brand), r = k(t.name) ?? t.sku, a = i && !r.startsWith(i) ? `${i} ${r}` : r, o = {
|
|
1404
|
+
sku: t.sku,
|
|
1405
|
+
name: a,
|
|
1406
|
+
url: k(t.url) ?? ""
|
|
1407
|
+
}, c = t.images?.[0];
|
|
1408
|
+
return c && (o.imageUrl = c), t.images && t.images.length > 1 && (o.images = t.images), e != null && (o.price = String(e)), n != null && (o.originalPrice = String(n)), s !== void 0 && (o.discountPercent = s), i !== void 0 && (o.brand = i), t.rating !== void 0 && (o.rating = t.rating), t.review_count !== void 0 && (o.reviewCount = t.review_count), t.cart_code !== void 0 && (o.cartCode = t.cart_code), t.in_stock !== void 0 && (o.inStock = t.in_stock), t.variants && t.variants.length > 0 && (o.variants = t.variants), t.discount_reason !== void 0 && (o.discountReason = t.discount_reason), t.promotions && t.promotions.length > 0 && (o.promotions = t.promotions), o;
|
|
1409
|
+
}
|
|
1410
|
+
function qn(t) {
|
|
1411
|
+
return t.results.map(D);
|
|
1412
|
+
}
|
|
1413
|
+
function Bn(t) {
|
|
1414
|
+
return t.product_groupings.map((e) => {
|
|
1415
|
+
const n = {
|
|
1416
|
+
name: e.name,
|
|
1417
|
+
products: (e.group_products ?? []).map(D)
|
|
1418
|
+
};
|
|
1419
|
+
return e.highlight !== void 0 && (n.highlight = e.highlight), n;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
const Ht = {
|
|
1423
|
+
process_action: "/process_action",
|
|
1424
|
+
launcher_action: "/launcher_action",
|
|
1425
|
+
similar_products: "/similar_products",
|
|
1426
|
+
product_groupings: "/product_groupings",
|
|
1427
|
+
proactive_action: "/proactive_action"
|
|
1428
|
+
};
|
|
1429
|
+
function Gt(t) {
|
|
1430
|
+
if (t === void 0)
|
|
1431
|
+
throw new Error("[gengage] middlewareUrl is required. Pass your Gengage backend URL in widget config.");
|
|
1432
|
+
const e = t.trim();
|
|
1433
|
+
return e === "" ? "" : e.replace(/\/+$/, "");
|
|
1434
|
+
}
|
|
1435
|
+
function Wn(t, e) {
|
|
1436
|
+
return `${Gt(e?.middlewareUrl)}/chat${Ht[t]}`;
|
|
1437
|
+
}
|
|
1438
|
+
var v;
|
|
1439
|
+
(function(t) {
|
|
1440
|
+
t.assertEqual = (i) => {
|
|
1441
|
+
};
|
|
1442
|
+
function e(i) {
|
|
1443
|
+
}
|
|
1444
|
+
t.assertIs = e;
|
|
1445
|
+
function n(i) {
|
|
1446
|
+
throw new Error();
|
|
1447
|
+
}
|
|
1448
|
+
t.assertNever = n, t.arrayToEnum = (i) => {
|
|
1449
|
+
const r = {};
|
|
1450
|
+
for (const a of i)
|
|
1451
|
+
r[a] = a;
|
|
1452
|
+
return r;
|
|
1453
|
+
}, t.getValidEnumValues = (i) => {
|
|
1454
|
+
const r = t.objectKeys(i).filter((o) => typeof i[i[o]] != "number"), a = {};
|
|
1455
|
+
for (const o of r)
|
|
1456
|
+
a[o] = i[o];
|
|
1457
|
+
return t.objectValues(a);
|
|
1458
|
+
}, t.objectValues = (i) => t.objectKeys(i).map(function(r) {
|
|
1459
|
+
return i[r];
|
|
1460
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (i) => Object.keys(i) : (i) => {
|
|
1461
|
+
const r = [];
|
|
1462
|
+
for (const a in i)
|
|
1463
|
+
Object.prototype.hasOwnProperty.call(i, a) && r.push(a);
|
|
1464
|
+
return r;
|
|
1465
|
+
}, t.find = (i, r) => {
|
|
1466
|
+
for (const a of i)
|
|
1467
|
+
if (r(a))
|
|
1468
|
+
return a;
|
|
1469
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (i) => Number.isInteger(i) : (i) => typeof i == "number" && Number.isFinite(i) && Math.floor(i) === i;
|
|
1470
|
+
function s(i, r = " | ") {
|
|
1471
|
+
return i.map((a) => typeof a == "string" ? `'${a}'` : a).join(r);
|
|
1472
|
+
}
|
|
1473
|
+
t.joinValues = s, t.jsonStringifyReplacer = (i, r) => typeof r == "bigint" ? r.toString() : r;
|
|
1474
|
+
})(v || (v = {}));
|
|
1475
|
+
var Te;
|
|
1476
|
+
(function(t) {
|
|
1477
|
+
t.mergeShapes = (e, n) => ({
|
|
1478
|
+
...e,
|
|
1479
|
+
...n
|
|
1480
|
+
// second overwrites first
|
|
1481
|
+
});
|
|
1482
|
+
})(Te || (Te = {}));
|
|
1483
|
+
const f = v.arrayToEnum([
|
|
1484
|
+
"string",
|
|
1485
|
+
"nan",
|
|
1486
|
+
"number",
|
|
1487
|
+
"integer",
|
|
1488
|
+
"float",
|
|
1489
|
+
"boolean",
|
|
1490
|
+
"date",
|
|
1491
|
+
"bigint",
|
|
1492
|
+
"symbol",
|
|
1493
|
+
"function",
|
|
1494
|
+
"undefined",
|
|
1495
|
+
"null",
|
|
1496
|
+
"array",
|
|
1497
|
+
"object",
|
|
1498
|
+
"unknown",
|
|
1499
|
+
"promise",
|
|
1500
|
+
"void",
|
|
1501
|
+
"never",
|
|
1502
|
+
"map",
|
|
1503
|
+
"set"
|
|
1504
|
+
]), Z = (t) => {
|
|
1505
|
+
switch (typeof t) {
|
|
1506
|
+
case "undefined":
|
|
1507
|
+
return f.undefined;
|
|
1508
|
+
case "string":
|
|
1509
|
+
return f.string;
|
|
1510
|
+
case "number":
|
|
1511
|
+
return Number.isNaN(t) ? f.nan : f.number;
|
|
1512
|
+
case "boolean":
|
|
1513
|
+
return f.boolean;
|
|
1514
|
+
case "function":
|
|
1515
|
+
return f.function;
|
|
1516
|
+
case "bigint":
|
|
1517
|
+
return f.bigint;
|
|
1518
|
+
case "symbol":
|
|
1519
|
+
return f.symbol;
|
|
1520
|
+
case "object":
|
|
1521
|
+
return Array.isArray(t) ? f.array : t === null ? f.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? f.promise : typeof Map < "u" && t instanceof Map ? f.map : typeof Set < "u" && t instanceof Set ? f.set : typeof Date < "u" && t instanceof Date ? f.date : f.object;
|
|
1522
|
+
default:
|
|
1523
|
+
return f.unknown;
|
|
1524
|
+
}
|
|
1525
|
+
}, d = v.arrayToEnum([
|
|
1526
|
+
"invalid_type",
|
|
1527
|
+
"invalid_literal",
|
|
1528
|
+
"custom",
|
|
1529
|
+
"invalid_union",
|
|
1530
|
+
"invalid_union_discriminator",
|
|
1531
|
+
"invalid_enum_value",
|
|
1532
|
+
"unrecognized_keys",
|
|
1533
|
+
"invalid_arguments",
|
|
1534
|
+
"invalid_return_type",
|
|
1535
|
+
"invalid_date",
|
|
1536
|
+
"invalid_string",
|
|
1537
|
+
"too_small",
|
|
1538
|
+
"too_big",
|
|
1539
|
+
"invalid_intersection_types",
|
|
1540
|
+
"not_multiple_of",
|
|
1541
|
+
"not_finite"
|
|
1542
|
+
]);
|
|
1543
|
+
class O extends Error {
|
|
1544
|
+
get errors() {
|
|
1545
|
+
return this.issues;
|
|
1546
|
+
}
|
|
1547
|
+
constructor(e) {
|
|
1548
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
1549
|
+
this.issues = [...this.issues, s];
|
|
1550
|
+
}, this.addIssues = (s = []) => {
|
|
1551
|
+
this.issues = [...this.issues, ...s];
|
|
1552
|
+
};
|
|
1553
|
+
const n = new.target.prototype;
|
|
1554
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, n) : this.__proto__ = n, this.name = "ZodError", this.issues = e;
|
|
1555
|
+
}
|
|
1556
|
+
format(e) {
|
|
1557
|
+
const n = e || function(r) {
|
|
1558
|
+
return r.message;
|
|
1559
|
+
}, s = { _errors: [] }, i = (r) => {
|
|
1560
|
+
for (const a of r.issues)
|
|
1561
|
+
if (a.code === "invalid_union")
|
|
1562
|
+
a.unionErrors.map(i);
|
|
1563
|
+
else if (a.code === "invalid_return_type")
|
|
1564
|
+
i(a.returnTypeError);
|
|
1565
|
+
else if (a.code === "invalid_arguments")
|
|
1566
|
+
i(a.argumentsError);
|
|
1567
|
+
else if (a.path.length === 0)
|
|
1568
|
+
s._errors.push(n(a));
|
|
1569
|
+
else {
|
|
1570
|
+
let o = s, c = 0;
|
|
1571
|
+
for (; c < a.path.length; ) {
|
|
1572
|
+
const l = a.path[c];
|
|
1573
|
+
c === a.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(n(a))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
return i(this), s;
|
|
1578
|
+
}
|
|
1579
|
+
static assert(e) {
|
|
1580
|
+
if (!(e instanceof O))
|
|
1581
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
1582
|
+
}
|
|
1583
|
+
toString() {
|
|
1584
|
+
return this.message;
|
|
1585
|
+
}
|
|
1586
|
+
get message() {
|
|
1587
|
+
return JSON.stringify(this.issues, v.jsonStringifyReplacer, 2);
|
|
1588
|
+
}
|
|
1589
|
+
get isEmpty() {
|
|
1590
|
+
return this.issues.length === 0;
|
|
1591
|
+
}
|
|
1592
|
+
flatten(e = (n) => n.message) {
|
|
1593
|
+
const n = {}, s = [];
|
|
1594
|
+
for (const i of this.issues)
|
|
1595
|
+
if (i.path.length > 0) {
|
|
1596
|
+
const r = i.path[0];
|
|
1597
|
+
n[r] = n[r] || [], n[r].push(e(i));
|
|
1598
|
+
} else
|
|
1599
|
+
s.push(e(i));
|
|
1600
|
+
return { formErrors: s, fieldErrors: n };
|
|
1601
|
+
}
|
|
1602
|
+
get formErrors() {
|
|
1603
|
+
return this.flatten();
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
O.create = (t) => new O(t);
|
|
1607
|
+
const ce = (t, e) => {
|
|
1608
|
+
let n;
|
|
1609
|
+
switch (t.code) {
|
|
1610
|
+
case d.invalid_type:
|
|
1611
|
+
t.received === f.undefined ? n = "Required" : n = `Expected ${t.expected}, received ${t.received}`;
|
|
1612
|
+
break;
|
|
1613
|
+
case d.invalid_literal:
|
|
1614
|
+
n = `Invalid literal value, expected ${JSON.stringify(t.expected, v.jsonStringifyReplacer)}`;
|
|
1615
|
+
break;
|
|
1616
|
+
case d.unrecognized_keys:
|
|
1617
|
+
n = `Unrecognized key(s) in object: ${v.joinValues(t.keys, ", ")}`;
|
|
1618
|
+
break;
|
|
1619
|
+
case d.invalid_union:
|
|
1620
|
+
n = "Invalid input";
|
|
1621
|
+
break;
|
|
1622
|
+
case d.invalid_union_discriminator:
|
|
1623
|
+
n = `Invalid discriminator value. Expected ${v.joinValues(t.options)}`;
|
|
1624
|
+
break;
|
|
1625
|
+
case d.invalid_enum_value:
|
|
1626
|
+
n = `Invalid enum value. Expected ${v.joinValues(t.options)}, received '${t.received}'`;
|
|
1627
|
+
break;
|
|
1628
|
+
case d.invalid_arguments:
|
|
1629
|
+
n = "Invalid function arguments";
|
|
1630
|
+
break;
|
|
1631
|
+
case d.invalid_return_type:
|
|
1632
|
+
n = "Invalid function return type";
|
|
1633
|
+
break;
|
|
1634
|
+
case d.invalid_date:
|
|
1635
|
+
n = "Invalid date";
|
|
1636
|
+
break;
|
|
1637
|
+
case d.invalid_string:
|
|
1638
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (n = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? n = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? n = `Invalid input: must end with "${t.validation.endsWith}"` : v.assertNever(t.validation) : t.validation !== "regex" ? n = `Invalid ${t.validation}` : n = "Invalid";
|
|
1639
|
+
break;
|
|
1640
|
+
case d.too_small:
|
|
1641
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? n = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : n = "Invalid input";
|
|
1642
|
+
break;
|
|
1643
|
+
case d.too_big:
|
|
1644
|
+
t.type === "array" ? n = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? n = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? n = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? n = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? n = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : n = "Invalid input";
|
|
1645
|
+
break;
|
|
1646
|
+
case d.custom:
|
|
1647
|
+
n = "Invalid input";
|
|
1648
|
+
break;
|
|
1649
|
+
case d.invalid_intersection_types:
|
|
1650
|
+
n = "Intersection results could not be merged";
|
|
1651
|
+
break;
|
|
1652
|
+
case d.not_multiple_of:
|
|
1653
|
+
n = `Number must be a multiple of ${t.multipleOf}`;
|
|
1654
|
+
break;
|
|
1655
|
+
case d.not_finite:
|
|
1656
|
+
n = "Number must be finite";
|
|
1657
|
+
break;
|
|
1658
|
+
default:
|
|
1659
|
+
n = e.defaultError, v.assertNever(t);
|
|
1660
|
+
}
|
|
1661
|
+
return { message: n };
|
|
1662
|
+
};
|
|
1663
|
+
let Jt = ce;
|
|
1664
|
+
function Qt() {
|
|
1665
|
+
return Jt;
|
|
1666
|
+
}
|
|
1667
|
+
const Yt = (t) => {
|
|
1668
|
+
const { data: e, path: n, errorMaps: s, issueData: i } = t, r = [...n, ...i.path || []], a = {
|
|
1669
|
+
...i,
|
|
1670
|
+
path: r
|
|
1671
|
+
};
|
|
1672
|
+
if (i.message !== void 0)
|
|
1673
|
+
return {
|
|
1674
|
+
...i,
|
|
1675
|
+
path: r,
|
|
1676
|
+
message: i.message
|
|
1677
|
+
};
|
|
1678
|
+
let o = "";
|
|
1679
|
+
const c = s.filter((l) => !!l).slice().reverse();
|
|
1680
|
+
for (const l of c)
|
|
1681
|
+
o = l(a, { data: e, defaultError: o }).message;
|
|
1682
|
+
return {
|
|
1683
|
+
...i,
|
|
1684
|
+
path: r,
|
|
1685
|
+
message: o
|
|
1686
|
+
};
|
|
1687
|
+
};
|
|
1688
|
+
function u(t, e) {
|
|
1689
|
+
const n = Qt(), s = Yt({
|
|
1690
|
+
issueData: e,
|
|
1691
|
+
data: t.data,
|
|
1692
|
+
path: t.path,
|
|
1693
|
+
errorMaps: [
|
|
1694
|
+
t.common.contextualErrorMap,
|
|
1695
|
+
// contextual error map is first priority
|
|
1696
|
+
t.schemaErrorMap,
|
|
1697
|
+
// then schema-bound map if available
|
|
1698
|
+
n,
|
|
1699
|
+
// then global override map
|
|
1700
|
+
n === ce ? void 0 : ce
|
|
1701
|
+
// then global default map
|
|
1702
|
+
].filter((i) => !!i)
|
|
1703
|
+
});
|
|
1704
|
+
t.common.issues.push(s);
|
|
1705
|
+
}
|
|
1706
|
+
class T {
|
|
1707
|
+
constructor() {
|
|
1708
|
+
this.value = "valid";
|
|
1709
|
+
}
|
|
1710
|
+
dirty() {
|
|
1711
|
+
this.value === "valid" && (this.value = "dirty");
|
|
1712
|
+
}
|
|
1713
|
+
abort() {
|
|
1714
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
1715
|
+
}
|
|
1716
|
+
static mergeArray(e, n) {
|
|
1717
|
+
const s = [];
|
|
1718
|
+
for (const i of n) {
|
|
1719
|
+
if (i.status === "aborted")
|
|
1720
|
+
return m;
|
|
1721
|
+
i.status === "dirty" && e.dirty(), s.push(i.value);
|
|
1722
|
+
}
|
|
1723
|
+
return { status: e.value, value: s };
|
|
1724
|
+
}
|
|
1725
|
+
static async mergeObjectAsync(e, n) {
|
|
1726
|
+
const s = [];
|
|
1727
|
+
for (const i of n) {
|
|
1728
|
+
const r = await i.key, a = await i.value;
|
|
1729
|
+
s.push({
|
|
1730
|
+
key: r,
|
|
1731
|
+
value: a
|
|
1732
|
+
});
|
|
1733
|
+
}
|
|
1734
|
+
return T.mergeObjectSync(e, s);
|
|
1735
|
+
}
|
|
1736
|
+
static mergeObjectSync(e, n) {
|
|
1737
|
+
const s = {};
|
|
1738
|
+
for (const i of n) {
|
|
1739
|
+
const { key: r, value: a } = i;
|
|
1740
|
+
if (r.status === "aborted" || a.status === "aborted")
|
|
1741
|
+
return m;
|
|
1742
|
+
r.status === "dirty" && e.dirty(), a.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof a.value < "u" || i.alwaysSet) && (s[r.value] = a.value);
|
|
1743
|
+
}
|
|
1744
|
+
return { status: e.value, value: s };
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
const m = Object.freeze({
|
|
1748
|
+
status: "aborted"
|
|
1749
|
+
}), J = (t) => ({ status: "dirty", value: t }), S = (t) => ({ status: "valid", value: t }), Ce = (t) => t.status === "aborted", Se = (t) => t.status === "dirty", q = (t) => t.status === "valid", X = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
1750
|
+
var p;
|
|
1751
|
+
(function(t) {
|
|
1752
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
1753
|
+
})(p || (p = {}));
|
|
1754
|
+
class I {
|
|
1755
|
+
constructor(e, n, s, i) {
|
|
1756
|
+
this._cachedPath = [], this.parent = e, this.data = n, this._path = s, this._key = i;
|
|
1757
|
+
}
|
|
1758
|
+
get path() {
|
|
1759
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const Ae = (t, e) => {
|
|
1763
|
+
if (q(e))
|
|
1764
|
+
return { success: !0, data: e.value };
|
|
1765
|
+
if (!t.common.issues.length)
|
|
1766
|
+
throw new Error("Validation failed but no issues detected.");
|
|
1767
|
+
return {
|
|
1768
|
+
success: !1,
|
|
1769
|
+
get error() {
|
|
1770
|
+
if (this._error)
|
|
1771
|
+
return this._error;
|
|
1772
|
+
const n = new O(t.common.issues);
|
|
1773
|
+
return this._error = n, this._error;
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
};
|
|
1777
|
+
function _(t) {
|
|
1778
|
+
if (!t)
|
|
1779
|
+
return {};
|
|
1780
|
+
const { errorMap: e, invalid_type_error: n, required_error: s, description: i } = t;
|
|
1781
|
+
if (e && (n || s))
|
|
1782
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1783
|
+
return e ? { errorMap: e, description: i } : { errorMap: (a, o) => {
|
|
1784
|
+
const { message: c } = t;
|
|
1785
|
+
return a.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? s ?? o.defaultError } : a.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? n ?? o.defaultError };
|
|
1786
|
+
}, description: i };
|
|
1787
|
+
}
|
|
1788
|
+
class y {
|
|
1789
|
+
get description() {
|
|
1790
|
+
return this._def.description;
|
|
1791
|
+
}
|
|
1792
|
+
_getType(e) {
|
|
1793
|
+
return Z(e.data);
|
|
1794
|
+
}
|
|
1795
|
+
_getOrReturnCtx(e, n) {
|
|
1796
|
+
return n || {
|
|
1797
|
+
common: e.parent.common,
|
|
1798
|
+
data: e.data,
|
|
1799
|
+
parsedType: Z(e.data),
|
|
1800
|
+
schemaErrorMap: this._def.errorMap,
|
|
1801
|
+
path: e.path,
|
|
1802
|
+
parent: e.parent
|
|
1803
|
+
};
|
|
1804
|
+
}
|
|
1805
|
+
_processInputParams(e) {
|
|
1806
|
+
return {
|
|
1807
|
+
status: new T(),
|
|
1808
|
+
ctx: {
|
|
1809
|
+
common: e.parent.common,
|
|
1810
|
+
data: e.data,
|
|
1811
|
+
parsedType: Z(e.data),
|
|
1812
|
+
schemaErrorMap: this._def.errorMap,
|
|
1813
|
+
path: e.path,
|
|
1814
|
+
parent: e.parent
|
|
1815
|
+
}
|
|
1816
|
+
};
|
|
1817
|
+
}
|
|
1818
|
+
_parseSync(e) {
|
|
1819
|
+
const n = this._parse(e);
|
|
1820
|
+
if (X(n))
|
|
1821
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
1822
|
+
return n;
|
|
1823
|
+
}
|
|
1824
|
+
_parseAsync(e) {
|
|
1825
|
+
const n = this._parse(e);
|
|
1826
|
+
return Promise.resolve(n);
|
|
1827
|
+
}
|
|
1828
|
+
parse(e, n) {
|
|
1829
|
+
const s = this.safeParse(e, n);
|
|
1830
|
+
if (s.success)
|
|
1831
|
+
return s.data;
|
|
1832
|
+
throw s.error;
|
|
1833
|
+
}
|
|
1834
|
+
safeParse(e, n) {
|
|
1835
|
+
const s = {
|
|
1836
|
+
common: {
|
|
1837
|
+
issues: [],
|
|
1838
|
+
async: n?.async ?? !1,
|
|
1839
|
+
contextualErrorMap: n?.errorMap
|
|
1840
|
+
},
|
|
1841
|
+
path: n?.path || [],
|
|
1842
|
+
schemaErrorMap: this._def.errorMap,
|
|
1843
|
+
parent: null,
|
|
1844
|
+
data: e,
|
|
1845
|
+
parsedType: Z(e)
|
|
1846
|
+
}, i = this._parseSync({ data: e, path: s.path, parent: s });
|
|
1847
|
+
return Ae(s, i);
|
|
1848
|
+
}
|
|
1849
|
+
"~validate"(e) {
|
|
1850
|
+
const n = {
|
|
1851
|
+
common: {
|
|
1852
|
+
issues: [],
|
|
1853
|
+
async: !!this["~standard"].async
|
|
1854
|
+
},
|
|
1855
|
+
path: [],
|
|
1856
|
+
schemaErrorMap: this._def.errorMap,
|
|
1857
|
+
parent: null,
|
|
1858
|
+
data: e,
|
|
1859
|
+
parsedType: Z(e)
|
|
1860
|
+
};
|
|
1861
|
+
if (!this["~standard"].async)
|
|
1862
|
+
try {
|
|
1863
|
+
const s = this._parseSync({ data: e, path: [], parent: n });
|
|
1864
|
+
return q(s) ? {
|
|
1865
|
+
value: s.value
|
|
1866
|
+
} : {
|
|
1867
|
+
issues: n.common.issues
|
|
1868
|
+
};
|
|
1869
|
+
} catch (s) {
|
|
1870
|
+
s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
1871
|
+
issues: [],
|
|
1872
|
+
async: !0
|
|
1873
|
+
};
|
|
1874
|
+
}
|
|
1875
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((s) => q(s) ? {
|
|
1876
|
+
value: s.value
|
|
1877
|
+
} : {
|
|
1878
|
+
issues: n.common.issues
|
|
1879
|
+
});
|
|
1880
|
+
}
|
|
1881
|
+
async parseAsync(e, n) {
|
|
1882
|
+
const s = await this.safeParseAsync(e, n);
|
|
1883
|
+
if (s.success)
|
|
1884
|
+
return s.data;
|
|
1885
|
+
throw s.error;
|
|
1886
|
+
}
|
|
1887
|
+
async safeParseAsync(e, n) {
|
|
1888
|
+
const s = {
|
|
1889
|
+
common: {
|
|
1890
|
+
issues: [],
|
|
1891
|
+
contextualErrorMap: n?.errorMap,
|
|
1892
|
+
async: !0
|
|
1893
|
+
},
|
|
1894
|
+
path: n?.path || [],
|
|
1895
|
+
schemaErrorMap: this._def.errorMap,
|
|
1896
|
+
parent: null,
|
|
1897
|
+
data: e,
|
|
1898
|
+
parsedType: Z(e)
|
|
1899
|
+
}, i = this._parse({ data: e, path: s.path, parent: s }), r = await (X(i) ? i : Promise.resolve(i));
|
|
1900
|
+
return Ae(s, r);
|
|
1901
|
+
}
|
|
1902
|
+
refine(e, n) {
|
|
1903
|
+
const s = (i) => typeof n == "string" || typeof n > "u" ? { message: n } : typeof n == "function" ? n(i) : n;
|
|
1904
|
+
return this._refinement((i, r) => {
|
|
1905
|
+
const a = e(i), o = () => r.addIssue({
|
|
1906
|
+
code: d.custom,
|
|
1907
|
+
...s(i)
|
|
1908
|
+
});
|
|
1909
|
+
return typeof Promise < "u" && a instanceof Promise ? a.then((c) => c ? !0 : (o(), !1)) : a ? !0 : (o(), !1);
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
refinement(e, n) {
|
|
1913
|
+
return this._refinement((s, i) => e(s) ? !0 : (i.addIssue(typeof n == "function" ? n(s, i) : n), !1));
|
|
1914
|
+
}
|
|
1915
|
+
_refinement(e) {
|
|
1916
|
+
return new F({
|
|
1917
|
+
schema: this,
|
|
1918
|
+
typeName: h.ZodEffects,
|
|
1919
|
+
effect: { type: "refinement", refinement: e }
|
|
1920
|
+
});
|
|
1921
|
+
}
|
|
1922
|
+
superRefine(e) {
|
|
1923
|
+
return this._refinement(e);
|
|
1924
|
+
}
|
|
1925
|
+
constructor(e) {
|
|
1926
|
+
this.spa = this.safeParseAsync, this._def = e, 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"] = {
|
|
1927
|
+
version: 1,
|
|
1928
|
+
vendor: "zod",
|
|
1929
|
+
validate: (n) => this["~validate"](n)
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
optional() {
|
|
1933
|
+
return j.create(this, this._def);
|
|
1934
|
+
}
|
|
1935
|
+
nullable() {
|
|
1936
|
+
return H.create(this, this._def);
|
|
1937
|
+
}
|
|
1938
|
+
nullish() {
|
|
1939
|
+
return this.nullable().optional();
|
|
1940
|
+
}
|
|
1941
|
+
array() {
|
|
1942
|
+
return E.create(this);
|
|
1943
|
+
}
|
|
1944
|
+
promise() {
|
|
1945
|
+
return ie.create(this, this._def);
|
|
1946
|
+
}
|
|
1947
|
+
or(e) {
|
|
1948
|
+
return te.create([this, e], this._def);
|
|
1949
|
+
}
|
|
1950
|
+
and(e) {
|
|
1951
|
+
return ne.create(this, e, this._def);
|
|
1952
|
+
}
|
|
1953
|
+
transform(e) {
|
|
1954
|
+
return new F({
|
|
1955
|
+
..._(this._def),
|
|
1956
|
+
schema: this,
|
|
1957
|
+
typeName: h.ZodEffects,
|
|
1958
|
+
effect: { type: "transform", transform: e }
|
|
1959
|
+
});
|
|
1960
|
+
}
|
|
1961
|
+
default(e) {
|
|
1962
|
+
const n = typeof e == "function" ? e : () => e;
|
|
1963
|
+
return new he({
|
|
1964
|
+
..._(this._def),
|
|
1965
|
+
innerType: this,
|
|
1966
|
+
defaultValue: n,
|
|
1967
|
+
typeName: h.ZodDefault
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
brand() {
|
|
1971
|
+
return new wn({
|
|
1972
|
+
typeName: h.ZodBranded,
|
|
1973
|
+
type: this,
|
|
1974
|
+
..._(this._def)
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
catch(e) {
|
|
1978
|
+
const n = typeof e == "function" ? e : () => e;
|
|
1979
|
+
return new me({
|
|
1980
|
+
..._(this._def),
|
|
1981
|
+
innerType: this,
|
|
1982
|
+
catchValue: n,
|
|
1983
|
+
typeName: h.ZodCatch
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
describe(e) {
|
|
1987
|
+
const n = this.constructor;
|
|
1988
|
+
return new n({
|
|
1989
|
+
...this._def,
|
|
1990
|
+
description: e
|
|
1991
|
+
});
|
|
1992
|
+
}
|
|
1993
|
+
pipe(e) {
|
|
1994
|
+
return ve.create(this, e);
|
|
1995
|
+
}
|
|
1996
|
+
readonly() {
|
|
1997
|
+
return ge.create(this);
|
|
1998
|
+
}
|
|
1999
|
+
isOptional() {
|
|
2000
|
+
return this.safeParse(void 0).success;
|
|
2001
|
+
}
|
|
2002
|
+
isNullable() {
|
|
2003
|
+
return this.safeParse(null).success;
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
const Kt = /^c[^\s-]{8,}$/i, Xt = /^[0-9a-z]+$/, en = /^[0-9A-HJKMNP-TV-Z]{26}$/i, tn = /^[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, nn = /^[a-z0-9_-]{21}$/i, sn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, rn = /^[-+]?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)?)??$/, an = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, on = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
2007
|
+
let de;
|
|
2008
|
+
const dn = /^(?:(?: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])$/, cn = /^(?:(?: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])$/, un = /^(([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]))$/, ln = /^(([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])$/, fn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, pn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ue = "((\\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])))", hn = new RegExp(`^${Ue}$`);
|
|
2009
|
+
function qe(t) {
|
|
2010
|
+
let e = "[0-5]\\d";
|
|
2011
|
+
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
2012
|
+
const n = t.precision ? "+" : "?";
|
|
2013
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`;
|
|
2014
|
+
}
|
|
2015
|
+
function mn(t) {
|
|
2016
|
+
return new RegExp(`^${qe(t)}$`);
|
|
2017
|
+
}
|
|
2018
|
+
function gn(t) {
|
|
2019
|
+
let e = `${Ue}T${qe(t)}`;
|
|
2020
|
+
const n = [];
|
|
2021
|
+
return n.push(t.local ? "Z?" : "Z"), t.offset && n.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${n.join("|")})`, new RegExp(`^${e}$`);
|
|
2022
|
+
}
|
|
2023
|
+
function _n(t, e) {
|
|
2024
|
+
return !!((e === "v4" || !e) && dn.test(t) || (e === "v6" || !e) && un.test(t));
|
|
2025
|
+
}
|
|
2026
|
+
function yn(t, e) {
|
|
2027
|
+
if (!sn.test(t))
|
|
2028
|
+
return !1;
|
|
2029
|
+
try {
|
|
2030
|
+
const [n] = t.split(".");
|
|
2031
|
+
if (!n)
|
|
2032
|
+
return !1;
|
|
2033
|
+
const s = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.length % 4) % 4, "="), i = JSON.parse(atob(s));
|
|
2034
|
+
return !(typeof i != "object" || i === null || "typ" in i && i?.typ !== "JWT" || !i.alg || e && i.alg !== e);
|
|
2035
|
+
} catch {
|
|
2036
|
+
return !1;
|
|
2037
|
+
}
|
|
2038
|
+
}
|
|
2039
|
+
function vn(t, e) {
|
|
2040
|
+
return !!((e === "v4" || !e) && cn.test(t) || (e === "v6" || !e) && ln.test(t));
|
|
2041
|
+
}
|
|
2042
|
+
class N extends y {
|
|
2043
|
+
_parse(e) {
|
|
2044
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
2045
|
+
const r = this._getOrReturnCtx(e);
|
|
2046
|
+
return u(r, {
|
|
2047
|
+
code: d.invalid_type,
|
|
2048
|
+
expected: f.string,
|
|
2049
|
+
received: r.parsedType
|
|
2050
|
+
}), m;
|
|
2051
|
+
}
|
|
2052
|
+
const s = new T();
|
|
2053
|
+
let i;
|
|
2054
|
+
for (const r of this._def.checks)
|
|
2055
|
+
if (r.kind === "min")
|
|
2056
|
+
e.data.length < r.value && (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2057
|
+
code: d.too_small,
|
|
2058
|
+
minimum: r.value,
|
|
2059
|
+
type: "string",
|
|
2060
|
+
inclusive: !0,
|
|
2061
|
+
exact: !1,
|
|
2062
|
+
message: r.message
|
|
2063
|
+
}), s.dirty());
|
|
2064
|
+
else if (r.kind === "max")
|
|
2065
|
+
e.data.length > r.value && (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2066
|
+
code: d.too_big,
|
|
2067
|
+
maximum: r.value,
|
|
2068
|
+
type: "string",
|
|
2069
|
+
inclusive: !0,
|
|
2070
|
+
exact: !1,
|
|
2071
|
+
message: r.message
|
|
2072
|
+
}), s.dirty());
|
|
2073
|
+
else if (r.kind === "length") {
|
|
2074
|
+
const a = e.data.length > r.value, o = e.data.length < r.value;
|
|
2075
|
+
(a || o) && (i = this._getOrReturnCtx(e, i), a ? u(i, {
|
|
2076
|
+
code: d.too_big,
|
|
2077
|
+
maximum: r.value,
|
|
2078
|
+
type: "string",
|
|
2079
|
+
inclusive: !0,
|
|
2080
|
+
exact: !0,
|
|
2081
|
+
message: r.message
|
|
2082
|
+
}) : o && u(i, {
|
|
2083
|
+
code: d.too_small,
|
|
2084
|
+
minimum: r.value,
|
|
2085
|
+
type: "string",
|
|
2086
|
+
inclusive: !0,
|
|
2087
|
+
exact: !0,
|
|
2088
|
+
message: r.message
|
|
2089
|
+
}), s.dirty());
|
|
2090
|
+
} else if (r.kind === "email")
|
|
2091
|
+
an.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2092
|
+
validation: "email",
|
|
2093
|
+
code: d.invalid_string,
|
|
2094
|
+
message: r.message
|
|
2095
|
+
}), s.dirty());
|
|
2096
|
+
else if (r.kind === "emoji")
|
|
2097
|
+
de || (de = new RegExp(on, "u")), de.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2098
|
+
validation: "emoji",
|
|
2099
|
+
code: d.invalid_string,
|
|
2100
|
+
message: r.message
|
|
2101
|
+
}), s.dirty());
|
|
2102
|
+
else if (r.kind === "uuid")
|
|
2103
|
+
tn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2104
|
+
validation: "uuid",
|
|
2105
|
+
code: d.invalid_string,
|
|
2106
|
+
message: r.message
|
|
2107
|
+
}), s.dirty());
|
|
2108
|
+
else if (r.kind === "nanoid")
|
|
2109
|
+
nn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2110
|
+
validation: "nanoid",
|
|
2111
|
+
code: d.invalid_string,
|
|
2112
|
+
message: r.message
|
|
2113
|
+
}), s.dirty());
|
|
2114
|
+
else if (r.kind === "cuid")
|
|
2115
|
+
Kt.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2116
|
+
validation: "cuid",
|
|
2117
|
+
code: d.invalid_string,
|
|
2118
|
+
message: r.message
|
|
2119
|
+
}), s.dirty());
|
|
2120
|
+
else if (r.kind === "cuid2")
|
|
2121
|
+
Xt.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2122
|
+
validation: "cuid2",
|
|
2123
|
+
code: d.invalid_string,
|
|
2124
|
+
message: r.message
|
|
2125
|
+
}), s.dirty());
|
|
2126
|
+
else if (r.kind === "ulid")
|
|
2127
|
+
en.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2128
|
+
validation: "ulid",
|
|
2129
|
+
code: d.invalid_string,
|
|
2130
|
+
message: r.message
|
|
2131
|
+
}), s.dirty());
|
|
2132
|
+
else if (r.kind === "url")
|
|
2133
|
+
try {
|
|
2134
|
+
new URL(e.data);
|
|
2135
|
+
} catch {
|
|
2136
|
+
i = this._getOrReturnCtx(e, i), u(i, {
|
|
2137
|
+
validation: "url",
|
|
2138
|
+
code: d.invalid_string,
|
|
2139
|
+
message: r.message
|
|
2140
|
+
}), s.dirty();
|
|
2141
|
+
}
|
|
2142
|
+
else r.kind === "regex" ? (r.regex.lastIndex = 0, r.regex.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2143
|
+
validation: "regex",
|
|
2144
|
+
code: d.invalid_string,
|
|
2145
|
+
message: r.message
|
|
2146
|
+
}), s.dirty())) : r.kind === "trim" ? e.data = e.data.trim() : r.kind === "includes" ? e.data.includes(r.value, r.position) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2147
|
+
code: d.invalid_string,
|
|
2148
|
+
validation: { includes: r.value, position: r.position },
|
|
2149
|
+
message: r.message
|
|
2150
|
+
}), s.dirty()) : r.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : r.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : r.kind === "startsWith" ? e.data.startsWith(r.value) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2151
|
+
code: d.invalid_string,
|
|
2152
|
+
validation: { startsWith: r.value },
|
|
2153
|
+
message: r.message
|
|
2154
|
+
}), s.dirty()) : r.kind === "endsWith" ? e.data.endsWith(r.value) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2155
|
+
code: d.invalid_string,
|
|
2156
|
+
validation: { endsWith: r.value },
|
|
2157
|
+
message: r.message
|
|
2158
|
+
}), s.dirty()) : r.kind === "datetime" ? gn(r).test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2159
|
+
code: d.invalid_string,
|
|
2160
|
+
validation: "datetime",
|
|
2161
|
+
message: r.message
|
|
2162
|
+
}), s.dirty()) : r.kind === "date" ? hn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2163
|
+
code: d.invalid_string,
|
|
2164
|
+
validation: "date",
|
|
2165
|
+
message: r.message
|
|
2166
|
+
}), s.dirty()) : r.kind === "time" ? mn(r).test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2167
|
+
code: d.invalid_string,
|
|
2168
|
+
validation: "time",
|
|
2169
|
+
message: r.message
|
|
2170
|
+
}), s.dirty()) : r.kind === "duration" ? rn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2171
|
+
validation: "duration",
|
|
2172
|
+
code: d.invalid_string,
|
|
2173
|
+
message: r.message
|
|
2174
|
+
}), s.dirty()) : r.kind === "ip" ? _n(e.data, r.version) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2175
|
+
validation: "ip",
|
|
2176
|
+
code: d.invalid_string,
|
|
2177
|
+
message: r.message
|
|
2178
|
+
}), s.dirty()) : r.kind === "jwt" ? yn(e.data, r.alg) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2179
|
+
validation: "jwt",
|
|
2180
|
+
code: d.invalid_string,
|
|
2181
|
+
message: r.message
|
|
2182
|
+
}), s.dirty()) : r.kind === "cidr" ? vn(e.data, r.version) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2183
|
+
validation: "cidr",
|
|
2184
|
+
code: d.invalid_string,
|
|
2185
|
+
message: r.message
|
|
2186
|
+
}), s.dirty()) : r.kind === "base64" ? fn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2187
|
+
validation: "base64",
|
|
2188
|
+
code: d.invalid_string,
|
|
2189
|
+
message: r.message
|
|
2190
|
+
}), s.dirty()) : r.kind === "base64url" ? pn.test(e.data) || (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2191
|
+
validation: "base64url",
|
|
2192
|
+
code: d.invalid_string,
|
|
2193
|
+
message: r.message
|
|
2194
|
+
}), s.dirty()) : v.assertNever(r);
|
|
2195
|
+
return { status: s.value, value: e.data };
|
|
2196
|
+
}
|
|
2197
|
+
_regex(e, n, s) {
|
|
2198
|
+
return this.refinement((i) => e.test(i), {
|
|
2199
|
+
validation: n,
|
|
2200
|
+
code: d.invalid_string,
|
|
2201
|
+
...p.errToObj(s)
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
_addCheck(e) {
|
|
2205
|
+
return new N({
|
|
2206
|
+
...this._def,
|
|
2207
|
+
checks: [...this._def.checks, e]
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
email(e) {
|
|
2211
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
2212
|
+
}
|
|
2213
|
+
url(e) {
|
|
2214
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
2215
|
+
}
|
|
2216
|
+
emoji(e) {
|
|
2217
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
2218
|
+
}
|
|
2219
|
+
uuid(e) {
|
|
2220
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
2221
|
+
}
|
|
2222
|
+
nanoid(e) {
|
|
2223
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
2224
|
+
}
|
|
2225
|
+
cuid(e) {
|
|
2226
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
2227
|
+
}
|
|
2228
|
+
cuid2(e) {
|
|
2229
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
2230
|
+
}
|
|
2231
|
+
ulid(e) {
|
|
2232
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
2233
|
+
}
|
|
2234
|
+
base64(e) {
|
|
2235
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
2236
|
+
}
|
|
2237
|
+
base64url(e) {
|
|
2238
|
+
return this._addCheck({
|
|
2239
|
+
kind: "base64url",
|
|
2240
|
+
...p.errToObj(e)
|
|
2241
|
+
});
|
|
2242
|
+
}
|
|
2243
|
+
jwt(e) {
|
|
2244
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
2245
|
+
}
|
|
2246
|
+
ip(e) {
|
|
2247
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
2248
|
+
}
|
|
2249
|
+
cidr(e) {
|
|
2250
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
2251
|
+
}
|
|
2252
|
+
datetime(e) {
|
|
2253
|
+
return typeof e == "string" ? this._addCheck({
|
|
2254
|
+
kind: "datetime",
|
|
2255
|
+
precision: null,
|
|
2256
|
+
offset: !1,
|
|
2257
|
+
local: !1,
|
|
2258
|
+
message: e
|
|
2259
|
+
}) : this._addCheck({
|
|
2260
|
+
kind: "datetime",
|
|
2261
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
2262
|
+
offset: e?.offset ?? !1,
|
|
2263
|
+
local: e?.local ?? !1,
|
|
2264
|
+
...p.errToObj(e?.message)
|
|
2265
|
+
});
|
|
2266
|
+
}
|
|
2267
|
+
date(e) {
|
|
2268
|
+
return this._addCheck({ kind: "date", message: e });
|
|
2269
|
+
}
|
|
2270
|
+
time(e) {
|
|
2271
|
+
return typeof e == "string" ? this._addCheck({
|
|
2272
|
+
kind: "time",
|
|
2273
|
+
precision: null,
|
|
2274
|
+
message: e
|
|
2275
|
+
}) : this._addCheck({
|
|
2276
|
+
kind: "time",
|
|
2277
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
2278
|
+
...p.errToObj(e?.message)
|
|
2279
|
+
});
|
|
2280
|
+
}
|
|
2281
|
+
duration(e) {
|
|
2282
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
2283
|
+
}
|
|
2284
|
+
regex(e, n) {
|
|
2285
|
+
return this._addCheck({
|
|
2286
|
+
kind: "regex",
|
|
2287
|
+
regex: e,
|
|
2288
|
+
...p.errToObj(n)
|
|
2289
|
+
});
|
|
2290
|
+
}
|
|
2291
|
+
includes(e, n) {
|
|
2292
|
+
return this._addCheck({
|
|
2293
|
+
kind: "includes",
|
|
2294
|
+
value: e,
|
|
2295
|
+
position: n?.position,
|
|
2296
|
+
...p.errToObj(n?.message)
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
startsWith(e, n) {
|
|
2300
|
+
return this._addCheck({
|
|
2301
|
+
kind: "startsWith",
|
|
2302
|
+
value: e,
|
|
2303
|
+
...p.errToObj(n)
|
|
2304
|
+
});
|
|
2305
|
+
}
|
|
2306
|
+
endsWith(e, n) {
|
|
2307
|
+
return this._addCheck({
|
|
2308
|
+
kind: "endsWith",
|
|
2309
|
+
value: e,
|
|
2310
|
+
...p.errToObj(n)
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
min(e, n) {
|
|
2314
|
+
return this._addCheck({
|
|
2315
|
+
kind: "min",
|
|
2316
|
+
value: e,
|
|
2317
|
+
...p.errToObj(n)
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
max(e, n) {
|
|
2321
|
+
return this._addCheck({
|
|
2322
|
+
kind: "max",
|
|
2323
|
+
value: e,
|
|
2324
|
+
...p.errToObj(n)
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
length(e, n) {
|
|
2328
|
+
return this._addCheck({
|
|
2329
|
+
kind: "length",
|
|
2330
|
+
value: e,
|
|
2331
|
+
...p.errToObj(n)
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2334
|
+
/**
|
|
2335
|
+
* Equivalent to `.min(1)`
|
|
2336
|
+
*/
|
|
2337
|
+
nonempty(e) {
|
|
2338
|
+
return this.min(1, p.errToObj(e));
|
|
2339
|
+
}
|
|
2340
|
+
trim() {
|
|
2341
|
+
return new N({
|
|
2342
|
+
...this._def,
|
|
2343
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
toLowerCase() {
|
|
2347
|
+
return new N({
|
|
2348
|
+
...this._def,
|
|
2349
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
toUpperCase() {
|
|
2353
|
+
return new N({
|
|
2354
|
+
...this._def,
|
|
2355
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
get isDatetime() {
|
|
2359
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
2360
|
+
}
|
|
2361
|
+
get isDate() {
|
|
2362
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
2363
|
+
}
|
|
2364
|
+
get isTime() {
|
|
2365
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
2366
|
+
}
|
|
2367
|
+
get isDuration() {
|
|
2368
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
2369
|
+
}
|
|
2370
|
+
get isEmail() {
|
|
2371
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
2372
|
+
}
|
|
2373
|
+
get isURL() {
|
|
2374
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
2375
|
+
}
|
|
2376
|
+
get isEmoji() {
|
|
2377
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
2378
|
+
}
|
|
2379
|
+
get isUUID() {
|
|
2380
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
2381
|
+
}
|
|
2382
|
+
get isNANOID() {
|
|
2383
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
2384
|
+
}
|
|
2385
|
+
get isCUID() {
|
|
2386
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
2387
|
+
}
|
|
2388
|
+
get isCUID2() {
|
|
2389
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
2390
|
+
}
|
|
2391
|
+
get isULID() {
|
|
2392
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
2393
|
+
}
|
|
2394
|
+
get isIP() {
|
|
2395
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
2396
|
+
}
|
|
2397
|
+
get isCIDR() {
|
|
2398
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
2399
|
+
}
|
|
2400
|
+
get isBase64() {
|
|
2401
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
2402
|
+
}
|
|
2403
|
+
get isBase64url() {
|
|
2404
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
2405
|
+
}
|
|
2406
|
+
get minLength() {
|
|
2407
|
+
let e = null;
|
|
2408
|
+
for (const n of this._def.checks)
|
|
2409
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
2410
|
+
return e;
|
|
2411
|
+
}
|
|
2412
|
+
get maxLength() {
|
|
2413
|
+
let e = null;
|
|
2414
|
+
for (const n of this._def.checks)
|
|
2415
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
2416
|
+
return e;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
N.create = (t) => new N({
|
|
2420
|
+
checks: [],
|
|
2421
|
+
typeName: h.ZodString,
|
|
2422
|
+
coerce: t?.coerce ?? !1,
|
|
2423
|
+
..._(t)
|
|
2424
|
+
});
|
|
2425
|
+
function kn(t, e) {
|
|
2426
|
+
const n = (t.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, i = n > s ? n : s, r = Number.parseInt(t.toFixed(i).replace(".", "")), a = Number.parseInt(e.toFixed(i).replace(".", ""));
|
|
2427
|
+
return r % a / 10 ** i;
|
|
2428
|
+
}
|
|
2429
|
+
class B extends y {
|
|
2430
|
+
constructor() {
|
|
2431
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
2432
|
+
}
|
|
2433
|
+
_parse(e) {
|
|
2434
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
|
|
2435
|
+
const r = this._getOrReturnCtx(e);
|
|
2436
|
+
return u(r, {
|
|
2437
|
+
code: d.invalid_type,
|
|
2438
|
+
expected: f.number,
|
|
2439
|
+
received: r.parsedType
|
|
2440
|
+
}), m;
|
|
2441
|
+
}
|
|
2442
|
+
let s;
|
|
2443
|
+
const i = new T();
|
|
2444
|
+
for (const r of this._def.checks)
|
|
2445
|
+
r.kind === "int" ? v.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2446
|
+
code: d.invalid_type,
|
|
2447
|
+
expected: "integer",
|
|
2448
|
+
received: "float",
|
|
2449
|
+
message: r.message
|
|
2450
|
+
}), i.dirty()) : r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2451
|
+
code: d.too_small,
|
|
2452
|
+
minimum: r.value,
|
|
2453
|
+
type: "number",
|
|
2454
|
+
inclusive: r.inclusive,
|
|
2455
|
+
exact: !1,
|
|
2456
|
+
message: r.message
|
|
2457
|
+
}), i.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2458
|
+
code: d.too_big,
|
|
2459
|
+
maximum: r.value,
|
|
2460
|
+
type: "number",
|
|
2461
|
+
inclusive: r.inclusive,
|
|
2462
|
+
exact: !1,
|
|
2463
|
+
message: r.message
|
|
2464
|
+
}), i.dirty()) : r.kind === "multipleOf" ? kn(e.data, r.value) !== 0 && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2465
|
+
code: d.not_multiple_of,
|
|
2466
|
+
multipleOf: r.value,
|
|
2467
|
+
message: r.message
|
|
2468
|
+
}), i.dirty()) : r.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2469
|
+
code: d.not_finite,
|
|
2470
|
+
message: r.message
|
|
2471
|
+
}), i.dirty()) : v.assertNever(r);
|
|
2472
|
+
return { status: i.value, value: e.data };
|
|
2473
|
+
}
|
|
2474
|
+
gte(e, n) {
|
|
2475
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
2476
|
+
}
|
|
2477
|
+
gt(e, n) {
|
|
2478
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
2479
|
+
}
|
|
2480
|
+
lte(e, n) {
|
|
2481
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
2482
|
+
}
|
|
2483
|
+
lt(e, n) {
|
|
2484
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
2485
|
+
}
|
|
2486
|
+
setLimit(e, n, s, i) {
|
|
2487
|
+
return new B({
|
|
2488
|
+
...this._def,
|
|
2489
|
+
checks: [
|
|
2490
|
+
...this._def.checks,
|
|
2491
|
+
{
|
|
2492
|
+
kind: e,
|
|
2493
|
+
value: n,
|
|
2494
|
+
inclusive: s,
|
|
2495
|
+
message: p.toString(i)
|
|
2496
|
+
}
|
|
2497
|
+
]
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
_addCheck(e) {
|
|
2501
|
+
return new B({
|
|
2502
|
+
...this._def,
|
|
2503
|
+
checks: [...this._def.checks, e]
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
int(e) {
|
|
2507
|
+
return this._addCheck({
|
|
2508
|
+
kind: "int",
|
|
2509
|
+
message: p.toString(e)
|
|
2510
|
+
});
|
|
2511
|
+
}
|
|
2512
|
+
positive(e) {
|
|
2513
|
+
return this._addCheck({
|
|
2514
|
+
kind: "min",
|
|
2515
|
+
value: 0,
|
|
2516
|
+
inclusive: !1,
|
|
2517
|
+
message: p.toString(e)
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
negative(e) {
|
|
2521
|
+
return this._addCheck({
|
|
2522
|
+
kind: "max",
|
|
2523
|
+
value: 0,
|
|
2524
|
+
inclusive: !1,
|
|
2525
|
+
message: p.toString(e)
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
nonpositive(e) {
|
|
2529
|
+
return this._addCheck({
|
|
2530
|
+
kind: "max",
|
|
2531
|
+
value: 0,
|
|
2532
|
+
inclusive: !0,
|
|
2533
|
+
message: p.toString(e)
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
nonnegative(e) {
|
|
2537
|
+
return this._addCheck({
|
|
2538
|
+
kind: "min",
|
|
2539
|
+
value: 0,
|
|
2540
|
+
inclusive: !0,
|
|
2541
|
+
message: p.toString(e)
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
multipleOf(e, n) {
|
|
2545
|
+
return this._addCheck({
|
|
2546
|
+
kind: "multipleOf",
|
|
2547
|
+
value: e,
|
|
2548
|
+
message: p.toString(n)
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
finite(e) {
|
|
2552
|
+
return this._addCheck({
|
|
2553
|
+
kind: "finite",
|
|
2554
|
+
message: p.toString(e)
|
|
2555
|
+
});
|
|
2556
|
+
}
|
|
2557
|
+
safe(e) {
|
|
2558
|
+
return this._addCheck({
|
|
2559
|
+
kind: "min",
|
|
2560
|
+
inclusive: !0,
|
|
2561
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
2562
|
+
message: p.toString(e)
|
|
2563
|
+
})._addCheck({
|
|
2564
|
+
kind: "max",
|
|
2565
|
+
inclusive: !0,
|
|
2566
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
2567
|
+
message: p.toString(e)
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
get minValue() {
|
|
2571
|
+
let e = null;
|
|
2572
|
+
for (const n of this._def.checks)
|
|
2573
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
2574
|
+
return e;
|
|
2575
|
+
}
|
|
2576
|
+
get maxValue() {
|
|
2577
|
+
let e = null;
|
|
2578
|
+
for (const n of this._def.checks)
|
|
2579
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
2580
|
+
return e;
|
|
2581
|
+
}
|
|
2582
|
+
get isInt() {
|
|
2583
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && v.isInteger(e.value));
|
|
2584
|
+
}
|
|
2585
|
+
get isFinite() {
|
|
2586
|
+
let e = null, n = null;
|
|
2587
|
+
for (const s of this._def.checks) {
|
|
2588
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
2589
|
+
return !0;
|
|
2590
|
+
s.kind === "min" ? (n === null || s.value > n) && (n = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
2591
|
+
}
|
|
2592
|
+
return Number.isFinite(n) && Number.isFinite(e);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
B.create = (t) => new B({
|
|
2596
|
+
checks: [],
|
|
2597
|
+
typeName: h.ZodNumber,
|
|
2598
|
+
coerce: t?.coerce || !1,
|
|
2599
|
+
..._(t)
|
|
2600
|
+
});
|
|
2601
|
+
class Y extends y {
|
|
2602
|
+
constructor() {
|
|
2603
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
2604
|
+
}
|
|
2605
|
+
_parse(e) {
|
|
2606
|
+
if (this._def.coerce)
|
|
2607
|
+
try {
|
|
2608
|
+
e.data = BigInt(e.data);
|
|
2609
|
+
} catch {
|
|
2610
|
+
return this._getInvalidInput(e);
|
|
2611
|
+
}
|
|
2612
|
+
if (this._getType(e) !== f.bigint)
|
|
2613
|
+
return this._getInvalidInput(e);
|
|
2614
|
+
let s;
|
|
2615
|
+
const i = new T();
|
|
2616
|
+
for (const r of this._def.checks)
|
|
2617
|
+
r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2618
|
+
code: d.too_small,
|
|
2619
|
+
type: "bigint",
|
|
2620
|
+
minimum: r.value,
|
|
2621
|
+
inclusive: r.inclusive,
|
|
2622
|
+
message: r.message
|
|
2623
|
+
}), i.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2624
|
+
code: d.too_big,
|
|
2625
|
+
type: "bigint",
|
|
2626
|
+
maximum: r.value,
|
|
2627
|
+
inclusive: r.inclusive,
|
|
2628
|
+
message: r.message
|
|
2629
|
+
}), i.dirty()) : r.kind === "multipleOf" ? e.data % r.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2630
|
+
code: d.not_multiple_of,
|
|
2631
|
+
multipleOf: r.value,
|
|
2632
|
+
message: r.message
|
|
2633
|
+
}), i.dirty()) : v.assertNever(r);
|
|
2634
|
+
return { status: i.value, value: e.data };
|
|
2635
|
+
}
|
|
2636
|
+
_getInvalidInput(e) {
|
|
2637
|
+
const n = this._getOrReturnCtx(e);
|
|
2638
|
+
return u(n, {
|
|
2639
|
+
code: d.invalid_type,
|
|
2640
|
+
expected: f.bigint,
|
|
2641
|
+
received: n.parsedType
|
|
2642
|
+
}), m;
|
|
2643
|
+
}
|
|
2644
|
+
gte(e, n) {
|
|
2645
|
+
return this.setLimit("min", e, !0, p.toString(n));
|
|
2646
|
+
}
|
|
2647
|
+
gt(e, n) {
|
|
2648
|
+
return this.setLimit("min", e, !1, p.toString(n));
|
|
2649
|
+
}
|
|
2650
|
+
lte(e, n) {
|
|
2651
|
+
return this.setLimit("max", e, !0, p.toString(n));
|
|
2652
|
+
}
|
|
2653
|
+
lt(e, n) {
|
|
2654
|
+
return this.setLimit("max", e, !1, p.toString(n));
|
|
2655
|
+
}
|
|
2656
|
+
setLimit(e, n, s, i) {
|
|
2657
|
+
return new Y({
|
|
2658
|
+
...this._def,
|
|
2659
|
+
checks: [
|
|
2660
|
+
...this._def.checks,
|
|
2661
|
+
{
|
|
2662
|
+
kind: e,
|
|
2663
|
+
value: n,
|
|
2664
|
+
inclusive: s,
|
|
2665
|
+
message: p.toString(i)
|
|
2666
|
+
}
|
|
2667
|
+
]
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
_addCheck(e) {
|
|
2671
|
+
return new Y({
|
|
2672
|
+
...this._def,
|
|
2673
|
+
checks: [...this._def.checks, e]
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
positive(e) {
|
|
2677
|
+
return this._addCheck({
|
|
2678
|
+
kind: "min",
|
|
2679
|
+
value: BigInt(0),
|
|
2680
|
+
inclusive: !1,
|
|
2681
|
+
message: p.toString(e)
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
negative(e) {
|
|
2685
|
+
return this._addCheck({
|
|
2686
|
+
kind: "max",
|
|
2687
|
+
value: BigInt(0),
|
|
2688
|
+
inclusive: !1,
|
|
2689
|
+
message: p.toString(e)
|
|
2690
|
+
});
|
|
2691
|
+
}
|
|
2692
|
+
nonpositive(e) {
|
|
2693
|
+
return this._addCheck({
|
|
2694
|
+
kind: "max",
|
|
2695
|
+
value: BigInt(0),
|
|
2696
|
+
inclusive: !0,
|
|
2697
|
+
message: p.toString(e)
|
|
2698
|
+
});
|
|
2699
|
+
}
|
|
2700
|
+
nonnegative(e) {
|
|
2701
|
+
return this._addCheck({
|
|
2702
|
+
kind: "min",
|
|
2703
|
+
value: BigInt(0),
|
|
2704
|
+
inclusive: !0,
|
|
2705
|
+
message: p.toString(e)
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
multipleOf(e, n) {
|
|
2709
|
+
return this._addCheck({
|
|
2710
|
+
kind: "multipleOf",
|
|
2711
|
+
value: e,
|
|
2712
|
+
message: p.toString(n)
|
|
2713
|
+
});
|
|
2714
|
+
}
|
|
2715
|
+
get minValue() {
|
|
2716
|
+
let e = null;
|
|
2717
|
+
for (const n of this._def.checks)
|
|
2718
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
2719
|
+
return e;
|
|
2720
|
+
}
|
|
2721
|
+
get maxValue() {
|
|
2722
|
+
let e = null;
|
|
2723
|
+
for (const n of this._def.checks)
|
|
2724
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
2725
|
+
return e;
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
Y.create = (t) => new Y({
|
|
2729
|
+
checks: [],
|
|
2730
|
+
typeName: h.ZodBigInt,
|
|
2731
|
+
coerce: t?.coerce ?? !1,
|
|
2732
|
+
..._(t)
|
|
2733
|
+
});
|
|
2734
|
+
class ue extends y {
|
|
2735
|
+
_parse(e) {
|
|
2736
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
2737
|
+
const s = this._getOrReturnCtx(e);
|
|
2738
|
+
return u(s, {
|
|
2739
|
+
code: d.invalid_type,
|
|
2740
|
+
expected: f.boolean,
|
|
2741
|
+
received: s.parsedType
|
|
2742
|
+
}), m;
|
|
2743
|
+
}
|
|
2744
|
+
return S(e.data);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
ue.create = (t) => new ue({
|
|
2748
|
+
typeName: h.ZodBoolean,
|
|
2749
|
+
coerce: t?.coerce || !1,
|
|
2750
|
+
..._(t)
|
|
2751
|
+
});
|
|
2752
|
+
class ee extends y {
|
|
2753
|
+
_parse(e) {
|
|
2754
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
2755
|
+
const r = this._getOrReturnCtx(e);
|
|
2756
|
+
return u(r, {
|
|
2757
|
+
code: d.invalid_type,
|
|
2758
|
+
expected: f.date,
|
|
2759
|
+
received: r.parsedType
|
|
2760
|
+
}), m;
|
|
2761
|
+
}
|
|
2762
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
2763
|
+
const r = this._getOrReturnCtx(e);
|
|
2764
|
+
return u(r, {
|
|
2765
|
+
code: d.invalid_date
|
|
2766
|
+
}), m;
|
|
2767
|
+
}
|
|
2768
|
+
const s = new T();
|
|
2769
|
+
let i;
|
|
2770
|
+
for (const r of this._def.checks)
|
|
2771
|
+
r.kind === "min" ? e.data.getTime() < r.value && (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2772
|
+
code: d.too_small,
|
|
2773
|
+
message: r.message,
|
|
2774
|
+
inclusive: !0,
|
|
2775
|
+
exact: !1,
|
|
2776
|
+
minimum: r.value,
|
|
2777
|
+
type: "date"
|
|
2778
|
+
}), s.dirty()) : r.kind === "max" ? e.data.getTime() > r.value && (i = this._getOrReturnCtx(e, i), u(i, {
|
|
2779
|
+
code: d.too_big,
|
|
2780
|
+
message: r.message,
|
|
2781
|
+
inclusive: !0,
|
|
2782
|
+
exact: !1,
|
|
2783
|
+
maximum: r.value,
|
|
2784
|
+
type: "date"
|
|
2785
|
+
}), s.dirty()) : v.assertNever(r);
|
|
2786
|
+
return {
|
|
2787
|
+
status: s.value,
|
|
2788
|
+
value: new Date(e.data.getTime())
|
|
2789
|
+
};
|
|
2790
|
+
}
|
|
2791
|
+
_addCheck(e) {
|
|
2792
|
+
return new ee({
|
|
2793
|
+
...this._def,
|
|
2794
|
+
checks: [...this._def.checks, e]
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
min(e, n) {
|
|
2798
|
+
return this._addCheck({
|
|
2799
|
+
kind: "min",
|
|
2800
|
+
value: e.getTime(),
|
|
2801
|
+
message: p.toString(n)
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
max(e, n) {
|
|
2805
|
+
return this._addCheck({
|
|
2806
|
+
kind: "max",
|
|
2807
|
+
value: e.getTime(),
|
|
2808
|
+
message: p.toString(n)
|
|
2809
|
+
});
|
|
2810
|
+
}
|
|
2811
|
+
get minDate() {
|
|
2812
|
+
let e = null;
|
|
2813
|
+
for (const n of this._def.checks)
|
|
2814
|
+
n.kind === "min" && (e === null || n.value > e) && (e = n.value);
|
|
2815
|
+
return e != null ? new Date(e) : null;
|
|
2816
|
+
}
|
|
2817
|
+
get maxDate() {
|
|
2818
|
+
let e = null;
|
|
2819
|
+
for (const n of this._def.checks)
|
|
2820
|
+
n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
2821
|
+
return e != null ? new Date(e) : null;
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
ee.create = (t) => new ee({
|
|
2825
|
+
checks: [],
|
|
2826
|
+
coerce: t?.coerce || !1,
|
|
2827
|
+
typeName: h.ZodDate,
|
|
2828
|
+
..._(t)
|
|
2829
|
+
});
|
|
2830
|
+
class Ee extends y {
|
|
2831
|
+
_parse(e) {
|
|
2832
|
+
if (this._getType(e) !== f.symbol) {
|
|
2833
|
+
const s = this._getOrReturnCtx(e);
|
|
2834
|
+
return u(s, {
|
|
2835
|
+
code: d.invalid_type,
|
|
2836
|
+
expected: f.symbol,
|
|
2837
|
+
received: s.parsedType
|
|
2838
|
+
}), m;
|
|
2839
|
+
}
|
|
2840
|
+
return S(e.data);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
Ee.create = (t) => new Ee({
|
|
2844
|
+
typeName: h.ZodSymbol,
|
|
2845
|
+
..._(t)
|
|
2846
|
+
});
|
|
2847
|
+
class Ie extends y {
|
|
2848
|
+
_parse(e) {
|
|
2849
|
+
if (this._getType(e) !== f.undefined) {
|
|
2850
|
+
const s = this._getOrReturnCtx(e);
|
|
2851
|
+
return u(s, {
|
|
2852
|
+
code: d.invalid_type,
|
|
2853
|
+
expected: f.undefined,
|
|
2854
|
+
received: s.parsedType
|
|
2855
|
+
}), m;
|
|
2856
|
+
}
|
|
2857
|
+
return S(e.data);
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
Ie.create = (t) => new Ie({
|
|
2861
|
+
typeName: h.ZodUndefined,
|
|
2862
|
+
..._(t)
|
|
2863
|
+
});
|
|
2864
|
+
class Ne extends y {
|
|
2865
|
+
_parse(e) {
|
|
2866
|
+
if (this._getType(e) !== f.null) {
|
|
2867
|
+
const s = this._getOrReturnCtx(e);
|
|
2868
|
+
return u(s, {
|
|
2869
|
+
code: d.invalid_type,
|
|
2870
|
+
expected: f.null,
|
|
2871
|
+
received: s.parsedType
|
|
2872
|
+
}), m;
|
|
2873
|
+
}
|
|
2874
|
+
return S(e.data);
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
Ne.create = (t) => new Ne({
|
|
2878
|
+
typeName: h.ZodNull,
|
|
2879
|
+
..._(t)
|
|
2880
|
+
});
|
|
2881
|
+
class Oe extends y {
|
|
2882
|
+
constructor() {
|
|
2883
|
+
super(...arguments), this._any = !0;
|
|
2884
|
+
}
|
|
2885
|
+
_parse(e) {
|
|
2886
|
+
return S(e.data);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
Oe.create = (t) => new Oe({
|
|
2890
|
+
typeName: h.ZodAny,
|
|
2891
|
+
..._(t)
|
|
2892
|
+
});
|
|
2893
|
+
class le extends y {
|
|
2894
|
+
constructor() {
|
|
2895
|
+
super(...arguments), this._unknown = !0;
|
|
2896
|
+
}
|
|
2897
|
+
_parse(e) {
|
|
2898
|
+
return S(e.data);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
le.create = (t) => new le({
|
|
2902
|
+
typeName: h.ZodUnknown,
|
|
2903
|
+
..._(t)
|
|
2904
|
+
});
|
|
2905
|
+
class L extends y {
|
|
2906
|
+
_parse(e) {
|
|
2907
|
+
const n = this._getOrReturnCtx(e);
|
|
2908
|
+
return u(n, {
|
|
2909
|
+
code: d.invalid_type,
|
|
2910
|
+
expected: f.never,
|
|
2911
|
+
received: n.parsedType
|
|
2912
|
+
}), m;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
L.create = (t) => new L({
|
|
2916
|
+
typeName: h.ZodNever,
|
|
2917
|
+
..._(t)
|
|
2918
|
+
});
|
|
2919
|
+
class Re extends y {
|
|
2920
|
+
_parse(e) {
|
|
2921
|
+
if (this._getType(e) !== f.undefined) {
|
|
2922
|
+
const s = this._getOrReturnCtx(e);
|
|
2923
|
+
return u(s, {
|
|
2924
|
+
code: d.invalid_type,
|
|
2925
|
+
expected: f.void,
|
|
2926
|
+
received: s.parsedType
|
|
2927
|
+
}), m;
|
|
2928
|
+
}
|
|
2929
|
+
return S(e.data);
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
Re.create = (t) => new Re({
|
|
2933
|
+
typeName: h.ZodVoid,
|
|
2934
|
+
..._(t)
|
|
2935
|
+
});
|
|
2936
|
+
class E extends y {
|
|
2937
|
+
_parse(e) {
|
|
2938
|
+
const { ctx: n, status: s } = this._processInputParams(e), i = this._def;
|
|
2939
|
+
if (n.parsedType !== f.array)
|
|
2940
|
+
return u(n, {
|
|
2941
|
+
code: d.invalid_type,
|
|
2942
|
+
expected: f.array,
|
|
2943
|
+
received: n.parsedType
|
|
2944
|
+
}), m;
|
|
2945
|
+
if (i.exactLength !== null) {
|
|
2946
|
+
const a = n.data.length > i.exactLength.value, o = n.data.length < i.exactLength.value;
|
|
2947
|
+
(a || o) && (u(n, {
|
|
2948
|
+
code: a ? d.too_big : d.too_small,
|
|
2949
|
+
minimum: o ? i.exactLength.value : void 0,
|
|
2950
|
+
maximum: a ? i.exactLength.value : void 0,
|
|
2951
|
+
type: "array",
|
|
2952
|
+
inclusive: !0,
|
|
2953
|
+
exact: !0,
|
|
2954
|
+
message: i.exactLength.message
|
|
2955
|
+
}), s.dirty());
|
|
2956
|
+
}
|
|
2957
|
+
if (i.minLength !== null && n.data.length < i.minLength.value && (u(n, {
|
|
2958
|
+
code: d.too_small,
|
|
2959
|
+
minimum: i.minLength.value,
|
|
2960
|
+
type: "array",
|
|
2961
|
+
inclusive: !0,
|
|
2962
|
+
exact: !1,
|
|
2963
|
+
message: i.minLength.message
|
|
2964
|
+
}), s.dirty()), i.maxLength !== null && n.data.length > i.maxLength.value && (u(n, {
|
|
2965
|
+
code: d.too_big,
|
|
2966
|
+
maximum: i.maxLength.value,
|
|
2967
|
+
type: "array",
|
|
2968
|
+
inclusive: !0,
|
|
2969
|
+
exact: !1,
|
|
2970
|
+
message: i.maxLength.message
|
|
2971
|
+
}), s.dirty()), n.common.async)
|
|
2972
|
+
return Promise.all([...n.data].map((a, o) => i.type._parseAsync(new I(n, a, n.path, o)))).then((a) => T.mergeArray(s, a));
|
|
2973
|
+
const r = [...n.data].map((a, o) => i.type._parseSync(new I(n, a, n.path, o)));
|
|
2974
|
+
return T.mergeArray(s, r);
|
|
2975
|
+
}
|
|
2976
|
+
get element() {
|
|
2977
|
+
return this._def.type;
|
|
2978
|
+
}
|
|
2979
|
+
min(e, n) {
|
|
2980
|
+
return new E({
|
|
2981
|
+
...this._def,
|
|
2982
|
+
minLength: { value: e, message: p.toString(n) }
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
max(e, n) {
|
|
2986
|
+
return new E({
|
|
2987
|
+
...this._def,
|
|
2988
|
+
maxLength: { value: e, message: p.toString(n) }
|
|
2989
|
+
});
|
|
2990
|
+
}
|
|
2991
|
+
length(e, n) {
|
|
2992
|
+
return new E({
|
|
2993
|
+
...this._def,
|
|
2994
|
+
exactLength: { value: e, message: p.toString(n) }
|
|
2995
|
+
});
|
|
2996
|
+
}
|
|
2997
|
+
nonempty(e) {
|
|
2998
|
+
return this.min(1, e);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
E.create = (t, e) => new E({
|
|
3002
|
+
type: t,
|
|
3003
|
+
minLength: null,
|
|
3004
|
+
maxLength: null,
|
|
3005
|
+
exactLength: null,
|
|
3006
|
+
typeName: h.ZodArray,
|
|
3007
|
+
..._(e)
|
|
3008
|
+
});
|
|
3009
|
+
function U(t) {
|
|
3010
|
+
if (t instanceof w) {
|
|
3011
|
+
const e = {};
|
|
3012
|
+
for (const n in t.shape) {
|
|
3013
|
+
const s = t.shape[n];
|
|
3014
|
+
e[n] = j.create(U(s));
|
|
3015
|
+
}
|
|
3016
|
+
return new w({
|
|
3017
|
+
...t._def,
|
|
3018
|
+
shape: () => e
|
|
3019
|
+
});
|
|
3020
|
+
} else return t instanceof E ? new E({
|
|
3021
|
+
...t._def,
|
|
3022
|
+
type: U(t.element)
|
|
3023
|
+
}) : t instanceof j ? j.create(U(t.unwrap())) : t instanceof H ? H.create(U(t.unwrap())) : t instanceof z ? z.create(t.items.map((e) => U(e))) : t;
|
|
3024
|
+
}
|
|
3025
|
+
class w extends y {
|
|
3026
|
+
constructor() {
|
|
3027
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
3028
|
+
}
|
|
3029
|
+
_getCached() {
|
|
3030
|
+
if (this._cached !== null)
|
|
3031
|
+
return this._cached;
|
|
3032
|
+
const e = this._def.shape(), n = v.objectKeys(e);
|
|
3033
|
+
return this._cached = { shape: e, keys: n }, this._cached;
|
|
3034
|
+
}
|
|
3035
|
+
_parse(e) {
|
|
3036
|
+
if (this._getType(e) !== f.object) {
|
|
3037
|
+
const l = this._getOrReturnCtx(e);
|
|
3038
|
+
return u(l, {
|
|
3039
|
+
code: d.invalid_type,
|
|
3040
|
+
expected: f.object,
|
|
3041
|
+
received: l.parsedType
|
|
3042
|
+
}), m;
|
|
3043
|
+
}
|
|
3044
|
+
const { status: s, ctx: i } = this._processInputParams(e), { shape: r, keys: a } = this._getCached(), o = [];
|
|
3045
|
+
if (!(this._def.catchall instanceof L && this._def.unknownKeys === "strip"))
|
|
3046
|
+
for (const l in i.data)
|
|
3047
|
+
a.includes(l) || o.push(l);
|
|
3048
|
+
const c = [];
|
|
3049
|
+
for (const l of a) {
|
|
3050
|
+
const g = r[l], x = i.data[l];
|
|
3051
|
+
c.push({
|
|
3052
|
+
key: { status: "valid", value: l },
|
|
3053
|
+
value: g._parse(new I(i, x, i.path, l)),
|
|
3054
|
+
alwaysSet: l in i.data
|
|
3055
|
+
});
|
|
3056
|
+
}
|
|
3057
|
+
if (this._def.catchall instanceof L) {
|
|
3058
|
+
const l = this._def.unknownKeys;
|
|
3059
|
+
if (l === "passthrough")
|
|
3060
|
+
for (const g of o)
|
|
3061
|
+
c.push({
|
|
3062
|
+
key: { status: "valid", value: g },
|
|
3063
|
+
value: { status: "valid", value: i.data[g] }
|
|
3064
|
+
});
|
|
3065
|
+
else if (l === "strict")
|
|
3066
|
+
o.length > 0 && (u(i, {
|
|
3067
|
+
code: d.unrecognized_keys,
|
|
3068
|
+
keys: o
|
|
3069
|
+
}), s.dirty());
|
|
3070
|
+
else if (l !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
3071
|
+
} else {
|
|
3072
|
+
const l = this._def.catchall;
|
|
3073
|
+
for (const g of o) {
|
|
3074
|
+
const x = i.data[g];
|
|
3075
|
+
c.push({
|
|
3076
|
+
key: { status: "valid", value: g },
|
|
3077
|
+
value: l._parse(
|
|
3078
|
+
new I(i, x, i.path, g)
|
|
3079
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
3080
|
+
),
|
|
3081
|
+
alwaysSet: g in i.data
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
return i.common.async ? Promise.resolve().then(async () => {
|
|
3086
|
+
const l = [];
|
|
3087
|
+
for (const g of c) {
|
|
3088
|
+
const x = await g.key, A = await g.value;
|
|
3089
|
+
l.push({
|
|
3090
|
+
key: x,
|
|
3091
|
+
value: A,
|
|
3092
|
+
alwaysSet: g.alwaysSet
|
|
3093
|
+
});
|
|
3094
|
+
}
|
|
3095
|
+
return l;
|
|
3096
|
+
}).then((l) => T.mergeObjectSync(s, l)) : T.mergeObjectSync(s, c);
|
|
3097
|
+
}
|
|
3098
|
+
get shape() {
|
|
3099
|
+
return this._def.shape();
|
|
3100
|
+
}
|
|
3101
|
+
strict(e) {
|
|
3102
|
+
return p.errToObj, new w({
|
|
3103
|
+
...this._def,
|
|
3104
|
+
unknownKeys: "strict",
|
|
3105
|
+
...e !== void 0 ? {
|
|
3106
|
+
errorMap: (n, s) => {
|
|
3107
|
+
const i = this._def.errorMap?.(n, s).message ?? s.defaultError;
|
|
3108
|
+
return n.code === "unrecognized_keys" ? {
|
|
3109
|
+
message: p.errToObj(e).message ?? i
|
|
3110
|
+
} : {
|
|
3111
|
+
message: i
|
|
3112
|
+
};
|
|
3113
|
+
}
|
|
3114
|
+
} : {}
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
strip() {
|
|
3118
|
+
return new w({
|
|
3119
|
+
...this._def,
|
|
3120
|
+
unknownKeys: "strip"
|
|
3121
|
+
});
|
|
3122
|
+
}
|
|
3123
|
+
passthrough() {
|
|
3124
|
+
return new w({
|
|
3125
|
+
...this._def,
|
|
3126
|
+
unknownKeys: "passthrough"
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
// const AugmentFactory =
|
|
3130
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
3131
|
+
// <Augmentation extends ZodRawShape>(
|
|
3132
|
+
// augmentation: Augmentation
|
|
3133
|
+
// ): ZodObject<
|
|
3134
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
3135
|
+
// Def["unknownKeys"],
|
|
3136
|
+
// Def["catchall"]
|
|
3137
|
+
// > => {
|
|
3138
|
+
// return new ZodObject({
|
|
3139
|
+
// ...def,
|
|
3140
|
+
// shape: () => ({
|
|
3141
|
+
// ...def.shape(),
|
|
3142
|
+
// ...augmentation,
|
|
3143
|
+
// }),
|
|
3144
|
+
// }) as any;
|
|
3145
|
+
// };
|
|
3146
|
+
extend(e) {
|
|
3147
|
+
return new w({
|
|
3148
|
+
...this._def,
|
|
3149
|
+
shape: () => ({
|
|
3150
|
+
...this._def.shape(),
|
|
3151
|
+
...e
|
|
3152
|
+
})
|
|
3153
|
+
});
|
|
3154
|
+
}
|
|
3155
|
+
/**
|
|
3156
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
3157
|
+
* inferred type of merged objects. Please
|
|
3158
|
+
* upgrade if you are experiencing issues.
|
|
3159
|
+
*/
|
|
3160
|
+
merge(e) {
|
|
3161
|
+
return new w({
|
|
3162
|
+
unknownKeys: e._def.unknownKeys,
|
|
3163
|
+
catchall: e._def.catchall,
|
|
3164
|
+
shape: () => ({
|
|
3165
|
+
...this._def.shape(),
|
|
3166
|
+
...e._def.shape()
|
|
3167
|
+
}),
|
|
3168
|
+
typeName: h.ZodObject
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
// merge<
|
|
3172
|
+
// Incoming extends AnyZodObject,
|
|
3173
|
+
// Augmentation extends Incoming["shape"],
|
|
3174
|
+
// NewOutput extends {
|
|
3175
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
3176
|
+
// ? Augmentation[k]["_output"]
|
|
3177
|
+
// : k extends keyof Output
|
|
3178
|
+
// ? Output[k]
|
|
3179
|
+
// : never;
|
|
3180
|
+
// },
|
|
3181
|
+
// NewInput extends {
|
|
3182
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
3183
|
+
// ? Augmentation[k]["_input"]
|
|
3184
|
+
// : k extends keyof Input
|
|
3185
|
+
// ? Input[k]
|
|
3186
|
+
// : never;
|
|
3187
|
+
// }
|
|
3188
|
+
// >(
|
|
3189
|
+
// merging: Incoming
|
|
3190
|
+
// ): ZodObject<
|
|
3191
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3192
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3193
|
+
// Incoming["_def"]["catchall"],
|
|
3194
|
+
// NewOutput,
|
|
3195
|
+
// NewInput
|
|
3196
|
+
// > {
|
|
3197
|
+
// const merged: any = new ZodObject({
|
|
3198
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3199
|
+
// catchall: merging._def.catchall,
|
|
3200
|
+
// shape: () =>
|
|
3201
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3202
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3203
|
+
// }) as any;
|
|
3204
|
+
// return merged;
|
|
3205
|
+
// }
|
|
3206
|
+
setKey(e, n) {
|
|
3207
|
+
return this.augment({ [e]: n });
|
|
3208
|
+
}
|
|
3209
|
+
// merge<Incoming extends AnyZodObject>(
|
|
3210
|
+
// merging: Incoming
|
|
3211
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
3212
|
+
// ZodObject<
|
|
3213
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3214
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3215
|
+
// Incoming["_def"]["catchall"]
|
|
3216
|
+
// > {
|
|
3217
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
3218
|
+
// // this._def.shape(),
|
|
3219
|
+
// // merging._def.shape()
|
|
3220
|
+
// // );
|
|
3221
|
+
// const merged: any = new ZodObject({
|
|
3222
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3223
|
+
// catchall: merging._def.catchall,
|
|
3224
|
+
// shape: () =>
|
|
3225
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3226
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3227
|
+
// }) as any;
|
|
3228
|
+
// return merged;
|
|
3229
|
+
// }
|
|
3230
|
+
catchall(e) {
|
|
3231
|
+
return new w({
|
|
3232
|
+
...this._def,
|
|
3233
|
+
catchall: e
|
|
3234
|
+
});
|
|
3235
|
+
}
|
|
3236
|
+
pick(e) {
|
|
3237
|
+
const n = {};
|
|
3238
|
+
for (const s of v.objectKeys(e))
|
|
3239
|
+
e[s] && this.shape[s] && (n[s] = this.shape[s]);
|
|
3240
|
+
return new w({
|
|
3241
|
+
...this._def,
|
|
3242
|
+
shape: () => n
|
|
3243
|
+
});
|
|
3244
|
+
}
|
|
3245
|
+
omit(e) {
|
|
3246
|
+
const n = {};
|
|
3247
|
+
for (const s of v.objectKeys(this.shape))
|
|
3248
|
+
e[s] || (n[s] = this.shape[s]);
|
|
3249
|
+
return new w({
|
|
3250
|
+
...this._def,
|
|
3251
|
+
shape: () => n
|
|
3252
|
+
});
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* @deprecated
|
|
3256
|
+
*/
|
|
3257
|
+
deepPartial() {
|
|
3258
|
+
return U(this);
|
|
3259
|
+
}
|
|
3260
|
+
partial(e) {
|
|
3261
|
+
const n = {};
|
|
3262
|
+
for (const s of v.objectKeys(this.shape)) {
|
|
3263
|
+
const i = this.shape[s];
|
|
3264
|
+
e && !e[s] ? n[s] = i : n[s] = i.optional();
|
|
3265
|
+
}
|
|
3266
|
+
return new w({
|
|
3267
|
+
...this._def,
|
|
3268
|
+
shape: () => n
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
required(e) {
|
|
3272
|
+
const n = {};
|
|
3273
|
+
for (const s of v.objectKeys(this.shape))
|
|
3274
|
+
if (e && !e[s])
|
|
3275
|
+
n[s] = this.shape[s];
|
|
3276
|
+
else {
|
|
3277
|
+
let r = this.shape[s];
|
|
3278
|
+
for (; r instanceof j; )
|
|
3279
|
+
r = r._def.innerType;
|
|
3280
|
+
n[s] = r;
|
|
3281
|
+
}
|
|
3282
|
+
return new w({
|
|
3283
|
+
...this._def,
|
|
3284
|
+
shape: () => n
|
|
3285
|
+
});
|
|
3286
|
+
}
|
|
3287
|
+
keyof() {
|
|
3288
|
+
return Be(v.objectKeys(this.shape));
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
w.create = (t, e) => new w({
|
|
3292
|
+
shape: () => t,
|
|
3293
|
+
unknownKeys: "strip",
|
|
3294
|
+
catchall: L.create(),
|
|
3295
|
+
typeName: h.ZodObject,
|
|
3296
|
+
..._(e)
|
|
3297
|
+
});
|
|
3298
|
+
w.strictCreate = (t, e) => new w({
|
|
3299
|
+
shape: () => t,
|
|
3300
|
+
unknownKeys: "strict",
|
|
3301
|
+
catchall: L.create(),
|
|
3302
|
+
typeName: h.ZodObject,
|
|
3303
|
+
..._(e)
|
|
3304
|
+
});
|
|
3305
|
+
w.lazycreate = (t, e) => new w({
|
|
3306
|
+
shape: t,
|
|
3307
|
+
unknownKeys: "strip",
|
|
3308
|
+
catchall: L.create(),
|
|
3309
|
+
typeName: h.ZodObject,
|
|
3310
|
+
..._(e)
|
|
3311
|
+
});
|
|
3312
|
+
class te extends y {
|
|
3313
|
+
_parse(e) {
|
|
3314
|
+
const { ctx: n } = this._processInputParams(e), s = this._def.options;
|
|
3315
|
+
function i(r) {
|
|
3316
|
+
for (const o of r)
|
|
3317
|
+
if (o.result.status === "valid")
|
|
3318
|
+
return o.result;
|
|
3319
|
+
for (const o of r)
|
|
3320
|
+
if (o.result.status === "dirty")
|
|
3321
|
+
return n.common.issues.push(...o.ctx.common.issues), o.result;
|
|
3322
|
+
const a = r.map((o) => new O(o.ctx.common.issues));
|
|
3323
|
+
return u(n, {
|
|
3324
|
+
code: d.invalid_union,
|
|
3325
|
+
unionErrors: a
|
|
3326
|
+
}), m;
|
|
3327
|
+
}
|
|
3328
|
+
if (n.common.async)
|
|
3329
|
+
return Promise.all(s.map(async (r) => {
|
|
3330
|
+
const a = {
|
|
3331
|
+
...n,
|
|
3332
|
+
common: {
|
|
3333
|
+
...n.common,
|
|
3334
|
+
issues: []
|
|
3335
|
+
},
|
|
3336
|
+
parent: null
|
|
3337
|
+
};
|
|
3338
|
+
return {
|
|
3339
|
+
result: await r._parseAsync({
|
|
3340
|
+
data: n.data,
|
|
3341
|
+
path: n.path,
|
|
3342
|
+
parent: a
|
|
3343
|
+
}),
|
|
3344
|
+
ctx: a
|
|
3345
|
+
};
|
|
3346
|
+
})).then(i);
|
|
3347
|
+
{
|
|
3348
|
+
let r;
|
|
3349
|
+
const a = [];
|
|
3350
|
+
for (const c of s) {
|
|
3351
|
+
const l = {
|
|
3352
|
+
...n,
|
|
3353
|
+
common: {
|
|
3354
|
+
...n.common,
|
|
3355
|
+
issues: []
|
|
3356
|
+
},
|
|
3357
|
+
parent: null
|
|
3358
|
+
}, g = c._parseSync({
|
|
3359
|
+
data: n.data,
|
|
3360
|
+
path: n.path,
|
|
3361
|
+
parent: l
|
|
3362
|
+
});
|
|
3363
|
+
if (g.status === "valid")
|
|
3364
|
+
return g;
|
|
3365
|
+
g.status === "dirty" && !r && (r = { result: g, ctx: l }), l.common.issues.length && a.push(l.common.issues);
|
|
3366
|
+
}
|
|
3367
|
+
if (r)
|
|
3368
|
+
return n.common.issues.push(...r.ctx.common.issues), r.result;
|
|
3369
|
+
const o = a.map((c) => new O(c));
|
|
3370
|
+
return u(n, {
|
|
3371
|
+
code: d.invalid_union,
|
|
3372
|
+
unionErrors: o
|
|
3373
|
+
}), m;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
get options() {
|
|
3377
|
+
return this._def.options;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
te.create = (t, e) => new te({
|
|
3381
|
+
options: t,
|
|
3382
|
+
typeName: h.ZodUnion,
|
|
3383
|
+
..._(e)
|
|
3384
|
+
});
|
|
3385
|
+
function fe(t, e) {
|
|
3386
|
+
const n = Z(t), s = Z(e);
|
|
3387
|
+
if (t === e)
|
|
3388
|
+
return { valid: !0, data: t };
|
|
3389
|
+
if (n === f.object && s === f.object) {
|
|
3390
|
+
const i = v.objectKeys(e), r = v.objectKeys(t).filter((o) => i.indexOf(o) !== -1), a = { ...t, ...e };
|
|
3391
|
+
for (const o of r) {
|
|
3392
|
+
const c = fe(t[o], e[o]);
|
|
3393
|
+
if (!c.valid)
|
|
3394
|
+
return { valid: !1 };
|
|
3395
|
+
a[o] = c.data;
|
|
3396
|
+
}
|
|
3397
|
+
return { valid: !0, data: a };
|
|
3398
|
+
} else if (n === f.array && s === f.array) {
|
|
3399
|
+
if (t.length !== e.length)
|
|
3400
|
+
return { valid: !1 };
|
|
3401
|
+
const i = [];
|
|
3402
|
+
for (let r = 0; r < t.length; r++) {
|
|
3403
|
+
const a = t[r], o = e[r], c = fe(a, o);
|
|
3404
|
+
if (!c.valid)
|
|
3405
|
+
return { valid: !1 };
|
|
3406
|
+
i.push(c.data);
|
|
3407
|
+
}
|
|
3408
|
+
return { valid: !0, data: i };
|
|
3409
|
+
} else return n === f.date && s === f.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
3410
|
+
}
|
|
3411
|
+
class ne extends y {
|
|
3412
|
+
_parse(e) {
|
|
3413
|
+
const { status: n, ctx: s } = this._processInputParams(e), i = (r, a) => {
|
|
3414
|
+
if (Ce(r) || Ce(a))
|
|
3415
|
+
return m;
|
|
3416
|
+
const o = fe(r.value, a.value);
|
|
3417
|
+
return o.valid ? ((Se(r) || Se(a)) && n.dirty(), { status: n.value, value: o.data }) : (u(s, {
|
|
3418
|
+
code: d.invalid_intersection_types
|
|
3419
|
+
}), m);
|
|
3420
|
+
};
|
|
3421
|
+
return s.common.async ? Promise.all([
|
|
3422
|
+
this._def.left._parseAsync({
|
|
3423
|
+
data: s.data,
|
|
3424
|
+
path: s.path,
|
|
3425
|
+
parent: s
|
|
3426
|
+
}),
|
|
3427
|
+
this._def.right._parseAsync({
|
|
3428
|
+
data: s.data,
|
|
3429
|
+
path: s.path,
|
|
3430
|
+
parent: s
|
|
3431
|
+
})
|
|
3432
|
+
]).then(([r, a]) => i(r, a)) : i(this._def.left._parseSync({
|
|
3433
|
+
data: s.data,
|
|
3434
|
+
path: s.path,
|
|
3435
|
+
parent: s
|
|
3436
|
+
}), this._def.right._parseSync({
|
|
3437
|
+
data: s.data,
|
|
3438
|
+
path: s.path,
|
|
3439
|
+
parent: s
|
|
3440
|
+
}));
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
ne.create = (t, e, n) => new ne({
|
|
3444
|
+
left: t,
|
|
3445
|
+
right: e,
|
|
3446
|
+
typeName: h.ZodIntersection,
|
|
3447
|
+
..._(n)
|
|
3448
|
+
});
|
|
3449
|
+
class z extends y {
|
|
3450
|
+
_parse(e) {
|
|
3451
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
3452
|
+
if (s.parsedType !== f.array)
|
|
3453
|
+
return u(s, {
|
|
3454
|
+
code: d.invalid_type,
|
|
3455
|
+
expected: f.array,
|
|
3456
|
+
received: s.parsedType
|
|
3457
|
+
}), m;
|
|
3458
|
+
if (s.data.length < this._def.items.length)
|
|
3459
|
+
return u(s, {
|
|
3460
|
+
code: d.too_small,
|
|
3461
|
+
minimum: this._def.items.length,
|
|
3462
|
+
inclusive: !0,
|
|
3463
|
+
exact: !1,
|
|
3464
|
+
type: "array"
|
|
3465
|
+
}), m;
|
|
3466
|
+
!this._def.rest && s.data.length > this._def.items.length && (u(s, {
|
|
3467
|
+
code: d.too_big,
|
|
3468
|
+
maximum: this._def.items.length,
|
|
3469
|
+
inclusive: !0,
|
|
3470
|
+
exact: !1,
|
|
3471
|
+
type: "array"
|
|
3472
|
+
}), n.dirty());
|
|
3473
|
+
const r = [...s.data].map((a, o) => {
|
|
3474
|
+
const c = this._def.items[o] || this._def.rest;
|
|
3475
|
+
return c ? c._parse(new I(s, a, s.path, o)) : null;
|
|
3476
|
+
}).filter((a) => !!a);
|
|
3477
|
+
return s.common.async ? Promise.all(r).then((a) => T.mergeArray(n, a)) : T.mergeArray(n, r);
|
|
3478
|
+
}
|
|
3479
|
+
get items() {
|
|
3480
|
+
return this._def.items;
|
|
3481
|
+
}
|
|
3482
|
+
rest(e) {
|
|
3483
|
+
return new z({
|
|
3484
|
+
...this._def,
|
|
3485
|
+
rest: e
|
|
3486
|
+
});
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
z.create = (t, e) => {
|
|
3490
|
+
if (!Array.isArray(t))
|
|
3491
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
3492
|
+
return new z({
|
|
3493
|
+
items: t,
|
|
3494
|
+
typeName: h.ZodTuple,
|
|
3495
|
+
rest: null,
|
|
3496
|
+
..._(e)
|
|
3497
|
+
});
|
|
3498
|
+
};
|
|
3499
|
+
class se extends y {
|
|
3500
|
+
get keySchema() {
|
|
3501
|
+
return this._def.keyType;
|
|
3502
|
+
}
|
|
3503
|
+
get valueSchema() {
|
|
3504
|
+
return this._def.valueType;
|
|
3505
|
+
}
|
|
3506
|
+
_parse(e) {
|
|
3507
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
3508
|
+
if (s.parsedType !== f.object)
|
|
3509
|
+
return u(s, {
|
|
3510
|
+
code: d.invalid_type,
|
|
3511
|
+
expected: f.object,
|
|
3512
|
+
received: s.parsedType
|
|
3513
|
+
}), m;
|
|
3514
|
+
const i = [], r = this._def.keyType, a = this._def.valueType;
|
|
3515
|
+
for (const o in s.data)
|
|
3516
|
+
i.push({
|
|
3517
|
+
key: r._parse(new I(s, o, s.path, o)),
|
|
3518
|
+
value: a._parse(new I(s, s.data[o], s.path, o)),
|
|
3519
|
+
alwaysSet: o in s.data
|
|
3520
|
+
});
|
|
3521
|
+
return s.common.async ? T.mergeObjectAsync(n, i) : T.mergeObjectSync(n, i);
|
|
3522
|
+
}
|
|
3523
|
+
get element() {
|
|
3524
|
+
return this._def.valueType;
|
|
3525
|
+
}
|
|
3526
|
+
static create(e, n, s) {
|
|
3527
|
+
return n instanceof y ? new se({
|
|
3528
|
+
keyType: e,
|
|
3529
|
+
valueType: n,
|
|
3530
|
+
typeName: h.ZodRecord,
|
|
3531
|
+
..._(s)
|
|
3532
|
+
}) : new se({
|
|
3533
|
+
keyType: N.create(),
|
|
3534
|
+
valueType: e,
|
|
3535
|
+
typeName: h.ZodRecord,
|
|
3536
|
+
..._(n)
|
|
3537
|
+
});
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
class Ze extends y {
|
|
3541
|
+
get keySchema() {
|
|
3542
|
+
return this._def.keyType;
|
|
3543
|
+
}
|
|
3544
|
+
get valueSchema() {
|
|
3545
|
+
return this._def.valueType;
|
|
3546
|
+
}
|
|
3547
|
+
_parse(e) {
|
|
3548
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
3549
|
+
if (s.parsedType !== f.map)
|
|
3550
|
+
return u(s, {
|
|
3551
|
+
code: d.invalid_type,
|
|
3552
|
+
expected: f.map,
|
|
3553
|
+
received: s.parsedType
|
|
3554
|
+
}), m;
|
|
3555
|
+
const i = this._def.keyType, r = this._def.valueType, a = [...s.data.entries()].map(([o, c], l) => ({
|
|
3556
|
+
key: i._parse(new I(s, o, s.path, [l, "key"])),
|
|
3557
|
+
value: r._parse(new I(s, c, s.path, [l, "value"]))
|
|
3558
|
+
}));
|
|
3559
|
+
if (s.common.async) {
|
|
3560
|
+
const o = /* @__PURE__ */ new Map();
|
|
3561
|
+
return Promise.resolve().then(async () => {
|
|
3562
|
+
for (const c of a) {
|
|
3563
|
+
const l = await c.key, g = await c.value;
|
|
3564
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
3565
|
+
return m;
|
|
3566
|
+
(l.status === "dirty" || g.status === "dirty") && n.dirty(), o.set(l.value, g.value);
|
|
3567
|
+
}
|
|
3568
|
+
return { status: n.value, value: o };
|
|
3569
|
+
});
|
|
3570
|
+
} else {
|
|
3571
|
+
const o = /* @__PURE__ */ new Map();
|
|
3572
|
+
for (const c of a) {
|
|
3573
|
+
const l = c.key, g = c.value;
|
|
3574
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
3575
|
+
return m;
|
|
3576
|
+
(l.status === "dirty" || g.status === "dirty") && n.dirty(), o.set(l.value, g.value);
|
|
3577
|
+
}
|
|
3578
|
+
return { status: n.value, value: o };
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
}
|
|
3582
|
+
Ze.create = (t, e, n) => new Ze({
|
|
3583
|
+
valueType: e,
|
|
3584
|
+
keyType: t,
|
|
3585
|
+
typeName: h.ZodMap,
|
|
3586
|
+
..._(n)
|
|
3587
|
+
});
|
|
3588
|
+
class K extends y {
|
|
3589
|
+
_parse(e) {
|
|
3590
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
3591
|
+
if (s.parsedType !== f.set)
|
|
3592
|
+
return u(s, {
|
|
3593
|
+
code: d.invalid_type,
|
|
3594
|
+
expected: f.set,
|
|
3595
|
+
received: s.parsedType
|
|
3596
|
+
}), m;
|
|
3597
|
+
const i = this._def;
|
|
3598
|
+
i.minSize !== null && s.data.size < i.minSize.value && (u(s, {
|
|
3599
|
+
code: d.too_small,
|
|
3600
|
+
minimum: i.minSize.value,
|
|
3601
|
+
type: "set",
|
|
3602
|
+
inclusive: !0,
|
|
3603
|
+
exact: !1,
|
|
3604
|
+
message: i.minSize.message
|
|
3605
|
+
}), n.dirty()), i.maxSize !== null && s.data.size > i.maxSize.value && (u(s, {
|
|
3606
|
+
code: d.too_big,
|
|
3607
|
+
maximum: i.maxSize.value,
|
|
3608
|
+
type: "set",
|
|
3609
|
+
inclusive: !0,
|
|
3610
|
+
exact: !1,
|
|
3611
|
+
message: i.maxSize.message
|
|
3612
|
+
}), n.dirty());
|
|
3613
|
+
const r = this._def.valueType;
|
|
3614
|
+
function a(c) {
|
|
3615
|
+
const l = /* @__PURE__ */ new Set();
|
|
3616
|
+
for (const g of c) {
|
|
3617
|
+
if (g.status === "aborted")
|
|
3618
|
+
return m;
|
|
3619
|
+
g.status === "dirty" && n.dirty(), l.add(g.value);
|
|
3620
|
+
}
|
|
3621
|
+
return { status: n.value, value: l };
|
|
3622
|
+
}
|
|
3623
|
+
const o = [...s.data.values()].map((c, l) => r._parse(new I(s, c, s.path, l)));
|
|
3624
|
+
return s.common.async ? Promise.all(o).then((c) => a(c)) : a(o);
|
|
3625
|
+
}
|
|
3626
|
+
min(e, n) {
|
|
3627
|
+
return new K({
|
|
3628
|
+
...this._def,
|
|
3629
|
+
minSize: { value: e, message: p.toString(n) }
|
|
3630
|
+
});
|
|
3631
|
+
}
|
|
3632
|
+
max(e, n) {
|
|
3633
|
+
return new K({
|
|
3634
|
+
...this._def,
|
|
3635
|
+
maxSize: { value: e, message: p.toString(n) }
|
|
3636
|
+
});
|
|
3637
|
+
}
|
|
3638
|
+
size(e, n) {
|
|
3639
|
+
return this.min(e, n).max(e, n);
|
|
3640
|
+
}
|
|
3641
|
+
nonempty(e) {
|
|
3642
|
+
return this.min(1, e);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
K.create = (t, e) => new K({
|
|
3646
|
+
valueType: t,
|
|
3647
|
+
minSize: null,
|
|
3648
|
+
maxSize: null,
|
|
3649
|
+
typeName: h.ZodSet,
|
|
3650
|
+
..._(e)
|
|
3651
|
+
});
|
|
3652
|
+
class Pe extends y {
|
|
3653
|
+
get schema() {
|
|
3654
|
+
return this._def.getter();
|
|
3655
|
+
}
|
|
3656
|
+
_parse(e) {
|
|
3657
|
+
const { ctx: n } = this._processInputParams(e);
|
|
3658
|
+
return this._def.getter()._parse({ data: n.data, path: n.path, parent: n });
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
Pe.create = (t, e) => new Pe({
|
|
3662
|
+
getter: t,
|
|
3663
|
+
typeName: h.ZodLazy,
|
|
3664
|
+
..._(e)
|
|
3665
|
+
});
|
|
3666
|
+
class pe extends y {
|
|
3667
|
+
_parse(e) {
|
|
3668
|
+
if (e.data !== this._def.value) {
|
|
3669
|
+
const n = this._getOrReturnCtx(e);
|
|
3670
|
+
return u(n, {
|
|
3671
|
+
received: n.data,
|
|
3672
|
+
code: d.invalid_literal,
|
|
3673
|
+
expected: this._def.value
|
|
3674
|
+
}), m;
|
|
3675
|
+
}
|
|
3676
|
+
return { status: "valid", value: e.data };
|
|
3677
|
+
}
|
|
3678
|
+
get value() {
|
|
3679
|
+
return this._def.value;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
pe.create = (t, e) => new pe({
|
|
3683
|
+
value: t,
|
|
3684
|
+
typeName: h.ZodLiteral,
|
|
3685
|
+
..._(e)
|
|
3686
|
+
});
|
|
3687
|
+
function Be(t, e) {
|
|
3688
|
+
return new W({
|
|
3689
|
+
values: t,
|
|
3690
|
+
typeName: h.ZodEnum,
|
|
3691
|
+
..._(e)
|
|
3692
|
+
});
|
|
3693
|
+
}
|
|
3694
|
+
class W extends y {
|
|
3695
|
+
_parse(e) {
|
|
3696
|
+
if (typeof e.data != "string") {
|
|
3697
|
+
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
3698
|
+
return u(n, {
|
|
3699
|
+
expected: v.joinValues(s),
|
|
3700
|
+
received: n.parsedType,
|
|
3701
|
+
code: d.invalid_type
|
|
3702
|
+
}), m;
|
|
3703
|
+
}
|
|
3704
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
3705
|
+
const n = this._getOrReturnCtx(e), s = this._def.values;
|
|
3706
|
+
return u(n, {
|
|
3707
|
+
received: n.data,
|
|
3708
|
+
code: d.invalid_enum_value,
|
|
3709
|
+
options: s
|
|
3710
|
+
}), m;
|
|
3711
|
+
}
|
|
3712
|
+
return S(e.data);
|
|
3713
|
+
}
|
|
3714
|
+
get options() {
|
|
3715
|
+
return this._def.values;
|
|
3716
|
+
}
|
|
3717
|
+
get enum() {
|
|
3718
|
+
const e = {};
|
|
3719
|
+
for (const n of this._def.values)
|
|
3720
|
+
e[n] = n;
|
|
3721
|
+
return e;
|
|
3722
|
+
}
|
|
3723
|
+
get Values() {
|
|
3724
|
+
const e = {};
|
|
3725
|
+
for (const n of this._def.values)
|
|
3726
|
+
e[n] = n;
|
|
3727
|
+
return e;
|
|
3728
|
+
}
|
|
3729
|
+
get Enum() {
|
|
3730
|
+
const e = {};
|
|
3731
|
+
for (const n of this._def.values)
|
|
3732
|
+
e[n] = n;
|
|
3733
|
+
return e;
|
|
3734
|
+
}
|
|
3735
|
+
extract(e, n = this._def) {
|
|
3736
|
+
return W.create(e, {
|
|
3737
|
+
...this._def,
|
|
3738
|
+
...n
|
|
3739
|
+
});
|
|
3740
|
+
}
|
|
3741
|
+
exclude(e, n = this._def) {
|
|
3742
|
+
return W.create(this.options.filter((s) => !e.includes(s)), {
|
|
3743
|
+
...this._def,
|
|
3744
|
+
...n
|
|
3745
|
+
});
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
W.create = Be;
|
|
3749
|
+
class je extends y {
|
|
3750
|
+
_parse(e) {
|
|
3751
|
+
const n = v.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
3752
|
+
if (s.parsedType !== f.string && s.parsedType !== f.number) {
|
|
3753
|
+
const i = v.objectValues(n);
|
|
3754
|
+
return u(s, {
|
|
3755
|
+
expected: v.joinValues(i),
|
|
3756
|
+
received: s.parsedType,
|
|
3757
|
+
code: d.invalid_type
|
|
3758
|
+
}), m;
|
|
3759
|
+
}
|
|
3760
|
+
if (this._cache || (this._cache = new Set(v.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
3761
|
+
const i = v.objectValues(n);
|
|
3762
|
+
return u(s, {
|
|
3763
|
+
received: s.data,
|
|
3764
|
+
code: d.invalid_enum_value,
|
|
3765
|
+
options: i
|
|
3766
|
+
}), m;
|
|
3767
|
+
}
|
|
3768
|
+
return S(e.data);
|
|
3769
|
+
}
|
|
3770
|
+
get enum() {
|
|
3771
|
+
return this._def.values;
|
|
3772
|
+
}
|
|
3773
|
+
}
|
|
3774
|
+
je.create = (t, e) => new je({
|
|
3775
|
+
values: t,
|
|
3776
|
+
typeName: h.ZodNativeEnum,
|
|
3777
|
+
..._(e)
|
|
3778
|
+
});
|
|
3779
|
+
class ie extends y {
|
|
3780
|
+
unwrap() {
|
|
3781
|
+
return this._def.type;
|
|
3782
|
+
}
|
|
3783
|
+
_parse(e) {
|
|
3784
|
+
const { ctx: n } = this._processInputParams(e);
|
|
3785
|
+
if (n.parsedType !== f.promise && n.common.async === !1)
|
|
3786
|
+
return u(n, {
|
|
3787
|
+
code: d.invalid_type,
|
|
3788
|
+
expected: f.promise,
|
|
3789
|
+
received: n.parsedType
|
|
3790
|
+
}), m;
|
|
3791
|
+
const s = n.parsedType === f.promise ? n.data : Promise.resolve(n.data);
|
|
3792
|
+
return S(s.then((i) => this._def.type.parseAsync(i, {
|
|
3793
|
+
path: n.path,
|
|
3794
|
+
errorMap: n.common.contextualErrorMap
|
|
3795
|
+
})));
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
ie.create = (t, e) => new ie({
|
|
3799
|
+
type: t,
|
|
3800
|
+
typeName: h.ZodPromise,
|
|
3801
|
+
..._(e)
|
|
3802
|
+
});
|
|
3803
|
+
class F extends y {
|
|
3804
|
+
innerType() {
|
|
3805
|
+
return this._def.schema;
|
|
3806
|
+
}
|
|
3807
|
+
sourceType() {
|
|
3808
|
+
return this._def.schema._def.typeName === h.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3809
|
+
}
|
|
3810
|
+
_parse(e) {
|
|
3811
|
+
const { status: n, ctx: s } = this._processInputParams(e), i = this._def.effect || null, r = {
|
|
3812
|
+
addIssue: (a) => {
|
|
3813
|
+
u(s, a), a.fatal ? n.abort() : n.dirty();
|
|
3814
|
+
},
|
|
3815
|
+
get path() {
|
|
3816
|
+
return s.path;
|
|
3817
|
+
}
|
|
3818
|
+
};
|
|
3819
|
+
if (r.addIssue = r.addIssue.bind(r), i.type === "preprocess") {
|
|
3820
|
+
const a = i.transform(s.data, r);
|
|
3821
|
+
if (s.common.async)
|
|
3822
|
+
return Promise.resolve(a).then(async (o) => {
|
|
3823
|
+
if (n.value === "aborted")
|
|
3824
|
+
return m;
|
|
3825
|
+
const c = await this._def.schema._parseAsync({
|
|
3826
|
+
data: o,
|
|
3827
|
+
path: s.path,
|
|
3828
|
+
parent: s
|
|
3829
|
+
});
|
|
3830
|
+
return c.status === "aborted" ? m : c.status === "dirty" || n.value === "dirty" ? J(c.value) : c;
|
|
3831
|
+
});
|
|
3832
|
+
{
|
|
3833
|
+
if (n.value === "aborted")
|
|
3834
|
+
return m;
|
|
3835
|
+
const o = this._def.schema._parseSync({
|
|
3836
|
+
data: a,
|
|
3837
|
+
path: s.path,
|
|
3838
|
+
parent: s
|
|
3839
|
+
});
|
|
3840
|
+
return o.status === "aborted" ? m : o.status === "dirty" || n.value === "dirty" ? J(o.value) : o;
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3843
|
+
if (i.type === "refinement") {
|
|
3844
|
+
const a = (o) => {
|
|
3845
|
+
const c = i.refinement(o, r);
|
|
3846
|
+
if (s.common.async)
|
|
3847
|
+
return Promise.resolve(c);
|
|
3848
|
+
if (c instanceof Promise)
|
|
3849
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3850
|
+
return o;
|
|
3851
|
+
};
|
|
3852
|
+
if (s.common.async === !1) {
|
|
3853
|
+
const o = this._def.schema._parseSync({
|
|
3854
|
+
data: s.data,
|
|
3855
|
+
path: s.path,
|
|
3856
|
+
parent: s
|
|
3857
|
+
});
|
|
3858
|
+
return o.status === "aborted" ? m : (o.status === "dirty" && n.dirty(), a(o.value), { status: n.value, value: o.value });
|
|
3859
|
+
} else
|
|
3860
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && n.dirty(), a(o.value).then(() => ({ status: n.value, value: o.value }))));
|
|
3861
|
+
}
|
|
3862
|
+
if (i.type === "transform")
|
|
3863
|
+
if (s.common.async === !1) {
|
|
3864
|
+
const a = this._def.schema._parseSync({
|
|
3865
|
+
data: s.data,
|
|
3866
|
+
path: s.path,
|
|
3867
|
+
parent: s
|
|
3868
|
+
});
|
|
3869
|
+
if (!q(a))
|
|
3870
|
+
return m;
|
|
3871
|
+
const o = i.transform(a.value, r);
|
|
3872
|
+
if (o instanceof Promise)
|
|
3873
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3874
|
+
return { status: n.value, value: o };
|
|
3875
|
+
} else
|
|
3876
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((a) => q(a) ? Promise.resolve(i.transform(a.value, r)).then((o) => ({
|
|
3877
|
+
status: n.value,
|
|
3878
|
+
value: o
|
|
3879
|
+
})) : m);
|
|
3880
|
+
v.assertNever(i);
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
F.create = (t, e, n) => new F({
|
|
3884
|
+
schema: t,
|
|
3885
|
+
typeName: h.ZodEffects,
|
|
3886
|
+
effect: e,
|
|
3887
|
+
..._(n)
|
|
3888
|
+
});
|
|
3889
|
+
F.createWithPreprocess = (t, e, n) => new F({
|
|
3890
|
+
schema: e,
|
|
3891
|
+
effect: { type: "preprocess", transform: t },
|
|
3892
|
+
typeName: h.ZodEffects,
|
|
3893
|
+
..._(n)
|
|
3894
|
+
});
|
|
3895
|
+
class j extends y {
|
|
3896
|
+
_parse(e) {
|
|
3897
|
+
return this._getType(e) === f.undefined ? S(void 0) : this._def.innerType._parse(e);
|
|
3898
|
+
}
|
|
3899
|
+
unwrap() {
|
|
3900
|
+
return this._def.innerType;
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
j.create = (t, e) => new j({
|
|
3904
|
+
innerType: t,
|
|
3905
|
+
typeName: h.ZodOptional,
|
|
3906
|
+
..._(e)
|
|
3907
|
+
});
|
|
3908
|
+
class H extends y {
|
|
3909
|
+
_parse(e) {
|
|
3910
|
+
return this._getType(e) === f.null ? S(null) : this._def.innerType._parse(e);
|
|
3911
|
+
}
|
|
3912
|
+
unwrap() {
|
|
3913
|
+
return this._def.innerType;
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
H.create = (t, e) => new H({
|
|
3917
|
+
innerType: t,
|
|
3918
|
+
typeName: h.ZodNullable,
|
|
3919
|
+
..._(e)
|
|
3920
|
+
});
|
|
3921
|
+
class he extends y {
|
|
3922
|
+
_parse(e) {
|
|
3923
|
+
const { ctx: n } = this._processInputParams(e);
|
|
3924
|
+
let s = n.data;
|
|
3925
|
+
return n.parsedType === f.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
3926
|
+
data: s,
|
|
3927
|
+
path: n.path,
|
|
3928
|
+
parent: n
|
|
3929
|
+
});
|
|
3930
|
+
}
|
|
3931
|
+
removeDefault() {
|
|
3932
|
+
return this._def.innerType;
|
|
3933
|
+
}
|
|
3934
|
+
}
|
|
3935
|
+
he.create = (t, e) => new he({
|
|
3936
|
+
innerType: t,
|
|
3937
|
+
typeName: h.ZodDefault,
|
|
3938
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3939
|
+
..._(e)
|
|
3940
|
+
});
|
|
3941
|
+
class me extends y {
|
|
3942
|
+
_parse(e) {
|
|
3943
|
+
const { ctx: n } = this._processInputParams(e), s = {
|
|
3944
|
+
...n,
|
|
3945
|
+
common: {
|
|
3946
|
+
...n.common,
|
|
3947
|
+
issues: []
|
|
3948
|
+
}
|
|
3949
|
+
}, i = this._def.innerType._parse({
|
|
3950
|
+
data: s.data,
|
|
3951
|
+
path: s.path,
|
|
3952
|
+
parent: {
|
|
3953
|
+
...s
|
|
3954
|
+
}
|
|
3955
|
+
});
|
|
3956
|
+
return X(i) ? i.then((r) => ({
|
|
3957
|
+
status: "valid",
|
|
3958
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
3959
|
+
get error() {
|
|
3960
|
+
return new O(s.common.issues);
|
|
3961
|
+
},
|
|
3962
|
+
input: s.data
|
|
3963
|
+
})
|
|
3964
|
+
})) : {
|
|
3965
|
+
status: "valid",
|
|
3966
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
3967
|
+
get error() {
|
|
3968
|
+
return new O(s.common.issues);
|
|
3969
|
+
},
|
|
3970
|
+
input: s.data
|
|
3971
|
+
})
|
|
3972
|
+
};
|
|
3973
|
+
}
|
|
3974
|
+
removeCatch() {
|
|
3975
|
+
return this._def.innerType;
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
me.create = (t, e) => new me({
|
|
3979
|
+
innerType: t,
|
|
3980
|
+
typeName: h.ZodCatch,
|
|
3981
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3982
|
+
..._(e)
|
|
3983
|
+
});
|
|
3984
|
+
class Le extends y {
|
|
3985
|
+
_parse(e) {
|
|
3986
|
+
if (this._getType(e) !== f.nan) {
|
|
3987
|
+
const s = this._getOrReturnCtx(e);
|
|
3988
|
+
return u(s, {
|
|
3989
|
+
code: d.invalid_type,
|
|
3990
|
+
expected: f.nan,
|
|
3991
|
+
received: s.parsedType
|
|
3992
|
+
}), m;
|
|
3993
|
+
}
|
|
3994
|
+
return { status: "valid", value: e.data };
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
Le.create = (t) => new Le({
|
|
3998
|
+
typeName: h.ZodNaN,
|
|
3999
|
+
..._(t)
|
|
4000
|
+
});
|
|
4001
|
+
class wn extends y {
|
|
4002
|
+
_parse(e) {
|
|
4003
|
+
const { ctx: n } = this._processInputParams(e), s = n.data;
|
|
4004
|
+
return this._def.type._parse({
|
|
4005
|
+
data: s,
|
|
4006
|
+
path: n.path,
|
|
4007
|
+
parent: n
|
|
4008
|
+
});
|
|
4009
|
+
}
|
|
4010
|
+
unwrap() {
|
|
4011
|
+
return this._def.type;
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
class ve extends y {
|
|
4015
|
+
_parse(e) {
|
|
4016
|
+
const { status: n, ctx: s } = this._processInputParams(e);
|
|
4017
|
+
if (s.common.async)
|
|
4018
|
+
return (async () => {
|
|
4019
|
+
const r = await this._def.in._parseAsync({
|
|
4020
|
+
data: s.data,
|
|
4021
|
+
path: s.path,
|
|
4022
|
+
parent: s
|
|
4023
|
+
});
|
|
4024
|
+
return r.status === "aborted" ? m : r.status === "dirty" ? (n.dirty(), J(r.value)) : this._def.out._parseAsync({
|
|
4025
|
+
data: r.value,
|
|
4026
|
+
path: s.path,
|
|
4027
|
+
parent: s
|
|
4028
|
+
});
|
|
4029
|
+
})();
|
|
4030
|
+
{
|
|
4031
|
+
const i = this._def.in._parseSync({
|
|
4032
|
+
data: s.data,
|
|
4033
|
+
path: s.path,
|
|
4034
|
+
parent: s
|
|
4035
|
+
});
|
|
4036
|
+
return i.status === "aborted" ? m : i.status === "dirty" ? (n.dirty(), {
|
|
4037
|
+
status: "dirty",
|
|
4038
|
+
value: i.value
|
|
4039
|
+
}) : this._def.out._parseSync({
|
|
4040
|
+
data: i.value,
|
|
4041
|
+
path: s.path,
|
|
4042
|
+
parent: s
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
}
|
|
4046
|
+
static create(e, n) {
|
|
4047
|
+
return new ve({
|
|
4048
|
+
in: e,
|
|
4049
|
+
out: n,
|
|
4050
|
+
typeName: h.ZodPipeline
|
|
4051
|
+
});
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
class ge extends y {
|
|
4055
|
+
_parse(e) {
|
|
4056
|
+
const n = this._def.innerType._parse(e), s = (i) => (q(i) && (i.value = Object.freeze(i.value)), i);
|
|
4057
|
+
return X(n) ? n.then((i) => s(i)) : s(n);
|
|
4058
|
+
}
|
|
4059
|
+
unwrap() {
|
|
4060
|
+
return this._def.innerType;
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
ge.create = (t, e) => new ge({
|
|
4064
|
+
innerType: t,
|
|
4065
|
+
typeName: h.ZodReadonly,
|
|
4066
|
+
..._(e)
|
|
4067
|
+
});
|
|
4068
|
+
var h;
|
|
4069
|
+
(function(t) {
|
|
4070
|
+
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";
|
|
4071
|
+
})(h || (h = {}));
|
|
4072
|
+
const Fn = N.create, Hn = B.create, Gn = ue.create, Jn = le.create;
|
|
4073
|
+
L.create;
|
|
4074
|
+
const Qn = E.create, Yn = w.create, Kn = te.create;
|
|
4075
|
+
ne.create;
|
|
4076
|
+
z.create;
|
|
4077
|
+
const Xn = se.create, es = pe.create, ts = W.create;
|
|
4078
|
+
ie.create;
|
|
4079
|
+
j.create;
|
|
4080
|
+
H.create;
|
|
4081
|
+
export {
|
|
4082
|
+
Sn as A,
|
|
4083
|
+
Vn as B,
|
|
4084
|
+
Cn as C,
|
|
4085
|
+
es as D,
|
|
4086
|
+
Ye as E,
|
|
4087
|
+
jn as F,
|
|
4088
|
+
Gt as G,
|
|
4089
|
+
ke as H,
|
|
4090
|
+
Qe as I,
|
|
4091
|
+
Je as J,
|
|
4092
|
+
Ge as K,
|
|
4093
|
+
Fe as L,
|
|
4094
|
+
it as M,
|
|
4095
|
+
$n as N,
|
|
4096
|
+
Q as O,
|
|
4097
|
+
He as P,
|
|
4098
|
+
D as Q,
|
|
4099
|
+
nt as R,
|
|
4100
|
+
st as S,
|
|
4101
|
+
zn as T,
|
|
4102
|
+
Dn as U,
|
|
4103
|
+
Ln as V,
|
|
4104
|
+
Ke as W,
|
|
4105
|
+
Un as a,
|
|
4106
|
+
Wn as b,
|
|
4107
|
+
lt as c,
|
|
4108
|
+
Qn as d,
|
|
4109
|
+
Gn as e,
|
|
4110
|
+
ts as f,
|
|
4111
|
+
Jn as g,
|
|
4112
|
+
Tn as h,
|
|
4113
|
+
An as i,
|
|
4114
|
+
Pn as j,
|
|
4115
|
+
Mn as k,
|
|
4116
|
+
En as l,
|
|
4117
|
+
xn as m,
|
|
4118
|
+
qn as n,
|
|
4119
|
+
Yn as o,
|
|
4120
|
+
Bn as p,
|
|
4121
|
+
Hn as q,
|
|
4122
|
+
bn as r,
|
|
4123
|
+
Fn as s,
|
|
4124
|
+
Zn as t,
|
|
4125
|
+
Kn as u,
|
|
4126
|
+
Xn as v,
|
|
4127
|
+
Rn as w,
|
|
4128
|
+
Nn as x,
|
|
4129
|
+
On as y,
|
|
4130
|
+
In as z
|
|
4131
|
+
};
|
|
4132
|
+
//# sourceMappingURL=types-yxW8WA7u.js.map
|