@delopay/sdk 0.351.0 → 0.361.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.
@@ -1962,6 +1962,77 @@ var Disputes = class {
1962
1962
  }
1963
1963
  };
1964
1964
 
1965
+ // src/resources/chargebackPrevention.ts
1966
+ function preventionCaseQuery(params) {
1967
+ if (!params) return void 0;
1968
+ const { provider, source, status, outcome, match_status, ...query } = params;
1969
+ return {
1970
+ ...query,
1971
+ ...provider?.length ? { provider: provider.join(",") } : {},
1972
+ ...source?.length ? { source: source.join(",") } : {},
1973
+ ...status?.length ? { status: status.join(",") } : {},
1974
+ ...outcome?.length ? { outcome: outcome.join(",") } : {},
1975
+ ...match_status?.length ? { match_status: match_status.join(",") } : {}
1976
+ };
1977
+ }
1978
+ var ChargebackPrevention = class {
1979
+ constructor(request) {
1980
+ this.request = request;
1981
+ }
1982
+ /** The merchant's connections, with their business accounts and sync health. */
1983
+ async listConnections() {
1984
+ return this.request("GET", "/chargeback-prevention/connections");
1985
+ }
1986
+ /**
1987
+ * Connect a provider account. DeloPay checks the key with the provider,
1988
+ * registers its webhooks there and starts reading alerts. Dashboard session
1989
+ * only.
1990
+ */
1991
+ async connect(params) {
1992
+ return this.request("POST", "/chargeback-prevention/connections", { body: params });
1993
+ }
1994
+ /** Replace a connection's key; reconnects one whose key was refused. */
1995
+ async replaceKey(connectionId, params) {
1996
+ return this.request(
1997
+ "PUT",
1998
+ `/chargeback-prevention/connections/${encodeURIComponent(connectionId)}/key`,
1999
+ { body: params }
2000
+ );
2001
+ }
2002
+ /** Stop reading a connection. Its cases are kept. */
2003
+ async disconnect(connectionId) {
2004
+ return this.request(
2005
+ "DELETE",
2006
+ `/chargeback-prevention/connections/${encodeURIComponent(connectionId)}`
2007
+ );
2008
+ }
2009
+ /** Read the connection's alerts again as soon as the provider allows. */
2010
+ async syncNow(connectionId) {
2011
+ return this.request(
2012
+ "POST",
2013
+ `/chargeback-prevention/connections/${encodeURIComponent(connectionId)}/sync`
2014
+ );
2015
+ }
2016
+ /** Set the shops a provider business account sells through; its cases are matched again. */
2017
+ async mapAccount(connectionId, providerAccountId, params) {
2018
+ return this.request(
2019
+ "PUT",
2020
+ `/chargeback-prevention/connections/${encodeURIComponent(connectionId)}/accounts/${encodeURIComponent(providerAccountId)}`,
2021
+ { body: params }
2022
+ );
2023
+ }
2024
+ /** Cases with what DeloPay's records say happened to each payment. */
2025
+ async listCases(params) {
2026
+ return this.request("GET", "/chargeback-prevention/cases", {
2027
+ query: preventionCaseQuery(params)
2028
+ });
2029
+ }
2030
+ /** One case with its references and observed history. */
2031
+ async retrieveCase(caseId) {
2032
+ return this.request("GET", `/chargeback-prevention/cases/${encodeURIComponent(caseId)}`);
2033
+ }
2034
+ };
2035
+
1965
2036
  // src/resources/paypalDisputes.ts
