@commercetools-frontend-extensions/unpublish-products-modal 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +72 -0
  3. package/dist/active-drag-drop-area-c4d16e89.cjs.prod.js +54 -0
  4. package/dist/active-drag-drop-area-cec2c6b5.esm.js +52 -0
  5. package/dist/active-drag-drop-area-f09afa25.cjs.dev.js +54 -0
  6. package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.d.ts +3 -0
  7. package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.dev.js +52 -0
  8. package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.js +7 -0
  9. package/dist/commercetools-frontend-extensions-unpublish-products-modal.cjs.prod.js +52 -0
  10. package/dist/commercetools-frontend-extensions-unpublish-products-modal.esm.js +44 -0
  11. package/dist/de-a34c5dd4.cjs.dev.js +6 -0
  12. package/dist/de-cd6c45d3.esm.js +4 -0
  13. package/dist/de-d954fe3d.cjs.prod.js +6 -0
  14. package/dist/declarations/src/@types/file-upload.d.ts +42 -0
  15. package/dist/declarations/src/@types/import-container.d.ts +11 -0
  16. package/dist/declarations/src/@types/index.d.ts +3 -0
  17. package/dist/declarations/src/@types/unpublish-products-modal-props.d.ts +4 -0
  18. package/dist/declarations/src/index.d.ts +2 -0
  19. package/dist/declarations/src/unpublish-products-modal.d.ts +6 -0
  20. package/dist/en-3a9aa2d4.esm.js +4 -0
  21. package/dist/en-6b3694f6.cjs.dev.js +6 -0
  22. package/dist/en-c7757448.cjs.prod.js +6 -0
  23. package/dist/enabled-drop-area-0fcec033.cjs.dev.js +115 -0
  24. package/dist/enabled-drop-area-82ec844a.esm.js +102 -0
  25. package/dist/enabled-drop-area-9e04a444.cjs.prod.js +115 -0
  26. package/dist/es-042343bd.cjs.prod.js +6 -0
  27. package/dist/es-8b3ecab1.cjs.dev.js +6 -0
  28. package/dist/es-e544023d.esm.js +4 -0
  29. package/dist/file-dropped-area-411688d1.cjs.prod.js +74 -0
  30. package/dist/file-dropped-area-7cd5f0cb.cjs.dev.js +74 -0
  31. package/dist/file-dropped-area-e301d075.esm.js +72 -0
  32. package/dist/fr-FR-9d9081ee.esm.js +4 -0
  33. package/dist/fr-FR-e7126fcc.cjs.dev.js +6 -0
  34. package/dist/fr-FR-fce1ca96.cjs.prod.js +6 -0
  35. package/dist/index-601d8304.cjs.prod.js +1533 -0
  36. package/dist/index-73a8bbcd.cjs.dev.js +1547 -0
  37. package/dist/index-95840e98.esm.js +1517 -0
  38. package/dist/ja-37632763.cjs.prod.js +6 -0
  39. package/dist/ja-73c088a7.esm.js +4 -0
  40. package/dist/ja-9bd5f452.cjs.dev.js +6 -0
  41. package/dist/pt-BR-b37d730b.esm.js +4 -0
  42. package/dist/pt-BR-ea6b3251.cjs.dev.js +6 -0
  43. package/dist/pt-BR-ec2a1a11.cjs.prod.js +6 -0
  44. package/dist/zh-CN-4780d88e.esm.js +4 -0
  45. package/dist/zh-CN-52baa549.cjs.prod.js +6 -0
  46. package/dist/zh-CN-d4bc6d26.cjs.dev.js +6 -0
  47. package/package.json +92 -0
