@bigbinary/neeto-molecules 5.1.19 → 5.1.21

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 (166) hide show
  1. package/dist/FinderModal.js +56 -9
  2. package/dist/FinderModal.js.map +1 -1
  3. package/dist/IpRestriction.js +2 -3175
  4. package/dist/IpRestriction.js.map +1 -1
  5. package/dist/MadeWith.js +3 -74
  6. package/dist/MadeWith.js.map +1 -1
  7. package/dist/NeetoWidget.js +3 -1958
  8. package/dist/NeetoWidget.js.map +1 -1
  9. package/dist/Onboarding.js +3 -400
  10. package/dist/Onboarding.js.map +1 -1
  11. package/dist/chevron-up-B2_LTx_h.js +15 -0
  12. package/dist/chevron-up-B2_LTx_h.js.map +1 -0
  13. package/dist/cjs/FinderModal.js +54 -7
  14. package/dist/cjs/FinderModal.js.map +1 -1
  15. package/dist/cjs/IpRestriction.js +21 -3194
  16. package/dist/cjs/IpRestriction.js.map +1 -1
  17. package/dist/cjs/MadeWith.js +17 -88
  18. package/dist/cjs/MadeWith.js.map +1 -1
  19. package/dist/cjs/NeetoWidget.js +4 -1959
  20. package/dist/cjs/NeetoWidget.js.map +1 -1
  21. package/dist/cjs/Onboarding.js +3 -400
  22. package/dist/cjs/Onboarding.js.map +1 -1
  23. package/dist/cjs/chevron-up-CpzhFWzM.js +17 -0
  24. package/dist/cjs/chevron-up-CpzhFWzM.js.map +1 -0
  25. package/dist/cjs/copy-CerjTcLL.js +20 -0
  26. package/dist/cjs/copy-CerjTcLL.js.map +1 -0
  27. package/dist/cjs/globe-DawgK2Dx.js +21 -0
  28. package/dist/cjs/globe-DawgK2Dx.js.map +1 -0
  29. package/dist/cjs/index-ARGXqXxG.js +78 -0
  30. package/dist/cjs/index-ARGXqXxG.js.map +1 -0
  31. package/dist/cjs/index-BeqE2JWC.js +3180 -0
  32. package/dist/cjs/index-BeqE2JWC.js.map +1 -0
  33. package/dist/cjs/panel-left-close-CLoRPBWH.js +21 -0
  34. package/dist/cjs/panel-left-close-CLoRPBWH.js.map +1 -0
  35. package/dist/cjs/phone-number-Bza7WGZm.js +315 -0
  36. package/dist/cjs/phone-number-Bza7WGZm.js.map +1 -0
  37. package/dist/cjs/prism-tomorrow-BMFuJ5o1.js +1963 -0
  38. package/dist/cjs/prism-tomorrow-BMFuJ5o1.js.map +1 -0
  39. package/dist/cjs/react-confetti-DdGoyZ0y.js +405 -0
  40. package/dist/cjs/react-confetti-DdGoyZ0y.js.map +1 -0
  41. package/dist/cjs/smartphone-ChvEvl-o.js +36 -0
  42. package/dist/cjs/smartphone-ChvEvl-o.js.map +1 -0
  43. package/dist/cjs/trash-2-CotPjU5n.js +23 -0
  44. package/dist/cjs/trash-2-CotPjU5n.js.map +1 -0
  45. package/dist/cjs/triangle-alert-De-qkUXK.js +27 -0
  46. package/dist/cjs/triangle-alert-De-qkUXK.js.map +1 -0
  47. package/dist/cjs/v2/AuditLogs.js +4 -18
  48. package/dist/cjs/v2/AuditLogs.js.map +1 -1
  49. package/dist/cjs/v2/Builder.js +4 -18
  50. package/dist/cjs/v2/Builder.js.map +1 -1
  51. package/dist/cjs/v2/Codeblock.js +1 -0
  52. package/dist/cjs/v2/Codeblock.js.map +1 -1
  53. package/dist/cjs/v2/CopyToClipboardButton.js +3 -16
  54. package/dist/cjs/v2/CopyToClipboardButton.js.map +1 -1
  55. package/dist/cjs/v2/FinderModal.js +48 -14
  56. package/dist/cjs/v2/FinderModal.js.map +1 -1
  57. package/dist/cjs/v2/FloatingActionMenu.js +1 -0
  58. package/dist/cjs/v2/FloatingActionMenu.js.map +1 -1
  59. package/dist/cjs/v2/Insights.js +344 -0
  60. package/dist/cjs/v2/Insights.js.map +1 -0
  61. package/dist/cjs/v2/IntegrationCard.js +222 -0
  62. package/dist/cjs/v2/IntegrationCard.js.map +1 -0
  63. package/dist/cjs/v2/IpRestriction.js +525 -0
  64. package/dist/cjs/v2/IpRestriction.js.map +1 -0
  65. package/dist/cjs/v2/MadeWith.js +73 -0
  66. package/dist/cjs/v2/MadeWith.js.map +1 -0
  67. package/dist/cjs/v2/Metadata.js +215 -0
  68. package/dist/cjs/v2/Metadata.js.map +1 -0
  69. package/dist/cjs/v2/NavigationHeader.js +1 -0
  70. package/dist/cjs/v2/NavigationHeader.js.map +1 -1
  71. package/dist/cjs/v2/NeetoWidget.js +855 -0
  72. package/dist/cjs/v2/NeetoWidget.js.map +1 -0
  73. package/dist/cjs/v2/Onboarding.js +323 -0
  74. package/dist/cjs/v2/Onboarding.js.map +1 -0
  75. package/dist/cjs/v2/OptionFields.js +1291 -0
  76. package/dist/cjs/v2/OptionFields.js.map +1 -0
  77. package/dist/cjs/v2/PhoneNumber.js +20 -307
  78. package/dist/cjs/v2/PhoneNumber.js.map +1 -1
  79. package/dist/cjs/v2/ProductEmbed.js +1870 -0
  80. package/dist/cjs/v2/ProductEmbed.js.map +1 -0
  81. package/dist/cjs/v2/PublishBlock.js +6 -22
  82. package/dist/cjs/v2/PublishBlock.js.map +1 -1
  83. package/dist/cjs/v2/PublishYourItem.js +60 -0
  84. package/dist/cjs/v2/PublishYourItem.js.map +1 -0
  85. package/dist/cjs/v2/ResponsiveDevicePicker.js +88 -0
  86. package/dist/cjs/v2/ResponsiveDevicePicker.js.map +1 -0
  87. package/dist/cjs/v2/SessionEnvironment.js +479 -0
  88. package/dist/cjs/v2/SessionEnvironment.js.map +1 -0
  89. package/dist/copy-DhbOoOav.js +18 -0
  90. package/dist/copy-DhbOoOav.js.map +1 -0
  91. package/dist/globe-rBiI1CjO.js +19 -0
  92. package/dist/globe-rBiI1CjO.js.map +1 -0
  93. package/dist/index-0jnA7dx6.js +3178 -0
  94. package/dist/index-0jnA7dx6.js.map +1 -0
  95. package/dist/index-DF5MKxql.js +76 -0
  96. package/dist/index-DF5MKxql.js.map +1 -0
  97. package/dist/panel-left-close-37jik3GB.js +19 -0
  98. package/dist/panel-left-close-37jik3GB.js.map +1 -0
  99. package/dist/phone-number-CGZtDB_n.js +291 -0
  100. package/dist/phone-number-CGZtDB_n.js.map +1 -0
  101. package/dist/prism-tomorrow-ZUb2Ikm9.js +1961 -0
  102. package/dist/prism-tomorrow-ZUb2Ikm9.js.map +1 -0
  103. package/dist/react-confetti-BnGq_LBE.js +403 -0
  104. package/dist/react-confetti-BnGq_LBE.js.map +1 -0
  105. package/dist/smartphone-B-jv1y8j.js +33 -0
  106. package/dist/smartphone-B-jv1y8j.js.map +1 -0
  107. package/dist/trash-2-N0F6K63L.js +21 -0
  108. package/dist/trash-2-N0F6K63L.js.map +1 -0
  109. package/dist/triangle-alert-Pkh6pc42.js +25 -0
  110. package/dist/triangle-alert-Pkh6pc42.js.map +1 -0
  111. package/dist/v2/AuditLogs.js +3 -17
  112. package/dist/v2/AuditLogs.js.map +1 -1
  113. package/dist/v2/Builder.js +3 -17
  114. package/dist/v2/Builder.js.map +1 -1
  115. package/dist/v2/Codeblock.js +1 -0
  116. package/dist/v2/Codeblock.js.map +1 -1
  117. package/dist/v2/CopyToClipboardButton.js +2 -15
  118. package/dist/v2/CopyToClipboardButton.js.map +1 -1
  119. package/dist/v2/FinderModal.js +49 -15
  120. package/dist/v2/FinderModal.js.map +1 -1
  121. package/dist/v2/FloatingActionMenu.js +1 -0
  122. package/dist/v2/FloatingActionMenu.js.map +1 -1
  123. package/dist/v2/Insights.js +342 -0
  124. package/dist/v2/Insights.js.map +1 -0
  125. package/dist/v2/IntegrationCard.js +220 -0
  126. package/dist/v2/IntegrationCard.js.map +1 -0
  127. package/dist/v2/IpRestriction.js +504 -0
  128. package/dist/v2/IpRestriction.js.map +1 -0
  129. package/dist/v2/MadeWith.js +52 -0
  130. package/dist/v2/MadeWith.js.map +1 -0
  131. package/dist/v2/Metadata.js +213 -0
  132. package/dist/v2/Metadata.js.map +1 -0
  133. package/dist/v2/NavigationHeader.js +1 -0
  134. package/dist/v2/NavigationHeader.js.map +1 -1
  135. package/dist/v2/NeetoWidget.js +834 -0
  136. package/dist/v2/NeetoWidget.js.map +1 -0
  137. package/dist/v2/Onboarding.js +321 -0
  138. package/dist/v2/Onboarding.js.map +1 -0
  139. package/dist/v2/OptionFields.js +1289 -0
  140. package/dist/v2/OptionFields.js.map +1 -0
  141. package/dist/v2/PhoneNumber.js +20 -287
  142. package/dist/v2/PhoneNumber.js.map +1 -1
  143. package/dist/v2/ProductEmbed.js +1868 -0
  144. package/dist/v2/ProductEmbed.js.map +1 -0
  145. package/dist/v2/PublishBlock.js +5 -21
  146. package/dist/v2/PublishBlock.js.map +1 -1
  147. package/dist/v2/PublishYourItem.js +58 -0
  148. package/dist/v2/PublishYourItem.js.map +1 -0
  149. package/dist/v2/ResponsiveDevicePicker.js +86 -0
  150. package/dist/v2/ResponsiveDevicePicker.js.map +1 -0
  151. package/dist/v2/SessionEnvironment.js +477 -0
  152. package/dist/v2/SessionEnvironment.js.map +1 -0
  153. package/package.json +3 -3
  154. package/types/v2/Insights.d.ts +69 -0
  155. package/types/v2/IntegrationCard.d.ts +30 -0
  156. package/types/v2/IpRestriction.d.ts +5 -0
  157. package/types/v2/MadeWith.d.ts +8 -0
  158. package/types/v2/Metadata.d.ts +26 -0
  159. package/types/v2/MobilePreviewHeader.d.ts +8 -0
  160. package/types/v2/NeetoWidget.d.ts +19 -0
  161. package/types/v2/Onboarding.d.ts +22 -0
  162. package/types/v2/OptionFields.d.ts +55 -0
  163. package/types/v2/ProductEmbed.d.ts +90 -0
  164. package/types/v2/PublishYourItem.d.ts +8 -0
  165. package/types/v2/ResponsiveDevicePicker.d.ts +11 -0
  166. package/types/v2/SessionEnvironment.d.ts +34 -0