1966
2037
  var PaypalDisputes = class {
1967
2038
  constructor(request) {
@@ -4201,7 +4272,12 @@ var Routing = class {
4201
4272
  async getDefaultForProfile(profileId) {
4202
4273
  return this.request("GET", `/routing/default/profile/${encodeURIComponent(profileId)}`);
4203
4274
  }
4204
- /** Update default config for a profile. `POST /routing/default/profile/{profileId}` */
4275
+ /**
4276
+ * Update default config for a profile. `POST /routing/default/profile/{profileId}`
4277
+ *
4278
+ * Send the list alone to keep the shop's fallback mode, or `{ connectors, mode, splits }` to set
4279
+ * it. A `volume_split` whose shares do not total 100 is refused.
4280
+ */
4205
4281
  async updateDefaultProfile(profileId, params, options) {
4206
4282
  return this.request("POST", `/routing/default/profile/${encodeURIComponent(profileId)}`, {
4207
4283
  body: params,
@@ -9714,7 +9790,8 @@ var Settlement = class {
9714
9790
  });
9715
9791
  }
9716
9792
  /**
9717
- * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with
9793
+ * Export a statement as PDF, or with `format` as CSV, JSON
9794
+ * (`StatementDocument`) or XLSX. Returns the raw bytes as a `Blob`, with
9718
9795
  * the same auth, retries and error handling as every other call — persist
9719
9796
  * or object-URL it caller-side.
9720
9797
  *
@@ -9733,7 +9810,8 @@ var Settlement = class {
9733
9810
  return this.request("GET", `/settlement/statements/${encodeURIComponent(statementId)}/pdf`, {
9734
9811
  query: {
9735
9812
  currency: params?.currency,
9736
- include_transactions: params?.include_transactions
9813
+ include_transactions: params?.include_transactions,
9814
+ format: params?.format
9737
9815
  },
9738
9816
  responseType: "blob",
9739
9817
  ...options
@@ -9997,7 +10075,21 @@ var OperationLimits = class {
9997
10075
  */
9998
10076
  async retrieveUsage(params, options) {
9999
10077
  return this.request("GET", "/operation-limits/usage", {
10000
- query: { operation: params.operation },
10078
+ query: { operation: params.operation, profile_id: params.profile_id },
10079
+ ...options
10080
+ });
10081
+ }
10082
+ /**
10083
+ * The version history of the merchant's limit settings, newest first: every
10084
+ * rule created, changed (switched off or on included) or deleted, and every
10085
+ * settings change, with who made it (and who really did, under act-as) and
10086
+ * the values before and after.
10087
+ *
10088
+ * `GET /operation-limits/history`
10089
+ */
10090
+ async listHistory(params, options) {
10091
+ return this.request("GET", "/operation-limits/history", {
10092
+ query: { limit: params?.limit, before: params?.before },
10001
10093
  ...options
10002
10094
  });
10003
10095
  }
@@ -10799,6 +10891,7 @@ var Delopay = class {
10799
10891
  this.paymentLinks = new PaymentLinks(request);
10800
10892
  this.mandates = new Mandates(request);
10801
10893
  this.disputes = new Disputes(request);
10894
+ this.chargebackPrevention = new ChargebackPrevention(request);
10802
10895
  this.paypalDisputes = new PaypalDisputes(request);
10803
10896
  this.whopResolutionCases = new WhopResolutionCases(request);
10804
10897
  this.payouts = new Payouts(request);
@@ -11644,9 +11737,9 @@ function resolveStripeTheme(theme, dark) {
11644
11737
  var STRIPE_INPUT_STYLES = ["spaced", "condensed"];
11645
11738
  var STRIPE_LABEL_PLACEMENTS = ["above", "floating"];
11646
11739
  var STRIPE_SPACINGS = ["compact", "comfortable", "spacious"];
11647
- function stripeSpacingValues(spacing) {
11648
- if (spacing === "compact") return { spacingUnit: "3px", gridRowSpacing: "8px" };
11649
- if (spacing === "spacious") return { spacingUnit: "5px", gridRowSpacing: "16px" };
11740
+ function stripeSpacingValues(spacing2) {
11741
+ if (spacing2 === "compact") return { spacingUnit: "3px", gridRowSpacing: "8px" };
11742
+ if (spacing2 === "spacious") return { spacingUnit: "5px", gridRowSpacing: "16px" };
11650
11743
  return { spacingUnit: "4px", gridRowSpacing: "12px" };
11651
11744
  }
11652
11745
  var PAYPAL_CARD_LAYOUTS = ["split", "stacked"];
@@ -11926,6 +12019,444 @@ function matchWhopLook(settings) {
11926
12019
  ) ?? null;
11927
12020
  }
11928
12021
 
12022
+ // src/enigmaCardForm.ts
12023
+ var ENIGMA_FIELD_CHROMES = ["outlined", "filled", "underline", "joined"];
12024
+ var ENIGMA_LABEL_PLACEMENTS = ["above", "inside"];
12025
+ var ENIGMA_LABEL_TONES = ["strong", "muted"];
12026
+ var ENIGMA_FIELD_ORDERS = ["number", "name"];
12027
+ var ENIGMA_NETWORK_MARKS = ["live", "static", "hidden"];
12028
+ var ENIGMA_FOCUS_RINGS = ["strong", "subtle"];
12029
+ var ENIGMA_FIELD_MOTIONS = ["smooth", "slow", "none"];
12030
+ var ENIGMA_FIELD_HEIGHTS = ["40", "44", "48", "52"];
12031
+ var ENIGMA_ROW_GAPS = ["8", "12", "16"];
12032
+ var ENIGMA_CORNERS = ["square", "small", "medium", "large", "pill"];
12033
+ var ENIGMA_STYLE_MODES = ["designed", "custom"];
12034
+ var ENIGMA_OPENINGS = ["place", "expand"];
12035
+ var ENIGMA_CLICK_FEEDBACK = ["both", "ring", "press", "none"];
12036
+ var ENIGMA_LOADING_STYLES = [
12037
+ "shimmer",
12038
+ "pulse",
12039
+ "dim",
12040
+ "line",
12041
+ "spinner",
12042
+ "none"
12043
+ ];
12044
+ var ENIGMA_REVEALS = ["fade", "rise", "wipe", "none"];
12045
+ var ENIGMA_PAY_FEEDBACK = ["spinner", "press", "none"];
12046
+ var ENIGMA_TEMPLATES = [
12047
+ "soft",
12048
+ "fields",
12049
+ "classic",
12050
+ "compact",
12051
+ "filled",
12052
+ "underline"
12053
+ ];
12054
+ var ENIGMA_CUSTOM_CSS_MAX_LENGTH = 950;
12055
+ var ENIGMA_CUSTOM_HEIGHT_MIN = 120;
12056
+ var ENIGMA_CUSTOM_HEIGHT_MAX = 600;
12057
+ var ENIGMA_CUSTOM_HEIGHT_DEFAULT = 260;
12058
+ var ENIGMA_TEMPLATE_PRESETS = {
12059
+ soft: {
12060
+ enigmaChrome: "outlined",
12061
+ enigmaLabels: "above",
12062
+ enigmaLabelTone: "strong",
12063
+ enigmaHints: true,
12064
+ enigmaCvcIcon: true,
12065
+ enigmaFieldOrder: "number",
12066
+ enigmaMarks: "live",
12067
+ enigmaFocusRing: "strong",
12068
+ enigmaFieldHeight: "44",
12069
+ enigmaRowGap: "12",
12070
+ enigmaCorner: "medium"
12071
+ },
12072
+ fields: {
12073
+ enigmaChrome: "outlined",
12074
+ enigmaLabels: "above",
12075
+ enigmaLabelTone: "muted",
12076
+ enigmaHints: true,
12077
+ enigmaCvcIcon: true,
12078
+ enigmaFieldOrder: "number",
12079
+ enigmaMarks: "live",
12080
+ enigmaFocusRing: "strong",
12081
+ enigmaFieldHeight: "48",
12082
+ enigmaRowGap: "12",
12083
+ enigmaCorner: "small"
12084
+ },
12085
+ classic: {
12086
+ enigmaChrome: "outlined",
12087
+ enigmaLabels: "above",
12088
+ enigmaLabelTone: "strong",
12089
+ enigmaHints: false,
12090
+ enigmaCvcIcon: true,
12091
+ enigmaFieldOrder: "number",
12092
+ enigmaMarks: "live",
12093
+ enigmaFocusRing: "strong",
12094
+ enigmaFieldHeight: "44",
12095
+ enigmaRowGap: "12",
12096
+ enigmaCorner: "medium"
12097
+ },
12098
+ compact: {
12099
+ enigmaChrome: "joined",
12100
+ enigmaLabels: "inside",
12101
+ enigmaLabelTone: "muted",
12102
+ enigmaHints: false,
12103
+ enigmaCvcIcon: true,
12104
+ enigmaFieldOrder: "number",
12105
+ enigmaMarks: "live",
12106
+ enigmaFocusRing: "strong",
12107
+ enigmaFieldHeight: "48",
12108
+ enigmaRowGap: "12",
12109
+ enigmaCorner: "medium"
12110
+ },
12111
+ filled: {
12112
+ enigmaChrome: "filled",
12113
+ enigmaLabels: "above",
12114
+ enigmaLabelTone: "strong",
12115
+ enigmaHints: false,
12116
+ enigmaCvcIcon: true,
12117
+ enigmaFieldOrder: "number",
12118
+ enigmaMarks: "live",
12119
+ enigmaFocusRing: "strong",
12120
+ enigmaFieldHeight: "44",
12121
+ enigmaRowGap: "12",
12122
+ enigmaCorner: "medium"
12123
+ },
12124
+ underline: {
12125
+ enigmaChrome: "underline",
12126
+ enigmaLabels: "above",
12127
+ enigmaLabelTone: "muted",
12128
+ enigmaHints: false,
12129
+ enigmaCvcIcon: true,
12130
+ enigmaFieldOrder: "number",
12131
+ enigmaMarks: "live",
12132
+ enigmaFocusRing: "strong",
12133
+ enigmaFieldHeight: "40",
12134
+ enigmaRowGap: "16",
12135
+ enigmaCorner: "square"
12136
+ }
12137
+ };
12138
+ var DEFAULT_ENIGMA_CARD_FORM = {
12139
+ enigmaTemplate: "soft",
12140
+ enigmaStyleMode: "designed",
12141
+ ...ENIGMA_TEMPLATE_PRESETS.soft,
12142
+ enigmaFieldMotion: "smooth",
12143
+ enigmaAccent: "",
12144
+ enigmaBorder: "",
12145
+ enigmaFill: "",
12146
+ enigmaTrustLine: true,
12147
+ enigmaAutoOpen: false,
12148
+ enigmaOpening: "place",
12149
+ enigmaClickFeedback: "both",
12150
+ enigmaLoading: "shimmer",
12151
+ enigmaReveal: "fade",
12152
+ enigmaPayFeedback: "spinner",
12153
+ enigmaCustomCss: "",
12154
+ enigmaCustomHeight: ENIGMA_CUSTOM_HEIGHT_DEFAULT
12155
+ };
12156
+ function applyEnigmaTemplate(template) {
12157
+ return { enigmaTemplate: template, ...ENIGMA_TEMPLATE_PRESETS[template] };
12158
+ }
12159
+ function enigmaTemplateChanges(settings) {
12160
+ const preset = ENIGMA_TEMPLATE_PRESETS[settings.enigmaTemplate];
12161
+ return Object.keys(preset).filter(
12162
+ (key) => settings[key] !== preset[key]
12163
+ );
12164
+ }
12165
+ function enigmaNamesInside(settings) {
12166
+ return settings.enigmaChrome === "joined" || settings.enigmaLabels === "inside";
12167
+ }
12168
+ var PSEUDO_CLASSES = [
12169
+ "focus",
12170
+ "focus-visible",
12171
+ "focus-within",
12172
+ "hover",
12173
+ "checked",
12174
+ "disabled",
12175
+ "invalid",
12176
+ "valid",
12177
+ "placeholder-shown",
12178
+ "first-child",
12179
+ "last-child"
12180
+ ];
12181
+ var HIDEABLE = ["p", "h1", "#header", "#headertext", ".timer", "#timer"];
12182
+ var PROPERTIES = [
12183
+ "color",
12184
+ "caret-color",
12185
+ "accent-color",
12186
+ "-webkit-text-fill-color",
12187
+ "background",
12188
+ "background-color",
12189
+ "border",
12190
+ "border-top",
12191
+ "border-right",
12192
+ "border-bottom",
12193
+ "border-left",
12194
+ "border-color",
12195
+ "border-width",
12196
+ "border-style",
12197
+ "border-top-color",
12198
+ "border-right-color",
12199
+ "border-bottom-color",
12200
+ "border-left-color",
12201
+ "border-top-width",
12202
+ "border-right-width",
12203
+ "border-bottom-width",
12204
+ "border-left-width",
12205
+ "border-radius",
12206
+ "border-top-left-radius",
12207
+ "border-top-right-radius",
12208
+ "border-bottom-left-radius",
12209
+ "border-bottom-right-radius",
12210
+ "box-shadow",
12211
+ "outline",
12212
+ "outline-color",
12213
+ "outline-offset",
12214
+ "font",
12215
+ "font-family",
12216
+ "font-size",
12217
+ "font-weight",
12218
+ "font-style",
12219
+ "letter-spacing",
12220
+ "line-height",
12221
+ "text-align",
12222
+ "text-transform",
12223
+ "padding",
12224
+ "padding-top",
12225
+ "padding-right",
12226
+ "padding-bottom",
12227
+ "padding-left",
12228
+ "margin",
12229
+ "margin-top",
12230
+ "margin-right",
12231
+ "margin-bottom",
12232
+ "margin-left",
12233
+ "height",
12234
+ "min-height",
12235
+ "width",
12236
+ "min-width",
12237
+ "max-width",
12238
+ "display",
12239
+ "flex-wrap",
12240
+ "gap",
12241
+ "transition",
12242
+ "box-sizing",
12243
+ "top"
12244
+ ];
12245
+ function lengthAtLeast(value, min) {
12246
+ const match = /^(-?[0-9.]+)(px|em|rem)$/.exec(value);
12247
+ if (!match) return false;
12248
+ const number = Number(match[1]) * (match[2] === "px" ? 1 : 16);
12249
+ return Number.isFinite(number) && number >= min;
12250
+ }
12251
+ function spacing(value) {
12252
+ return value.split(" ").every(
12253
+ (part) => part === "0" || part === "auto" || lengthAtLeast(part, 0) && !lengthAtLeast(part, 48.5)
12254
+ );
12255
+ }
12256
+ function width(value) {
12257
+ if (value === "auto") return true;
12258
+ if (value.endsWith("%")) return Number(value.slice(0, -1)) >= 20;
12259
+ const calc = /^calc\(([0-9.]+)% - ([0-9.]+)px\)$/.exec(value);
12260
+ if (calc) return Number(calc[1]) >= 20 && Number(calc[2]) <= 48;
12261
+ if (value.startsWith("calc(")) return false;
12262
+ return lengthAtLeast(value, 40);
12263
+ }
12264
+ function opaqueColour(value) {
12265
+ if (value.startsWith("#")) return /^#([0-9a-f]{3}|[0-9a-f]{6})$/.test(value);
12266
+ if (value.startsWith("rgb("))
12267
+ return value.endsWith(")") && value.split(",").length === 3 && !value.includes("/");
12268
+ return value !== "transparent" && /^[a-z]+$/.test(value);
12269
+ }
12270
+ function declarationProblem(selector, declaration) {
12271
+ const at = declaration.indexOf(":");
12272
+ if (at < 0) return null;
12273
+ const property = declaration.slice(0, at).trim();
12274
+ const raw = declaration.slice(at + 1).trim();
12275
+ const important = raw.endsWith("!important");
12276
+ const value = raw.replace(/!important$/, "").trim();
12277
+ if (!PROPERTIES.includes(property)) return "property";
12278
+ if (["var(", "env(", "attr("].some((fn) => value.includes(fn))) return "variable";
12279
+ let ok = true;
12280
+ switch (property) {
12281
+ case "display": {
12282
+ if (important) return "important_display";
12283
+ const hideable = selector.split(",").every((one) => {
12284
+ const subject = one.split(/[ >]/).pop() ?? one;
12285
+ return HIDEABLE.includes(subject.split(":")[0] ?? subject);
12286
+ });
12287
+ ok = ["block", "flex", "grid", "inline", "inline-block", "inline-flex"].includes(value) || value === "none" && hideable;
12288
+ break;
12289
+ }
12290
+ case "margin":
12291
+ case "margin-top":
12292
+ case "margin-right":
12293
+ case "margin-bottom":
12294
+ case "margin-left":
12295
+ case "padding":
12296
+ case "padding-top":
12297
+ case "padding-right":
12298
+ case "padding-bottom":
12299
+ case "padding-left":
12300
+ ok = spacing(value);
12301
+ break;
12302
+ case "height":
12303
+ case "min-height":
12304
+ ok = value === "auto" || lengthAtLeast(value, 20);
12305
+ break;
12306
+ case "width":
12307
+ case "min-width":
12308
+ case "max-width":
12309
+ ok = width(value);
12310
+ break;
12311
+ case "font-size":
12312
+ ok = lengthAtLeast(value, 12);
12313
+ break;
12314
+ case "font": {
12315
+ const size = value.split(/[ /]/).find((part) => part.endsWith("px") || part.endsWith("em"));
12316
+ ok = size !== void 0 && lengthAtLeast(size, 12);
12317
+ break;
12318
+ }
12319
+ case "line-height":
12320
+ ok = value === "normal" || Number(value) >= 1 || lengthAtLeast(value, 12);
12321
+ break;
12322
+ case "color":
12323
+ case "caret-color":
12324
+ ok = opaqueColour(value);
12325
+ break;
12326
+ case "top":
12327
+ ok = value === "0" || /^-?[0-9.]+px$/.test(value) && Math.abs(parseFloat(value)) <= 4;
12328
+ break;
12329
+ case "-webkit-text-fill-color":
12330
+ ok = selector.split(",").every((one) => (one.split(/[ >]/).pop() ?? "").includes(":placeholder-shown")) || opaqueColour(value);
12331
+ break;
12332
+ }
12333
+ return ok ? null : "hides_field";
12334
+ }
12335
+ function selectorProblem(selector) {
12336
+ if (!selector || !/^[a-z0-9\-_#.:,> ]+$/.test(selector) || selector.includes("::"))
12337
+ return "selector";
12338
+ const pseudoOk = selector.split(":").slice(1).every((after) => PSEUDO_CLASSES.includes(after.split(/[ >,.#]/)[0] ?? after));
12339
+ return pseudoOk ? null : "selector";
12340
+ }
12341
+ function enigmaCustomCssProblem(css) {
12342
+ if (!css.trim()) return null;
12343
+ if (css.length > ENIGMA_CUSTOM_CSS_MAX_LENGTH) return "too_long";
12344
+ if (/[^\x20-\x7e\n\r\t]/.test(css)) return "not_ascii";
12345
+ if (css.includes("<")) return "markup";
12346
+ if (css.includes("\\")) return "escape";
12347
+ const lower = css.toLowerCase();
12348
+ if (lower.includes("/*")) return "comment";
12349
+ if (["url(", "image-set(", "image(", "element(", "cross-fade(", "src(", "data:"].some(
12350
+ (needle) => lower.includes(needle)
12351
+ )) {
12352
+ return "loads_resource";
12353
+ }
12354
+ if (["expression(", "javascript:", "behavior", "-moz-binding"].some(
12355
+ (needle) => lower.includes(needle)
12356
+ )) {
12357
+ return "script";
12358
+ }
12359
+ if (/@(?!media)/.test(lower)) return "at_rule";
12360
+ const compact = lower.split(/\s+/).filter(Boolean).join(" ");
12361
+ const blocks = [];
12362
+ let text = "";
12363
+ for (const ch of compact) {
12364
+ if (ch === "{") {
12365
+ const prelude = text.trim();
12366
+ text = "";
12367
+ const media = prelude.startsWith("@media");
12368
+ if (!media) {
12369
+ const problem = selectorProblem(prelude.replace(/, /g, ","));
12370
+ if (problem) return problem;
12371
+ }
12372
+ blocks.push({ selector: prelude, media });
12373
+ } else if (ch === "}" || ch === ";") {
12374
+ const declaration = text;
12375
+ text = "";
12376
+ const top = blocks[blocks.length - 1];
12377
+ if (!top) {
12378
+ if (ch === "}") return "unbalanced";
12379
+ continue;
12380
+ }
12381
+ if (!top.media && declaration.trim()) {
12382
+ const problem = declarationProblem(top.selector.replace(/, /g, ","), declaration);
12383
+ if (problem) return problem;
12384
+ }
12385
+ if (ch === "}") blocks.pop();
12386
+ } else {
12387
+ text += ch;
12388
+ }
12389
+ }
12390
+ return blocks.length > 0 ? "unbalanced" : null;
12391
+ }
12392
+ function enigmaCornerPx(corner) {
12393
+ return { square: 0, small: 6, medium: 8, large: 12, pill: 22 }[corner];
12394
+ }
12395
+ var HEX = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;
12396
+ function pick(value, allowed, fallback) {
12397
+ return typeof value === "string" && allowed.includes(value) ? value : fallback;
12398
+ }
12399
+ function bool(value, fallback) {
12400
+ if (value === true || value === "true") return true;
12401
+ if (value === false || value === "false") return false;
12402
+ return fallback;
12403
+ }
12404
+ function hexOrEmpty(value) {
12405
+ return typeof value === "string" && HEX.test(value.trim()) ? value.trim() : "";
12406
+ }
12407
+ function decodeEnigmaCardForm(source) {
12408
+ const d = DEFAULT_ENIGMA_CARD_FORM;
12409
+ const height = Number(source["enigmaCustomHeight"]);
12410
+ const css = typeof source["enigmaCustomCss"] === "string" ? source["enigmaCustomCss"] : "";
12411
+ return {
12412
+ enigmaTemplate: pick(source["enigmaTemplate"], ENIGMA_TEMPLATES, d.enigmaTemplate),
12413
+ enigmaStyleMode: pick(source["enigmaStyleMode"], ENIGMA_STYLE_MODES, d.enigmaStyleMode),
12414
+ enigmaChrome: pick(source["enigmaChrome"], ENIGMA_FIELD_CHROMES, d.enigmaChrome),
12415
+ enigmaLabels: pick(source["enigmaLabels"], ENIGMA_LABEL_PLACEMENTS, d.enigmaLabels),
12416
+ enigmaLabelTone: pick(source["enigmaLabelTone"], ENIGMA_LABEL_TONES, d.enigmaLabelTone),
12417
+ enigmaHints: bool(source["enigmaHints"], d.enigmaHints),
12418
+ enigmaCvcIcon: bool(source["enigmaCvcIcon"], d.enigmaCvcIcon),
12419
+ enigmaFieldOrder: pick(source["enigmaFieldOrder"], ENIGMA_FIELD_ORDERS, d.enigmaFieldOrder),
12420
+ enigmaMarks: pick(source["enigmaMarks"], ENIGMA_NETWORK_MARKS, d.enigmaMarks),
12421
+ enigmaFocusRing: pick(source["enigmaFocusRing"], ENIGMA_FOCUS_RINGS, d.enigmaFocusRing),
12422
+ enigmaFieldMotion: pick(source["enigmaFieldMotion"], ENIGMA_FIELD_MOTIONS, d.enigmaFieldMotion),
12423
+ enigmaFieldHeight: pick(
12424
+ String(source["enigmaFieldHeight"] ?? ""),
12425
+ ENIGMA_FIELD_HEIGHTS,
12426
+ d.enigmaFieldHeight
12427
+ ),
12428
+ enigmaRowGap: pick(String(source["enigmaRowGap"] ?? ""), ENIGMA_ROW_GAPS, d.enigmaRowGap),
12429
+ enigmaCorner: pick(source["enigmaCorner"], ENIGMA_CORNERS, d.enigmaCorner),
12430
+ enigmaAccent: hexOrEmpty(source["enigmaAccent"]),
12431
+ enigmaBorder: hexOrEmpty(source["enigmaBorder"]),
12432
+ enigmaFill: hexOrEmpty(source["enigmaFill"]),
12433
+ enigmaTrustLine: bool(source["enigmaTrustLine"], d.enigmaTrustLine),
12434
+ enigmaAutoOpen: bool(source["enigmaAutoOpen"], d.enigmaAutoOpen),
12435
+ enigmaOpening: pick(source["enigmaOpening"], ENIGMA_OPENINGS, d.enigmaOpening),
12436
+ enigmaClickFeedback: pick(
12437
+ source["enigmaClickFeedback"],
12438
+ ENIGMA_CLICK_FEEDBACK,
12439
+ d.enigmaClickFeedback
12440
+ ),
12441
+ enigmaLoading: pick(source["enigmaLoading"], ENIGMA_LOADING_STYLES, d.enigmaLoading),
12442
+ enigmaReveal: pick(source["enigmaReveal"], ENIGMA_REVEALS, d.enigmaReveal),
12443
+ enigmaPayFeedback: pick(source["enigmaPayFeedback"], ENIGMA_PAY_FEEDBACK, d.enigmaPayFeedback),
12444
+ enigmaCustomCss: css.slice(0, ENIGMA_CUSTOM_CSS_MAX_LENGTH),
12445
+ enigmaCustomHeight: Number.isInteger(height) && height >= ENIGMA_CUSTOM_HEIGHT_MIN && height <= ENIGMA_CUSTOM_HEIGHT_MAX ? height : d.enigmaCustomHeight
12446
+ };
12447
+ }
12448
+ function encodeEnigmaCardForm(settings) {
12449
+ const out = {};
12450
+ for (const key of Object.keys(DEFAULT_ENIGMA_CARD_FORM)) {
12451
+ const value = settings[key];
12452
+ if (value === DEFAULT_ENIGMA_CARD_FORM[key]) continue;
12453
+ const text = String(value);
12454
+ if (key === "enigmaCustomCss" && !text.trim()) continue;
12455
+ out[key] = text;
12456
+ }
12457
+ return out;
12458
+ }
12459
+
11929
12460
  // src/branding.ts
11930
12461
  function surchargeShowsLabel(labelMode, style, position) {
11931
12462
  if (labelMode !== "labelled") return false;
@@ -12199,18 +12730,48 @@ function inputPadValue(size) {
12199
12730
  function buttonPadValue(size) {
12200
12731
  return BUTTON_PAD[size] ?? BUTTON_PAD.md;
12201
12732
  }
12202
- function vaultFormAppearance(b, danger) {
12203
- return {
12733
+ function vaultFormAppearance(b, danger, options = {}) {
12734
+ const border = b.enigmaBorder || b.border;
12735
+ const look = {
12204
12736
  surface: b.surface,
12205
12737
  text: b.text,
12206
- border: b.border,
12207
- accent: b.primary,
12738
+ border,
12739
+ accent: b.enigmaAccent || b.primary,
12208
12740
  ...danger ? { danger } : {},
12209
12741
  font: b.fontFamily,
12210
12742
  radius: b.radiusInput,
12211
12743
  size: b.inputSize,
12212
12744
  labels: b.labelStyle
12213
12745
  };
12746
+ if (!options.designed) return look;
12747
+ return {
12748
+ ...look,
12749
+ chrome: b.enigmaChrome,
12750
+ label: enigmaNamesInside(b) ? "inside" : "above",
12751
+ hints: b.enigmaHints,
12752
+ order: b.enigmaFieldOrder,
12753
+ marks: b.enigmaMarks,
12754
+ focus: b.enigmaFocusRing,
12755
+ motion: b.enigmaFieldMotion,
12756
+ height: b.enigmaFieldHeight,
12757
+ gap: b.enigmaRowGap,
12758
+ corner: b.enigmaCorner,
12759
+ fill: b.enigmaFill || enigmaDefaultFill(b.surface, b.text),
12760
+ ...b.enigmaStyleMode === "custom" ? { custom: true } : {}
12761
+ };
12762
+ }
12763
+ function enigmaDefaultFill(surface, text) {
12764
+ const channels = (hex) => {
12765
+ const v = hex.trim().replace("#", "");
12766
+ const full = v.length === 3 ? v.replace(/./g, "$&$&") : v;
12767
+ if (!/^[0-9a-fA-F]{6}$/.test(full)) return null;
12768
+ return [0, 2, 4].map((i) => parseInt(full.slice(i, i + 2), 16));
12769
+ };
12770
+ const s2 = channels(surface) ?? [255, 255, 255];
12771
+ const t = channels(text) ?? [30, 41, 59];
12772
+ return `#${s2.map(
12773
+ (value, i) => Math.round(value * 0.94 + (t[i] ?? 0) * 0.06).toString(16).padStart(2, "0")
12774
+ ).join("")}`;
12214
12775
  }
12215
12776
  function logoDimensions(size) {
12216
12777
  switch (size) {
@@ -12712,7 +13273,9 @@ var DEFAULT_BRANDING_BASE = {
12712
13273
  whopShadow: "soft",
12713
13274
  whopMethodIcons: true,
12714
13275
  whopSelection: "radio_tint",
12715
- customCss: ""
13276
+ customCss: "",
13277
+ // The Enigma Vault card form: the Stripe-like template.
13278
+ ...DEFAULT_ENIGMA_CARD_FORM
12716
13279
  };
12717
13280
  var DEFAULT_BRANDING = {
12718
13281
  ...DEFAULT_BRANDING_BASE,
@@ -13822,7 +14385,8 @@ function decodeBranding(source) {
13822
14385
  GOOGLE_PAY_BUTTON_TYPES,
13823
14386
  DEFAULT_BRANDING.nomupayGooglePayButtonType
13824
14387
  ),
13825
- customCss: s(extras["customCss"])
14388
+ customCss: s(extras["customCss"]),
14389
+ ...decodeEnigmaCardForm(extras)
13826
14390
  };
13827
14391
  }
13828
14392
  function encodeBranding(branding, base) {
@@ -13984,6 +14548,7 @@ function encodeBranding(branding, base) {
13984
14548
  if (support) extras["supportEmail"] = support;
13985
14549
  const css = trim(branding.customCss);
13986
14550
  if (css) extras["customCss"] = css;
14551
+ Object.assign(extras, encodeEnigmaCardForm(branding));
13987
14552
  const nextRules = {
13988
14553
  ...existingRules,
13989
14554
  [BRANDING_GROUP_KEY]: extras
@@ -14504,7 +15069,8 @@ function parseImportedBranding(raw) {
14504
15069
  GOOGLE_PAY_BUTTON_TYPES,
14505
15070
  dflt.nomupayGooglePayButtonType
14506
15071
  ),
14507
- customCss: sStr(root["customCss"], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH)
15072
+ customCss: sStr(root["customCss"], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH),
15073
+ ...decodeEnigmaCardForm(root)
14508
15074
  };
14509
15075
  }
14510
15076
  function isObject(v) {
@@ -14597,7 +15163,19 @@ function vaultFormQuery(params) {
14597
15163
  form_font: look?.font,
14598
15164
  form_radius: look?.radius,
14599
15165
  form_size: look?.size,
14600
- form_labels: look?.labels
15166
+ form_labels: look?.labels,
15167
+ form_chrome: look?.chrome,
15168
+ form_label: look?.label,
15169
+ form_hints: look?.hints === void 0 ? void 0 : String(look.hints),
15170
+ form_order: look?.order,
15171
+ form_marks: look?.marks,
15172
+ form_focus: look?.focus,
15173
+ form_motion: look?.motion,
15174
+ form_height: look?.height,
15175
+ form_gap: look?.gap,
15176
+ form_corner: look?.corner,
15177
+ form_fill: look?.fill,
15178
+ form_custom: look?.custom ? "true" : void 0
14601
15179
  };
14602
15180
  }
14603
15181
  function withoutHeader(headers, name) {
@@ -16096,6 +16674,8 @@ export {
16096
16674
  DelopayError,
16097
16675
  DelopayAuthenticationError,
16098
16676
  runExport,
16677
+ preventionCaseQuery,
16678
+ ChargebackPrevention,
16099
16679
  PaypalDisputes,
16100
16680
  WhopResolutionCases,
16101
16681
  Search,
@@ -16203,6 +16783,36 @@ export {
16203
16783
  WHOP_LOOKS,
16204
16784
  WHOP_LOOK_SETTINGS,
16205
16785
  matchWhopLook,
16786
+ ENIGMA_FIELD_CHROMES,
16787
+ ENIGMA_LABEL_PLACEMENTS,
16788
+ ENIGMA_LABEL_TONES,
16789
+ ENIGMA_FIELD_ORDERS,
16790
+ ENIGMA_NETWORK_MARKS,
16791
+ ENIGMA_FOCUS_RINGS,
16792
+ ENIGMA_FIELD_MOTIONS,
16793
+ ENIGMA_FIELD_HEIGHTS,
16794
+ ENIGMA_ROW_GAPS,
16795
+ ENIGMA_CORNERS,
16796
+ ENIGMA_STYLE_MODES,
16797
+ ENIGMA_OPENINGS,
16798
+ ENIGMA_CLICK_FEEDBACK,
16799
+ ENIGMA_LOADING_STYLES,
16800
+ ENIGMA_REVEALS,
16801
+ ENIGMA_PAY_FEEDBACK,
16802
+ ENIGMA_TEMPLATES,
16803
+ ENIGMA_CUSTOM_CSS_MAX_LENGTH,
16804
+ ENIGMA_CUSTOM_HEIGHT_MIN,
16805
+ ENIGMA_CUSTOM_HEIGHT_MAX,
16806
+ ENIGMA_CUSTOM_HEIGHT_DEFAULT,
16807
+ ENIGMA_TEMPLATE_PRESETS,
16808
+ DEFAULT_ENIGMA_CARD_FORM,
16809
+ applyEnigmaTemplate,
16810
+ enigmaTemplateChanges,
16811
+ enigmaNamesInside,
16812
+ enigmaCustomCssProblem,
16813
+ enigmaCornerPx,
16814
+ decodeEnigmaCardForm,
16815
+ encodeEnigmaCardForm,
16206
16816
  surchargeShowsLabel,
16207
16817
  surchargeFigurePlan,
16208
16818
  readableInkOn,
@@ -16240,6 +16850,7 @@ export {
16240
16850
  inputPadValue,
16241
16851
  buttonPadValue,
16242
16852
  vaultFormAppearance,
16853
+ enigmaDefaultFill,
16243
16854
  logoDimensions,
16244
16855
  isHexColor,
16245
16856
  WCAG_AA_TEXT,
@@ -16360,4 +16971,4 @@ export {
16360
16971
  decodeNativePanes,
16361
16972
  encodeNativePanes
16362
16973
  };
16363
- //# sourceMappingURL=chunk-MSVWVVF7.js.map
16974
+ //# sourceMappingURL=chunk-P2Q4GXEB.js.map