@seeqdev/qomponents 0.0.19 → 0.0.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 (42) hide show
  1. package/dist/Button/Button.js +12 -4
  2. package/dist/Button/Button.js.map +1 -1
  3. package/dist/Button/Button.types.d.ts +4 -0
  4. package/dist/Icon/Icon.js +41 -34
  5. package/dist/Icon/Icon.js.map +1 -1
  6. package/dist/Icon/Icon.types.d.ts +4 -6
  7. package/dist/TextArea/TextArea.js +10 -4
  8. package/dist/TextArea/TextArea.js.map +1 -1
  9. package/dist/TextField/TextField.js +10 -4
  10. package/dist/TextField/TextField.js.map +1 -1
  11. package/dist/Tooltip/QTip.stories.d.ts +5 -0
  12. package/dist/Tooltip/QTip.stories.js +40 -0
  13. package/dist/Tooltip/QTip.stories.js.map +1 -0
  14. package/dist/Tooltip/QTip.types.d.ts +13 -0
  15. package/dist/Tooltip/QTip.types.js +2 -0
  16. package/dist/Tooltip/QTip.types.js.map +1 -0
  17. package/dist/Tooltip/QTipPerformance.stories.d.ts +5 -0
  18. package/dist/Tooltip/QTipPerformance.stories.js +30 -0
  19. package/dist/Tooltip/QTipPerformance.stories.js.map +1 -0
  20. package/dist/Tooltip/Qtip.d.ts +25 -0
  21. package/dist/Tooltip/Qtip.js +146 -0
  22. package/dist/Tooltip/Qtip.js.map +1 -0
  23. package/dist/Tooltip/Tooltip.d.ts +7 -1
  24. package/dist/Tooltip/Tooltip.js +7 -1
  25. package/dist/Tooltip/Tooltip.js.map +1 -1
  26. package/dist/Tooltip/TooltipPerformance.stories.d.ts +5 -0
  27. package/dist/Tooltip/TooltipPerformance.stories.js +30 -0
  28. package/dist/Tooltip/TooltipPerformance.stories.js.map +1 -0
  29. package/dist/Tooltip/index.d.ts +2 -1
  30. package/dist/Tooltip/index.js +2 -1
  31. package/dist/Tooltip/index.js.map +1 -1
  32. package/dist/example/package.json +1 -1
  33. package/dist/example/src/Example.tsx +109 -97
  34. package/dist/example/src/index.css +55 -46
  35. package/dist/index.d.ts +2 -1
  36. package/dist/index.esm.js +3152 -228
  37. package/dist/index.esm.js.map +1 -1
  38. package/dist/index.js +3152 -227
  39. package/dist/index.js.map +1 -1
  40. package/dist/styles.css +46 -1
  41. package/package.json +7 -2
  42. package/dist/example/package-lock.json +0 -3369
package/dist/index.js CHANGED
@@ -50,243 +50,3171 @@ const browserName = browserId && browserId.split(' ', 2)[0];
50
50
  browserId && parseInt(browserId.split(' ', 2)[1], 10);
51
51
  const browserIsFirefox = browserId && browserName === 'Firefox';
52
52
 