@@ -0,0 +1,1533 @@
1
+ 'use strict';
2
+
3
+ var _Object$keys = require('@babel/runtime-corejs3/core-js-stable/object/keys');
4
+ var _Object$getOwnPropertySymbols = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols');
5
+ var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
6
+ var _Object$getOwnPropertyDescriptor = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor');
7
+ var _forEachInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/for-each');
8
+ var _Object$getOwnPropertyDescriptors = require('@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors');
9
+ var _Object$defineProperties = require('@babel/runtime-corejs3/core-js-stable/object/define-properties');
10
+ var _Object$defineProperty = require('@babel/runtime-corejs3/core-js-stable/object/define-property');
11
+ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
12
+ var reactIntl = require('react-intl');
13
+ var applicationShellConnectors = require('@commercetools-frontend/application-shell-connectors');
14
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
15
+ var React = require('react');
16
+ var sdk = require('@commercetools-frontend/sdk');
17
+ var _JSON$stringify = require('@babel/runtime-corejs3/core-js-stable/json/stringify');
18
+ var constants = require('@commercetools-frontend/constants');
19
+ var _everyInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/every');
20
+ var _Promise = require('@babel/runtime-corejs3/core-js-stable/promise');
21
+ var _Array$isArray = require('@babel/runtime-corejs3/core-js-stable/array/is-array');
22
+ var _findInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/find');
23
+ var _mapInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/map');
24
+ var Papa = require('papaparse');
25
+ var jsxRuntime = require('@emotion/react/jsx-runtime');
26
+ var applicationComponents = require('@commercetools-frontend/application-components');
27
+ var fullstory = require('@commercetools-frontend/fullstory');
28
+ var uiKit = require('@commercetools-frontend/ui-kit');
29
+ var _someInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/some');
30
+ var reactDropzone = require('react-dropzone');
31
+ var actionsGlobal = require('@commercetools-frontend/actions-global');
32
+ var _styled = require('@emotion/styled/base');
33
+ var react = require('@emotion/react');
34
+ var _Reflect$construct = require('@babel/runtime-corejs3/core-js-stable/reflect/construct');
35
+ var _createClass = require('@babel/runtime-corejs3/helpers/createClass');
36
+ var _classCallCheck = require('@babel/runtime-corejs3/helpers/classCallCheck');
37
+ var _possibleConstructorReturn = require('@babel/runtime-corejs3/helpers/possibleConstructorReturn');
38
+ var _getPrototypeOf = require('@babel/runtime-corejs3/helpers/getPrototypeOf');
39
+ var _inherits = require('@babel/runtime-corejs3/helpers/inherits');
40
+ var _wrapNativeSuper = require('@babel/runtime-corejs3/helpers/wrapNativeSuper');
41
+ var sentry = require('@commercetools-frontend/sentry');
42
+ var applicationShell = require('@commercetools-frontend/application-shell');
43
+ var _sliceInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/slice');
44
+ var DataTable = require('@commercetools-uikit/data-table');
45
+ var i18n = require('@commercetools-frontend/i18n');
46
+
47
+ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
48
+
49
+ var _Object$keys__default = /*#__PURE__*/_interopDefault(_Object$keys);
50
+ var _Object$getOwnPropertySymbols__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertySymbols);
51
+ var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
52
+ var _Object$getOwnPropertyDescriptor__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptor);
53
+ var _forEachInstanceProperty__default = /*#__PURE__*/_interopDefault(_forEachInstanceProperty);
54
+ var _Object$getOwnPropertyDescriptors__default = /*#__PURE__*/_interopDefault(_Object$getOwnPropertyDescriptors);
55
+ var _Object$defineProperties__default = /*#__PURE__*/_interopDefault(_Object$defineProperties);
56
+ var _Object$defineProperty__default = /*#__PURE__*/_interopDefault(_Object$defineProperty);
57
+ var React__default = /*#__PURE__*/_interopDefault(React);
58
+ var _JSON$stringify__default = /*#__PURE__*/_interopDefault(_JSON$stringify);
59
+ var _everyInstanceProperty__default = /*#__PURE__*/_interopDefault(_everyInstanceProperty);
60
+ var _Promise__default = /*#__PURE__*/_interopDefault(_Promise);
61
+ var _Array$isArray__default = /*#__PURE__*/_interopDefault(_Array$isArray);
62
+ var _findInstanceProperty__default = /*#__PURE__*/_interopDefault(_findInstanceProperty);
63
+ var _mapInstanceProperty__default = /*#__PURE__*/_interopDefault(_mapInstanceProperty);
64
+ var Papa__default = /*#__PURE__*/_interopDefault(Papa);
65
+ var _someInstanceProperty__default = /*#__PURE__*/_interopDefault(_someInstanceProperty);
66
+ var _styled__default = /*#__PURE__*/_interopDefault(_styled);
67
+ var _Reflect$construct__default = /*#__PURE__*/_interopDefault(_Reflect$construct);
68
+ var _sliceInstanceProperty__default = /*#__PURE__*/_interopDefault(_sliceInstanceProperty);
69
+ var DataTable__default = /*#__PURE__*/_interopDefault(DataTable);
70
+
71
+ function ownKeys$a(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
72
+ function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$a(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$a(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
73
+ function reducer(state, action) {
74
+ if (action.type === 'setCurrentStep') return _objectSpread$a(_objectSpread$a({}, state), {}, {
75
+ currentStep: action.currentStep,
76
+ progress: 0
77
+ });
78
+ if (action.type === 'setContainerKey') return _objectSpread$a(_objectSpread$a({}, state), {}, {
79
+ containerKey: action.containerKey
80
+ });
81
+ if (action.type === 'cancelImport') return _objectSpread$a(_objectSpread$a({}, state), {}, {
82
+ currentStep: 'upload',
83
+ containerKey: undefined,
84
+ droppedFile: undefined,
85
+ dropAreaState: 'ready-for-drop',
86
+ progress: 0
87
+ });
88
+ if (action.type === 'uploadNewFile') return _objectSpread$a(_objectSpread$a({}, state), {}, {
89
+ currentStep: 'upload',
90
+ containerKey: undefined,
91
+ droppedFile: undefined,
92
+ dropAreaState: 'ready-for-drop',
93
+ progress: 0
94
+ });
95
+ if (action.type === 'setDroppedFile') {
96
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
97
+ droppedFile: action.droppedFile
98
+ });
99
+ }
100
+ if (action.type === 'setAbortController') {
101
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
102
+ abortController: action.abortController
103
+ });
104
+ }
105
+ if (action.type === 'setProgress') {
106
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
107
+ progress: action.progress
108
+ });
109
+ }
110
+ if (action.type === 'setUploadFileResponse') {
111
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
112
+ uploadFileResponse: action.uploadFileResponse
113
+ });
114
+ }
115
+ if (action.type === 'setFileUploadErrors') {
116
+ return _objectSpread$a(_objectSpread$a({}, state), {}, {
117
+ fileUploadErrors: action.fileUploadErrors
118
+ });
119
+ }
120
+ throw new Error(getUnknownActionError(action));
121
+ }
122
+ function getUnknownActionError(actionType) {
123
+ return `Unkown type: ${actionType}`;
124
+ }
125
+ const initialState = {
126
+ currentStep: 'upload',
127
+ abortController: new AbortController(),
128
+ dropAreaState: 'ready-for-drop',
129
+ containerKey: undefined,
130
+ progress: 0,
131
+ uploadFileResponse: undefined,
132
+ fileUploadErrors: []
133
+ };
134
+ const initialActions = {
135
+ setCurrentStep(_currentStep) {
136
+ /**/
137
+ },
138
+ cancelImport() {
139
+ /**/
140
+ },
141
+ uploadNewFile() {
142
+ /**/
143
+ },
144
+ setDroppedFile(_nextDroppedFile) {
145
+ /**/
146
+ },
147
+ setUploadFileResponse(_uploadFileResponse) {
148
+ /**/
149
+ },
150
+ setFileUploadErrors(_fileUploadErrors) {
151
+ /**/
152
+ },
153
+ setContainerKey(_containerKey) {
154
+ /**/
155
+ },
156
+ setAbortController(_abortController) {
157
+ /**/
158
+ },
159
+ setProgress(_progress) {
160
+ /**/
161
+ }
162
+ };
163
+
164
+ function getCreateImportContainerURL(projectKey) {
165
+ return `/${projectKey}/import-containers`;
166
+ }
167
+ function getDeleteImportContainerURL(projectKey, containerKey) {
168
+ return `/${projectKey}/import-containers/${containerKey}`;
169
+ }
170
+ function getFileUploadURL(projectKey, containerKey) {
171
+ return `/${projectKey}/products/import-containers/${containerKey}/file-upload`;
172
+ }
173
+ function getProccessFileURL(projectKey, containerKey) {
174
+ return `/${projectKey}/products/import-containers/${containerKey}/process-file`;
175
+ }
176
+
177
+ function createImportContainerForFileUpload(importContainerDraft, projectKey, asyncDispatch) {
178
+ return asyncDispatch(sdk.actions.post({
179
+ mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.IMPORT,
180
+ uri: getCreateImportContainerURL(projectKey),
181
+ headers: {
182
+ accept: 'application/json',
183
+ 'Content-Type': 'application/json'
184
+ },
185
+ payload: _JSON$stringify__default["default"](importContainerDraft)
186
+ }));
187
+ }
188
+ function deleteImportContainer(projectKey, containerKey, asyncDispatch) {
189
+ return asyncDispatch(sdk.actions.del({
190
+ mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.IMPORT,
191
+ uri: getDeleteImportContainerURL(projectKey, containerKey),
192
+ headers: {
193
+ accept: 'application/json'
194
+ }
195
+ }));
196
+ }
197
+
198
+ function convertFileSizeToKB(sizeInBytes) {
199
+ return sizeInBytes / 1000;
200
+ }
201
+ function hasOwnProperty(obj, prop) {
202
+ return typeof obj === 'object' && obj !== null && obj.hasOwnProperty(prop);
203
+ }
204
+ function hasRequiredFields(maybeValidObject, requiredFields) {
205
+ return typeof maybeValidObject === 'object' && maybeValidObject !== null && _everyInstanceProperty__default["default"](requiredFields).call(requiredFields, property => hasOwnProperty(maybeValidObject, property));
206
+ }
207
+ function isAbortError(error) {
208
+ return error instanceof DOMException && error.name === 'AbortError';
209
+ }
210
+
211
+ const encodeFileNameWithTimestampToContainerKey = fileName => {
212
+ return btoa(_JSON$stringify__default["default"]({
213
+ timestamp: new Date().getTime(),
214
+ fileName
215
+ })).replace(/=+$/g, '');
216
+ };
217
+
218
+ function ownKeys$9(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
219
+ function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$9(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$9(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
220
+ /**
221
+ * Returns the number of rows in a CSV file excluding the header
222
+ * @param file The CSV file to process.
223
+ * @returns A promise that resolves to the number of rows
224
+ */
225
+ const getRowCount = file => {
226
+ return new _Promise__default["default"](resolve => {
227
+ let lineCount = 0;
228
+ Papa__default["default"].parse(file, {
229
+ step: _ref => {
230
+ let data = _ref.data;
231
+ // empty lines at the end of the file should not be counted
232
+ if (_Array$isArray__default["default"](data) && _findInstanceProperty__default["default"](data).call(data, Boolean)) lineCount++;
233
+ },
234
+ complete: () => {
235
+ // Subtract 1 for the header row
236
+ // We use Math.max to make sure the count is not less than 0, this is needed for empty files
237
+ resolve(Math.max(0, lineCount - 1));
238
+ }
239
+ });
240
+ });
241
+ };
242
+
243
+ /**
244
+ * Checks if the CSV file only contains a single column named 'key'
245
+ * @param file The CSV file to process
246
+ * @returns A promise that resolves to true if the file contains only one column named 'key', otherwise false
247
+ */
248
+ const hasSingleKeyColumn = file => {
249
+ return new _Promise__default["default"](resolve => {
250
+ Papa__default["default"].parse(file, {
251
+ header: true,
252
+ // Only parse the first row (header)
253
+ preview: 1,
254
+ complete: results => {
255
+ const fields = results?.meta?.fields;
256
+ resolve(fields.length === 1 && fields[0] === 'key');
257
+ }
258
+ });
259
+ });
260
+ };
261
+ const toBytes = megabytes => megabytes * 1024 * 1024;
262
+ const mapFileUploadErrorsToUploadFileErrorRows = uploadFileErrors => {
263
+ let idCounter = 1;
264
+ return _mapInstanceProperty__default["default"](uploadFileErrors).call(uploadFileErrors, uploadFileError => _objectSpread$9(_objectSpread$9({}, uploadFileError), {}, {
265
+ id: String(idCounter++)
266
+ }));
267
+ };
268
+
269
+ async function processUploadedFile(_ref) {
270
+ let projectKey = _ref.projectKey,
271
+ containerKey = _ref.containerKey,
272
+ asyncDispatch = _ref.asyncDispatch;
273
+ const uri = getProccessFileURL(projectKey, containerKey);
274
+ const response = await asyncDispatch(sdk.actions.post({
275
+ mcApiProxyTarget: constants.MC_API_PROXY_TARGETS.IMPORT,
276
+ uri: uri,
277
+ headers: {
278
+ accept: 'application/json',
279
+ 'Content-Type': 'application/json'
280
+ },
281
+ payload: {}
282
+ }));
283
+ assertProcessFileResponse(response);
284
+ return response;
285
+ }
286
+ function assertProcessFileResponse(maybeProcessFileResponse) {
287
+ const requiredFields = ['message'];
288
+ if (hasRequiredFields(maybeProcessFileResponse, requiredFields)) return;
289
+ throw new Error('Invalid response');
290
+ }
291
+
292
+ const UnpublishProductsContext = /*#__PURE__*/React__default["default"].createContext({
293
+ state: initialState,
294
+ actions: initialActions,
295
+ onClose: () => {}
296
+ });
297
+ const UnpublishProductsProvider = props => {
298
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
299
+ projectKey: context.project?.key
300
+ })),
301
+ projectKey = _useApplicationContex.projectKey;
302
+ const asyncDispatch = sdk.useAsyncDispatch();
303
+ const _React$useReducer = React__default["default"].useReducer(reducer, initialState),
304
+ _React$useReducer2 = _slicedToArray(_React$useReducer, 2),
305
+ state = _React$useReducer2[0],
306
+ dispatch = _React$useReducer2[1];
307
+ const setCurrentStep = currentStep => dispatch({
308
+ type: 'setCurrentStep',
309
+ currentStep
310
+ });
311
+ const setContainerKey = containerKey => dispatch({
312
+ type: 'setContainerKey',
313
+ containerKey
314
+ });
315
+ const cancelImport = () => dispatch({
316
+ type: 'cancelImport'
317
+ });
318
+ const uploadNewFile = () => dispatch({
319
+ type: 'uploadNewFile'
320
+ });
321
+ const setDroppedFile = droppedFile => dispatch({
322
+ type: 'setDroppedFile',
323
+ droppedFile: droppedFile
324
+ });
325
+ const setFileUploadErrors = fileUploadErrors => {
326
+ dispatch({
327
+ type: 'setFileUploadErrors',
328
+ fileUploadErrors
329
+ });
330
+ };
331
+ const setAbortController = abortController => dispatch({
332
+ type: 'setAbortController',
333
+ abortController: abortController
334
+ });
335
+ const setProgress = progress => dispatch({
336
+ type: 'setProgress',
337
+ progress
338
+ });
339
+ const setUploadFileResponse = uploadFileResponse => {
340
+ dispatch({
341
+ type: 'setUploadFileResponse',
342
+ uploadFileResponse
343
+ });
344
+ };
345
+ const handleClose = function () {
346
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
347
+ if (state.abortController) state.abortController.abort();
348
+ if (typeof props.onClose === 'function') props.onClose();
349
+ // Removes the associated import container when the import is closed
350
+ if (options.shouldDeleteImportContainer && projectKey && state.containerKey) deleteImportContainer(projectKey, state.containerKey, asyncDispatch);
351
+ };
352
+ return jsxRuntime.jsx(UnpublishProductsContext.Provider, {
353
+ value: {
354
+ state,
355
+ onClose: handleClose,
356
+ actions: {
357
+ setCurrentStep,
358
+ cancelImport,
359
+ uploadNewFile,
360
+ setDroppedFile,
361
+ setUploadFileResponse,
362
+ setFileUploadErrors,
363
+ setContainerKey,
364
+ setAbortController,
365
+ setProgress
366
+ }
367
+ },
368
+ children: props.children
369
+ });
370
+ };
371
+
372
+ const getBorderColor = state => {
373
+ const borderColors = {
374
+ default: '#909dbc',
375
+ error: '#e60050',
376
+ active: uiKit.customProperties.colorPrimary
377
+ };
378
+ return borderColors[state] || borderColors.default;
379
+ };
380
+ const getDashedBorder = function () {
381
+ let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
382
+ const color = getBorderColor(state);
383
+ const svgContent = `
384
+ <svg width="100%" height="100%" xmlns="http://www.w3.org/2000/svg">
385
+ <rect width="100%" height="100%" fill="none" stroke="${color}" stroke-width="2px" stroke-dasharray="6,6" stroke-dashoffset="0" stroke-linecap="square"/>
386
+ </svg>
387
+ `;
388
+ return `data:image/svg+xml,${encodeURIComponent(svgContent)}`;
389
+ };
390
+ const base = /*#__PURE__*/react.css("border-radius:", uiKit.customProperties.borderRadius6, ";min-height:136px;display:flex;justify-content:center;align-items:center;" + ("" ), "" );
391
+ const readyForDrop = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";" + ("" ), "" );
392
+ const activeDrag = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder('active'), "\");background-color:", uiKit.customProperties.colorPrimary95, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
393
+ const fileDropped = /*#__PURE__*/react.css("background-image:url(\"", getDashedBorder(), "\");background-color:", uiKit.customProperties.colorSurface, ";padding:", uiKit.customProperties.spacing50, " 100px;" + ("" ), "" );
394
+ const styles = {
395
+ base,
396
+ readyForDrop,
397
+ fileDropped,
398
+ activeDrag
399
+ };
400
+
401
+ const DropWrapper = /*#__PURE__*/_styled__default["default"]("div", {
402
+ target: "e19vac9v0"
403
+ } )(styles.base, " ", props => {
404
+ if (props.dropAreaState === 'ready-for-drop') {
405
+ return styles.readyForDrop;
406
+ }
407
+ if (props.dropAreaState === 'active-drag') {
408
+ return styles.activeDrag;
409
+ }
410
+ if (props.dropAreaState === 'file-dropped') {
411
+ return styles.fileDropped;
412
+ }
413
+ return getDefaultDropWrapperStyles(props.dropAreaState);
414
+ }, ";" + ("" ));
415
+ function getDefaultDropWrapperStyles(_dropAreaState) {
416
+ return /*#__PURE__*/react.css("" , "" );
417
+ }
418
+
419
+ var ActiveDragDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./active-drag-drop-area-c4d16e89.cjs.prod.js' /* webpackChunkName: "active-drag-drop-area" */); }));
420
+
421
+ var EnabledDropArea = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./enabled-drop-area-9e04a444.cjs.prod.js' /* webpackChunkName: "enabled-drop-area" */); }));
422
+
423
+ var FileDropped = /*#__PURE__*/React.lazy(() => Promise.resolve().then(function () { return require('./file-dropped-area-411688d1.cjs.prod.js' /* webpackChunkName: "filed-dropped-area" */); }));
424
+
425
+ function getDropArea(_ref) {
426
+ let dropAreaState = _ref.dropAreaState,
427
+ isFileDropped = _ref.isFileDropped;
428
+ if (dropAreaState === 'ready-for-drop') {
429
+ return jsxRuntime.jsx(EnabledDropArea, {});
430
+ }
431
+ if (dropAreaState === 'file-dropped') {
432
+ return jsxRuntime.jsx(FileDropped, {});
433
+ }
434
+ if (dropAreaState === 'active-drag') {
435
+ return jsxRuntime.jsx(ActiveDragDropArea, {
436
+ isFileDropped: isFileDropped
437
+ });
438
+ }
439
+ return fallbackDropArea();
440
+ }
441
+ function fallbackDropArea(_invalidDropAreaState) {
442
+ return jsxRuntime.jsx(FileDropped, {});
443
+ }
444
+ function getDropAreaState(flags) {
445
+ if (flags.isDragActive) {
446
+ return 'active-drag';
447
+ }
448
+ if (flags.isReady) {
449
+ return 'file-dropped';
450
+ }
451
+ return 'ready-for-drop';
452
+ }
453
+
454
+ var messages$4 = reactIntl.defineMessages({
455
+ dragAndDropCSV: {
456
+ id: 'UnpublishProductsModal.dragAndDropCSV',
457
+ description: 'The message telling the user to drag and drop CSV file in the file drop area',
458
+ defaultMessage: 'Drag and drop CSV'
459
+ },
460
+ or: {
461
+ id: 'UnpublishProductsModal.or',
462
+ description: 'The word "or" in the drag and drop message',
463
+ defaultMessage: 'or'
464
+ },
465
+ browseButton: {
466
+ id: 'UnpublishProductsModal.browseFile',
467
+ defaultMessage: 'Browse file'
468
+ },
469
+ uploadAndPreview: {
470
+ id: 'UnpublishProductsModal.uploadAndPreview',
471
+ description: 'Label for the button that uploads the file and shows the preview',
472
+ defaultMessage: 'Upload and preview'
473
+ },
474
+ chooseFile: {
475
+ id: 'UnpublishProductsModal.chooseFile',
476
+ description: 'Label for a button on the file upload page, shown on ready to upload state',
477
+ defaultMessage: 'Choose file'
478
+ },
479
+ fileUploadFailed: {
480
+ id: 'UnpublishProductsModal.fileUploadFailed',
481
+ description: 'A title on the file upload page, shown on file upload error state',
482
+ defaultMessage: 'File upload failed'
483
+ },
484
+ fileFormatNotSupported: {
485
+ id: 'UnpublishProductsModal.fileFormatNotSupported',
486
+ description: 'Error message displayed when a user drags and drops a non-CSV file',
487
+ defaultMessage: 'Invalid file format: The file is not in CSV format and cannot be processed.'
488
+ },
489
+ tooManyFilesError: {
490
+ id: 'UnpublishProductsModal.tooManyFilesError',
491
+ description: 'Error message displayed when a user drags and drops multiple files at once',
492
+ defaultMessage: 'Multiple files detected: You can only drag and drop one file at a time.'
493
+ },
494
+ genericError: {
495
+ id: 'UnpublishProductsModal.genericError',
496
+ description: 'Default error message for unexpected file upload issues (for unhandled cases)',
497
+ defaultMessage: 'Error occurred: Please try uploading the file again or contact our support team for assistance.'
498
+ },
499
+ dataType: {
500
+ id: 'UnpublishProductsModal.dataType',
501
+ description: 'Label for the data type selection dropdown',
502
+ defaultMessage: 'Data type'
503
+ },
504
+ instructions: {
505
+ id: 'UnpublishProductsModal.instructions',
506
+ description: 'Label for the instructions section',
507
+ defaultMessage: 'Instructions'
508
+ }
509
+ });
510
+
511
+ function _callSuper$1(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct$1() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
512
+ function _isNativeReflectConstruct$1() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct$1 = function () { return !!t; })(); }
513
+ let HttpError = /*#__PURE__*/function (_Error) {
514
+ function HttpError(statusCode, statusText, errorData) {
515
+ var _this;
516
+ _classCallCheck(this, HttpError);
517
+ _this = _callSuper$1(this, HttpError, [`HTTP Error! Status code: ${statusCode}, message: "${statusText ? statusText : ''}"`]);
518
+ _this.statusCode = void 0;
519
+ _this.errorData = void 0;
520
+ _this.name = 'HttpError';
521
+ _this.statusCode = statusCode;
522
+ _this.errorData = errorData;
523
+ return _this;
524
+ }
525
+ _inherits(HttpError, _Error);
526
+ return _createClass(HttpError);
527
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
528
+
529
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? _Reflect$construct__default["default"](o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
530
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(_Reflect$construct__default["default"](Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
531
+ let MissingUnpublishProductsProviderError = /*#__PURE__*/function (_Error) {
532
+ function MissingUnpublishProductsProviderError() {
533
+ var _this;
534
+ _classCallCheck(this, MissingUnpublishProductsProviderError);
535
+ _this = _callSuper(this, MissingUnpublishProductsProviderError, ['useUnpublishProductsProviderError must be used within MissingUnpublishProductsProviderError']);
536
+ _this.name = 'MissingUnpublishProductsProviderError';
537
+ return _this;
538
+ }
539
+ _inherits(MissingUnpublishProductsProviderError, _Error);
540
+ return _createClass(MissingUnpublishProductsProviderError);
541
+ }(/*#__PURE__*/_wrapNativeSuper(Error));
542
+
543
+ const useUnpublishProductsContext = () => {
544
+ const context = React.useContext(UnpublishProductsContext);
545
+ if (!context) {
546
+ throw new MissingUnpublishProductsProviderError();
547
+ }
548
+ return context;
549
+ };
550
+
551
+ var messages$3 = reactIntl.defineMessages({
552
+ fileSizeExceededTitle: {
553
+ id: 'UnpublishProductsModal.sizeExceededTitle',
554
+ defaultMessage: 'File size exceeded'
555
+ },
556
+ fileSizeExceededDescription: {
557
+ id: 'UnpublishProductsModal.sizeExceededDescription',
558
+ description: 'Error description when the file size exceeds the allowable limit',
559
+ defaultMessage: 'The file exceeds the maximum allowed size of {fileSizeLimit} MB'
560
+ },
561
+ rowLimitExceededTitle: {
562
+ id: 'UnpublishProductsModal.rowLimitExceededTitle',
563
+ defaultMessage: 'Row limit exceeded'
564
+ },
565
+ rowLimitExceededDescription: {
566
+ id: 'UnpublishProductsModal.rowLimitExceededDescription',
567
+ description: 'Error description when the file contains more rows than the allowable maximum',
568
+ defaultMessage: 'The file contains more than the allowable maximum of {rowLimit} rows'
569
+ },
570
+ dropAreaNotEnoughRowsTitle: {
571
+ id: 'UnpublishProductsModal.dropAreaNotEnoughRowsTitle',
572
+ description: 'Error title shown when the uploaded CSV file does not contain a header and at least one row of data',
573
+ defaultMessage: 'Invalid CSV file'
574
+ },
575
+ dropAreaNotEnoughRowsDescription: {
576
+ id: 'UnpublishProductsModal.dropAreaNotEnoughRowsDescription',
577
+ description: 'Error description shown when the uploaded CSV file does not contain a header and at least one row of data',
578
+ defaultMessage: 'Make sure the file contains a header and at least one row of data'
579
+ },
580
+ unexpectedError: {
581
+ id: 'UnpublishProductsModal.unexpectedError',
582
+ description: 'Generic notification message when file upload fails',
583
+ defaultMessage: 'An unexpected error occurred during the file upload. Please try again, or contact support if this error occurs again.'
584
+ },
585
+ missingRequiredField: {
586
+ id: 'UnpublishProductsModal.missingRequiredField',
587
+ description: 'Error message displayed when a required field is missing',
588
+ defaultMessage: 'Missing required field'
589
+ },
590
+ missingKeyError: {
591
+ id: 'UnpublishProductsModal.missingKeyError',
592
+ description: 'Error message displayed when the uploaded file is missing the key field',
593
+ defaultMessage: "The 'key' field is missing or incomplete in some rows. Please ensure every row has a 'key' value."
594
+ },
595
+ csvFormatErrorTitle: {
596
+ id: 'UnpublishProductsModal.csvFormatErrorTitle',
597
+ description: 'Error title shown when the uploaded CSV file is not formatted correctly',
598
+ defaultMessage: 'Invalid CSV file'
599
+ },
600
+ csvFormatErrorDescription: {
601
+ id: 'FileUpload.csvFormatErrorDescription',
602
+ description: 'Error message displayed when the CSV file is not formatted correctly',
603
+ defaultMessage: "Your CSV file is not formatted correctly. Make sure the file contains only one column named 'key', which includes the product keys"
604
+ }
605
+ });
606
+
607
+ const IMPORT_TAG_KEYS = {
608
+ source: 'source'
609
+ };
610
+ const IMPORT_TAG_VALUES = {
611
+ fileUpload: 'file-upload'
612
+ };
613
+ const TAG_KEY_SOURCE_FILE_UPLOAD = `${IMPORT_TAG_KEYS.source}:${IMPORT_TAG_VALUES.fileUpload}`;
614
+ const FILE_SIZE_LIMIT_MB = 35;
615
+ const ROW_COUNT_LIMIT = 80_000;
616
+
617
+ // TODO: replace with actual links
618
+ const DOCUMENTATION_LINK = '';
619
+
620
+ // TODO: replace with actual links
621
+ const TEMPLATE_DOWNLOAD_LINK = '';
622
+
623
+ function ownKeys$8(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
624
+ function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$8(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$8(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
625
+ const addProxyPrefixToUrl = (uri, proxy) => {
626
+ return proxy ? `/proxy/${proxy}${uri}` : uri;
627
+ };
628
+ const fetchUsingXhr = _ref2 => {
629
+ let url = _ref2.url,
630
+ payload = _ref2.payload,
631
+ config = _ref2.config,
632
+ onProgress = _ref2.onProgress,
633
+ onSuccess = _ref2.onSuccess,
634
+ onError = _ref2.onError;
635
+ const options = applicationShell.createHttpClientOptions({
636
+ headers: _objectSpread$8({
637
+ 'Content-Type': 'application/json'
638
+ }, config?.headers)
639
+ });
640
+ const xhr = new XMLHttpRequest();
641
+ xhr.open(config?.method, applicationShell.buildApiUrl(addProxyPrefixToUrl(url, config?.proxy)), true);
642
+ // Include cookies in the request
643
+ xhr.withCredentials = true;
644
+ if (options.headers) {
645
+ var _context;
646
+ _forEachInstanceProperty__default["default"](_context = _Object$keys__default["default"](options.headers)).call(_context, key => {
647
+ xhr.setRequestHeader(key, options.headers[key]);
648
+ });
649
+ }
650
+ xhr.upload.onprogress = function (event) {
651
+ if (event.lengthComputable) {
652
+ const percentComplete = event.loaded / event.total * 100;
653
+ onProgress(percentComplete);
654
+ }
655
+ };
656
+ xhr.onload = function () {
657
+ const data = JSON.parse(xhr.responseText);
658
+ // Code copied from `executeHttpClientRequest` to replicate the same behavior
659
+ const refreshedSessionToken = xhr.getResponseHeader('x-refreshed-session-token');
660
+ if (refreshedSessionToken) {
661
+ applicationShellConnectors.oidcStorage.setActiveSession(refreshedSessionToken);
662
+ }
663
+ if (xhr.status >= 200 && xhr.status < 300) {
664
+ onSuccess(data);
665
+ } else {
666
+ onError(new HttpError(xhr.status, xhr.statusText, data));
667
+ }
668
+ };
669
+ xhr.onerror = function () {
670
+ const errorData = JSON.parse(xhr.responseText);
671
+ onError(new HttpError(xhr.status, xhr.statusText, errorData));
672
+ };
673
+ xhr.onabort = function () {
674
+ onError(new DOMException('Aborted', 'AbortError'));
675
+ };
676
+ xhr.send(payload);
677
+ return xhr;
678
+ };
679
+
680
+ function uploadFileForImport(_ref) {
681
+ let projectKey = _ref.projectKey,
682
+ containerKey = _ref.containerKey,
683
+ file = _ref.file,
684
+ abortSignal = _ref.abortSignal,
685
+ onSuccess = _ref.onSuccess,
686
+ onProgress = _ref.onProgress,
687
+ onError = _ref.onError;
688
+ const uri = getFileUploadURL(projectKey, containerKey);
689
+ const formData = new FormData();
690
+ formData.append('file', file, file.name);
691
+ return fetchUsingXhr({
692
+ url: uri,
693
+ payload: formData,
694
+ config: {
695
+ abortSignal,
696
+ proxy: constants.MC_API_PROXY_TARGETS.IMPORT,
697
+ method: 'POST',
698
+ headers: {
699
+ 'Content-Type': null
700
+ }
701
+ },
702
+ onProgress,
703
+ onSuccess,
704
+ onError
705
+ });
706
+ }
707
+
708
+ const useUpload = () => {
709
+ const intl = reactIntl.useIntl();
710
+ const projectKey = applicationShellConnectors.useApplicationContext(context => context.project?.key);
711
+ const _useUnpublishProducts = useUnpublishProductsContext(),
712
+ state = _useUnpublishProducts.state,
713
+ actions = _useUnpublishProducts.actions;
714
+ const asyncDispatch = sdk.useAsyncDispatch();
715
+ const showNotification = actionsGlobal.useShowNotification();
716
+ React__default["default"].useEffect(() => {
717
+ return () => {
718
+ if (state.abortController) state.abortController.abort();
719
+ };
720
+ }, [state.abortController]);
721
+ const isFileValid = async file => {
722
+ const errors = [];
723
+ const rowCount = await getRowCount(file);
724
+ if (rowCount < 1) errors.push({
725
+ title: intl.formatMessage(messages$3.dropAreaNotEnoughRowsTitle),
726
+ description: intl.formatMessage(messages$3.dropAreaNotEnoughRowsDescription)
727
+ });
728
+ if (file.size > toBytes(FILE_SIZE_LIMIT_MB)) errors.push({
729
+ title: intl.formatMessage(messages$3.fileSizeExceededTitle),
730
+ description: intl.formatMessage(messages$3.fileSizeExceededDescription, {
731
+ fileSizeLimit: intl.formatNumber(FILE_SIZE_LIMIT_MB)
732
+ })
733
+ });
734
+ if (!(await hasSingleKeyColumn(file))) {
735
+ errors.push({
736
+ title: intl.formatMessage(messages$3.csvFormatErrorTitle),
737
+ description: intl.formatMessage(messages$3.csvFormatErrorDescription)
738
+ });
739
+ }
740
+ if (rowCount > ROW_COUNT_LIMIT) errors.push({
741
+ title: intl.formatMessage(messages$3.rowLimitExceededTitle),
742
+ description: intl.formatMessage(messages$3.rowLimitExceededDescription, {
743
+ rowLimit: intl.formatNumber(ROW_COUNT_LIMIT)
744
+ })
745
+ });
746
+ if (errors.length > 0) {
747
+ actions.setFileUploadErrors(errors);
748
+ actions.setCurrentStep('upload-error');
749
+ return false;
750
+ }
751
+ return true;
752
+ };
753
+ const handleUploadError = error => {
754
+ if (isAbortError(error)) {
755
+ actions.cancelImport();
756
+ return;
757
+ }
758
+ if (error instanceof HttpError) {
759
+ if (error.errorData?.code === 'MISSING_KEY_ERROR') {
760
+ actions.setFileUploadErrors([{
761
+ title: intl.formatMessage(messages$3.missingRequiredField),
762
+ description: intl.formatMessage(messages$3.missingKeyError)
763
+ }]);
764
+ actions.setCurrentStep('upload-error');
765
+ } else {
766
+ actions.cancelImport();
767
+ showNotification({
768
+ kind: 'error',
769
+ domain: constants.DOMAINS.PAGE,
770
+ text: intl.formatMessage(messages$3.unexpectedError)
771
+ });
772
+ }
773
+ } else {
774
+ actions.cancelImport();
775
+ showNotification({
776
+ kind: 'error',
777
+ domain: constants.DOMAINS.PAGE,
778
+ text: String(error)
779
+ });
780
+ sentry.reportErrorToSentry(new Error('Upload File Error: An unexpected issue occurred while uploading the file'), {
781
+ extra: {
782
+ error,
783
+ projectKey,
784
+ containerKey: state.containerKey,
785
+ fileSizeInBytes: state.droppedFile?.size
786
+ }
787
+ });
788
+ }
789
+ };
790
+ const handleUploadAndValidation = async () => {
791
+ if (!projectKey || !state.droppedFile) return;
792
+ const canUpload = await isFileValid(state.droppedFile);
793
+ if (!canUpload) return;
794
+ actions.setCurrentStep('uploading');
795
+ const containerKey = encodeFileNameWithTimestampToContainerKey(state.droppedFile.name);
796
+ actions.setContainerKey(containerKey);
797
+ try {
798
+ await createImportContainerForFileUpload({
799
+ key: containerKey,
800
+ tags: [TAG_KEY_SOURCE_FILE_UPLOAD],
801
+ resourceType: 'product',
802
+ settings: {
803
+ resourceType: 'product-draft',
804
+ format: 'CSV',
805
+ options: {
806
+ unpublishAllChanges: true
807
+ }
808
+ }
809
+ }, projectKey, asyncDispatch);
810
+ const newAbortController = uploadFileForImport({
811
+ projectKey,
812
+ containerKey,
813
+ file: state.droppedFile,
814
+ onSuccess: fileUploadResponse => {
815
+ actions.setUploadFileResponse(fileUploadResponse);
816
+ actions.setCurrentStep('upload-preview');
817
+ },
818
+ onProgress: progress => {
819
+ actions.setProgress(progress);
820
+ },
821
+ onError: error => {
822
+ deleteImportContainer(projectKey, containerKey, asyncDispatch);
823
+ handleUploadError(error);
824
+ }
825
+ });
826
+ actions.setAbortController(newAbortController);
827
+ } catch (error) {
828
+ deleteImportContainer(projectKey, containerKey, asyncDispatch);
829
+ handleUploadError(error);
830
+ }
831
+ };
832
+ return {
833
+ handleUploadAndValidation
834
+ };
835
+ };
836
+
837
+ function ownKeys$7(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
838
+ function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var _context3, _context4; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context3 = ownKeys$7(Object(t), !0)).call(_context3, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context4 = ownKeys$7(Object(t))).call(_context4, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
839
+ const FileDropArea = () => {
840
+ const intl = reactIntl.useIntl();
841
+ const _useUnpublishProducts = useUnpublishProductsContext(),
842
+ state = _useUnpublishProducts.state,
843
+ actions = _useUnpublishProducts.actions;
844
+ const showNotification = actionsGlobal.useShowNotification();
845
+ const onDrop = React__default["default"].useCallback(_ref => {
846
+ let _ref2 = _slicedToArray(_ref, 1),
847
+ file = _ref2[0];
848
+ if (!file) return;
849
+ actions.setDroppedFile(file);
850
+ }, [actions]);
851
+ const _useDropzone = reactDropzone.useDropzone({
852
+ onDrop,
853
+ multiple: false,
854
+ accept: {
855
+ 'text/csv': ['.csv']
856
+ },
857
+ onDropRejected: _ref3 => {
858
+ var _context, _context2;
859
+ let _ref4 = _slicedToArray(_ref3, 1),
860
+ rejectedFile = _ref4[0];
861
+ if (_someInstanceProperty__default["default"](_context = rejectedFile.errors).call(_context, error => error.code === 'too-many-files')) {
862
+ showNotification({
863
+ kind: 'error',
864
+ domain: constants.DOMAINS.PAGE,
865
+ text: intl.formatMessage(messages$4.tooManyFilesError)
866
+ });
867
+ return;
868
+ }
869
+ if (_someInstanceProperty__default["default"](_context2 = rejectedFile.errors).call(_context2, error => error.code === 'file-invalid-type')) {
870
+ showNotification({
871
+ kind: 'error',
872
+ domain: constants.DOMAINS.PAGE,
873
+ text: intl.formatMessage(messages$4.fileFormatNotSupported)
874
+ });
875
+ } else {
876
+ showNotification({
877
+ kind: 'error',
878
+ domain: constants.DOMAINS.PAGE,
879
+ text: intl.formatMessage(messages$4.genericError)
880
+ });
881
+ }
882
+ }
883
+ }),
884
+ getRootProps = _useDropzone.getRootProps,
885
+ getInputProps = _useDropzone.getInputProps,
886
+ isDragActive = _useDropzone.isDragActive;
887
+ const dropAreaState = React__default["default"].useMemo(() => getDropAreaState({
888
+ isReady: Boolean(state.droppedFile),
889
+ isDragActive
890
+ }), [state.droppedFile, isDragActive]);
891
+ const dropArea = getDropArea({
892
+ dropAreaState,
893
+ isFileDropped: Boolean(state.droppedFile)
894
+ });
895
+ return jsxRuntime.jsxs(DropWrapper, _objectSpread$7(_objectSpread$7({
896
+ role: "presentation"
897
+ }, getRootProps()), {}, {
898
+ dropAreaState: dropAreaState,
899
+ children: [jsxRuntime.jsx("input", _objectSpread$7({
900
+ "data-testid": "file-input"
901
+ }, getInputProps())), jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
902
+ children: dropArea
903
+ })]
904
+ }));
905
+ };
906
+
907
+ var sharedMessages = reactIntl.defineMessages({
908
+ unpublishModalTitle: {
909
+ id: 'UnpublishProductsModal.unpublishModalTitle',
910
+ description: 'The title of the modal',
911
+ defaultMessage: 'Bulk unpublish via CSV'
912
+ },
913
+ startBulkUnpublish: {
914
+ id: 'UnpublishProductsModal.startBulkUnpublish',
915
+ description: 'Start bulk unpublish button',
916
+ defaultMessage: 'Start bulk unpublish'
917
+ },
918
+ cancel: {
919
+ id: 'UnpublishProductsModal.cancel',
920
+ description: 'The label for the cancel button',
921
+ defaultMessage: 'Cancel'
922
+ }
923
+ });
924
+
925
+ var messages$2 = reactIntl.defineMessages({
926
+ fileUploadInstructions: {
927
+ id: 'UnpublishProductsModal.fileUploadInstructions',
928
+ description: 'Instructions for uploading a CSV file with product keys to unpublish',
929
+ defaultMessage: "The CSV file must contain the product keys to be unpublished under the header 'key'. Maximum file size is {maxFileSize} MB with a limit of {maxRowCount} rows. Download <csvTemplateLink>the CSV template</csvTemplateLink> or refer to <documentationLink>the documentation</documentationLink>."
930
+ }
931
+ });
932
+
933
+ function ownKeys$6(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
934
+ function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$6(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$6(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
935
+ const Instructions = () => {
936
+ const intl = reactIntl.useIntl();
937
+ return jsxRuntime.jsx(uiKit.Text.Body, {
938
+ intlMessage: _objectSpread$6(_objectSpread$6({}, messages$2.fileUploadInstructions), {}, {
939
+ values: {
940
+ maxFileSize: intl.formatNumber(FILE_SIZE_LIMIT_MB),
941
+ maxRowCount: intl.formatNumber(ROW_COUNT_LIMIT),
942
+ csvTemplateLink: msg => jsxRuntime.jsx(uiKit.Link, {
943
+ tone: "secondary",
944
+ isExternal: true,
945
+ to: TEMPLATE_DOWNLOAD_LINK,
946
+ children: msg
947
+ }),
948
+ documentationLink: msg => jsxRuntime.jsx(uiKit.Link, {
949
+ tone: "secondary",
950
+ isExternal: true,
951
+ to: DOCUMENTATION_LINK,
952
+ children: msg
953
+ })
954
+ }
955
+ })
956
+ });
957
+ };
958
+
959
+ const Upload = () => {
960
+ const _useUnpublishProducts = useUnpublishProductsContext(),
961
+ state = _useUnpublishProducts.state,
962
+ onClose = _useUnpublishProducts.onClose;
963
+ const intl = reactIntl.useIntl();
964
+ const _useUpload = useUpload(),
965
+ handleUploadAndValidation = _useUpload.handleUploadAndValidation;
966
+ return jsxRuntime.jsx(applicationComponents.FormDialog, {
967
+ size: 16,
968
+ isOpen: true,
969
+ title: intl.formatMessage(sharedMessages.unpublishModalTitle),
970
+ labelPrimary: intl.formatMessage(messages$4.uploadAndPreview),
971
+ onPrimaryButtonClick: handleUploadAndValidation,
972
+ isPrimaryButtonDisabled: !Boolean(state.droppedFile),
973
+ onSecondaryButtonClick: () => onClose({
974
+ shouldDeleteImportContainer: true
975
+ }),
976
+ onClose: () => onClose({
977
+ shouldDeleteImportContainer: true
978
+ }),
979
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
980
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
981
+ scale: "m",
982
+ children: [jsxRuntime.jsx(Instructions, {}), jsxRuntime.jsx(FileDropArea, {})]
983
+ })
984
+ })
985
+ });
986
+ };
987
+
988
+ function ownKeys$5(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
989
+ function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$5(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$5(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
990
+ var FileIcon = function FileIcon(props) {
991
+ return jsxRuntime.jsxs("svg", _objectSpread$5(_objectSpread$5({}, props), {}, {
992
+ children: [jsxRuntime.jsx("mask", {
993
+ id: "a",
994
+ style: {
995
+ maskType: "alpha"
996
+ },
997
+ maskUnits: "userSpaceOnUse",
998
+ x: "0",
999
+ y: "0",
1000
+ width: "32",
1001
+ height: "32",
1002
+ children: jsxRuntime.jsx("path", {
1003
+ fill: "#D9D9D9",
1004
+ d: "M0 0h32v32H0z"
1005
+ })
1006
+ }), jsxRuntime.jsx("g", {
1007
+ mask: "url(#a)",
1008
+ children: jsxRuntime.jsx("path", {
1009
+ d: "M14.667 25.333h2.666v-5.566l2.134 2.133 1.866-1.9L16 14.667 10.667 20l1.9 1.867 2.1-2.1v5.566Zm-6.667 4a2.568 2.568 0 0 1-1.883-.783 2.568 2.568 0 0 1-.784-1.883V5.333c0-.733.261-1.36.784-1.883A2.568 2.568 0 0 1 8 2.667h10.667l8 8v16c0 .733-.261 1.36-.784 1.883a2.568 2.568 0 0 1-1.883.783H8ZM17.333 12H24l-6.667-6.667V12Z",
1010
+ fill: "#B1ACFF"
1011
+ })
1012
+ })]
1013
+ }));
1014
+ };
1015
+ FileIcon.defaultProps = {
1016
+ width: "32",
1017
+ height: "32",
1018
+ fill: "none",
1019
+ xmlns: "http://www.w3.org/2000/svg"
1020
+ };
1021
+ const Uploading = () => {
1022
+ const intl = reactIntl.useIntl();
1023
+ const _useUnpublishProducts = useUnpublishProductsContext(),
1024
+ state = _useUnpublishProducts.state,
1025
+ actions = _useUnpublishProducts.actions,
1026
+ onClose = _useUnpublishProducts.onClose;
1027
+ if (state.droppedFile?.name) return jsxRuntime.jsx(applicationComponents.InfoDialog, {
1028
+ size: 16,
1029
+ isOpen: true,
1030
+ title: intl.formatMessage(sharedMessages.unpublishModalTitle),
1031
+ onClose: () => onClose({
1032
+ shouldDeleteImportContainer: true
1033
+ }),
1034
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1035
+ scale: "m",
1036
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1037
+ alignItems: "center",
1038
+ justifyContent: "space-between",
1039
+ children: [jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1040
+ alignItems: "center",
1041
+ children: [jsxRuntime.jsx(FileIcon, {}), jsxRuntime.jsx(uiKit.Spacings.Inline, {
1042
+ children: jsxRuntime.jsx(uiKit.Constraints.Horizontal, {
1043
+ max: 10,
1044
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1045
+ truncate: true,
1046
+ fontWeight: "bold",
1047
+ children: state.droppedFile.name
1048
+ })
1049
+ })
1050
+ }), jsxRuntime.jsxs(uiKit.Text.Body, {
1051
+ tone: "secondary",
1052
+ children: ["(", intl.formatNumber(convertFileSizeToKB(state.droppedFile.size)), ' ', "KB)"]
1053
+ })]
1054
+ }), jsxRuntime.jsx(uiKit.SecondaryButton, {
1055
+ tone: "secondary",
1056
+ size: "medium",
1057
+ label: intl.formatMessage(sharedMessages.cancel),
1058
+ onClick: () => {
1059
+ actions.setCurrentStep('upload');
1060
+ state.abortController.abort();
1061
+ }
1062
+ })]
1063
+ }), jsxRuntime.jsx(uiKit.ProgressBar, {
1064
+ barWidth: "scale",
1065
+ height: "10",
1066
+ progress: state.progress
1067
+ }), jsxRuntime.jsx("div", {})]
1068
+ })
1069
+ });
1070
+ return null;
1071
+ };
1072
+
1073
+ var messages$1 = reactIntl.defineMessages({
1074
+ uploadNewFile: {
1075
+ id: 'UnpublishProductsModal.uploadNewFile',
1076
+ defaultMessage: 'Upload new file'
1077
+ },
1078
+ uploadErrorDescription: {
1079
+ id: 'UnpublishProductsModal.uploadError',
1080
+ description: 'Title when errors detected while uploading file',
1081
+ defaultMessage: 'There {errorsCount, plural, one {is <b>1</b> error} other {are <b>{errorsCount}</b> errors}} detected while uploading the file "{fileName}".'
1082
+ },
1083
+ errorType: {
1084
+ id: 'UnpublishProductsModal.errorType',
1085
+ description: 'Error type" column',
1086
+ defaultMessage: 'Error type'
1087
+ },
1088
+ details: {
1089
+ id: 'UnpublishProductsModal.details',
1090
+ description: '"Details" column',
1091
+ defaultMessage: 'Details'
1092
+ }
1093
+ });
1094
+
1095
+ function ownKeys$4(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1096
+ function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var _context2, _context3; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context2 = ownKeys$4(Object(t), !0)).call(_context2, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context3 = ownKeys$4(Object(t))).call(_context3, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1097
+ const getColumns = () => [{
1098
+ key: 'errorType',
1099
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$1.errorType)),
1100
+ width: 'max-content'
1101
+ }, {
1102
+ key: 'details',
1103
+ label: jsxRuntime.jsx(reactIntl.FormattedMessage, _objectSpread$4({}, messages$1.details))
1104
+ }];
1105
+ const UploadErrorTable = props => {
1106
+ var _context;
1107
+ const pagination = uiKit.usePaginationState({
1108
+ perPage: 10
1109
+ });
1110
+ const startIndex = (pagination.page.value - 1) * pagination.perPage.value;
1111
+ const endIndex = startIndex + pagination.perPage.value;
1112
+ const currentPageRows = _sliceInstanceProperty__default["default"](_context = props.rows).call(_context, startIndex, endIndex);
1113
+ const shouldShowPagination = props.rows.length > pagination.perPage.value;
1114
+ return jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1115
+ scale: "l",
1116
+ children: [jsxRuntime.jsx(DataTable__default["default"], {
1117
+ verticalCellAlignment: "center",
1118
+ isCondensed: true,
1119
+ rows: currentPageRows,
1120
+ columns: getColumns(),
1121
+ itemRenderer: itemRenderer
1122
+ }), shouldShowPagination && jsxRuntime.jsx(uiKit.PageNavigator, {
1123
+ onPageChange: pagination.page.onChange,
1124
+ page: pagination.page.value,
1125
+ totalPages: Math.ceil(props.rows.length / pagination.perPage.value)
1126
+ })]
1127
+ });
1128
+ };
1129
+ function itemRenderer(item, column) {
1130
+ switch (column.key) {
1131
+ case 'errorType':
1132
+ return jsxRuntime.jsx(uiKit.Stamp, {
1133
+ isCondensed: true,
1134
+ label: item.title,
1135
+ tone: "critical"
1136
+ });
1137
+ case 'details':
1138
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1139
+ children: item.description
1140
+ });
1141
+ default:
1142
+ return null;
1143
+ }
1144
+ }
1145
+
1146
+ function ownKeys$3(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1147
+ function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$3(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$3(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1148
+ const UploadErrorsModal = () => {
1149
+ const intl = reactIntl.useIntl();
1150
+ const _useUnpublishProducts = useUnpublishProductsContext(),
1151
+ state = _useUnpublishProducts.state,
1152
+ actions = _useUnpublishProducts.actions,
1153
+ onClose = _useUnpublishProducts.onClose;
1154
+ const errorsCount = state.fileUploadErrors.length;
1155
+ return jsxRuntime.jsx(applicationComponents.InfoDialog, {
1156
+ size: 16,
1157
+ isOpen: true,
1158
+ title: intl.formatMessage(sharedMessages.unpublishModalTitle),
1159
+ onClose: () => onClose(),
1160
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1161
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1162
+ scale: "l",
1163
+ children: [jsxRuntime.jsx(fullstory.Masking.Mask, {
1164
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1165
+ intlMessage: _objectSpread$3(_objectSpread$3({}, messages$1.uploadErrorDescription), {}, {
1166
+ values: {
1167
+ fileName: state.droppedFile?.name,
1168
+ errorsCount: intl.formatNumber(errorsCount),
1169
+ b: getBold$2
1170
+ }
1171
+ })
1172
+ })
1173
+ }), jsxRuntime.jsx(UploadErrorTable, {
1174
+ rows: mapFileUploadErrorsToUploadFileErrorRows(state.fileUploadErrors)
1175
+ }), jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1176
+ scale: "m",
1177
+ justifyContent: "flex-end",
1178
+ children: [jsxRuntime.jsx(uiKit.SecondaryButton, {
1179
+ label: intl.formatMessage(sharedMessages.cancel),
1180
+ onClick: () => onClose()
1181
+ }), jsxRuntime.jsx(uiKit.PrimaryButton, {
1182
+ iconLeft: jsxRuntime.jsx(uiKit.ImportIcon, {}),
1183
+ label: intl.formatMessage(messages$1.uploadNewFile),
1184
+ onClick: () => actions.uploadNewFile()
1185
+ })]
1186
+ })]
1187
+ })
1188
+ })
1189
+ });
1190
+ };
1191
+ function getBold$2(msg) {
1192
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1193
+ as: "span",
1194
+ isBold: true,
1195
+ children: msg
1196
+ });
1197
+ }
1198
+
1199
+ var messages = reactIntl.defineMessages({
1200
+ continue: {
1201
+ id: 'UnpublishProductsModal.continue',
1202
+ description: 'Continue button',
1203
+ defaultMessage: 'Continue'
1204
+ },
1205
+ heresAPreview: {
1206
+ id: 'UnpublishProductsModal.heresAPreview',
1207
+ description: 'Here is a preview',
1208
+ defaultMessage: "Here's a preview:"
1209
+ },
1210
+ productsToBeUnpublished: {
1211
+ id: 'UnpublishProductsModal.productsToBeUnpublished',
1212
+ description: 'Products to be unpublished',
1213
+ defaultMessage: '{count, plural, one {<b>{count}</b> product to be unpublished} other {<b>{count}</b> products to be unpublished}}'
1214
+ },
1215
+ confirmationQuestion: {
1216
+ id: 'UnpublishProductsModal.confirmationQuestion',
1217
+ description: 'Confirmation question',
1218
+ defaultMessage: 'Are you sure you want to unpublish the products? '
1219
+ },
1220
+ confirmationText: {
1221
+ id: 'UnpublishProductsModal.confirmationText',
1222
+ description: 'Confirmation text',
1223
+ defaultMessage: '{count, plural, one {You are about to unpublish <b>{count}</b> product in the project: <b>{projectName}</b>.} other {You are about to unpublish <b>{count}</b> products in the project: <b>{projectName}</b>.}}'
1224
+ },
1225
+ importStarted: {
1226
+ id: 'UnpublishProductsModal.importStarted',
1227
+ description: 'Import started',
1228
+ defaultMessage: '<b>Your import for bulk unpublish has started.</b><newline></newline>Go to <logsLink>Import logs</logsLink> to view the progress.'
1229
+ },
1230
+ preparingImport: {
1231
+ id: 'UnpublishProductsModal.preparingImport',
1232
+ description: 'Preparing import',
1233
+ defaultMessage: '<b>Prepare bulk unpublish.</b><newline></newline>Once preparation is complete, you can track the progress <logsLink>in the Import logs</logsLink>. The data will be unpublished after the import is finalized.'
1234
+ }
1235
+ });
1236
+
1237
+ function ownKeys$2(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1238
+ function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$2(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$2(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1239
+ const getNewLine = () => jsxRuntime.jsx("br", {});
1240
+ const getImportLogsLink = (msg, projectKey) => jsxRuntime.jsx(uiKit.Link, {
1241
+ to: `/${projectKey}/operations/import/logs`,
1242
+ children: msg
1243
+ });
1244
+ var _ref2 = {
1245
+ name: "1vs9i7r",
1246
+ styles: "width:360px"
1247
+ } ;
1248
+ const ImportRunningTextNotification = props => jsxRuntime.jsx("div", {
1249
+ css: _ref2,
1250
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1251
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages.importStarted), {}, {
1252
+ values: {
1253
+ newline: getNewLine,
1254
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1255
+ b: getBold$1
1256
+ }
1257
+ })
1258
+ })
1259
+ });
1260
+ var _ref = {
1261
+ name: "1vs9i7r",
1262
+ styles: "width:360px"
1263
+ } ;
1264
+ const ImportPreparingTextNotification = props => jsxRuntime.jsx("div", {
1265
+ css: _ref,
1266
+ children: jsxRuntime.jsx(uiKit.Text.Body, {
1267
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages.preparingImport), {}, {
1268
+ values: {
1269
+ newline: getNewLine,
1270
+ logsLink: msg => getImportLogsLink(msg, props.projectKey),
1271
+ b: getBold$1
1272
+ }
1273
+ })
1274
+ })
1275
+ });
1276
+ const UnpublishProductsConfirmationModal = () => {
1277
+ const intl = reactIntl.useIntl();
1278
+ const _useUnpublishProducts = useUnpublishProductsContext(),
1279
+ state = _useUnpublishProducts.state,
1280
+ onClose = _useUnpublishProducts.onClose;
1281
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
1282
+ projectKey: context.project?.key,
1283
+ projectName: context.project?.name
1284
+ })),
1285
+ projectKey = _useApplicationContex.projectKey,
1286
+ projectName = _useApplicationContex.projectName;
1287
+ const asyncDispatch = sdk.useAsyncDispatch();
1288
+ const showNotification = actionsGlobal.useShowNotification();
1289
+ return jsxRuntime.jsx(applicationComponents.ConfirmationDialog, {
1290
+ title: intl.formatMessage(sharedMessages.unpublishModalTitle),
1291
+ labelPrimary: intl.formatMessage(sharedMessages.startBulkUnpublish),
1292
+ isOpen: true,
1293
+ onClose: () => onClose({
1294
+ shouldDeleteImportContainer: true
1295
+ }),
1296
+ onCancel: () => onClose({
1297
+ shouldDeleteImportContainer: true
1298
+ }),
1299
+ dataAttributesPrimaryButton: {
1300
+ 'data-test-id': 'confirmation-dialog-confirm'
1301
+ },
1302
+ dataAttributesSecondaryButton: {
1303
+ 'data-test-id': 'confirmation-dialog-cancel'
1304
+ },
1305
+ onConfirm: async () => {
1306
+ try {
1307
+ const canConfirm = projectKey && state.containerKey && state.droppedFile?.name;
1308
+ if (!canConfirm) return;
1309
+ onClose();
1310
+ showNotification({
1311
+ kind: 'info',
1312
+ domain: constants.DOMAINS.SIDE,
1313
+ // @ts-ignore
1314
+ text: jsxRuntime.jsx(ImportPreparingTextNotification, {
1315
+ projectKey: projectKey
1316
+ })
1317
+ }, {
1318
+ dismissAfter: 5000
1319
+ });
1320
+ await processUploadedFile({
1321
+ projectKey,
1322
+ containerKey: state.containerKey,
1323
+ asyncDispatch
1324
+ });
1325
+ showNotification({
1326
+ kind: 'info',
1327
+ domain: constants.DOMAINS.SIDE,
1328
+ // @ts-ignore
1329
+ text: jsxRuntime.jsx(ImportRunningTextNotification, {
1330
+ projectKey: projectKey
1331
+ })
1332
+ }, {
1333
+ dismissAfter: 5000
1334
+ });
1335
+ } catch (error) {
1336
+ onClose({
1337
+ shouldDeleteImportContainer: true
1338
+ });
1339
+ showNotification({
1340
+ kind: 'error',
1341
+ domain: constants.DOMAINS.PAGE,
1342
+ text: String(error)
1343
+ });
1344
+ }
1345
+ },
1346
+ size: 16,
1347
+ children: jsxRuntime.jsx(fullstory.Masking.Unmask, {
1348
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1349
+ scale: "xl",
1350
+ children: [jsxRuntime.jsx(uiKit.Text.Body, {
1351
+ intlMessage: _objectSpread$2(_objectSpread$2({}, messages.confirmationText), {}, {
1352
+ values: {
1353
+ projectName: projectName,
1354
+ // TODO: Replace with actual count
1355
+ count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
1356
+ b: getBold$1
1357
+ }
1358
+ })
1359
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1360
+ intlMessage: messages.confirmationQuestion
1361
+ })]
1362
+ })
1363
+ })
1364
+ });
1365
+ };
1366
+ function getBold$1(msg) {
1367
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1368
+ as: "span",
1369
+ isBold: true,
1370
+ children: msg
1371
+ });
1372
+ }
1373
+
1374
+ function ownKeys$1(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1375
+ function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys$1(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys$1(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1376
+ function UploadPreviewModal() {
1377
+ const _useUnpublishProducts = useUnpublishProductsContext(),
1378
+ state = _useUnpublishProducts.state,
1379
+ onClose = _useUnpublishProducts.onClose,
1380
+ actions = _useUnpublishProducts.actions;
1381
+ const intl = reactIntl.useIntl();
1382
+ return jsxRuntime.jsx(applicationComponents.FormDialog, {
1383
+ size: 16,
1384
+ isOpen: true,
1385
+ title: intl.formatMessage(sharedMessages.unpublishModalTitle),
1386
+ labelPrimary: intl.formatMessage(messages.continue),
1387
+ onSecondaryButtonClick: () => onClose({
1388
+ shouldDeleteImportContainer: true
1389
+ }),
1390
+ onPrimaryButtonClick: () => {
1391
+ actions.setCurrentStep('unpublish-confirmation');
1392
+ },
1393
+ onClose: () => onClose({
1394
+ shouldDeleteImportContainer: true
1395
+ }),
1396
+ children: jsxRuntime.jsxs(uiKit.Spacings.Stack, {
1397
+ scale: "m",
1398
+ children: [jsxRuntime.jsx(uiKit.Text.Body, {
1399
+ intlMessage: messages.heresAPreview
1400
+ }), jsxRuntime.jsx(uiKit.Card, {
1401
+ insetScale: "xl",
1402
+ children: jsxRuntime.jsxs(uiKit.Spacings.Inline, {
1403
+ scale: "m",
1404
+ alignItems: "center",
1405
+ children: [jsxRuntime.jsx(uiKit.CloseBoldIcon, {
1406
+ size: "40",
1407
+ color: "neutral60"
1408
+ }), jsxRuntime.jsx(uiKit.Text.Body, {
1409
+ intlMessage: _objectSpread$1(_objectSpread$1({}, messages.productsToBeUnpublished), {}, {
1410
+ values: {
1411
+ count: intl.formatNumber(state.uploadFileResponse?.rowsCount),
1412
+ b: getBold
1413
+ }
1414
+ })
1415
+ })]
1416
+ })
1417
+ })]
1418
+ })
1419
+ });
1420
+ }
1421
+ function getBold(msg) {
1422
+ return jsxRuntime.jsx(uiKit.Text.Body, {
1423
+ as: "span",
1424
+ isBold: true,
1425
+ children: msg
1426
+ });
1427
+ }
1428
+
1429
+ const steps = {
1430
+ upload: jsxRuntime.jsx(Upload, {}),
1431
+ uploading: jsxRuntime.jsx(Uploading, {}),
1432
+ 'upload-preview': jsxRuntime.jsx(UploadPreviewModal, {}),
1433
+ 'upload-error': jsxRuntime.jsx(UploadErrorsModal, {}),
1434
+ 'unpublish-confirmation': jsxRuntime.jsx(UnpublishProductsConfirmationModal, {})
1435
+ };
1436
+ const CurrentStep = () => {
1437
+ const _useUnpublishProducts = useUnpublishProductsContext(),
1438
+ state = _useUnpublishProducts.state;
1439
+ return steps[state.currentStep] || null;
1440
+ };
1441
+
1442
+ const getChunkImport = locale => {
1443
+ const intlLocale = i18n.mapLocaleToIntlLocale(locale);
1444
+ switch (intlLocale) {
1445
+ case 'de':
1446
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-de" */'./de-d954fe3d.cjs.prod.js'); });
1447
+ case 'es':
1448
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-es" */'./es-042343bd.cjs.prod.js'); });
1449
+ case 'fr-FR':
1450
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-fr-FR" */'./fr-FR-fce1ca96.cjs.prod.js'); });
1451
+ case 'zh-CN':
1452
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-zh-CN" */'./zh-CN-52baa549.cjs.prod.js'); });
1453
+ case 'ja':
1454
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-ja" */'./ja-37632763.cjs.prod.js'); });
1455
+ case 'pt-BR':
1456
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "change-history-i18n-pt-BR" */'./pt-BR-ec2a1a11.cjs.prod.js'); });
1457
+ default:
1458
+ return Promise.resolve().then(function () { return require(/* webpackChunkName: "unpublish-products-modal-i18n-en" */'./en-c7757448.cjs.prod.js'); });
1459
+ }
1460
+ };
1461
+ const loadMessages = async locale => {
1462
+ try {
1463
+ const chunkImport = await getChunkImport(locale);
1464
+ return i18n.parseChunkImport(chunkImport);
1465
+ } catch (error) {
1466
+ // eslint-disable-next-line no-console
1467
+ console.warn(`Something went wrong while loading the unpublish-products-modal messages for ${locale}`, error);
1468
+ sentry.reportErrorToSentry(new Error(`Something went wrong while loading the unpublish-products-modal messages for ${locale}`), {
1469
+ extra: error
1470
+ });
1471
+ return {};
1472
+ }
1473
+ };
1474
+
1475
+ const useAsyncIntlMessages = (locale, loader) => {
1476
+ const _useState = React.useState({
1477
+ isLoading: true,
1478
+ messages: undefined,
1479
+ error: undefined
1480
+ }),
1481
+ _useState2 = _slicedToArray(_useState, 2),
1482
+ state = _useState2[0],
1483
+ setState = _useState2[1];
1484
+ React.useEffect(() => {
1485
+ let _isUnmounting = false;
1486
+ async function load() {
1487
+ try {
1488
+ if (!_isUnmounting) {
1489
+ const messages = await loader(locale);
1490
+ setState({
1491
+ isLoading: false,
1492
+ messages
1493
+ });
1494
+ }
1495
+ } catch (error) {
1496
+ setState({
1497
+ isLoading: false,
1498
+ error
1499
+ });
1500
+ }
1501
+ }
1502
+ if (locale) load();
1503
+ return () => {
1504
+ _isUnmounting = true;
1505
+ };
1506
+ }, [locale, loader]);
1507
+ return state;
1508
+ };
1509
+
1510
+ function ownKeys(e, r) { var t = _Object$keys__default["default"](e); if (_Object$getOwnPropertySymbols__default["default"]) { var o = _Object$getOwnPropertySymbols__default["default"](e); r && (o = _filterInstanceProperty__default["default"](o).call(o, function (r) { return _Object$getOwnPropertyDescriptor__default["default"](e, r).enumerable; })), t.push.apply(t, o); } return t; }
1511
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty__default["default"](_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors__default["default"] ? _Object$defineProperties__default["default"](e, _Object$getOwnPropertyDescriptors__default["default"](t)) : _forEachInstanceProperty__default["default"](_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty__default["default"](e, r, _Object$getOwnPropertyDescriptor__default["default"](t, r)); }); } return e; }
1512
+ const UnpublishProductsModal = props => {
1513
+ const _useApplicationContex = applicationShellConnectors.useApplicationContext(context => ({
1514
+ locale: context.user && context.user.locale
1515
+ })),
1516
+ locale = _useApplicationContex.locale;
1517
+ const messages = useAsyncIntlMessages(locale, loadMessages);
1518
+ if (!props.isOpen || messages.isLoading) return null;
1519
+ return jsxRuntime.jsx(reactIntl.IntlProvider, {
1520
+ locale: locale,
1521
+ messages: messages.messages,
1522
+ children: jsxRuntime.jsx(UnpublishProductsProvider, _objectSpread(_objectSpread({}, props), {}, {
1523
+ children: jsxRuntime.jsx(CurrentStep, {})
1524
+ }))
1525
+ });
1526
+ };
1527
+ UnpublishProductsModal.displayName = 'UnpublishProductsModal';
1528
+
1529
+ exports.EnabledDropArea = EnabledDropArea;
1530
+ exports.FileDropped = FileDropped;
1531
+ exports.UnpublishProductsModal = UnpublishProductsModal;
1532
+ exports.messages = messages$4;
1533
+ exports.useUnpublishProductsContext = useUnpublishProductsContext;