@@ -0,0 +1,1868 @@
1
+ import { useShallow } from 'zustand/shallow';
2
+ import { useEffect, useState, useMemo, useRef } from 'react';
3
+ import { isPresent, filterBy, hyphenate, noop } from '@bigbinary/neeto-cist';
4
+ import { useLocation, useHistory } from 'react-router-dom';
5
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
6
+ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
7
+ import { Label, Input, Button, Select, ColorPicker, Checkbox, Switch, Typography, Spinner } from '@bigbinary/neeto-atoms';
8
+ import classnames from 'classnames';
9
+ import useStateWithDependency from '@bigbinary/neeto-commons-frontend/v2/react-utils/useStateWithDependency';
10
+ import { toPairs, mergeDeepLeft, isEmpty, mergeLeft } from 'ramda';
11
+ import { useTranslation } from 'react-i18next';
12
+ import { t } from 'i18next';
13
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
14
+ import HelpPopover from './HelpPopover.js';
15
+ import { withImmutableActions, handleMetaClick } from '@bigbinary/neeto-commons-frontend/v2/react-utils';
16
+ import { create } from 'zustand';
17
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
18
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
19
+ import { T as Trash2 } from '../trash-2-N0F6K63L.js';
20
+ import { P as Plus } from '../plus-clM1IC_E.js';
21
+ import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
22
+ import Codeblock from './Codeblock.js';
23
+ import { globalProps as globalProps$1 } from '@bigbinary/neeto-commons-frontend/v2/initializers';
24
+ import BrowserPreview from './BrowserPreview.js';
25
+ import Container from './Container.js';
26
+ import Header from './Header.js';
27
+ import { c as createLucideIcon } from '../createLucideIcon-mNMhCCpf.js';
28
+ import '../circle-question-mark-Dib48f5Z.js';
29
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils/useBreakpoints';
30
+ import 'react-syntax-highlighter/dist/esm/languages/prism/javascript';
31
+ import 'react-syntax-highlighter/dist/esm/prism-light.js';
32
+ import 'react-syntax-highlighter/dist/esm/styles/prism';
33
+ import './CopyToClipboardButton.js';
34
+ import '@bigbinary/neeto-commons-frontend/v2/utils/general';
35
+ import '../check-DvxzqR83.js';
36
+ import '../copy-DhbOoOav.js';
37
+ import '../index-DAYCJu79.js';
38
+ import '../_commonjsHelpers-BFTU3MAI.js';
39
+ import './Breadcrumbs.js';
40
+ import '@bigbinary/neeto-atoms/primitives';
41
+ import './MoreDropdown.js';
42
+ import '../ellipsis-DpI9xqUK.js';
43
+ import './Search.js';
44
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils/useFuncDebounce';
45
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils/useQueryParams';
46
+ import '@bigbinary/neeto-commons-frontend/v2/react-utils/useUpdateEffect';
47
+ import '@bigbinary/neeto-commons-frontend/v2/utils';
48
+ import '../search-DCgpNjip.js';
49
+
50
+ /**
51
+ * @license lucide-react v1.7.0 - ISC
52
+ *
53
+ * This source code is licensed under the ISC license.
54
+ * See the LICENSE file in the root directory of this source tree.
55
+ */
56
+
57
+
58
+ const __iconNode = [
59
+ ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
60
+ ["path", { d: "M19 12H5", key: "x3x0zl" }]
61
+ ];
62
+ const ArrowLeft = createLucideIcon("arrow-left", __iconNode);
63
+
64
+ var FLOATING_BUTTON_POSITIONS = [{
65
+ label: t("neetoMolecules.productEmbed.floatingPopup.position.bottomLeft"),
66
+ value: "bottomLeft"
67
+ }, {
68
+ label: t("neetoMolecules.productEmbed.floatingPopup.position.bottomRight"),
69
+ value: "bottomRight"
70
+ }];
71
+ var INITIAL_QUERY_PARAM = {
72
+ name: "",
73
+ value: ""
74
+ };
75
+
76
+ /** @type {import("neetocommons/react-utils").ZustandStoreHook} */
77
+ var useProductEmbedStore = create(withImmutableActions(function (set) {
78
+ return {
79
+ isQueryParamsEnabled: false,
80
+ queryParams: [INITIAL_QUERY_PARAM],
81
+ queryParamsProps: {
82
+ helpPopoverProps: {},
83
+ label: "",
84
+ keyPlaceholder: "",
85
+ valuePlaceholder: "",
86
+ addButtonLabel: ""
87
+ },
88
+ setProductEmbedState: set,
89
+ setQueryParams: function setQueryParams(queryParams) {
90
+ return set({
91
+ queryParams: queryParams
92
+ });
93
+ }
94
+ };
95
+ }));
96
+
97
+ var camelCasedAppName$1 = globalProps.appName.replace(/^neeto/i, "neeto");
98
+ var embedBaseScript = function embedBaseScript(embedScriptLink) {
99
+ return "<script>window.".concat(camelCasedAppName$1, " = window.").concat(camelCasedAppName$1, " || { embed: function(){(").concat(camelCasedAppName$1, ".q=").concat(camelCasedAppName$1, ".q||[]).push(arguments)} };</script>\n <script async\n src=\"").concat(embedScriptLink, "\">\n </script>");
100
+ };
101
+ var embedEnv$1 = function embedEnv() {
102
+ return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
103
+ };
104
+ var embedQueryParam$1 = function embedQueryParam(queryParams) {
105
+ return queryParams ? "\n".concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
106
+ };
107
+ var parseExtraArgs$1 = function parseExtraArgs(extraArgs) {
108
+ return toPairs(extraArgs).map(function (_ref) {
109
+ var _ref2 = _slicedToArray(_ref, 2),
110
+ key = _ref2[0],
111
+ value = _ref2[1];
112
+ return "\n".concat(TAB_STRING, " ").concat(key, ": \"").concat(value, "\"");
113
+ });
114
+ };
115
+ var formatIframeAttributes$1 = function formatIframeAttributes(attributes) {
116
+ return toPairs(attributes).map(function (_ref3) {
117
+ var _ref4 = _slicedToArray(_ref3, 2),
118
+ key = _ref4[0],
119
+ value = _ref4[1];
120
+ return "\n".concat(TAB_STRING).concat(key, "=\"").concat(value, "\"");
121
+ }).join("");
122
+ };
123
+ var inlineEmbedCode$1 = function inlineEmbedCode(_ref5) {
124
+ var customization = _ref5.customization,
125
+ id = _ref5.id,
126
+ embedScriptLink = _ref5.embedScriptLink,
127
+ extraArgs = _ref5.extraArgs,
128
+ inlineWrapperStyle = _ref5.inlineWrapperStyle,
129
+ iframeStyle = _ref5.iframeStyle,
130
+ queryParams = _ref5.queryParams;
131
+ var elementSelector = customization.elementSelector,
132
+ dynamicHeight = customization.dynamicHeight;
133
+ var processedInlineWrapperStyle = dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value ? removeHeightFromStyle(inlineWrapperStyle) : inlineWrapperStyle;
134
+ return "\n <!-- ".concat(globalProps.appName, " inline embed code begins -->\n <div style=\"").concat(processedInlineWrapperStyle, "\" id=\"").concat(elementSelector, "\">\n <!-- ").concat(globalProps.appName, " widget will be added here -->\n </div>\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: \"").concat(iframeStyle, "\", ").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " inline embed code ends -->");
135
+ };
136
+ var floatingPopupEmbedCode$1 = function floatingPopupEmbedCode(_ref6) {
137
+ var customization = _ref6.customization,
138
+ id = _ref6.id,
139
+ embedScriptLink = _ref6.embedScriptLink,
140
+ extraArgs = _ref6.extraArgs,
141
+ queryParams = _ref6.queryParams;
142
+ var btnTextColor = customization.btnTextColor,
143
+ showIcon = customization.showIcon,
144
+ btnText = customization.btnText,
145
+ btnPosition = customization.btnPosition,
146
+ btnColor = customization.btnColor,
147
+ icon = customization.icon;
148
+ return "\n <!-- ".concat(globalProps.appName, " floating-popup embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\", ").concat(icon ? "\n".concat(TAB_STRING).concat(TAB_STRING, "showIcon: ").concat(showIcon, ",") : "", "\n },").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " floating-popup embed code ends -->");
149
+ };
150
+ var elementPopupEmbedCode$1 = function elementPopupEmbedCode(_ref7) {
151
+ var customization = _ref7.customization,
152
+ id = _ref7.id,
153
+ embedScriptLink = _ref7.embedScriptLink,
154
+ extraArgs = _ref7.extraArgs,
155
+ queryParams = _ref7.queryParams;
156
+ var elementSelector = customization.elementSelector;
157
+ return "\n <!-- This is a demo button, you can use any element on your website instead. -->\n <!-- <button id=\"".concat(elementSelector, "\">Click to open popup</button> -->\n\n <!-- ").concat(globalProps.appName, " element-click embed code begins -->\n ").concat(embedBaseScript(embedScriptLink), "\n <script>\n ").concat(camelCasedAppName$1, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam$1(queryParams)).concat(embedEnv$1()).concat(parseExtraArgs$1(extraArgs), "\n });\n </script>\n <!-- ").concat(globalProps.appName, " element-click embed code ends -->");
158
+ };
159
+ var iframeEmbedCode$1 = function iframeEmbedCode(_ref8) {
160
+ var id = _ref8.id,
161
+ customization = _ref8.customization,
162
+ queryParams = _ref8.queryParams,
163
+ embedScriptLink = _ref8.embedScriptLink;
164
+ var height = customization.height,
165
+ width = customization.width,
166
+ iframeTitle = customization.iframeTitle,
167
+ iframeUrl = customization.iframeUrl,
168
+ dynamicHeight = customization.dynamicHeight,
169
+ iframeAttributes = customization.iframeAttributes;
170
+ var iframeSrc = buildIframeURL$1({
171
+ id: id,
172
+ iframeUrl: iframeUrl,
173
+ queryParams: queryParams
174
+ });
175
+ var heightAttribute = dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value ? "" : "\n".concat(TAB_STRING, "height=\"").concat(height, "\"");
176
+ return "\n <!-- ".concat(globalProps.appName, " iframe embed code begins -->\n ").concat(dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value && embedScriptLink ? embedBaseScript(embedScriptLink) : "", "\n <iframe\n allowfullscreen").concat(heightAttribute, "\n width=\"").concat(width, "\"\n frameborder=\"0\"\n title=\"").concat(iframeTitle, "\"\n src=\"").concat(iframeSrc, "\"").concat(formatIframeAttributes$1(iframeAttributes), "\n ></iframe>\n <!-- ").concat(globalProps.appName, " iframe embed code ends -->");
177
+ };
178
+ var htmlCodeGenerators = {
179
+ inline: inlineEmbedCode$1,
180
+ floatingPopup: floatingPopupEmbedCode$1,
181
+ elementPopup: elementPopupEmbedCode$1,
182
+ iframe: iframeEmbedCode$1
183
+ };
184
+
185
+ var camelCasedAppName = globalProps.appName.replace(/^neeto/i, "neeto");
186
+ var embedFunctionName = "embed".concat(globalProps.appName);
187
+ var embedScript = function embedScript(scriptLink) {
188
+ return "const embedScript = document.createElement(\"script\");\n embedScript.type = \"module\";\n embedScript.src = \"".concat(scriptLink, "\";\n embedScript.async = true;\n");
189
+ };
190
+ var cleanupFunction = "\n return () => {\n embedScript.onload = null;\n if(window.".concat(camelCasedAppName, ") window.").concat(camelCasedAppName, ".destroy();\n document.body.removeChild(embedScript);\n };");
191
+ var embedEnv = function embedEnv() {
192
+ return globalProps.railsEnv !== "production" ? "\n".concat(TAB_STRING).concat(TAB_STRING, " env: \"").concat(globalProps.railsEnv, "\",") : "";
193
+ };
194
+ var embedQueryParam = function embedQueryParam(queryParams) {
195
+ return queryParams ? "\n".concat(TAB_STRING).concat(TAB_STRING, " queryParams: ").concat(queryParams, ",") : "";
196
+ };
197
+ var parseExtraArgs = function parseExtraArgs(extraArgs) {
198
+ return toPairs(extraArgs).map(function (_ref) {
199
+ var _ref2 = _slicedToArray(_ref, 2),
200
+ key = _ref2[0],
201
+ value = _ref2[1];
202
+ return "\n".concat(TAB_STRING).concat(TAB_STRING).concat(key, ": \"").concat(value, "\"");
203
+ });
204
+ };
205
+ var formatIframeAttributes = function formatIframeAttributes(attributes) {
206
+ return toPairs(attributes).map(function (_ref3) {
207
+ var _ref4 = _slicedToArray(_ref3, 2),
208
+ key = _ref4[0],
209
+ value = _ref4[1];
210
+ return "\n".concat(TAB_STRING).concat(TAB_STRING, " ").concat(key, "=\"").concat(value, "\"");
211
+ }).join("");
212
+ };
213
+ var parseInlineStyle = function parseInlineStyle(styleString) {
214
+ return styleString.split(";").map(function (rule) {
215
+ var _rule$split$map = rule.split(":").map(function (s) {
216
+ return s.trim();
217
+ }),
218
+ _rule$split$map2 = _slicedToArray(_rule$split$map, 2),
219
+ key = _rule$split$map2[0],
220
+ value = _rule$split$map2[1];
221
+ return key && value ? "".concat(key, ": \"").concat(value, "\"") : null;
222
+ }).filter(Boolean).join(", ");
223
+ };
224
+ var inlineEmbedCode = function inlineEmbedCode(_ref5) {
225
+ var customization = _ref5.customization,
226
+ id = _ref5.id,
227
+ embedScriptLink = _ref5.embedScriptLink,
228
+ extraArgs = _ref5.extraArgs,
229
+ inlineWrapperStyle = _ref5.inlineWrapperStyle,
230
+ iframeStyle = _ref5.iframeStyle,
231
+ queryParams = _ref5.queryParams;
232
+ var elementSelector = customization.elementSelector,
233
+ dynamicHeight = customization.dynamicHeight;
234
+ var processedInlineWrapperStyle = dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value ? removeHeightFromStyle(inlineWrapperStyle) : inlineWrapperStyle;
235
+ return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(embedScript(embedScriptLink), "\n embedScript.onload = () => {\n window.").concat(camelCasedAppName, ".embed({\n type: \"inline\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",\n styles: \"").concat(iframeStyle, "\",").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n };\n\n document.body.appendChild(embedScript);\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return (\n <div\n id=\"inline-embed-container\"\n style={{ ").concat(parseInlineStyle(processedInlineWrapperStyle), " }}\n />\n );\n };");
236
+ };
237
+ var floatingPopupEmbedCode = function floatingPopupEmbedCode(_ref6) {
238
+ var customization = _ref6.customization,
239
+ id = _ref6.id,
240
+ embedScriptLink = _ref6.embedScriptLink,
241
+ extraArgs = _ref6.extraArgs,
242
+ queryParams = _ref6.queryParams;
243
+ var btnTextColor = customization.btnTextColor,
244
+ showIcon = customization.showIcon,
245
+ btnText = customization.btnText,
246
+ btnPosition = customization.btnPosition,
247
+ btnColor = customization.btnColor,
248
+ icon = customization.icon;
249
+ return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(embedScript(embedScriptLink), "\n embedScript.onload = () => {\n window.").concat(camelCasedAppName, ".embed({\n type: \"floatingPopup\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n styles: {\n btnTextColor: \"").concat(btnTextColor, "\",\n btnPosition: \"").concat(btnPosition, "\",\n btnColor: \"").concat(btnColor, "\",\n btnText: \"").concat(btnText, "\",").concat(icon ? "\n".concat(TAB_STRING).concat(TAB_STRING).concat(TAB_STRING, "showIcon: ").concat(showIcon, ",") : "", "\n },").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n };\n\n document.body.appendChild(embedScript);\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <div />;\n };");
250
+ };
251
+ var elementPopupEmbedCode = function elementPopupEmbedCode(_ref7) {
252
+ var customization = _ref7.customization,
253
+ id = _ref7.id,
254
+ embedScriptLink = _ref7.embedScriptLink,
255
+ extraArgs = _ref7.extraArgs,
256
+ queryParams = _ref7.queryParams;
257
+ var elementSelector = customization.elementSelector;
258
+ return "\n import { useEffect } from \"react\";\n\n const App = () => {\n const ".concat(embedFunctionName, " = () => {\n ").concat(embedScript(embedScriptLink), "\n embedScript.onload = () => {\n window.").concat(camelCasedAppName, ".embed({\n type: \"elementClick\",\n id: \"").concat(id, "\",\n organization: \"").concat(globalProps.organization.subdomain, "\",\n elementSelector: \"#").concat(elementSelector, "\",").concat(embedQueryParam(queryParams)).concat(embedEnv()).concat(parseExtraArgs(extraArgs), "\n });\n };\n\n document.body.appendChild(embedScript);\n ").concat(cleanupFunction, "\n };\n\n useEffect(() => ").concat(embedFunctionName, "(), []);\n\n return <button id=\"").concat(elementSelector, "\">Click to open popup</button>;\n };");
259
+ };
260
+ var iframeEmbedCode = function iframeEmbedCode(_ref8) {
261
+ var customization = _ref8.customization,
262
+ id = _ref8.id,
263
+ queryParams = _ref8.queryParams;
264
+ var height = customization.height,
265
+ width = customization.width,
266
+ iframeTitle = customization.iframeTitle,
267
+ iframeUrl = customization.iframeUrl,
268
+ dynamicHeight = customization.dynamicHeight,
269
+ iframeAttributes = customization.iframeAttributes;
270
+ var iframeSrc = buildIframeURL$1({
271
+ id: id,
272
+ iframeUrl: iframeUrl,
273
+ queryParams: queryParams
274
+ });
275
+ var heightAttribute = dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value ? "" : "\n".concat(TAB_STRING).concat(TAB_STRING, " height=\"").concat(height, "\"");
276
+ return "\n const App = () => {\n return (\n <>\n {/* ".concat(globalProps.appName, " iframe embed code begins */}\n <iframe\n allowFullScreen").concat(heightAttribute, "\n width=\"").concat(width, "\"\n frameBorder=\"0\"\n title=\"").concat(iframeTitle, "\"\n src=\"").concat(iframeSrc, "\"").concat(formatIframeAttributes(iframeAttributes), "\n ></iframe>\n {/* ").concat(globalProps.appName, " iframe embed code ends */}\n </>\n );\n };\n");
277
+ };
278
+ var reactCodeGenerators = {
279
+ inline: inlineEmbedCode,
280
+ floatingPopup: floatingPopupEmbedCode,
281
+ elementPopup: elementPopupEmbedCode,
282
+ iframe: iframeEmbedCode
283
+ };
284
+
285
+ var _excluded$1 = ["selectedLanguage", "type"];
286
+ function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
287
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
288
+ var buildQueryParams$1 = function buildQueryParams() {
289
+ var customization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
290
+ var existingQueryParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
291
+ var activeOptions = Object.keys(SWITCH_OPTIONS).reduce(function (acc, key) {
292
+ var _customization$key;
293
+ var value = (_customization$key = customization[key]) === null || _customization$key === void 0 ? void 0 : _customization$key.value;
294
+ if (value) acc[key] = value;
295
+ return acc;
296
+ }, {});
297
+ var mergedQueryParams = _objectSpread$8(_objectSpread$8({}, existingQueryParams), activeOptions);
298
+ if (isEmpty(mergedQueryParams)) return "";
299
+ return JSON.stringify(mergedQueryParams, null, 2).replace(/\n/g, " ").replace(/\s\s+/g, " ");
300
+ };
301
+ var generateCode = function generateCode(options) {
302
+ var _embeddedCodeOptions$, _reactCodeGenerators$, _htmlCodeGenerators$t;
303
+ var selectedLanguage = options.selectedLanguage,
304
+ type = options.type,
305
+ embeddedCodeOptions = _objectWithoutProperties(options, _excluded$1);
306
+ var queryParams = ((_embeddedCodeOptions$ = embeddedCodeOptions.customization) === null || _embeddedCodeOptions$ === void 0 ? void 0 : _embeddedCodeOptions$.queryParams) || {};
307
+ var customization = embeddedCodeOptions.customization || {};
308
+ var codeOptions = _objectSpread$8(_objectSpread$8({}, embeddedCodeOptions), {}, {
309
+ queryParams: buildQueryParams$1(customization, queryParams)
310
+ });
311
+ return selectedLanguage === "react" ? (_reactCodeGenerators$ = reactCodeGenerators[type]) === null || _reactCodeGenerators$ === void 0 ? void 0 : _reactCodeGenerators$.call(reactCodeGenerators, codeOptions) : (_htmlCodeGenerators$t = htmlCodeGenerators[type]) === null || _htmlCodeGenerators$t === void 0 ? void 0 : _htmlCodeGenerators$t.call(htmlCodeGenerators, codeOptions);
312
+ };
313
+ var buildDefaultCustomization = function buildDefaultCustomization(defaultCustomizations) {
314
+ return mergeDeepLeft(defaultCustomizations, DEFAULT_CUSTOMIZATION);
315
+ };
316
+ var buildQueryParamsFromInputFields = function buildQueryParamsFromInputFields(inputFields) {
317
+ var filteredInputFields = inputFields.filter(function (_ref) {
318
+ var name = _ref.name,
319
+ value = _ref.value;
320
+ return name && value;
321
+ });
322
+ return filteredInputFields.reduce(function (queryParams, _ref2) {
323
+ var name = _ref2.name,
324
+ value = _ref2.value;
325
+ queryParams[name] = value;
326
+ return queryParams;
327
+ }, {});
328
+ };
329
+ var toCamelCasedString = function toCamelCasedString(string) {
330
+ return string === null || string === void 0 ? void 0 : string.replace(/[_-]+(\w)/g, function (_, nextChar) {
331
+ return nextChar.toUpperCase();
332
+ });
333
+ };
334
+ var buildIframeURL$1 = function buildIframeURL(_ref3) {
335
+ var id = _ref3.id,
336
+ iframeUrl = _ref3.iframeUrl,
337
+ queryParams = _ref3.queryParams;
338
+ var url = new URL(iframeUrl || "".concat(location.origin, "/embed/").concat(id));
339
+ if (!queryParams) return url.toString();
340
+ var parsedQueryParams = JSON.parse(queryParams);
341
+ Object.entries(parsedQueryParams).forEach(function (_ref4) {
342
+ var _ref5 = _slicedToArray(_ref4, 2),
343
+ key = _ref5[0],
344
+ value = _ref5[1];
345
+ url.searchParams.append(key, value);
346
+ });
347
+ return url.toString();
348
+ };
349
+ var removeHeightFromStyle = function removeHeightFromStyle(style) {
350
+ return style.replace(/height\s*:\s*[^;]+;?\s*/g, "").trim();
351
+ };
352
+
353
+ function ownKeys$7(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
354
+ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
355
+ var DynamicQueryParams = function DynamicQueryParams(_ref) {
356
+ var updateCustomization = _ref.updateCustomization;
357
+ var _useTranslation = useTranslation(),
358
+ t = _useTranslation.t;
359
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
360
+ return {
361
+ queryParamsProps: store["queryParamsProps"],
362
+ queryParams: store["queryParams"],
363
+ setQueryParams: store["setQueryParams"]
364
+ };
365
+ })),
366
+ queryParamsProps = _useProductEmbedStore.queryParamsProps,
367
+ queryParams = _useProductEmbedStore.queryParams,
368
+ setQueryParams = _useProductEmbedStore.setQueryParams;
369
+ var handleAddQueryParam = function handleAddQueryParam() {
370
+ setQueryParams([].concat(_toConsumableArray(queryParams), [INITIAL_QUERY_PARAM]));
371
+ };
372
+ var handleRemoveQueryParam = function handleRemoveQueryParam(index) {
373
+ var newQueryParams = queryParams.filter(function (_, i) {
374
+ return i !== index;
375
+ });
376
+ setQueryParams(newQueryParams);
377
+ };
378
+ var handleInputChange = function handleInputChange(index, field, value) {
379
+ var newQueryParams = queryParams.map(function (param, i) {
380
+ return i === index ? _objectSpread$7(_objectSpread$7({}, param), {}, _defineProperty({}, field, value)) : param;
381
+ });
382
+ setQueryParams(newQueryParams);
383
+ };
384
+ useEffect(function () {
385
+ updateCustomization({
386
+ queryParams: buildQueryParamsFromInputFields(queryParams)
387
+ });
388
+ }, [queryParams]);
389
+ return /*#__PURE__*/jsxs("div", {
390
+ children: [/*#__PURE__*/jsxs("div", {
391
+ className: "mb-2 flex",
392
+ "data-testid": "dynamic-query-params-label-container",
393
+ children: [/*#__PURE__*/jsx(Label, {
394
+ "data-testid": "dynamic-query-params-label",
395
+ children: queryParamsProps.label || t("neetoMolecules.productEmbed.queryParam.label")
396
+ }), isPresent(queryParamsProps.helpPopoverProps) && /*#__PURE__*/jsx(HelpPopover, _objectSpread$7({
397
+ className: "ms-1"
398
+ }, queryParamsProps.helpPopoverProps))]
399
+ }), queryParams.map(function (param, index) {
400
+ return /*#__PURE__*/jsxs("div", {
401
+ className: "mb-2 flex gap-1",
402
+ children: [/*#__PURE__*/jsx(Input, {
403
+ "data-testid": "dynamic-query-key-name-input",
404
+ name: "queryParams.".concat(index, ".name"),
405
+ value: param.name,
406
+ placeholder: queryParamsProps.keyPlaceholder || t("neetoMolecules.productEmbed.queryParam.keyNamePlaceholder"),
407
+ onChange: function onChange(e) {
408
+ return handleInputChange(index, "name", e.target.value);
409
+ }
410
+ }), /*#__PURE__*/jsx(Input, {
411
+ "data-testid": "dynamic-query-key-value-input",
412
+ name: "queryParams.".concat(index, ".value"),
413
+ value: param.value,
414
+ placeholder: queryParamsProps.valuePlaceholder || t("neetoMolecules.productEmbed.queryParam.keyValuePlaceholder"),
415
+ onChange: function onChange(e) {
416
+ return handleInputChange(index, "value", e.target.value);
417
+ }
418
+ }), /*#__PURE__*/jsx(Button, {
419
+ "data-testid": "dynamic-query-delete-button",
420
+ icon: Trash2,
421
+ variant: "ghost",
422
+ onClick: function onClick() {
423
+ return handleRemoveQueryParam(index);
424
+ }
425
+ })]
426
+ }, index);
427
+ }), /*#__PURE__*/jsx(Button, {
428
+ className: "my-2",
429
+ "data-testid": "dynamic-query-add-new-button",
430
+ icon: Plus,
431
+ iconPosition: "left",
432
+ variant: "link",
433
+ label: queryParamsProps.addButtonLabel || t("neetoMolecules.productEmbed.queryParam.addQueryParam"),
434
+ onClick: handleAddQueryParam
435
+ })]
436
+ });
437
+ };
438
+
439
+ var ElementPopup$1 = function ElementPopup(_ref) {
440
+ var customization = _ref.customization,
441
+ updateCustomization = _ref.updateCustomization,
442
+ otherCustomizations = _ref.otherCustomizations;
443
+ var elementSelector = customization.elementSelector;
444
+ var _useTranslation = useTranslation(),
445
+ t = _useTranslation.t;
446
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
447
+ return {
448
+ isQueryParamsEnabled: store["isQueryParamsEnabled"]
449
+ };
450
+ })),
451
+ isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
452
+ useEffect(function () {
453
+ if (isQueryParamsEnabled) return;
454
+ updateCustomization({
455
+ queryParams: undefined
456
+ });
457
+ }, []);
458
+ return /*#__PURE__*/jsxs(Fragment, {
459
+ children: [/*#__PURE__*/jsx(Input, {
460
+ className: "w-full",
461
+ "data-testid": "element-id-input-field",
462
+ helpText: t("neetoMolecules.productEmbed.elementPopup.callout"),
463
+ label: t("neetoMolecules.productEmbed.elementPopup.elementId"),
464
+ value: elementSelector,
465
+ error: !elementSelector && t("neetoMolecules.productEmbed.elementPopup.elementIdError"),
466
+ onChange: function onChange(e) {
467
+ return updateCustomization({
468
+ elementSelector: e.target.value
469
+ });
470
+ }
471
+ }), otherCustomizations(), isQueryParamsEnabled && /*#__PURE__*/jsx(DynamicQueryParams, {
472
+ updateCustomization: updateCustomization
473
+ })]
474
+ });
475
+ };
476
+
477
+ var FloatingPopup$1 = function FloatingPopup(_ref) {
478
+ var customization = _ref.customization,
479
+ updateCustomization = _ref.updateCustomization,
480
+ otherCustomizations = _ref.otherCustomizations;
481
+ var _useTranslation = useTranslation(),
482
+ t = _useTranslation.t;
483
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
484
+ return {
485
+ isQueryParamsEnabled: store["isQueryParamsEnabled"]
486
+ };
487
+ })),
488
+ isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
489
+ var btnTextColor = customization.btnTextColor,
490
+ showIcon = customization.showIcon,
491
+ btnText = customization.btnText,
492
+ btnPosition = customization.btnPosition,
493
+ btnColor = customization.btnColor,
494
+ icon = customization.icon;
495
+ useEffect(function () {
496
+ if (isQueryParamsEnabled) return;
497
+ updateCustomization({
498
+ queryParams: undefined
499
+ });
500
+ }, []);
501
+ return /*#__PURE__*/jsxs("div", {
502
+ className: "flex w-full flex-col gap-y-4",
503
+ children: [/*#__PURE__*/jsx("div", {
504
+ className: "flex flex-col gap-y-2",
505
+ children: /*#__PURE__*/jsx(Input, {
506
+ "data-testid": "button-text-input-field",
507
+ label: t("neetoMolecules.productEmbed.floatingPopup.button.text"),
508
+ value: btnText,
509
+ error: !btnText && t("neetoMolecules.productEmbed.floatingPopup.button.textError"),
510
+ onChange: function onChange(e) {
511
+ return updateCustomization({
512
+ btnText: e.target.value
513
+ });
514
+ }
515
+ })
516
+ }), /*#__PURE__*/jsx("div", {
517
+ className: "flex flex-col gap-y-2",
518
+ children: /*#__PURE__*/jsx(Select, {
519
+ dataTestId: "button-position-select-field",
520
+ label: t("neetoMolecules.productEmbed.floatingPopup.button.pos"),
521
+ options: FLOATING_BUTTON_POSITIONS,
522
+ value: btnPosition,
523
+ onChange: function onChange(value) {
524
+ return updateCustomization({
525
+ btnPosition: value
526
+ });
527
+ }
528
+ })
529
+ }), /*#__PURE__*/jsxs("div", {
530
+ className: "flex items-center justify-between gap-2",
531
+ "data-testid": "button-color-label",
532
+ children: [/*#__PURE__*/jsx(Label, {
533
+ children: t("neetoMolecules.productEmbed.floatingPopup.button.color")
534
+ }), /*#__PURE__*/jsx(ColorPicker, {
535
+ color: btnColor,
536
+ size: "medium",
537
+ onChange: function onChange(e) {
538
+ return updateCustomization({
539
+ btnColor: e.hex
540
+ });
541
+ }
542
+ })]
543
+ }), /*#__PURE__*/jsxs("div", {
544
+ className: "flex items-center justify-between gap-2",
545
+ "data-testid": "button-text-color-label",
546
+ children: [/*#__PURE__*/jsx(Label, {
547
+ children: t("neetoMolecules.productEmbed.floatingPopup.button.textColor")
548
+ }), /*#__PURE__*/jsx(ColorPicker, {
549
+ color: btnTextColor,
550
+ size: "medium",
551
+ onChange: function onChange(e) {
552
+ return updateCustomization({
553
+ btnTextColor: e.hex
554
+ });
555
+ }
556
+ })]
557
+ }), icon && /*#__PURE__*/jsx(Checkbox, {
558
+ checked: showIcon,
559
+ "data-testid": "show-icon-checkbox",
560
+ label: t("neetoMolecules.productEmbed.floatingPopup.showCalIcon"),
561
+ onCheckedChange: function onCheckedChange(checked) {
562
+ return updateCustomization({
563
+ showIcon: checked
564
+ });
565
+ }
566
+ }), otherCustomizations(), isQueryParamsEnabled && /*#__PURE__*/jsx(DynamicQueryParams, {
567
+ updateCustomization: updateCustomization
568
+ })]
569
+ });
570
+ };
571
+
572
+ var _excluded = ["value", "label", "helpIconProps"];
573
+ function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
574
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
575
+ var SwitchOptions = function SwitchOptions(_ref) {
576
+ var _ref$customization = _ref.customization,
577
+ customization = _ref$customization === void 0 ? {} : _ref$customization,
578
+ updateCustomization = _ref.updateCustomization;
579
+ var visibleOptions = Object.keys(SWITCH_OPTIONS).filter(function (key) {
580
+ return key in customization;
581
+ }).map(function (key) {
582
+ return [key, customization[key]];
583
+ });
584
+ if (isEmpty(visibleOptions)) return null;
585
+ return /*#__PURE__*/jsx("div", {
586
+ className: "flex flex-col gap-4",
587
+ children: visibleOptions.map(function (_ref2) {
588
+ var _ref3 = _slicedToArray(_ref2, 2),
589
+ option = _ref3[0],
590
+ _ref3$ = _ref3[1],
591
+ value = _ref3$.value,
592
+ label = _ref3$.label,
593
+ helpIconProps = _ref3$.helpIconProps,
594
+ rest = _objectWithoutProperties(_ref3$, _excluded);
595
+ return /*#__PURE__*/jsx(Switch, {
596
+ checked: value,
597
+ label: /*#__PURE__*/jsxs("span", {
598
+ className: "flex items-center gap-1",
599
+ children: [label || SWITCH_OPTIONS[option].label, helpIconProps && /*#__PURE__*/jsx(HelpPopover, _objectSpread$6({}, helpIconProps.popoverProps))]
600
+ }),
601
+ onCheckedChange: function onCheckedChange(checked) {
602
+ return updateCustomization(_defineProperty({}, option, _objectSpread$6(_objectSpread$6({}, rest), {}, {
603
+ label: label,
604
+ helpIconProps: helpIconProps,
605
+ value: checked
606
+ })));
607
+ }
608
+ }, option);
609
+ })
610
+ });
611
+ };
612
+
613
+ var Iframe$1 = function Iframe(_ref) {
614
+ var updateCustomization = _ref.updateCustomization,
615
+ otherCustomizations = _ref.otherCustomizations,
616
+ customization = _ref.customization;
617
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
618
+ return {
619
+ isQueryParamsEnabled: store["isQueryParamsEnabled"]
620
+ };
621
+ })),
622
+ isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
623
+ useEffect(function () {
624
+ if (isQueryParamsEnabled) return;
625
+ updateCustomization({
626
+ queryParams: undefined
627
+ });
628
+ }, []);
629
+ return /*#__PURE__*/jsxs(Fragment, {
630
+ children: [otherCustomizations(), /*#__PURE__*/jsx(SwitchOptions, {
631
+ customization: customization,
632
+ updateCustomization: updateCustomization
633
+ }), isQueryParamsEnabled && /*#__PURE__*/jsx(DynamicQueryParams, {
634
+ updateCustomization: updateCustomization
635
+ })]
636
+ });
637
+ };
638
+
639
+ var Inline$1 = function Inline(_ref) {
640
+ var customization = _ref.customization,
641
+ updateCustomization = _ref.updateCustomization,
642
+ otherCustomizations = _ref.otherCustomizations;
643
+ var _useTranslation = useTranslation(),
644
+ t = _useTranslation.t;
645
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
646
+ return {
647
+ isQueryParamsEnabled: store["isQueryParamsEnabled"]
648
+ };
649
+ })),
650
+ isQueryParamsEnabled = _useProductEmbedStore.isQueryParamsEnabled;
651
+ var elementSelector = customization.elementSelector;
652
+ var handleInputChange = function handleInputChange(_ref2, attribute) {
653
+ var value = _ref2.target.value;
654
+ return updateCustomization(_defineProperty({}, attribute, value));
655
+ };
656
+ useEffect(function () {
657
+ if (isQueryParamsEnabled) return;
658
+ updateCustomization({
659
+ queryParams: undefined
660
+ });
661
+ }, []);
662
+ return /*#__PURE__*/jsxs(Fragment, {
663
+ children: [/*#__PURE__*/jsx(Input, {
664
+ "data-testid": "inline-element-id-input-field",
665
+ label: t("neetoMolecules.productEmbed.inline.elementId"),
666
+ value: elementSelector,
667
+ error: !elementSelector && t("neetoMolecules.productEmbed.inline.elementIdError"),
668
+ onChange: function onChange(e) {
669
+ return handleInputChange(e, "elementSelector");
670
+ }
671
+ }), /*#__PURE__*/jsx(SwitchOptions, {
672
+ customization: customization,
673
+ updateCustomization: updateCustomization
674
+ }), otherCustomizations(), isQueryParamsEnabled && /*#__PURE__*/jsx(DynamicQueryParams, {
675
+ updateCustomization: updateCustomization
676
+ })]
677
+ });
678
+ };
679
+
680
+ function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
681
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
682
+ var InlineEmbedIcon = function InlineEmbedIcon(_ref) {
683
+ var other = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
684
+ return /*#__PURE__*/jsxs("svg", _objectSpread$5(_objectSpread$5({
685
+ fill: "none",
686
+ height: "163",
687
+ viewBox: "0 0 278 163",
688
+ width: "278",
689
+ xmlns: "http://www.w3.org/2000/svg"
690
+ }, other), {}, {
691
+ children: [/*#__PURE__*/jsxs("g", {
692
+ clipPath: "url(#clip0_8605_6776)",
693
+ children: [/*#__PURE__*/jsx("rect", {
694
+ fill: "rgb(var(--neeto-ui-white))",
695
+ height: "163",
696
+ rx: "6",
697
+ width: "278"
698
+ }), /*#__PURE__*/jsx("mask", {
699
+ fill: "rgb(var(--neeto-ui-white))",
700
+ id: "path-3-inside-1_8605_6776",
701
+ children: /*#__PURE__*/jsx("path", {
702
+ d: "M0 0h305v20H0z"
703
+ })
704
+ }), /*#__PURE__*/jsx("path", {
705
+ d: "M0 0h305v20H0z",
706
+ fill: "rgb(var(--neeto-ui-white))"
707
+ }), /*#__PURE__*/jsx("path", {
708
+ d: "M305 19H0v2h305z",
709
+ fill: "currentColor",
710
+ mask: "url(#path-3-inside-1_8605_6776)"
711
+ }), /*#__PURE__*/jsx("circle", {
712
+ cx: "10.596",
713
+ cy: "10.432",
714
+ fill: "#FD5350",
715
+ r: "2.307"
716
+ }), /*#__PURE__*/jsx("circle", {
717
+ cx: "18.143",
718
+ cy: "10.432",
719
+ fill: "#FEB33A",
720
+ r: "2.307"
721
+ }), /*#__PURE__*/jsx("circle", {
722
+ cx: "25.69",
723
+ cy: "10.432",
724
+ fill: "#2CC146",
725
+ r: "2.307"
726
+ }), /*#__PURE__*/jsx("path", {
727
+ d: "M36 20h206v10H36zM36 150h206v12H36z",
728
+ fill: "currentColor"
729
+ }), /*#__PURE__*/jsx("rect", {
730
+ height: "103.55",
731
+ rx: "5.217",
732
+ stroke: "rgb(var(--neeto-ui-gray-300))",
733
+ strokeWidth: "0.45",
734
+ width: "205.55",
735
+ x: "36.225",
736
+ y: "38.225"
737
+ }), /*#__PURE__*/jsx("rect", {
738
+ fill: "currentColor",
739
+ height: "2.311",
740
+ rx: "1.156",
741
+ width: "36.079",
742
+ x: "45.32",
743
+ y: "81.914"
744
+ }), /*#__PURE__*/jsx("rect", {
745
+ fill: "currentColor",
746
+ height: "2.311",
747
+ rx: "1.156",
748
+ width: "20.949",
749
+ x: "45.32",
750
+ y: "87.688"
751
+ }), /*#__PURE__*/jsx("rect", {
752
+ fill: "#008068",
753
+ height: "7.988",
754
+ rx: "1",
755
+ width: "23.183",
756
+ x: "203.539",
757
+ y: "61.109"
758
+ }), /*#__PURE__*/jsx("rect", {
759
+ fill: "currentColor",
760
+ height: "7.728",
761
+ rx: "1",
762
+ width: "23.183",
763
+ x: "203.539",
764
+ y: "73.57"
765
+ }), /*#__PURE__*/jsx("rect", {
766
+ fill: "currentColor",
767
+ height: "8.134",
768
+ rx: "1",
769
+ width: "23.183",
770
+ x: "203.539",
771
+ y: "85.773"
772
+ }), /*#__PURE__*/jsx("rect", {
773
+ fill: "currentColor",
774
+ height: "8.134",
775
+ rx: "1",
776
+ width: "23.183",
777
+ x: "203.539",
778
+ y: "98.383"
779
+ }), /*#__PURE__*/jsx("rect", {
780
+ fill: "currentColor",
781
+ height: "8.134",
782
+ rx: "1",
783
+ width: "23.183",
784
+ x: "203.539",
785
+ y: "110.992"
786
+ }), /*#__PURE__*/jsx("circle", {
787
+ cx: "52.077",
788
+ cy: "67.819",
789
+ fill: "currentColor",
790
+ r: "6.733"
791
+ }), /*#__PURE__*/jsx("circle", {
792
+ cx: "120.314",
793
+ cy: "74.322",
794
+ fill: "currentColor",
795
+ r: "2.65"
796
+ }), /*#__PURE__*/jsx("circle", {
797
+ cx: "120.322",
798
+ cy: "84.876",
799
+ fill: "currentColor",
800
+ r: "2.65"
801
+ }), /*#__PURE__*/jsx("circle", {
802
+ cx: "120.322",
803
+ cy: "95.439",
804
+ fill: "currentColor",
805
+ r: "2.65"
806
+ }), /*#__PURE__*/jsx("circle", {
807
+ cx: "130.954",
808
+ cy: "63.767",
809
+ fill: "currentColor",
810
+ r: "2.65"
811
+ }), /*#__PURE__*/jsx("circle", {
812
+ cx: "130.954",
813
+ cy: "74.322",
814
+ fill: "currentColor",
815
+ r: "2.65"
816
+ }), /*#__PURE__*/jsx("circle", {
817
+ cx: "130.954",
818
+ cy: "84.876",
819
+ fill: "currentColor",
820
+ r: "2.65"
821
+ }), /*#__PURE__*/jsx("circle", {
822
+ cx: "130.954",
823
+ cy: "95.439",
824
+ fill: "currentColor",
825
+ r: "2.65"
826
+ }), /*#__PURE__*/jsx("circle", {
827
+ cx: "141.572",
828
+ cy: "63.767",
829
+ fill: "currentColor",
830
+ r: "2.65"
831
+ }), /*#__PURE__*/jsx("circle", {
832
+ cx: "141.572",
833
+ cy: "74.322",
834
+ fill: "currentColor",
835
+ r: "2.65"
836
+ }), /*#__PURE__*/jsx("circle", {
837
+ cx: "141.572",
838
+ cy: "84.876",
839
+ fill: "currentColor",
840
+ r: "2.65"
841
+ }), /*#__PURE__*/jsx("circle", {
842
+ cx: "141.572",
843
+ cy: "95.439",
844
+ fill: "currentColor",
845
+ r: "2.65"
846
+ }), /*#__PURE__*/jsx("circle", {
847
+ cx: "152.181",
848
+ cy: "63.767",
849
+ fill: "currentColor",
850
+ r: "2.65"
851
+ }), /*#__PURE__*/jsx("circle", {
852
+ cx: "152.181",
853
+ cy: "74.322",
854
+ fill: "currentColor",
855
+ r: "2.65"
856
+ }), /*#__PURE__*/jsx("circle", {
857
+ cx: "152.181",
858
+ cy: "84.876",
859
+ fill: "currentColor",
860
+ r: "2.65"
861
+ }), /*#__PURE__*/jsx("circle", {
862
+ cx: "162.806",
863
+ cy: "63.767",
864
+ fill: "currentColor",
865
+ r: "2.65"
866
+ }), /*#__PURE__*/jsx("circle", {
867
+ cx: "162.806",
868
+ cy: "74.322",
869
+ fill: "#008068",
870
+ r: "2.65"
871
+ }), /*#__PURE__*/jsx("circle", {
872
+ cx: "162.806",
873
+ cy: "84.876",
874
+ fill: "currentColor",
875
+ r: "2.65"
876
+ }), /*#__PURE__*/jsx("circle", {
877
+ cx: "173.439",
878
+ cy: "63.767",
879
+ fill: "currentColor",
880
+ r: "2.65"
881
+ }), /*#__PURE__*/jsx("circle", {
882
+ cx: "173.439",
883
+ cy: "74.322",
884
+ fill: "currentColor",
885
+ r: "2.65"
886
+ }), /*#__PURE__*/jsx("circle", {
887
+ cx: "173.439",
888
+ cy: "84.876",
889
+ fill: "currentColor",
890
+ r: "2.65"
891
+ }), /*#__PURE__*/jsx("circle", {
892
+ cx: "184.064",
893
+ cy: "63.767",
894
+ fill: "currentColor",
895
+ r: "2.65"
896
+ }), /*#__PURE__*/jsx("circle", {
897
+ cx: "184.064",
898
+ cy: "74.322",
899
+ fill: "currentColor",
900
+ r: "2.65"
901
+ }), /*#__PURE__*/jsx("circle", {
902
+ cx: "184.075",
903
+ cy: "84.876",
904
+ fill: "currentColor",
905
+ r: "2.65"
906
+ }), /*#__PURE__*/jsx("path", {
907
+ d: "M93.023 38v104",
908
+ stroke: "#E7E7E7",
909
+ strokeWidth: "0.454"
910
+ })]
911
+ }), /*#__PURE__*/jsx("rect", {
912
+ height: "162",
913
+ rx: "5.5",
914
+ stroke: "rgb(var(--neeto-ui-gray-300))",
915
+ width: "277",
916
+ x: "0.5",
917
+ y: "0.5"
918
+ }), /*#__PURE__*/jsx("defs", {
919
+ children: /*#__PURE__*/jsx("clipPath", {
920
+ id: "clip0_8605_6776",
921
+ children: /*#__PURE__*/jsx("rect", {
922
+ fill: "rgb(var(--neeto-ui-white))",
923
+ height: "163",
924
+ rx: "6",
925
+ width: "278"
926
+ })
927
+ })
928
+ })]
929
+ }));
930
+ };
931
+ var FloatingPopupIcon = function FloatingPopupIcon(_ref2) {
932
+ var other = Object.assign({}, (_objectDestructuringEmpty(_ref2), _ref2));
933
+ return /*#__PURE__*/jsxs("svg", _objectSpread$5(_objectSpread$5({
934
+ fill: "none",
935
+ height: "163",
936
+ viewBox: "0 0 278 163",
937
+ width: "278",
938
+ xmlns: "http://www.w3.org/2000/svg"
939
+ }, other), {}, {
940
+ children: [/*#__PURE__*/jsxs("g", {
941
+ clipPath: "url(#clip0_9047_10870)",
942
+ children: [/*#__PURE__*/jsx("rect", {
943
+ fill: "rgb(var(--neeto-ui-white))",
944
+ height: "163",
945
+ rx: "6",
946
+ width: "278"
947
+ }), /*#__PURE__*/jsx("mask", {
948
+ fill: "rgb(var(--neeto-ui-white))",
949
+ id: "path-3-inside-1_9047_10870",
950
+ children: /*#__PURE__*/jsx("path", {
951
+ d: "M0 0H305V20H0V0Z"
952
+ })
953
+ }), /*#__PURE__*/jsx("path", {
954
+ d: "M0 0H305V20H0V0Z",
955
+ fill: "rgb(var(--neeto-ui-white))"
956
+ }), /*#__PURE__*/jsx("path", {
957
+ d: "M305 19H0V21H305V19Z",
958
+ fill: "currentColor",
959
+ mask: "url(#path-3-inside-1_9047_10870)"
960
+ }), /*#__PURE__*/jsx("circle", {
961
+ cx: "10.5963",
962
+ cy: "10.4322",
963
+ fill: "#FD5350",
964
+ r: "2.30723"
965
+ }), /*#__PURE__*/jsx("circle", {
966
+ cx: "18.1432",
967
+ cy: "10.4322",
968
+ fill: "#FEB33A",
969
+ r: "2.30723"
970
+ }), /*#__PURE__*/jsx("circle", {
971
+ cx: "25.69",
972
+ cy: "10.4322",
973
+ fill: "#2CC146",
974
+ r: "2.30723"
975
+ }), /*#__PURE__*/jsx("rect", {
976
+ fill: "currentColor",
977
+ height: "3",
978
+ opacity: "0.78",
979
+ rx: "1.5",
980
+ width: "84.6936",
981
+ x: "145",
982
+ y: "63"
983
+ }), /*#__PURE__*/jsx("rect", {
984
+ fill: "currentColor",
985
+ height: "3",
986
+ opacity: "0.78",
987
+ rx: "1.5",
988
+ width: "89",
989
+ x: "145",
990
+ y: "70"
991
+ }), /*#__PURE__*/jsx("rect", {
992
+ fill: "currentColor",
993
+ height: "3",
994
+ opacity: "0.78",
995
+ rx: "1.5",
996
+ width: "49",
997
+ x: "145",
998
+ y: "77"
999
+ }), /*#__PURE__*/jsx("rect", {
1000
+ fill: "currentColor",
1001
+ height: "3",
1002
+ opacity: "0.78",
1003
+ rx: "1.5",
1004
+ width: "84.6936",
1005
+ x: "36",
1006
+ y: "111"
1007
+ }), /*#__PURE__*/jsx("rect", {
1008
+ fill: "currentColor",
1009
+ height: "3",
1010
+ opacity: "0.78",
1011
+ rx: "1.5",
1012
+ width: "89",
1013
+ x: "36",
1014
+ y: "118"
1015
+ }), /*#__PURE__*/jsx("rect", {
1016
+ fill: "currentColor",
1017
+ height: "3",
1018
+ opacity: "0.78",
1019
+ rx: "1.5",
1020
+ width: "25.8387",
1021
+ x: "36",
1022
+ y: "125"
1023
+ }), /*#__PURE__*/jsx("rect", {
1024
+ fill: "currentColor",
1025
+ height: "35",
1026
+ width: "96",
1027
+ x: "36",
1028
+ y: "57"
1029
+ }), /*#__PURE__*/jsx("rect", {
1030
+ fill: "currentColor",
1031
+ height: "35",
1032
+ width: "95",
1033
+ x: "145",
1034
+ y: "102"
1035
+ }), /*#__PURE__*/jsx("rect", {
1036
+ fill: "currentColor",
1037
+ height: "26",
1038
+ width: "204",
1039
+ x: "36",
1040
+ y: "20"
1041
+ }), /*#__PURE__*/jsx("rect", {
1042
+ fill: "currentColor",
1043
+ height: "14",
1044
+ width: "204",
1045
+ x: "36",
1046
+ y: "148"
1047
+ })]
1048
+ }), /*#__PURE__*/jsx("rect", {
1049
+ height: "162",
1050
+ rx: "5.5",
1051
+ stroke: "rgb(var(--neeto-ui-gray-300))",
1052
+ width: "277",
1053
+ x: "0.5",
1054
+ y: "0.5"
1055
+ }), /*#__PURE__*/jsx("rect", {
1056
+ fill: "#008068",
1057
+ height: "18",
1058
+ rx: "9",
1059
+ width: "69",
1060
+ x: "194",
1061
+ y: "134"
1062
+ }), /*#__PURE__*/jsx("defs", {
1063
+ children: /*#__PURE__*/jsx("clipPath", {
1064
+ id: "clip0_9047_10870",
1065
+ children: /*#__PURE__*/jsx("rect", {
1066
+ fill: "rgb(var(--neeto-ui-white))",
1067
+ height: "163",
1068
+ rx: "6",
1069
+ width: "278"
1070
+ })
1071
+ })
1072
+ })]
1073
+ }));
1074
+ };
1075
+ var ElementPopupIcon = function ElementPopupIcon(_ref3) {
1076
+ var other = Object.assign({}, (_objectDestructuringEmpty(_ref3), _ref3));
1077
+ return /*#__PURE__*/jsxs("svg", _objectSpread$5(_objectSpread$5({
1078
+ fill: "none",
1079
+ height: "163",
1080
+ viewBox: "0 0 278 163",
1081
+ width: "278",
1082
+ xmlns: "http://www.w3.org/2000/svg"
1083
+ }, other), {}, {
1084
+ children: [/*#__PURE__*/jsxs("g", {
1085
+ clipPath: "url(#clip0_9047_10869)",
1086
+ children: [/*#__PURE__*/jsx("rect", {
1087
+ fill: "rgb(var(--neeto-ui-white))",
1088
+ height: "163",
1089
+ rx: "6",
1090
+ width: "278"
1091
+ }), /*#__PURE__*/jsx("mask", {
1092
+ fill: "rgb(var(--neeto-ui-white))",
1093
+ id: "path-3-inside-1_9047_10869",
1094
+ children: /*#__PURE__*/jsx("path", {
1095
+ d: "M0 0h305v20H0z"
1096
+ })
1097
+ }), /*#__PURE__*/jsx("path", {
1098
+ d: "M0 0h305v20H0z",
1099
+ fill: "rgb(var(--neeto-ui-white))"
1100
+ }), /*#__PURE__*/jsx("path", {
1101
+ d: "M305 19H0v2h305z",
1102
+ fill: "currentColor",
1103
+ mask: "url(#path-3-inside-1_9047_10869)"
1104
+ }), /*#__PURE__*/jsx("circle", {
1105
+ cx: "10.596",
1106
+ cy: "10.432",
1107
+ fill: "#FD5350",
1108
+ r: "2.307"
1109
+ }), /*#__PURE__*/jsx("circle", {
1110
+ cx: "18.143",
1111
+ cy: "10.432",
1112
+ fill: "#FEB33A",
1113
+ r: "2.307"
1114
+ }), /*#__PURE__*/jsx("circle", {
1115
+ cx: "25.69",
1116
+ cy: "10.432",
1117
+ fill: "#2CC146",
1118
+ r: "2.307"
1119
+ })]
1120
+ }), /*#__PURE__*/jsx("rect", {
1121
+ height: "162",
1122
+ rx: "5.5",
1123
+ stroke: "rgb(var(--neeto-ui-gray-300))",
1124
+ width: "277",
1125
+ x: "0.5",
1126
+ y: "0.5"
1127
+ }), /*#__PURE__*/jsx("rect", {
1128
+ fill: "currentColor",
1129
+ height: "3.944",
1130
+ opacity: "0.78",
1131
+ rx: "1.972",
1132
+ width: "85",
1133
+ x: "135",
1134
+ y: "58.461"
1135
+ }), /*#__PURE__*/jsx("rect", {
1136
+ fill: "currentColor",
1137
+ height: "3.944",
1138
+ opacity: "0.78",
1139
+ rx: "1.972",
1140
+ width: "89",
1141
+ x: "135",
1142
+ y: "66.352"
1143
+ }), /*#__PURE__*/jsx("rect", {
1144
+ fill: "#008068",
1145
+ height: "7",
1146
+ rx: "3.5",
1147
+ width: "38",
1148
+ x: "135",
1149
+ y: "74"
1150
+ }), /*#__PURE__*/jsx("rect", {
1151
+ fill: "currentColor",
1152
+ height: "3.944",
1153
+ opacity: "0.78",
1154
+ rx: "1.972",
1155
+ width: "85",
1156
+ x: "135",
1157
+ y: "100.859"
1158
+ }), /*#__PURE__*/jsx("rect", {
1159
+ fill: "currentColor",
1160
+ height: "3.944",
1161
+ opacity: "0.78",
1162
+ rx: "1.972",
1163
+ width: "89",
1164
+ x: "135",
1165
+ y: "108.75"
1166
+ }), /*#__PURE__*/jsx("rect", {
1167
+ fill: "currentColor",
1168
+ height: "3.944",
1169
+ opacity: "0.78",
1170
+ rx: "1.972",
1171
+ width: "26",
1172
+ x: "135",
1173
+ y: "116.641"
1174
+ }), /*#__PURE__*/jsx("path", {
1175
+ d: "M36 52h88v34H36zM36 20h204v28H36zM240 162H36v-28h204zM36 90h88v41H36z",
1176
+ fill: "currentColor"
1177
+ }), /*#__PURE__*/jsx("defs", {
1178
+ children: /*#__PURE__*/jsx("clipPath", {
1179
+ id: "clip0_9047_10869",
1180
+ children: /*#__PURE__*/jsx("rect", {
1181
+ fill: "rgb(var(--neeto-ui-white))",
1182
+ height: "163",
1183
+ rx: "6",
1184
+ width: "278"
1185
+ })
1186
+ })
1187
+ })]
1188
+ }));
1189
+ };
1190
+
1191
+ var EMBED_OPTIONS = {
1192
+ INLINE: "inline",
1193
+ FLOATING_POPUP: "floatingPopup",
1194
+ ELEMENT_POPUP: "elementPopup",
1195
+ IFRAME: "iframe"
1196
+ };
1197
+ var EMBED_ICONS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, InlineEmbedIcon), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopupIcon), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopupIcon), EMBED_OPTIONS.IFRAME, InlineEmbedIcon);
1198
+ var DEFAULT_CUSTOMIZATION = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, {
1199
+ width: 100,
1200
+ height: 100,
1201
+ elementSelector: "inline-embed-container"
1202
+ }), EMBED_OPTIONS.FLOATING_POPUP, {
1203
+ showIcon: false,
1204
+ btnText: "Open",
1205
+ btnColor: "#008068",
1206
+ btnTextColor: "#fff",
1207
+ btnPosition: "bottomRight"
1208
+ }), EMBED_OPTIONS.ELEMENT_POPUP, {
1209
+ elementSelector: "open-popup-button"
1210
+ }), EMBED_OPTIONS.IFRAME, {
1211
+ height: 100,
1212
+ width: 100,
1213
+ iframeTitle: "Iframe embed"
1214
+ });
1215
+ var EMBED_CUSTOMIZATION_COMPONENTS = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline$1), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup$1), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup$1), EMBED_OPTIONS.IFRAME, Iframe$1);
1216
+ var EMBED_TITLES = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, t("neetoMolecules.productEmbed.inline.title")), EMBED_OPTIONS.FLOATING_POPUP, t("neetoMolecules.productEmbed.floatingPopup.title")), EMBED_OPTIONS.ELEMENT_POPUP, t("neetoMolecules.productEmbed.elementPopup.title")), EMBED_OPTIONS.IFRAME, t("neetoMolecules.productEmbed.iframe.title"));
1217
+ var SUPPORTED_LANGUAGES = [{
1218
+ value: "html",
1219
+ label: t("neetoMolecules.productEmbed.language.html")
1220
+ }, {
1221
+ value: "react",
1222
+ label: t("neetoMolecules.productEmbed.language.react")
1223
+ }];
1224
+ var SCRIPT_ID = "embed-script";
1225
+ var TAB_STRING = " ";
1226
+ var SWITCH_OPTIONS = {
1227
+ dynamicHeight: {
1228
+ label: t("neetoMolecules.productEmbed.dynamicHeight")
1229
+ },
1230
+ hideTitle: {
1231
+ label: t("neetoMolecules.productEmbed.hideTitle")
1232
+ },
1233
+ alignContentLeft: {
1234
+ label: t("neetoMolecules.productEmbed.alignContentLeft")
1235
+ },
1236
+ transparentBackground: {
1237
+ label: t("neetoMolecules.productEmbed.transparentBackground")
1238
+ }
1239
+ };
1240
+
1241
+ var Code = function Code(_ref) {
1242
+ var id = _ref.id,
1243
+ selectedEmbed = _ref.selectedEmbed,
1244
+ embedScriptLink = _ref.embedScriptLink,
1245
+ extraArgs = _ref.extraArgs,
1246
+ inlineWrapperStyle = _ref.inlineWrapperStyle,
1247
+ iframeStyle = _ref.iframeStyle,
1248
+ supportedLanguages = _ref.supportedLanguages,
1249
+ customization = _ref.customization;
1250
+ var _useTranslation = useTranslation(),
1251
+ t = _useTranslation.t;
1252
+ var supportedLanguagesOptions = filterBy({
1253
+ value: function value(_value) {
1254
+ return supportedLanguages === null || supportedLanguages === void 0 ? void 0 : supportedLanguages.includes(_value);
1255
+ }
1256
+ }, SUPPORTED_LANGUAGES);
1257
+ var _useState = useState(supportedLanguagesOptions[0].value),
1258
+ _useState2 = _slicedToArray(_useState, 2),
1259
+ selectedLanguage = _useState2[0],
1260
+ setSelectedLanguage = _useState2[1];
1261
+ var code = generateCode({
1262
+ id: id,
1263
+ selectedLanguage: selectedLanguage,
1264
+ type: selectedEmbed,
1265
+ customization: customization,
1266
+ embedScriptLink: embedScriptLink,
1267
+ extraArgs: extraArgs,
1268
+ inlineWrapperStyle: inlineWrapperStyle,
1269
+ iframeStyle: iframeStyle
1270
+ });
1271
+ return /*#__PURE__*/jsxs("div", {
1272
+ className: "flex flex-col gap-3",
1273
+ children: [/*#__PURE__*/jsxs("div", {
1274
+ className: "flex items-center justify-between",
1275
+ children: [/*#__PURE__*/jsx(Typography, {
1276
+ variant: "h4",
1277
+ children: t("neetoMolecules.productEmbed.embedCode")
1278
+ }), /*#__PURE__*/jsx(Select, {
1279
+ className: "w-28 flex-grow-0",
1280
+ options: supportedLanguagesOptions,
1281
+ size: "small",
1282
+ value: selectedLanguage,
1283
+ onChange: setSelectedLanguage
1284
+ })]
1285
+ }), /*#__PURE__*/jsx("div", {
1286
+ className: "relative w-full overflow-y-auto [&_.neeto-molecules-code-block]:!mt-0 [&_.neeto-molecules-code-block]:h-[13.4375rem] [&_.neeto-molecules-code-block]:text-sm",
1287
+ "data-testid": "embed-code-block",
1288
+ children: /*#__PURE__*/jsx(Codeblock, {
1289
+ code: code,
1290
+ codeblockProps: {
1291
+ "data-testid": "".concat(selectedLanguage, "-code-block")
1292
+ },
1293
+ copyButtonProps: {
1294
+ variant: "default",
1295
+ label: t("neetoMolecules.productEmbed.copyCode")
1296
+ }
1297
+ })
1298
+ })]
1299
+ });
1300
+ };
1301
+
1302
+ function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1303
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1304
+ var FloatingPopupPlaceholderImage = function FloatingPopupPlaceholderImage(_ref) {
1305
+ var other = Object.assign({}, (_objectDestructuringEmpty(_ref), _ref));
1306
+ return /*#__PURE__*/jsxs("svg", _objectSpread$4(_objectSpread$4({
1307
+ fill: "none",
1308
+ height: "518",
1309
+ viewBox: "0 0 796 518",
1310
+ width: "796",
1311
+ xmlns: "http://www.w3.org/2000/svg"
1312
+ }, other), {}, {
1313
+ children: [/*#__PURE__*/jsx("rect", {
1314
+ fill: "currentColor",
1315
+ height: "12.706",
1316
+ opacity: "0.78",
1317
+ rx: "6.353",
1318
+ width: "358.702",
1319
+ x: "406.645",
1320
+ y: "152.109"
1321
+ }), /*#__PURE__*/jsx("rect", {
1322
+ fill: "currentColor",
1323
+ height: "12.706",
1324
+ opacity: "0.78",
1325
+ rx: "6.353",
1326
+ width: "376.941",
1327
+ x: "406.645",
1328
+ y: "181.758"
1329
+ }), /*#__PURE__*/jsx("rect", {
1330
+ fill: "currentColor",
1331
+ height: "12.706",
1332
+ opacity: "0.78",
1333
+ rx: "6.353",
1334
+ width: "207.529",
1335
+ x: "406.645",
1336
+ y: "211.406"
1337
+ }), /*#__PURE__*/jsx("rect", {
1338
+ fill: "currentColor",
1339
+ height: "12.706",
1340
+ opacity: "0.78",
1341
+ rx: "6.353",
1342
+ width: "358.702",
1343
+ y: "333.414"
1344
+ }), /*#__PURE__*/jsx("rect", {
1345
+ fill: "currentColor",
1346
+ height: "12.706",
1347
+ opacity: "0.78",
1348
+ rx: "6.353",
1349
+ width: "376.941",
1350
+ y: "363.062"
1351
+ }), /*#__PURE__*/jsx("rect", {
1352
+ fill: "currentColor",
1353
+ height: "12.706",
1354
+ opacity: "0.78",
1355
+ rx: "6.353",
1356
+ width: "109.435",
1357
+ y: "392.711"
1358
+ }), /*#__PURE__*/jsx("path", {
1359
+ d: "M0 127.203h374v148H0zM407 295h389v149H407zM0 .203h796v110H0zM0 460.203h796v59H0z",
1360
+ fill: "currentColor"
1361
+ })]
1362
+ }));
1363
+ };
1364
+ var ElementPopupPlaceholderImage = function ElementPopupPlaceholderImage(_ref2) {
1365
+ var other = Object.assign({}, (_objectDestructuringEmpty(_ref2), _ref2));
1366
+ return /*#__PURE__*/jsxs("svg", _objectSpread$4(_objectSpread$4({
1367
+ fill: "none",
1368
+ height: "518",
1369
+ viewBox: "0 0 748 518",
1370
+ width: "748",
1371
+ xmlns: "http://www.w3.org/2000/svg"
1372
+ }, other), {}, {
1373
+ children: [/*#__PURE__*/jsx("rect", {
1374
+ fill: "currentColor",
1375
+ height: "14.463",
1376
+ opacity: "0.78",
1377
+ rx: "7.231",
1378
+ width: "311.667",
1379
+ x: "363",
1380
+ y: "142.688"
1381
+ }), /*#__PURE__*/jsx("rect", {
1382
+ fill: "currentColor",
1383
+ height: "14.463",
1384
+ opacity: "0.78",
1385
+ rx: "7.231",
1386
+ width: "326.333",
1387
+ x: "363",
1388
+ y: "171.617"
1389
+ }), /*#__PURE__*/jsx("rect", {
1390
+ fill: "currentColor",
1391
+ height: "14.463",
1392
+ opacity: "0.78",
1393
+ rx: "7.231",
1394
+ width: "311.667",
1395
+ x: "363",
1396
+ y: "298.141"
1397
+ }), /*#__PURE__*/jsx("rect", {
1398
+ fill: "currentColor",
1399
+ height: "14.463",
1400
+ opacity: "0.78",
1401
+ rx: "7.231",
1402
+ width: "326.333",
1403
+ x: "363",
1404
+ y: "327.07"
1405
+ }), /*#__PURE__*/jsx("rect", {
1406
+ fill: "currentColor",
1407
+ height: "14.463",
1408
+ opacity: "0.78",
1409
+ rx: "7.231",
1410
+ width: "95.333",
1411
+ x: "363",
1412
+ y: "356"
1413
+ }), /*#__PURE__*/jsx("path", {
1414
+ d: "M0 119h322.667v124.667H0zM0 0h748v104H0zM748 522.336H0V419.669h748zM0 258.328h322.667v150.333H0z",
1415
+ fill: "currentColor"
1416
+ })]
1417
+ }));
1418
+ };
1419
+
1420
+ var ElementPopup = function ElementPopup(_ref) {
1421
+ var iframeURL = _ref.iframeURL;
1422
+ var _useTranslation = useTranslation(),
1423
+ t = _useTranslation.t;
1424
+
1425
+ /**
1426
+ * Currently embed() function doesn't have an unembed handler.
1427
+ * When iframe link changes, we don't have an option to reinitiate it.
1428
+ * So we forcefully recreate the element with `key` and call embed() again
1429
+ */
1430
+ var elementSelectorId = useMemo(function () {
1431
+ return "popup-button-".concat(Math.random().toString().substring(2, 10));
1432
+ }, [iframeURL]);
1433
+ useEffect(function () {
1434
+ var _window$appName;
1435
+ var element = document.getElementById(elementSelectorId);
1436
+ if (!element) return;
1437
+ var appName = globalProps$1.appName.replace(/^neeto/i, "neeto");
1438
+ (_window$appName = window[appName]) === null || _window$appName === void 0 || _window$appName.embed(element, iframeURL);
1439
+ }, [iframeURL]);
1440
+ return /*#__PURE__*/jsxs("div", {
1441
+ className: "relative h-full w-full overflow-hidden",
1442
+ children: [/*#__PURE__*/jsx(ElementPopupPlaceholderImage, {
1443
+ className: "text-muted-foreground/20 absolute inset-0 h-auto w-full p-10"
1444
+ }), /*#__PURE__*/jsx(Button, {
1445
+ className: "absolute start-[48.5294117647%] top-[39.0804597701%]",
1446
+ "data-testid": "preview-element-popup-button",
1447
+ id: elementSelectorId,
1448
+ label: t("neetoMolecules.productEmbed.elementPopup.label")
1449
+ }, elementSelectorId)]
1450
+ });
1451
+ };
1452
+
1453
+ var FloatingPopup = function FloatingPopup(_ref) {
1454
+ var iframeURL = _ref.iframeURL,
1455
+ customization = _ref.customization;
1456
+ var btnTextColor = customization.btnTextColor,
1457
+ showIcon = customization.showIcon,
1458
+ btnText = customization.btnText,
1459
+ btnPosition = customization.btnPosition,
1460
+ btnColor = customization.btnColor,
1461
+ icon = customization.icon;
1462
+
1463
+ /**
1464
+ * Currently embed() function doesn't have an unembed handler.
1465
+ * When iframe link changes, we don't have an option to reinitiate it.
1466
+ * So we forcefully recreate the element with `key` and call embed() again
1467
+ */
1468
+ var elementSelectorId = useMemo(function () {
1469
+ return "popup-button-".concat(Math.random().toString().substring(2, 10));
1470
+ }, [iframeURL]);
1471
+ useEffect(function () {
1472
+ var _window$appName;
1473
+ var element = document.getElementById(elementSelectorId);
1474
+ if (!element) return;
1475
+ var appName = globalProps$1.appName.replace(/^neeto/i, "neeto");
1476
+ (_window$appName = window[appName]) === null || _window$appName === void 0 || _window$appName.embed(element, iframeURL);
1477
+ }, [iframeURL]);
1478
+ useEffect(function () {
1479
+ var btn = document.getElementById(elementSelectorId);
1480
+ btn.style.backgroundColor = btnColor;
1481
+ btn.style.color = btnTextColor;
1482
+ }, [btnColor, btnTextColor]);
1483
+ return /*#__PURE__*/jsxs("div", {
1484
+ className: "relative h-full w-full overflow-hidden",
1485
+ children: [/*#__PURE__*/jsx(FloatingPopupPlaceholderImage, {
1486
+ className: "text-muted-foreground/20 h-auto w-full p-10"
1487
+ }), /*#__PURE__*/jsx(Button, {
1488
+ "data-testid": "popup-preview-button",
1489
+ icon: icon && showIcon ? icon : null,
1490
+ iconPosition: "left",
1491
+ id: elementSelectorId,
1492
+ label: btnText,
1493
+ className: classnames("absolute bottom-0 m-4", {
1494
+ "start-0": btnPosition === "bottomLeft",
1495
+ "end-0": btnPosition === "bottomRight"
1496
+ })
1497
+ }, elementSelectorId)]
1498
+ });
1499
+ };
1500
+
1501
+ function useIframeHeightReset(iframeRef, dynamicHeight) {
1502
+ useEffect(function () {
1503
+ if (!(dynamicHeight !== null && dynamicHeight !== void 0 && dynamicHeight.value) && iframeRef !== null && iframeRef !== void 0 && iframeRef.current) {
1504
+ iframeRef.current.style.height = "";
1505
+ }
1506
+ }, [dynamicHeight === null || dynamicHeight === void 0 ? void 0 : dynamicHeight.value, iframeRef]);
1507
+ }
1508
+
1509
+ function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1510
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1511
+ var Iframe = function Iframe(_ref) {
1512
+ var iframeURL = _ref.iframeURL,
1513
+ customization = _ref.customization;
1514
+ var height = customization.height,
1515
+ width = customization.width,
1516
+ iframeTitle = customization.iframeTitle,
1517
+ dynamicHeight = customization.dynamicHeight,
1518
+ iframeAttributes = customization.iframeAttributes;
1519
+ var iframeRef = useRef(null);
1520
+ useIframeHeightReset(iframeRef, dynamicHeight);
1521
+ return /*#__PURE__*/jsx("iframe", _objectSpread$3(_objectSpread$3({}, _objectSpread$3(_objectSpread$3({}, iframeAttributes), {}, {
1522
+ height: height,
1523
+ width: width
1524
+ })), {}, {
1525
+ allowFullScreen: true,
1526
+ className: "m-auto border-0",
1527
+ ref: iframeRef,
1528
+ src: iframeURL,
1529
+ title: iframeTitle
1530
+ }));
1531
+ };
1532
+
1533
+ var Inline = function Inline(_ref) {
1534
+ var iframeURL = _ref.iframeURL,
1535
+ customization = _ref.customization;
1536
+ var dynamicHeight = customization.dynamicHeight;
1537
+ var iframeRef = useRef(null);
1538
+ useIframeHeightReset(iframeRef, dynamicHeight);
1539
+ return /*#__PURE__*/jsx("iframe", {
1540
+ className: "m-auto border-0",
1541
+ ref: iframeRef,
1542
+ src: iframeURL
1543
+ });
1544
+ };
1545
+
1546
+ function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1547
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1548
+ var buildQueryParams = function buildQueryParams() {
1549
+ var customization = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1550
+ var existingQueryParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1551
+ var activeOptions = Object.keys(SWITCH_OPTIONS).reduce(function (acc, key) {
1552
+ var _customization$key;
1553
+ var value = (_customization$key = customization[key]) === null || _customization$key === void 0 ? void 0 : _customization$key.value;
1554
+ if (value) acc[key] = value;
1555
+ return acc;
1556
+ }, {});
1557
+ return _objectSpread$2(_objectSpread$2({}, existingQueryParams), activeOptions);
1558
+ };
1559
+ var buildIframeURL = function buildIframeURL(_ref) {
1560
+ var previewURL = _ref.previewURL,
1561
+ selectedEmbed = _ref.selectedEmbed,
1562
+ queryParams = _ref.queryParams,
1563
+ customization = _ref.customization;
1564
+ var url = new URL(previewURL);
1565
+ var params = buildQueryParams(customization, queryParams);
1566
+ Object.entries(params).forEach(function (_ref2) {
1567
+ var _ref3 = _slicedToArray(_ref2, 2),
1568
+ name = _ref3[0],
1569
+ value = _ref3[1];
1570
+ url.searchParams.append(name, value);
1571
+ });
1572
+ if (selectedEmbed === EMBED_OPTIONS.FLOATING_POPUP || selectedEmbed === EMBED_OPTIONS.ELEMENT_POPUP) {
1573
+ url.searchParams.set("dynamicHeight", "true");
1574
+ }
1575
+ return url.toString();
1576
+ };
1577
+
1578
+ var Preview = function Preview(_ref) {
1579
+ var isScriptLoading = _ref.isScriptLoading,
1580
+ selectedEmbed = _ref.selectedEmbed,
1581
+ id = _ref.id,
1582
+ customization = _ref.customization,
1583
+ _ref$customPreviewIfr = _ref.customPreviewIframeUrl,
1584
+ customPreviewIframeUrl = _ref$customPreviewIfr === void 0 ? "" : _ref$customPreviewIfr;
1585
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
1586
+ return {
1587
+ queryParams: store["queryParams"]
1588
+ };
1589
+ })),
1590
+ queryParams = _useProductEmbedStore.queryParams;
1591
+ var preview = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, EMBED_OPTIONS.INLINE, Inline), EMBED_OPTIONS.FLOATING_POPUP, FloatingPopup), EMBED_OPTIONS.ELEMENT_POPUP, ElementPopup), EMBED_OPTIONS.IFRAME, Iframe);
1592
+ var previewURL = customPreviewIframeUrl || "".concat(location.origin, "/embed/").concat(id);
1593
+ var iframeURL = buildIframeURL({
1594
+ previewURL: previewURL,
1595
+ selectedEmbed: selectedEmbed,
1596
+ queryParams: queryParams,
1597
+ customization: customization
1598
+ });
1599
+ var Component = preview[selectedEmbed];
1600
+ if (isScriptLoading) {
1601
+ return /*#__PURE__*/jsx("div", {
1602
+ className: "flex min-h-0 flex-grow items-center justify-center overflow-y-auto",
1603
+ children: /*#__PURE__*/jsx(Spinner, {})
1604
+ });
1605
+ }
1606
+ return /*#__PURE__*/jsx(BrowserPreview, {
1607
+ className: "relative h-full [&>iframe]:absolute [&>iframe]:inset-0 [&>iframe]:h-full [&>iframe]:w-full",
1608
+ wrapperClassName: "pointer-events-auto h-full min-h-[18.75rem]",
1609
+ children: /*#__PURE__*/jsx(Component, {
1610
+ customization: customization,
1611
+ iframeURL: iframeURL
1612
+ })
1613
+ });
1614
+ };
1615
+
1616
+ function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1617
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1618
+ var EmbedRenderer = function EmbedRenderer(_ref) {
1619
+ var _options$iframe;
1620
+ var className = _ref.className,
1621
+ customEmbedScriptPath = _ref.customEmbedScriptPath,
1622
+ customPreviewIframeUrl = _ref.customPreviewIframeUrl,
1623
+ id = _ref.id,
1624
+ options = _ref.options,
1625
+ extraArgs = _ref.extraArgs,
1626
+ otherCustomizations = _ref.otherCustomizations,
1627
+ inlineWrapperStyle = _ref.inlineWrapperStyle,
1628
+ iframeStyle = _ref.iframeStyle,
1629
+ supportedLanguages = _ref.supportedLanguages,
1630
+ selectedEmbed = _ref.selectedEmbed;
1631
+ var _useTranslation = useTranslation(),
1632
+ t = _useTranslation.t;
1633
+ var location = useLocation();
1634
+ var _useState = useState(true),
1635
+ _useState2 = _slicedToArray(_useState, 2),
1636
+ isScriptLoading = _useState2[0],
1637
+ setIsScriptLoading = _useState2[1];
1638
+ var _useStateWithDependen = useStateWithDependency(function () {
1639
+ return buildDefaultCustomization(options);
1640
+ }, [options === null || options === void 0 || (_options$iframe = options.iframe) === null || _options$iframe === void 0 ? void 0 : _options$iframe.iframeUrl]),
1641
+ _useStateWithDependen2 = _slicedToArray(_useStateWithDependen, 2),
1642
+ customizations = _useStateWithDependen2[0],
1643
+ setCustomizations = _useStateWithDependen2[1];
1644
+ var description = customizations[selectedEmbed].description;
1645
+ var customization = customizations[selectedEmbed];
1646
+ var CustomizationComponent = EMBED_CUSTOMIZATION_COMPONENTS[selectedEmbed];
1647
+ var embedScriptLink = customEmbedScriptPath || "".concat(window.location.protocol, "//").concat(window.location.host, "/javascript/embed.js");
1648
+ var loadScript = function loadScript() {
1649
+ var script = document.createElement("script");
1650
+ script.id = SCRIPT_ID;
1651
+ script.src = embedScriptLink;
1652
+ script.onload = function () {
1653
+ return setIsScriptLoading(false);
1654
+ };
1655
+ document.head.appendChild(script);
1656
+ };
1657
+ var updateCustomization = function updateCustomization(props) {
1658
+ return setCustomizations(function (prevState) {
1659
+ return _objectSpread$1(_objectSpread$1({}, prevState), {}, _defineProperty({}, selectedEmbed, mergeLeft(props, prevState[selectedEmbed])));
1660
+ });
1661
+ };
1662
+ useEffect(function () {
1663
+ var isScriptLoaded = document.getElementById(SCRIPT_ID);
1664
+ if (isScriptLoaded) setIsScriptLoading(false);else loadScript();
1665
+ }, []);
1666
+ return /*#__PURE__*/jsxs(Container, {
1667
+ "data-testid": "embed-product",
1668
+ className: classnames("neeto-molecules-embed flex w-full flex-grow flex-col p-0 md:flex-row", className),
1669
+ children: [/*#__PURE__*/jsxs("div", {
1670
+ className: "md:border-border flex w-full shrink-0 flex-col items-start overflow-y-auto px-5 py-8 md:h-full md:max-w-[25rem] md:overflow-y-auto md:border-e md:px-10 lg:max-w-[30.3125rem]",
1671
+ children: [/*#__PURE__*/jsx(Button, {
1672
+ className: "mb-4",
1673
+ "data-testid": "back-to-embed-selection-button",
1674
+ icon: ArrowLeft,
1675
+ iconPosition: "left",
1676
+ label: t("neetoMolecules.productEmbed.backToEmbedSelection"),
1677
+ size: "sm",
1678
+ to: location.pathname,
1679
+ variant: "link"
1680
+ }), /*#__PURE__*/jsx(Header, {
1681
+ className: "py-0",
1682
+ "data-testid": "".concat(hyphenate(selectedEmbed), "-embed-title"),
1683
+ title: EMBED_TITLES[selectedEmbed]
1684
+ }), description && /*#__PURE__*/jsx(Typography, {
1685
+ className: "mt-2",
1686
+ "data-testid": "".concat(hyphenate(selectedEmbed), "-description"),
1687
+ variant: "body2",
1688
+ children: description
1689
+ }), /*#__PURE__*/jsx("div", {
1690
+ className: "mt-4 flex w-full flex-col gap-y-6",
1691
+ children: /*#__PURE__*/jsxs("div", {
1692
+ className: "flex flex-col gap-y-6",
1693
+ children: [/*#__PURE__*/jsx(Code, {
1694
+ customization: customization,
1695
+ embedScriptLink: embedScriptLink,
1696
+ extraArgs: extraArgs,
1697
+ id: id,
1698
+ iframeStyle: iframeStyle,
1699
+ inlineWrapperStyle: inlineWrapperStyle,
1700
+ selectedEmbed: selectedEmbed,
1701
+ supportedLanguages: supportedLanguages
1702
+ }), /*#__PURE__*/jsx(CustomizationComponent, {
1703
+ customization: customization,
1704
+ otherCustomizations: otherCustomizations,
1705
+ updateCustomization: updateCustomization
1706
+ })]
1707
+ })
1708
+ })]
1709
+ }), /*#__PURE__*/jsx("div", {
1710
+ className: "bg-muted/40 flex min-h-dvh w-full min-w-0 flex-col gap-3 overflow-y-auto p-6 md:h-full md:min-h-0 md:flex-grow",
1711
+ children: /*#__PURE__*/jsx(Preview, {
1712
+ customPreviewIframeUrl: customPreviewIframeUrl,
1713
+ customization: customization,
1714
+ id: id,
1715
+ isScriptLoading: isScriptLoading,
1716
+ selectedEmbed: selectedEmbed
1717
+ })
1718
+ })]
1719
+ });
1720
+ };
1721
+
1722
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
1723
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1724
+ var EmbedSelector = function EmbedSelector(_ref) {
1725
+ var options = _ref.options,
1726
+ goBackLink = _ref.goBackLink,
1727
+ title = _ref.title,
1728
+ titleHelpPopoverProps = _ref.titleHelpPopoverProps,
1729
+ subTitleHelpPopoverProps = _ref.subTitleHelpPopoverProps;
1730
+ var _useTranslation = useTranslation(),
1731
+ t = _useTranslation.t;
1732
+ var history = useHistory();
1733
+ var location = useLocation();
1734
+ return /*#__PURE__*/jsxs(Container, {
1735
+ className: "neeto-molecules-embed-landing-page py-8",
1736
+ children: [goBackLink && /*#__PURE__*/jsx(Button, {
1737
+ className: "mb-4",
1738
+ "data-testid": "back-button",
1739
+ icon: ArrowLeft,
1740
+ iconPosition: "left",
1741
+ label: t("neetoMolecules.productEmbed.backToShare"),
1742
+ size: "sm",
1743
+ to: goBackLink,
1744
+ variant: "link"
1745
+ }), /*#__PURE__*/jsx(Header, {
1746
+ titleHelpPopoverProps: titleHelpPopoverProps,
1747
+ className: "py-0",
1748
+ "data-testid": "embed-selector-header",
1749
+ title: t("neetoMolecules.productEmbed.title")
1750
+ }), /*#__PURE__*/jsxs("div", {
1751
+ className: "mx-auto w-full max-w-5xl py-6 md:py-10",
1752
+ children: [/*#__PURE__*/jsxs(Typography, {
1753
+ className: "mb-2",
1754
+ variant: "h2",
1755
+ children: [title || t("neetoMolecules.productEmbed.embedSelectionTitle", {
1756
+ productName: globalProps$1.appName
1757
+ }), isPresent(subTitleHelpPopoverProps) && /*#__PURE__*/jsx(HelpPopover, _objectSpread(_objectSpread({}, subTitleHelpPopoverProps), {}, {
1758
+ className: classnames("ml-2 align-middle", subTitleHelpPopoverProps === null || subTitleHelpPopoverProps === void 0 ? void 0 : subTitleHelpPopoverProps.className)
1759
+ }))]
1760
+ }), /*#__PURE__*/jsx(Typography, {
1761
+ className: "mb-8",
1762
+ variant: "body1",
1763
+ children: t("neetoMolecules.productEmbed.embedSelectionDescription")
1764
+ }), /*#__PURE__*/jsx("div", {
1765
+ className: "grid w-full grid-cols-1 flex-wrap gap-6 md:grid-cols-3",
1766
+ children: Object.entries(options).map(function (_ref2) {
1767
+ var _ref3 = _slicedToArray(_ref2, 2),
1768
+ key = _ref3[0],
1769
+ _ref3$ = _ref3[1],
1770
+ label = _ref3$.label,
1771
+ description = _ref3$.description,
1772
+ embedIcon = _ref3$.embedIcon;
1773
+ var EmbedIcon = embedIcon || EMBED_ICONS[key];
1774
+ return /*#__PURE__*/jsxs("button", {
1775
+ className: "border-border bg-background outline-background hover:border-primary hover:outline-primary flex w-full flex-col rounded-xl border p-6 text-start outline outline-1 transition-all motion-reduce:transition-none",
1776
+ "data-testid": "embed-selector-card-".concat(hyphenate(key)),
1777
+ onClick: handleMetaClick(history, "".concat(location.pathname, "?type=").concat(hyphenate(key))),
1778
+ children: [/*#__PURE__*/jsx("span", {
1779
+ className: "mb-6 block",
1780
+ children: /*#__PURE__*/jsx(EmbedIcon, {
1781
+ className: "text-muted-foreground/30 h-auto w-full max-w-72"
1782
+ })
1783
+ }), /*#__PURE__*/jsx(Typography, {
1784
+ className: "mb-2",
1785
+ variant: "h4",
1786
+ children: label
1787
+ }), /*#__PURE__*/jsx(Typography, {
1788
+ variant: "body2",
1789
+ children: description
1790
+ })]
1791
+ }, key);
1792
+ })
1793
+ })]
1794
+ })]
1795
+ });
1796
+ };
1797
+
1798
+ var ProductEmbed = function ProductEmbed(_ref) {
1799
+ var title = _ref.title,
1800
+ _ref$titleHelpPopover = _ref.titleHelpPopoverProps,
1801
+ titleHelpPopoverProps = _ref$titleHelpPopover === void 0 ? {} : _ref$titleHelpPopover,
1802
+ _ref$subTitleHelpPopo = _ref.subTitleHelpPopoverProps,
1803
+ subTitleHelpPopoverProps = _ref$subTitleHelpPopo === void 0 ? {} : _ref$subTitleHelpPopo,
1804
+ _ref$className = _ref.className,
1805
+ className = _ref$className === void 0 ? "" : _ref$className,
1806
+ _ref$customEmbedScrip = _ref.customEmbedScriptPath,
1807
+ customEmbedScriptPath = _ref$customEmbedScrip === void 0 ? "" : _ref$customEmbedScrip,
1808
+ _ref$customPreviewIfr = _ref.customPreviewIframeUrl,
1809
+ customPreviewIframeUrl = _ref$customPreviewIfr === void 0 ? "" : _ref$customPreviewIfr,
1810
+ _ref$goBackLink = _ref.goBackLink,
1811
+ goBackLink = _ref$goBackLink === void 0 ? "" : _ref$goBackLink,
1812
+ id = _ref.id,
1813
+ _ref$isQueryParamsEna = _ref.isQueryParamsEnabled,
1814
+ isQueryParamsEnabled = _ref$isQueryParamsEna === void 0 ? false : _ref$isQueryParamsEna,
1815
+ _ref$queryParamsProps = _ref.queryParamsProps,
1816
+ queryParamsProps = _ref$queryParamsProps === void 0 ? {} : _ref$queryParamsProps,
1817
+ _ref$options = _ref.options,
1818
+ options = _ref$options === void 0 ? {} : _ref$options,
1819
+ _ref$extraArgs = _ref.extraArgs,
1820
+ extraArgs = _ref$extraArgs === void 0 ? {} : _ref$extraArgs,
1821
+ _ref$otherCustomizati = _ref.otherCustomizations,
1822
+ otherCustomizations = _ref$otherCustomizati === void 0 ? noop : _ref$otherCustomizati,
1823
+ _ref$inlineWrapperSty = _ref.inlineWrapperStyle,
1824
+ inlineWrapperStyle = _ref$inlineWrapperSty === void 0 ? "height: 90vh; width: 100%;" : _ref$inlineWrapperSty,
1825
+ _ref$iframeStyle = _ref.iframeStyle,
1826
+ iframeStyle = _ref$iframeStyle === void 0 ? "height: 100%; width: 100%;" : _ref$iframeStyle,
1827
+ _ref$supportedLanguag = _ref.supportedLanguages,
1828
+ supportedLanguages = _ref$supportedLanguag === void 0 ? ["html"] : _ref$supportedLanguag;
1829
+ var _useLocation = useLocation(),
1830
+ search = _useLocation.search;
1831
+ var queryParams = new URLSearchParams(search);
1832
+ var selectedEmbed = toCamelCasedString(queryParams.get("type"));
1833
+ var _useProductEmbedStore = useProductEmbedStore(useShallow(function (store) {
1834
+ return {
1835
+ setProductEmbedState: store["setProductEmbedState"]
1836
+ };
1837
+ })),
1838
+ setProductEmbedState = _useProductEmbedStore.setProductEmbedState;
1839
+ useEffect(function () {
1840
+ setProductEmbedState({
1841
+ isQueryParamsEnabled: isQueryParamsEnabled,
1842
+ queryParamsProps: queryParamsProps
1843
+ });
1844
+ }, []);
1845
+ return selectedEmbed ? /*#__PURE__*/jsx(EmbedRenderer, {
1846
+ className: className,
1847
+ customEmbedScriptPath: customEmbedScriptPath,
1848
+ customPreviewIframeUrl: customPreviewIframeUrl,
1849
+ extraArgs: extraArgs,
1850
+ id: id,
1851
+ iframeStyle: iframeStyle,
1852
+ inlineWrapperStyle: inlineWrapperStyle,
1853
+ options: options,
1854
+ otherCustomizations: otherCustomizations,
1855
+ queryParamsProps: queryParamsProps,
1856
+ selectedEmbed: selectedEmbed,
1857
+ supportedLanguages: supportedLanguages
1858
+ }) : /*#__PURE__*/jsx(EmbedSelector, {
1859
+ goBackLink: goBackLink,
1860
+ options: options,
1861
+ subTitleHelpPopoverProps: subTitleHelpPopoverProps,
1862
+ title: title,
1863
+ titleHelpPopoverProps: titleHelpPopoverProps
1864
+ });
1865
+ };
1866
+
1867
+ export { ProductEmbed as default };
1868
+ //# sourceMappingURL=ProductEmbed.js.map