53
+ const colorClassesThemeLight = {
54
+ 'theme': 'tw-text-sq-color-dark',
55
+ 'white': 'tw-text-white',
56
+ 'dark-gray': 'tw-text-sq-fairly-dark-gray',
57
+ 'warning': 'tw-text-sq-warning-color',
58
+ 'darkish-gray': 'tw-text-sq-darkish-gray',
59
+ 'gray': 'tw-text-sq-disabled-gray',
60
+ 'color': '',
61
+ 'info': 'tw-text-sq-link',
62
+ 'text': 'tw-text-sq-text-color',
63
+ 'inherit': '',
64
+ 'danger': 'tw-text-sq-danger-color',
65
+ 'theme-light': 'tw-text-sq-color-light',
66
+ 'success': 'tw-text-sq-success-color',
67
+ };
68
+ const colorClassesThemeDark = {
69
+ 'theme': 'dark:tw-text-sq-color-dark-dark',
70
+ 'white': '',
71
+ 'dark-gray': 'tw-text-sq-fairly-dark-gray',
72
+ 'warning': '',
73
+ 'darkish-gray': 'tw-text-sq-darkish-gray',
74
+ 'gray': 'dark:tw-text-sq-dark-disabled-gray',
75
+ 'color': '',
76
+ 'info': 'dark:tw-text-sq-link-dark',
77
+ 'text': 'dark:tw-text-sq-dark-text',
78
+ 'inherit': '',
79
+ 'danger': 'tw-text-sq-danger-color',
80
+ 'theme-light': 'tw-text-sq-color-light',
81
+ 'success': 'tw-text-sq-success-color',
82
+ };
83
+ /**
84
+ * Icon:
85
+ * - access to Seeq custom icons by providing the desired icon
86
+ * - leverage "type" to style your icon
87
+ */
88
+ const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipPlacement, number, isHtmlTooltip = false, tooltipTestId, tooltipDelay = 0, }) => {
89
+ if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
90
+ const errorMessage = color === undefined || color === ''
91
+ ? 'Icon with type="color" must have prop color specified.'
92
+ : 'Icon with prop color must have type="color".';
93
+ return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
94
+ }
95
+ const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';
96
+ const style = type === 'color' && color ? { color } : {};
97
+ const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
98
+ ${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
99
+ const tooltipData = tooltip
100
+ ? {
101
+ 'data-qtip-text': tooltip,
102
+ 'data-qtip-placement': tooltipPlacement,
103
+ 'data-qtip-is-html': isHtmlTooltip,
104
+ 'data-qtip-testid': tooltipTestId,
105
+ 'data-qtip-delay': tooltipDelay,
106
+ }
107
+ : undefined;
108
+ return (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
109
+ };
110
+
111
+ /**
112
+ * All-in-one Button:
113
+ * - use "variant" to achieve the desired style
114
+ * - include tooltips and/or icons
115
+ */
116
+ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, preventBlur = false, isHtmlTooltip = false, tooltipTestId, }) => {
117
+ const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
118
+ const baseClassesByVariant = {
119
+ 'outline': 'tw-border-solid tw-border',
120
+ 'theme': 'disabled:tw-opacity-50',
121
+ 'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-opacity-50',
122
+ 'theme-light': 'disabled:tw-opacity-50',
123
+ 'no-border': '',
124
+ 'warning': 'tw-bg-sq-warning-color',
125
+ };
126
+ const textClassesByVariantLightTheme = {
127
+ 'outline': 'tw-text-sq-text-color',
128
+ 'theme': 'tw-text-white',
129
+ 'theme-light': 'tw-text-white',
130
+ 'danger': 'tw-text-white',
131
+ 'no-border': 'tw-text-sq-text-color',
132
+ 'warning': 'tw-text-white',
133
+ };
134
+ const textClassesByVariantDarkTheme = {
135
+ 'outline': 'dark:tw-text-sq-dark-text',
136
+ 'theme': 'dark:tw-text-white',
137
+ 'theme-light': 'dark:tw-text-white',
138
+ 'danger': 'dark:tw-text-white',
139
+ 'no-border': 'dark:tw-text-sq-dark-text',
140
+ 'warning': 'dark:tw-text-white',
141
+ };
142
+ const classesByVariantLightTheme = {
143
+ 'outline': 'tw-border-sq-disabled-gray hover:tw-bg-sq-light-gray' +
144
+ ' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
145
+ 'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight',
146
+ 'danger': '',
147
+ 'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link',
148
+ 'no-border': '',
149
+ 'warning': 'tw-bg-sq-warning-color',
150
+ };
151
+ const classesByVariantDarkTheme = {
152
+ 'outline': 'dark:tw-border-sq-dark-disabled-gray dark:hover:tw-bg-sq-highlight-color-dark' +
153
+ ' dark:focus:tw-bg-sq-dark-gray dark:active:tw-bg-sq-dark-gray dark:focus:tw-border-sq-color-dark' +
154
+ ' dark:active:tw-border-sq-color-dark',
155
+ 'theme': 'dark:tw-bg-sq-color-dark dark:hover:tw-bg-sq-color-highlight',
156
+ 'danger': '',
157
+ 'theme-light': 'dark:tw-bg-sq-icon-dark dark:hover:tw-bg-sq-link-dark',
158
+ 'no-border': '',
159
+ 'warning': '',
160
+ };
161
+ const sizeClasses = {
162
+ sm: 'tw-text-sm',
163
+ lg: 'tw-text-xl',
164
+ };
165
+ const appliedClasses = `${baseClasses} ${baseClassesByVariant[variant]} ${sizeClasses[size]} ${classesByVariantLightTheme[variant]} ${classesByVariantDarkTheme[variant]} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]} ${extraClassNames}`;
166
+ let tooltipData = undefined;
167
+ if (tooltip) {
168
+ tooltipData = {
169
+ 'data-qtip-text': tooltip,
170
+ 'data-qtip-placement': tooltipOptions?.position,
171
+ 'data-qtip-is-html': isHtmlTooltip,
172
+ 'data-qtip-testid': tooltipTestId,
173
+ 'data-qtip-delay': tooltipOptions?.delay ?? 0,
174
+ };
175
+ }
176
+ return (React.createElement("button", { id: id, ...tooltipData, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
177
+ stopPropagation && e.stopPropagation();
178
+ onClick && onClick();
179
+ }, onMouseDown: (e) => {
180
+ if (preventBlur) {
181
+ e.preventDefault();
182
+ }
183
+ }, className: appliedClasses },
184
+ icon && (React.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` })),
185
+ label));
186
+ };
187
+
188
+ const errorClasses$2 = 'tw-border-sq-danger-color';
189
+ const borderColorClasses$2 = [
190
+ 'tw-border-sq-disabled-gray',
191
+ 'dark:tw-border-sq-dark-disabled-gray',
192
+ 'dark:focus:tw-border-sq-color-dark-dark',
193
+ 'dark:active:tw-border-sq-color-dark-dark',
194
+ 'focus:tw-border-sq-color-dark',
195
+ 'active:tw-border-sq-color-dark',
196
+ ].join(' ');
197
+ const baseClasses$3 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
198
+ ' disabled:tw-pointer-events-none' +
199
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
200
+ ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
201
+ const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text';
202
+ const lightTheme$1 = 'tw-text-sq-text-color';
203
+ const sizeClasses = {
204
+ sm: 'tw-text-sm',
205
+ lg: 'tw-text-xl',
206
+ };
207
+ /**
208
+ * Textfield.
209
+ */
210
+ const TextField = React.forwardRef((props, ref) => {
211
+ const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, } = props;
212
+ const internalRef = React.useRef(null);
213
+ const [cursor, setCursor] = React.useState(null);
214
+ const setAllRefs = (receivedRef) => {
215
+ if (ref)
216
+ ref.current = receivedRef;
217
+ internalRef.current = receivedRef;
218
+ };
219
+ React.useEffect(() => {
220
+ const input = internalRef.current;
221
+ if (input && type !== 'number')
222
+ input.setSelectionRange(cursor, cursor);
223
+ }, [ref, cursor, value]);
224
+ const handleChange = (e) => {
225
+ setCursor(e.target.selectionStart);
226
+ onChange && onChange(e);
227
+ };
228
+ React.useEffect(() => {
229
+ /**
230
+ * we need to change the value only if it's different since the internal state of "input" will change it anyway
231
+ * this will only be the case when the value has been changed externally via store (undo / redo)
232
+ */
233
+ if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
234
+ // we need to use this method because using the value props directly will switch the input to a "controlled"
235
+ // component
236
+ internalRef.current.value = `${value}`;
237
+ }
238
+ }, [value]);
239
+ let borderRadius = 'tw-rounded-sm';
240
+ if (inputGroup === 'left') {
241
+ borderRadius = 'tw-rounded-l-sm tw-border-r-0 focus:tw-border-r' + ' active:tw-border-r';
242
+ }
243
+ else if (inputGroup === 'right') {
244
+ borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
245
+ }
246
+ const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
247
+ return (React.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: "none", onChange: handleChange, onKeyUp: onKeyUp, step: step }));
248
+ });
249
+
250
+ const alignment = 'tw-flex tw-items-center';
251
+ const labelClasses = 'tw-ml-1.5 tw-text-sm';
252
+ const baseClasses$2 = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
253
+ ' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:checked:tw-bg-sq-dark-text' +
254
+ ' checked:tw-text-sq-text-color' +
255
+ ' disabled:tw-text-sq-fairly-dark-gray';
256
+ const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses$2}`;
257
+ const radioClasses = `tw-form-radio ${baseClasses$2}`;
258
+ /**
259
+ * Checkbox and Radio Box Component.
260
+ */
261
+ const Checkbox = (props) => {
262
+ const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, } = props;
263
+ const assignedId = id ?? 'checkbox_' + Math.random();
264
+ return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
265
+ React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown }),
266
+ React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
267
+ ? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
268
+ : 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
269
+ };
270
+
271
+ const baseClasses$1 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
272
+ ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
273
+ const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text ' + 'dark:tw-placeholder-sq-dark-text-lighter';
274
+ const lightTheme = 'tw-text-sq-text-color tw-placeholder-gray-400';
275
+ const errorClasses$1 = 'tw-border-sq-danger-color';
276
+ const borderColorClasses$1 = [
277
+ 'tw-border-sq-disabled-gray',
278
+ 'dark:tw-border-sq-dark-disabled-gray',
279
+ 'dark:focus:tw-border-sq-color-dark-dark',
280
+ 'dark:active:tw-border-sq-color-dark-dark',
281
+ 'focus:tw-border-sq-color-dark',
282
+ 'active:tw-border-sq-color-dark',
283
+ ].join(' ');
284
+ /**
285
+ * TextArea.
286
+ */
287
+ const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, showError, }) => {
288
+ const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme} ${showError ? errorClasses$1 : borderColorClasses$1}`;
289
+ return (React.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autofocus }));
290
+ };
291
+
53
292
  const DEFAULT_TOOL_TIP_DELAY = 1000;
54
293
 
55
- /**
56
- * This component displays a Tooltip for the provided children.
57
- */
58
- const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
59
- const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
60
- const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
61
- const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
62
- const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
63
- before:tw-border-l-transparent before:tw-border-r-black`;
64
- const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
65
- before:tw-border-l-black before:tw-border-r-transparent`;
66
- const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
67
- before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
68
- const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
69
- before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
70
- const placements = {
71
- top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
72
- left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
73
- right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
74
- bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
75
- };
76
- return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
77
- children,
78
- React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
79
- tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
80
- };
294
+ /**
295
+ * @deprecated
296
+ * Note: Tooltip has been replaced by QTip - a singleton JS tooltip that behaves well even with overflow settings :)
297
+ * See @QTip for more info!
298
+ *
299
+ * This component displays a Tooltip for the provided children. It is a CSS only tooltip that will not display
300
+ * correctly if a parent element has an overflow CSS property assigned. Please use QTip to ensure your tooltips
301
+ * display correctly.
302
+ */
303
+ const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
304
+ const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
305
+ const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
306
+ const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
307
+ const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
308
+ before:tw-border-l-transparent before:tw-border-r-black`;
309
+ const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
310
+ before:tw-border-l-black before:tw-border-r-transparent`;
311
+ const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
312
+ before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
313
+ const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
314
+ before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
315
+ const placements = {
316
+ top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
317
+ left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
318
+ right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
319
+ bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
320
+ };
321
+ return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
322
+ children,
323
+ React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
324
+ tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
325
+ };
326
+
327
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
328
+
329
+ var purifyExports = {};
330
+ var purify = {
331
+ get exports(){ return purifyExports; },
332
+ set exports(v){ purifyExports = v; },
333
+ };
334
+
335
+ /*! @license DOMPurify 3.0.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.5/LICENSE */
336
+
337
+ (function (module, exports) {
338
+ (function (global, factory) {
339
+ module.exports = factory() ;
340
+ })(commonjsGlobal, (function () {
341
+ const {
342
+ entries,
343
+ setPrototypeOf,
344
+ isFrozen,
345
+ getPrototypeOf,
346
+ getOwnPropertyDescriptor
347
+ } = Object;
348
+ let {
349
+ freeze,
350
+ seal,
351
+ create
352
+ } = Object; // eslint-disable-line import/no-mutable-exports
353
+
354
+ let {
355
+ apply,
356
+ construct
357
+ } = typeof Reflect !== 'undefined' && Reflect;
358
+
359
+ if (!apply) {
360
+ apply = function apply(fun, thisValue, args) {
361
+ return fun.apply(thisValue, args);
362
+ };
363
+ }
364
+
365
+ if (!freeze) {
366
+ freeze = function freeze(x) {
367
+ return x;
368
+ };
369
+ }
370
+
371
+ if (!seal) {
372
+ seal = function seal(x) {
373
+ return x;
374
+ };
375
+ }
376
+
377
+ if (!construct) {
378
+ construct = function construct(Func, args) {
379
+ return new Func(...args);
380
+ };
381
+ }
382
+
383
+ const arrayForEach = unapply(Array.prototype.forEach);
384
+ const arrayPop = unapply(Array.prototype.pop);
385
+ const arrayPush = unapply(Array.prototype.push);
386
+ const stringToLowerCase = unapply(String.prototype.toLowerCase);
387
+ const stringToString = unapply(String.prototype.toString);
388
+ const stringMatch = unapply(String.prototype.match);
389
+ const stringReplace = unapply(String.prototype.replace);
390
+ const stringIndexOf = unapply(String.prototype.indexOf);
391
+ const stringTrim = unapply(String.prototype.trim);
392
+ const regExpTest = unapply(RegExp.prototype.test);
393
+ const typeErrorCreate = unconstruct(TypeError);
394
+ function unapply(func) {
395
+ return function (thisArg) {
396
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
397
+ args[_key - 1] = arguments[_key];
398
+ }
399
+
400
+ return apply(func, thisArg, args);
401
+ };
402
+ }
403
+ function unconstruct(func) {
404
+ return function () {
405
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
406
+ args[_key2] = arguments[_key2];
407
+ }
408
+
409
+ return construct(func, args);
410
+ };
411
+ }
412
+ /* Add properties to a lookup table */
413
+
414
+ function addToSet(set, array, transformCaseFunc) {
415
+ var _transformCaseFunc;
416
+
417
+ transformCaseFunc = (_transformCaseFunc = transformCaseFunc) !== null && _transformCaseFunc !== void 0 ? _transformCaseFunc : stringToLowerCase;
418
+
419
+ if (setPrototypeOf) {
420
+ // Make 'in' and truthy checks like Boolean(set.constructor)
421
+ // independent of any properties defined on Object.prototype.
422
+ // Prevent prototype setters from intercepting set as a this value.
423
+ setPrototypeOf(set, null);
424
+ }
425
+
426
+ let l = array.length;
427
+
428
+ while (l--) {
429
+ let element = array[l];
430
+
431
+ if (typeof element === 'string') {
432
+ const lcElement = transformCaseFunc(element);
433
+
434
+ if (lcElement !== element) {
435
+ // Config presets (e.g. tags.js, attrs.js) are immutable.
436
+ if (!isFrozen(array)) {
437
+ array[l] = lcElement;
438
+ }
439
+
440
+ element = lcElement;
441
+ }
442
+ }
443
+
444
+ set[element] = true;
445
+ }
446
+
447
+ return set;
448
+ }
449
+ /* Shallow clone an object */
450
+
451
+ function clone(object) {
452
+ const newObject = create(null);
453
+
454
+ for (const [property, value] of entries(object)) {
455
+ newObject[property] = value;
456
+ }
457
+
458
+ return newObject;
459
+ }
460
+ /* This method automatically checks if the prop is function
461
+ * or getter and behaves accordingly. */
462
+
463
+ function lookupGetter(object, prop) {
464
+ while (object !== null) {
465
+ const desc = getOwnPropertyDescriptor(object, prop);
466
+
467
+ if (desc) {
468
+ if (desc.get) {
469
+ return unapply(desc.get);
470
+ }
471
+
472
+ if (typeof desc.value === 'function') {
473
+ return unapply(desc.value);
474
+ }
475
+ }
476
+
477
+ object = getPrototypeOf(object);
478
+ }
479
+
480
+ function fallbackValue(element) {
481
+ console.warn('fallback value for', element);
482
+ return null;
483
+ }
484
+
485
+ return fallbackValue;
486
+ }
487
+
488
+ const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'section', 'select', 'shadow', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); // SVG
489
+
490
+ const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);
491
+ const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); // List of SVG elements that are disallowed by default.
492
+ // We still need to know them so that we can do namespace
493
+ // checks properly in case one wants to add them to
494
+ // allow-list.
495
+
496
+ const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);
497
+ const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); // Similarly to SVG, we want to know all MathML elements,
498
+ // even those that we disallow by default.
499
+
500
+ const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
501
+ const text = freeze(['#text']);
502
+
503
+ const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'pattern', 'placeholder', 'playsinline', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'xmlns', 'slot']);
504
+ const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);
505
+ const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);
506
+ const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
507
+
508
+ const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
509
+
510
+ const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
511
+ const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
512
+ const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
513
+
514
+ const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
515
+
516
+ const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape
517
+ );
518
+ const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
519
+ const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
520
+ );
521
+ const DOCTYPE_NAME = seal(/^html$/i);
522
+
523
+ var EXPRESSIONS = /*#__PURE__*/Object.freeze({
524
+ __proto__: null,
525
+ MUSTACHE_EXPR: MUSTACHE_EXPR,
526
+ ERB_EXPR: ERB_EXPR,
527
+ TMPLIT_EXPR: TMPLIT_EXPR,
528
+ DATA_ATTR: DATA_ATTR,
529
+ ARIA_ATTR: ARIA_ATTR,
530
+ IS_ALLOWED_URI: IS_ALLOWED_URI,
531
+ IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
532
+ ATTR_WHITESPACE: ATTR_WHITESPACE,
533
+ DOCTYPE_NAME: DOCTYPE_NAME
534
+ });
535
+
536
+ const getGlobal = () => typeof window === 'undefined' ? null : window;
537
+ /**
538
+ * Creates a no-op policy for internal use only.
539
+ * Don't export this function outside this module!
540
+ * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
541
+ * @param {HTMLScriptElement} purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).
542
+ * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
543
+ * are not supported or creating the policy failed).
544
+ */
545
+
546
+
547
+ const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {
548
+ if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
549
+ return null;
550
+ } // Allow the callers to control the unique policy name
551
+ // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
552
+ // Policy creation with duplicate names throws in Trusted Types.
553
+
554
+
555
+ let suffix = null;
556
+ const ATTR_NAME = 'data-tt-policy-suffix';
557
+
558
+ if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {
559
+ suffix = purifyHostElement.getAttribute(ATTR_NAME);
560
+ }
561
+
562
+ const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
563
+
564
+ try {
565
+ return trustedTypes.createPolicy(policyName, {
566
+ createHTML(html) {
567
+ return html;
568
+ },
569
+
570
+ createScriptURL(scriptUrl) {
571
+ return scriptUrl;
572
+ }
573
+
574
+ });
575
+ } catch (_) {
576
+ // Policy creation failed (most likely another DOMPurify script has
577
+ // already run). Skip creating the policy, as this will only cause errors
578
+ // if TT are enforced.
579
+ console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
580
+ return null;
581
+ }
582
+ };
583
+
584
+ function createDOMPurify() {
585
+ let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
586
+
587
+ const DOMPurify = root => createDOMPurify(root);
588
+ /**
589
+ * Version label, exposed for easier checks
590
+ * if DOMPurify is up to date or not
591
+ */
592
+
593
+
594
+ DOMPurify.version = '3.0.5';
595
+ /**
596
+ * Array of elements that DOMPurify removed during sanitation.
597
+ * Empty if nothing was removed.
598
+ */
599
+
600
+ DOMPurify.removed = [];
601
+
602
+ if (!window || !window.document || window.document.nodeType !== 9) {
603
+ // Not running in a browser, provide a factory function
604
+ // so that you can pass your own Window
605
+ DOMPurify.isSupported = false;
606
+ return DOMPurify;
607
+ }
608
+
609
+ const originalDocument = window.document;
610
+ const currentScript = originalDocument.currentScript;
611
+ let {
612
+ document
613
+ } = window;
614
+ const {
615
+ DocumentFragment,
616
+ HTMLTemplateElement,
617
+ Node,
618
+ Element,
619
+ NodeFilter,
620
+ NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
621
+ HTMLFormElement,
622
+ DOMParser,
623
+ trustedTypes
624
+ } = window;
625
+ const ElementPrototype = Element.prototype;
626
+ const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
627
+ const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
628
+ const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
629
+ const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
630
+ // new document created via createHTMLDocument. As per the spec
631
+ // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
632
+ // a new empty registry is used when creating a template contents owner
633
+ // document, so we use that as our parent document to ensure nothing
634
+ // is inherited.
635
+
636
+ if (typeof HTMLTemplateElement === 'function') {
637
+ const template = document.createElement('template');
638
+
639
+ if (template.content && template.content.ownerDocument) {
640
+ document = template.content.ownerDocument;
641
+ }
642
+ }
643
+
644
+ let trustedTypesPolicy;
645
+ let emptyHTML = '';
646
+ const {
647
+ implementation,
648
+ createNodeIterator,
649
+ createDocumentFragment,
650
+ getElementsByTagName
651
+ } = document;
652
+ const {
653
+ importNode
654
+ } = originalDocument;
655
+ let hooks = {};
656
+ /**
657
+ * Expose whether this browser supports running the full DOMPurify.
658
+ */
659
+
660
+ DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;
661
+ const {
662
+ MUSTACHE_EXPR,
663
+ ERB_EXPR,
664
+ TMPLIT_EXPR,
665
+ DATA_ATTR,
666
+ ARIA_ATTR,
667
+ IS_SCRIPT_OR_DATA,
668
+ ATTR_WHITESPACE
669
+ } = EXPRESSIONS;
670
+ let {
671
+ IS_ALLOWED_URI: IS_ALLOWED_URI$1
672
+ } = EXPRESSIONS;
673
+ /**
674
+ * We consider the elements and attributes below to be safe. Ideally
675
+ * don't add any new ones but feel free to remove unwanted ones.
676
+ */
677
+
678
+ /* allowed element names */
679
+
680
+ let ALLOWED_TAGS = null;
681
+ const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
682
+ /* Allowed attribute names */
683
+
684
+ let ALLOWED_ATTR = null;
685
+ const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
686
+ /*
687
+ * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
688
+ * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
689
+ * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
690
+ * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
691
+ */
692
+
693
+ let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
694
+ tagNameCheck: {
695
+ writable: true,
696
+ configurable: false,
697
+ enumerable: true,
698
+ value: null
699
+ },
700
+ attributeNameCheck: {
701
+ writable: true,
702
+ configurable: false,
703
+ enumerable: true,
704
+ value: null
705
+ },
706
+ allowCustomizedBuiltInElements: {
707
+ writable: true,
708
+ configurable: false,
709
+ enumerable: true,
710
+ value: false
711
+ }
712
+ }));
713
+ /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
714
+
715
+ let FORBID_TAGS = null;
716
+ /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
717
+
718
+ let FORBID_ATTR = null;
719
+ /* Decide if ARIA attributes are okay */
720
+
721
+ let ALLOW_ARIA_ATTR = true;
722
+ /* Decide if custom data attributes are okay */
723
+
724
+ let ALLOW_DATA_ATTR = true;
725
+ /* Decide if unknown protocols are okay */
726
+
727
+ let ALLOW_UNKNOWN_PROTOCOLS = false;
728
+ /* Decide if self-closing tags in attributes are allowed.
729
+ * Usually removed due to a mXSS issue in jQuery 3.0 */
730
+
731
+ let ALLOW_SELF_CLOSE_IN_ATTR = true;
732
+ /* Output should be safe for common template engines.
733
+ * This means, DOMPurify removes data attributes, mustaches and ERB
734
+ */
735
+
736
+ let SAFE_FOR_TEMPLATES = false;
737
+ /* Decide if document with <html>... should be returned */
738
+
739
+ let WHOLE_DOCUMENT = false;
740
+ /* Track whether config is already set on this instance of DOMPurify. */
741
+
742
+ let SET_CONFIG = false;
743
+ /* Decide if all elements (e.g. style, script) must be children of
744
+ * document.body. By default, browsers might move them to document.head */
745
+
746
+ let FORCE_BODY = false;
747
+ /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
748
+ * string (or a TrustedHTML object if Trusted Types are supported).
749
+ * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
750
+ */
751
+
752
+ let RETURN_DOM = false;
753
+ /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
754
+ * string (or a TrustedHTML object if Trusted Types are supported) */
755
+
756
+ let RETURN_DOM_FRAGMENT = false;
757
+ /* Try to return a Trusted Type object instead of a string, return a string in
758
+ * case Trusted Types are not supported */
759
+
760
+ let RETURN_TRUSTED_TYPE = false;
761
+ /* Output should be free from DOM clobbering attacks?
762
+ * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
763
+ */
764
+
765
+ let SANITIZE_DOM = true;
766
+ /* Achieve full DOM Clobbering protection by isolating the namespace of named
767
+ * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
768
+ *
769
+ * HTML/DOM spec rules that enable DOM Clobbering:
770
+ * - Named Access on Window (§7.3.3)
771
+ * - DOM Tree Accessors (§3.1.5)
772
+ * - Form Element Parent-Child Relations (§4.10.3)
773
+ * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
774
+ * - HTMLCollection (§4.2.10.2)
775
+ *
776
+ * Namespace isolation is implemented by prefixing `id` and `name` attributes
777
+ * with a constant string, i.e., `user-content-`
778
+ */
779
+
780
+ let SANITIZE_NAMED_PROPS = false;
781
+ const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
782
+ /* Keep element content when removing element? */
783
+
784
+ let KEEP_CONTENT = true;
785
+ /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
786
+ * of importing it into a new Document and returning a sanitized copy */
787
+
788
+ let IN_PLACE = false;
789
+ /* Allow usage of profiles like html, svg and mathMl */
790
+
791
+ let USE_PROFILES = {};
792
+ /* Tags to ignore content of when KEEP_CONTENT is true */
793
+
794
+ let FORBID_CONTENTS = null;
795
+ const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);
796
+ /* Tags that are safe for data: URIs */
797
+
798
+ let DATA_URI_TAGS = null;
799
+ const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
800
+ /* Attributes safe for values like "javascript:" */
801
+
802
+ let URI_SAFE_ATTRIBUTES = null;
803
+ const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
804
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
805
+ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
806
+ const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
807
+ /* Document namespace */
808
+
809
+ let NAMESPACE = HTML_NAMESPACE;
810
+ let IS_EMPTY_INPUT = false;
811
+ /* Allowed XHTML+XML namespaces */
812
+
813
+ let ALLOWED_NAMESPACES = null;
814
+ const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
815
+ /* Parsing of strict XHTML documents */
816
+
817
+ let PARSER_MEDIA_TYPE;
818
+ const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
819
+ const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
820
+ let transformCaseFunc;
821
+ /* Keep a reference to config to pass to hooks */
822
+
823
+ let CONFIG = null;
824
+ /* Ideally, do not touch anything below this line */
825
+
826
+ /* ______________________________________________ */
827
+
828
+ const formElement = document.createElement('form');
829
+
830
+ const isRegexOrFunction = function isRegexOrFunction(testValue) {
831
+ return testValue instanceof RegExp || testValue instanceof Function;
832
+ };
833
+ /**
834
+ * _parseConfig
835
+ *
836
+ * @param {Object} cfg optional config literal
837
+ */
838
+ // eslint-disable-next-line complexity
839
+
840
+
841
+ const _parseConfig = function _parseConfig(cfg) {
842
+ if (CONFIG && CONFIG === cfg) {
843
+ return;
844
+ }
845
+ /* Shield configuration object from tampering */
846
+
847
+
848
+ if (!cfg || typeof cfg !== 'object') {
849
+ cfg = {};
850
+ }
851
+ /* Shield configuration object from prototype pollution */
852
+
853
+
854
+ cfg = clone(cfg);
855
+ PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
856
+ SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? PARSER_MEDIA_TYPE = DEFAULT_PARSER_MEDIA_TYPE : PARSER_MEDIA_TYPE = cfg.PARSER_MEDIA_TYPE; // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.
857
+
858
+ transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
859
+ /* Set configuration parameters */
860
+
861
+ ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
862
+ ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
863
+ ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
864
+ URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
865
+ cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
866
+ transformCaseFunc // eslint-disable-line indent
867
+ ) // eslint-disable-line indent
868
+ : DEFAULT_URI_SAFE_ATTRIBUTES;
869
+ DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
870
+ cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
871
+ transformCaseFunc // eslint-disable-line indent
872
+ ) // eslint-disable-line indent
873
+ : DEFAULT_DATA_URI_TAGS;
874
+ FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
875
+ FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
876
+ FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
877
+ USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
878
+ ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
879
+
880
+ ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
881
+
882
+ ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
883
+
884
+ ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
885
+
886
+ SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
887
+
888
+ WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
889
+
890
+ RETURN_DOM = cfg.RETURN_DOM || false; // Default false
891
+
892
+ RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
893
+
894
+ RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
895
+
896
+ FORCE_BODY = cfg.FORCE_BODY || false; // Default false
897
+
898
+ SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
899
+
900
+ SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
901
+
902
+ KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
903
+
904
+ IN_PLACE = cfg.IN_PLACE || false; // Default false
905
+
906
+ IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
907
+ NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
908
+ CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
909
+
910
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
911
+ CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
912
+ }
913
+
914
+ if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
915
+ CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
916
+ }
917
+
918
+ if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
919
+ CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
920
+ }
921
+
922
+ if (SAFE_FOR_TEMPLATES) {
923
+ ALLOW_DATA_ATTR = false;
924
+ }
925
+
926
+ if (RETURN_DOM_FRAGMENT) {
927
+ RETURN_DOM = true;
928
+ }
929
+ /* Parse profile info */
930
+
931
+
932
+ if (USE_PROFILES) {
933
+ ALLOWED_TAGS = addToSet({}, [...text]);
934
+ ALLOWED_ATTR = [];
935
+
936
+ if (USE_PROFILES.html === true) {
937
+ addToSet(ALLOWED_TAGS, html$1);
938
+ addToSet(ALLOWED_ATTR, html);
939
+ }
940
+
941
+ if (USE_PROFILES.svg === true) {
942
+ addToSet(ALLOWED_TAGS, svg$1);
943
+ addToSet(ALLOWED_ATTR, svg);
944
+ addToSet(ALLOWED_ATTR, xml);
945
+ }
946
+
947
+ if (USE_PROFILES.svgFilters === true) {
948
+ addToSet(ALLOWED_TAGS, svgFilters);
949
+ addToSet(ALLOWED_ATTR, svg);
950
+ addToSet(ALLOWED_ATTR, xml);
951
+ }
952
+
953
+ if (USE_PROFILES.mathMl === true) {
954
+ addToSet(ALLOWED_TAGS, mathMl$1);
955
+ addToSet(ALLOWED_ATTR, mathMl);
956
+ addToSet(ALLOWED_ATTR, xml);
957
+ }
958
+ }
959
+ /* Merge configuration parameters */
960
+
961
+
962
+ if (cfg.ADD_TAGS) {
963
+ if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
964
+ ALLOWED_TAGS = clone(ALLOWED_TAGS);
965
+ }
966
+
967
+ addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
968
+ }
969
+
970
+ if (cfg.ADD_ATTR) {
971
+ if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
972
+ ALLOWED_ATTR = clone(ALLOWED_ATTR);
973
+ }
974
+
975
+ addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
976
+ }
977
+
978
+ if (cfg.ADD_URI_SAFE_ATTR) {
979
+ addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
980
+ }
981
+
982
+ if (cfg.FORBID_CONTENTS) {
983
+ if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
984
+ FORBID_CONTENTS = clone(FORBID_CONTENTS);
985
+ }
986
+
987
+ addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
988
+ }
989
+ /* Add #text in case KEEP_CONTENT is set to true */
990
+
991
+
992
+ if (KEEP_CONTENT) {
993
+ ALLOWED_TAGS['#text'] = true;
994
+ }
995
+ /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
996
+
997
+
998
+ if (WHOLE_DOCUMENT) {
999
+ addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
1000
+ }
1001
+ /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
1002
+
1003
+
1004
+ if (ALLOWED_TAGS.table) {
1005
+ addToSet(ALLOWED_TAGS, ['tbody']);
1006
+ delete FORBID_TAGS.tbody;
1007
+ }
1008
+
1009
+ if (cfg.TRUSTED_TYPES_POLICY) {
1010
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {
1011
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');
1012
+ }
1013
+
1014
+ if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {
1015
+ throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');
1016
+ } // Overwrite existing TrustedTypes policy.
1017
+
1018
+
1019
+ trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; // Sign local variables required by `sanitize`.
1020
+
1021
+ emptyHTML = trustedTypesPolicy.createHTML('');
1022
+ } else {
1023
+ // Uninitialized policy, attempt to initialize the internal dompurify policy.
1024
+ if (trustedTypesPolicy === undefined) {
1025
+ trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);
1026
+ } // If creating the internal policy succeeded sign internal variables.
1027
+
1028
+
1029
+ if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {
1030
+ emptyHTML = trustedTypesPolicy.createHTML('');
1031
+ }
1032
+ } // Prevent further manipulation of configuration.
1033
+ // Not available in IE8, Safari 5, etc.
1034
+
1035
+
1036
+ if (freeze) {
1037
+ freeze(cfg);
1038
+ }
1039
+
1040
+ CONFIG = cfg;
1041
+ };
1042
+
1043
+ const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
1044
+ const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
1045
+ // namespace. We need to specify them explicitly
1046
+ // so that they don't get erroneously deleted from
1047
+ // HTML namespace.
1048
+
1049
+ const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
1050
+ /* Keep track of all possible SVG and MathML tags
1051
+ * so that we can perform the namespace checks
1052
+ * correctly. */
1053
+
1054
+ const ALL_SVG_TAGS = addToSet({}, svg$1);
1055
+ addToSet(ALL_SVG_TAGS, svgFilters);
1056
+ addToSet(ALL_SVG_TAGS, svgDisallowed);
1057
+ const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
1058
+ addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
1059
+ /**
1060
+ *
1061
+ *
1062
+ * @param {Element} element a DOM element whose namespace is being checked
1063
+ * @returns {boolean} Return false if the element has a
1064
+ * namespace that a spec-compliant parser would never
1065
+ * return. Return true otherwise.
1066
+ */
1067
+
1068
+ const _checkValidNamespace = function _checkValidNamespace(element) {
1069
+ let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
1070
+ // can be null. We just simulate parent in this case.
1071
+
1072
+ if (!parent || !parent.tagName) {
1073
+ parent = {
1074
+ namespaceURI: NAMESPACE,
1075
+ tagName: 'template'
1076
+ };
1077
+ }
1078
+
1079
+ const tagName = stringToLowerCase(element.tagName);
1080
+ const parentTagName = stringToLowerCase(parent.tagName);
1081
+
1082
+ if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
1083
+ return false;
1084
+ }
1085
+
1086
+ if (element.namespaceURI === SVG_NAMESPACE) {
1087
+ // The only way to switch from HTML namespace to SVG
1088
+ // is via <svg>. If it happens via any other tag, then
1089
+ // it should be killed.
1090
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1091
+ return tagName === 'svg';
1092
+ } // The only way to switch from MathML to SVG is via`
1093
+ // svg if parent is either <annotation-xml> or MathML
1094
+ // text integration points.
1095
+
1096
+
1097
+ if (parent.namespaceURI === MATHML_NAMESPACE) {
1098
+ return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
1099
+ } // We only allow elements that are defined in SVG
1100
+ // spec. All others are disallowed in SVG namespace.
1101
+
1102
+
1103
+ return Boolean(ALL_SVG_TAGS[tagName]);
1104
+ }
1105
+
1106
+ if (element.namespaceURI === MATHML_NAMESPACE) {
1107
+ // The only way to switch from HTML namespace to MathML
1108
+ // is via <math>. If it happens via any other tag, then
1109
+ // it should be killed.
1110
+ if (parent.namespaceURI === HTML_NAMESPACE) {
1111
+ return tagName === 'math';
1112
+ } // The only way to switch from SVG to MathML is via
1113
+ // <math> and HTML integration points
1114
+
1115
+
1116
+ if (parent.namespaceURI === SVG_NAMESPACE) {
1117
+ return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
1118
+ } // We only allow elements that are defined in MathML
1119
+ // spec. All others are disallowed in MathML namespace.
1120
+
1121
+
1122
+ return Boolean(ALL_MATHML_TAGS[tagName]);
1123
+ }
1124
+
1125
+ if (element.namespaceURI === HTML_NAMESPACE) {
1126
+ // The only way to switch from SVG to HTML is via
1127
+ // HTML integration points, and from MathML to HTML
1128
+ // is via MathML text integration points
1129
+ if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
1130
+ return false;
1131
+ }
1132
+
1133
+ if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
1134
+ return false;
1135
+ } // We disallow tags that are specific for MathML
1136
+ // or SVG and should never appear in HTML namespace
1137
+
1138
+
1139
+ return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
1140
+ } // For XHTML and XML documents that support custom namespaces
1141
+
1142
+
1143
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
1144
+ return true;
1145
+ } // The code should never reach this place (this means
1146
+ // that the element somehow got namespace that is not
1147
+ // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
1148
+ // Return false just in case.
1149
+
1150
+
1151
+ return false;
1152
+ };
1153
+ /**
1154
+ * _forceRemove
1155
+ *
1156
+ * @param {Node} node a DOM node
1157
+ */
1158
+
1159
+
1160
+ const _forceRemove = function _forceRemove(node) {
1161
+ arrayPush(DOMPurify.removed, {
1162
+ element: node
1163
+ });
1164
+
1165
+ try {
1166
+ // eslint-disable-next-line unicorn/prefer-dom-node-remove
1167
+ node.parentNode.removeChild(node);
1168
+ } catch (_) {
1169
+ node.remove();
1170
+ }
1171
+ };
1172
+ /**
1173
+ * _removeAttribute
1174
+ *
1175
+ * @param {String} name an Attribute name
1176
+ * @param {Node} node a DOM node
1177
+ */
1178
+
1179
+
1180
+ const _removeAttribute = function _removeAttribute(name, node) {
1181
+ try {
1182
+ arrayPush(DOMPurify.removed, {
1183
+ attribute: node.getAttributeNode(name),
1184
+ from: node
1185
+ });
1186
+ } catch (_) {
1187
+ arrayPush(DOMPurify.removed, {
1188
+ attribute: null,
1189
+ from: node
1190
+ });
1191
+ }
1192
+
1193
+ node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
1194
+
1195
+ if (name === 'is' && !ALLOWED_ATTR[name]) {
1196
+ if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
1197
+ try {
1198
+ _forceRemove(node);
1199
+ } catch (_) {}
1200
+ } else {
1201
+ try {
1202
+ node.setAttribute(name, '');
1203
+ } catch (_) {}
1204
+ }
1205
+ }
1206
+ };
1207
+ /**
1208
+ * _initDocument
1209
+ *
1210
+ * @param {String} dirty a string of dirty markup
1211
+ * @return {Document} a DOM, filled with the dirty markup
1212
+ */
1213
+
1214
+
1215
+ const _initDocument = function _initDocument(dirty) {
1216
+ /* Create a HTML document */
1217
+ let doc;
1218
+ let leadingWhitespace;
1219
+
1220
+ if (FORCE_BODY) {
1221
+ dirty = '<remove></remove>' + dirty;
1222
+ } else {
1223
+ /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
1224
+ const matches = stringMatch(dirty, /^[\r\n\t ]+/);
1225
+ leadingWhitespace = matches && matches[0];
1226
+ }
1227
+
1228
+ if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
1229
+ // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
1230
+ dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
1231
+ }
1232
+
1233
+ const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
1234
+ /*
1235
+ * Use the DOMParser API by default, fallback later if needs be
1236
+ * DOMParser not work for svg when has multiple root element.
1237
+ */
1238
+
1239
+ if (NAMESPACE === HTML_NAMESPACE) {
1240
+ try {
1241
+ doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
1242
+ } catch (_) {}
1243
+ }
1244
+ /* Use createHTMLDocument in case DOMParser is not available */
1245
+
1246
+
1247
+ if (!doc || !doc.documentElement) {
1248
+ doc = implementation.createDocument(NAMESPACE, 'template', null);
1249
+
1250
+ try {
1251
+ doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
1252
+ } catch (_) {// Syntax error if dirtyPayload is invalid xml
1253
+ }
1254
+ }
1255
+
1256
+ const body = doc.body || doc.documentElement;
1257
+
1258
+ if (dirty && leadingWhitespace) {
1259
+ body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
1260
+ }
1261
+ /* Work on whole document or just its body */
1262
+
1263
+
1264
+ if (NAMESPACE === HTML_NAMESPACE) {
1265
+ return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
1266
+ }
1267
+
1268
+ return WHOLE_DOCUMENT ? doc.documentElement : body;
1269
+ };
1270
+ /**
1271
+ * _createIterator
1272
+ *
1273
+ * @param {Document} root document/fragment to create iterator for
1274
+ * @return {Iterator} iterator instance
1275
+ */
1276
+
1277
+
1278
+ const _createIterator = function _createIterator(root) {
1279
+ return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
1280
+ NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
1281
+ };
1282
+ /**
1283
+ * _isClobbered
1284
+ *
1285
+ * @param {Node} elm element to check for clobbering attacks
1286
+ * @return {Boolean} true if clobbered, false if safe
1287
+ */
1288
+
1289
+
1290
+ const _isClobbered = function _isClobbered(elm) {
1291
+ return elm instanceof HTMLFormElement && (typeof elm.nodeName !== 'string' || typeof elm.textContent !== 'string' || typeof elm.removeChild !== 'function' || !(elm.attributes instanceof NamedNodeMap) || typeof elm.removeAttribute !== 'function' || typeof elm.setAttribute !== 'function' || typeof elm.namespaceURI !== 'string' || typeof elm.insertBefore !== 'function' || typeof elm.hasChildNodes !== 'function');
1292
+ };
1293
+ /**
1294
+ * _isNode
1295
+ *
1296
+ * @param {Node} obj object to check whether it's a DOM node
1297
+ * @return {Boolean} true is object is a DOM node
1298
+ */
1299
+
1300
+
1301
+ const _isNode = function _isNode(object) {
1302
+ return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
1303
+ };
1304
+ /**
1305
+ * _executeHook
1306
+ * Execute user configurable hooks
1307
+ *
1308
+ * @param {String} entryPoint Name of the hook's entry point
1309
+ * @param {Node} currentNode node to work on with the hook
1310
+ * @param {Object} data additional hook parameters
1311
+ */
1312
+
1313
+
1314
+ const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1315
+ if (!hooks[entryPoint]) {
1316
+ return;
1317
+ }
1318
+
1319
+ arrayForEach(hooks[entryPoint], hook => {
1320
+ hook.call(DOMPurify, currentNode, data, CONFIG);
1321
+ });
1322
+ };
1323
+ /**
1324
+ * _sanitizeElements
1325
+ *
1326
+ * @protect nodeName
1327
+ * @protect textContent
1328
+ * @protect removeChild
1329
+ *
1330
+ * @param {Node} currentNode to check for permission to exist
1331
+ * @return {Boolean} true if node was killed, false if left alive
1332
+ */
1333
+
1334
+
1335
+ const _sanitizeElements = function _sanitizeElements(currentNode) {
1336
+ let content;
1337
+ /* Execute a hook if present */
1338
+
1339
+ _executeHook('beforeSanitizeElements', currentNode, null);
1340
+ /* Check if element is clobbered or can clobber */
1341
+
1342
+
1343
+ if (_isClobbered(currentNode)) {
1344
+ _forceRemove(currentNode);
1345
+
1346
+ return true;
1347
+ }
1348
+ /* Now let's check the element's type and name */
1349
+
1350
+
1351
+ const tagName = transformCaseFunc(currentNode.nodeName);
1352
+ /* Execute a hook if present */
1353
+
1354
+ _executeHook('uponSanitizeElement', currentNode, {
1355
+ tagName,
1356
+ allowedTags: ALLOWED_TAGS
1357
+ });
1358
+ /* Detect mXSS attempts abusing namespace confusion */
1359
+
1360
+
1361
+ if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1362
+ _forceRemove(currentNode);
1363
+
1364
+ return true;
1365
+ }
1366
+ /* Remove element if anything forbids its presence */
1367
+
1368
+
1369
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1370
+ /* Check if we have a custom element to handle */
1371
+ if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
1372
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1373
+ if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1374
+ }
1375
+ /* Keep content except for bad-listed elements */
1376
+
1377
+
1378
+ if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1379
+ const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1380
+ const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1381
+
1382
+ if (childNodes && parentNode) {
1383
+ const childCount = childNodes.length;
1384
+
1385
+ for (let i = childCount - 1; i >= 0; --i) {
1386
+ parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1387
+ }
1388
+ }
1389
+ }
1390
+
1391
+ _forceRemove(currentNode);
1392
+
1393
+ return true;
1394
+ }
1395
+ /* Check whether element has a valid namespace */
1396
+
1397
+
1398
+ if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1399
+ _forceRemove(currentNode);
1400
+
1401
+ return true;
1402
+ }
1403
+ /* Make sure that older browsers don't get fallback-tag mXSS */
1404
+
1405
+
1406
+ if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) {
1407
+ _forceRemove(currentNode);
1408
+
1409
+ return true;
1410
+ }
1411
+ /* Sanitize element content to be template-safe */
1412
+
1413
+
1414
+ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1415
+ /* Get the element's text content */
1416
+ content = currentNode.textContent;
1417
+ content = stringReplace(content, MUSTACHE_EXPR, ' ');
1418
+ content = stringReplace(content, ERB_EXPR, ' ');
1419
+ content = stringReplace(content, TMPLIT_EXPR, ' ');
1420
+
1421
+ if (currentNode.textContent !== content) {
1422
+ arrayPush(DOMPurify.removed, {
1423
+ element: currentNode.cloneNode()
1424
+ });
1425
+ currentNode.textContent = content;
1426
+ }
1427
+ }
1428
+ /* Execute a hook if present */
1429
+
1430
+
1431
+ _executeHook('afterSanitizeElements', currentNode, null);
1432
+
1433
+ return false;
1434
+ };
1435
+ /**
1436
+ * _isValidAttribute
1437
+ *
1438
+ * @param {string} lcTag Lowercase tag name of containing element.
1439
+ * @param {string} lcName Lowercase attribute name.
1440
+ * @param {string} value Attribute value.
1441
+ * @return {Boolean} Returns true if `value` is valid, otherwise false.
1442
+ */
1443
+ // eslint-disable-next-line complexity
1444
+
1445
+
1446
+ const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1447
+ /* Make sure attribute cannot clobber */
1448
+ if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1449
+ return false;
1450
+ }
1451
+ /* Allow valid data-* attributes: At least one character after "-"
1452
+ (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1453
+ XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1454
+ We don't need to check the value; it's always URI safe. */
1455
+
1456
+
1457
+ if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {
1458
+ if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1459
+ // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1460
+ // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1461
+ _basicCustomElementTest(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName)) || // Alternative, second condition checks if it's an `is`-attribute, AND
1462
+ // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1463
+ lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {
1464
+ return false;
1465
+ }
1466
+ /* Check value is safe. First, is attr inert? If so, is safe */
1467
+
1468
+ } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {
1469
+ return false;
1470
+ } else ;
1471
+
1472
+ return true;
1473
+ };
1474
+ /**
1475
+ * _basicCustomElementCheck
1476
+ * checks if at least one dash is included in tagName, and it's not the first char
1477
+ * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1478
+ * @param {string} tagName name of the tag of the node to sanitize
1479
+ */
1480
+
1481
+
1482
+ const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1483
+ return tagName.indexOf('-') > 0;
1484
+ };
1485
+ /**
1486
+ * _sanitizeAttributes
1487
+ *
1488
+ * @protect attributes
1489
+ * @protect nodeName
1490
+ * @protect removeAttribute
1491
+ * @protect setAttribute
1492
+ *
1493
+ * @param {Node} currentNode to sanitize
1494
+ */
1495
+
1496
+
1497
+ const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1498
+ let attr;
1499
+ let value;
1500
+ let lcName;
1501
+ let l;
1502
+ /* Execute a hook if present */
1503
+
1504
+ _executeHook('beforeSanitizeAttributes', currentNode, null);
1505
+
1506
+ const {
1507
+ attributes
1508
+ } = currentNode;
1509
+ /* Check if we have attributes; if not we might have a text node */
1510
+
1511
+ if (!attributes) {
1512
+ return;
1513
+ }
1514
+
1515
+ const hookEvent = {
1516
+ attrName: '',
1517
+ attrValue: '',
1518
+ keepAttr: true,
1519
+ allowedAttributes: ALLOWED_ATTR
1520
+ };
1521
+ l = attributes.length;
1522
+ /* Go backwards over all attributes; safely remove bad ones */
1523
+
1524
+ while (l--) {
1525
+ attr = attributes[l];
1526
+ const {
1527
+ name,
1528
+ namespaceURI
1529
+ } = attr;
1530
+ value = name === 'value' ? attr.value : stringTrim(attr.value);
1531
+ lcName = transformCaseFunc(name);
1532
+ /* Execute a hook if present */
1533
+
1534
+ hookEvent.attrName = lcName;
1535
+ hookEvent.attrValue = value;
1536
+ hookEvent.keepAttr = true;
1537
+ hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1538
+
1539
+ _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1540
+
1541
+ value = hookEvent.attrValue;
1542
+ /* Did the hooks approve of the attribute? */
1543
+
1544
+ if (hookEvent.forceKeepAttr) {
1545
+ continue;
1546
+ }
1547
+ /* Remove attribute */
1548
+
1549
+
1550
+ _removeAttribute(name, currentNode);
1551
+ /* Did the hooks approve of the attribute? */
1552
+
1553
+
1554
+ if (!hookEvent.keepAttr) {
1555
+ continue;
1556
+ }
1557
+ /* Work around a security issue in jQuery 3.0 */
1558
+
1559
+
1560
+ if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1561
+ _removeAttribute(name, currentNode);
1562
+
1563
+ continue;
1564
+ }
1565
+ /* Sanitize attribute content to be template-safe */
1566
+
1567
+
1568
+ if (SAFE_FOR_TEMPLATES) {
1569
+ value = stringReplace(value, MUSTACHE_EXPR, ' ');
1570
+ value = stringReplace(value, ERB_EXPR, ' ');
1571
+ value = stringReplace(value, TMPLIT_EXPR, ' ');
1572
+ }
1573
+ /* Is `value` valid for this attribute? */
1574
+
1575
+
1576
+ const lcTag = transformCaseFunc(currentNode.nodeName);
1577
+
1578
+ if (!_isValidAttribute(lcTag, lcName, value)) {
1579
+ continue;
1580
+ }
1581
+ /* Full DOM Clobbering protection via namespace isolation,
1582
+ * Prefix id and name attributes with `user-content-`
1583
+ */
1584
+
1585
+
1586
+ if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1587
+ // Remove the attribute with this value
1588
+ _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
1589
+
1590
+
1591
+ value = SANITIZE_NAMED_PROPS_PREFIX + value;
1592
+ }
1593
+ /* Handle attributes that require Trusted Types */
1594
+
1595
+
1596
+ if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1597
+ if (namespaceURI) ; else {
1598
+ switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1599
+ case 'TrustedHTML':
1600
+ {
1601
+ value = trustedTypesPolicy.createHTML(value);
1602
+ break;
1603
+ }
1604
+
1605
+ case 'TrustedScriptURL':
1606
+ {
1607
+ value = trustedTypesPolicy.createScriptURL(value);
1608
+ break;
1609
+ }
1610
+ }
1611
+ }
1612
+ }
1613
+ /* Handle invalid data-* attribute set by try-catching it */
1614
+
1615
+
1616
+ try {
1617
+ if (namespaceURI) {
1618
+ currentNode.setAttributeNS(namespaceURI, name, value);
1619
+ } else {
1620
+ /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1621
+ currentNode.setAttribute(name, value);
1622
+ }
1623
+
1624
+ arrayPop(DOMPurify.removed);
1625
+ } catch (_) {}
1626
+ }
1627
+ /* Execute a hook if present */
1628
+
1629
+
1630
+ _executeHook('afterSanitizeAttributes', currentNode, null);
1631
+ };
1632
+ /**
1633
+ * _sanitizeShadowDOM
1634
+ *
1635
+ * @param {DocumentFragment} fragment to iterate over recursively
1636
+ */
1637
+
1638
+
1639
+ const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1640
+ let shadowNode;
1641
+
1642
+ const shadowIterator = _createIterator(fragment);
1643
+ /* Execute a hook if present */
1644
+
1645
+
1646
+ _executeHook('beforeSanitizeShadowDOM', fragment, null);
1647
+
1648
+ while (shadowNode = shadowIterator.nextNode()) {
1649
+ /* Execute a hook if present */
1650
+ _executeHook('uponSanitizeShadowNode', shadowNode, null);
1651
+ /* Sanitize tags and elements */
1652
+
1653
+
1654
+ if (_sanitizeElements(shadowNode)) {
1655
+ continue;
1656
+ }
1657
+ /* Deep shadow DOM detected */
1658
+
1659
+
1660
+ if (shadowNode.content instanceof DocumentFragment) {
1661
+ _sanitizeShadowDOM(shadowNode.content);
1662
+ }
1663
+ /* Check attributes, sanitize if necessary */
1664
+
1665
+
1666
+ _sanitizeAttributes(shadowNode);
1667
+ }
1668
+ /* Execute a hook if present */
1669
+
1670
+
1671
+ _executeHook('afterSanitizeShadowDOM', fragment, null);
1672
+ };
1673
+ /**
1674
+ * Sanitize
1675
+ * Public method providing core sanitation functionality
1676
+ *
1677
+ * @param {String|Node} dirty string or DOM node
1678
+ * @param {Object} configuration object
1679
+ */
1680
+ // eslint-disable-next-line complexity
1681
+
1682
+
1683
+ DOMPurify.sanitize = function (dirty) {
1684
+ let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1685
+ let body;
1686
+ let importedNode;
1687
+ let currentNode;
1688
+ let returnNode;
1689
+ /* Make sure we have a string to sanitize.
1690
+ DO NOT return early, as this will return the wrong type if
1691
+ the user has requested a DOM object rather than a string */
1692
+
1693
+ IS_EMPTY_INPUT = !dirty;
1694
+
1695
+ if (IS_EMPTY_INPUT) {
1696
+ dirty = '<!-->';
1697
+ }
1698
+ /* Stringify, in case dirty is an object */
1699
+
1700
+
1701
+ if (typeof dirty !== 'string' && !_isNode(dirty)) {
1702
+ if (typeof dirty.toString === 'function') {
1703
+ dirty = dirty.toString();
1704
+
1705
+ if (typeof dirty !== 'string') {
1706
+ throw typeErrorCreate('dirty is not a string, aborting');
1707
+ }
1708
+ } else {
1709
+ throw typeErrorCreate('toString is not a function');
1710
+ }
1711
+ }
1712
+ /* Return dirty HTML if DOMPurify cannot run */
1713
+
1714
+
1715
+ if (!DOMPurify.isSupported) {
1716
+ return dirty;
1717
+ }
1718
+ /* Assign config vars */
1719
+
1720
+
1721
+ if (!SET_CONFIG) {
1722
+ _parseConfig(cfg);
1723
+ }
1724
+ /* Clean up removed elements */
1725
+
1726
+
1727
+ DOMPurify.removed = [];
1728
+ /* Check if dirty is correctly typed for IN_PLACE */
1729
+
1730
+ if (typeof dirty === 'string') {
1731
+ IN_PLACE = false;
1732
+ }
1733
+
1734
+ if (IN_PLACE) {
1735
+ /* Do some early pre-sanitization to avoid unsafe root nodes */
1736
+ if (dirty.nodeName) {
1737
+ const tagName = transformCaseFunc(dirty.nodeName);
1738
+
1739
+ if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1740
+ throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1741
+ }
1742
+ }
1743
+ } else if (dirty instanceof Node) {
1744
+ /* If dirty is a DOM element, append to an empty document to avoid
1745
+ elements being stripped by the parser */
1746
+ body = _initDocument('<!---->');
1747
+ importedNode = body.ownerDocument.importNode(dirty, true);
1748
+
1749
+ if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1750
+ /* Node is already a body, use as is */
1751
+ body = importedNode;
1752
+ } else if (importedNode.nodeName === 'HTML') {
1753
+ body = importedNode;
1754
+ } else {
1755
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1756
+ body.appendChild(importedNode);
1757
+ }
1758
+ } else {
1759
+ /* Exit directly if we have nothing to do */
1760
+ if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
1761
+ dirty.indexOf('<') === -1) {
1762
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1763
+ }
1764
+ /* Initialize the document to work on */
1765
+
1766
+
1767
+ body = _initDocument(dirty);
1768
+ /* Check we have a DOM node from the data */
1769
+
1770
+ if (!body) {
1771
+ return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1772
+ }
1773
+ }
1774
+ /* Remove first element node (ours) if FORCE_BODY is set */
1775
+
1776
+
1777
+ if (body && FORCE_BODY) {
1778
+ _forceRemove(body.firstChild);
1779
+ }
1780
+ /* Get node iterator */
1781
+
1782
+
1783
+ const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
1784
+ /* Now start iterating over the created document */
1785
+
1786
+
1787
+ while (currentNode = nodeIterator.nextNode()) {
1788
+ /* Sanitize tags and elements */
1789
+ if (_sanitizeElements(currentNode)) {
1790
+ continue;
1791
+ }
1792
+ /* Shadow DOM detected, sanitize it */
1793
+
1794
+
1795
+ if (currentNode.content instanceof DocumentFragment) {
1796
+ _sanitizeShadowDOM(currentNode.content);
1797
+ }
1798
+ /* Check attributes, sanitize if necessary */
1799
+
1800
+
1801
+ _sanitizeAttributes(currentNode);
1802
+ }
1803
+ /* If we sanitized `dirty` in-place, return it. */
1804
+
1805
+
1806
+ if (IN_PLACE) {
1807
+ return dirty;
1808
+ }
1809
+ /* Return sanitized string or DOM */
1810
+
1811
+
1812
+ if (RETURN_DOM) {
1813
+ if (RETURN_DOM_FRAGMENT) {
1814
+ returnNode = createDocumentFragment.call(body.ownerDocument);
1815
+
1816
+ while (body.firstChild) {
1817
+ // eslint-disable-next-line unicorn/prefer-dom-node-append
1818
+ returnNode.appendChild(body.firstChild);
1819
+ }
1820
+ } else {
1821
+ returnNode = body;
1822
+ }
1823
+
1824
+ if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {
1825
+ /*
1826
+ AdoptNode() is not used because internal state is not reset
1827
+ (e.g. the past names map of a HTMLFormElement), this is safe
1828
+ in theory but we would rather not risk another attack vector.
1829
+ The state that is cloned by importNode() is explicitly defined
1830
+ by the specs.
1831
+ */
1832
+ returnNode = importNode.call(originalDocument, returnNode, true);
1833
+ }
1834
+
1835
+ return returnNode;
1836
+ }
1837
+
1838
+ let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1839
+ /* Serialize doctype if allowed */
1840
+
1841
+ if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1842
+ serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1843
+ }
1844
+ /* Sanitize final string template-safe */
1845
+
1846
+
1847
+ if (SAFE_FOR_TEMPLATES) {
1848
+ serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
1849
+ serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
1850
+ serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
1851
+ }
1852
+
1853
+ return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1854
+ };
1855
+ /**
1856
+ * Public method to set the configuration once
1857
+ * setConfig
1858
+ *
1859
+ * @param {Object} cfg configuration object
1860
+ */
1861
+
1862
+
1863
+ DOMPurify.setConfig = function (cfg) {
1864
+ _parseConfig(cfg);
1865
+
1866
+ SET_CONFIG = true;
1867
+ };
1868
+ /**
1869
+ * Public method to remove the configuration
1870
+ * clearConfig
1871
+ *
1872
+ */
1873
+
1874
+
1875
+ DOMPurify.clearConfig = function () {
1876
+ CONFIG = null;
1877
+ SET_CONFIG = false;
1878
+ };
1879
+ /**
1880
+ * Public method to check if an attribute value is valid.
1881
+ * Uses last set config, if any. Otherwise, uses config defaults.
1882
+ * isValidAttribute
1883
+ *
1884
+ * @param {string} tag Tag name of containing element.
1885
+ * @param {string} attr Attribute name.
1886
+ * @param {string} value Attribute value.
1887
+ * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1888
+ */
1889
+
1890
+
1891
+ DOMPurify.isValidAttribute = function (tag, attr, value) {
1892
+ /* Initialize shared config vars if necessary. */
1893
+ if (!CONFIG) {
1894
+ _parseConfig({});
1895
+ }
1896
+
1897
+ const lcTag = transformCaseFunc(tag);
1898
+ const lcName = transformCaseFunc(attr);
1899
+ return _isValidAttribute(lcTag, lcName, value);
1900
+ };
1901
+ /**
1902
+ * AddHook
1903
+ * Public method to add DOMPurify hooks
1904
+ *
1905
+ * @param {String} entryPoint entry point for the hook to add
1906
+ * @param {Function} hookFunction function to execute
1907
+ */
1908
+
1909
+
1910
+ DOMPurify.addHook = function (entryPoint, hookFunction) {
1911
+ if (typeof hookFunction !== 'function') {
1912
+ return;
1913
+ }
1914
+
1915
+ hooks[entryPoint] = hooks[entryPoint] || [];
1916
+ arrayPush(hooks[entryPoint], hookFunction);
1917
+ };
1918
+ /**
1919
+ * RemoveHook
1920
+ * Public method to remove a DOMPurify hook at a given entryPoint
1921
+ * (pops it from the stack of hooks if more are present)
1922
+ *
1923
+ * @param {String} entryPoint entry point for the hook to remove
1924
+ * @return {Function} removed(popped) hook
1925
+ */
1926
+
1927
+
1928
+ DOMPurify.removeHook = function (entryPoint) {
1929
+ if (hooks[entryPoint]) {
1930
+ return arrayPop(hooks[entryPoint]);
1931
+ }
1932
+ };
1933
+ /**
1934
+ * RemoveHooks
1935
+ * Public method to remove all DOMPurify hooks at a given entryPoint
1936
+ *
1937
+ * @param {String} entryPoint entry point for the hooks to remove
1938
+ */
1939
+
1940
+
1941
+ DOMPurify.removeHooks = function (entryPoint) {
1942
+ if (hooks[entryPoint]) {
1943
+ hooks[entryPoint] = [];
1944
+ }
1945
+ };
1946
+ /**
1947
+ * RemoveAllHooks
1948
+ * Public method to remove all DOMPurify hooks
1949
+ *
1950
+ */
1951
+
1952
+
1953
+ DOMPurify.removeAllHooks = function () {
1954
+ hooks = {};
1955
+ };
1956
+
1957
+ return DOMPurify;
1958
+ }
1959
+
1960
+ var purify = createDOMPurify();
1961
+
1962
+ return purify;
1963
+
1964
+ }));
1965
+
1966
+ } (purify));
1967
+
1968
+ var DOMPurify = purifyExports;
1969
+
1970
+ const min = Math.min;
1971
+ const max = Math.max;
1972
+ const round = Math.round;
1973
+ const floor = Math.floor;
1974
+ const createCoords = v => ({
1975
+ x: v,
1976
+ y: v
1977
+ });
1978
+ function clamp(start, value, end) {
1979
+ return max(start, min(value, end));
1980
+ }
1981
+ function evaluate(value, param) {
1982
+ return typeof value === 'function' ? value(param) : value;
1983
+ }
1984
+ function getSide(placement) {
1985
+ return placement.split('-')[0];
1986
+ }
1987
+ function getAlignment(placement) {
1988
+ return placement.split('-')[1];
1989
+ }
1990
+ function getOppositeAxis(axis) {
1991
+ return axis === 'x' ? 'y' : 'x';
1992
+ }
1993
+ function getAxisLength(axis) {
1994
+ return axis === 'y' ? 'height' : 'width';
1995
+ }
1996
+ function getSideAxis(placement) {
1997
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'y' : 'x';
1998
+ }
1999
+ function getAlignmentAxis(placement) {
2000
+ return getOppositeAxis(getSideAxis(placement));
2001
+ }
2002
+ function expandPaddingObject(padding) {
2003
+ return {
2004
+ top: 0,
2005
+ right: 0,
2006
+ bottom: 0,
2007
+ left: 0,
2008
+ ...padding
2009
+ };
2010
+ }
2011
+ function getPaddingObject(padding) {
2012
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
2013
+ top: padding,
2014
+ right: padding,
2015
+ bottom: padding,
2016
+ left: padding
2017
+ };
2018
+ }
2019
+ function rectToClientRect(rect) {
2020
+ return {
2021
+ ...rect,
2022
+ top: rect.y,
2023
+ left: rect.x,
2024
+ right: rect.x + rect.width,
2025
+ bottom: rect.y + rect.height
2026
+ };
2027
+ }
2028
+
2029
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
2030
+ let {
2031
+ reference,
2032
+ floating
2033
+ } = _ref;
2034
+ const sideAxis = getSideAxis(placement);
2035
+ const alignmentAxis = getAlignmentAxis(placement);
2036
+ const alignLength = getAxisLength(alignmentAxis);
2037
+ const side = getSide(placement);
2038
+ const isVertical = sideAxis === 'y';
2039
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
2040
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
2041
+ const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
2042
+ let coords;
2043
+ switch (side) {
2044
+ case 'top':
2045
+ coords = {
2046
+ x: commonX,
2047
+ y: reference.y - floating.height
2048
+ };
2049
+ break;
2050
+ case 'bottom':
2051
+ coords = {
2052
+ x: commonX,
2053
+ y: reference.y + reference.height
2054
+ };
2055
+ break;
2056
+ case 'right':
2057
+ coords = {
2058
+ x: reference.x + reference.width,
2059
+ y: commonY
2060
+ };
2061
+ break;
2062
+ case 'left':
2063
+ coords = {
2064
+ x: reference.x - floating.width,
2065
+ y: commonY
2066
+ };
2067
+ break;
2068
+ default:
2069
+ coords = {
2070
+ x: reference.x,
2071
+ y: reference.y
2072
+ };
2073
+ }
2074
+ switch (getAlignment(placement)) {
2075
+ case 'start':
2076
+ coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
2077
+ break;
2078
+ case 'end':
2079
+ coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
2080
+ break;
2081
+ }
2082
+ return coords;
2083
+ }
2084
+
2085
+ /**
2086
+ * Computes the `x` and `y` coordinates that will place the floating element
2087
+ * next to a reference element when it is given a certain positioning strategy.
2088
+ *
2089
+ * This export does not have any `platform` interface logic. You will need to
2090
+ * write one for the platform you are using Floating UI with.
2091
+ */
2092
+ const computePosition$1 = async (reference, floating, config) => {
2093
+ const {
2094
+ placement = 'bottom',
2095
+ strategy = 'absolute',
2096
+ middleware = [],
2097
+ platform
2098
+ } = config;
2099
+ const validMiddleware = middleware.filter(Boolean);
2100
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
2101
+ let rects = await platform.getElementRects({
2102
+ reference,
2103
+ floating,
2104
+ strategy
2105
+ });
2106
+ let {
2107
+ x,
2108
+ y
2109
+ } = computeCoordsFromPlacement(rects, placement, rtl);
2110
+ let statefulPlacement = placement;
2111
+ let middlewareData = {};
2112
+ let resetCount = 0;
2113
+ for (let i = 0; i < validMiddleware.length; i++) {
2114
+ const {
2115
+ name,
2116
+ fn
2117
+ } = validMiddleware[i];
2118
+ const {
2119
+ x: nextX,
2120
+ y: nextY,
2121
+ data,
2122
+ reset
2123
+ } = await fn({
2124
+ x,
2125
+ y,
2126
+ initialPlacement: placement,
2127
+ placement: statefulPlacement,
2128
+ strategy,
2129
+ middlewareData,
2130
+ rects,
2131
+ platform,
2132
+ elements: {
2133
+ reference,
2134
+ floating
2135
+ }
2136
+ });
2137
+ x = nextX != null ? nextX : x;
2138
+ y = nextY != null ? nextY : y;
2139
+ middlewareData = {
2140
+ ...middlewareData,
2141
+ [name]: {
2142
+ ...middlewareData[name],
2143
+ ...data
2144
+ }
2145
+ };
2146
+ if (reset && resetCount <= 50) {
2147
+ resetCount++;
2148
+ if (typeof reset === 'object') {
2149
+ if (reset.placement) {
2150
+ statefulPlacement = reset.placement;
2151
+ }
2152
+ if (reset.rects) {
2153
+ rects = reset.rects === true ? await platform.getElementRects({
2154
+ reference,
2155
+ floating,
2156
+ strategy
2157
+ }) : reset.rects;
2158
+ }
2159
+ ({
2160
+ x,
2161
+ y
2162
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
2163
+ }
2164
+ i = -1;
2165
+ continue;
2166
+ }
2167
+ }
2168
+ return {
2169
+ x,
2170
+ y,
2171
+ placement: statefulPlacement,
2172
+ strategy,
2173
+ middlewareData
2174
+ };
2175
+ };
2176
+
2177
+ /**
2178
+ * Provides data to position an inner element of the floating element so that it
2179
+ * appears centered to the reference element.
2180
+ * @see https://floating-ui.com/docs/arrow
2181
+ */
2182
+ const arrow = options => ({
2183
+ name: 'arrow',
2184
+ options,
2185
+ async fn(state) {
2186
+ const {
2187
+ x,
2188
+ y,
2189
+ placement,
2190
+ rects,
2191
+ platform,
2192
+ elements
2193
+ } = state;
2194
+ // Since `element` is required, we don't Partial<> the type.
2195
+ const {
2196
+ element,
2197
+ padding = 0
2198
+ } = evaluate(options, state) || {};
2199
+ if (element == null) {
2200
+ return {};
2201
+ }
2202
+ const paddingObject = getPaddingObject(padding);
2203
+ const coords = {
2204
+ x,
2205
+ y
2206
+ };
2207
+ const axis = getAlignmentAxis(placement);
2208
+ const length = getAxisLength(axis);
2209
+ const arrowDimensions = await platform.getDimensions(element);
2210
+ const isYAxis = axis === 'y';
2211
+ const minProp = isYAxis ? 'top' : 'left';
2212
+ const maxProp = isYAxis ? 'bottom' : 'right';
2213
+ const clientProp = isYAxis ? 'clientHeight' : 'clientWidth';
2214
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
2215
+ const startDiff = coords[axis] - rects.reference[axis];
2216
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
2217
+ let clientSize = arrowOffsetParent ? arrowOffsetParent[clientProp] : 0;
2218
+
2219
+ // DOM platform can return `window` as the `offsetParent`.
2220
+ if (!clientSize || !(await (platform.isElement == null ? void 0 : platform.isElement(arrowOffsetParent)))) {
2221
+ clientSize = elements.floating[clientProp] || rects.floating[length];
2222
+ }
2223
+ const centerToReference = endDiff / 2 - startDiff / 2;
2224
+
2225
+ // If the padding is large enough that it causes the arrow to no longer be
2226
+ // centered, modify the padding so that it is centered.
2227
+ const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
2228
+ const minPadding = min(paddingObject[minProp], largestPossiblePadding);
2229
+ const maxPadding = min(paddingObject[maxProp], largestPossiblePadding);
2230
+
2231
+ // Make sure the arrow doesn't overflow the floating element if the center
2232
+ // point is outside the floating element's bounds.
2233
+ const min$1 = minPadding;
2234
+ const max = clientSize - arrowDimensions[length] - maxPadding;
2235
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
2236
+ const offset = clamp(min$1, center, max);
2237
+
2238
+ // If the reference is small enough that the arrow's padding causes it to
2239
+ // to point to nothing for an aligned placement, adjust the offset of the
2240
+ // floating element itself. This stops `shift()` from taking action, but can
2241
+ // be worked around by calling it again after the `arrow()` if desired.
2242
+ const shouldAddOffset = getAlignment(placement) != null && center != offset && rects.reference[length] / 2 - (center < min$1 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
2243
+ const alignmentOffset = shouldAddOffset ? center < min$1 ? min$1 - center : max - center : 0;
2244
+ return {
2245
+ [axis]: coords[axis] - alignmentOffset,
2246
+ data: {
2247
+ [axis]: offset,
2248
+ centerOffset: center - offset + alignmentOffset
2249
+ }
2250
+ };
2251
+ }
2252
+ });
2253
+
2254
+ // For type backwards-compatibility, the `OffsetOptions` type was also
2255
+ // Derivable.
2256
+ async function convertValueToCoords(state, options) {
2257
+ const {
2258
+ placement,
2259
+ platform,
2260
+ elements
2261
+ } = state;
2262
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
2263
+ const side = getSide(placement);
2264
+ const alignment = getAlignment(placement);
2265
+ const isVertical = getSideAxis(placement) === 'y';
2266
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
2267
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
2268
+ const rawValue = evaluate(options, state);
2269
+
2270
+ // eslint-disable-next-line prefer-const
2271
+ let {
2272
+ mainAxis,
2273
+ crossAxis,
2274
+ alignmentAxis
2275
+ } = typeof rawValue === 'number' ? {
2276
+ mainAxis: rawValue,
2277
+ crossAxis: 0,
2278
+ alignmentAxis: null
2279
+ } : {
2280
+ mainAxis: 0,
2281
+ crossAxis: 0,
2282
+ alignmentAxis: null,
2283
+ ...rawValue
2284
+ };
2285
+ if (alignment && typeof alignmentAxis === 'number') {
2286
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
2287
+ }
2288
+ return isVertical ? {
2289
+ x: crossAxis * crossAxisMulti,
2290
+ y: mainAxis * mainAxisMulti
2291
+ } : {
2292
+ x: mainAxis * mainAxisMulti,
2293
+ y: crossAxis * crossAxisMulti
2294
+ };
2295
+ }
2296
+
2297
+ /**
2298
+ * Modifies the placement by translating the floating element along the
2299
+ * specified axes.
2300
+ * A number (shorthand for `mainAxis` or distance), or an axes configuration
2301
+ * object may be passed.
2302
+ * @see https://floating-ui.com/docs/offset
2303
+ */
2304
+ const offset = function (options) {
2305
+ if (options === void 0) {
2306
+ options = 0;
2307
+ }
2308
+ return {
2309
+ name: 'offset',
2310
+ options,
2311
+ async fn(state) {
2312
+ const {
2313
+ x,
2314
+ y
2315
+ } = state;
2316
+ const diffCoords = await convertValueToCoords(state, options);
2317
+ return {
2318
+ x: x + diffCoords.x,
2319
+ y: y + diffCoords.y,
2320
+ data: diffCoords
2321
+ };
2322
+ }
2323
+ };
2324
+ };
2325
+
2326
+ function getNodeName(node) {
2327
+ if (isNode(node)) {
2328
+ return (node.nodeName || '').toLowerCase();
2329
+ }
2330
+ // Mocked nodes in testing environments may not be instances of Node. By
2331
+ // returning `#document` an infinite loop won't occur.
2332
+ // https://github.com/floating-ui/floating-ui/issues/2317
2333
+ return '#document';
2334
+ }
2335
+ function getWindow(node) {
2336
+ var _node$ownerDocument;
2337
+ return (node == null ? void 0 : (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
2338
+ }
2339
+ function getDocumentElement(node) {
2340
+ var _ref;
2341
+ return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
2342
+ }
2343
+ function isNode(value) {
2344
+ return value instanceof Node || value instanceof getWindow(value).Node;
2345
+ }
2346
+ function isElement(value) {
2347
+ return value instanceof Element || value instanceof getWindow(value).Element;
2348
+ }
2349
+ function isHTMLElement(value) {
2350
+ return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
2351
+ }
2352
+ function isShadowRoot(value) {
2353
+ // Browsers without `ShadowRoot` support.
2354
+ if (typeof ShadowRoot === 'undefined') {
2355
+ return false;
2356
+ }
2357
+ return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
2358
+ }
2359
+ function isOverflowElement(element) {
2360
+ const {
2361
+ overflow,
2362
+ overflowX,
2363
+ overflowY,
2364
+ display
2365
+ } = getComputedStyle$1(element);
2366
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !['inline', 'contents'].includes(display);
2367
+ }
2368
+ function isTableElement(element) {
2369
+ return ['table', 'td', 'th'].includes(getNodeName(element));
2370
+ }
2371
+ function isContainingBlock(element) {
2372
+ const webkit = isWebKit();
2373
+ const css = getComputedStyle$1(element);
2374
+
2375
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2376
+ return css.transform !== 'none' || css.perspective !== 'none' || (css.containerType ? css.containerType !== 'normal' : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== 'none' : false) || !webkit && (css.filter ? css.filter !== 'none' : false) || ['transform', 'perspective', 'filter'].some(value => (css.willChange || '').includes(value)) || ['paint', 'layout', 'strict', 'content'].some(value => (css.contain || '').includes(value));
2377
+ }
2378
+ function getContainingBlock(element) {
2379
+ let currentNode = getParentNode(element);
2380
+ while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
2381
+ if (isContainingBlock(currentNode)) {
2382
+ return currentNode;
2383
+ } else {
2384
+ currentNode = getParentNode(currentNode);
2385
+ }
2386
+ }
2387
+ return null;
2388
+ }
2389
+ function isWebKit() {
2390
+ if (typeof CSS === 'undefined' || !CSS.supports) return false;
2391
+ return CSS.supports('-webkit-backdrop-filter', 'none');
2392
+ }
2393
+ function isLastTraversableNode(node) {
2394
+ return ['html', 'body', '#document'].includes(getNodeName(node));
2395
+ }
2396
+ function getComputedStyle$1(element) {
2397
+ return getWindow(element).getComputedStyle(element);
2398
+ }
2399
+ function getNodeScroll(element) {
2400
+ if (isElement(element)) {
2401
+ return {
2402
+ scrollLeft: element.scrollLeft,
2403
+ scrollTop: element.scrollTop
2404
+ };
2405
+ }
2406
+ return {
2407
+ scrollLeft: element.pageXOffset,
2408
+ scrollTop: element.pageYOffset
2409
+ };
2410
+ }
2411
+ function getParentNode(node) {
2412
+ if (getNodeName(node) === 'html') {
2413
+ return node;
2414
+ }
2415
+ const result =
2416
+ // Step into the shadow DOM of the parent of a slotted node.
2417
+ node.assignedSlot ||
2418
+ // DOM Element detected.
2419
+ node.parentNode ||
2420
+ // ShadowRoot detected.
2421
+ isShadowRoot(node) && node.host ||
2422
+ // Fallback.
2423
+ getDocumentElement(node);
2424
+ return isShadowRoot(result) ? result.host : result;
2425
+ }
2426
+ function getNearestOverflowAncestor(node) {
2427
+ const parentNode = getParentNode(node);
2428
+ if (isLastTraversableNode(parentNode)) {
2429
+ return node.ownerDocument ? node.ownerDocument.body : node.body;
2430
+ }
2431
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
2432
+ return parentNode;
2433
+ }
2434
+ return getNearestOverflowAncestor(parentNode);
2435
+ }
2436
+ function getOverflowAncestors(node, list) {
2437
+ var _node$ownerDocument2;
2438
+ if (list === void 0) {
2439
+ list = [];
2440
+ }
2441
+ const scrollableAncestor = getNearestOverflowAncestor(node);
2442
+ const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
2443
+ const win = getWindow(scrollableAncestor);
2444
+ if (isBody) {
2445
+ return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []);
2446
+ }
2447
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor));
2448
+ }
2449
+
2450
+ function getCssDimensions(element) {
2451
+ const css = getComputedStyle$1(element);
2452
+ // In testing environments, the `width` and `height` properties are empty
2453
+ // strings for SVG elements, returning NaN. Fallback to `0` in this case.
2454
+ let width = parseFloat(css.width) || 0;
2455
+ let height = parseFloat(css.height) || 0;
2456
+ const hasOffset = isHTMLElement(element);
2457
+ const offsetWidth = hasOffset ? element.offsetWidth : width;
2458
+ const offsetHeight = hasOffset ? element.offsetHeight : height;
2459
+ const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
2460
+ if (shouldFallback) {
2461
+ width = offsetWidth;
2462
+ height = offsetHeight;
2463
+ }
2464
+ return {
2465
+ width,
2466
+ height,
2467
+ $: shouldFallback
2468
+ };
2469
+ }
2470
+
2471
+ function unwrapElement(element) {
2472
+ return !isElement(element) ? element.contextElement : element;
2473
+ }
2474
+
2475
+ function getScale(element) {
2476
+ const domElement = unwrapElement(element);
2477
+ if (!isHTMLElement(domElement)) {
2478
+ return createCoords(1);
2479
+ }
2480
+ const rect = domElement.getBoundingClientRect();
2481
+ const {
2482
+ width,
2483
+ height,
2484
+ $
2485
+ } = getCssDimensions(domElement);
2486
+ let x = ($ ? round(rect.width) : rect.width) / width;
2487
+ let y = ($ ? round(rect.height) : rect.height) / height;
2488
+
2489
+ // 0, NaN, or Infinity should always fallback to 1.
2490
+
2491
+ if (!x || !Number.isFinite(x)) {
2492
+ x = 1;
2493
+ }
2494
+ if (!y || !Number.isFinite(y)) {
2495
+ y = 1;
2496
+ }
2497
+ return {
2498
+ x,
2499
+ y
2500
+ };
2501
+ }
2502
+
2503
+ const noOffsets = /*#__PURE__*/createCoords(0);
2504
+ function getVisualOffsets(element) {
2505
+ const win = getWindow(element);
2506
+ if (!isWebKit() || !win.visualViewport) {
2507
+ return noOffsets;
2508
+ }
2509
+ return {
2510
+ x: win.visualViewport.offsetLeft,
2511
+ y: win.visualViewport.offsetTop
2512
+ };
2513
+ }
2514
+ function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
2515
+ if (isFixed === void 0) {
2516
+ isFixed = false;
2517
+ }
2518
+ if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
2519
+ return false;
2520
+ }
2521
+ return isFixed;
2522
+ }
2523
+
2524
+ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
2525
+ if (includeScale === void 0) {
2526
+ includeScale = false;
2527
+ }
2528
+ if (isFixedStrategy === void 0) {
2529
+ isFixedStrategy = false;
2530
+ }
2531
+ const clientRect = element.getBoundingClientRect();
2532
+ const domElement = unwrapElement(element);
2533
+ let scale = createCoords(1);
2534
+ if (includeScale) {
2535
+ if (offsetParent) {
2536
+ if (isElement(offsetParent)) {
2537
+ scale = getScale(offsetParent);
2538
+ }
2539
+ } else {
2540
+ scale = getScale(element);
2541
+ }
2542
+ }
2543
+ const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
2544
+ let x = (clientRect.left + visualOffsets.x) / scale.x;
2545
+ let y = (clientRect.top + visualOffsets.y) / scale.y;
2546
+ let width = clientRect.width / scale.x;
2547
+ let height = clientRect.height / scale.y;
2548
+ if (domElement) {
2549
+ const win = getWindow(domElement);
2550
+ const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
2551
+ let currentIFrame = win.frameElement;
2552
+ while (currentIFrame && offsetParent && offsetWin !== win) {
2553
+ const iframeScale = getScale(currentIFrame);
2554
+ const iframeRect = currentIFrame.getBoundingClientRect();
2555
+ const css = getComputedStyle$1(currentIFrame);
2556
+ const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
2557
+ const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
2558
+ x *= iframeScale.x;
2559
+ y *= iframeScale.y;
2560
+ width *= iframeScale.x;
2561
+ height *= iframeScale.y;
2562
+ x += left;
2563
+ y += top;
2564
+ currentIFrame = getWindow(currentIFrame).frameElement;
2565
+ }
2566
+ }
2567
+ return rectToClientRect({
2568
+ width,
2569
+ height,
2570
+ x,
2571
+ y
2572
+ });
2573
+ }
2574
+
2575
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
2576
+ let {
2577
+ rect,
2578
+ offsetParent,
2579
+ strategy
2580
+ } = _ref;
2581
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2582
+ const documentElement = getDocumentElement(offsetParent);
2583
+ if (offsetParent === documentElement) {
2584
+ return rect;
2585
+ }
2586
+ let scroll = {
2587
+ scrollLeft: 0,
2588
+ scrollTop: 0
2589
+ };
2590
+ let scale = createCoords(1);
2591
+ const offsets = createCoords(0);
2592
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
2593
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2594
+ scroll = getNodeScroll(offsetParent);
2595
+ }
2596
+ if (isHTMLElement(offsetParent)) {
2597
+ const offsetRect = getBoundingClientRect(offsetParent);
2598
+ scale = getScale(offsetParent);
2599
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2600
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2601
+ }
2602
+ }
2603
+ return {
2604
+ width: rect.width * scale.x,
2605
+ height: rect.height * scale.y,
2606
+ x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x,
2607
+ y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y
2608
+ };
2609
+ }
2610
+
2611
+ function getClientRects(element) {
2612
+ return Array.from(element.getClientRects());
2613
+ }
2614
+
2615
+ function getWindowScrollBarX(element) {
2616
+ // If <html> has a CSS width greater than the viewport, then this will be
2617
+ // incorrect for RTL.
2618
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
2619
+ }
2620
+
2621
+ // Gets the entire size of the scrollable document area, even extending outside
2622
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable.
2623
+ function getDocumentRect(element) {
2624
+ const html = getDocumentElement(element);
2625
+ const scroll = getNodeScroll(element);
2626
+ const body = element.ownerDocument.body;
2627
+ const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
2628
+ const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
2629
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
2630
+ const y = -scroll.scrollTop;
2631
+ if (getComputedStyle$1(body).direction === 'rtl') {
2632
+ x += max(html.clientWidth, body.clientWidth) - width;
2633
+ }
2634
+ return {
2635
+ width,
2636
+ height,
2637
+ x,
2638
+ y
2639
+ };
2640
+ }
2641
+
2642
+ function getViewportRect(element, strategy) {
2643
+ const win = getWindow(element);
2644
+ const html = getDocumentElement(element);
2645
+ const visualViewport = win.visualViewport;
2646
+ let width = html.clientWidth;
2647
+ let height = html.clientHeight;
2648
+ let x = 0;
2649
+ let y = 0;
2650
+ if (visualViewport) {
2651
+ width = visualViewport.width;
2652
+ height = visualViewport.height;
2653
+ const visualViewportBased = isWebKit();
2654
+ if (!visualViewportBased || visualViewportBased && strategy === 'fixed') {
2655
+ x = visualViewport.offsetLeft;
2656
+ y = visualViewport.offsetTop;
2657
+ }
2658
+ }
2659
+ return {
2660
+ width,
2661
+ height,
2662
+ x,
2663
+ y
2664
+ };
2665
+ }
2666
+
2667
+ // Returns the inner client rect, subtracting scrollbars if present.
2668
+ function getInnerBoundingClientRect(element, strategy) {
2669
+ const clientRect = getBoundingClientRect(element, true, strategy === 'fixed');
2670
+ const top = clientRect.top + element.clientTop;
2671
+ const left = clientRect.left + element.clientLeft;
2672
+ const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
2673
+ const width = element.clientWidth * scale.x;
2674
+ const height = element.clientHeight * scale.y;
2675
+ const x = left * scale.x;
2676
+ const y = top * scale.y;
2677
+ return {
2678
+ width,
2679
+ height,
2680
+ x,
2681
+ y
2682
+ };
2683
+ }
2684
+ function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
2685
+ let rect;
2686
+ if (clippingAncestor === 'viewport') {
2687
+ rect = getViewportRect(element, strategy);
2688
+ } else if (clippingAncestor === 'document') {
2689
+ rect = getDocumentRect(getDocumentElement(element));
2690
+ } else if (isElement(clippingAncestor)) {
2691
+ rect = getInnerBoundingClientRect(clippingAncestor, strategy);
2692
+ } else {
2693
+ const visualOffsets = getVisualOffsets(element);
2694
+ rect = {
2695
+ ...clippingAncestor,
2696
+ x: clippingAncestor.x - visualOffsets.x,
2697
+ y: clippingAncestor.y - visualOffsets.y
2698
+ };
2699
+ }
2700
+ return rectToClientRect(rect);
2701
+ }
2702
+ function hasFixedPositionAncestor(element, stopNode) {
2703
+ const parentNode = getParentNode(element);
2704
+ if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
2705
+ return false;
2706
+ }
2707
+ return getComputedStyle$1(parentNode).position === 'fixed' || hasFixedPositionAncestor(parentNode, stopNode);
2708
+ }
2709
+
2710
+ // A "clipping ancestor" is an `overflow` element with the characteristic of
2711
+ // clipping (or hiding) child elements. This returns all clipping ancestors
2712
+ // of the given element up the tree.
2713
+ function getClippingElementAncestors(element, cache) {
2714
+ const cachedResult = cache.get(element);
2715
+ if (cachedResult) {
2716
+ return cachedResult;
2717
+ }
2718
+ let result = getOverflowAncestors(element).filter(el => isElement(el) && getNodeName(el) !== 'body');
2719
+ let currentContainingBlockComputedStyle = null;
2720
+ const elementIsFixed = getComputedStyle$1(element).position === 'fixed';
2721
+ let currentNode = elementIsFixed ? getParentNode(element) : element;
2722
+
2723
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
2724
+ while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
2725
+ const computedStyle = getComputedStyle$1(currentNode);
2726
+ const currentNodeIsContaining = isContainingBlock(currentNode);
2727
+ if (!currentNodeIsContaining && computedStyle.position === 'fixed') {
2728
+ currentContainingBlockComputedStyle = null;
2729
+ }
2730
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === 'static' && !!currentContainingBlockComputedStyle && ['absolute', 'fixed'].includes(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
2731
+ if (shouldDropCurrentNode) {
2732
+ // Drop non-containing blocks.
2733
+ result = result.filter(ancestor => ancestor !== currentNode);
2734
+ } else {
2735
+ // Record last containing block for next iteration.
2736
+ currentContainingBlockComputedStyle = computedStyle;
2737
+ }
2738
+ currentNode = getParentNode(currentNode);
2739
+ }
2740
+ cache.set(element, result);
2741
+ return result;
2742
+ }
2743
+
2744
+ // Gets the maximum area that the element is visible in due to any number of
2745
+ // clipping ancestors.
2746
+ function getClippingRect(_ref) {
2747
+ let {
2748
+ element,
2749
+ boundary,
2750
+ rootBoundary,
2751
+ strategy
2752
+ } = _ref;
2753
+ const elementClippingAncestors = boundary === 'clippingAncestors' ? getClippingElementAncestors(element, this._c) : [].concat(boundary);
2754
+ const clippingAncestors = [...elementClippingAncestors, rootBoundary];
2755
+ const firstClippingAncestor = clippingAncestors[0];
2756
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
2757
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
2758
+ accRect.top = max(rect.top, accRect.top);
2759
+ accRect.right = min(rect.right, accRect.right);
2760
+ accRect.bottom = min(rect.bottom, accRect.bottom);
2761
+ accRect.left = max(rect.left, accRect.left);
2762
+ return accRect;
2763
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
2764
+ return {
2765
+ width: clippingRect.right - clippingRect.left,
2766
+ height: clippingRect.bottom - clippingRect.top,
2767
+ x: clippingRect.left,
2768
+ y: clippingRect.top
2769
+ };
2770
+ }
2771
+
2772
+ function getDimensions(element) {
2773
+ return getCssDimensions(element);
2774
+ }
2775
+
2776
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
2777
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
2778
+ const documentElement = getDocumentElement(offsetParent);
2779
+ const isFixed = strategy === 'fixed';
2780
+ const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
2781
+ let scroll = {
2782
+ scrollLeft: 0,
2783
+ scrollTop: 0
2784
+ };
2785
+ const offsets = createCoords(0);
2786
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
2787
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
2788
+ scroll = getNodeScroll(offsetParent);
2789
+ }
2790
+ if (isOffsetParentAnElement) {
2791
+ const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
2792
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
2793
+ offsets.y = offsetRect.y + offsetParent.clientTop;
2794
+ } else if (documentElement) {
2795
+ offsets.x = getWindowScrollBarX(documentElement);
2796
+ }
2797
+ }
2798
+ return {
2799
+ x: rect.left + scroll.scrollLeft - offsets.x,
2800
+ y: rect.top + scroll.scrollTop - offsets.y,
2801
+ width: rect.width,
2802
+ height: rect.height
2803
+ };
2804
+ }
2805
+
2806
+ function getTrueOffsetParent(element, polyfill) {
2807
+ if (!isHTMLElement(element) || getComputedStyle$1(element).position === 'fixed') {
2808
+ return null;
2809
+ }
2810
+ if (polyfill) {
2811
+ return polyfill(element);
2812
+ }
2813
+ return element.offsetParent;
2814
+ }
2815
+
2816
+ // Gets the closest ancestor positioned element. Handles some edge cases,
2817
+ // such as table ancestors and cross browser bugs.
2818
+ function getOffsetParent(element, polyfill) {
2819
+ const window = getWindow(element);
2820
+ if (!isHTMLElement(element)) {
2821
+ return window;
2822
+ }
2823
+ let offsetParent = getTrueOffsetParent(element, polyfill);
2824
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') {
2825
+ offsetParent = getTrueOffsetParent(offsetParent, polyfill);
2826
+ }
2827
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
2828
+ return window;
2829
+ }
2830
+ return offsetParent || getContainingBlock(element) || window;
2831
+ }
81
2832
 
