@usertour/helpers 0.0.37 → 0.0.39

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/index.cjs CHANGED
@@ -37,6 +37,12 @@ var src_exports = {};
37
37
  __export(src_exports, {
38
38
  AbortController: () => AbortController,
39
39
  ArrayProto: () => ArrayProto,
40
+ EmptyButton: () => EmptyButton,
41
+ EmptyColumn: () => EmptyColumn,
42
+ EmptyEmbed: () => EmptyEmbed,
43
+ EmptyGroup: () => EmptyGroup,
44
+ EmptyImage: () => EmptyImage,
45
+ EmptyText: () => EmptyText,
40
46
  XMLHttpRequest: () => XMLHttpRequest,
41
47
  absoluteUrl: () => absoluteUrl,
42
48
  allConditionsHaveIds: () => allConditionsHaveIds,
@@ -49,9 +55,19 @@ __export(src_exports, {
49
55
  convertSettings: () => convertSettings,
50
56
  convertTimeConditionLegacyToV2: () => convertTimeConditionLegacyToV2,
51
57
  convertToCssVars: () => convertToCssVars,
58
+ createNewColumn: () => createNewColumn,
59
+ createNewGroup: () => createNewGroup,
60
+ createStepCopy: () => createStepCopy,
61
+ createValue1: () => createValue1,
62
+ createValue2: () => createValue2,
63
+ createValue3: () => createValue3,
64
+ createValue4: () => createValue4,
65
+ createValue5: () => createValue5,
66
+ createValue6: () => createValue6,
52
67
  cuid: () => cuid,
53
68
  deepClone: () => deepClone,
54
69
  defaultContentConfig: () => defaultContentConfig,
70
+ defaultInitialValue: () => defaultInitialValue,
55
71
  defaultStep: () => defaultStep,
56
72
  document: () => document,
57
73
  evalCode: () => evalCode,
@@ -60,16 +76,19 @@ __export(src_exports, {
60
76
  evaluateRulesConditions: () => evaluateRulesConditions,
61
77
  evaluateTimeCondition: () => evaluateTimeCondition,
62
78
  evaluateUrlCondition: () => evaluateUrlCondition,
79
+ extractQuestionData: () => extractQuestionData,
63
80
  fetch: () => fetch,
64
81
  filterConditionsByType: () => filterConditionsByType,
65
82
  filterNullAttributes: () => filterNullAttributes,
66
83
  formatDate: () => formatDate,
67
84
  generateAutoStateColors: () => generateAutoStateColors,
85
+ generateUniqueCopyName: () => generateUniqueCopyName,
68
86
  getAttributeType: () => getAttributeType,
69
87
  getAuthToken: () => getAuthToken,
70
88
  getCodeError: () => getCodeError,
71
89
  getContentError: () => getContentError,
72
90
  getCurrentTimeError: () => getCurrentTimeError,
91
+ getDefaultDataForType: () => getDefaultDataForType,
73
92
  getElementError: () => getElementError,
74
93
  getErrorMessage: () => getErrorMessage,
75
94
  getNavitateError: () => getNavitateError,
@@ -81,13 +100,16 @@ __export(src_exports, {
81
100
  getUrlPatternError: () => getUrlPatternError,
82
101
  getUserAttrError: () => getUserAttrError,
83
102
  getWaitError: () => getWaitError,
103
+ groupData: () => groupData,
84
104
  hasActionError: () => hasActionError,
85
105
  hasError: () => hasError,
106
+ hasMissingRequiredData: () => hasMissingRequiredData,
86
107
  hexToHSLString: () => hexToHSLString,
87
108
  hexToRGBStr: () => hexToRGBStr,
88
109
  hexToRgb: () => hexToRgb,
89
110
  isArray: () => isArray,
90
111
  isBoolean: () => isBoolean,
112
+ isClickableElement: () => isClickableElement,
91
113
  isConditionsActived: () => isConditionsActived,
92
114
  isDark: () => isDark,
93
115
  isDate: () => isDate,
@@ -99,12 +121,15 @@ __export(src_exports, {
99
121
  isFormData: () => isFormData,
100
122
  isFunction: () => isFunction,
101
123
  isMatchUrlPattern: () => isMatchUrlPattern,
124
+ isMissingRequiredData: () => isMissingRequiredData,
102
125
  isNull: () => isNull,
103
126
  isNullish: () => isNullish,
104
127
  isNumber: () => isNumber,
105
128
  isObject: () => isObject,
106
129
  isPublishedAtLeastOneEnvironment: () => isPublishedAtLeastOneEnvironment,
107
130
  isPublishedInAllEnvironments: () => isPublishedInAllEnvironments,
131
+ isQuestionElement: () => isQuestionElement,
132
+ isRestrictedType: () => isRestrictedType,
108
133
  isString: () => isString,
109
134
  isTimeConditionDataLegacy: () => isTimeConditionDataLegacy,
110
135
  isTimeConditionDataV2: () => isTimeConditionDataV2,
@@ -119,10 +144,14 @@ __export(src_exports, {
119
144
  navigator: () => navigator,
120
145
  normalizeTimeConditionData: () => normalizeTimeConditionData,
121
146
  parseUrlParams: () => parseUrlParams,
147
+ processQuestionElements: () => processQuestionElements,
122
148
  regenerateConditionIds: () => regenerateConditionIds,
149
+ regenerateTarget: () => regenerateTarget,
150
+ regenerateTrigger: () => regenerateTrigger,
123
151
  removeAuthToken: () => removeAuthToken,
124
152
  setAuthToken: () => setAuthToken,
125
153
  storage: () => storage,
154
+ surveysValue: () => surveysValue,
126
155
  userAgent: () => userAgent,
127
156
  uuidV4: () => uuidV4,
128
157
  wait: () => wait,
@@ -1623,10 +1652,947 @@ var filterNullAttributes = (attributes) => {
1623
1652
  }
1624
1653
  return attrs;
1625
1654
  };
1655
+
1656
+ // src/editor-helper.ts
1657
+ var import_types7 = require("@usertour/types");
1658
+ var EmptyGroup = {
1659
+ element: { type: "group" },
1660
+ children: []
1661
+ };
1662
+ var EmptyColumn = {
1663
+ element: {
1664
+ type: "column",
1665
+ width: { type: "fill" },
1666
+ justifyContent: "justify-center",
1667
+ style: {}
1668
+ },
1669
+ children: []
1670
+ };
1671
+ var EmptyButton = {
1672
+ element: {
1673
+ type: "button",
1674
+ data: {
1675
+ action: "next",
1676
+ text: "Next",
1677
+ type: "default"
1678
+ }
1679
+ }
1680
+ };
1681
+ var EmptyImage = {
1682
+ element: { type: "image", url: "" }
1683
+ };
1684
+ var EmptyEmbed = {
1685
+ element: { type: "embed", url: "" }
1686
+ };
1687
+ var EmptyText = {
1688
+ element: {
1689
+ type: "text",
1690
+ data: [{ type: "paragraph", children: [{ text: "Write text here" }] }]
1691
+ }
1692
+ };
1693
+ var createNewGroup = (children) => {
1694
+ return {
1695
+ ...EmptyGroup,
1696
+ id: uuidV4(),
1697
+ children: [
1698
+ {
1699
+ ...EmptyColumn,
1700
+ id: uuidV4(),
1701
+ children: [...children]
1702
+ }
1703
+ ]
1704
+ };
1705
+ };
1706
+ var createNewColumn = (children) => {
1707
+ return {
1708
+ ...EmptyColumn,
1709
+ id: uuidV4(),
1710
+ children: [...children]
1711
+ };
1712
+ };
1713
+ var defaultInitialValue = [
1714
+ {
1715
+ ...EmptyGroup,
1716
+ children: [
1717
+ {
1718
+ ...EmptyColumn,
1719
+ children: [
1720
+ {
1721
+ ...EmptyText
1722
+ }
1723
+ ]
1724
+ },
1725
+ {
1726
+ ...EmptyColumn,
1727
+ children: [
1728
+ {
1729
+ ...EmptyEmbed
1730
+ }
1731
+ ]
1732
+ }
1733
+ ]
1734
+ },
1735
+ {
1736
+ ...EmptyGroup,
1737
+ children: [
1738
+ {
1739
+ ...EmptyColumn,
1740
+ children: [
1741
+ {
1742
+ ...EmptyButton
1743
+ }
1744
+ ]
1745
+ },
1746
+ {
1747
+ ...EmptyColumn,
1748
+ children: [
1749
+ {
1750
+ ...EmptyImage
1751
+ }
1752
+ ]
1753
+ }
1754
+ ]
1755
+ }
1756
+ ];
1757
+ var groupData = [
1758
+ {
1759
+ type: "group",
1760
+ isFirst: true,
1761
+ isLast: true,
1762
+ children: [
1763
+ {
1764
+ type: "column",
1765
+ width: { type: "fill", value: 50 },
1766
+ justifyContent: "justify-center",
1767
+ style: { marginRight: "30" },
1768
+ children: [
1769
+ {
1770
+ type: "paragraph",
1771
+ children: [{ text: "Write text here" }]
1772
+ }
1773
+ ]
1774
+ },
1775
+ {
1776
+ type: "column",
1777
+ width: { type: "fill", value: 50 },
1778
+ justifyContent: "justify-center",
1779
+ style: { marginRight: "30" },
1780
+ children: [
1781
+ {
1782
+ type: "paragraph",
1783
+ children: [{ text: "Write text here" }]
1784
+ }
1785
+ ]
1786
+ }
1787
+ ]
1788
+ }
1789
+ ];
1790
+ var createValue1 = [
1791
+ // {
1792
+ // element: {
1793
+ // type: "group",
1794
+ // },
1795
+ // children: [
1796
+ // {
1797
+ // element: {
1798
+ // type: "column",
1799
+ // width: {
1800
+ // type: "fill",
1801
+ // },
1802
+ // justifyContent: "justify-start",
1803
+ // style: {},
1804
+ // },
1805
+ // children: [
1806
+ // {
1807
+ // element: {
1808
+ // type: "text",
1809
+ // data: [
1810
+ // {
1811
+ // type: "h1",
1812
+ // children: [
1813
+ // {
1814
+ // text: "This is Title",
1815
+ // },
1816
+ // ],
1817
+ // },
1818
+ // ],
1819
+ // },
1820
+ // children: null,
1821
+ // },
1822
+ // ],
1823
+ // },
1824
+ // ],
1825
+ // },
1826
+ {
1827
+ element: {
1828
+ type: "group"
1829
+ },
1830
+ children: [
1831
+ {
1832
+ element: {
1833
+ type: "column",
1834
+ justifyContent: "justify-start",
1835
+ width: {
1836
+ type: "fill"
1837
+ },
1838
+ style: {}
1839
+ },
1840
+ children: [
1841
+ {
1842
+ element: {
1843
+ type: "text",
1844
+ data: [
1845
+ {
1846
+ type: "paragraph",
1847
+ children: [
1848
+ {
1849
+ text: "Write text here"
1850
+ }
1851
+ ]
1852
+ },
1853
+ {
1854
+ type: "paragraph",
1855
+ children: [
1856
+ {
1857
+ text: ""
1858
+ }
1859
+ ]
1860
+ }
1861
+ ]
1862
+ }
1863
+ }
1864
+ ]
1865
+ }
1866
+ ]
1867
+ }
1868
+ ];
1869
+ var createValue2 = [
1870
+ {
1871
+ element: {
1872
+ type: "group"
1873
+ },
1874
+ children: [
1875
+ {
1876
+ element: {
1877
+ type: "column",
1878
+ justifyContent: "justify-center",
1879
+ width: {
1880
+ type: "fill"
1881
+ },
1882
+ style: {}
1883
+ },
1884
+ children: [
1885
+ {
1886
+ element: {
1887
+ type: "text",
1888
+ data: [
1889
+ {
1890
+ type: "paragraph",
1891
+ children: [
1892
+ {
1893
+ text: "Write text here"
1894
+ }
1895
+ ],
1896
+ align: "left"
1897
+ },
1898
+ {
1899
+ type: "paragraph",
1900
+ children: [
1901
+ {
1902
+ text: ""
1903
+ }
1904
+ ]
1905
+ }
1906
+ ]
1907
+ }
1908
+ }
1909
+ ]
1910
+ }
1911
+ ]
1912
+ },
1913
+ {
1914
+ element: {
1915
+ type: "group"
1916
+ },
1917
+ children: [
1918
+ {
1919
+ element: {
1920
+ type: "column",
1921
+ width: {
1922
+ type: "fill"
1923
+ },
1924
+ justifyContent: "justify-end",
1925
+ style: {}
1926
+ },
1927
+ children: [
1928
+ {
1929
+ element: {
1930
+ type: "button",
1931
+ data: {
1932
+ action: "goto",
1933
+ text: "Prev",
1934
+ type: "secondary"
1935
+ }
1936
+ },
1937
+ children: null
1938
+ },
1939
+ {
1940
+ element: {
1941
+ type: "button",
1942
+ data: {
1943
+ action: "goto",
1944
+ text: "Next",
1945
+ type: "default"
1946
+ },
1947
+ margin: {
1948
+ top: 0,
1949
+ left: "10",
1950
+ bottom: 0,
1951
+ right: 0,
1952
+ enabled: true
1953
+ }
1954
+ },
1955
+ children: null
1956
+ }
1957
+ ]
1958
+ }
1959
+ ]
1960
+ }
1961
+ ];
1962
+ var createValue3 = [
1963
+ {
1964
+ element: {
1965
+ type: "group"
1966
+ },
1967
+ children: [
1968
+ {
1969
+ element: {
1970
+ type: "column",
1971
+ style: {},
1972
+ width: {
1973
+ type: "fill"
1974
+ },
1975
+ justifyContent: "justify-center"
1976
+ },
1977
+ children: [
1978
+ {
1979
+ element: {
1980
+ url: "https://assets.usertour.io/5d9975de-f095-40ee-a6f9-8da3c3c38515/stick-figures-holding-word-welcome-vector-banner-text-welcome-welcome-together-people-big-colorful-letters-114865217.webp",
1981
+ type: "image"
1982
+ },
1983
+ children: null
1984
+ }
1985
+ ]
1986
+ }
1987
+ ]
1988
+ },
1989
+ {
1990
+ element: {
1991
+ type: "group"
1992
+ },
1993
+ children: [
1994
+ {
1995
+ element: {
1996
+ type: "column",
1997
+ style: {},
1998
+ width: {
1999
+ type: "fill"
2000
+ },
2001
+ justifyContent: "justify-start"
2002
+ },
2003
+ children: [
2004
+ {
2005
+ element: {
2006
+ data: [
2007
+ {
2008
+ type: "paragraph",
2009
+ children: [
2010
+ {
2011
+ text: ""
2012
+ }
2013
+ ]
2014
+ },
2015
+ {
2016
+ type: "h1",
2017
+ align: "center",
2018
+ children: [
2019
+ {
2020
+ bold: true,
2021
+ text: "Welcome to Usertour!"
2022
+ }
2023
+ ]
2024
+ },
2025
+ {
2026
+ type: "paragraph",
2027
+ align: "center",
2028
+ children: [
2029
+ {
2030
+ text: ""
2031
+ }
2032
+ ]
2033
+ }
2034
+ ],
2035
+ type: "text"
2036
+ },
2037
+ children: null
2038
+ }
2039
+ ]
2040
+ }
2041
+ ]
2042
+ },
2043
+ {
2044
+ element: {
2045
+ type: "group"
2046
+ },
2047
+ children: [
2048
+ {
2049
+ element: {
2050
+ type: "column",
2051
+ style: {},
2052
+ width: {
2053
+ type: "fill"
2054
+ },
2055
+ justifyContent: "justify-center"
2056
+ },
2057
+ children: [
2058
+ {
2059
+ element: {
2060
+ data: {
2061
+ text: "Let's create a flow",
2062
+ type: "default",
2063
+ action: "goto",
2064
+ actions: [
2065
+ {
2066
+ data: {
2067
+ stepCvid: ""
2068
+ },
2069
+ type: "step-goto",
2070
+ operators: "and"
2071
+ }
2072
+ ]
2073
+ },
2074
+ type: "button"
2075
+ },
2076
+ children: null
2077
+ }
2078
+ ]
2079
+ }
2080
+ ]
2081
+ }
2082
+ ];
2083
+ var createValue4 = createValue3;
2084
+ var createValue5 = [
2085
+ {
2086
+ element: {
2087
+ type: "group"
2088
+ },
2089
+ children: [
2090
+ {
2091
+ element: {
2092
+ type: "column",
2093
+ justifyContent: "justify-center",
2094
+ width: {
2095
+ type: "fill"
2096
+ },
2097
+ style: {}
2098
+ },
2099
+ children: [
2100
+ {
2101
+ element: {
2102
+ type: "text",
2103
+ data: [
2104
+ {
2105
+ type: "paragraph",
2106
+ children: [
2107
+ {
2108
+ text: "Welcome to Usertour!"
2109
+ }
2110
+ ],
2111
+ align: "left"
2112
+ },
2113
+ {
2114
+ type: "paragraph",
2115
+ children: [
2116
+ {
2117
+ text: ""
2118
+ }
2119
+ ]
2120
+ }
2121
+ ]
2122
+ }
2123
+ }
2124
+ ]
2125
+ }
2126
+ ]
2127
+ },
2128
+ {
2129
+ element: {
2130
+ type: "group"
2131
+ },
2132
+ children: [
2133
+ {
2134
+ element: {
2135
+ type: "column",
2136
+ width: {
2137
+ type: "fill"
2138
+ },
2139
+ justifyContent: "justify-end",
2140
+ style: {}
2141
+ },
2142
+ children: [
2143
+ {
2144
+ element: {
2145
+ type: "button",
2146
+ data: {
2147
+ action: "goto",
2148
+ text: "Prev",
2149
+ type: "secondary"
2150
+ }
2151
+ },
2152
+ children: null
2153
+ },
2154
+ {
2155
+ element: {
2156
+ type: "button",
2157
+ data: {
2158
+ action: "goto",
2159
+ text: "Next",
2160
+ type: "default"
2161
+ },
2162
+ margin: {
2163
+ top: 0,
2164
+ left: "10",
2165
+ bottom: 0,
2166
+ right: 0,
2167
+ enabled: true
2168
+ }
2169
+ },
2170
+ children: null
2171
+ }
2172
+ ]
2173
+ }
2174
+ ]
2175
+ }
2176
+ ];
2177
+ var createValue6 = [
2178
+ {
2179
+ element: {
2180
+ type: "group"
2181
+ },
2182
+ children: [
2183
+ {
2184
+ element: {
2185
+ type: "column",
2186
+ justifyContent: "justify-center",
2187
+ width: {
2188
+ type: "fill"
2189
+ },
2190
+ style: {}
2191
+ },
2192
+ children: [
2193
+ {
2194
+ element: {
2195
+ type: "image",
2196
+ url: "https://assets.usertour.io/5d9975de-f095-40ee-a6f9-8da3c3c38515/stick-figures-holding-word-welcome-vector-banner-text-welcome-welcome-together-people-big-colorful-letters-114865217.webp"
2197
+ },
2198
+ children: null
2199
+ }
2200
+ ]
2201
+ }
2202
+ ]
2203
+ },
2204
+ {
2205
+ element: {
2206
+ type: "group"
2207
+ },
2208
+ children: [
2209
+ {
2210
+ element: {
2211
+ type: "column",
2212
+ width: {
2213
+ type: "fill"
2214
+ },
2215
+ justifyContent: "justify-start",
2216
+ style: {}
2217
+ },
2218
+ children: [
2219
+ {
2220
+ element: {
2221
+ type: "text",
2222
+ data: [
2223
+ {
2224
+ type: "paragraph",
2225
+ children: [
2226
+ {
2227
+ text: ""
2228
+ }
2229
+ ]
2230
+ },
2231
+ {
2232
+ type: "paragraph",
2233
+ children: [
2234
+ {
2235
+ text: "Title"
2236
+ }
2237
+ ]
2238
+ }
2239
+ ]
2240
+ },
2241
+ children: null
2242
+ }
2243
+ ]
2244
+ }
2245
+ ]
2246
+ },
2247
+ {
2248
+ element: {
2249
+ type: "group"
2250
+ },
2251
+ children: [
2252
+ {
2253
+ element: {
2254
+ type: "column",
2255
+ width: {
2256
+ type: "fill"
2257
+ },
2258
+ justifyContent: "justify-start",
2259
+ style: {}
2260
+ },
2261
+ children: [
2262
+ {
2263
+ element: {
2264
+ type: "text",
2265
+ data: [
2266
+ {
2267
+ type: "paragraph",
2268
+ children: [
2269
+ {
2270
+ text: "Write text here"
2271
+ }
2272
+ ]
2273
+ }
2274
+ ]
2275
+ },
2276
+ children: null
2277
+ }
2278
+ ]
2279
+ }
2280
+ ]
2281
+ },
2282
+ {
2283
+ element: {
2284
+ type: "group"
2285
+ },
2286
+ children: [
2287
+ {
2288
+ element: {
2289
+ type: "column",
2290
+ justifyContent: "justify-end",
2291
+ width: {
2292
+ type: "fill"
2293
+ },
2294
+ style: {}
2295
+ },
2296
+ children: [
2297
+ {
2298
+ element: {
2299
+ type: "button",
2300
+ data: {
2301
+ text: "Prev",
2302
+ type: "secondary",
2303
+ action: "next"
2304
+ }
2305
+ },
2306
+ children: null
2307
+ },
2308
+ {
2309
+ element: {
2310
+ type: "button",
2311
+ data: {
2312
+ text: "Next",
2313
+ type: "",
2314
+ action: "next"
2315
+ },
2316
+ margin: {
2317
+ top: "0",
2318
+ left: "10",
2319
+ bottom: 0,
2320
+ right: 0,
2321
+ enabled: true
2322
+ }
2323
+ },
2324
+ children: null
2325
+ }
2326
+ ]
2327
+ }
2328
+ ]
2329
+ }
2330
+ ];
2331
+ var surveysValue = [
2332
+ {
2333
+ element: {
2334
+ type: "group"
2335
+ },
2336
+ children: [
2337
+ {
2338
+ element: {
2339
+ type: "column",
2340
+ style: {},
2341
+ width: {
2342
+ type: "fill"
2343
+ },
2344
+ justifyContent: "justify-start"
2345
+ },
2346
+ children: [
2347
+ {
2348
+ element: {
2349
+ data: [
2350
+ {
2351
+ type: "paragraph",
2352
+ children: [
2353
+ {
2354
+ text: ""
2355
+ }
2356
+ ]
2357
+ },
2358
+ {
2359
+ type: "h1",
2360
+ align: "center",
2361
+ children: [
2362
+ {
2363
+ bold: true,
2364
+ text: "How easy-to-use is our product?"
2365
+ }
2366
+ ]
2367
+ },
2368
+ {
2369
+ type: "paragraph",
2370
+ children: [
2371
+ {
2372
+ text: ""
2373
+ }
2374
+ ]
2375
+ }
2376
+ ],
2377
+ type: "text"
2378
+ }
2379
+ }
2380
+ ]
2381
+ }
2382
+ ]
2383
+ },
2384
+ {
2385
+ element: {
2386
+ type: "group"
2387
+ },
2388
+ children: [
2389
+ {
2390
+ element: {
2391
+ type: "column",
2392
+ style: {},
2393
+ width: {
2394
+ type: "fill"
2395
+ },
2396
+ justifyContent: "justify-center"
2397
+ },
2398
+ children: [
2399
+ {
2400
+ element: {
2401
+ data: {
2402
+ cvid: "oatboqldqf7qcxtl1kdrvsvk",
2403
+ name: "sss",
2404
+ actions: [
2405
+ {
2406
+ data: {},
2407
+ type: "flow-dismis",
2408
+ operators: "and"
2409
+ }
2410
+ ],
2411
+ lowLabel: "",
2412
+ highLabel: "",
2413
+ bindToAttribute: true,
2414
+ selectedAttribute: "nn5"
2415
+ },
2416
+ type: "nps"
2417
+ },
2418
+ children: null
2419
+ }
2420
+ ]
2421
+ }
2422
+ ]
2423
+ }
2424
+ ];
2425
+ var isRestrictedType = (type) => {
2426
+ const restrictedTypes = [
2427
+ import_types7.ContentEditorElementType.NPS,
2428
+ import_types7.ContentEditorElementType.STAR_RATING,
2429
+ import_types7.ContentEditorElementType.SCALE,
2430
+ import_types7.ContentEditorElementType.SINGLE_LINE_TEXT,
2431
+ import_types7.ContentEditorElementType.MULTI_LINE_TEXT,
2432
+ import_types7.ContentEditorElementType.MULTIPLE_CHOICE
2433
+ ];
2434
+ return restrictedTypes.includes(type);
2435
+ };
2436
+ var isMissingRequiredData = (element) => {
2437
+ var _a, _b, _c, _d;
2438
+ if (isRestrictedType(element.type)) {
2439
+ return isEmptyString((_a = element.data) == null ? void 0 : _a.name);
2440
+ }
2441
+ if (element.type === import_types7.ContentEditorElementType.BUTTON) {
2442
+ if (isEmptyString((_b = element.data) == null ? void 0 : _b.text)) {
2443
+ return true;
2444
+ }
2445
+ if (!((_c = element == null ? void 0 : element.data) == null ? void 0 : _c.actions) || ((_d = element == null ? void 0 : element.data) == null ? void 0 : _d.actions.length) === 0) {
2446
+ return true;
2447
+ }
2448
+ }
2449
+ return false;
2450
+ };
2451
+ var hasMissingRequiredData = (contents) => {
2452
+ return contents.some(
2453
+ (group) => group.children.some(
2454
+ (column) => column.children.some((item) => isMissingRequiredData(item.element))
2455
+ )
2456
+ );
2457
+ };
2458
+ var isQuestionElement = (element) => {
2459
+ return element.type === import_types7.ContentEditorElementType.SINGLE_LINE_TEXT || element.type === import_types7.ContentEditorElementType.MULTI_LINE_TEXT || element.type === import_types7.ContentEditorElementType.NPS || element.type === import_types7.ContentEditorElementType.STAR_RATING || element.type === import_types7.ContentEditorElementType.SCALE || element.type === import_types7.ContentEditorElementType.MULTIPLE_CHOICE;
2460
+ };
2461
+ var isClickableElement = (element) => {
2462
+ return element.type === import_types7.ContentEditorElementType.BUTTON || isQuestionElement(element);
2463
+ };
2464
+ var extractQuestionData = (data) => {
2465
+ const result = [];
2466
+ function isQuestionRootElement(item) {
2467
+ return "element" in item && isQuestionElement(item.element);
2468
+ }
2469
+ function traverse(item) {
2470
+ if (isQuestionRootElement(item)) {
2471
+ result.push(item.element);
2472
+ }
2473
+ if ("children" in item && item.children) {
2474
+ for (const child of item.children) {
2475
+ traverse(child);
2476
+ }
2477
+ }
2478
+ }
2479
+ for (const item of data) {
2480
+ traverse(item);
2481
+ }
2482
+ return result;
2483
+ };
2484
+ var getDefaultDataForType = (type) => {
2485
+ switch (type) {
2486
+ case "modal":
2487
+ return createValue4;
2488
+ case "hidden":
2489
+ return createValue2;
2490
+ default:
2491
+ return createValue1;
2492
+ }
2493
+ };
2494
+ var processQuestionElements = (contents) => {
2495
+ if (!contents || !isArray(contents) || contents.length === 0) {
2496
+ return [];
2497
+ }
2498
+ return contents.map((group) => ({
2499
+ ...group,
2500
+ children: group.children.map((column) => ({
2501
+ ...column,
2502
+ children: column.children.map((item) => {
2503
+ var _a, _b;
2504
+ const element = item.element;
2505
+ if (isQuestionElement(element)) {
2506
+ const questionElement = element;
2507
+ const updatedElement = {
2508
+ ...questionElement,
2509
+ data: {
2510
+ ...questionElement.data,
2511
+ cvid: cuid(),
2512
+ ...((_a = questionElement.data) == null ? void 0 : _a.actions) && isArray(questionElement.data.actions) ? { actions: regenerateConditionIds(questionElement.data.actions) } : {}
2513
+ }
2514
+ };
2515
+ return {
2516
+ ...item,
2517
+ element: updatedElement
2518
+ };
2519
+ }
2520
+ if (element.type === import_types7.ContentEditorElementType.BUTTON) {
2521
+ const buttonElement = element;
2522
+ if (((_b = buttonElement.data) == null ? void 0 : _b.actions) && isArray(buttonElement.data.actions)) {
2523
+ return {
2524
+ ...item,
2525
+ element: {
2526
+ ...buttonElement,
2527
+ data: {
2528
+ ...buttonElement.data,
2529
+ actions: regenerateConditionIds(buttonElement.data.actions)
2530
+ }
2531
+ }
2532
+ };
2533
+ }
2534
+ }
2535
+ return item;
2536
+ })
2537
+ }))
2538
+ }));
2539
+ };
2540
+ var regenerateTrigger = (trigger) => {
2541
+ return trigger.map((t) => ({
2542
+ ...t,
2543
+ id: cuid(),
2544
+ conditions: regenerateConditionIds(t.conditions),
2545
+ actions: regenerateConditionIds(t.actions)
2546
+ }));
2547
+ };
2548
+ var regenerateTarget = (target) => {
2549
+ if (!target) {
2550
+ return void 0;
2551
+ }
2552
+ if (target.actions && isArray(target.actions)) {
2553
+ return {
2554
+ ...target,
2555
+ actions: regenerateConditionIds(target.actions)
2556
+ };
2557
+ }
2558
+ return target;
2559
+ };
2560
+ var generateUniqueCopyName = (originalName, existingNames) => {
2561
+ let name = `${originalName} (copy)`;
2562
+ if (existingNames == null ? void 0 : existingNames.includes(name)) {
2563
+ let number = 2;
2564
+ while (existingNames.includes(`${originalName} (copy ${number})`)) {
2565
+ number++;
2566
+ }
2567
+ name = `${originalName} (copy ${number})`;
2568
+ }
2569
+ return name;
2570
+ };
2571
+ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2572
+ const { id, cvid, updatedAt, createdAt, ...rest } = originalStep;
2573
+ const name = generateUniqueCopyName(originalStep == null ? void 0 : originalStep.name, existingStepNames);
2574
+ const trigger = (originalStep == null ? void 0 : originalStep.trigger) ? regenerateTrigger(originalStep == null ? void 0 : originalStep.trigger) : [];
2575
+ const data = (originalStep == null ? void 0 : originalStep.data) ? processQuestionElements(originalStep == null ? void 0 : originalStep.data) : [];
2576
+ const target = regenerateTarget(originalStep == null ? void 0 : originalStep.target);
2577
+ return {
2578
+ ...rest,
2579
+ data,
2580
+ trigger,
2581
+ target,
2582
+ name,
2583
+ sequence
2584
+ };
2585
+ };
1626
2586
  // Annotate the CommonJS export names for ESM import in node:
1627
2587
  0 && (module.exports = {
1628
2588
  AbortController,
1629
2589
  ArrayProto,
2590
+ EmptyButton,
2591
+ EmptyColumn,
2592
+ EmptyEmbed,
2593
+ EmptyGroup,
2594
+ EmptyImage,
2595
+ EmptyText,
1630
2596
  XMLHttpRequest,
1631
2597
  absoluteUrl,
1632
2598
  allConditionsHaveIds,
@@ -1639,9 +2605,19 @@ var filterNullAttributes = (attributes) => {
1639
2605
  convertSettings,
1640
2606
  convertTimeConditionLegacyToV2,
1641
2607
  convertToCssVars,
2608
+ createNewColumn,
2609
+ createNewGroup,
2610
+ createStepCopy,
2611
+ createValue1,
2612
+ createValue2,
2613
+ createValue3,
2614
+ createValue4,
2615
+ createValue5,
2616
+ createValue6,
1642
2617
  cuid,
1643
2618
  deepClone,
1644
2619
  defaultContentConfig,
2620
+ defaultInitialValue,
1645
2621
  defaultStep,
1646
2622
  document,
1647
2623
  evalCode,
@@ -1650,16 +2626,19 @@ var filterNullAttributes = (attributes) => {
1650
2626
  evaluateRulesConditions,
1651
2627
  evaluateTimeCondition,
1652
2628
  evaluateUrlCondition,
2629
+ extractQuestionData,
1653
2630
  fetch,
1654
2631
  filterConditionsByType,
1655
2632
  filterNullAttributes,
1656
2633
  formatDate,
1657
2634
  generateAutoStateColors,
2635
+ generateUniqueCopyName,
1658
2636
  getAttributeType,
1659
2637
  getAuthToken,
1660
2638
  getCodeError,
1661
2639
  getContentError,
1662
2640
  getCurrentTimeError,
2641
+ getDefaultDataForType,
1663
2642
  getElementError,
1664
2643
  getErrorMessage,
1665
2644
  getNavitateError,
@@ -1671,13 +2650,16 @@ var filterNullAttributes = (attributes) => {
1671
2650
  getUrlPatternError,
1672
2651
  getUserAttrError,
1673
2652
  getWaitError,
2653
+ groupData,
1674
2654
  hasActionError,
1675
2655
  hasError,
2656
+ hasMissingRequiredData,
1676
2657
  hexToHSLString,
1677
2658
  hexToRGBStr,
1678
2659
  hexToRgb,
1679
2660
  isArray,
1680
2661
  isBoolean,
2662
+ isClickableElement,
1681
2663
  isConditionsActived,
1682
2664
  isDark,
1683
2665
  isDate,
@@ -1689,12 +2671,15 @@ var filterNullAttributes = (attributes) => {
1689
2671
  isFormData,
1690
2672
  isFunction,
1691
2673
  isMatchUrlPattern,
2674
+ isMissingRequiredData,
1692
2675
  isNull,
1693
2676
  isNullish,
1694
2677
  isNumber,
1695
2678
  isObject,
1696
2679
  isPublishedAtLeastOneEnvironment,
1697
2680
  isPublishedInAllEnvironments,
2681
+ isQuestionElement,
2682
+ isRestrictedType,
1698
2683
  isString,
1699
2684
  isTimeConditionDataLegacy,
1700
2685
  isTimeConditionDataV2,
@@ -1709,10 +2694,14 @@ var filterNullAttributes = (attributes) => {
1709
2694
  navigator,
1710
2695
  normalizeTimeConditionData,
1711
2696
  parseUrlParams,
2697
+ processQuestionElements,
1712
2698
  regenerateConditionIds,
2699
+ regenerateTarget,
2700
+ regenerateTrigger,
1713
2701
  removeAuthToken,
1714
2702
  setAuthToken,
1715
2703
  storage,
2704
+ surveysValue,
1716
2705
  userAgent,
1717
2706
  uuidV4,
1718
2707
  wait,