@picked/client 0.0.1-dev.1789541668638 → 0.0.1-next.2

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.
Files changed (443) hide show
  1. package/README.md +8 -0
  2. package/dist/cjs/index.js +1 -4
  3. package/dist/cjs/plugins/create-experience/index.js +1 -1
  4. package/dist/cjs/plugins/experience-browserstorage-plugin/index.js +1 -0
  5. package/dist/cjs/plugins/history-browserstorage-plugin/index.js +1 -0
  6. package/dist/cjs/plugins/responses-browserstorage-plugin/index.js +1 -0
  7. package/dist/cjs/plugins/responses-indexeddb-plugin/index.js +1 -0
  8. package/dist/cjs/plugins/shopify/index.js +1 -0
  9. package/dist/cjs/plugins/single-page-app/index.js +1 -1
  10. package/dist/cjs/plugins/window-object/index.js +1 -1
  11. package/dist/cjs/server/index.js +1 -1
  12. package/dist/esm/index.js +739 -1814
  13. package/dist/esm/plugins/create-experience/index.js +398 -490
  14. package/dist/esm/plugins/experience-browserstorage-plugin/index.js +38 -0
  15. package/dist/esm/plugins/history-browserstorage-plugin/index.js +26 -0
  16. package/dist/esm/plugins/responses-browserstorage-plugin/index.js +36 -0
  17. package/dist/esm/plugins/responses-indexeddb-plugin/index.js +101 -0
  18. package/dist/esm/plugins/shopify/index.js +59 -0
  19. package/dist/esm/plugins/single-page-app/index.js +35 -31
  20. package/dist/esm/plugins/window-object/index.js +9 -9
  21. package/dist/esm/server/index.js +89 -141
  22. package/dist/experience-instance-6ZKZS7dF.cjs +1 -0
  23. package/dist/experience-instance-BA0EXYg5.js +712 -0
  24. package/dist/id-BKIWbSTy.cjs +1 -0
  25. package/dist/id-BW-g3y32.js +6 -0
  26. package/dist/logger-BsmHUUw1.cjs +1 -0
  27. package/dist/logger-C9a75KZn.js +5 -0
  28. package/dist/object-BbFTsGh3.cjs +1 -0
  29. package/dist/object-JwZ58NOH.js +28 -0
  30. package/dist/storage-BPJwmlva.cjs +1 -0
  31. package/dist/storage-D87xFySf.js +85 -0
  32. package/dist/supports-BvrzQAVk.js +79 -0
  33. package/dist/supports-C0y3-V5V.cjs +1 -0
  34. package/dist/types/client.d.ts +23 -119
  35. package/dist/types/client.d.ts.map +1 -1
  36. package/dist/types/entities/component/component.d.ts +6 -45
  37. package/dist/types/entities/component/component.d.ts.map +1 -1
  38. package/dist/types/entities/experience/experience.d.ts +99 -160
  39. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  40. package/dist/types/entities/experience-instance/experience-instance.d.ts +113 -83
  41. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  42. package/dist/types/entities/feature/feature.d.ts +8 -118
  43. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  44. package/dist/types/entities/field/field.d.ts +64 -96
  45. package/dist/types/entities/field/field.d.ts.map +1 -1
  46. package/dist/types/entities/framework/framework.d.ts +7 -32
  47. package/dist/types/entities/framework/framework.d.ts.map +1 -1
  48. package/dist/types/entities/history/history.d.ts +6 -6
  49. package/dist/types/entities/history/history.d.ts.map +1 -1
  50. package/dist/types/entities/plugin/plugin.d.ts +2 -41
  51. package/dist/types/entities/plugin/plugin.d.ts.map +1 -1
  52. package/dist/types/entities/predicate/predicate.d.ts +7 -30
  53. package/dist/types/entities/predicate/predicate.d.ts.map +1 -1
  54. package/dist/types/entities/project/project.d.ts +9 -0
  55. package/dist/types/entities/project/project.d.ts.map +1 -0
  56. package/dist/types/entities/response/response.d.ts +21 -57
  57. package/dist/types/entities/response/response.d.ts.map +1 -1
  58. package/dist/types/exports.d.ts +4 -22
  59. package/dist/types/exports.d.ts.map +1 -1
  60. package/dist/types/index.d.ts +3 -12
  61. package/dist/types/index.d.ts.map +1 -1
  62. package/dist/types/logic-engine.d.ts +11 -13
  63. package/dist/types/logic-engine.d.ts.map +1 -1
  64. package/dist/types/picked.d.ts +184 -381
  65. package/dist/types/picked.d.ts.map +1 -1
  66. package/dist/types/ping.d.ts +10 -0
  67. package/dist/types/ping.d.ts.map +1 -0
  68. package/dist/types/plugins/create-experience/create-experience.d.ts +44 -119
  69. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  70. package/dist/types/plugins/create-experience/index.d.ts +2 -2
  71. package/dist/types/plugins/create-experience/index.d.ts.map +1 -1
  72. package/dist/types/plugins/create-experience/plugin.d.ts +2 -3
  73. package/dist/types/plugins/create-experience/plugin.d.ts.map +1 -1
  74. package/dist/types/plugins/create-experience/serialization.d.ts.map +1 -1
  75. package/dist/types/plugins/experience-browserstorage-plugin/index.d.ts.map +1 -0
  76. package/dist/types/plugins/experience-browserstorage-plugin/plugin.d.ts +6 -0
  77. package/dist/types/plugins/experience-browserstorage-plugin/plugin.d.ts.map +1 -0
  78. package/dist/types/plugins/history-browserstorage-plugin/index.d.ts.map +1 -0
  79. package/dist/types/plugins/{history-browser-storage → history-browserstorage-plugin}/plugin.d.ts +1 -2
  80. package/dist/types/plugins/history-browserstorage-plugin/plugin.d.ts.map +1 -0
  81. package/dist/types/plugins/responses-browserstorage-plugin/index.d.ts.map +1 -0
  82. package/dist/types/plugins/responses-browserstorage-plugin/plugin.d.ts +6 -0
  83. package/dist/types/plugins/responses-browserstorage-plugin/plugin.d.ts.map +1 -0
  84. package/dist/types/plugins/responses-indexeddb-plugin/index.d.ts.map +1 -0
  85. package/dist/types/plugins/responses-indexeddb-plugin/plugin.d.ts +3 -0
  86. package/dist/types/plugins/responses-indexeddb-plugin/plugin.d.ts.map +1 -0
  87. package/dist/types/plugins/shopify/index.d.ts +2 -0
  88. package/dist/types/plugins/shopify/index.d.ts.map +1 -0
  89. package/dist/types/plugins/shopify/plugin.d.ts +3 -0
  90. package/dist/types/plugins/shopify/plugin.d.ts.map +1 -0
  91. package/dist/types/plugins/shopify/shopify.d.ts +28 -0
  92. package/dist/types/plugins/shopify/shopify.d.ts.map +1 -0
  93. package/dist/types/plugins/single-page-app/plugin.d.ts +2 -2
  94. package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
  95. package/dist/types/plugins/window-object/plugin.d.ts +2 -2
  96. package/dist/types/server/index.d.ts +3 -18
  97. package/dist/types/server/index.d.ts.map +1 -1
  98. package/dist/types/utils/dom.d.ts +6 -4
  99. package/dist/types/utils/dom.d.ts.map +1 -1
  100. package/dist/types/utils/events.d.ts +38 -83
  101. package/dist/types/utils/events.d.ts.map +1 -1
  102. package/dist/types/utils/global-obj.d.ts +2 -1
  103. package/dist/types/utils/global-obj.d.ts.map +1 -1
  104. package/dist/types/utils/id.d.ts.map +1 -1
  105. package/dist/types/utils/indexed-db.d.ts +1 -2
  106. package/dist/types/utils/indexed-db.d.ts.map +1 -1
  107. package/dist/types/utils/logger.d.ts +1 -2
  108. package/dist/types/utils/logger.d.ts.map +1 -1
  109. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +3 -0
  110. package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +1 -0
  111. package/dist/types/utils/node-tree/get-next-node.d.ts +1 -1
  112. package/dist/types/utils/node-tree/get-next-node.d.ts.map +1 -1
  113. package/dist/types/utils/node-tree/get-origin-node.d.ts +1 -1
  114. package/dist/types/utils/node-tree/get-origin-node.d.ts.map +1 -1
  115. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts +7 -17
  116. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  117. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts +8 -19
  118. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  119. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +7 -31
  120. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  121. package/dist/types/utils/nodes.d.ts +2 -3
  122. package/dist/types/utils/nodes.d.ts.map +1 -1
  123. package/dist/types/utils/object.d.ts +8 -0
  124. package/dist/types/utils/object.d.ts.map +1 -1
  125. package/dist/types/utils/rules-logic.d.ts +3 -33
  126. package/dist/types/utils/rules-logic.d.ts.map +1 -1
  127. package/dist/types/utils/search-params.d.ts.map +1 -1
  128. package/dist/types/utils/state-snaphot.d.ts +16 -0
  129. package/dist/types/utils/state-snaphot.d.ts.map +1 -0
  130. package/dist/types/utils/storage.d.ts +11 -374
  131. package/dist/types/utils/storage.d.ts.map +1 -1
  132. package/dist/types/utils/supports.d.ts +0 -87
  133. package/dist/types/utils/supports.d.ts.map +1 -1
  134. package/package.json +49 -182
  135. package/dist/.tsbuildinfo +0 -1
  136. package/dist/api-C7q_7vxn.js +0 -22
  137. package/dist/api-Ctvh1qkk.cjs +0 -1
  138. package/dist/cjs/form/index.js +0 -1
  139. package/dist/cjs/plugins/dom-observer/index.js +0 -1
  140. package/dist/cjs/plugins/dynamic-experiences/index.js +0 -1
  141. package/dist/cjs/plugins/experience-browser-storage/index.js +0 -1
  142. package/dist/cjs/plugins/history-browser-storage/index.js +0 -1
  143. package/dist/cjs/plugins/responses-browser-storage/index.js +0 -1
  144. package/dist/cjs/plugins/responses-indexeddb/index.js +0 -1
  145. package/dist/cjs/plugins/telemetry/index.js +0 -1
  146. package/dist/cjs/plugins/web-components/index.js +0 -1
  147. package/dist/cjs/preview/index.js +0 -1
  148. package/dist/docs/_root.css +0 -101
  149. package/dist/docs/explanation/conditions-and-the-logic-engine.md +0 -94
  150. package/dist/docs/explanation/content-references.md +0 -99
  151. package/dist/docs/explanation/feature-flag-allocation.md +0 -218
  152. package/dist/docs/explanation/how-picked-works.md +0 -124
  153. package/dist/docs/explanation/how-pickedql-works.md +0 -76
  154. package/dist/docs/explanation/pages-and-flows.md +0 -64
  155. package/dist/docs/explanation/the-content-model.md +0 -87
  156. package/dist/docs/explanation/the-two-apis.md +0 -68
  157. package/dist/docs/explanation/why-server-side-rendering.md +0 -76
  158. package/dist/docs/explanation/workspaces-and-versions.md +0 -71
  159. package/dist/docs/how-to/add-a-step-field-or-action.md +0 -43
  160. package/dist/docs/how-to/analytics/index.md +0 -316
  161. package/dist/docs/how-to/archive-or-delete-a-workspace.md +0 -46
  162. package/dist/docs/how-to/authenticate-the-cli.md +0 -97
  163. package/dist/docs/how-to/authenticate-with-a-magic-link.md +0 -40
  164. package/dist/docs/how-to/authenticate-with-a-password.md +0 -51
  165. package/dist/docs/how-to/authenticate-with-an-api-key.md +0 -51
  166. package/dist/docs/how-to/authenticate-with-oauth.md +0 -40
  167. package/dist/docs/how-to/build-a-flow.md +0 -83
  168. package/dist/docs/how-to/connect-the-mcp-server.md +0 -38
  169. package/dist/docs/how-to/create-a-content-entry.md +0 -48
  170. package/dist/docs/how-to/create-a-project.md +0 -29
  171. package/dist/docs/how-to/create-an-experience.md +0 -42
  172. package/dist/docs/how-to/create-and-revoke-an-api-key.md +0 -42
  173. package/dist/docs/how-to/debug-with-the-chrome-extension.md +0 -57
  174. package/dist/docs/how-to/define-a-page-layout.md +0 -46
  175. package/dist/docs/how-to/fill-and-publish-a-page.md +0 -66
  176. package/dist/docs/how-to/install-the-gtm-template.md +0 -84
  177. package/dist/docs/how-to/install-the-sdk.md +0 -93
  178. package/dist/docs/how-to/install-the-vite-plugin.md +0 -69
  179. package/dist/docs/how-to/invite-and-remove-members.md +0 -35
  180. package/dist/docs/how-to/point-one-entry-at-another.md +0 -61
  181. package/dist/docs/how-to/preview-a-workspace.md +0 -28
  182. package/dist/docs/how-to/publish-a-workspace.md +0 -30
  183. package/dist/docs/how-to/read-a-feature-flag.md +0 -113
  184. package/dist/docs/how-to/read-a-referenced-entry.md +0 -109
  185. package/dist/docs/how-to/register-a-component.md +0 -55
  186. package/dist/docs/how-to/register-an-action-handler.md +0 -67
  187. package/dist/docs/how-to/render-a-step-form.md +0 -131
  188. package/dist/docs/how-to/render-an-unpublished-preview.md +0 -41
  189. package/dist/docs/how-to/reuse-a-section.md +0 -53
  190. package/dist/docs/how-to/reuse-a-step-field-or-action.md +0 -28
  191. package/dist/docs/how-to/roll-back-a-published-version.md +0 -26
  192. package/dist/docs/how-to/run-an-ab-test.md +0 -49
  193. package/dist/docs/how-to/run-code-on-a-form-submission.md +0 -125
  194. package/dist/docs/how-to/server-render-a-page.md +0 -81
  195. package/dist/docs/how-to/set-a-content-security-policy.md +0 -32
  196. package/dist/docs/how-to/set-up-mfa.md +0 -69
  197. package/dist/docs/how-to/switch-workspaces.md +0 -122
  198. package/dist/docs/how-to/upload-and-use-an-asset.mdx +0 -73
  199. package/dist/docs/how-to/validate-a-field.md +0 -52
  200. package/dist/docs/how-to/write-a-condition.md +0 -45
  201. package/dist/docs/how-to/write-a-predicate.md +0 -60
  202. package/dist/docs/index.md +0 -59
  203. package/dist/docs/reference/dashboard/actions.mdx +0 -53
  204. package/dist/docs/reference/dashboard/api-keys.mdx +0 -38
  205. package/dist/docs/reference/dashboard/conditions.mdx +0 -42
  206. package/dist/docs/reference/dashboard/content/asset-library.mdx +0 -63
  207. package/dist/docs/reference/dashboard/content/blocks.mdx +0 -57
  208. package/dist/docs/reference/dashboard/content/content-entries.mdx +0 -95
  209. package/dist/docs/reference/dashboard/content/models.mdx +0 -108
  210. package/dist/docs/reference/dashboard/content/pages.mdx +0 -61
  211. package/dist/docs/reference/dashboard/experiences.mdx +0 -51
  212. package/dist/docs/reference/dashboard/features.mdx +0 -154
  213. package/dist/docs/reference/dashboard/fields.mdx +0 -106
  214. package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +0 -58
  215. package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +0 -57
  216. package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +0 -72
  217. package/dist/docs/reference/dashboard/flow-builder/nodes.md +0 -63
  218. package/dist/docs/reference/dashboard/projects.mdx +0 -44
  219. package/dist/docs/reference/dashboard/reports.mdx +0 -43
  220. package/dist/docs/reference/dashboard/steps.mdx +0 -37
  221. package/dist/docs/reference/dashboard/team-management.md +0 -29
  222. package/dist/docs/reference/dashboard/workspace-versioning.mdx +0 -30
  223. package/dist/docs/reference/dashboard/workspaces.mdx +0 -76
  224. package/dist/docs/reference/delivery-api/experience-content.md +0 -152
  225. package/dist/docs/reference/delivery-api/index.md +0 -45
  226. package/dist/docs/reference/delivery-api/preview-caching-crawling.md +0 -79
  227. package/dist/docs/reference/delivery-api/project-config.md +0 -65
  228. package/dist/docs/reference/delivery-api/workspace-schema.md +0 -85
  229. package/dist/docs/reference/glossary.md +0 -181
  230. package/dist/docs/reference/management-api/authentication.md +0 -74
  231. package/dist/docs/reference/management-api/authorization-and-scopes.md +0 -285
  232. package/dist/docs/reference/management-api/error-handling.md +0 -233
  233. package/dist/docs/reference/management-api/pagination.md +0 -192
  234. package/dist/docs/reference/pickedql/data-sources.md +0 -174
  235. package/dist/docs/reference/pickedql/dimensions.md +0 -103
  236. package/dist/docs/reference/pickedql/filtering.md +0 -64
  237. package/dist/docs/reference/pickedql/index.md +0 -18
  238. package/dist/docs/reference/pickedql/schema.md +0 -172
  239. package/dist/docs/reference/pickedql/virtual-functions.md +0 -248
  240. package/dist/docs/reference/sdk/actions.md +0 -30
  241. package/dist/docs/reference/sdk/analytics-events.md +0 -445
  242. package/dist/docs/reference/sdk/conditions.md +0 -147
  243. package/dist/docs/reference/sdk/content-security-policy.md +0 -21
  244. package/dist/docs/reference/sdk/content.md +0 -213
  245. package/dist/docs/reference/sdk/experiences.md +0 -51
  246. package/dist/docs/reference/sdk/features.md +0 -256
  247. package/dist/docs/reference/sdk/fields.md +0 -255
  248. package/dist/docs/reference/sdk/index.md +0 -68
  249. package/dist/docs/reference/sdk/plugins/create-experience.md +0 -123
  250. package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +0 -74
  251. package/dist/docs/reference/sdk/plugins/index.md +0 -29
  252. package/dist/docs/reference/sdk/plugins/window-object.md +0 -25
  253. package/dist/docs/reference/sdk/predicates.md +0 -43
  254. package/dist/docs/reference/sdk/ssr/index.md +0 -33
  255. package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +0 -103
  256. package/dist/docs/reference/sdk/ssr/serialize.md +0 -80
  257. package/dist/docs/reference/sdk/ssr/slots-and-placements.md +0 -59
  258. package/dist/docs/reference/sdk/steps.md +0 -86
  259. package/dist/docs/reference/sdk/type-generation.md +0 -196
  260. package/dist/docs/reference/tools/chrome-extension.md +0 -16
  261. package/dist/docs/reference/tools/cli.md +0 -146
  262. package/dist/docs/reference/tools/image-optimisation-service.md +0 -104
  263. package/dist/docs/reference/tools/mcp.md +0 -90
  264. package/dist/docs/reference/tools/vite-plugin.md +0 -163
  265. package/dist/docs/tutorials/first-api-call.md +0 -228
  266. package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +0 -143
  267. package/dist/docs/tutorials/first-experience.mdx +0 -254
  268. package/dist/docs/tutorials/first-server-rendered-page.mdx +0 -186
  269. package/dist/dom-BqcToNL0.js +0 -82
  270. package/dist/dom-DlLH3FxV.cjs +0 -1
  271. package/dist/emit-D-tLiWL1.cjs +0 -1
  272. package/dist/emit-Ds2EG7CB.js +0 -14
  273. package/dist/esm/form/index.js +0 -565
  274. package/dist/esm/plugins/dom-observer/index.js +0 -87
  275. package/dist/esm/plugins/dynamic-experiences/index.js +0 -5
  276. package/dist/esm/plugins/experience-browser-storage/index.js +0 -38
  277. package/dist/esm/plugins/history-browser-storage/index.js +0 -26
  278. package/dist/esm/plugins/responses-browser-storage/index.js +0 -71
  279. package/dist/esm/plugins/responses-indexeddb/index.js +0 -89
  280. package/dist/esm/plugins/telemetry/index.js +0 -100
  281. package/dist/esm/plugins/web-components/index.js +0 -19
  282. package/dist/esm/preview/index.js +0 -2
  283. package/dist/experience-instance-B9S6Yf0N.js +0 -711
  284. package/dist/experience-instance-D8rOg6We.cjs +0 -1
  285. package/dist/id-Bo4RBeOs.js +0 -4
  286. package/dist/id-Js-62re-.cjs +0 -1
  287. package/dist/inert-script-report-B_bMPRzp.js +0 -18
  288. package/dist/inert-script-report-ijRHPtcY.cjs +0 -1
  289. package/dist/logger-CSTvAyyB.cjs +0 -1
  290. package/dist/logger-DMN6TxJJ.js +0 -4
  291. package/dist/object-BUDGxEqy.js +0 -25
  292. package/dist/object-CIkt7Fkr.cjs +0 -1
  293. package/dist/plugin-ChafFq6S.js +0 -194
  294. package/dist/plugin-Dn25Gffy.cjs +0 -1
  295. package/dist/preview-channel-CSr96XAo.js +0 -98
  296. package/dist/preview-channel-Cx0e6fye.cjs +0 -1
  297. package/dist/protocol-Bb_vpLKE.cjs +0 -1
  298. package/dist/protocol-C5KkkiZc.js +0 -84
  299. package/dist/provider-B8wvmeC8.js +0 -98
  300. package/dist/provider-BBLlQOjV.cjs +0 -1
  301. package/dist/registry-C1t8l3t9.cjs +0 -1
  302. package/dist/registry-CXZv0uLg.js +0 -18
  303. package/dist/rules-logic-CGZIYgAI.cjs +0 -1
  304. package/dist/rules-logic-HesIUCu6.js +0 -13
  305. package/dist/storage-1MW3-_As.js +0 -103
  306. package/dist/storage-DUw9UJ2h.cjs +0 -1
  307. package/dist/supports-CO9bJGNl.js +0 -92
  308. package/dist/supports-DBzjGaWD.cjs +0 -1
  309. package/dist/types/data-source/api.d.ts +0 -60
  310. package/dist/types/data-source/api.d.ts.map +0 -1
  311. package/dist/types/data-source/provider.d.ts +0 -103
  312. package/dist/types/data-source/provider.d.ts.map +0 -1
  313. package/dist/types/data-source/registry.d.ts +0 -26
  314. package/dist/types/data-source/registry.d.ts.map +0 -1
  315. package/dist/types/data-source/request-observer.d.ts +0 -62
  316. package/dist/types/data-source/request-observer.d.ts.map +0 -1
  317. package/dist/types/data-source/virtual-data.d.ts +0 -19
  318. package/dist/types/data-source/virtual-data.d.ts.map +0 -1
  319. package/dist/types/entities/action/action.d.ts +0 -85
  320. package/dist/types/entities/action/action.d.ts.map +0 -1
  321. package/dist/types/entities/component/lazyComponent.d.ts +0 -11
  322. package/dist/types/entities/component/lazyComponent.d.ts.map +0 -1
  323. package/dist/types/entities/condition/condition.d.ts +0 -29
  324. package/dist/types/entities/condition/condition.d.ts.map +0 -1
  325. package/dist/types/entities/content/content.d.ts +0 -53
  326. package/dist/types/entities/content/content.d.ts.map +0 -1
  327. package/dist/types/entities/content/reference.d.ts +0 -101
  328. package/dist/types/entities/content/reference.d.ts.map +0 -1
  329. package/dist/types/entities/field/policies.d.ts +0 -35
  330. package/dist/types/entities/field/policies.d.ts.map +0 -1
  331. package/dist/types/entities/response/response-validation.d.ts +0 -75
  332. package/dist/types/entities/response/response-validation.d.ts.map +0 -1
  333. package/dist/types/entities/session/session.d.ts +0 -46
  334. package/dist/types/entities/session/session.d.ts.map +0 -1
  335. package/dist/types/entities/step/step.d.ts +0 -56
  336. package/dist/types/entities/step/step.d.ts.map +0 -1
  337. package/dist/types/form/build-responses.d.ts +0 -18
  338. package/dist/types/form/build-responses.d.ts.map +0 -1
  339. package/dist/types/form/create-field-evaluator.d.ts +0 -28
  340. package/dist/types/form/create-field-evaluator.d.ts.map +0 -1
  341. package/dist/types/form/create-field-validation.d.ts +0 -60
  342. package/dist/types/form/create-field-validation.d.ts.map +0 -1
  343. package/dist/types/form/create-form.d.ts +0 -153
  344. package/dist/types/form/create-form.d.ts.map +0 -1
  345. package/dist/types/form/create-submit-pipeline.d.ts +0 -116
  346. package/dist/types/form/create-submit-pipeline.d.ts.map +0 -1
  347. package/dist/types/form/get-step-fields.d.ts +0 -19
  348. package/dist/types/form/get-step-fields.d.ts.map +0 -1
  349. package/dist/types/form/index.d.ts +0 -11
  350. package/dist/types/form/index.d.ts.map +0 -1
  351. package/dist/types/lifecycle/condition-selection.d.ts +0 -146
  352. package/dist/types/lifecycle/condition-selection.d.ts.map +0 -1
  353. package/dist/types/lifecycle/lifecycle.d.ts +0 -48
  354. package/dist/types/lifecycle/lifecycle.d.ts.map +0 -1
  355. package/dist/types/lifecycle/rules-logic.d.ts +0 -25
  356. package/dist/types/lifecycle/rules-logic.d.ts.map +0 -1
  357. package/dist/types/lifecycle/state-snapshot.d.ts +0 -38
  358. package/dist/types/lifecycle/state-snapshot.d.ts.map +0 -1
  359. package/dist/types/plugins/dom-observer/index.d.ts +0 -3
  360. package/dist/types/plugins/dom-observer/index.d.ts.map +0 -1
  361. package/dist/types/plugins/dom-observer/plugin.d.ts +0 -50
  362. package/dist/types/plugins/dom-observer/plugin.d.ts.map +0 -1
  363. package/dist/types/plugins/dynamic-experiences/hash.d.ts +0 -105
  364. package/dist/types/plugins/dynamic-experiences/hash.d.ts.map +0 -1
  365. package/dist/types/plugins/dynamic-experiences/index.d.ts +0 -7
  366. package/dist/types/plugins/dynamic-experiences/index.d.ts.map +0 -1
  367. package/dist/types/plugins/dynamic-experiences/plugin.d.ts +0 -49
  368. package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +0 -1
  369. package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -45
  370. package/dist/types/plugins/dynamic-experiences/types.d.ts.map +0 -1
  371. package/dist/types/plugins/experience-browser-storage/index.d.ts.map +0 -1
  372. package/dist/types/plugins/experience-browser-storage/plugin.d.ts +0 -7
  373. package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +0 -1
  374. package/dist/types/plugins/history-browser-storage/index.d.ts.map +0 -1
  375. package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +0 -1
  376. package/dist/types/plugins/responses-browser-storage/index.d.ts.map +0 -1
  377. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +0 -18
  378. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +0 -1
  379. package/dist/types/plugins/responses-indexeddb/index.d.ts.map +0 -1
  380. package/dist/types/plugins/responses-indexeddb/plugin.d.ts +0 -3
  381. package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +0 -1
  382. package/dist/types/plugins/telemetry/emit.d.ts +0 -18
  383. package/dist/types/plugins/telemetry/emit.d.ts.map +0 -1
  384. package/dist/types/plugins/telemetry/index.d.ts +0 -4
  385. package/dist/types/plugins/telemetry/index.d.ts.map +0 -1
  386. package/dist/types/plugins/telemetry/plugin-summary.d.ts +0 -10
  387. package/dist/types/plugins/telemetry/plugin-summary.d.ts.map +0 -1
  388. package/dist/types/plugins/telemetry/plugin.d.ts +0 -45
  389. package/dist/types/plugins/telemetry/plugin.d.ts.map +0 -1
  390. package/dist/types/plugins/web-components/index.d.ts +0 -2
  391. package/dist/types/plugins/web-components/index.d.ts.map +0 -1
  392. package/dist/types/plugins/web-components/plugin.d.ts +0 -4
  393. package/dist/types/plugins/web-components/plugin.d.ts.map +0 -1
  394. package/dist/types/preview/index.d.ts +0 -18
  395. package/dist/types/preview/index.d.ts.map +0 -1
  396. package/dist/types/preview-bridge/index.d.ts +0 -14
  397. package/dist/types/preview-bridge/index.d.ts.map +0 -1
  398. package/dist/types/preview-channel.d.ts +0 -16
  399. package/dist/types/preview-channel.d.ts.map +0 -1
  400. package/dist/types/preview-receiver/apply-ops.d.ts +0 -32
  401. package/dist/types/preview-receiver/apply-ops.d.ts.map +0 -1
  402. package/dist/types/preview-receiver/index.d.ts +0 -32
  403. package/dist/types/preview-receiver/index.d.ts.map +0 -1
  404. package/dist/types/preview-receiver/protocol.d.ts +0 -69
  405. package/dist/types/preview-receiver/protocol.d.ts.map +0 -1
  406. package/dist/types/schema-registry.d.ts +0 -206
  407. package/dist/types/schema-registry.d.ts.map +0 -1
  408. package/dist/types/server/serialize.d.ts +0 -87
  409. package/dist/types/server/serialize.d.ts.map +0 -1
  410. package/dist/types/typed-content.d.ts +0 -17
  411. package/dist/types/typed-content.d.ts.map +0 -1
  412. package/dist/types/utils/client-telemetry.d.ts +0 -25
  413. package/dist/types/utils/client-telemetry.d.ts.map +0 -1
  414. package/dist/types/utils/content-path.d.ts +0 -37
  415. package/dist/types/utils/content-path.d.ts.map +0 -1
  416. package/dist/types/utils/html-asset-value.d.ts +0 -20
  417. package/dist/types/utils/html-asset-value.d.ts.map +0 -1
  418. package/dist/types/utils/inert-script-report.d.ts +0 -40
  419. package/dist/types/utils/inert-script-report.d.ts.map +0 -1
  420. package/dist/types/utils/node-tree/get-next-node-from-action.d.ts +0 -25
  421. package/dist/types/utils/node-tree/get-next-node-from-action.d.ts.map +0 -1
  422. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts +0 -17
  423. package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +0 -1
  424. package/dist/types/utils/node-tree/node-adjacency.d.ts +0 -50
  425. package/dist/types/utils/node-tree/node-adjacency.d.ts.map +0 -1
  426. package/dist/types/utils/node-tree/node-tree-index.d.ts +0 -57
  427. package/dist/types/utils/node-tree/node-tree-index.d.ts.map +0 -1
  428. package/dist/types/utils/picked-config.d.ts +0 -39
  429. package/dist/types/utils/picked-config.d.ts.map +0 -1
  430. package/dist/types/utils/preview-session.d.ts +0 -12
  431. package/dist/types/utils/preview-session.d.ts.map +0 -1
  432. package/dist/types/utils/rehydrate-scripts.d.ts +0 -50
  433. package/dist/types/utils/rehydrate-scripts.d.ts.map +0 -1
  434. package/dist/types/utils/render-string.d.ts +0 -24
  435. package/dist/types/utils/render-string.d.ts.map +0 -1
  436. package/dist/types/utils/user-timing.d.ts +0 -21
  437. package/dist/types/utils/user-timing.d.ts.map +0 -1
  438. package/dist/version-CLjPfmxk.cjs +0 -1
  439. package/dist/version-CPKulHMH.js +0 -256
  440. /package/dist/types/plugins/{experience-browser-storage → experience-browserstorage-plugin}/index.d.ts +0 -0
  441. /package/dist/types/plugins/{history-browser-storage → history-browserstorage-plugin}/index.d.ts +0 -0
  442. /package/dist/types/plugins/{responses-browser-storage → responses-browserstorage-plugin}/index.d.ts +0 -0
  443. /package/dist/types/plugins/{responses-indexeddb → responses-indexeddb-plugin}/index.d.ts +0 -0