82
- /**
83
- * Icon:
84
- * - access to Seeq custom icons by providing the desired icon
85
- * - leverage "type" to style your icon
86
- */
87
- const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipDelay, tooltipPlacement, number, hasExternalTooltipHandler = false, }) => {
88
- if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
89
- const errorMessage = color === undefined || color === ''
90
- ? 'Icon with type="color" must have prop color specified.'
91
- : 'Icon with prop color must have type="color".';
92
- return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
93
- }
94
- const colorClassesThemeLight = {
95
- 'theme': 'tw-text-sq-color-dark',
96
- 'white': 'tw-text-white',
97
- 'dark-gray': 'tw-text-sq-fairly-dark-gray',
98
- 'warning': 'tw-text-sq-warning-color',
99
- 'darkish-gray': 'tw-text-sq-darkish-gray',
100
- 'gray': 'tw-text-sq-disabled-gray',
101
- 'color': '',
102
- 'info': 'tw-text-sq-link',
103
- 'text': 'tw-text-sq-text-color',
104
- 'inherit': '',
105
- 'danger': 'tw-text-sq-danger-color',
106
- 'theme-light': 'tw-text-sq-color-light',
107
- 'success': 'tw-text-sq-success-color',
108
- };
109
- const colorClassesThemeDark = {
110
- 'theme': 'dark:tw-text-sq-color-dark-dark',
111
- 'white': '',
112
- 'dark-gray': 'tw-text-sq-fairly-dark-gray',
113
- 'warning': '',
114
- 'darkish-gray': 'tw-text-sq-darkish-gray',
115
- 'gray': 'dark:tw-text-sq-dark-disabled-gray',
116
- 'color': '',
117
- 'info': 'dark:tw-text-sq-link-dark',
118
- 'text': 'dark:tw-text-sq-dark-text',
119
- 'inherit': '',
120
- 'danger': 'tw-text-sq-danger-color',
121
- 'theme-light': 'tw-text-sq-color-light',
122
- 'success': 'tw-text-sq-success-color',
123
- };
124
- const iconPrefix = icon.startsWith('fc') ? 'fc' : 'fa';
125
- const style = type === 'color' && color ? { color } : {};
126
- const appliedClassNames = `${iconPrefix} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
127
- ${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
128
- const iconTag = (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number }));
129
- return !hasExternalTooltipHandler && tooltip && tooltip !== '' ? (React.createElement(Tooltip, { text: tooltip, delay: tooltipDelay, position: tooltipPlacement }, iconTag)) : (iconTag);
2833
+ const getElementRects = async function (_ref) {
2834
+ let {
2835
+ reference,
2836
+ floating,
2837
+ strategy
2838
+ } = _ref;
2839
+ const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
2840
+ const getDimensionsFn = this.getDimensions;
2841
+ return {
2842
+ reference: getRectRelativeToOffsetParent(reference, await getOffsetParentFn(floating), strategy),
2843
+ floating: {
2844
+ x: 0,
2845
+ y: 0,
2846
+ ...(await getDimensionsFn(floating))
2847
+ }
2848
+ };
130
2849
  };
131
2850
 
132
- /**
133
- * All-in-one Button:
134
- * - use "variant" to achieve the desired style
135
- * - include tooltips and/or icons
136
- */
137
- const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, preventBlur = false, }) => {
138
- const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
139
- const baseClassesByVariant = {
140
- 'outline': 'tw-border-solid tw-border',
141
- 'theme': 'disabled:tw-opacity-50',
142
- 'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-opacity-50',
143
- 'theme-light': 'disabled:tw-opacity-50',
144
- 'no-border': '',
145
- 'warning': 'tw-bg-sq-warning-color',
146
- };
147
- const textClassesByVariantLightTheme = {
148
- 'outline': 'tw-text-sq-text-color',
149
- 'theme': 'tw-text-white',
150
- 'theme-light': 'tw-text-white',
151
- 'danger': 'tw-text-white',
152
- 'no-border': 'tw-text-sq-text-color',
153
- 'warning': 'tw-text-white',
154
- };
155
- const textClassesByVariantDarkTheme = {
156
- 'outline': 'dark:tw-text-sq-dark-text',
157
- 'theme': 'dark:tw-text-white',
158
- 'theme-light': 'dark:tw-text-white',
159
- 'danger': 'dark:tw-text-white',
160
- 'no-border': 'dark:tw-text-sq-dark-text',
161
- 'warning': 'dark:tw-text-white',
162
- };
163
- const classesByVariantLightTheme = {
164
- 'outline': 'tw-border-sq-disabled-gray hover:tw-bg-sq-light-gray' +
165
- ' focus:tw-bg-sq-dark-gray active:tw-bg-sq-dark-gray focus:tw-border-sq-color-dark active:tw-border-sq-color-dark',
166
- 'theme': 'tw-bg-sq-color-dark hover:tw-bg-sq-color-highlight',
167
- 'danger': '',
168
- 'theme-light': 'tw-bg-sq-icon hover:tw-bg-sq-link',
169
- 'no-border': '',
170
- 'warning': 'tw-bg-sq-warning-color',
171
- };
172
- const classesByVariantDarkTheme = {
173
- 'outline': 'dark:tw-border-sq-dark-disabled-gray dark:hover:tw-bg-sq-highlight-color-dark' +
174
- ' dark:focus:tw-bg-sq-dark-gray dark:active:tw-bg-sq-dark-gray dark:focus:tw-border-sq-color-dark' +
175
- ' dark:active:tw-border-sq-color-dark',
176
- 'theme': 'dark:tw-bg-sq-color-dark dark:hover:tw-bg-sq-color-highlight',
177
- 'danger': '',
178
- 'theme-light': 'dark:tw-bg-sq-icon-dark dark:hover:tw-bg-sq-link-dark',
179
- 'no-border': '',
180
- 'warning': '',
181
- };
182
- const sizeClasses = {
183
- sm: 'tw-text-sm',
184
- lg: 'tw-text-xl',
185
- };
186
- const appliedClasses = `${baseClasses} ${baseClassesByVariant[variant]} ${sizeClasses[size]} ${classesByVariantLightTheme[variant]} ${classesByVariantDarkTheme[variant]} ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]} ${extraClassNames}`;
187
- const button = (React.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
188
- stopPropagation && e.stopPropagation();
189
- onClick && onClick();
190
- }, onMouseDown: (e) => {
191
- if (preventBlur) {
192
- e.preventDefault();
193
- }
194
- }, className: appliedClasses },
195
- icon && (React.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` })),
196
- label));
197
- return tooltip ? (React.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
2851
+ function isRTL(element) {
2852
+ return getComputedStyle$1(element).direction === 'rtl';
2853
+ }
2854
+
2855
+ const platform = {
2856
+ convertOffsetParentRelativeRectToViewportRelativeRect,
2857
+ getDocumentElement,
2858
+ getClippingRect,
2859
+ getOffsetParent,
2860
+ getElementRects,
2861
+ getClientRects,
2862
+ getDimensions,
2863
+ getScale,
2864
+ isElement,
2865
+ isRTL
2866
+ };
2867
+
2868
+ // https://samthor.au/2021/observing-dom/
2869
+ function observeMove(element, onMove) {
2870
+ let io = null;
2871
+ let timeoutId;
2872
+ const root = getDocumentElement(element);
2873
+ function cleanup() {
2874
+ clearTimeout(timeoutId);
2875
+ io && io.disconnect();
2876
+ io = null;
2877
+ }
2878
+ function refresh(skip, threshold) {
2879
+ if (skip === void 0) {
2880
+ skip = false;
2881
+ }
2882
+ if (threshold === void 0) {
2883
+ threshold = 1;
2884
+ }
2885
+ cleanup();
2886
+ const {
2887
+ left,
2888
+ top,
2889
+ width,
2890
+ height
2891
+ } = element.getBoundingClientRect();
2892
+ if (!skip) {
2893
+ onMove();
2894
+ }
2895
+ if (!width || !height) {
2896
+ return;
2897
+ }
2898
+ const insetTop = floor(top);
2899
+ const insetRight = floor(root.clientWidth - (left + width));
2900
+ const insetBottom = floor(root.clientHeight - (top + height));
2901
+ const insetLeft = floor(left);
2902
+ const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
2903
+ const options = {
2904
+ rootMargin,
2905
+ threshold: max(0, min(1, threshold)) || 1
2906
+ };
2907
+ let isFirstUpdate = true;
2908
+ function handleObserve(entries) {
2909
+ const ratio = entries[0].intersectionRatio;
2910
+ if (ratio !== threshold) {
2911
+ if (!isFirstUpdate) {
2912
+ return refresh();
2913
+ }
2914
+ if (!ratio) {
2915
+ timeoutId = setTimeout(() => {
2916
+ refresh(false, 1e-7);
2917
+ }, 100);
2918
+ } else {
2919
+ refresh(false, ratio);
2920
+ }
2921
+ }
2922
+ isFirstUpdate = false;
2923
+ }
2924
+
2925
+ // Older browsers don't support a `document` as the root and will throw an
2926
+ // error.
2927
+ try {
2928
+ io = new IntersectionObserver(handleObserve, {
2929
+ ...options,
2930
+ // Handle <iframe>s
2931
+ root: root.ownerDocument
2932
+ });
2933
+ } catch (e) {
2934
+ io = new IntersectionObserver(handleObserve, options);
2935
+ }
2936
+ io.observe(element);
2937
+ }
2938
+ refresh(true);
2939
+ return cleanup;
2940
+ }
2941
+
2942
+ /**
2943
+ * Automatically updates the position of the floating element when necessary.
2944
+ * Should only be called when the floating element is mounted on the DOM or
2945
+ * visible on the screen.
2946
+ * @returns cleanup function that should be invoked when the floating element is
2947
+ * removed from the DOM or hidden from the screen.
2948
+ * @see https://floating-ui.com/docs/autoUpdate
2949
+ */
2950
+ function autoUpdate(reference, floating, update, options) {
2951
+ if (options === void 0) {
2952
+ options = {};
2953
+ }
2954
+ const {
2955
+ ancestorScroll = true,
2956
+ ancestorResize = true,
2957
+ elementResize = typeof ResizeObserver === 'function',
2958
+ layoutShift = typeof IntersectionObserver === 'function',
2959
+ animationFrame = false
2960
+ } = options;
2961
+ const referenceEl = unwrapElement(reference);
2962
+ const ancestors = ancestorScroll || ancestorResize ? [...(referenceEl ? getOverflowAncestors(referenceEl) : []), ...getOverflowAncestors(floating)] : [];
2963
+ ancestors.forEach(ancestor => {
2964
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
2965
+ passive: true
2966
+ });
2967
+ ancestorResize && ancestor.addEventListener('resize', update);
2968
+ });
2969
+ const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update) : null;
2970
+ let reobserveFrame = -1;
2971
+ let resizeObserver = null;
2972
+ if (elementResize) {
2973
+ resizeObserver = new ResizeObserver(_ref => {
2974
+ let [firstEntry] = _ref;
2975
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
2976
+ // Prevent update loops when using the `size` middleware.
2977
+ // https://github.com/floating-ui/floating-ui/issues/1740
2978
+ resizeObserver.unobserve(floating);
2979
+ cancelAnimationFrame(reobserveFrame);
2980
+ reobserveFrame = requestAnimationFrame(() => {
2981
+ resizeObserver && resizeObserver.observe(floating);
2982
+ });
2983
+ }
2984
+ update();
2985
+ });
2986
+ if (referenceEl && !animationFrame) {
2987
+ resizeObserver.observe(referenceEl);
2988
+ }
2989
+ resizeObserver.observe(floating);
2990
+ }
2991
+ let frameId;
2992
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
2993
+ if (animationFrame) {
2994
+ frameLoop();
2995
+ }
2996
+ function frameLoop() {
2997
+ const nextRefRect = getBoundingClientRect(reference);
2998
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
2999
+ update();
3000
+ }
3001
+ prevRefRect = nextRefRect;
3002
+ frameId = requestAnimationFrame(frameLoop);
3003
+ }
3004
+ update();
3005
+ return () => {
3006
+ ancestors.forEach(ancestor => {
3007
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
3008
+ ancestorResize && ancestor.removeEventListener('resize', update);
3009
+ });
3010
+ cleanupIo && cleanupIo();
3011
+ resizeObserver && resizeObserver.disconnect();
3012
+ resizeObserver = null;
3013
+ if (animationFrame) {
3014
+ cancelAnimationFrame(frameId);
3015
+ }
3016
+ };
3017
+ }
3018
+
3019
+ /**
3020
+ * Computes the `x` and `y` coordinates that will place the floating element
3021
+ * next to a reference element when it is given a certain CSS positioning
3022
+ * strategy.
3023
+ */
3024
+ const computePosition = (reference, floating, options) => {
3025
+ // This caches the expensive `getClippingElementAncestors` function so that
3026
+ // multiple lifecycle resets re-use the same result. It only lives for a
3027
+ // single call. If other functions become expensive, we can add them as well.
3028
+ const cache = new Map();
3029
+ const mergedOptions = {
3030
+ platform,
3031
+ ...options
3032
+ };
3033
+ const platformWithCache = {
3034
+ ...mergedOptions.platform,
3035
+ _c: cache
3036
+ };
3037
+ return computePosition$1(reference, floating, {
3038
+ ...mergedOptions,
3039
+ platform: platformWithCache
3040
+ });
198
3041
  };
