@usertour/helpers 0.0.14 → 0.0.17
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/dist/__tests__/attribute.test.cjs +1036 -0
- package/dist/__tests__/attribute.test.d.cts +2 -0
- package/dist/__tests__/attribute.test.d.ts +2 -0
- package/dist/__tests__/attribute.test.js +802 -0
- package/dist/__tests__/time.test.cjs +73 -0
- package/dist/__tests__/time.test.d.cts +2 -0
- package/dist/__tests__/time.test.d.ts +2 -0
- package/dist/__tests__/time.test.js +48 -0
- package/dist/__tests__/url.test.cjs +259 -0
- package/dist/__tests__/url.test.d.cts +2 -0
- package/dist/__tests__/url.test.d.ts +2 -0
- package/dist/__tests__/url.test.js +197 -0
- package/dist/{chunk-BBPZYUJR.js → chunk-4LLDSAHJ.js} +37 -1
- package/dist/chunk-7CC4WXB3.js +60 -0
- package/dist/chunk-7ODE2AIC.js +0 -0
- package/dist/{chunk-FNQIIEWK.js → chunk-BC7KXBMF.js} +5 -56
- package/dist/chunk-CEK3SCQO.js +31 -0
- package/dist/chunk-PBZSPV5R.js +239 -0
- package/dist/conditions/attribute.cjs +264 -0
- package/dist/conditions/attribute.d.cts +28 -0
- package/dist/conditions/attribute.d.ts +28 -0
- package/dist/conditions/attribute.js +9 -0
- package/dist/conditions/condition.cjs +95 -0
- package/dist/{condition.d.cts → conditions/condition.d.cts} +1 -2
- package/dist/{condition.d.ts → conditions/condition.d.ts} +1 -2
- package/dist/conditions/condition.js +9 -0
- package/dist/conditions/index.cjs +379 -0
- package/dist/conditions/index.d.cts +6 -0
- package/dist/conditions/index.d.ts +6 -0
- package/dist/conditions/index.js +24 -0
- package/dist/conditions/time.cjs +55 -0
- package/dist/conditions/time.d.cts +10 -0
- package/dist/conditions/time.d.ts +10 -0
- package/dist/conditions/time.js +7 -0
- package/dist/{condition.cjs → conditions/url.cjs} +9 -71
- package/dist/conditions/url.d.cts +6 -0
- package/dist/conditions/url.d.ts +6 -0
- package/dist/conditions/url.js +9 -0
- package/dist/content.cjs +36 -0
- package/dist/content.d.cts +4 -2
- package/dist/content.d.ts +4 -2
- package/dist/content.js +5 -1
- package/dist/index.cjs +328 -504
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +44 -61
- package/package.json +15 -9
- package/dist/chunk-64BFWPHJ.js +0 -50
- package/dist/chunk-SYVTGB2A.js +0 -462
- package/dist/condition.js +0 -11
- package/dist/conditions.cjs +0 -615
- package/dist/conditions.d.cts +0 -35
- package/dist/conditions.d.ts +0 -35
- package/dist/conditions.js +0 -50
- package/dist/content-settings.cjs +0 -76
- package/dist/content-settings.d.cts +0 -7
- package/dist/content-settings.d.ts +0 -7
- package/dist/content-settings.js +0 -11
package/dist/index.cjs
CHANGED
|
@@ -39,13 +39,8 @@ __export(src_exports, {
|
|
|
39
39
|
ArrayProto: () => ArrayProto,
|
|
40
40
|
XMLHttpRequest: () => XMLHttpRequest,
|
|
41
41
|
absoluteUrl: () => absoluteUrl,
|
|
42
|
-
activedContentRulesConditions: () => activedContentRulesConditions,
|
|
43
|
-
activedRulesConditions: () => activedRulesConditions,
|
|
44
42
|
assignableWindow: () => assignableWindow,
|
|
45
|
-
autoStartConditions: () => autoStartConditions,
|
|
46
43
|
buildConfig: () => buildConfig,
|
|
47
|
-
checklistIsDimissed: () => checklistIsDimissed,
|
|
48
|
-
checklistIsSeen: () => checklistIsSeen,
|
|
49
44
|
cn: () => cn,
|
|
50
45
|
conditionsIsSame: () => conditionsIsSame,
|
|
51
46
|
convertSettings: () => convertSettings,
|
|
@@ -56,11 +51,10 @@ __export(src_exports, {
|
|
|
56
51
|
defaultStep: () => defaultStep,
|
|
57
52
|
document: () => document,
|
|
58
53
|
evalCode: () => evalCode,
|
|
54
|
+
evaluateAttributeCondition: () => evaluateAttributeCondition,
|
|
55
|
+
evaluateTimeCondition: () => evaluateTimeCondition,
|
|
56
|
+
evaluateUrlCondition: () => evaluateUrlCondition,
|
|
59
57
|
fetch: () => fetch,
|
|
60
|
-
filterAutoStartContent: () => filterAutoStartContent,
|
|
61
|
-
findLatestEvent: () => findLatestEvent,
|
|
62
|
-
flowIsDismissed: () => flowIsDismissed,
|
|
63
|
-
flowIsSeen: () => flowIsSeen,
|
|
64
58
|
formatDate: () => formatDate,
|
|
65
59
|
generateAutoStateColors: () => generateAutoStateColors,
|
|
66
60
|
getAuthToken: () => getAuthToken,
|
|
@@ -83,8 +77,6 @@ __export(src_exports, {
|
|
|
83
77
|
hexToHSLString: () => hexToHSLString,
|
|
84
78
|
hexToRGBStr: () => hexToRGBStr,
|
|
85
79
|
hexToRgb: () => hexToRgb,
|
|
86
|
-
isActive: () => isActive,
|
|
87
|
-
isActiveRulesByCurrentTime: () => isActiveRulesByCurrentTime,
|
|
88
80
|
isArray: () => isArray,
|
|
89
81
|
isBoolean: () => isBoolean,
|
|
90
82
|
isDark: () => isDark,
|
|
@@ -107,14 +99,12 @@ __export(src_exports, {
|
|
|
107
99
|
isUint8Array: () => isUint8Array,
|
|
108
100
|
isUndefined: () => isUndefined,
|
|
109
101
|
isUrl: () => isUrl,
|
|
110
|
-
isValidContent: () => isValidContent,
|
|
111
102
|
isValidSelector: () => isValidSelector,
|
|
112
|
-
location: () =>
|
|
103
|
+
location: () => location,
|
|
113
104
|
mergeThemeDefaultSettings: () => mergeThemeDefaultSettings,
|
|
114
105
|
nativeForEach: () => nativeForEach,
|
|
115
106
|
nativeIndexOf: () => nativeIndexOf,
|
|
116
107
|
navigator: () => navigator,
|
|
117
|
-
parseUrlParams: () => parseUrlParams,
|
|
118
108
|
removeAuthToken: () => removeAuthToken,
|
|
119
109
|
setAuthToken: () => setAuthToken,
|
|
120
110
|
storage: () => storage,
|
|
@@ -453,169 +443,8 @@ var convertToCssVars = (settings, type = "tooltip") => {
|
|
|
453
443
|
return css;
|
|
454
444
|
};
|
|
455
445
|
|
|
456
|
-
// src/condition.ts
|
|
457
|
-
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
458
|
-
var parseUrl = (url) => {
|
|
459
|
-
const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
|
|
460
|
-
if (!urlPatterns) {
|
|
461
|
-
return null;
|
|
462
|
-
}
|
|
463
|
-
const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
|
|
464
|
-
return { scheme, domain, path, query, fragment };
|
|
465
|
-
};
|
|
466
|
-
var replaceWildcard = (input, s1, s2) => {
|
|
467
|
-
const withSpecialWords = replaceSpecialWords(input);
|
|
468
|
-
const withWildcard = withSpecialWords.replace(/\\\*/g, `${s1}*`);
|
|
469
|
-
if (!s2) {
|
|
470
|
-
return withWildcard;
|
|
471
|
-
}
|
|
472
|
-
return withWildcard.replace(/:[a-z0-9_]+/g, `[^${s2}]+`);
|
|
473
|
-
};
|
|
474
|
-
var replaceSpecialWords = (str) => {
|
|
475
|
-
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
476
|
-
};
|
|
477
|
-
var parsePattern = (pattern) => {
|
|
478
|
-
if (!pattern || !pattern.trim()) {
|
|
479
|
-
return null;
|
|
480
|
-
}
|
|
481
|
-
const _pattern = parseUrl(pattern);
|
|
482
|
-
if (!_pattern) {
|
|
483
|
-
console.error("Invalid URL pattern:", pattern);
|
|
484
|
-
return null;
|
|
485
|
-
}
|
|
486
|
-
const { scheme, domain, path, query, fragment } = _pattern;
|
|
487
|
-
const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
|
|
488
|
-
const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
|
|
489
|
-
const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
|
|
490
|
-
const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
|
|
491
|
-
let _query = "(\\?[^#]*)?";
|
|
492
|
-
if (query) {
|
|
493
|
-
new URLSearchParams(query).forEach((value, key) => {
|
|
494
|
-
const _str = value === "" ? "=?" : value === "*" ? "(=[^&#]*)?" : `=${replaceWildcard(value, "[^#]")}`;
|
|
495
|
-
_query += `(?=.*[?&]${replaceSpecialWords(key)}${_str}([&#]|$))`;
|
|
496
|
-
});
|
|
497
|
-
_query += "\\?[^#]*";
|
|
498
|
-
}
|
|
499
|
-
return new RegExp(`^${_scheme}://${_domain}(:\\d+)?${_path}${_query}${_fragment}$`);
|
|
500
|
-
};
|
|
501
|
-
var isMatchUrlPattern = (_url, includes, excludes) => {
|
|
502
|
-
const isMatchIncludesConditions = includes.length > 0 ? includes.some((_include) => {
|
|
503
|
-
const reg = parsePattern(_include);
|
|
504
|
-
if (reg) {
|
|
505
|
-
return reg.test(_url);
|
|
506
|
-
}
|
|
507
|
-
return false;
|
|
508
|
-
}) : true;
|
|
509
|
-
const isMatchExcludesConditions = excludes.length > 0 ? excludes.some((_exclude) => {
|
|
510
|
-
const reg = parsePattern(_exclude);
|
|
511
|
-
if (reg) {
|
|
512
|
-
return reg.test(_url);
|
|
513
|
-
}
|
|
514
|
-
return false;
|
|
515
|
-
}) : false;
|
|
516
|
-
return isMatchIncludesConditions && !isMatchExcludesConditions;
|
|
517
|
-
};
|
|
518
|
-
var compareConditionsItem = (item1, item2) => {
|
|
519
|
-
const { data = {}, ...others1 } = item1;
|
|
520
|
-
const { data: data2 = {}, ...others2 } = item2;
|
|
521
|
-
if (!(0, import_fast_deep_equal.default)(others2, others1)) {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
|
-
for (const key in data) {
|
|
525
|
-
if (!(0, import_fast_deep_equal.default)(data[key], data2[key])) {
|
|
526
|
-
return false;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
return true;
|
|
530
|
-
};
|
|
531
|
-
var conditionsIsSame = (rr1, rr2) => {
|
|
532
|
-
const r1 = [...rr1];
|
|
533
|
-
const r2 = [...rr2];
|
|
534
|
-
if (r1.length === 0 && r2.length === 0) {
|
|
535
|
-
return true;
|
|
536
|
-
}
|
|
537
|
-
if (r1.length !== r2.length) {
|
|
538
|
-
return false;
|
|
539
|
-
}
|
|
540
|
-
const group1 = r1.filter((item) => item.type === "group");
|
|
541
|
-
const group2 = r2.filter((item) => item.type === "group");
|
|
542
|
-
if (group1.length !== group2.length) {
|
|
543
|
-
return false;
|
|
544
|
-
}
|
|
545
|
-
for (let index = 0; index < r1.length; index++) {
|
|
546
|
-
const item1 = r1[index];
|
|
547
|
-
const item2 = r2[index];
|
|
548
|
-
if (!item1 || !item2) {
|
|
549
|
-
return false;
|
|
550
|
-
}
|
|
551
|
-
if (item1.type === "group") {
|
|
552
|
-
if (!item2.conditions) {
|
|
553
|
-
return false;
|
|
554
|
-
}
|
|
555
|
-
const c1 = item1.conditions;
|
|
556
|
-
const c2 = item2.conditions;
|
|
557
|
-
if (item1.operators !== item2.operators) {
|
|
558
|
-
return false;
|
|
559
|
-
}
|
|
560
|
-
if (!conditionsIsSame(c1, c2)) {
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
} else {
|
|
564
|
-
if (!compareConditionsItem(item1, item2)) {
|
|
565
|
-
return false;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
return true;
|
|
570
|
-
};
|
|
571
|
-
|
|
572
|
-
// src/content-settings.ts
|
|
573
|
-
var import_types2 = require("@usertour/types");
|
|
574
|
-
var import_deepmerge_ts2 = require("deepmerge-ts");
|
|
575
|
-
var rulesSetting = {
|
|
576
|
-
// frequency: {
|
|
577
|
-
// frequency: Frequency.ONCE,
|
|
578
|
-
// every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
|
|
579
|
-
// atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
|
|
580
|
-
// },
|
|
581
|
-
startIfNotComplete: false,
|
|
582
|
-
priority: import_types2.ContentPriority.MEDIUM,
|
|
583
|
-
wait: 0
|
|
584
|
-
};
|
|
585
|
-
var hideRulesSetting = {};
|
|
586
|
-
var defaultContentConfig = {
|
|
587
|
-
enabledAutoStartRules: false,
|
|
588
|
-
enabledHideRules: false,
|
|
589
|
-
autoStartRules: [],
|
|
590
|
-
hideRules: [],
|
|
591
|
-
autoStartRulesSetting: rulesSetting,
|
|
592
|
-
hideRulesSetting
|
|
593
|
-
};
|
|
594
|
-
var autoStartConditions = {
|
|
595
|
-
...defaultContentConfig,
|
|
596
|
-
enabledAutoStartRules: true,
|
|
597
|
-
autoStartRules: [
|
|
598
|
-
{
|
|
599
|
-
data: { excludes: [], includes: ["/*"] },
|
|
600
|
-
type: "current-page",
|
|
601
|
-
operators: "and"
|
|
602
|
-
}
|
|
603
|
-
]
|
|
604
|
-
};
|
|
605
|
-
var buildConfig = (config) => {
|
|
606
|
-
return {
|
|
607
|
-
...defaultContentConfig,
|
|
608
|
-
...config,
|
|
609
|
-
autoStartRulesSetting: (0, import_deepmerge_ts2.deepmerge)(
|
|
610
|
-
defaultContentConfig.autoStartRulesSetting,
|
|
611
|
-
(config == null ? void 0 : config.autoStartRulesSetting) || {}
|
|
612
|
-
),
|
|
613
|
-
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
614
|
-
};
|
|
615
|
-
};
|
|
616
|
-
|
|
617
446
|
// src/error.ts
|
|
618
|
-
var
|
|
447
|
+
var import_types2 = require("@usertour/types");
|
|
619
448
|
var isValidSelector = (selector) => {
|
|
620
449
|
if (!selector) {
|
|
621
450
|
return false;
|
|
@@ -637,9 +466,9 @@ var getUserAttrError = (data, attributes) => {
|
|
|
637
466
|
} else if ((data == null ? void 0 : data.logic) === "between" && (!(data == null ? void 0 : data.value) || !(data == null ? void 0 : data.value2))) {
|
|
638
467
|
ret.showError = true;
|
|
639
468
|
ret.errorInfo = "Please enter a value";
|
|
640
|
-
} else if ((item == null ? void 0 : item.dataType) !==
|
|
469
|
+
} else if ((item == null ? void 0 : item.dataType) !== import_types2.AttributeDataType.Boolean) {
|
|
641
470
|
if (data.logic !== "any" && data.logic !== "empty") {
|
|
642
|
-
if ((item == null ? void 0 : item.dataType) ===
|
|
471
|
+
if ((item == null ? void 0 : item.dataType) === import_types2.AttributeDataType.List) {
|
|
643
472
|
if (!data.listValues || data.listValues.length === 0) {
|
|
644
473
|
ret.showError = true;
|
|
645
474
|
ret.errorInfo = "Please enter a value";
|
|
@@ -777,10 +606,10 @@ var hasError = (conds, attributes) => {
|
|
|
777
606
|
return false;
|
|
778
607
|
};
|
|
779
608
|
var errorActionHandlerMapping = {
|
|
780
|
-
[
|
|
781
|
-
[
|
|
782
|
-
[
|
|
783
|
-
[
|
|
609
|
+
[import_types2.ContentActionsItemType.STEP_GOTO]: getStepError,
|
|
610
|
+
[import_types2.ContentActionsItemType.PAGE_NAVIGATE]: getNavitateError,
|
|
611
|
+
[import_types2.ContentActionsItemType.FLOW_START]: getContentError,
|
|
612
|
+
[import_types2.ContentActionsItemType.JAVASCRIPT_EVALUATE]: getCodeError
|
|
784
613
|
};
|
|
785
614
|
var hasActionError = (conds) => {
|
|
786
615
|
for (const cond of conds) {
|
|
@@ -824,7 +653,7 @@ var nativeForEach = ArrayProto.forEach;
|
|
|
824
653
|
var nativeIndexOf = ArrayProto.indexOf;
|
|
825
654
|
var navigator = global == null ? void 0 : global.navigator;
|
|
826
655
|
var document = global == null ? void 0 : global.document;
|
|
827
|
-
var
|
|
656
|
+
var location = global == null ? void 0 : global.location;
|
|
828
657
|
var fetch = global == null ? void 0 : global.fetch;
|
|
829
658
|
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
830
659
|
var AbortController = global == null ? void 0 : global.AbortController;
|
|
@@ -998,6 +827,8 @@ function isUrl(string) {
|
|
|
998
827
|
}
|
|
999
828
|
|
|
1000
829
|
// src/content.ts
|
|
830
|
+
var import_types3 = require("@usertour/types");
|
|
831
|
+
var import_deepmerge_ts2 = require("deepmerge-ts");
|
|
1001
832
|
var isPublishedInAllEnvironments = (content, environmentList, version) => {
|
|
1002
833
|
const isPublishedInAllEnvironments2 = environmentList == null ? void 0 : environmentList.every(
|
|
1003
834
|
(env) => {
|
|
@@ -1020,6 +851,36 @@ var isPublishedAtLeastOneEnvironment = (content) => {
|
|
|
1020
851
|
}
|
|
1021
852
|
return false;
|
|
1022
853
|
};
|
|
854
|
+
var rulesSetting = {
|
|
855
|
+
// frequency: {
|
|
856
|
+
// frequency: Frequency.ONCE,
|
|
857
|
+
// every: { duration: 0, times: 1, unit: FrequencyUnits.MINUTES },
|
|
858
|
+
// atLeast: { duration: 0, unit: FrequencyUnits.MINUTES },
|
|
859
|
+
// },
|
|
860
|
+
startIfNotComplete: false,
|
|
861
|
+
priority: import_types3.ContentPriority.MEDIUM,
|
|
862
|
+
wait: 0
|
|
863
|
+
};
|
|
864
|
+
var hideRulesSetting = {};
|
|
865
|
+
var defaultContentConfig = {
|
|
866
|
+
enabledAutoStartRules: false,
|
|
867
|
+
enabledHideRules: false,
|
|
868
|
+
autoStartRules: [],
|
|
869
|
+
hideRules: [],
|
|
870
|
+
autoStartRulesSetting: rulesSetting,
|
|
871
|
+
hideRulesSetting
|
|
872
|
+
};
|
|
873
|
+
var buildConfig = (config) => {
|
|
874
|
+
return {
|
|
875
|
+
...defaultContentConfig,
|
|
876
|
+
...config,
|
|
877
|
+
autoStartRulesSetting: (0, import_deepmerge_ts2.deepmerge)(
|
|
878
|
+
defaultContentConfig.autoStartRulesSetting,
|
|
879
|
+
(config == null ? void 0 : config.autoStartRulesSetting) || {}
|
|
880
|
+
),
|
|
881
|
+
hideRulesSetting: (config == null ? void 0 : config.hideRulesSetting) || {}
|
|
882
|
+
};
|
|
883
|
+
};
|
|
1023
884
|
|
|
1024
885
|
// src/utils.ts
|
|
1025
886
|
var deepClone = (obj) => {
|
|
@@ -1099,375 +960,343 @@ var getRandomColor = () => {
|
|
|
1099
960
|
return colors[Math.floor(Math.random() * colors.length)];
|
|
1100
961
|
};
|
|
1101
962
|
|
|
1102
|
-
// src/conditions.ts
|
|
1103
|
-
var
|
|
1104
|
-
var
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
import_types4.ContentPriority.MEDIUM,
|
|
1109
|
-
import_types4.ContentPriority.LOW,
|
|
1110
|
-
import_types4.ContentPriority.LOWEST
|
|
1111
|
-
];
|
|
1112
|
-
var rulesTypes = Object.values(import_types4.RulesType);
|
|
1113
|
-
var isActiveRulesByCurrentPage = (rules) => {
|
|
1114
|
-
const { excludes, includes } = rules.data;
|
|
1115
|
-
if (location) {
|
|
1116
|
-
const href = location.href;
|
|
1117
|
-
return isMatchUrlPattern(href, includes, excludes);
|
|
1118
|
-
}
|
|
1119
|
-
return false;
|
|
1120
|
-
};
|
|
1121
|
-
var isActiveRulesByCurrentTime = (rules) => {
|
|
1122
|
-
const { endDate, endDateHour, endDateMinute, startDate, startDateHour, startDateMinute } = rules.data;
|
|
1123
|
-
const startTime = /* @__PURE__ */ new Date(`${startDate} ${startDateHour}:${startDateMinute}:00`);
|
|
1124
|
-
const endTime = /* @__PURE__ */ new Date(`${endDate} ${endDateHour}:${endDateMinute}:00`);
|
|
1125
|
-
const now = /* @__PURE__ */ new Date();
|
|
1126
|
-
if (!endDate) {
|
|
1127
|
-
return (0, import_date_fns.isAfter)(now, startTime);
|
|
1128
|
-
}
|
|
1129
|
-
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
1130
|
-
};
|
|
1131
|
-
var isActivedContentRulesCondition = (rules, contentSession) => {
|
|
1132
|
-
const { contentId, logic } = rules.data;
|
|
1133
|
-
const { latestSession, seenSessions, completedSessions } = contentSession;
|
|
1134
|
-
if (!contentId || !logic || contentId !== contentSession.contentId) {
|
|
963
|
+
// src/conditions/condition.ts
|
|
964
|
+
var import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1);
|
|
965
|
+
var compareConditionsItem = (item1, item2) => {
|
|
966
|
+
const { data = {}, ...others1 } = item1;
|
|
967
|
+
const { data: data2 = {}, ...others2 } = item2;
|
|
968
|
+
if (!(0, import_fast_deep_equal.default)(others2, others1)) {
|
|
1135
969
|
return false;
|
|
1136
970
|
}
|
|
1137
|
-
|
|
1138
|
-
if (!
|
|
1139
|
-
return
|
|
971
|
+
for (const key in data) {
|
|
972
|
+
if (!(0, import_fast_deep_equal.default)(data[key], data2[key])) {
|
|
973
|
+
return false;
|
|
1140
974
|
}
|
|
1141
|
-
const isActived = !(flowIsDismissed(latestSession) || checklistIsDimissed(latestSession));
|
|
1142
|
-
return logic === import_types4.ContentConditionLogic.ACTIVED ? isActived : !isActived;
|
|
1143
|
-
}
|
|
1144
|
-
const isSeen = seenSessions > 0;
|
|
1145
|
-
const isCompleted = completedSessions > 0;
|
|
1146
|
-
if (logic === import_types4.ContentConditionLogic.SEEN || logic === import_types4.ContentConditionLogic.UNSEEN) {
|
|
1147
|
-
return logic === import_types4.ContentConditionLogic.SEEN ? isSeen : !isSeen;
|
|
1148
|
-
}
|
|
1149
|
-
if (logic === import_types4.ContentConditionLogic.COMPLETED || logic === import_types4.ContentConditionLogic.UNCOMPLETED) {
|
|
1150
|
-
return logic === import_types4.ContentConditionLogic.COMPLETED ? isCompleted : !isCompleted;
|
|
1151
975
|
}
|
|
1152
|
-
return
|
|
1153
|
-
};
|
|
1154
|
-
var isValidRulesType = (type) => {
|
|
1155
|
-
return rulesTypes.includes(type);
|
|
976
|
+
return true;
|
|
1156
977
|
};
|
|
1157
|
-
var
|
|
1158
|
-
|
|
978
|
+
var conditionsIsSame = (rr1, rr2) => {
|
|
979
|
+
const r1 = [...rr1];
|
|
980
|
+
const r2 = [...rr2];
|
|
981
|
+
if (r1.length === 0 && r2.length === 0) {
|
|
1159
982
|
return true;
|
|
1160
983
|
}
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
return isActiveRulesByCurrentPage(rules);
|
|
1164
|
-
case import_types4.RulesType.TIME:
|
|
1165
|
-
return isActiveRulesByCurrentTime(rules);
|
|
1166
|
-
default:
|
|
1167
|
-
return rules.actived;
|
|
984
|
+
if (r1.length !== r2.length) {
|
|
985
|
+
return false;
|
|
1168
986
|
}
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
const rules = rulesCondition[j];
|
|
1174
|
-
if (rules.type !== "group") {
|
|
1175
|
-
if (rewrite == null ? void 0 : rewrite[rules.type]) {
|
|
1176
|
-
rulesCondition[j].actived = true;
|
|
1177
|
-
} else {
|
|
1178
|
-
rulesCondition[j].actived = await isActiveRules(rules);
|
|
1179
|
-
}
|
|
1180
|
-
} else if (rules.conditions) {
|
|
1181
|
-
rulesCondition[j].conditions = await activedRulesConditions(rules.conditions);
|
|
1182
|
-
}
|
|
987
|
+
const group1 = r1.filter((item) => item.type === "group");
|
|
988
|
+
const group2 = r2.filter((item) => item.type === "group");
|
|
989
|
+
if (group1.length !== group2.length) {
|
|
990
|
+
return false;
|
|
1183
991
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
if (
|
|
1191
|
-
if (
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
992
|
+
for (let index = 0; index < r1.length; index++) {
|
|
993
|
+
const item1 = r1[index];
|
|
994
|
+
const item2 = r2[index];
|
|
995
|
+
if (!item1 || !item2) {
|
|
996
|
+
return false;
|
|
997
|
+
}
|
|
998
|
+
if (item1.type === "group") {
|
|
999
|
+
if (!item2.conditions) {
|
|
1000
|
+
return false;
|
|
1001
|
+
}
|
|
1002
|
+
const c1 = item1.conditions;
|
|
1003
|
+
const c2 = item2.conditions;
|
|
1004
|
+
if (item1.operators !== item2.operators) {
|
|
1005
|
+
return false;
|
|
1006
|
+
}
|
|
1007
|
+
if (!conditionsIsSame(c1, c2)) {
|
|
1008
|
+
return false;
|
|
1009
|
+
}
|
|
1010
|
+
} else {
|
|
1011
|
+
if (!compareConditionsItem(item1, item2)) {
|
|
1012
|
+
return false;
|
|
1204
1013
|
}
|
|
1205
|
-
} else if (rules.conditions) {
|
|
1206
|
-
rulesCondition[j].conditions = await activedContentRulesConditions(
|
|
1207
|
-
rules.conditions,
|
|
1208
|
-
contents
|
|
1209
|
-
);
|
|
1210
1014
|
}
|
|
1211
1015
|
}
|
|
1212
|
-
return
|
|
1016
|
+
return true;
|
|
1213
1017
|
};
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1018
|
+
|
|
1019
|
+
// src/conditions/url.ts
|
|
1020
|
+
var parseUrl = (url) => {
|
|
1021
|
+
const urlPatterns = url.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);
|
|
1022
|
+
if (!urlPatterns) {
|
|
1023
|
+
return null;
|
|
1217
1024
|
}
|
|
1218
|
-
const
|
|
1219
|
-
|
|
1220
|
-
if (!rule.conditions) {
|
|
1221
|
-
return rule.actived;
|
|
1222
|
-
}
|
|
1223
|
-
return isActive(rule.conditions);
|
|
1224
|
-
});
|
|
1225
|
-
return operator === "and" ? actives.length === autoStartRules.length : actives.length > 0;
|
|
1025
|
+
const [, , scheme = "", domain = "", path = "", , query = "", fragment = ""] = urlPatterns;
|
|
1026
|
+
return { scheme, domain, path, query, fragment };
|
|
1226
1027
|
};
|
|
1227
|
-
var
|
|
1228
|
-
const
|
|
1229
|
-
|
|
1230
|
-
|
|
1028
|
+
var replaceWildcard = (input, s1, s2) => {
|
|
1029
|
+
const withSpecialWords = replaceSpecialWords(input);
|
|
1030
|
+
const withWildcard = withSpecialWords.replace(/\\\*/g, `${s1}*`);
|
|
1031
|
+
if (!s2) {
|
|
1032
|
+
return withWildcard;
|
|
1231
1033
|
}
|
|
1232
|
-
return
|
|
1034
|
+
return withWildcard.replace(/:[a-z0-9_]+/g, `[^${s2}]+`);
|
|
1233
1035
|
};
|
|
1234
|
-
var
|
|
1235
|
-
|
|
1236
|
-
const a1 = (_b = (_a = a == null ? void 0 : a.config) == null ? void 0 : _a.autoStartRulesSetting) == null ? void 0 : _b.priority;
|
|
1237
|
-
const a2 = (_d = (_c = b == null ? void 0 : b.config) == null ? void 0 : _c.autoStartRulesSetting) == null ? void 0 : _d.priority;
|
|
1238
|
-
if (!a1 || !a2) {
|
|
1239
|
-
return 0;
|
|
1240
|
-
}
|
|
1241
|
-
const index1 = PRIORITIES.indexOf(a1);
|
|
1242
|
-
const index2 = PRIORITIES.indexOf(a2);
|
|
1243
|
-
if (index1 > index2) {
|
|
1244
|
-
return 1;
|
|
1245
|
-
}
|
|
1246
|
-
if (index1 < index2) {
|
|
1247
|
-
return -1;
|
|
1248
|
-
}
|
|
1249
|
-
return 0;
|
|
1036
|
+
var replaceSpecialWords = (str) => {
|
|
1037
|
+
return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
1250
1038
|
};
|
|
1251
|
-
var
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1039
|
+
var parsePattern = (pattern) => {
|
|
1040
|
+
if (!pattern || !pattern.trim()) {
|
|
1041
|
+
return null;
|
|
1042
|
+
}
|
|
1043
|
+
const _pattern = parseUrl(pattern);
|
|
1044
|
+
if (!_pattern) {
|
|
1045
|
+
console.error("Invalid URL pattern:", pattern);
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
const { scheme, domain, path, query, fragment } = _pattern;
|
|
1049
|
+
const _scheme = scheme ? replaceSpecialWords(scheme) : "[a-z\\d]+";
|
|
1050
|
+
const _domain = domain ? replaceWildcard(domain, "[^/]", ".") : "[^/]*";
|
|
1051
|
+
const _fragment = fragment ? replaceWildcard(fragment, ".", "/") : "(#.*)?";
|
|
1052
|
+
const _path = path ? replaceWildcard(path, "[^?#]", "/") : "/[^?#]*";
|
|
1053
|
+
let _query = "(\\?[^#]*)?";
|
|
1054
|
+
if (query) {
|
|
1055
|
+
new URLSearchParams(query).forEach((value, key) => {
|
|
1056
|
+
const _str = value === "" ? "=?" : value === "*" ? "(=[^&#]*)?" : `=${replaceWildcard(value, "[^#]")}`;
|
|
1057
|
+
_query += `(?=.*[?&]${replaceSpecialWords(key)}${_str}([&#]|$))`;
|
|
1058
|
+
});
|
|
1059
|
+
_query += "\\?[^#]*";
|
|
1060
|
+
}
|
|
1061
|
+
return new RegExp(`^${_scheme}://${_domain}(:\\d+)?${_path}${_query}${_fragment}$`);
|
|
1257
1062
|
};
|
|
1258
|
-
var
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
for (let index = 0; index < contents.length; index++) {
|
|
1264
|
-
const content = contents[index];
|
|
1265
|
-
if (content.id === contentId || content.type !== contentType) {
|
|
1266
|
-
continue;
|
|
1063
|
+
var isMatchUrlPattern = (_url, includes, excludes) => {
|
|
1064
|
+
const isMatchIncludesConditions = includes.length > 0 ? includes.some((_include) => {
|
|
1065
|
+
const reg = parsePattern(_include);
|
|
1066
|
+
if (reg) {
|
|
1067
|
+
return reg.test(_url);
|
|
1267
1068
|
}
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1069
|
+
return false;
|
|
1070
|
+
}) : true;
|
|
1071
|
+
const isMatchExcludesConditions = excludes.length > 0 ? excludes.some((_exclude) => {
|
|
1072
|
+
const reg = parsePattern(_exclude);
|
|
1073
|
+
if (reg) {
|
|
1074
|
+
return reg.test(_url);
|
|
1274
1075
|
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
var findLatestEvent = (bizEvents) => {
|
|
1279
|
-
const initialValue = bizEvents[0];
|
|
1280
|
-
const lastEvent = bizEvents.reduce(
|
|
1281
|
-
(accumulator, currentValue) => {
|
|
1282
|
-
if ((0, import_date_fns.isAfter)(new Date(currentValue.createdAt), new Date(accumulator.createdAt))) {
|
|
1283
|
-
return currentValue;
|
|
1284
|
-
}
|
|
1285
|
-
return accumulator;
|
|
1286
|
-
},
|
|
1287
|
-
initialValue
|
|
1288
|
-
);
|
|
1289
|
-
return lastEvent;
|
|
1290
|
-
};
|
|
1291
|
-
var completeEventMapping = {
|
|
1292
|
-
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_COMPLETED,
|
|
1293
|
-
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_ACTIVATED,
|
|
1294
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_COMPLETED
|
|
1295
|
-
};
|
|
1296
|
-
var showEventMapping = {
|
|
1297
|
-
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_STEP_SEEN,
|
|
1298
|
-
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_SEEN,
|
|
1299
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_SEEN
|
|
1076
|
+
return false;
|
|
1077
|
+
}) : false;
|
|
1078
|
+
return isMatchIncludesConditions && !isMatchExcludesConditions;
|
|
1300
1079
|
};
|
|
1301
|
-
var
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_DISMISSED
|
|
1080
|
+
var evaluateUrlCondition = (rules, url) => {
|
|
1081
|
+
const { excludes, includes } = rules.data;
|
|
1082
|
+
return isMatchUrlPattern(url, includes, excludes);
|
|
1305
1083
|
};
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1084
|
+
|
|
1085
|
+
// src/conditions/time.ts
|
|
1086
|
+
var import_date_fns = require("date-fns");
|
|
1087
|
+
var evaluateTimeCondition = (rules) => {
|
|
1088
|
+
try {
|
|
1089
|
+
const { endDate, endDateHour, endDateMinute, startDate, startDateHour, startDateMinute } = rules.data || {};
|
|
1090
|
+
if (!startDate || !startDateHour || !startDateMinute) {
|
|
1312
1091
|
return false;
|
|
1313
1092
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
}
|
|
1318
|
-
return false;
|
|
1319
|
-
case import_types4.FrequencyUnits.HOURS:
|
|
1320
|
-
if ((0, import_date_fns.differenceInHours)(dateLeft, dateRight) >= duration) {
|
|
1321
|
-
return true;
|
|
1322
|
-
}
|
|
1323
|
-
return false;
|
|
1324
|
-
case import_types4.FrequencyUnits.DAYES:
|
|
1325
|
-
if ((0, import_date_fns.differenceInDays)(dateLeft, dateRight) >= duration) {
|
|
1326
|
-
return true;
|
|
1327
|
-
}
|
|
1093
|
+
const startTimeString = `${startDate}T${startDateHour.padStart(2, "0")}:${startDateMinute.padStart(2, "0")}:00`;
|
|
1094
|
+
const startTime = (0, import_date_fns.parseISO)(startTimeString);
|
|
1095
|
+
if (!(0, import_date_fns.isValid)(startTime)) {
|
|
1328
1096
|
return false;
|
|
1329
|
-
default:
|
|
1330
|
-
return false;
|
|
1331
|
-
}
|
|
1332
|
-
};
|
|
1333
|
-
var checklistIsDimissed = (latestSession) => {
|
|
1334
|
-
var _a;
|
|
1335
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
1336
|
-
(event) => {
|
|
1337
|
-
var _a2;
|
|
1338
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_DISMISSED;
|
|
1339
1097
|
}
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
var _a;
|
|
1344
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find((event) => {
|
|
1345
|
-
var _a2;
|
|
1346
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_ENDED;
|
|
1347
|
-
});
|
|
1348
|
-
};
|
|
1349
|
-
var flowIsSeen = (latestSession) => {
|
|
1350
|
-
var _a;
|
|
1351
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
1352
|
-
(event) => {
|
|
1353
|
-
var _a2;
|
|
1354
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_STEP_SEEN;
|
|
1098
|
+
const now = /* @__PURE__ */ new Date();
|
|
1099
|
+
if (!endDate || !endDateHour || !endDateMinute) {
|
|
1100
|
+
return (0, import_date_fns.isAfter)(now, startTime);
|
|
1355
1101
|
}
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
var _a;
|
|
1360
|
-
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
1361
|
-
(event) => {
|
|
1362
|
-
var _a2;
|
|
1363
|
-
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_SEEN;
|
|
1364
|
-
}
|
|
1365
|
-
);
|
|
1366
|
-
};
|
|
1367
|
-
var isValidContent = (content, contents) => {
|
|
1368
|
-
var _a;
|
|
1369
|
-
const now = /* @__PURE__ */ new Date();
|
|
1370
|
-
if (content.type === import_types4.ContentDataType.FLOW) {
|
|
1371
|
-
if (!content.steps || content.steps.length === 0) {
|
|
1102
|
+
const endTimeString = `${endDate}T${endDateHour.padStart(2, "0")}:${endDateMinute.padStart(2, "0")}:00`;
|
|
1103
|
+
const endTime = (0, import_date_fns.parseISO)(endTimeString);
|
|
1104
|
+
if (!(0, import_date_fns.isValid)(endTime)) {
|
|
1372
1105
|
return false;
|
|
1373
1106
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
if (!content.config.autoStartRulesSetting) {
|
|
1380
|
-
return true;
|
|
1107
|
+
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
1108
|
+
} catch {
|
|
1109
|
+
return false;
|
|
1381
1110
|
}
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
// src/conditions/attribute.ts
|
|
1114
|
+
var import_types4 = require("@usertour/types");
|
|
1115
|
+
var import_date_fns2 = require("date-fns");
|
|
1116
|
+
function evaluateAttributeCondition(condition, attributes, userAttributes) {
|
|
1117
|
+
const { data } = condition;
|
|
1118
|
+
if (!data) {
|
|
1386
1119
|
return false;
|
|
1387
1120
|
}
|
|
1388
|
-
|
|
1389
|
-
|
|
1121
|
+
const { logic, value, attrId, value2, listValues = [] } = data;
|
|
1122
|
+
if (!attrId) {
|
|
1123
|
+
return false;
|
|
1390
1124
|
}
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
const lastEvent = getLatestEvent(content, contents, lastEventName);
|
|
1394
|
-
const contentEvents = (_a = content.latestSession) == null ? void 0 : _a.bizEvent;
|
|
1395
|
-
if (lastEvent && frequency && frequency.atLeast && !isGreaterThenDuration(
|
|
1396
|
-
now,
|
|
1397
|
-
new Date(lastEvent.createdAt),
|
|
1398
|
-
frequency.atLeast.unit,
|
|
1399
|
-
frequency.atLeast.duration
|
|
1400
|
-
)) {
|
|
1125
|
+
const attr = attributes.find((attr2) => attr2.id === attrId);
|
|
1126
|
+
if (!attr) {
|
|
1401
1127
|
return false;
|
|
1402
1128
|
}
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1129
|
+
const actualValue = getAttributeValue(attr.codeName, userAttributes);
|
|
1130
|
+
if (attr.dataType === import_types4.BizAttributeTypes.String) {
|
|
1131
|
+
return evaluateStringCondition(logic, actualValue, value);
|
|
1132
|
+
}
|
|
1133
|
+
if (attr.dataType === import_types4.BizAttributeTypes.Number) {
|
|
1134
|
+
return evaluateNumberCondition(logic, actualValue, value, value2);
|
|
1135
|
+
}
|
|
1136
|
+
if (attr.dataType === import_types4.BizAttributeTypes.Boolean) {
|
|
1137
|
+
return evaluateBooleanCondition(logic, actualValue);
|
|
1138
|
+
}
|
|
1139
|
+
if (attr.dataType === import_types4.BizAttributeTypes.List) {
|
|
1140
|
+
return evaluateListCondition(logic, actualValue, listValues);
|
|
1141
|
+
}
|
|
1142
|
+
if (attr.dataType === import_types4.BizAttributeTypes.DateTime) {
|
|
1143
|
+
return evaluateDateTimeCondition(logic, actualValue, value);
|
|
1408
1144
|
}
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1145
|
+
return false;
|
|
1146
|
+
}
|
|
1147
|
+
function getAttributeValue(codeName, userAttributes) {
|
|
1148
|
+
return userAttributes == null ? void 0 : userAttributes[codeName];
|
|
1149
|
+
}
|
|
1150
|
+
function evaluateStringCondition(logic, actualValue, expectedValue) {
|
|
1151
|
+
const stringValue = actualValue === null || actualValue === void 0 ? "" : String(actualValue);
|
|
1152
|
+
switch (logic) {
|
|
1153
|
+
case "is":
|
|
1154
|
+
return stringValue === expectedValue;
|
|
1155
|
+
case "not":
|
|
1156
|
+
return stringValue !== expectedValue;
|
|
1157
|
+
case "contains":
|
|
1158
|
+
return stringValue.includes(expectedValue);
|
|
1159
|
+
case "notContain":
|
|
1160
|
+
return !stringValue.includes(expectedValue);
|
|
1161
|
+
case "startsWith":
|
|
1162
|
+
return stringValue.startsWith(expectedValue);
|
|
1163
|
+
case "endsWith":
|
|
1164
|
+
return stringValue.endsWith(expectedValue);
|
|
1165
|
+
case "empty": {
|
|
1166
|
+
const isEmpty = !stringValue || stringValue === "";
|
|
1167
|
+
return isEmpty;
|
|
1414
1168
|
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1169
|
+
case "any":
|
|
1170
|
+
return Boolean(stringValue && stringValue !== "");
|
|
1171
|
+
default:
|
|
1172
|
+
return false;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
function evaluateNumberCondition(logic, actualValue, expectedValue, expectedValue2) {
|
|
1176
|
+
const numValue = Number(actualValue);
|
|
1177
|
+
const numValue2 = Number(expectedValue2);
|
|
1178
|
+
if (Number.isNaN(numValue)) {
|
|
1179
|
+
return false;
|
|
1418
1180
|
}
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1181
|
+
switch (logic) {
|
|
1182
|
+
case "is":
|
|
1183
|
+
return numValue === expectedValue;
|
|
1184
|
+
case "not":
|
|
1185
|
+
return numValue !== expectedValue;
|
|
1186
|
+
case "isLessThan":
|
|
1187
|
+
return numValue < expectedValue;
|
|
1188
|
+
case "isLessThanOrEqualTo":
|
|
1189
|
+
return numValue <= expectedValue;
|
|
1190
|
+
case "isGreaterThan":
|
|
1191
|
+
return numValue > expectedValue;
|
|
1192
|
+
case "isGreaterThanOrEqualTo":
|
|
1193
|
+
return numValue >= expectedValue;
|
|
1194
|
+
case "between":
|
|
1195
|
+
return numValue >= expectedValue && numValue <= numValue2;
|
|
1196
|
+
case "empty":
|
|
1197
|
+
return actualValue === null || actualValue === void 0 || actualValue === "";
|
|
1198
|
+
case "any":
|
|
1199
|
+
return actualValue !== null && actualValue !== void 0 && actualValue !== "";
|
|
1200
|
+
default:
|
|
1423
1201
|
return false;
|
|
1424
|
-
}
|
|
1425
1202
|
}
|
|
1426
|
-
|
|
1427
|
-
|
|
1203
|
+
}
|
|
1204
|
+
function evaluateBooleanCondition(logic, actualValue) {
|
|
1205
|
+
switch (logic) {
|
|
1206
|
+
case "true":
|
|
1207
|
+
return actualValue === true;
|
|
1208
|
+
case "false":
|
|
1209
|
+
return actualValue === false;
|
|
1210
|
+
case "empty":
|
|
1211
|
+
return actualValue === null || actualValue === void 0 || actualValue === "";
|
|
1212
|
+
case "any":
|
|
1213
|
+
return actualValue !== null && actualValue !== void 0 && actualValue !== "";
|
|
1214
|
+
default:
|
|
1428
1215
|
return false;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
1219
|
+
const arrayValue = Array.isArray(actualValue) ? actualValue : [];
|
|
1220
|
+
if (logic === "empty" || logic === "any") {
|
|
1221
|
+
switch (logic) {
|
|
1222
|
+
case "empty":
|
|
1223
|
+
return !arrayValue || arrayValue.length === 0;
|
|
1224
|
+
case "any":
|
|
1225
|
+
return arrayValue && arrayValue.length > 0;
|
|
1226
|
+
default:
|
|
1227
|
+
return false;
|
|
1429
1228
|
}
|
|
1430
1229
|
}
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
if (!
|
|
1435
|
-
return
|
|
1230
|
+
const filteredValues = expectedValues.filter(
|
|
1231
|
+
(value) => value !== null && value !== void 0 && value !== ""
|
|
1232
|
+
);
|
|
1233
|
+
if (!filteredValues.length) {
|
|
1234
|
+
return false;
|
|
1436
1235
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
return
|
|
1236
|
+
switch (logic) {
|
|
1237
|
+
case "includesAtLeastOne":
|
|
1238
|
+
return filteredValues.some((value) => arrayValue.includes(value));
|
|
1239
|
+
case "includesAll":
|
|
1240
|
+
return filteredValues.every((value) => arrayValue.includes(value));
|
|
1241
|
+
case "notIncludesAtLeastOne":
|
|
1242
|
+
return !filteredValues.some((value) => arrayValue.includes(value));
|
|
1243
|
+
case "notIncludesAll":
|
|
1244
|
+
return !filteredValues.every((value) => arrayValue.includes(value));
|
|
1245
|
+
default:
|
|
1246
|
+
return false;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
function evaluateDateTimeCondition(logic, actualValue, expectedValue) {
|
|
1250
|
+
const actualDate = actualValue ? new Date(actualValue) : null;
|
|
1251
|
+
const now = /* @__PURE__ */ new Date();
|
|
1252
|
+
if (!actualDate || Number.isNaN(actualDate.getTime())) {
|
|
1253
|
+
return false;
|
|
1254
|
+
}
|
|
1255
|
+
switch (logic) {
|
|
1256
|
+
case "lessThan": {
|
|
1257
|
+
const targetDate = (0, import_date_fns2.subDays)(now, Number(expectedValue));
|
|
1258
|
+
return actualDate >= targetDate;
|
|
1442
1259
|
}
|
|
1443
|
-
|
|
1444
|
-
const
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
return hashParams.get(paramName);
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1260
|
+
case "exactly": {
|
|
1261
|
+
const targetDate = (0, import_date_fns2.subDays)(now, Number(expectedValue));
|
|
1262
|
+
const start = (0, import_date_fns2.startOfDay)(targetDate);
|
|
1263
|
+
const end = (0, import_date_fns2.endOfDay)(targetDate);
|
|
1264
|
+
return actualDate >= start && actualDate <= end;
|
|
1451
1265
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1266
|
+
case "moreThan": {
|
|
1267
|
+
const targetDate = (0, import_date_fns2.subDays)(now, Number(expectedValue));
|
|
1268
|
+
return actualDate <= targetDate;
|
|
1269
|
+
}
|
|
1270
|
+
case "before": {
|
|
1271
|
+
const expectedDate = new Date(expectedValue);
|
|
1272
|
+
return actualDate <= expectedDate;
|
|
1273
|
+
}
|
|
1274
|
+
case "on": {
|
|
1275
|
+
const expectedDateOn = new Date(expectedValue);
|
|
1276
|
+
const start = (0, import_date_fns2.startOfDay)(expectedDateOn);
|
|
1277
|
+
const end = (0, import_date_fns2.endOfDay)(expectedDateOn);
|
|
1278
|
+
return actualDate >= start && actualDate <= end;
|
|
1279
|
+
}
|
|
1280
|
+
case "after": {
|
|
1281
|
+
const expectedDateAfter = new Date(expectedValue);
|
|
1282
|
+
return actualDate >= expectedDateAfter;
|
|
1283
|
+
}
|
|
1284
|
+
case "empty":
|
|
1285
|
+
return !actualValue || actualValue === "";
|
|
1286
|
+
case "any":
|
|
1287
|
+
return actualValue && actualValue !== "";
|
|
1288
|
+
default:
|
|
1289
|
+
return false;
|
|
1456
1290
|
}
|
|
1457
|
-
}
|
|
1291
|
+
}
|
|
1458
1292
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1459
1293
|
0 && (module.exports = {
|
|
1460
1294
|
AbortController,
|
|
1461
1295
|
ArrayProto,
|
|
1462
1296
|
XMLHttpRequest,
|
|
1463
1297
|
absoluteUrl,
|
|
1464
|
-
activedContentRulesConditions,
|
|
1465
|
-
activedRulesConditions,
|
|
1466
1298
|
assignableWindow,
|
|
1467
|
-
autoStartConditions,
|
|
1468
1299
|
buildConfig,
|
|
1469
|
-
checklistIsDimissed,
|
|
1470
|
-
checklistIsSeen,
|
|
1471
1300
|
cn,
|
|
1472
1301
|
conditionsIsSame,
|
|
1473
1302
|
convertSettings,
|
|
@@ -1478,11 +1307,10 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1478
1307
|
defaultStep,
|
|
1479
1308
|
document,
|
|
1480
1309
|
evalCode,
|
|
1310
|
+
evaluateAttributeCondition,
|
|
1311
|
+
evaluateTimeCondition,
|
|
1312
|
+
evaluateUrlCondition,
|
|
1481
1313
|
fetch,
|
|
1482
|
-
filterAutoStartContent,
|
|
1483
|
-
findLatestEvent,
|
|
1484
|
-
flowIsDismissed,
|
|
1485
|
-
flowIsSeen,
|
|
1486
1314
|
formatDate,
|
|
1487
1315
|
generateAutoStateColors,
|
|
1488
1316
|
getAuthToken,
|
|
@@ -1505,8 +1333,6 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1505
1333
|
hexToHSLString,
|
|
1506
1334
|
hexToRGBStr,
|
|
1507
1335
|
hexToRgb,
|
|
1508
|
-
isActive,
|
|
1509
|
-
isActiveRulesByCurrentTime,
|
|
1510
1336
|
isArray,
|
|
1511
1337
|
isBoolean,
|
|
1512
1338
|
isDark,
|
|
@@ -1529,14 +1355,12 @@ var parseUrlParams = (url, paramName) => {
|
|
|
1529
1355
|
isUint8Array,
|
|
1530
1356
|
isUndefined,
|
|
1531
1357
|
isUrl,
|
|
1532
|
-
isValidContent,
|
|
1533
1358
|
isValidSelector,
|
|
1534
1359
|
location,
|
|
1535
1360
|
mergeThemeDefaultSettings,
|
|
1536
1361
|
nativeForEach,
|
|
1537
1362
|
nativeIndexOf,
|
|
1538
1363
|
navigator,
|
|
1539
|
-
parseUrlParams,
|
|
1540
1364
|
removeAuthToken,
|
|
1541
1365
|
setAuthToken,
|
|
1542
1366
|
storage,
|