package/dist/esm/index.js CHANGED
@@ -1,1826 +1,751 @@
1
- import { t as e } from "../object-BUDGxEqy.js";
2
- import { n as t, t as n } from "../rules-logic-HesIUCu6.js";
3
- import { t as r } from "../logger-DMN6TxJJ.js";
4
- import { a as i, c as a, d as o, f as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _ } from "../supports-CO9bJGNl.js";
5
- import { a as v, i as y, r as ee, s as b, t as x } from "../dom-BqcToNL0.js";
6
- import { d as S, l as C, n as w, r as te, u as T } from "../experience-instance-B9S6Yf0N.js";
7
- import { i as ne, n as E, r as D, t as O } from "../storage-1MW3-_As.js";
8
- import { i as re, n as ie, r as ae, t as oe } from "../version-CPKulHMH.js";
9
- import { t as se } from "../id-Bo4RBeOs.js";
10
- import { n as ce, r as le, t as ue } from "../inert-script-report-B_bMPRzp.js";
11
- import { attach as k, combine as A, createApi as j, createDomain as M, createEffect as N, createEvent as P, createStore as F, is as de, sample as I } from "effector";
12
- import { createFactory as L, invoke as R } from "@withease/factories";
13
- //#region src/entities/experience/experience.ts
14
- var z = M("experience"), fe = L(({ client: e, experience: r }) => {
15
- let i = z.store(r), a = j(i, { merge(e, t) {
16
- return {
17
- ...e,
18
- ...t.experience
19
- };
20
- } }), o = i.map((e) => ({
21
- name: e.name,
22
- decisionLogic: e.condition,
23
- targetSelectors: e.targets,
24
- initializeOpenLogic: e.initializeOpen
25
- })), s = A(i, e.components.listStore, (e, t) => (e.componentName ? t.find((t) => t.name === e.componentName) : void 0) || t.find((t) => t.name === `experience:${e.id}`) || t.find((e) => e.name === "experience"), { skipVoid: !1 }), c = A(i, e.steps.indexStore, e.conditions.indexStore, (e, t, n) => {
26
- let r = e.nodes.filter(S).map((e) => t[e.stepId]).filter((e) => e !== void 0), i = e.nodes.filter(T).map((e) => n[e.conditionId]).filter((e) => e !== void 0);
27
- return {
28
- steps: r,
29
- nodes: e.nodes,
30
- edges: e.edges,
31
- conditions: i
32
- };
33
- }), l = i.map((e) => C(e.nodes, e.edges)), u = r.actions ?? [], d, f = k({
34
- source: o,
35
- effect: (t, n) => {
36
- let i = y(t.targetSelectors, r.id);
37
- i.forEach(({ elements: e }) => e.forEach((e) => b(e, r.id))), x(i, r.id, r.key).forEach((t) => {
38
- n ? e.experienceInstances.spawn(d, t, n) : e.experienceInstances.spawn(d, t);
39
- });
40
- }
41
- }), p = A({
42
- preconditionPassed: e.preconditionPassedStore,
43
- isUser: e.session.store.map((e) => e.isUser, { skipVoid: !1 }),
44
- config: o
45
- }), m = k({
46
- source: p,
47
- effect: async ({ preconditionPassed: i, isUser: a, config: o }) => {
48
- if (!i || !a) return !1;
49
- let { decisionLogic: s, targetSelectors: c } = o;
50
- return c.length === 0 || y(c, r.id).length < 1 ? !1 : s === void 0 || !t(s) || await n(e, s) === !0;
51
- }
52
- }), h = N(async () => {
53
- if (!e.contentLoader) return !0;
54
- try {
55
- await e.contentLoader({
56
- id: r.id,
57
- key: r.key
58
- });
59
- } catch {
60
- `${r.id}`;
61
- }
62
- return !0;
63
- }), g = P(), _ = P(), v = z.createStore(void 0, { skipVoid: !1 }).on(g, (e, t) => t).on(_, (e, t) => t);
64
- return I({
65
- clock: g,
66
- target: m
67
- }), I({
68
- clock: m.doneData,
69
- source: v,
70
- filter: (e, t) => t,
71
- fn: (e) => e,
72
- target: f
73
- }), I({
74
- clock: m.doneData,
75
- filter: Boolean,
76
- target: h
77
- }), I({
78
- clock: _,
79
- source: v,
80
- fn: (e) => e,
81
- target: f
82
- }), I({
83
- clock: _,
84
- target: h
85
- }), d = {
86
- id: r.id,
87
- key: r.key,
88
- name: r.name,
89
- configStore: o,
90
- treeStore: c,
91
- nodeTreeStore: l,
92
- componentStore: s,
93
- actions: u,
94
- merge: a.merge,
95
- initialiseFx: f,
96
- shouldInitialiseFx: m,
97
- initialiseRequested: g,
98
- initialiseDirectly: _,
99
- prepareExperienceContentFx: h
100
- }, d;
1
+ var q = Object.defineProperty;
2
+ var G = (t, e, s) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var m = (t, e, s) => G(t, typeof e != "symbol" ? e + "" : e, s);
4
+ import { createDomain as x, createApi as b, createEffect as O, attach as W, sample as E, combine as R, createEvent as A } from "effector";
5
+ import { createFactory as v, invoke as k } from "@withease/factories";
6
+ import { g as z, t as J, c as Y, e as D, i as Q, a as X, b as Z, d as ee } from "../experience-instance-BA0EXYg5.js";
7
+ import { f as st } from "../experience-instance-BA0EXYg5.js";
8
+ import { l as w } from "../logger-C9a75KZn.js";
9
+ import { c as B, s as j, l as C } from "../storage-D87xFySf.js";
10
+ import { a as ot } from "../storage-D87xFySf.js";
11
+ import { g as te } from "../id-BW-g3y32.js";
12
+ import { i as re } from "../object-JwZ58NOH.js";
13
+ import { s as _, a as se, b as ne } from "../supports-BvrzQAVk.js";
14
+ import { g as at, d as ct, i as ut, e as lt, c as dt, f as pt, h as gt } from "../supports-BvrzQAVk.js";
15
+ const U = x("experience"), oe = v(
16
+ ({ client: t, experience: e }) => {
17
+ const s = U.store(e), o = b(s, {
18
+ merge(n, g) {
19
+ return {
20
+ ...n,
21
+ ...g.experience
22
+ };
23
+ }
24
+ }), i = s.map((n) => ({
25
+ type: n.type,
26
+ name: n.name,
27
+ decisionLogic: n.decide,
28
+ targetSelectors: n.targets
29
+ })), d = t.components.listStore.map(
30
+ (n) => n.find((g) => g.name === `experience:${e.id}`) || n.find((g) => g.name === "experience"),
31
+ { skipVoid: !1 }
32
+ ), r = s.map((n) => ({
33
+ steps: n.steps,
34
+ nodes: n.nodes,
35
+ edges: n.edges,
36
+ conditionals: n.conditionals
37
+ }));
38
+ return {
39
+ id: e.id,
40
+ configStore: i,
41
+ treeStore: r,
42
+ componentStore: d,
43
+ merge: o.merge
44
+ };
45
+ }
46
+ );
47
+ function ie(t) {
48
+ return k(oe, t);
49
+ }
50
+ const ae = v(({ client: t }) => {
51
+ const e = U.store({}), s = b(e, {
52
+ register(r, n) {
53
+ return {
54
+ ...r,
55
+ [n.id]: n
56
+ };
57
+ }
58
+ });
59
+ function o(r) {
60
+ const n = e.getState()[r.id];
61
+ if (n) {
62
+ n.merge({ experience: r, strategy: "override" });
63
+ return;
64
+ }
65
+ const g = ie({ client: t, experience: r });
66
+ s.register(g);
67
+ }
68
+ const i = e.map((r) => Object.values(r));
69
+ function d(r) {
70
+ return e.map((n) => n[r], { skipVoid: !1 });
71
+ }
72
+ return {
73
+ register: o,
74
+ getById: d,
75
+ listStore: i
76
+ };
101
77
  });
102
- function pe(e) {
103
- return R(fe, e);
104
- }
105
- var me = L(({ client: e }) => {
106
- let t = z.store({}), n = j(t, { register(e, t) {
107
- return {
108
- ...e,
109
- [t.id]: t
110
- };
111
- } }), r = P(), i = N((t) => {
112
- n.register(pe({
113
- client: e,
114
- experience: t
115
- }));
116
- });
117
- I({
118
- clock: r,
119
- source: t,
120
- filter: (e, t) => e[t.id] !== void 0,
121
- fn: (e, t) => ({
122
- existing: e[t.id],
123
- experience: t
124
- })
125
- }).watch(({ existing: e, experience: t }) => {
126
- e?.merge({
127
- experience: t,
128
- strategy: "override"
129
- });
130
- }), I({
131
- clock: r,
132
- source: t,
133
- filter: (e, t) => e[t.id] === void 0,
134
- fn: (e, t) => t,
135
- target: i
136
- });
137
- let a = t.map((e) => Object.values(e));
138
- function o(e) {
139
- return t.map((t) => t[e], { skipVoid: !1 });
140
- }
141
- function s(e) {
142
- return t.map((t) => Object.values(t).find((t) => t.key === e) ?? t[e], { skipVoid: !1 });
143
- }
144
- let c = k({
145
- source: t,
146
- effect: (e, t) => {
147
- let n = "key" in t ? Object.values(e).find((e) => e.key === t.key) : e[t.id];
148
- if (!n) {
149
- "key" in t ? `${t.key}` : `${t.id}`;
150
- return;
151
- }
152
- let { options: r } = t;
153
- r?.bypassCondition ? n.initialiseDirectly(r) : n.initialiseRequested(r);
154
- }
155
- });
156
- return {
157
- register: r,
158
- get: o,
159
- getById: o,
160
- getByKey: s,
161
- launch: c,
162
- open: k({
163
- source: {
164
- experiences: t,
165
- instances: e.experienceInstances.listStore
166
- },
167
- effect: async ({ experiences: e, instances: t }, n) => {
168
- let r = "key" in n ? Object.values(e).find((e) => e.key === n.key) : e[n.id], i = t.filter((e) => e.experienceId === r?.id);
169
- if (i.length > 0) {
170
- for (let e of i) e.open();
171
- return;
172
- }
173
- let a = "key" in n ? {
174
- key: n.key,
175
- options: {
176
- ...n.options,
177
- initialiseOpen: !0
178
- }
179
- } : {
180
- id: n.id,
181
- options: {
182
- ...n.options,
183
- initialiseOpen: !0
184
- }
185
- };
186
- await c(a);
187
- }
188
- }),
189
- listStore: a,
190
- initialiseExperiencesFx: k({
191
- source: a,
192
- effect: (e) => {
193
- for (let t of e) t.initialiseRequested(void 0);
194
- }
195
- })
196
- };
78
+ function ce(t) {
79
+ return k(ae, t);
80
+ }
81
+ const ue = (t, e) => {
82
+ e.register(t);
83
+ }, H = (t, e) => {
84
+ const { targetSelectors: s } = e.configStore.getState(), o = z(s, e.id);
85
+ o.forEach(
86
+ ({ elements: d }) => d.forEach((r) => J(r, e.id))
87
+ ), Y(o).forEach((d) => {
88
+ t.experienceInstances.spawn(e, d);
89
+ });
90
+ }, V = async (t) => {
91
+ await Promise.all(
92
+ t.experiences.listStore.getState().map(async (e) => {
93
+ await le(t, e) && H(t, e);
94
+ })
95
+ );
96
+ }, le = async (t, e) => {
97
+ const { type: s, decisionLogic: o, targetSelectors: i } = e.configStore.getState();
98
+ return z(i, e.id).length < 1 ? !1 : s === "funnel" ? o ? await D(t, o) === !0 : !1 : i.length === 0 ? !1 : Q(o) ? await D(t, o) === !0 : !0;
99
+ }, de = (t, e, s) => {
100
+ const o = e.name, i = e.setup(t);
101
+ if (i) {
102
+ const d = s[o] ?? {};
103
+ s[o] = Object.freeze({ ...d, ...i });
104
+ }
105
+ }, pe = x("component"), ge = v(
106
+ ({ client: t, component: e, name: s }) => {
107
+ const o = t.frameworks.getByName(e.frameworkName);
108
+ return {
109
+ name: s,
110
+ component: e,
111
+ frameworkStore: o
112
+ };
113
+ }
114
+ );
115
+ function fe(t) {
116
+ return k(ge, t);
117
+ }
118
+ const me = v(({ client: t }) => {
119
+ const e = pe.store({}), s = b(e, {
120
+ register(r, n) {
121
+ return {
122
+ ...r,
123
+ [n.name]: n
124
+ };
125
+ }
126
+ });
127
+ function o(r, n) {
128
+ e.getState()[r] && w(
129
+ "warn",
130
+ `Component '${r}' already registered. Registering again will override the previous registration.`
131
+ );
132
+ const h = fe({ client: t, name: r, component: n });
133
+ s.register(h);
134
+ }
135
+ const i = e.map((r) => Object.values(r));
136
+ function d(r) {
137
+ return e.map((n) => n[r], { skipVoid: !1 });
138
+ }
139
+ return {
140
+ register: o,
141
+ getByName: d,
142
+ listStore: i
143
+ };
197
144
  });
198
- function he(e) {
199
- return R(me, e);
200
- }
201
- var ge = async (e) => {
202
- await e.experiences.initialiseExperiencesFx();
203
- };
204
- //#endregion
205
- //#region src/entities/plugin/plugin.ts
206
- function _e(e) {
207
- return N(async () => {
208
- await e();
209
- });
210
- }
211
- var ve = (e, t, n) => {
212
- let r = t.name, i = t.setup(e), a = n[r] ?? {};
213
- n[r] = Object.freeze({
214
- ...a,
215
- ...i
216
- });
217
- }, ye = M("component"), be = L(({ client: e, component: t, name: n }) => ({
218
- name: n,
219
- component: t,
220
- frameworkStore: e.frameworks.getByName(t.frameworkName)
221
- }));
222
- function xe(e) {
223
- return R(be, e);
224
- }
225
- var Se = L(({ client: e }) => {
226
- let t = ye.store({}), n = j(t, { register(e, t) {
227
- return {
228
- ...e,
229
- [t.name]: t
230
- };
231
- } }), i = P();
232
- I({
233
- clock: i,
234
- source: t,
235
- filter: (e, { name: t }) => e[t] !== void 0,
236
- fn: (e, { name: t }) => `Component '${t}' already registered. Registering again will override the previous registration.`
237
- }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
238
- clock: i,
239
- fn: ({ name: t, component: n }) => xe({
240
- client: e,
241
- name: t,
242
- component: n
243
- }),
244
- target: n.register
245
- });
246
- let a = t.map((e) => Object.values(e));
247
- function o(e) {
248
- return t.map((t) => t[e], { skipVoid: !1 });
249
- }
250
- return {
251
- register: i,
252
- getByName: o,
253
- listStore: a
254
- };
145
+ function ye(t) {
146
+ return k(me, t);
147
+ }
148
+ const M = (t, e, s) => {
149
+ s.register(t, e);
150
+ }, he = x("framework"), Se = v(({ client: t }) => {
151
+ const e = he.store({}), s = b(e, {
152
+ register(r, n) {
153
+ return {
154
+ ...r,
155
+ [n.name]: n.framework
156
+ };
157
+ }
158
+ });
159
+ function o(r, n) {
160
+ e.getState()[r] && w(
161
+ "warn",
162
+ `Framework '${r}' already registered. Registering again will override the previous registration.`
163
+ ), s.register({ name: r, framework: n });
164
+ }
165
+ const i = e.map((r) => Object.values(r));
166
+ function d(r) {
167
+ return e.map((n) => n[r], { skipVoid: !1 });
168
+ }
169
+ return {
170
+ register: o,
171
+ getByName: d,
172
+ listStore: i
173
+ };
255
174
  });
256
- function Ce(e) {
257
- return R(Se, e);
258
- }
259
- var we = (e, t, n) => {
260
- n.register({
261
- name: e,
262
- component: t
263
- });
264
- }, Te = M("framework"), Ee = L((e) => {
265
- let t = Te.store({}), n = j(t, { register(e, t) {
266
- return {
267
- ...e,
268
- [t.name]: t.framework
269
- };
270
- } }), i = P();
271
- I({
272
- clock: i,
273
- source: t,
274
- filter: (e, { name: t }) => e[t] !== void 0,
275
- fn: (e, { name: t }) => `Framework '${t}' already registered. Registering again will override the previous registration.`
276
- }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
277
- clock: i,
278
- target: n.register
279
- });
280
- let a = t.map((e) => Object.values(e));
281
- function o(e) {
282
- return t.map((t) => t[e], { skipVoid: !1 });
283
- }
284
- return {
285
- register: i,
286
- getByName: o,
287
- listStore: a
288
- };
289
- });
290
- function De(e) {
291
- return R(Ee, e);
292
- }
293
- var Oe = (e, t) => {
294
- t.register({
295
- name: e.name,
296
- framework: e
297
- });
298
- }, ke = L(({ client: e }) => {
299
- let t = "window" in globalThis, n = {
300
- location: t ? globalThis.location : void 0,
301
- document: t ? globalThis.document : void 0,
302
- sessionStorage: t ? globalThis.sessionStorage : void 0,
303
- localStorage: t ? globalThis.localStorage : void 0
304
- };
305
- return A(e.responses.listStore, e.fields.listStore, (t, r) => Object.freeze({
306
- client: e,
307
- responses: t,
308
- fields: r,
309
- ...n
310
- }));
311
- });
312
- function Ae(e) {
313
- return R(ke, e);
314
- }
315
- //#endregion
316
- //#region src/logic-engine.ts
317
- function je(e) {
318
- return typeof e == "number" && !isNaN(e);
319
- }
320
- function B(e) {
321
- return typeof e == "string";
322
- }
323
- function V(e) {
324
- return Array.isArray(e);
325
- }
326
- function Me(e) {
327
- return e instanceof Promise;
328
- }
329
- function Ne(e) {
330
- return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
331
- }
332
- function H(e) {
333
- if (je(e)) return e;
334
- let t = parseFloat(`${e}`);
335
- return isNaN(t) ? 0 : t;
336
- }
337
- function U(e) {
338
- return `${e}`;
339
- }
340
- var Pe = {
341
- "==": (e, t) => e == t,
342
- "===": (e, t) => e === t,
343
- "!=": (e, t) => e != t,
344
- "!==": (e, t) => e !== t,
345
- ">": (e, t) => H(e) > H(t),
346
- ">=": (e, t) => H(e) >= H(t),
347
- "<": (e, t, n) => {
348
- let r = H(e), i = H(t);
349
- if (n === void 0) return r < i;
350
- let a = H(n);
351
- return r < i && i < a;
352
- },
353
- "<=": (e, t, n) => {
354
- let r = H(e), i = H(t);
355
- if (n === void 0) return r <= i;
356
- let a = H(n);
357
- return r <= i && i <= a;
358
- },
359
- "!!": async (e) => await G(e),
360
- "!": async (e) => !await G(e),
361
- "%": (e, t) => H(e) % H(t),
362
- log: (e) => (console.log(e), e),
363
- in: (e, t) => t ? B(t) ? t.indexOf(U(e)) !== -1 : V(t) ? t.includes(e) : !1 : !1,
364
- cat: (...e) => e.map(U).join(""),
365
- substr: (e, t, n) => {
366
- let r = U(e), i = H(t);
367
- if (n === void 0) return r.substr(i);
368
- let a = H(n);
369
- if (a < 0) {
370
- let e = r.substr(i);
371
- return e.substr(0, e.length + a);
372
- }
373
- return r.substr(i, a);
374
- },
375
- "+": (...e) => e.reduce((e, t) => H(e) + H(t), 0),
376
- "*": (...e) => e.reduce((e, t) => H(e) * H(t), 1),
377
- "-": (e, t) => {
378
- let n = H(e);
379
- return t === void 0 ? -n : n - H(t);
380
- },
381
- "/": (e, t) => H(e) / H(t),
382
- min: (...e) => Math.min(...e.map(H)),
383
- max: (...e) => Math.max(...e.map(H)),
384
- merge: (...e) => e.reduce((e, t) => V(t) ? e.concat(t) : e.concat([t]), []),
385
- var(e, t) {
386
- let n = arguments.length > 1 ? t : null;
387
- if (e === "" || e === "." || e == null) return this;
388
- if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
389
- let r = U(e);
390
- if (r === "" || r === ".") return this;
391
- let i = r.split("."), a = this;
392
- for (let e of i) {
393
- if (a == null) return n;
394
- if (Array.isArray(a)) {
395
- let t = parseInt(e, 10);
396
- a = isNaN(t) ? a[e] : a[t];
397
- } else a = a[e];
398
- }
399
- return a === void 0 ? n : a;
400
- },
401
- async missing(...e) {
402
- let t = V(e[0]) ? e[0] : e, n = [];
403
- for (let e of t) {
404
- let t = await W({ var: e }, this);
405
- (t === null || t === "") && n.push(`${e}`);
406
- }
407
- return n;
408
- },
409
- async missing_some(e, t) {
410
- let n = await W({ missing: t }, this);
411
- if (!V(n) || !V(t)) return [];
412
- let r = n.filter(B);
413
- return t.filter(B).length - r.length >= H(e) ? [] : r;
414
- },
415
- invoke(...e) {
416
- let [t, ...n] = e;
417
- return typeof t == "function" ? Reflect.apply(t, null, n) : null;
418
- },
419
- startsWith: (e, t) => B(e) && B(t) && e.startsWith(t),
420
- endsWith: (e, t) => B(e) && B(t) && e.endsWith(t),
421
- regexp_matches(e, t) {
422
- let n = e, r = "";
423
- if (V(e)) {
424
- let [t, i] = e;
425
- n = t, r = i;
426
- }
427
- return !B(n) || !B(r) ? !1 : new RegExp(n, r).test(U(t));
428
- },
429
- throw(e) {
430
- throw Error(U(e));
431
- }
175
+ function we(t) {
176
+ return k(Se, t);
177
+ }
178
+ const ve = (t, e) => {
179
+ e.register(t.name, t);
180
+ }, ke = 6e3, N = B("last_ping", "global"), xe = (t) => `${t}/api/v1/ping`, be = async (t) => {
181
+ try {
182
+ const e = Date.now(), s = localStorage.getItem(N);
183
+ if (s && e - parseInt(s) < ke)
184
+ return !0;
185
+ const o = xe(t.apiUrl), i = {
186
+ projectId: t.projectId,
187
+ path: window.location.pathname
188
+ }, d = JSON.stringify(i), r = {
189
+ "Content-Type": "application/json"
190
+ }, n = document.getElementById("picked_script"), g = n == null ? void 0 : n.dataset.verceltoken;
191
+ g && (r["x-vercel-protection-bypass"] = g);
192
+ const u = (await fetch(o, {
193
+ method: "POST",
194
+ headers: r,
195
+ body: d
196
+ })).ok;
197
+ return u && localStorage.setItem(N, e.toString()), u;
198
+ } catch (e) {
199
+ return w("error", e), !1;
200
+ }
432
201
  };
433
- async function W(e, t) {
434
- if (!e) return e;
435
- if (Me(e)) return W(await e, t);
436
- if (V(e)) return Promise.all(e.map((e) => W(e, t)));
437
- if (!Ne(e)) return e;
438
- let n = Fe(e), r = n ? e[n] ?? [] : [];
439
- switch (V(r) || (r = [r]), n) {
440
- case "if":
441
- case "?:":
442
- for (let e = 0; e < r.length - 1; e += 2) if (await G(await W(r[e], t))) return W(r[e + 1], t);
443
- return r.length % 2 == 1 ? W(r[r.length - 1], t) : null;
444
- case "and": {
445
- let e = null;
446
- for (let n of r) if (e = await W(n, t), !await G(e)) return e;
447
- return e;
448
- }
449
- case "or": {
450
- let e = null;
451
- for (let n of r) if (e = await W(n, t), await G(e)) return e;
452
- return e;
453
- }
454
- case "map": {
455
- let e = await W(r[0], t);
456
- return V(e) ? await Promise.all(e.map((e) => W(r[1], e))) : [];
457
- }
458
- case "filter": {
459
- let e = await W(r[0], t);
460
- return V(e) ? (await Promise.all(e.map(async (e) => ({
461
- item: e,
462
- shouldInclude: await G(await W(r[1], e))
463
- })))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
464
- }
465
- case "reduce": {
466
- let e = await W(r[0], t);
467
- if (!V(e)) return r.length > 2 ? await W(r[2], t) : null;
468
- let n = r[1], i = r.length > 2 ? await W(r[2], t) : null;
469
- for (let t of e) i = await W(n, {
470
- current: t,
471
- accumulator: i
472
- });
473
- return i;
474
- }
475
- case "all": {
476
- let e = await W(r[0], t);
477
- if (!V(e) || e.length === 0) return !1;
478
- for (let t of e) if (!await G(await W(r[1], t))) return !1;
479
- return !0;
480
- }
481
- case "some": {
482
- let e = await W(r[0], t);
483
- if (!V(e)) return !1;
484
- for (let t of e) if (await G(await W(r[1], t))) return !0;
485
- return !1;
486
- }
487
- case "none": {
488
- let e = await W(r[0], t);
489
- if (!V(e)) return !0;
490
- for (let t of e) if (await G(await W(r[1], t))) return !1;
491
- return !0;
492
- }
493
- case "catch": try {
494
- return await W(r[0], t);
495
- } catch (e) {
496
- return Ne(e) ? await W(e, t) : r[1] ? await W(r[1], e) : e instanceof Error ? e.message : e;
497
- }
498
- }
499
- let i = await Promise.all(r.map((e) => W(e, t))), a = n ? Pe[n] : void 0;
500
- if (!a) throw Error(`Unrecognized operation ${n}`);
501
- return a.apply(t, i);
502
- }
503
- async function G(e) {
504
- return Me(e) ? G(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
505
- }
506
- function Fe(e) {
507
- return Object.keys(e)[0];
508
- }
509
- //#endregion
510
- //#region src/lifecycle/rules-logic.ts
511
- function Ie(e, t, n) {
512
- return new Proxy(Object.create(null), { get(r, i) {
513
- if (typeof i != "string") return;
514
- let a = e.find((e) => e.key === i);
515
- if (a !== void 0) return async () => !n.has(i) && await W(a.logic, {
516
- ...t,
517
- conditions: Ie(e, t, new Set(n).add(i))
518
- }) === !0;
519
- } });
520
- }
521
- var Le = L(({ client: e }) => k({
522
- source: {
523
- stateSnapshot: e.stateSnapshotStore,
524
- predicates: e.predicates.listStore,
525
- actions: e.actions.listStore,
526
- features: e.features.listStore,
527
- responses: e.responses.getAllStore,
528
- conditions: e.conditions.listStore
529
- },
530
- effect: async ({ stateSnapshot: e, predicates: t, actions: n, features: r, responses: i, conditions: a }, { rule: o, context: s }) => {
531
- let c = t.reduce((t, n) => (t[n.name] = async (...t) => await n.predicate({
532
- ...e,
533
- args: t
534
- }), t), {}), l = n.reduce((t, n) => (t[n.key] = async (...t) => await n.action({
535
- ...e,
536
- args: t
537
- }, null) ?? void 0, t), {}), u = r.reduce((e, t) => (e[t.id] = async () => {
538
- let { bucket: e } = await t.getBucket();
539
- return e;
540
- }, e), {}), d = {
541
- responses: i,
542
- location: typeof e.location == "object" ? {
543
- hash: e.location.hash,
544
- host: e.location.host,
545
- hostname: e.location.hostname,
546
- href: e.location.href,
547
- origin: e.location.origin,
548
- pathname: e.location.pathname,
549
- port: e.location.port,
550
- protocol: e.location.protocol,
551
- search: e.location.search
552
- } : void 0,
553
- predicates: c,
554
- actions: l,
555
- features: u,
556
- ...s
557
- };
558
- return await W(o, {
559
- ...d,
560
- conditions: Ie(a, d, /* @__PURE__ */ new Set())
561
- });
562
- }
563
- }));
564
- function Re(e) {
565
- return R(Le, e);
566
- }
567
- //#endregion
568
- //#region src/lifecycle/lifecycle.ts
569
- var K = M("lifecycle"), ze = L(({ client: e }) => {
570
- let t = K.store(!1), r = F(void 0, {
571
- skipVoid: !1,
572
- domain: K
573
- }), i = F(void 0, {
574
- skipVoid: !1,
575
- domain: K
576
- }), a = K.store("idle"), o = K.store([]), s = F(void 0, {
577
- skipVoid: !1,
578
- domain: K
579
- }), l = F(void 0, {
580
- skipVoid: !1,
581
- domain: K
582
- }), u = P(), d = P(), f = P(), p = P(), m = P(), h = P();
583
- o.on(p, (e, t) => [...e, t]), s.on(m, (e, t) => t), l.on(h, (e, t) => t), t.on(d, () => !0);
584
- let g = N(async () => {
585
- await ee();
586
- }), _ = N(async () => {
587
- await ge(e);
588
- }), v = k({ effect: _ }), y = k({
589
- source: o,
590
- effect: async (e) => {
591
- for (let t of e) await t();
592
- }
593
- }), b = k({
594
- source: s,
595
- effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
596
- }), x = k({
597
- source: l,
598
- effect: async (t) => t === void 0 ? !0 : typeof t == "boolean" ? t : await n(e, t) === !0
599
- }), S = I({
600
- clock: u,
601
- source: a,
602
- filter: (e) => e === "idle" && c(),
603
- fn: () => void 0
604
- });
605
- I({
606
- clock: S,
607
- fn: () => "starting",
608
- target: a
609
- }), S.watch(e.performance.markBegin), d.watch(e.performance.measure), I({
610
- clock: S,
611
- target: y
612
- }), I({
613
- clock: S,
614
- target: g
615
- }), I({
616
- clock: y.done,
617
- target: b
618
- }), I({
619
- clock: b.doneData,
620
- target: r
621
- }), I({
622
- clock: x.doneData,
623
- target: i
624
- }), I({
625
- clock: b.doneData,
626
- filter: (e) => e,
627
- target: x
628
- }), I({
629
- clock: x.doneData,
630
- target: e.session.setIsUser
631
- }), I({
632
- clock: x.doneData,
633
- fn: (e) => ({
634
- type: "user_decide",
635
- value: e
636
- }),
637
- target: e.eventBus
638
- }), I({
639
- clock: b.doneData,
640
- filter: (e) => !e,
641
- fn: () => void 0,
642
- target: f
643
- }), I({
644
- clock: x.doneData,
645
- fn: () => void 0,
646
- target: f
647
- }), I({
648
- clock: f,
649
- fn: () => ({ type: "initialize" }),
650
- target: e.eventBus
651
- });
652
- let C = F(!1).on(g.done, () => !0), w = F(!1).on(f, () => !0), te = F(!1).on(v.done, () => !0), T = A(r, i, (e, t) => e === !0 && t === !0);
653
- I({
654
- clock: f,
655
- source: T,
656
- filter: (e) => e,
657
- fn: () => void 0,
658
- target: _
659
- });
660
- let ne = A(C, w, T, (e, t, n) => e && t && n);
661
- I({
662
- clock: ne,
663
- filter: (e) => e,
664
- fn: () => void 0,
665
- target: v
666
- });
667
- let E = A(C, w, T, te, (e, t, n, r) => e && t && (!n || r));
668
- return I({
669
- clock: E,
670
- filter: (e) => e,
671
- fn: () => void 0,
672
- target: d
673
- }), I({
674
- clock: d,
675
- fn: () => "ready",
676
- target: a
677
- }), I({
678
- clock: d,
679
- fn: () => ({ type: "ready" }),
680
- target: e.eventBus
681
- }), I({
682
- clock: d,
683
- source: e.session.store,
684
- fn: ({ id: e, isUser: t, identifiers: n }) => ({
685
- type: "session",
686
- id: e,
687
- isUser: t,
688
- identifiers: n
689
- }),
690
- target: e.eventBus
691
- }), I({
692
- clock: [
693
- y.fail,
694
- b.fail,
695
- x.fail,
696
- _.fail,
697
- v.fail,
698
- g.fail
699
- ],
700
- fn: () => "failed",
701
- target: a
702
- }), {
703
- start: u,
704
- readyStore: t,
705
- preconditionPassedStore: r,
706
- conditionPassedStore: i,
707
- lifecycleStageStore: a,
708
- registerPluginStartHook: p,
709
- setPrecondition: m,
710
- setCondition: h
711
- };
712
- });
713
- function Be(e) {
714
- return R(ze, e);
715
- }
716
- //#endregion
717
- //#region src/entities/predicate/predicate.ts
718
- var Ve = M("predicate"), He = L(({ client: e }) => {
719
- let t = Ve.store({}), n = j(t, { register(e, t) {
720
- return {
721
- ...e,
722
- [t.name]: {
723
- name: t.name,
724
- predicate: t.predicate
725
- }
726
- };
727
- } }), i = P();
728
- I({
729
- clock: i,
730
- source: t,
731
- filter: (e, { name: t }) => e[t] !== void 0,
732
- fn: (e, { name: t }) => `Predicate '${t}' already registered. Registering again will override the previous registration.`
733
- }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
734
- clock: i,
735
- fn: ({ name: e, predicate: t }) => Object.freeze({
736
- name: e,
737
- predicate: t
738
- }),
739
- target: n.register
740
- });
741
- let a = t.map((e) => Object.values(e));
742
- function o(e) {
743
- return t.map((t) => t[e]?.predicate, { skipVoid: !1 });
744
- }
745
- function s(t) {
746
- let n = F(() => void 0, { skipVoid: !1 }), r = k({
747
- source: {
748
- predicate: o(t),
749
- snapshot: e.stateSnapshotStore
750
- },
751
- effect: ({ predicate: e, snapshot: t }) => {
752
- if (e) return (...n) => e({
753
- ...t,
754
- args: n
755
- });
756
- }
757
- });
758
- return I({
759
- source: {
760
- responses: e.responses.listStore,
761
- fields: e.fields.listStore
762
- },
763
- target: r
764
- }), I({
765
- clock: r.doneData,
766
- filter: (e) => e !== void 0,
767
- target: n
768
- }), r(), n;
769
- }
770
- return {
771
- register: i,
772
- getByName: o,
773
- listStore: a,
774
- getEvokablePredicate: s
775
- };
202
+ function Fe(t) {
203
+ const e = typeof window < "u", s = {
204
+ client: t,
205
+ responses: t.responses.listStore.getState(),
206
+ fields: t.fields.listStore.getState(),
207
+ location: e ? window.location : void 0,
208
+ document: e ? window.document : void 0,
209
+ sessionStorage: e ? window.sessionStorage : void 0,
210
+ localStorage: e ? window.localStorage : void 0
211
+ };
212
+ return Object.freeze(s);
213
+ }
214
+ const Ie = x("predicate"), Ee = v(({ client: t }) => {
215
+ const e = Ie.store({}), s = b(e, {
216
+ register(r, n) {
217
+ return {
218
+ ...r,
219
+ [n.name]: {
220
+ name: n.name,
221
+ predicate: n.predicate
222
+ }
223
+ };
224
+ }
225
+ });
226
+ function o(r, n) {
227
+ e.getState()[r] && w(
228
+ "warn",
229
+ `Predicate '${r}' already registered. Registering again will override the previous registration.`
230
+ ), s.register(Object.freeze({ name: r, predicate: n }));
231
+ }
232
+ const i = e.map((r) => Object.values(r));
233
+ function d(r) {
234
+ return e.map((n) => n[r], { skipVoid: !1 });
235
+ }
236
+ return {
237
+ register: o,
238
+ getByName: d,
239
+ listStore: i
240
+ };
776
241
  });
777
- function Ue(e) {
778
- return R(He, e);
779
- }
780
- var We = (e, t, n) => {
781
- n.register({
782
- name: e,
783
- predicate: t
784
- });
785
- }, q = M("history");
786
- function Ge(e, t) {
787
- return {
788
- id: se(`history-entry-${Date.now()}-${Math.random()}}`),
789
- node: t,
790
- at: Date.now(),
791
- experienceId: e
792
- };
793
- }
794
- var Ke = L(() => {
795
- let e = q.store({ entries: [] }), t = q.event(), n = q.event(), r = q.event(), i = q.event();
796
- e.on(t, (e, t) => ({ entries: [...e.entries, Ge(t.experienceId, t.node)] })), e.on(n, (e, t) => ({ entries: [...e.entries.slice(0, -1), Ge(t.experienceId, t.node)] })), e.on(i, (e, t) => t);
797
- function a(e, t) {
798
- let n = {
799
- lastStepIndex: -1,
800
- secondLastStepIndex: -1
801
- };
802
- for (let r = e.length - 1; r >= 0; r--) {
803
- let i = e[r], a = i?.node;
804
- if (!(!a || !S(a)) && !(t && i.experienceId !== t)) if (n.lastStepIndex === -1) n.lastStepIndex = r;
805
- else {
806
- n.secondLastStepIndex = r;
807
- break;
808
- }
809
- }
810
- return n;
811
- }
812
- return e.on(r, (e, t) => {
813
- let { secondLastStepIndex: n } = a(e.entries, t.experienceId), r = n === -1 ? e.entries : e.entries.slice(0, n + 1);
814
- return {
815
- ...e,
816
- entries: r
817
- };
818
- }), {
819
- push: t,
820
- replace: n,
821
- back: r,
822
- restore: i,
823
- entriesStore: e.map((e) => e.entries)
824
- };
825
- });
826
- function qe() {
827
- return R(Ke);
828
- }
829
- //#endregion
830
- //#region src/utils/events.ts
831
- var Je = 0, Ye = (e) => {
832
- let t = F([]);
833
- return t.on(e, (e, t) => [...e, {
834
- id: Je++,
835
- at: /* @__PURE__ */ new Date(),
836
- payload: t
837
- }]), t;
838
- };
839
- //#endregion
840
- //#region src/entities/field/policies.ts
841
- function Xe(e) {
842
- let { doNotTrackValue: t, doNotStoreValue: n } = e ?? {}, r = e?.trackValue ?? t === !1, i = e?.storeValue ?? n === !1;
843
- return {
844
- trackValue: r,
845
- storeValue: i,
846
- doNotTrackValue: !r,
847
- doNotStoreValue: !i
848
- };
849
- }
850
- //#endregion
851
- //#region src/entities/field/field.ts
852
- var Ze = M("field"), Qe = L(() => {
853
- let e = Ze.store({}), t = j(e, {
854
- register(e, t) {
855
- let n = Object.assign({}, t.field, { policies: Xe(t.field.policies) });
856
- return {
857
- ...e,
858
- [n.id]: n
859
- };
860
- },
861
- updateByKey(e, t) {
862
- let n = Object.values(e).find((e) => e.key === t.fieldKey);
863
- if (!n) return e;
864
- let r = Object.assign({}, n, t.updates);
865
- return {
866
- ...e,
867
- [n.id]: Object.assign({}, r, { policies: Xe(r.policies) })
868
- };
869
- }
870
- });
871
- function n(e) {
872
- t.register({ field: e });
873
- }
874
- let r = {};
875
- e.watch((e) => {
876
- r = e;
877
- });
878
- function i(e, n) {
879
- let i = Object.values(r).find((t) => t.key === e)?.key;
880
- i && t.updateByKey({
881
- fieldKey: i,
882
- updates: n
883
- });
884
- }
885
- let a = e.map((e) => Object.values(e));
886
- function o(t) {
887
- return e.map((e) => e[t] ?? null, { skipVoid: !1 });
888
- }
889
- function s(t) {
890
- return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
891
- }
892
- function c(t) {
893
- return e.map((e) => Object.values(e).find((e) => e.name === t) ?? null, { skipVoid: !1 });
894
- }
895
- return {
896
- register: n,
897
- update: i,
898
- getById: o,
899
- getByKey: s,
900
- listStore: a,
901
- getByName: c
902
- };
242
+ function Pe(t) {
243
+ return k(Ee, t);
244
+ }
245
+ const Be = (t, e, s) => {
246
+ s.register(t, e);
247
+ }, T = x("feature"), je = v(() => {
248
+ const t = T.store({}), e = T.store([]), s = b(t, {
249
+ register(u, c) {
250
+ return {
251
+ ...u,
252
+ [c.id]: c.feature
253
+ };
254
+ }
255
+ });
256
+ function o(u, c) {
257
+ t.getState()[u] && w(
258
+ "warn",
259
+ `Feature '${u}' already registered. Registering again will override the previous registration.`
260
+ );
261
+ const p = {
262
+ id: u,
263
+ feature: {
264
+ ...c,
265
+ id: u
266
+ }
267
+ };
268
+ s.register(
269
+ Object.freeze({
270
+ id: u,
271
+ feature: p
272
+ })
273
+ );
274
+ }
275
+ const i = O(
276
+ async ({
277
+ id: u,
278
+ key: c,
279
+ storage: a = "local"
280
+ }) => {
281
+ const p = B(`feature:${u}:${c}`, "global"), l = (a === "session" ? j : C).get(p).boolean();
282
+ if (l !== null)
283
+ return { id: u, bucket: l };
284
+ }
285
+ ), d = O((u) => {
286
+ if (!u)
287
+ return null;
288
+ const c = B(`feature:${u.id}:${u.key}`, "global");
289
+ (u.storage === "session" ? j : C).set(c, u.bucket);
290
+ }), r = /* @__PURE__ */ new Map(), n = W({
291
+ source: { allFeaturesStore: t, resolvedFeaturesStore: e },
292
+ effect: async ({ allFeaturesStore: u, resolvedFeaturesStore: c }, { id: a, decide: p, key: f }) => {
293
+ const l = c.find(($) => $.id === a);
294
+ if (l)
295
+ return l;
296
+ const y = u[a];
297
+ if (!y)
298
+ throw new Error(`Feature with id '${a}' not found`);
299
+ const S = r.get(`${a}:${f}`);
300
+ if (S) {
301
+ const $ = await S;
302
+ return { id: y.id, bucket: $, storage: y.feature.storage };
303
+ }
304
+ const P = p();
305
+ r.set(`${a}:${f}`, P);
306
+ const F = await P;
307
+ return { id: y.id, bucket: F, storage: y.feature.storage };
308
+ }
309
+ });
310
+ E({
311
+ clock: s.register,
312
+ fn: (u) => {
313
+ const { id: c, feature: a } = u;
314
+ return { id: c, key: a.feature.key, storage: a.feature.storage };
315
+ },
316
+ target: i
317
+ }), E({
318
+ source: e,
319
+ clock: [i.doneData, n.doneData],
320
+ fn: (u, c) => !c || u.some((a) => a.id === c.id) ? u : [...u, c],
321
+ target: e
322
+ }), E({
323
+ source: t,
324
+ clock: n.doneData,
325
+ fn: (u, c) => {
326
+ var y;
327
+ const { id: a, bucket: p, storage: f } = c, l = (y = u[a]) == null ? void 0 : y.feature.key;
328
+ return l ? { key: l, id: a, bucket: p, storage: f } : null;
329
+ },
330
+ target: d
331
+ });
332
+ const g = R({ allFeaturesStore: t, resolvedFeaturesStore: e }).map(
333
+ ({
334
+ allFeaturesStore: u,
335
+ resolvedFeaturesStore: c
336
+ }) => Object.values(u).map((a) => {
337
+ const p = c.find((f) => f.id === a.id);
338
+ return p ? {
339
+ id: a.id,
340
+ name: a.feature.name,
341
+ key: a.feature.key,
342
+ getBucket: () => ({ id: a.id, bucket: p.bucket }),
343
+ isResolved: !0
344
+ } : {
345
+ id: a.id,
346
+ name: a.feature.name,
347
+ key: a.feature.key,
348
+ getBucket: async () => await n(a.feature),
349
+ isResolved: !1
350
+ };
351
+ })
352
+ );
353
+ function h(u) {
354
+ return t.map((c) => c[u], { skipVoid: !1 });
355
+ }
356
+ return {
357
+ register: o,
358
+ getByName: h,
359
+ listStore: g
360
+ };
903
361
  });
904
362
  function $e() {
905
- return R(Qe);
906
- }
907
- //#endregion
908
- //#region src/entities/step/step.ts
909
- var et = M("step"), tt = L(() => {
910
- let e = et.store({}), t = j(e, { register(e, t) {
911
- return {
912
- ...e,
913
- [t.step.id]: t.step
914
- };
915
- } });
916
- function n(e) {
917
- t.register({ step: e });
918
- }
919
- let r = e.map((e) => Object.values(e));
920
- function i(t) {
921
- return e.map((e) => e[t] ?? null, { skipVoid: !1 });
922
- }
923
- function a(t) {
924
- return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
925
- }
926
- return {
927
- register: n,
928
- getById: i,
929
- getByKey: a,
930
- listStore: r,
931
- indexStore: e
932
- };
363
+ return k(je);
364
+ }
365
+ const Re = (t, e, s) => {
366
+ s.register(t, e);
367
+ }, I = x("history");
368
+ function L(t, e) {
369
+ return {
370
+ id: te("history-entry"),
371
+ node: e,
372
+ at: Date.now(),
373
+ experienceId: t
374
+ };
375
+ }
376
+ const Ae = v(() => {
377
+ const t = I.store({ entries: [] }), e = I.event(), s = I.event(), o = I.event(), i = I.event();
378
+ t.on(e, (r, n) => ({
379
+ entries: [...r.entries, L(n.experienceId, n.node)]
380
+ })), t.on(s, (r, n) => ({
381
+ entries: [
382
+ ...r.entries.slice(0, -1),
383
+ L(n.experienceId, n.node)
384
+ ]
385
+ })), t.on(i, (r, n) => n);
386
+ function d(r, n) {
387
+ const g = { lastStepIndex: -1, secondLastStepIndex: -1 };
388
+ for (let h = r.length - 1; h >= 0; h--) {
389
+ const u = r[h], c = u == null ? void 0 : u.node;
390
+ if (!(!c || !X(c)) && !(n && (u == null ? void 0 : u.experienceId) !== n))
391
+ if (g.lastStepIndex === -1)
392
+ g.lastStepIndex = h;
393
+ else {
394
+ g.secondLastStepIndex = h;
395
+ break;
396
+ }
397
+ }
398
+ return g;
399
+ }
400
+ return t.on(o, (r, n) => {
401
+ const { secondLastStepIndex: g } = d(r.entries, n.experienceId), h = g !== -1 ? r.entries.slice(0, g + 1) : r.entries;
402
+ return {
403
+ ...r,
404
+ entries: h
405
+ };
406
+ }), {
407
+ push: e,
408
+ replace: s,
409
+ back: o,
410
+ restore: i,
411
+ entriesStore: t.map((r) => r.entries)
412
+ };
933
413
  });
934
- function nt() {
935
- return R(tt);
936
- }
937
- function rt(e, t) {
938
- t.register(e);
939
- }
940
- //#endregion
941
- //#region src/entities/content/content.ts
942
- var it = M("content"), at = L(() => {
943
- let e = it.store({}), t = j(e, {
944
- register(e, t) {
945
- return {
946
- ...e,
947
- [t.content.id]: t.content
948
- };
949
- },
950
- patch(e, t) {
951
- let n = e[t.id];
952
- if (!n) return e;
953
- let r = t.apply(n.data);
954
- return r === n.data ? e : {
955
- ...e,
956
- [t.id]: {
957
- ...n,
958
- data: r
959
- }
960
- };
961
- }
962
- });
963
- function n(e) {
964
- t.register({ content: e });
965
- }
966
- function r(e, n) {
967
- t.patch({
968
- id: e,
969
- apply: n
970
- });
971
- }
972
- let i = e.map((e) => Object.values(e));
973
- function a(t) {
974
- return e.map((e) => e[t] ?? null, { skipVoid: !1 });
975
- }
976
- return {
977
- register: n,
978
- patch: r,
979
- getById: a,
980
- listStore: i,
981
- indexStore: e
982
- };
414
+ function De() {
415
+ return k(Ae);
416
+ }
417
+ const Oe = () => A(), Ce = x("field"), Ve = v(() => {
418
+ const t = Ce.store({}), e = b(t, {
419
+ register(r, n) {
420
+ return {
421
+ ...r,
422
+ [n.field.id]: n.field
423
+ };
424
+ }
425
+ });
426
+ function s(r) {
427
+ e.register({ field: r });
428
+ }
429
+ const o = t.map((r) => Object.values(r));
430
+ function i(r) {
431
+ return t.map((n) => n[r] || null);
432
+ }
433
+ function d(r) {
434
+ return t.map((n) => Object.values(n).find((g) => g.name === r) || null);
435
+ }
436
+ return {
437
+ register: s,
438
+ getById: i,
439
+ listStore: o,
440
+ getByName: d
441
+ };
983
442
  });
984
- function ot() {
985
- return R(at);
986
- }
987
- function st(e, t) {
988
- t.register(e);
989
- }
990
- //#endregion
991
- //#region src/entities/action/action.ts
992
- var ct = M("action"), lt = L(({ client: e }) => {
993
- let t = ct.store({}), n = j(t, { register(e, t) {
994
- return {
995
- ...e,
996
- [t.key]: {
997
- key: t.key,
998
- action: t.action
999
- }
1000
- };
1001
- } }), i = P();
1002
- I({
1003
- clock: i,
1004
- source: t,
1005
- filter: (e, { key: t }) => e[t] !== void 0,
1006
- fn: (e, { key: t }) => `Action '${t}' already registered. Registering again will override the previous registration.`
1007
- }).watch((e) => /* @__PURE__ */ r("warn", e)), I({
1008
- clock: i,
1009
- fn: ({ key: e, action: t }) => Object.freeze({
1010
- key: e,
1011
- action: t
1012
- }),
1013
- target: n.register
1014
- });
1015
- let a = t.map((e) => Object.values(e));
1016
- function o(e) {
1017
- return t.map((t) => t[e]?.action, { skipVoid: !1 });
1018
- }
1019
- function s(t, n) {
1020
- let r = F(() => void 0, { skipVoid: !1 }), i = n ? { experience: n.experience } : null, a = k({
1021
- source: {
1022
- action: o(t),
1023
- snapshot: e.stateSnapshotStore
1024
- },
1025
- effect: ({ action: e, snapshot: t }) => {
1026
- if (e) return (...n) => e({
1027
- ...t,
1028
- args: n
1029
- }, i);
1030
- }
1031
- });
1032
- return I({
1033
- source: {
1034
- responses: e.responses.listStore,
1035
- fields: e.fields.listStore
1036
- },
1037
- target: a
1038
- }), I({
1039
- clock: a.doneData,
1040
- filter: (e) => e !== void 0,
1041
- target: r
1042
- }), a(), r;
1043
- }
1044
- return {
1045
- register: i,
1046
- getByKey: o,
1047
- listStore: a,
1048
- getEvokableAction: s
1049
- };
443
+ function Me() {
444
+ return k(Ve);
445
+ }
446
+ const Ne = (t, e) => {
447
+ e.register(t);
448
+ }, Te = x("response"), Le = v(({ client: t }) => {
449
+ const e = Te.store({}), s = A(), o = A(), i = b(e, {
450
+ register(c, a) {
451
+ return {
452
+ ...c,
453
+ [a.fieldId]: a.response
454
+ };
455
+ },
456
+ clear(c, a) {
457
+ const { [a]: p, ...f } = c;
458
+ return f;
459
+ },
460
+ clearAll() {
461
+ return {};
462
+ }
463
+ });
464
+ function d(c, a) {
465
+ i.register({ fieldId: c, response: a });
466
+ }
467
+ async function r(c) {
468
+ const a = [];
469
+ return await Promise.allSettled(
470
+ Object.entries(c).map(async ([p, f]) => {
471
+ let l = f;
472
+ const y = t.fields.getById(p).getState();
473
+ if (!y) {
474
+ a.push({
475
+ fieldId: p,
476
+ userMessage: `Field '${p}' not found`,
477
+ systemMessage: `No field with ID '${p}' exists. Available field IDs are: ${Object.keys(t.fields.listStore.getState()).join(",")}.`,
478
+ value: l
479
+ });
480
+ return;
481
+ }
482
+ if (y.multiple && (typeof l == "string" || typeof l == "number" || typeof l == "boolean") && (l = [l]), !re(y.validation)) {
483
+ const S = await D(t, y.validation, {
484
+ $input: l
485
+ });
486
+ if (typeof S == "string") {
487
+ a.push({
488
+ fieldId: p,
489
+ userMessage: S,
490
+ systemMessage: `Field validation resulted in an error: ${S}.`,
491
+ value: l
492
+ });
493
+ return;
494
+ }
495
+ if (S === !1) {
496
+ a.push({
497
+ fieldId: p,
498
+ userMessage: "This field is invalid",
499
+ systemMessage: "Field validation resulted in an unspecified error.",
500
+ value: l
501
+ });
502
+ return;
503
+ }
504
+ }
505
+ if (y.required && (typeof l > "u" || l === null || l === "" || Array.isArray(l) && !l.length)) {
506
+ a.push({
507
+ fieldId: p,
508
+ userMessage: "This field is required",
509
+ systemMessage: "Field is required.",
510
+ value: l
511
+ });
512
+ return;
513
+ }
514
+ if (!y.multiple && Array.isArray(l) && l.length > 1) {
515
+ a.push({
516
+ fieldId: p,
517
+ userMessage: "This field expects a single response",
518
+ systemMessage: "Field expects a single response.",
519
+ value: l
520
+ });
521
+ return;
522
+ }
523
+ if (y.options) {
524
+ const S = y.options.map((F) => F.value), P = Array.isArray(l) ? l : [l];
525
+ Array.isArray(l) && (P.every((F) => S.includes(F)) || a.push({
526
+ fieldId: p,
527
+ userMessage: "This field expects a valid option",
528
+ systemMessage: `Field expects a valid option. Valid options are: ${S.join(", ")}`,
529
+ value: l
530
+ }));
531
+ }
532
+ })
533
+ ), a.length ? { errors: a } : (Object.entries(c).forEach(([p, f]) => {
534
+ d(p, f);
535
+ }), { errors: [] });
536
+ }
537
+ const n = e.map((c) => c), g = e.map((c) => Object.keys(c).map((p) => ({
538
+ fieldId: p,
539
+ value: c[p]
540
+ })));
541
+ function h(c) {
542
+ const a = t.fields.getById(c), p = e.map((f) => f[c] || null);
543
+ return R({ f: a, r: p }, ({ f, r: l }) => l || (f != null && f.defaultValue ? f.defaultValue : null));
544
+ }
545
+ function u(c) {
546
+ const a = t.fields.getByName(c);
547
+ return R({ f: a, s: e }, ({ f: p, s: f }) => {
548
+ const l = p && f[p.id] || null;
549
+ return l || (p != null && p.defaultValue ? p.defaultValue : null);
550
+ });
551
+ }
552
+ return E({
553
+ clock: s,
554
+ target: i.clearAll
555
+ }), E({
556
+ clock: o,
557
+ target: i.clear
558
+ }), {
559
+ register: d,
560
+ clearAll: s,
561
+ clear: o,
562
+ commit: r,
563
+ listStore: g,
564
+ getAllStore: n,
565
+ getByFieldId: h,
566
+ getByFieldName: u
567
+ };
1050
568
  });
1051
- function ut(e) {
1052
- return R(lt, e);
1053
- }
1054
- var dt = (e, t, n) => {
1055
- n.register({
1056
- key: e,
1057
- action: t
1058
- });
569
+ function ze(t) {
570
+ return k(Le, t);
571
+ }
572
+ const _e = () => "0.0.1-next.2";
573
+ function Ue() {
574
+ if (_()) {
575
+ const t = [
576
+ document.currentScript,
577
+ document.getElementById("picked_script"),
578
+ document.getElementById("picked"),
579
+ document.getElementById("cvly"),
580
+ document.getElementById("cvly-x")
581
+ ];
582
+ for (const e of t)
583
+ if (e != null && e.dataset.api)
584
+ return e.dataset.api;
585
+ }
586
+ return "https://api.picked.app";
587
+ }
588
+ function He() {
589
+ if (!se())
590
+ return {};
591
+ const t = new URLSearchParams(window.location.search), e = {}, s = /* @__PURE__ */ new Set();
592
+ for (const [i] of t.entries())
593
+ i.startsWith("picked-") && s.add(i);
594
+ for (const i of s) {
595
+ const d = i.replace("picked-", "");
596
+ e[d] = t.getAll(i);
597
+ }
598
+ const o = B("s");
599
+ if (s.size > 0)
600
+ j.set(o, e);
601
+ else {
602
+ const i = j.get(o);
603
+ if (i)
604
+ return i.json() || {};
605
+ }
606
+ return e;
607
+ }
608
+ class K {
609
+ constructor(e) {
610
+ m(this, "options");
611
+ m(this, "isReady", !1);
612
+ m(this, "project");
613
+ m(this, "plugins", {});
614
+ m(this, "eventBus", Oe());
615
+ m(this, "organizationId");
616
+ m(this, "projectId");
617
+ m(this, "apiUrl");
618
+ m(this, "searchParams", He());
619
+ m(this, "history", De());
620
+ m(this, "components", ye({ client: this }));
621
+ m(this, "experienceInstances", Z({ client: this }));
622
+ m(this, "experiences", ce({ client: this }));
623
+ m(this, "frameworks", we({ client: this }));
624
+ m(this, "predicates", Pe({ client: this }));
625
+ m(this, "features", $e());
626
+ m(this, "fields", Me());
627
+ m(this, "responses", ze({ client: this }));
628
+ w("info", "Picked client initializing."), this.organizationId = e.organizationId, this.projectId = e.projectId, this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Ue(), this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.eventBus({ type: "initialized", version: _e() }), w("info", "Picked client initialized.");
629
+ }
630
+ start() {
631
+ be(this), (async () => {
632
+ _() && (document.body && await V(this), await ee(), await V(this), this.eventBus({ type: "ready" }), this.isReady = !0);
633
+ })();
634
+ }
635
+ registerFramework(e) {
636
+ ve(e, this.frameworks);
637
+ }
638
+ registerComponent(e, s) {
639
+ M(e, s, this.components);
640
+ }
641
+ registerPlugin(e) {
642
+ de(this, e, this.plugins);
643
+ }
644
+ registerFeature(e, s) {
645
+ Re(e, s, this.features);
646
+ }
647
+ registerPredicate(e, s) {
648
+ Be(e, s, this.predicates);
649
+ }
650
+ registerField(e) {
651
+ Ne(e, this.fields);
652
+ }
653
+ registerExperience(e) {
654
+ e.component && M(`experience:${e.id}`, e.component, this.components), ue(e, this.experiences);
655
+ }
656
+ getStateSnapshot() {
657
+ return Fe(this);
658
+ }
659
+ async launchExperienceById(e) {
660
+ const s = this.experiences.getById(e).getState();
661
+ if (!s) {
662
+ w("warn", `Experience with id '${e}' not found.`);
663
+ return;
664
+ }
665
+ H(this, s);
666
+ }
667
+ // private async fetchProject() {
668
+ // if (this.project) {
669
+ // return
670
+ // }
671
+ //
672
+ // // todo: fetch project
673
+ //
674
+ // this.project.experiences.forEach((experience) => setupExperience(experience, this.experiences))
675
+ // }
676
+ setupPlugins() {
677
+ var e;
678
+ (e = this.options.plugins) == null || e.forEach((s) => {
679
+ if (Array.isArray(s)) {
680
+ s.forEach((i) => {
681
+ this.registerPlugin(i);
682
+ });
683
+ return;
684
+ }
685
+ const o = typeof s == "function" ? s() : s;
686
+ if (Array.isArray(o)) {
687
+ o.forEach((i) => this.registerPlugin(i));
688
+ return;
689
+ }
690
+ this.registerPlugin(o);
691
+ });
692
+ }
693
+ setupFeatures() {
694
+ const e = this.options.features;
695
+ e && (Object.entries(e).forEach(([s, o]) => {
696
+ const i = typeof o == "function" ? o() : o;
697
+ this.registerFeature(s, i);
698
+ }), this.searchParams.feature && this.searchParams.feature.forEach((s) => {
699
+ try {
700
+ const [o, i] = s.split(":");
701
+ if (!o || !i)
702
+ return;
703
+ let d = i;
704
+ (d === "true" || d === "false") && (d = !!d), this.registerFeature(o, {
705
+ key: "*",
706
+ name: o,
707
+ // eslint-disable-next-line sonarjs/function-return-type
708
+ decide: () => d,
709
+ storage: "session"
710
+ });
711
+ } catch {
712
+ }
713
+ }));
714
+ }
715
+ setupPredicates() {
716
+ const e = this.options.predicates;
717
+ e && Object.entries(e).forEach(([s, o]) => {
718
+ if (typeof o != "function") {
719
+ w("warn", `Predicate "${s}" is not a function.`);
720
+ return;
721
+ }
722
+ this.registerPredicate(s, o);
723
+ });
724
+ }
725
+ getPluginConfig(e) {
726
+ return this.plugins[e] ?? {};
727
+ }
728
+ }
729
+ m(K, "logger", w);
730
+ const et = (t) => {
731
+ const e = new K(t);
732
+ return ne(e), e;
1059
733
  };
1060
- //#endregion
1061
- //#region src/entities/response/response-validation.ts
1062
- function J(e, t, n, r) {
1063
- return {
1064
- fieldKey: e.key,
1065
- userMessage: n,
1066
- systemMessage: r,
1067
- value: t
1068
- };
1069
- }
1070
- function Y(e) {
1071
- return e === null || e === "" || Array.isArray(e) && !e.length;
1072
- }
1073
- function ft(e) {
1074
- return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
1075
- }
1076
- function pt(e) {
1077
- try {
1078
- return JSON.stringify(e), !0;
1079
- } catch {
1080
- return !1;
1081
- }
1082
- }
1083
- function mt(e, t) {
1084
- return t.find((t) => t.key === e) ?? null;
1085
- }
1086
- function ht(e, t) {
1087
- return e.multiple && (typeof t == "string" || typeof t == "number" || typeof t == "boolean") ? [t] : t;
1088
- }
1089
- function gt(e, t) {
1090
- if (e.type !== "object" || Y(t)) return null;
1091
- if (e.multiple) {
1092
- if (!Array.isArray(t)) return J(e, t, "This field expects multiple values", "Field expects an array of objects.");
1093
- for (let n of t) {
1094
- if (typeof n != "object" || !n) return J(e, t, "This field expects object values", "Field expects an array of objects, but received non-object value.");
1095
- if (!pt(n)) return J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1096
- }
1097
- return null;
1098
- }
1099
- return Array.isArray(t) ? J(e, t, "This field expects a single value", "Field expects a single object, not an array.") : typeof t != "object" || !t ? J(e, t, "This field expects an object value", "Field expects an object value.") : pt(t) ? null : J(e, t, "This field contains non-serializable data", "Field value contains non-JSON-serializable data (functions, circular references, etc.).");
1100
- }
1101
- function _t(e, t) {
1102
- if (Y(t) || !Array.isArray(e.options) || e.options.length === 0) return null;
1103
- let n = Array.isArray(t) ? t : [t];
1104
- if (e.type === "object") {
1105
- let r = new Set(e.options.map((e) => JSON.stringify(e.value)));
1106
- return n.every((e) => r.has(JSON.stringify(e))) ? null : J(e, t, "This field expects a valid option", "Field expects a valid option from the defined choices.");
1107
- }
1108
- let r = e.options.map((e) => e.value);
1109
- return n.every((e) => !ft(e) || e === null ? !1 : r.includes(e)) ? null : J(e, t, "This field expects a valid option", `Field expects a valid option. Valid options are: ${r.join(", ")}`);
1110
- }
1111
- async function vt(t, n, r, i) {
1112
- if (n.validation && !e(n.validation) && !Y(r)) {
1113
- let e = i ? {
1114
- $input: r,
1115
- responses: i
1116
- } : { $input: r }, a = await t(n.validation, e);
1117
- if (typeof a == "string") return J(n, r, a, `Field validation resulted in an error: ${a}.`);
1118
- if (a === !1) return J(n, r, "This field is invalid", "Field validation resulted in an unspecified error.");
1119
- }
1120
- return n.required && Y(r) ? J(n, r, "This field is required", "Field is required.") : !n.multiple && Array.isArray(r) && r.length > 1 ? J(n, r, "This field expects a single response", "Field expects a single response.") : null;
1121
- }
1122
- //#endregion
1123
- //#region src/entities/response/response.ts
1124
- var yt = M("response"), bt = L(({ client: e }) => {
1125
- let t = yt.store({}), r = P(), i = P(), a = j(t, {
1126
- register(e, t) {
1127
- return {
1128
- ...e,
1129
- [t.fieldKey]: t.response
1130
- };
1131
- },
1132
- registerBatch(e, t) {
1133
- return {
1134
- ...e,
1135
- ...t
1136
- };
1137
- },
1138
- clear(e, t) {
1139
- return Object.fromEntries(Object.entries(e).filter(([e]) => e !== t));
1140
- },
1141
- clearAll() {
1142
- return {};
1143
- }
1144
- });
1145
- function o(e, t) {
1146
- if (typeof e == "string") {
1147
- if (t === void 0) throw Error("Response is required when registering a single field");
1148
- a.register({
1149
- fieldKey: e,
1150
- response: t
1151
- });
1152
- } else a.registerBatch(e);
1153
- }
1154
- let s = (t, r) => n(e, t, r), c = k({
1155
- source: {
1156
- allFields: e.fields.listStore,
1157
- existingResponses: t
1158
- },
1159
- effect: async ({ allFields: e, existingResponses: t }, n) => {
1160
- let r = [], i = {}, a = {
1161
- ...t,
1162
- ...n
1163
- }, o = Object.entries(n), c = await Promise.allSettled(o.map(async ([t, n]) => {
1164
- let o = mt(t, e);
1165
- if (!o) {
1166
- r.push({
1167
- fieldKey: t,
1168
- userMessage: `Field '${t}' not found`,
1169
- systemMessage: `No field with key '${t}' exists. Available field keys are: ${e.map((e) => e.key).join(",")}.`,
1170
- value: n
1171
- });
1172
- return;
1173
- }
1174
- let c = ht(o, n), l = await vt(s, o, c, a);
1175
- if (l) {
1176
- r.push(l);
1177
- return;
1178
- }
1179
- let u = gt(o, c);
1180
- if (u) {
1181
- r.push(u);
1182
- return;
1183
- }
1184
- let d = _t(o, c);
1185
- if (d) {
1186
- r.push(d);
1187
- return;
1188
- }
1189
- i[o.key] = n;
1190
- }));
1191
- for (let [e, t] of c.entries()) {
1192
- if (t.status !== "rejected") continue;
1193
- let n = o[e];
1194
- if (!n) continue;
1195
- let [i, a] = n, s = t.reason instanceof Error ? t.reason.message : String(t.reason);
1196
- r.push({
1197
- fieldKey: i,
1198
- userMessage: "An unexpected error occurred validating this field",
1199
- systemMessage: `Validation threw for field '${i}': ${s}`,
1200
- value: a
1201
- });
1202
- }
1203
- return {
1204
- responsesToCommit: i,
1205
- validationErrors: r
1206
- };
1207
- }
1208
- });
1209
- async function l(e) {
1210
- return c(e);
1211
- }
1212
- let u = k({
1213
- source: t,
1214
- effect: async (e, t) => {
1215
- let { responsesToCommit: n, validationErrors: r } = await c(t);
1216
- return r.length ? { errors: r } : (a.registerBatch(n), { errors: [] });
1217
- }
1218
- });
1219
- async function d(e) {
1220
- return u(e);
1221
- }
1222
- let f = t.map((e) => e), p = t.map((e) => Object.entries(e).map(([e, t]) => ({
1223
- fieldKey: e,
1224
- value: t
1225
- })));
1226
- function m(e) {
1227
- return A({
1228
- f: e,
1229
- s: t
1230
- }, ({ f: e, s: t }) => {
1231
- let n = e ? t[e.key] ?? null : null;
1232
- return n === null ? e?.defaultValue !== void 0 && e.defaultValue !== null ? e.defaultValue : null : n;
1233
- });
1234
- }
1235
- function h(t) {
1236
- return m(e.fields.getById(t));
1237
- }
1238
- function g(t) {
1239
- return m(e.fields.getByKey(t));
1240
- }
1241
- function _(t) {
1242
- return m(e.fields.getByName(t));
1243
- }
1244
- return I({
1245
- clock: r,
1246
- target: a.clearAll
1247
- }), I({
1248
- clock: i,
1249
- target: a.clear
1250
- }), {
1251
- register: o,
1252
- clearAll: r,
1253
- clear: i,
1254
- commit: d,
1255
- getResponsesToCommit: l,
1256
- listStore: p,
1257
- getAllStore: f,
1258
- getByFieldId: h,
1259
- getByFieldKey: g,
1260
- getByFieldName: _
1261
- };
1262
- });
1263
- function xt(e) {
1264
- return R(bt, e);
1265
- }
1266
- //#endregion
1267
- //#region src/entities/condition/condition.ts
1268
- var St = M("condition"), Ct = L(() => {
1269
- let e = St.store({}), t = j(e, { register(e, t) {
1270
- return {
1271
- ...e,
1272
- [t.condition.id]: t.condition
1273
- };
1274
- } });
1275
- function n(e) {
1276
- t.register({ condition: e });
1277
- }
1278
- let r = e.map((e) => Object.values(e));
1279
- function i(t) {
1280
- return e.map((e) => e[t] ?? null, { skipVoid: !1 });
1281
- }
1282
- function a(t) {
1283
- return e.map((e) => Object.values(e).find((e) => e.key === t) ?? null, { skipVoid: !1 });
1284
- }
1285
- return {
1286
- register: n,
1287
- getById: i,
1288
- getByKey: a,
1289
- listStore: r,
1290
- indexStore: e
1291
- };
1292
- });
1293
- function wt() {
1294
- return R(Ct);
1295
- }
1296
- //#endregion
1297
- //#region src/utils/api-url.ts
1298
- function Tt() {
1299
- if (c()) {
1300
- let e = [
1301
- document.currentScript,
1302
- document.getElementById("picked_script"),
1303
- document.getElementById("picked"),
1304
- document.getElementById("cvly"),
1305
- document.getElementById("cvly-x")
1306
- ];
1307
- for (let t of e) if (t?.dataset.api) return t.dataset.api;
1308
- }
1309
- return "https://api.picked.app";
1310
- }
1311
- //#endregion
1312
- //#region src/utils/search-params.ts
1313
- function Et() {
1314
- if (!s()) return {};
1315
- let e = new URLSearchParams(window.location.search), t = {}, n = /* @__PURE__ */ new Set();
1316
- for (let [t] of e.entries()) t.startsWith("picked-") && n.add(t);
1317
- for (let r of n) {
1318
- let n = r.replace("picked-", "");
1319
- t[n] = e.getAll(r);
1320
- }
1321
- let r = O("s");
1322
- if (n.size > 0) D.set(r, t);
1323
- else {
1324
- let e = D.get(r);
1325
- if (e) return e.json() || {};
1326
- }
1327
- return t;
1328
- }
1329
- //#endregion
1330
- //#region src/utils/user-timing.ts
1331
- var Dt = "picked:start:begin", Ot = "picked:start";
1332
- function kt() {
1333
- try {
1334
- return s() && !!p.window && "performance" in p;
1335
- } catch {
1336
- return !1;
1337
- }
1338
- }
1339
- function At() {
1340
- let e = null, t = null;
1341
- return {
1342
- markBegin: () => {
1343
- if (kt()) try {
1344
- e = performance.mark(Dt).startTime;
1345
- } catch {}
1346
- },
1347
- measure: () => {
1348
- if (!(!kt() || e === null)) try {
1349
- t = performance.measure(Ot, { start: e });
1350
- } catch {}
1351
- },
1352
- get startMeasure() {
1353
- return t;
1354
- }
1355
- };
1356
- }
1357
- //#endregion
1358
- //#region src/utils/client-telemetry.ts
1359
- function jt() {
1360
- let e = null;
1361
- return {
1362
- observeDeliveryAPIRequests: (t) => {
1363
- e = t;
1364
- },
1365
- get deliveryAPIRequestObserver() {
1366
- return e;
1367
- }
1368
- };
1369
- }
1370
- //#endregion
1371
- //#region src/entities/session/session.ts
1372
- var Mt = O("session", "global");
1373
- function Nt() {
1374
- return m() ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}-${Math.random().toString(36).substring(2, 15)}`;
1375
- }
1376
- function Pt() {
1377
- if (!h()) return null;
1378
- let e = E.get(Mt);
1379
- if (!e.isSet()) return null;
1380
- try {
1381
- return e.json();
1382
- } catch {
1383
- return null;
1384
- }
1385
- }
1386
- var Ft = L(() => {
1387
- let e = Pt(), t = { id: e?.id ?? Nt() };
1388
- e?.isUser !== void 0 && (t.isUser = e.isUser), e?.identifiers && Object.keys(e.identifiers).length > 0 && (t.identifiers = e.identifiers);
1389
- let n = F(t), r = j(n, {
1390
- setIsUser: (e, t) => ({
1391
- ...e,
1392
- isUser: t
1393
- }),
1394
- setIdentifier: (e, { key: t, value: n }) => ({
1395
- ...e,
1396
- identifiers: {
1397
- ...e.identifiers ?? {},
1398
- [t]: n
1399
- }
1400
- }),
1401
- removeIdentifier: (e, t) => {
1402
- let n = e.identifiers;
1403
- if (!n || !(t in n)) return e;
1404
- let r = {};
1405
- for (let [e, i] of Object.entries(n)) e !== t && (r[e] = i);
1406
- let i = { id: e.id };
1407
- return e.isUser !== void 0 && (i.isUser = e.isUser), Object.keys(r).length > 0 && (i.identifiers = r), i;
1408
- }
1409
- }), i = k({
1410
- source: n,
1411
- effect: (e) => {
1412
- if (h()) try {
1413
- E.get(Mt).set(e);
1414
- } catch {}
1415
- }
1416
- });
1417
- return I({
1418
- source: n,
1419
- target: i
1420
- }), {
1421
- store: n,
1422
- setIsUser: r.setIsUser,
1423
- setIdentifier: r.setIdentifier,
1424
- removeIdentifier: r.removeIdentifier
1425
- };
1426
- });
1427
- function It() {
1428
- return R(Ft, void 0);
1429
- }
1430
- //#endregion
1431
- //#region src/utils/picked-config.ts
1432
- function Lt() {
1433
- if (s()) return globalThis.window.pickedConfig;
1434
- }
1435
- function Rt() {
1436
- if (s()) return Lt()?.projectId;
1437
- }
1438
- function zt() {
1439
- if (!c()) return;
1440
- let e = document.getElementById("picked_script") || document.querySelector("script#picked") || document.getElementById("cvly");
1441
- if (e) return e.dataset.projectid || e.getAttribute("project-id") || void 0;
1442
- }
1443
- function Bt(e) {
1444
- if (e.projectId) return e.projectId;
1445
- let t = Rt();
1446
- if (t) return t;
1447
- let n = zt();
1448
- if (n) return n;
1449
- throw Error("projectId is required. You can provide it via one of:\n (1) createClient({ projectId }) options;\n (2) window.pickedConfig = { projectId };\n (3) a <script> tag with id 'picked_script', 'picked', or 'cvly' that includes a data-projectid (or project-id) attribute.");
1450
- }
1451
- //#endregion
1452
- //#region src/utils/render-string.ts
1453
- function X(e) {
1454
- return e == null || e === "" || Number.isNaN(e);
1455
- }
1456
- var Vt = {
1457
- default: (e, t) => X(e) ? String(t ?? "") : String(e),
1458
- append: (e, t) => t && !X(e) ? `${e} ${t}` : e,
1459
- prepend: (e, t) => t && !X(e) ? `${t} ${e}` : e,
1460
- upper: (e) => typeof e == "string" ? e.toUpperCase() : e,
1461
- lower: (e) => typeof e == "string" ? e.toLowerCase() : e,
1462
- capitalize: (e) => typeof e == "string" ? e.charAt(0).toUpperCase() + e.slice(1) : e,
1463
- list: (e) => {
1464
- if (!e || typeof e != "object") return e;
1465
- let t = new Intl.ListFormat("en", {
1466
- style: "long",
1467
- type: "conjunction"
1468
- });
1469
- if (Array.isArray(e)) return t.format(e.map(String));
1470
- if (e instanceof Map) {
1471
- let n = Array.from(e.entries()).map(([e, t]) => `${e}: ${t}`);
1472
- return t.format(n);
1473
- }
1474
- return e instanceof Set ? t.format(Array.from(e).map(String)) : e;
1475
- }
734
+ export {
735
+ K as Picked,
736
+ et as createClient,
737
+ B as createStorageKey,
738
+ st as isPickedRoot,
739
+ C as localStore,
740
+ j as sessionStore,
741
+ ot as subscribe,
742
+ at as supportsCookies,
743
+ _ as supportsDocument,
744
+ ct as supportsHistory,
745
+ ut as supportsIntersectionObserver,
746
+ lt as supportsLocalStorage,
747
+ dt as supportsLocation,
748
+ pt as supportsSessionStorage,
749
+ gt as supportsShadowRoot,
750
+ se as supportsWindow
1476
751
  };
1477
- function Ht(e) {
1478
- return typeof e == "object" && !!e;
1479
- }
1480
- function Ut(e, t) {
1481
- let n = t;
1482
- for (let t of e.split(".")) if (Ht(n) && t in n) n = n[t];
1483
- else return;
1484
- return typeof n == "function" ? n() : n;
1485
- }
1486
- function Wt(e, t) {
1487
- let n = e.split("|").map((e) => e.trim()), r = Ut(n.shift() ?? "", t);
1488
- for (let e of n) {
1489
- let [t, ...n] = e.split(":"), i = t?.trim() ?? "", a = n.join(":").trim().replaceAll(/(?:^['"]|['"]$)/g, ""), o = Vt[i];
1490
- o && (r = o(r, a));
1491
- }
1492
- return X(r) ? "" : typeof r == "object" ? JSON.stringify(r) : String(r);
1493
- }
1494
- function Gt(e, t) {
1495
- let n = "", r = 0;
1496
- for (; r < e.length;) if (e[r] === "{" && e[r + 1] === "{") {
1497
- r += 2;
1498
- let i = "";
1499
- for (; r < e.length;) {
1500
- if (e[r] === "}" && e[r + 1] === "}") {
1501
- r += 2;
1502
- break;
1503
- }
1504
- i += e[r++];
1505
- }
1506
- n += Wt(i.trim(), t);
1507
- } else n += e[r++];
1508
- return n;
1509
- }
1510
- //#endregion
1511
- //#region src/utils/preview-session.ts
1512
- var Kt = "preview-token";
1513
- function qt() {
1514
- return !s() || !g() ? !1 : !!Et()[Kt]?.[0];
1515
- }
1516
- //#endregion
1517
- //#region src/picked.ts
1518
- var Jt = class {
1519
- static logger = r;
1520
- options;
1521
- dataSource = null;
1522
- seededVersionId = null;
1523
- versionSkew = null;
1524
- contentLoader;
1525
- previewEmbedderOrigins = null;
1526
- plugins = {};
1527
- telemetry = jt();
1528
- dataProviders = /* @__PURE__ */ new Map();
1529
- eventBus = P();
1530
- events;
1531
- projectId;
1532
- apiUrl;
1533
- dashboardUrl;
1534
- documentationSiteUrl;
1535
- session = It();
1536
- performance = At();
1537
- searchParams = Et();
1538
- history = qe();
1539
- components = Ce({ client: this });
1540
- experienceInstances = w({ client: this });
1541
- experiences = he({ client: this });
1542
- frameworks = De({ client: this });
1543
- predicates = Ue({ client: this });
1544
- features = ie({ client: this });
1545
- conditions = wt();
1546
- fields = $e();
1547
- responses = xt({ client: this });
1548
- steps = nt();
1549
- contents = ot();
1550
- actions = ut({ client: this });
1551
- conditionResults = te();
1552
- stateSnapshotStore = Ae({ client: this });
1553
- evaluateRuleLogicFx = Re({ client: this });
1554
- start;
1555
- readyStore;
1556
- preconditionPassedStore;
1557
- conditionPassedStore;
1558
- lifecycleStageStore;
1559
- lifecycle = Be({ client: this });
1560
- renderStringFx = k({
1561
- source: this.responses.listStore,
1562
- effect: (e, { template: t, context: n }) => {
1563
- let r = {};
1564
- for (let t of e) r[t.fieldKey] = t.value;
1565
- return Gt(t, {
1566
- ...n,
1567
- responses: r
1568
- });
1569
- }
1570
- });
1571
- constructor(e) {
1572
- this.events = Ye(this.eventBus), this.projectId = Bt(e), this.options = Object.freeze(e), this.apiUrl = e.apiUrl || Tt(), this.dashboardUrl = e.dashboardUrl ?? "https://dashboard.picked.app", this.documentationSiteUrl = e.documentationSiteUrl ?? "https://docs.picked.app", this.start = this.lifecycle.start, this.readyStore = this.lifecycle.readyStore, this.preconditionPassedStore = this.lifecycle.preconditionPassedStore, this.conditionPassedStore = this.lifecycle.conditionPassedStore, this.lifecycleStageStore = this.lifecycle.lifecycleStageStore, this.setupPlugins(), this.setupFeatures(), this.setupPredicates(), this.setupActions(), this.setupFields(), this.setupComponents(), this.lifecycle.setPrecondition(e.precondition), this.lifecycle.setCondition(e.condition), this.eventBus({
1573
- type: "load",
1574
- version: oe()
1575
- }), this.maybeStartPreviewChannel();
1576
- }
1577
- dataProviderFor(e) {
1578
- let t = e ?? "", n = this.dataProviders.get(t);
1579
- if (n) return n;
1580
- let r = import("../provider-B8wvmeC8.js").then((t) => t.createPickedDataProvider({
1581
- apiUrl: this.apiUrl,
1582
- projectId: this.projectId,
1583
- getRequestObserver: () => this.telemetry.deliveryAPIRequestObserver,
1584
- ...e !== void 0 && { previewToken: e }
1585
- }));
1586
- return this.dataProviders.set(t, r), r;
1587
- }
1588
- async getProjectConfig(e) {
1589
- let t = await this.dataProviderFor(e?.previewToken), n = await t.getProjectConfig();
1590
- if (this.dataSource = t.meta.manifest, n === null) throw Error(`Picked could not resolve the configuration for project "${this.projectId}" from ${this.apiUrl}.`);
1591
- return n;
1592
- }
1593
- async getExperienceContent(e, t) {
1594
- return (await this.dataProviderFor(t?.previewToken)).getContent(e, t?.signal === void 0 ? void 0 : { signal: t.signal });
1595
- }
1596
- maybeStartPreviewChannel() {
1597
- qt() && import("../preview-channel-CSr96XAo.js").then((e) => e.initPreviewChannel(this)).catch(() => void 0);
1598
- }
1599
- registerFramework = (e) => {
1600
- Oe(e, this.frameworks);
1601
- };
1602
- registerComponent = (e, t) => {
1603
- we(e, t, this.components);
1604
- };
1605
- registerPlugin = (e) => {
1606
- ve(this, e, this.plugins);
1607
- let t = this.plugins[e.name];
1608
- t?.onStart && this.lifecycle.registerPluginStartHook(t.onStart);
1609
- };
1610
- registerFeature = (e, t) => {
1611
- re(e, t, this.features);
1612
- };
1613
- registerPredicate = (e, t) => {
1614
- We(e, t, this.predicates);
1615
- };
1616
- registerCondition = (e) => {
1617
- this.conditions.register(e);
1618
- };
1619
- registerField = (e) => {
1620
- this.fields.register(e);
1621
- };
1622
- registerStep = (e) => {
1623
- rt(e, this.steps);
1624
- };
1625
- registerContent = (e) => {
1626
- st(e, this.contents);
1627
- };
1628
- patchContent = (e, t) => {
1629
- this.contents.patch(e, t);
1630
- };
1631
- registerAction = (e, t) => {
1632
- dt(e, t, this.actions);
1633
- };
1634
- registerExperience = (e) => {
1635
- e.component && we(`experience:${e.id}`, e.component, this.components), this.experiences.register(e);
1636
- };
1637
- launchExperienceById = async (e, t) => {
1638
- this.experiences.launch({
1639
- id: e,
1640
- options: t
1641
- });
1642
- };
1643
- launchExperienceByKey = async (e, t) => {
1644
- this.experiences.launch({
1645
- key: e,
1646
- options: t
1647
- });
1648
- };
1649
- openExperienceById = async (e) => {
1650
- this.experiences.open({ id: e });
1651
- };
1652
- openExperienceByKey = async (e) => {
1653
- this.experiences.open({ key: e });
1654
- };
1655
- setupPlugins() {
1656
- this.options.plugins?.forEach((e) => {
1657
- if (Array.isArray(e)) {
1658
- e.forEach((e) => {
1659
- this.registerPlugin(e);
1660
- });
1661
- return;
1662
- }
1663
- let t = typeof e == "function" ? e() : e;
1664
- if (Array.isArray(t)) {
1665
- t.forEach((e) => this.registerPlugin(e));
1666
- return;
1667
- }
1668
- this.registerPlugin(t);
1669
- });
1670
- }
1671
- setupFeatures() {
1672
- let e = this.options.features;
1673
- e && Object.entries(e).forEach(([e, t]) => {
1674
- let n = typeof t == "function" ? t() : t;
1675
- this.registerFeature(e, n);
1676
- }), this.searchParams.feature && this.searchParams.feature.forEach((e) => {
1677
- try {
1678
- let t = ae(e);
1679
- if (!t) return;
1680
- let { id: n, bucket: r } = t;
1681
- this.registerFeature(n, {
1682
- key: `${r}`,
1683
- name: n,
1684
- enabled: !0,
1685
- decide: () => r,
1686
- storage: "session"
1687
- });
1688
- } catch {}
1689
- });
1690
- }
1691
- setupPredicates() {
1692
- let e = this.options.predicates;
1693
- e && Object.entries(e).forEach(([e, t]) => {
1694
- if (typeof t != "function") {
1695
- `${e}`;
1696
- return;
1697
- }
1698
- this.registerPredicate(e, t);
1699
- });
1700
- }
1701
- setupActions() {
1702
- let e = this.options.actions;
1703
- e && Object.entries(e).forEach(([e, t]) => {
1704
- if (typeof t != "function") {
1705
- `${e}`;
1706
- return;
1707
- }
1708
- this.registerAction(e, t);
1709
- });
1710
- }
1711
- setupFields() {
1712
- let e = this.options.fields;
1713
- e && Object.entries(e).forEach(([e, t]) => {
1714
- let n = typeof t == "function" ? t() : t;
1715
- this.registerField({
1716
- ...n,
1717
- key: n.key ?? e
1718
- });
1719
- });
1720
- }
1721
- setupComponents() {
1722
- let e = this.options.components;
1723
- e && Object.entries(e).forEach(([e, t]) => {
1724
- this.registerComponent(e, t);
1725
- });
1726
- }
1727
- getPluginConfig = (e) => this.plugins[e] ?? {};
1728
- }, Yt = "application/picked-javascript", Xt = "application/picked-module", Zt = "data-picked-hydrated";
1729
- async function Qt(e) {
1730
- if (!("document" in globalThis)) return;
1731
- let t = "application/picked-module", n = "data-picked-hydrated";
1732
- function r(e) {
1733
- try {
1734
- Function(e.textContent);
1735
- } catch (t) {
1736
- return t instanceof SyntaxError && (console.error("[picked] Skipped a rehydrated inline script that failed to parse.", t), e.setAttribute(n, ""), !0);
1737
- }
1738
- return !1;
1739
- }
1740
- function i(e, t) {
1741
- let r = document.createElement("script");
1742
- for (let t of Array.from(e.attributes)) t.name !== "type" && r.setAttribute(t.name, t.value);
1743
- t && r.setAttribute("type", t), r.setAttribute(n, ""), e.src ? r.async = !1 : r.textContent = e.textContent;
1744
- let i = e.src ? new Promise((e) => {
1745
- r.addEventListener("load", () => e(), { once: !0 }), r.addEventListener("error", () => e(), { once: !0 });
1746
- }) : null;
1747
- return e.src ? e.replaceWith(r) : (globalThis.__pickedEmbedScriptRoot = e.getRootNode(), e.replaceWith(r), globalThis.__pickedEmbedScriptRoot = null), i;
1748
- }
1749
- let a = Array.from(e.querySelectorAll(`script[type="application/picked-javascript"]:not([${n}]), script[type="${t}"]:not([${n}])`)).filter((e) => e instanceof HTMLScriptElement);
1750
- for (let e of a) {
1751
- if (!e.isConnected) continue;
1752
- let n = e.getAttribute("type") === t ? "module" : null;
1753
- if (!e.src && n === null && r(e)) continue;
1754
- let a = i(e, n);
1755
- a && await a;
1756
- }
1757
- }
1758
- function $t() {
1759
- return `<script>(${Qt.toString()})(document)<\/script>`;
1760
- }
1761
- //#endregion
1762
- //#region src/utils/html-asset-value.ts
1763
- function en(e) {
1764
- return typeof e == "object" && !!e && "id" in e && typeof e.id == "string" && "content" in e && (typeof e.content == "string" || e.content === null);
1765
- }
1766
- //#endregion
1767
- //#region src/entities/component/lazyComponent.ts
1768
- function tn(e) {
1769
- return {
1770
- $$type: "lazy-component",
1771
- load: e
1772
- };
1773
- }
1774
- function nn(e) {
1775
- return typeof e == "object" && !!e && "$$type" in e && e.$$type === "lazy-component";
1776
- }
1777
- //#endregion
1778
- //#region src/entities/content/reference.ts
1779
- function Z(e) {
1780
- return typeof e == "object" && !!e && !Array.isArray(e) && "contentEntryId" in e && typeof e.contentEntryId == "string";
1781
- }
1782
- function Q(e) {
1783
- return Z(e) ? e.contentEntryId : null;
1784
- }
1785
- function $(e) {
1786
- let t = Array.isArray(e) ? e : [e], n = [];
1787
- for (let e of t) Z(e) && n.push(e.contentEntryId);
1788
- return n;
1789
- }
1790
- function rn(e, t) {
1791
- return t === null ? null : e[t] ?? null;
1792
- }
1793
- function an(e, t) {
1794
- let n = [];
1795
- for (let r of t) {
1796
- let t = e[r];
1797
- t !== void 0 && n.push(t);
1798
- }
1799
- return n;
1800
- }
1801
- function on(e, t) {
1802
- if (de.store(t)) return A(t, e.indexStore, (e, t) => rn(t, Q(e)));
1803
- let n = Q(t);
1804
- return e.indexStore.map((e) => rn(e, n), { skipVoid: !1 });
1805
- }
1806
- function sn(e, t) {
1807
- if (de.store(t)) return A(t, e.indexStore, (e, t) => an(t, $(e)));
1808
- let n = $(t);
1809
- return e.indexStore.map((e) => an(e, n), { skipVoid: !1 });
1810
- }
1811
- //#endregion
1812
- //#region src/exports.ts
1813
- var cn = (e) => {
1814
- let t = new Jt(e);
1815
- return u(t), t;
1816
- };
1817
- //#endregion
1818
- //#region src/typed-content.ts
1819
- function ln(e) {
1820
- return typeof e.data == "object";
1821
- }
1822
- function un(e) {
1823
- return e.map((e) => !e || !ln(e) ? null : e, { skipVoid: !1 });
1824
- }
1825
- //#endregion
1826
- export { Zt as PICKED_HYDRATED_ATTR, Xt as PICKED_MODULE_SCRIPT_TYPE, Yt as PICKED_SCRIPT_TYPE, Kt as PREVIEW_TOKEN_PARAM, Jt as Picked, $t as buildRehydrateBootstrap, cn as createClient, _e as createPluginEffect, O as createStorageKey, on as deriveReference, sn as deriveReferences, n as evaluateRuleLogic, Lt as getPickedConfig, Z as isContentReference, en as isHtmlAssetValue, g as isInsideIframe, nn as isLazyLoader, v as isPickedRoot, qt as isPreviewSession, tn as lazyComponent, E as localStore, ue as onInertScriptSubtrees, Q as readReferenceId, $ as readReferenceIds, Qt as rehydrateScripts, ce as reportInertScriptSubtrees, le as resetInertScriptReport, D as sessionStore, ne as subscribe, d as supportsCookies, m as supportsCryptoRandomUUID, c as supportsDocument, i as supportsHistory, f as supportsIntersectionObserver, h as supportsLocalStorage, a as supportsLocation, l as supportsSessionStorage, _ as supportsShadowRoot, o as supportsWebComponents, s as supportsWindow, un as toTypedContentStore };