199
3042
 
200
- const errorClasses$2 = 'tw-border-sq-danger-color';
201
- const borderColorClasses$2 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
202
- const baseClasses$3 = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
203
- ' disabled:tw-pointer-events-none' +
204
- ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
205
- ' dark:tw-placeholder-sq-dark-text-lighter specTextField';
206
- const darkTheme$1 = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
207
- ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
208
- const lightTheme$1 = 'tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
209
- const sizeClasses = {
210
- sm: 'tw-text-sm',
211
- lg: 'tw-text-xl',
212
- };
3043
+ const noop$1 = () => { };
3044
+
213
3045
  /**
214
- * Textfield.
3046
+ * A setInterval hook that calls a callback after a interval duration
3047
+ * when a condition is true
3048
+ *
3049
+ * @param callback The callback to be invoked after interval
3050
+ * @param intervalDurationMs Amount of time in ms after which to invoke
3051
+ * @param when The condition which when true, sets the interval
3052
+ * @param startImmediate If the callback should be invoked immediately
3053
+ * @see https://rooks.vercel.app/docs/useIntervalWhen
215
3054
  */
216
- const TextField = React.forwardRef((props, ref) => {
217
- const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, showError, } = props;
218
- const internalRef = React.useRef(null);
219
- const [cursor, setCursor] = React.useState(null);
220
- const setAllRefs = (receivedRef) => {
221
- if (ref)
222
- ref.current = receivedRef;
223
- internalRef.current = receivedRef;
224
- };
3055
+ function useIntervalWhen(callback, intervalDurationMs = 0, when = true, startImmediate = false) {
3056
+ const savedRefCallback = React.useRef();
225
3057
  React.useEffect(() => {
226
- const input = internalRef.current;
227
- if (input && type !== 'number')
228
- input.setSelectionRange(cursor, cursor);
229
- }, [ref, cursor, value]);
230
- const handleChange = (e) => {
231
- setCursor(e.target.selectionStart);
232
- onChange && onChange(e);
233
- };
3058
+ savedRefCallback.current = callback;
3059
+ });
234
3060
  React.useEffect(() => {
235
- /**
236
- * we need to change the value only if it's different since the internal state of "input" will change it anyway
237
- * this will only be the case when the value has been changed externally via store (undo / redo)
238
- */
239
- if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
240
- // we need to use this method because using the value props directly will switch the input to a "controlled"
241
- // component
242
- internalRef.current.value = `${value}`;
3061
+ if (when) {
3062
+ function internalCallback() {
3063
+ var _a;
3064
+ (_a = savedRefCallback.current) === null || _a === void 0 ? void 0 : _a.call(savedRefCallback);
3065
+ }
3066
+ if (startImmediate) {
3067
+ internalCallback();
3068
+ }
3069
+ const interval = window.setInterval(internalCallback, intervalDurationMs);
3070
+ return () => {
3071
+ window.clearInterval(interval);
3072
+ };
243
3073
  }
244
- }, [value]);
245
- let borderRadius = 'tw-rounded-sm';
246
- if (inputGroup === 'left') {
247
- borderRadius = 'tw-rounded-l-sm tw-border-r-0 focus:tw-border-r' + ' active:tw-border-r';
248
- }
249
- else if (inputGroup === 'right') {
250
- borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
3074
+ return noop$1;
3075
+ }, [when, intervalDurationMs, startImmediate]);
3076
+ }
3077
+
3078
+ const getArrowStyle = (position, x, arrowWidth, tooltipHeight, tooltipWidth) => {
3079
+ switch (position) {
3080
+ case 'bottom':
3081
+ return {
3082
+ left: `${x}px`,
3083
+ top: `${-arrowWidth}px`,
3084
+ };
3085
+ case 'left':
3086
+ return {
3087
+ left: `${tooltipWidth - arrowWidth}px`,
3088
+ top: `${tooltipHeight / 2 - arrowWidth}px`,
3089
+ };
3090
+ case 'right':
3091
+ return {
3092
+ left: `${-arrowWidth}px`,
3093
+ top: `${tooltipHeight / 2 - arrowWidth}px`,
3094
+ };
3095
+ default: // 'top':
3096
+ return {
3097
+ left: `${x}px`,
3098
+ top: `${tooltipHeight - 10 + arrowWidth}px`,
3099
+ };
251
3100
  }
252
- const appliedClasses = `${baseClasses$3} ${sizeClasses[size]} ${extraClassNames} ${lightTheme$1} ${darkTheme$1} ${borderRadius} ${showError ? errorClasses$2 : borderColorClasses$2} `;
253
- return (React.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: "none", onChange: handleChange, onKeyUp: onKeyUp, step: step }));
254
- });
255
-
256
- const alignment = 'tw-flex tw-items-center';
257
- const labelClasses = 'tw-ml-1.5 tw-text-sm';
258
- const baseClasses$2 = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
259
- ' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:checked:tw-bg-sq-dark-text' +
260
- ' checked:tw-text-sq-text-color' +
261
- ' disabled:tw-text-sq-fairly-dark-gray';
262
- const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses$2}`;
263
- const radioClasses = `tw-form-radio ${baseClasses$2}`;
264
- /**
265
- * Checkbox and Radio Box Component.
266
- */
267
- const Checkbox = (props) => {
268
- const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, } = props;
269
- const assignedId = id ?? 'checkbox_' + Math.random();
270
- return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
271
- React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown }),
272
- React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
273
- ? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
274
- : 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
275
- };
276
-
277
- const baseClasses$1 = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
278
- ' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-text-sm';
279
- const darkTheme = 'dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
280
- ' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark dark:tw-placeholder-sq-dark-text-lighter';
281
- const lightTheme = 'tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark tw-placeholder-gray-400';
282
- const errorClasses$1 = 'tw-border-sq-danger-color';
283
- const borderColorClasses$1 = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
3101
+ };
3102
+ const HTMLTip = ({ text }) => {
3103
+ return React.createElement('div', {
3104
+ dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(text) },
3105
+ });
3106
+ };
284
3107
  /**
285
- * TextArea.
3108
+ * QTip
3109
+ *
3110
+ * QTip is a Singleton Tooltip component that guarantees high-performance and reduces component wrappers!
3111
+ *
3112
+ * QTip is used by all qomponents that support the display of tooltips.
3113
+ * If you want to add a Tooltip to your application you can do so by adding the following html data-attributes:
3114
+ *
3115
+ * 'data-qtip-text': the tooltip text to display; this can also be a string containing valid HTML
3116
+ * 'data-qtip-placement': one of TooltipPosition (top, bottom, right, or left)
3117
+ * 'data-qtip-is-html': set this to true if you provided a text that contains HTML,
3118
+ * 'data-qtip-delay': this can be used to delay the showing of the tooltip. this should be a number representing
3119
+ * the # of milliseconds you want to delay the tooltip for.
3120
+ * 'data-qtip-testid': use this attribute to provide a value for a data-testid of your tooltip; this is useful
3121
+ * for tests
3122
+ *
3123
+ * In order for QTip to be able to display Tooltips you must add the QTip component to your top-most component
3124
+ * (often that's App or Application) - simply add:
3125
+ *
3126
+ * <QTip />
3127
+ *
3128
+ * and enjoy beautiful & performant tooltips!
286
3129
  */
287
- const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, showError, }) => {
288
- const appliedClasses = `${baseClasses$1} ${extraClassNames} ${lightTheme} ${darkTheme} ${showError ? errorClasses$1 : borderColorClasses$1}`;
289
- return (React.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autofocus }));
3130
+ const QTip = () => {
3131
+ const tooltipRef = React.useRef(null);
3132
+ const tooltipTarget = React.useRef(null);
3133
+ const tooltipArrowRef = React.useRef(null);
3134
+ const [tooltipText, setTooltipText] = React.useState('');
3135
+ const [tooltipTargetOriginalPosition, setTooltipTargetOriginalPosition] = React.useState(null);
3136
+ const [show, setShow] = React.useState(false);
3137
+ const [html, setHtml] = React.useState(false);
3138
+ const [tooltipTestId, setTooltipTestId] = React.useState('');
3139
+ const [overTooltip, setOverTooltip] = React.useState(false);
3140
+ // Check every 300ms if the tooltip target position has changed and hide the tooltip if this happens.
3141
+ useIntervalWhen(() => {
3142
+ const currentPosition = tooltipTarget?.current?.getBoundingClientRect();
3143
+ if (overTooltip) {
3144
+ return;
3145
+ }
3146
+ if (tooltipTargetOriginalPosition?.y !== currentPosition?.y ||
3147
+ tooltipTargetOriginalPosition?.x !== currentPosition?.x) {
3148
+ setShow(false);
3149
+ }
3150
+ }, 300, show);
3151
+ React.useEffect(() => {
3152
+ document.body.addEventListener('mousemove', onMouseMove);
3153
+ return () => {
3154
+ document.removeEventListener('mousemove', onMouseMove);
3155
+ };
3156
+ }, []);
3157
+ const ttTimeout = React.useRef();
3158
+ const onMouseMove = (e) => {
3159
+ clearTimeout(ttTimeout.current);
3160
+ if (!(e.target instanceof HTMLElement)) {
3161
+ return;
3162
+ }
3163
+ tooltipTarget.current = e.target;
3164
+ let dataset = e.target?.dataset;
3165
+ let text = dataset?.qtipText;
3166
+ // Buttons support React.Nodes as children, the tooltip however is applied to the actual button component.
3167
+ // we only check one level up - alternatively the tooltip can also be provided on the React.Node
3168
+ if (!text || text === '') {
3169
+ dataset = e.target?.parentElement?.dataset;
3170
+ text = dataset?.qtipText;
3171
+ tooltipTarget.current = e.target?.parentElement;
3172
+ }
3173
+ if (text) {
3174
+ const delay = parseInt(dataset?.qtipDelay ?? '0');
3175
+ ttTimeout.current = setTimeout(() => makeTooltip(text, dataset?.qtipPlacement, dataset?.qtipIsHtml === 'true', dataset?.qtipTestid, delay), delay);
3176
+ }
3177
+ };
3178
+ const makeTooltip = (tooltipText, position = 'top', isHtml, dataTestId, delay) => {
3179
+ if (tooltipText && tooltipTarget.current) {
3180
+ setHtml(isHtml);
3181
+ setTooltipText(tooltipText);
3182
+ setTooltipTestId(dataTestId);
3183
+ setTooltipTargetOriginalPosition(tooltipTarget.current.getBoundingClientRect());
3184
+ const positionTooltip = () => {
3185
+ if (tooltipRef.current && tooltipTarget.current) {
3186
+ computePosition(tooltipTarget.current, tooltipRef.current, {
3187
+ placement: position,
3188
+ middleware: [offset(10), arrow({ element: tooltipArrowRef.current })],
3189
+ }).then(({ x, y, middlewareData }) => {
3190
+ Object.assign(tooltipRef.current?.style, {
3191
+ left: `${x}px`,
3192
+ top: `${y}px`,
3193
+ });
3194
+ if (middlewareData.arrow) {
3195
+ const { x, y } = middlewareData.arrow;
3196
+ const arrowWidth = tooltipArrowRef.current?.offsetHeight / 2;
3197
+ const tooltipHeight = tooltipRef.current?.offsetHeight;
3198
+ const tooltipWidth = tooltipRef.current?.offsetWidth;
3199
+ const style = getArrowStyle(position, x || y, arrowWidth, tooltipHeight, tooltipWidth);
3200
+ Object.assign(tooltipArrowRef.current.style, style);
3201
+ }
3202
+ setShow(true);
3203
+ });
3204
+ }
3205
+ };
3206
+ delay > 0
3207
+ ? requestAnimationFrame(() => {
3208
+ positionTooltip();
3209
+ })
3210
+ : positionTooltip();
3211
+ }
3212
+ };
3213
+ return (React.createElement(React.Fragment, null,
3214
+ React.createElement("div", { onMouseEnter: () => setOverTooltip(true), onMouseLeave: () => setOverTooltip(false), "data-testid": tooltipTestId, ref: tooltipRef, className: 'tw-absolute tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white tw-z-[9999] fade-in ' +
3215
+ (show ? 'tw-visible' : 'tw-invisible tw-pointer-events-none') },
3216
+ html ? React.createElement(HTMLTip, { text: tooltipText }) : tooltipText,
3217
+ React.createElement("div", { className: "tw-absolute tw-w-[10px] tw-h-[10px] tw-rotate-45 tw-bg-black", ref: tooltipArrowRef }))));
290
3218
  };
291
3219
 
292
3220
  function _typeof(obj) {
@@ -3264,10 +6192,6 @@ function _taggedTemplateLiteral(strings, raw) {
3264
6192
  }));
3265
6193
  }
3266
6194
 
3267
- function l$1(t){return {...t,top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height}}const g$1=["top","right","bottom","left"];g$1.reduce(((t,e)=>t.concat(e,e+"-start",e+"-end")),[]);
3268
-
3269
- function n(t){var e;return (null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function o(t){return n(t).getComputedStyle(t)}function i$1(t){return t instanceof n(t).Node}function r(t){return i$1(t)?(t.nodeName||"").toLowerCase():""}let l;function c(){if(l)return l;const t=navigator.userAgentData;return t&&Array.isArray(t.brands)?(l=t.brands.map((t=>t.brand+"/"+t.version)).join(" "),l):navigator.userAgent}function s(t){return t instanceof n(t).HTMLElement}function f(t){return t instanceof n(t).Element}function u(t){if("undefined"==typeof ShadowRoot)return !1;return t instanceof n(t).ShadowRoot||t instanceof ShadowRoot}function a(t){const{overflow:e,overflowX:n,overflowY:i,display:r}=o(t);return /auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!["inline","contents"].includes(r)}function p(){return /^((?!chrome|android).)*safari/i.test(c())}function g(t){return ["html","body","#document"].includes(r(t))}const x=Math.round;function w$1(t){const e=o(t);let n=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const r=s(t),l=r?t.offsetWidth:n,c=r?t.offsetHeight:i,f=x(n)!==l||x(i)!==c;return f&&(n=l,i=c),{width:n,height:i,fallback:f}}function v(t){return f(t)?t:t.contextElement}const b={x:1,y:1};function L(t){const e=v(t);if(!s(e))return b;const n=e.getBoundingClientRect(),{width:o,height:i,fallback:r}=w$1(e);let l=(r?x(n.width):n.width)/o,c=(r?x(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),c&&Number.isFinite(c)||(c=1),{x:l,y:c}}function E(e,o,i,r){var l,c;void 0===o&&(o=!1),void 0===i&&(i=!1);const s=e.getBoundingClientRect(),u=v(e);let a=b;o&&(r?f(r)&&(a=L(r)):a=L(e));const d=u?n(u):window,h=p()&&i;let g=(s.left+(h&&(null==(l=d.visualViewport)?void 0:l.offsetLeft)||0))/a.x,m=(s.top+(h&&(null==(c=d.visualViewport)?void 0:c.offsetTop)||0))/a.y,y=s.width/a.x,x=s.height/a.y;if(u){const t=n(u),e=r&&f(r)?n(r):r;let o=t.frameElement;for(;o&&r&&e!==t;){const t=L(o),e=o.getBoundingClientRect(),i=getComputedStyle(o);e.x+=(o.clientLeft+parseFloat(i.paddingLeft))*t.x,e.y+=(o.clientTop+parseFloat(i.paddingTop))*t.y,g*=t.x,m*=t.y,y*=t.x,x*=t.y,g+=e.x,m+=e.y,o=n(o).frameElement;}}return l$1({width:y,height:x,x:g,y:m})}function T(t){return ((i$1(t)?t.ownerDocument:t.document)||window.document).documentElement}function F(t){if("html"===r(t))return t;const e=t.assignedSlot||t.parentNode||u(t)&&t.host||T(t);return u(e)?e.host:e}function S(t){const e=F(t);return g(e)?e.ownerDocument.body:s(e)&&a(e)?e:S(e)}function W(t,e){var o;void 0===e&&(e=[]);const i=S(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=n(i);return r?e.concat(l,l.visualViewport||[],a(i)?i:[]):e.concat(i,W(i))}function z(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l=!0,animationFrame:c=!1}=o,s=i||r?[...f(t)?W(t):t.contextElement?W(t.contextElement):[],...W(e)]:[];s.forEach((t=>{const e=!f(t)&&t.toString().includes("V");!i||c&&!e||t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n);}));let u,a=null;l&&(a=new ResizeObserver((()=>{n();})),f(t)&&!c&&a.observe(t),f(t)||!t.contextElement||c||a.observe(t.contextElement),a.observe(e));let d=c?E(t):null;return c&&function e(){const o=E(t);!d||o.x===d.x&&o.y===d.y&&o.width===d.width&&o.height===d.height||n();d=o,u=requestAnimationFrame(e);}(),n(),()=>{var t;s.forEach((t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n);})),null==(t=a)||t.disconnect(),a=null,c&&cancelAnimationFrame(u);}}
3270
-
3271
6195
  var index = React.useLayoutEffect ;
3272
6196
 
3273
6197
  var _excluded$3 = ["className", "clearValue", "cx", "getStyles", "getClassNames", "getValue", "hasValue", "isMulti", "isRtl", "options", "selectOption", "selectProps", "setValue", "theme"];
@@ -3937,7 +6861,7 @@ var MenuPortal = function MenuPortal(props) {
3937
6861
  cleanupRef.current = null;
3938
6862
  }
3939
6863
  if (controlElement && menuPortalRef.current) {
3940
- cleanupRef.current = z(controlElement, menuPortalRef.current, updateComputedPosition, {
6864
+ cleanupRef.current = autoUpdate(controlElement, menuPortalRef.current, updateComputedPosition, {
3941
6865
  elementResize: 'ResizeObserver' in window
3942
6866
  });
3943
6867
  }
@@ -7486,6 +10410,7 @@ const Select = ({ options, value, placeholder = 'select', noOptionsMessage = 'no
7486
10410
  exports.Button = Button;
7487
10411
  exports.Checkbox = Checkbox;
7488
10412
  exports.Icon = Icon;
10413
+ exports.QTip = QTip;
7489
10414
  exports.Select = Select;
7490
10415
  exports.TextArea = TextArea;
7491
10416
  exports.TextField = TextField;