@bigbinary/neeto-message-templates-frontend 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -10,1639 +10,46 @@ var NeetoHeader = require('@bigbinary/neeto-molecules/Header');
10
10
  var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
11
11
  var neetoui = require('@bigbinary/neetoui');
12
12
  var ramda = require('ramda');
13
- var reactQuery = require('react-query');
14
- var devtools = require('react-query/devtools');
15
- var neetoIcons = require('@bigbinary/neeto-icons');
16
- var axios = require('axios');
17
- var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
18
- var zustand = require('zustand');
19
- var neetoEditor = require('@bigbinary/neeto-editor');
20
- var formik$1 = require('@bigbinary/neetoui/formik');
21
- var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
22
- var yup = require('yup');
23
- var formik = require('formik');
24
- var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
25
-
26
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
27
-
28
- function _interopNamespace(e) {
29
- if (e && e.__esModule) return e;
30
- var n = Object.create(null);
31
- if (e) {
32
- Object.keys(e).forEach(function (k) {
33
- if (k !== 'default') {
34
- var d = Object.getOwnPropertyDescriptor(e, k);
35
- Object.defineProperty(n, k, d.get ? d : {
36
- enumerable: true,
37
- get: function () { return e[k]; }
38
- });
39
- }
40
- });
41
- }
42
- n["default"] = e;
43
- return Object.freeze(n);
44
- }
45
-
46
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
47
- var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
48
- var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
49
- var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
50
- var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
51
- var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
52
- var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
53
-
54
- /*! @license DOMPurify 3.0.2 | (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.2/LICENSE */
55
-
56
- const {
57
- entries,
58
- setPrototypeOf,
59
- isFrozen,
60
- getPrototypeOf,
61
- getOwnPropertyDescriptor
62
- } = Object;
63
- let {
64
- freeze,
65
- seal,
66
- create
67
- } = Object; // eslint-disable-line import/no-mutable-exports
68
-
69
- let {
70
- apply,
71
- construct
72
- } = typeof Reflect !== 'undefined' && Reflect;
73
-
74
- if (!apply) {
75
- apply = function apply(fun, thisValue, args) {
76
- return fun.apply(thisValue, args);
77
- };
78
- }
79
-
80
- if (!freeze) {
81
- freeze = function freeze(x) {
82
- return x;
83
- };
84
- }
85
-
86
- if (!seal) {
87
- seal = function seal(x) {
88
- return x;
89
- };
90
- }
91
-
92
- if (!construct) {
93
- construct = function construct(Func, args) {
94
- return new Func(...args);
95
- };
96
- }
97
-
98
- const arrayForEach = unapply(Array.prototype.forEach);
99
- const arrayPop = unapply(Array.prototype.pop);
100
- const arrayPush = unapply(Array.prototype.push);
101
- const stringToLowerCase = unapply(String.prototype.toLowerCase);
102
- const stringToString = unapply(String.prototype.toString);
103
- const stringMatch = unapply(String.prototype.match);
104
- const stringReplace = unapply(String.prototype.replace);
105
- const stringIndexOf = unapply(String.prototype.indexOf);
106
- const stringTrim = unapply(String.prototype.trim);
107
- const regExpTest = unapply(RegExp.prototype.test);
108
- const typeErrorCreate = unconstruct(TypeError);
109
- function unapply(func) {
110
- return function (thisArg) {
111
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
112
- args[_key - 1] = arguments[_key];
113
- }
114
-
115
- return apply(func, thisArg, args);
116
- };
117
- }
118
- function unconstruct(func) {
119
- return function () {
120
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
121
- args[_key2] = arguments[_key2];
122
- }
123
-
124
- return construct(func, args);
125
- };
126
- }
127
- /* Add properties to a lookup table */
128
-
129
- function addToSet(set, array, transformCaseFunc) {
130
- transformCaseFunc = transformCaseFunc ? transformCaseFunc : stringToLowerCase;
131
-
132
- if (setPrototypeOf) {
133
- // Make 'in' and truthy checks like Boolean(set.constructor)
134
- // independent of any properties defined on Object.prototype.
135
- // Prevent prototype setters from intercepting set as a this value.
136
- setPrototypeOf(set, null);
137
- }
138
-
139
- let l = array.length;
140
-
141
- while (l--) {
142
- let element = array[l];
143
-
144
- if (typeof element === 'string') {
145
- const lcElement = transformCaseFunc(element);
146
-
147
- if (lcElement !== element) {
148
- // Config presets (e.g. tags.js, attrs.js) are immutable.
149
- if (!isFrozen(array)) {
150
- array[l] = lcElement;
151
- }
152
-
153
- element = lcElement;
154
- }
155
- }
156
-
157
- set[element] = true;
158
- }
159
-
160
- return set;
161
- }
162
- /* Shallow clone an object */
163
-
164
- function clone(object) {
165
- const newObject = create(null);
166
-
167
- for (const [property, value] of entries(object)) {
168
- newObject[property] = value;
169
- }
170
-
171
- return newObject;
172
- }
173
- /* This method automatically checks if the prop is function
174
- * or getter and behaves accordingly. */
175
-
176
- function lookupGetter(object, prop) {
177
- while (object !== null) {
178
- const desc = getOwnPropertyDescriptor(object, prop);
179
-
180
- if (desc) {
181
- if (desc.get) {
182
- return unapply(desc.get);
183
- }
184
-
185
- if (typeof desc.value === 'function') {
186
- return unapply(desc.value);
187
- }
188
- }
189
-
190
- object = getPrototypeOf(object);
191
- }
192
-
193
- function fallbackValue(element) {
194
- console.warn('fallback value for', element);
195
- return null;
196
- }
197
-
198
- return fallbackValue;
199
- }
200
-
201
- 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
202
-
203
- 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']);
204
- const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', '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.
205
- // We still need to know them so that we can do namespace
206
- // checks properly in case one wants to add them to
207
- // allow-list.
208
-
209
- const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'fedropshadow', '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']);
210
- 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,
211
- // even those that we disallow by default.
212
-
213
- const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);
214
- const text = freeze(['#text']);
215
-
216
- 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']);
217
- 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']);
218
- 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']);
219
- const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);
220
-
221
- const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode
222
-
223
- const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm);
224
- const TMPLIT_EXPR = seal(/\${[\w\W]*}/gm);
225
- const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]/); // eslint-disable-line no-useless-escape
226
-
227
- const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape
228
-
229
- 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
230
- );
231
- const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i);
232
- const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex
233
- );
234
- const DOCTYPE_NAME = seal(/^html$/i);
235
-
236
- var EXPRESSIONS = /*#__PURE__*/Object.freeze({
237
- __proto__: null,
238
- MUSTACHE_EXPR: MUSTACHE_EXPR,
239
- ERB_EXPR: ERB_EXPR,
240
- TMPLIT_EXPR: TMPLIT_EXPR,
241
- DATA_ATTR: DATA_ATTR,
242
- ARIA_ATTR: ARIA_ATTR,
243
- IS_ALLOWED_URI: IS_ALLOWED_URI,
244
- IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,
245
- ATTR_WHITESPACE: ATTR_WHITESPACE,
246
- DOCTYPE_NAME: DOCTYPE_NAME
247
- });
248
-
249
- const getGlobal = () => typeof window === 'undefined' ? null : window;
250
- /**
251
- * Creates a no-op policy for internal use only.
252
- * Don't export this function outside this module!
253
- * @param {?TrustedTypePolicyFactory} trustedTypes The policy factory.
254
- * @param {Document} document The document object (to determine policy name suffix)
255
- * @return {?TrustedTypePolicy} The policy created (or null, if Trusted Types
256
- * are not supported).
257
- */
258
-
259
-
260
- const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, document) {
261
- if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {
262
- return null;
263
- } // Allow the callers to control the unique policy name
264
- // by adding a data-tt-policy-suffix to the script element with the DOMPurify.
265
- // Policy creation with duplicate names throws in Trusted Types.
266
-
267
-
268
- let suffix = null;
269
- const ATTR_NAME = 'data-tt-policy-suffix';
270
-
271
- if (document.currentScript && document.currentScript.hasAttribute(ATTR_NAME)) {
272
- suffix = document.currentScript.getAttribute(ATTR_NAME);
273
- }
274
-
275
- const policyName = 'dompurify' + (suffix ? '#' + suffix : '');
276
-
277
- try {
278
- return trustedTypes.createPolicy(policyName, {
279
- createHTML(html) {
280
- return html;
281
- },
282
-
283
- createScriptURL(scriptUrl) {
284
- return scriptUrl;
285
- }
286
-
287
- });
288
- } catch (_) {
289
- // Policy creation failed (most likely another DOMPurify script has
290
- // already run). Skip creating the policy, as this will only cause errors
291
- // if TT are enforced.
292
- console.warn('TrustedTypes policy ' + policyName + ' could not be created.');
293
- return null;
294
- }
295
- };
296
-
297
- function createDOMPurify() {
298
- let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();
299
-
300
- const DOMPurify = root => createDOMPurify(root);
301
- /**
302
- * Version label, exposed for easier checks
303
- * if DOMPurify is up to date or not
304
- */
305
-
306
-
307
- DOMPurify.version = '3.0.2';
308
- /**
309
- * Array of elements that DOMPurify removed during sanitation.
310
- * Empty if nothing was removed.
311
- */
312
-
313
- DOMPurify.removed = [];
314
-
315
- if (!window || !window.document || window.document.nodeType !== 9) {
316
- // Not running in a browser, provide a factory function
317
- // so that you can pass your own Window
318
- DOMPurify.isSupported = false;
319
- return DOMPurify;
320
- }
321
-
322
- const originalDocument = window.document;
323
- let {
324
- document
325
- } = window;
326
- const {
327
- DocumentFragment,
328
- HTMLTemplateElement,
329
- Node,
330
- Element,
331
- NodeFilter,
332
- NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,
333
- HTMLFormElement,
334
- DOMParser,
335
- trustedTypes
336
- } = window;
337
- const ElementPrototype = Element.prototype;
338
- const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');
339
- const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');
340
- const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');
341
- const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); // As per issue #47, the web-components registry is inherited by a
342
- // new document created via createHTMLDocument. As per the spec
343
- // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)
344
- // a new empty registry is used when creating a template contents owner
345
- // document, so we use that as our parent document to ensure nothing
346
- // is inherited.
347
-
348
- if (typeof HTMLTemplateElement === 'function') {
349
- const template = document.createElement('template');
350
-
351
- if (template.content && template.content.ownerDocument) {
352
- document = template.content.ownerDocument;
353
- }
354
- }
355
-
356
- const trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, originalDocument);
357
-
358
- const emptyHTML = trustedTypesPolicy ? trustedTypesPolicy.createHTML('') : '';
359
- const {
360
- implementation,
361
- createNodeIterator,
362
- createDocumentFragment,
363
- getElementsByTagName
364
- } = document;
365
- const {
366
- importNode
367
- } = originalDocument;
368
- let hooks = {};
369
- /**
370
- * Expose whether this browser supports running the full DOMPurify.
371
- */
372
-
373
- DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && typeof implementation.createHTMLDocument !== 'undefined';
374
- const {
375
- MUSTACHE_EXPR,
376
- ERB_EXPR,
377
- TMPLIT_EXPR,
378
- DATA_ATTR,
379
- ARIA_ATTR,
380
- IS_SCRIPT_OR_DATA,
381
- ATTR_WHITESPACE
382
- } = EXPRESSIONS;
383
- let {
384
- IS_ALLOWED_URI: IS_ALLOWED_URI$1
385
- } = EXPRESSIONS;
386
- /**
387
- * We consider the elements and attributes below to be safe. Ideally
388
- * don't add any new ones but feel free to remove unwanted ones.
389
- */
390
-
391
- /* allowed element names */
392
-
393
- let ALLOWED_TAGS = null;
394
- const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);
395
- /* Allowed attribute names */
396
-
397
- let ALLOWED_ATTR = null;
398
- const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);
399
- /*
400
- * Configure how DOMPUrify should handle custom elements and their attributes as well as customized built-in elements.
401
- * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)
402
- * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)
403
- * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.
404
- */
405
-
406
- let CUSTOM_ELEMENT_HANDLING = Object.seal(Object.create(null, {
407
- tagNameCheck: {
408
- writable: true,
409
- configurable: false,
410
- enumerable: true,
411
- value: null
412
- },
413
- attributeNameCheck: {
414
- writable: true,
415
- configurable: false,
416
- enumerable: true,
417
- value: null
418
- },
419
- allowCustomizedBuiltInElements: {
420
- writable: true,
421
- configurable: false,
422
- enumerable: true,
423
- value: false
424
- }
425
- }));
426
- /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */
427
-
428
- let FORBID_TAGS = null;
429
- /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */
430
-
431
- let FORBID_ATTR = null;
432
- /* Decide if ARIA attributes are okay */
433
-
434
- let ALLOW_ARIA_ATTR = true;
435
- /* Decide if custom data attributes are okay */
436
-
437
- let ALLOW_DATA_ATTR = true;
438
- /* Decide if unknown protocols are okay */
439
-
440
- let ALLOW_UNKNOWN_PROTOCOLS = false;
441
- /* Decide if self-closing tags in attributes are allowed.
442
- * Usually removed due to a mXSS issue in jQuery 3.0 */
443
-
444
- let ALLOW_SELF_CLOSE_IN_ATTR = true;
445
- /* Output should be safe for common template engines.
446
- * This means, DOMPurify removes data attributes, mustaches and ERB
447
- */
448
-
449
- let SAFE_FOR_TEMPLATES = false;
450
- /* Decide if document with <html>... should be returned */
451
-
452
- let WHOLE_DOCUMENT = false;
453
- /* Track whether config is already set on this instance of DOMPurify. */
454
-
455
- let SET_CONFIG = false;
456
- /* Decide if all elements (e.g. style, script) must be children of
457
- * document.body. By default, browsers might move them to document.head */
458
-
459
- let FORCE_BODY = false;
460
- /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html
461
- * string (or a TrustedHTML object if Trusted Types are supported).
462
- * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead
463
- */
464
-
465
- let RETURN_DOM = false;
466
- /* Decide if a DOM `DocumentFragment` should be returned, instead of a html
467
- * string (or a TrustedHTML object if Trusted Types are supported) */
468
-
469
- let RETURN_DOM_FRAGMENT = false;
470
- /* Try to return a Trusted Type object instead of a string, return a string in
471
- * case Trusted Types are not supported */
472
-
473
- let RETURN_TRUSTED_TYPE = false;
474
- /* Output should be free from DOM clobbering attacks?
475
- * This sanitizes markups named with colliding, clobberable built-in DOM APIs.
476
- */
477
-
478
- let SANITIZE_DOM = true;
479
- /* Achieve full DOM Clobbering protection by isolating the namespace of named
480
- * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.
481
- *
482
- * HTML/DOM spec rules that enable DOM Clobbering:
483
- * - Named Access on Window (§7.3.3)
484
- * - DOM Tree Accessors (§3.1.5)
485
- * - Form Element Parent-Child Relations (§4.10.3)
486
- * - Iframe srcdoc / Nested WindowProxies (§4.8.5)
487
- * - HTMLCollection (§4.2.10.2)
488
- *
489
- * Namespace isolation is implemented by prefixing `id` and `name` attributes
490
- * with a constant string, i.e., `user-content-`
491
- */
492
-
493
- let SANITIZE_NAMED_PROPS = false;
494
- const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';
495
- /* Keep element content when removing element? */
496
-
497
- let KEEP_CONTENT = true;
498
- /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead
499
- * of importing it into a new Document and returning a sanitized copy */
500
-
501
- let IN_PLACE = false;
502
- /* Allow usage of profiles like html, svg and mathMl */
503
-
504
- let USE_PROFILES = {};
505
- /* Tags to ignore content of when KEEP_CONTENT is true */
506
-
507
- let FORBID_CONTENTS = null;
508
- 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']);
509
- /* Tags that are safe for data: URIs */
510
-
511
- let DATA_URI_TAGS = null;
512
- const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);
513
- /* Attributes safe for values like "javascript:" */
514
-
515
- let URI_SAFE_ATTRIBUTES = null;
516
- const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);
517
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
518
- const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
519
- const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';
520
- /* Document namespace */
521
-
522
- let NAMESPACE = HTML_NAMESPACE;
523
- let IS_EMPTY_INPUT = false;
524
- /* Allowed XHTML+XML namespaces */
525
-
526
- let ALLOWED_NAMESPACES = null;
527
- const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);
528
- /* Parsing of strict XHTML documents */
529
-
530
- let PARSER_MEDIA_TYPE;
531
- const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];
532
- const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';
533
- let transformCaseFunc;
534
- /* Keep a reference to config to pass to hooks */
535
-
536
- let CONFIG = null;
537
- /* Ideally, do not touch anything below this line */
538
-
539
- /* ______________________________________________ */
540
-
541
- const formElement = document.createElement('form');
542
-
543
- const isRegexOrFunction = function isRegexOrFunction(testValue) {
544
- return testValue instanceof RegExp || testValue instanceof Function;
545
- };
546
- /**
547
- * _parseConfig
548
- *
549
- * @param {Object} cfg optional config literal
550
- */
551
- // eslint-disable-next-line complexity
552
-
553
-
554
- const _parseConfig = function _parseConfig(cfg) {
555
- if (CONFIG && CONFIG === cfg) {
556
- return;
557
- }
558
- /* Shield configuration object from tampering */
559
-
560
-
561
- if (!cfg || typeof cfg !== 'object') {
562
- cfg = {};
563
- }
564
- /* Shield configuration object from prototype pollution */
565
-
566
-
567
- cfg = clone(cfg);
568
- PARSER_MEDIA_TYPE = // eslint-disable-next-line unicorn/prefer-includes
569
- 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.
570
-
571
- transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;
572
- /* Set configuration parameters */
573
-
574
- ALLOWED_TAGS = 'ALLOWED_TAGS' in cfg ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;
575
- ALLOWED_ATTR = 'ALLOWED_ATTR' in cfg ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;
576
- ALLOWED_NAMESPACES = 'ALLOWED_NAMESPACES' in cfg ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;
577
- URI_SAFE_ATTRIBUTES = 'ADD_URI_SAFE_ATTR' in cfg ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), // eslint-disable-line indent
578
- cfg.ADD_URI_SAFE_ATTR, // eslint-disable-line indent
579
- transformCaseFunc // eslint-disable-line indent
580
- ) // eslint-disable-line indent
581
- : DEFAULT_URI_SAFE_ATTRIBUTES;
582
- DATA_URI_TAGS = 'ADD_DATA_URI_TAGS' in cfg ? addToSet(clone(DEFAULT_DATA_URI_TAGS), // eslint-disable-line indent
583
- cfg.ADD_DATA_URI_TAGS, // eslint-disable-line indent
584
- transformCaseFunc // eslint-disable-line indent
585
- ) // eslint-disable-line indent
586
- : DEFAULT_DATA_URI_TAGS;
587
- FORBID_CONTENTS = 'FORBID_CONTENTS' in cfg ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;
588
- FORBID_TAGS = 'FORBID_TAGS' in cfg ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : {};
589
- FORBID_ATTR = 'FORBID_ATTR' in cfg ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : {};
590
- USE_PROFILES = 'USE_PROFILES' in cfg ? cfg.USE_PROFILES : false;
591
- ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true
592
-
593
- ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true
594
-
595
- ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false
596
-
597
- ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true
598
-
599
- SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false
600
-
601
- WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false
602
-
603
- RETURN_DOM = cfg.RETURN_DOM || false; // Default false
604
-
605
- RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false
606
-
607
- RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false
608
-
609
- FORCE_BODY = cfg.FORCE_BODY || false; // Default false
610
-
611
- SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true
612
-
613
- SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false
614
-
615
- KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true
616
-
617
- IN_PLACE = cfg.IN_PLACE || false; // Default false
618
-
619
- IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;
620
- NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;
621
- CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};
622
-
623
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {
624
- CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;
625
- }
626
-
627
- if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {
628
- CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;
629
- }
630
-
631
- if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {
632
- CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;
633
- }
634
-
635
- if (SAFE_FOR_TEMPLATES) {
636
- ALLOW_DATA_ATTR = false;
637
- }
638
-
639
- if (RETURN_DOM_FRAGMENT) {
640
- RETURN_DOM = true;
641
- }
642
- /* Parse profile info */
643
-
644
-
645
- if (USE_PROFILES) {
646
- ALLOWED_TAGS = addToSet({}, [...text]);
647
- ALLOWED_ATTR = [];
648
-
649
- if (USE_PROFILES.html === true) {
650
- addToSet(ALLOWED_TAGS, html$1);
651
- addToSet(ALLOWED_ATTR, html);
652
- }
653
-
654
- if (USE_PROFILES.svg === true) {
655
- addToSet(ALLOWED_TAGS, svg$1);
656
- addToSet(ALLOWED_ATTR, svg);
657
- addToSet(ALLOWED_ATTR, xml);
658
- }
659
-
660
- if (USE_PROFILES.svgFilters === true) {
661
- addToSet(ALLOWED_TAGS, svgFilters);
662
- addToSet(ALLOWED_ATTR, svg);
663
- addToSet(ALLOWED_ATTR, xml);
664
- }
665
-
666
- if (USE_PROFILES.mathMl === true) {
667
- addToSet(ALLOWED_TAGS, mathMl$1);
668
- addToSet(ALLOWED_ATTR, mathMl);
669
- addToSet(ALLOWED_ATTR, xml);
670
- }
671
- }
672
- /* Merge configuration parameters */
673
-
674
-
675
- if (cfg.ADD_TAGS) {
676
- if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {
677
- ALLOWED_TAGS = clone(ALLOWED_TAGS);
678
- }
679
-
680
- addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);
681
- }
682
-
683
- if (cfg.ADD_ATTR) {
684
- if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {
685
- ALLOWED_ATTR = clone(ALLOWED_ATTR);
686
- }
687
-
688
- addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);
689
- }
690
-
691
- if (cfg.ADD_URI_SAFE_ATTR) {
692
- addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);
693
- }
694
-
695
- if (cfg.FORBID_CONTENTS) {
696
- if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {
697
- FORBID_CONTENTS = clone(FORBID_CONTENTS);
698
- }
699
-
700
- addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);
701
- }
702
- /* Add #text in case KEEP_CONTENT is set to true */
703
-
704
-
705
- if (KEEP_CONTENT) {
706
- ALLOWED_TAGS['#text'] = true;
707
- }
708
- /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */
709
-
710
-
711
- if (WHOLE_DOCUMENT) {
712
- addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);
713
- }
714
- /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */
715
-
716
-
717
- if (ALLOWED_TAGS.table) {
718
- addToSet(ALLOWED_TAGS, ['tbody']);
719
- delete FORBID_TAGS.tbody;
720
- } // Prevent further manipulation of configuration.
721
- // Not available in IE8, Safari 5, etc.
722
-
723
-
724
- if (freeze) {
725
- freeze(cfg);
726
- }
727
-
728
- CONFIG = cfg;
729
- };
730
-
731
- const MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);
732
- const HTML_INTEGRATION_POINTS = addToSet({}, ['foreignobject', 'desc', 'title', 'annotation-xml']); // Certain elements are allowed in both SVG and HTML
733
- // namespace. We need to specify them explicitly
734
- // so that they don't get erroneously deleted from
735
- // HTML namespace.
736
-
737
- const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);
738
- /* Keep track of all possible SVG and MathML tags
739
- * so that we can perform the namespace checks
740
- * correctly. */
741
-
742
- const ALL_SVG_TAGS = addToSet({}, svg$1);
743
- addToSet(ALL_SVG_TAGS, svgFilters);
744
- addToSet(ALL_SVG_TAGS, svgDisallowed);
745
- const ALL_MATHML_TAGS = addToSet({}, mathMl$1);
746
- addToSet(ALL_MATHML_TAGS, mathMlDisallowed);
747
- /**
748
- *
749
- *
750
- * @param {Element} element a DOM element whose namespace is being checked
751
- * @returns {boolean} Return false if the element has a
752
- * namespace that a spec-compliant parser would never
753
- * return. Return true otherwise.
754
- */
755
-
756
- const _checkValidNamespace = function _checkValidNamespace(element) {
757
- let parent = getParentNode(element); // In JSDOM, if we're inside shadow DOM, then parentNode
758
- // can be null. We just simulate parent in this case.
759
-
760
- if (!parent || !parent.tagName) {
761
- parent = {
762
- namespaceURI: NAMESPACE,
763
- tagName: 'template'
764
- };
765
- }
766
-
767
- const tagName = stringToLowerCase(element.tagName);
768
- const parentTagName = stringToLowerCase(parent.tagName);
769
-
770
- if (!ALLOWED_NAMESPACES[element.namespaceURI]) {
771
- return false;
772
- }
773
-
774
- if (element.namespaceURI === SVG_NAMESPACE) {
775
- // The only way to switch from HTML namespace to SVG
776
- // is via <svg>. If it happens via any other tag, then
777
- // it should be killed.
778
- if (parent.namespaceURI === HTML_NAMESPACE) {
779
- return tagName === 'svg';
780
- } // The only way to switch from MathML to SVG is via`
781
- // svg if parent is either <annotation-xml> or MathML
782
- // text integration points.
783
-
784
-
785
- if (parent.namespaceURI === MATHML_NAMESPACE) {
786
- return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);
787
- } // We only allow elements that are defined in SVG
788
- // spec. All others are disallowed in SVG namespace.
789
-
790
-
791
- return Boolean(ALL_SVG_TAGS[tagName]);
792
- }
793
-
794
- if (element.namespaceURI === MATHML_NAMESPACE) {
795
- // The only way to switch from HTML namespace to MathML
796
- // is via <math>. If it happens via any other tag, then
797
- // it should be killed.
798
- if (parent.namespaceURI === HTML_NAMESPACE) {
799
- return tagName === 'math';
800
- } // The only way to switch from SVG to MathML is via
801
- // <math> and HTML integration points
802
-
803
-
804
- if (parent.namespaceURI === SVG_NAMESPACE) {
805
- return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];
806
- } // We only allow elements that are defined in MathML
807
- // spec. All others are disallowed in MathML namespace.
808
-
809
-
810
- return Boolean(ALL_MATHML_TAGS[tagName]);
811
- }
812
-
813
- if (element.namespaceURI === HTML_NAMESPACE) {
814
- // The only way to switch from SVG to HTML is via
815
- // HTML integration points, and from MathML to HTML
816
- // is via MathML text integration points
817
- if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {
818
- return false;
819
- }
820
-
821
- if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {
822
- return false;
823
- } // We disallow tags that are specific for MathML
824
- // or SVG and should never appear in HTML namespace
825
-
826
-
827
- return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);
828
- } // For XHTML and XML documents that support custom namespaces
829
-
830
-
831
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {
832
- return true;
833
- } // The code should never reach this place (this means
834
- // that the element somehow got namespace that is not
835
- // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).
836
- // Return false just in case.
837
-
838
-
839
- return false;
840
- };
841
- /**
842
- * _forceRemove
843
- *
844
- * @param {Node} node a DOM node
845
- */
846
-
847
-
848
- const _forceRemove = function _forceRemove(node) {
849
- arrayPush(DOMPurify.removed, {
850
- element: node
851
- });
852
-
853
- try {
854
- // eslint-disable-next-line unicorn/prefer-dom-node-remove
855
- node.parentNode.removeChild(node);
856
- } catch (_) {
857
- node.remove();
858
- }
859
- };
860
- /**
861
- * _removeAttribute
862
- *
863
- * @param {String} name an Attribute name
864
- * @param {Node} node a DOM node
865
- */
866
-
867
-
868
- const _removeAttribute = function _removeAttribute(name, node) {
869
- try {
870
- arrayPush(DOMPurify.removed, {
871
- attribute: node.getAttributeNode(name),
872
- from: node
873
- });
874
- } catch (_) {
875
- arrayPush(DOMPurify.removed, {
876
- attribute: null,
877
- from: node
878
- });
879
- }
880
-
881
- node.removeAttribute(name); // We void attribute values for unremovable "is"" attributes
882
-
883
- if (name === 'is' && !ALLOWED_ATTR[name]) {
884
- if (RETURN_DOM || RETURN_DOM_FRAGMENT) {
885
- try {
886
- _forceRemove(node);
887
- } catch (_) {}
888
- } else {
889
- try {
890
- node.setAttribute(name, '');
891
- } catch (_) {}
892
- }
893
- }
894
- };
895
- /**
896
- * _initDocument
897
- *
898
- * @param {String} dirty a string of dirty markup
899
- * @return {Document} a DOM, filled with the dirty markup
900
- */
901
-
902
-
903
- const _initDocument = function _initDocument(dirty) {
904
- /* Create a HTML document */
905
- let doc;
906
- let leadingWhitespace;
907
-
908
- if (FORCE_BODY) {
909
- dirty = '<remove></remove>' + dirty;
910
- } else {
911
- /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */
912
- const matches = stringMatch(dirty, /^[\r\n\t ]+/);
913
- leadingWhitespace = matches && matches[0];
914
- }
915
-
916
- if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {
917
- // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)
918
- dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>';
919
- }
920
-
921
- const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;
922
- /*
923
- * Use the DOMParser API by default, fallback later if needs be
924
- * DOMParser not work for svg when has multiple root element.
925
- */
926
-
927
- if (NAMESPACE === HTML_NAMESPACE) {
928
- try {
929
- doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);
930
- } catch (_) {}
931
- }
932
- /* Use createHTMLDocument in case DOMParser is not available */
933
-
934
-
935
- if (!doc || !doc.documentElement) {
936
- doc = implementation.createDocument(NAMESPACE, 'template', null);
937
-
938
- try {
939
- doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;
940
- } catch (_) {// Syntax error if dirtyPayload is invalid xml
941
- }
942
- }
943
-
944
- const body = doc.body || doc.documentElement;
945
-
946
- if (dirty && leadingWhitespace) {
947
- body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);
948
- }
949
- /* Work on whole document or just its body */
950
-
951
-
952
- if (NAMESPACE === HTML_NAMESPACE) {
953
- return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];
954
- }
955
-
956
- return WHOLE_DOCUMENT ? doc.documentElement : body;
957
- };
958
- /**
959
- * _createIterator
960
- *
961
- * @param {Document} root document/fragment to create iterator for
962
- * @return {Iterator} iterator instance
963
- */
964
-
965
-
966
- const _createIterator = function _createIterator(root) {
967
- return createNodeIterator.call(root.ownerDocument || root, root, // eslint-disable-next-line no-bitwise
968
- NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT, null, false);
969
- };
970
- /**
971
- * _isClobbered
972
- *
973
- * @param {Node} elm element to check for clobbering attacks
974
- * @return {Boolean} true if clobbered, false if safe
975
- */
976
-
977
-
978
- const _isClobbered = function _isClobbered(elm) {
979
- 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');
980
- };
981
- /**
982
- * _isNode
983
- *
984
- * @param {Node} obj object to check whether it's a DOM node
985
- * @return {Boolean} true is object is a DOM node
986
- */
987
-
988
-
989
- const _isNode = function _isNode(object) {
990
- return typeof Node === 'object' ? object instanceof Node : object && typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string';
991
- };
992
- /**
993
- * _executeHook
994
- * Execute user configurable hooks
995
- *
996
- * @param {String} entryPoint Name of the hook's entry point
997
- * @param {Node} currentNode node to work on with the hook
998
- * @param {Object} data additional hook parameters
999
- */
1000
-
1001
-
1002
- const _executeHook = function _executeHook(entryPoint, currentNode, data) {
1003
- if (!hooks[entryPoint]) {
1004
- return;
1005
- }
1006
-
1007
- arrayForEach(hooks[entryPoint], hook => {
1008
- hook.call(DOMPurify, currentNode, data, CONFIG);
1009
- });
1010
- };
1011
- /**
1012
- * _sanitizeElements
1013
- *
1014
- * @protect nodeName
1015
- * @protect textContent
1016
- * @protect removeChild
1017
- *
1018
- * @param {Node} currentNode to check for permission to exist
1019
- * @return {Boolean} true if node was killed, false if left alive
1020
- */
1021
-
1022
-
1023
- const _sanitizeElements = function _sanitizeElements(currentNode) {
1024
- let content;
1025
- /* Execute a hook if present */
1026
-
1027
- _executeHook('beforeSanitizeElements', currentNode, null);
1028
- /* Check if element is clobbered or can clobber */
1029
-
1030
-
1031
- if (_isClobbered(currentNode)) {
1032
- _forceRemove(currentNode);
1033
-
1034
- return true;
1035
- }
1036
- /* Now let's check the element's type and name */
1037
-
1038
-
1039
- const tagName = transformCaseFunc(currentNode.nodeName);
1040
- /* Execute a hook if present */
1041
-
1042
- _executeHook('uponSanitizeElement', currentNode, {
1043
- tagName,
1044
- allowedTags: ALLOWED_TAGS
1045
- });
1046
- /* Detect mXSS attempts abusing namespace confusion */
1047
-
1048
-
1049
- if (currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && (!_isNode(currentNode.content) || !_isNode(currentNode.content.firstElementChild)) && regExpTest(/<[/\w]/g, currentNode.innerHTML) && regExpTest(/<[/\w]/g, currentNode.textContent)) {
1050
- _forceRemove(currentNode);
1051
-
1052
- return true;
1053
- }
1054
- /* Remove element if anything forbids its presence */
1055
-
1056
-
1057
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1058
- /* Check if we have a custom element to handle */
1059
- if (!FORBID_TAGS[tagName] && _basicCustomElementTest(tagName)) {
1060
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) return false;
1061
- if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) return false;
1062
- }
1063
- /* Keep content except for bad-listed elements */
1064
-
1065
-
1066
- if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {
1067
- const parentNode = getParentNode(currentNode) || currentNode.parentNode;
1068
- const childNodes = getChildNodes(currentNode) || currentNode.childNodes;
1069
-
1070
- if (childNodes && parentNode) {
1071
- const childCount = childNodes.length;
1072
-
1073
- for (let i = childCount - 1; i >= 0; --i) {
1074
- parentNode.insertBefore(cloneNode(childNodes[i], true), getNextSibling(currentNode));
1075
- }
1076
- }
1077
- }
1078
-
1079
- _forceRemove(currentNode);
1080
-
1081
- return true;
1082
- }
1083
- /* Check whether element has a valid namespace */
1084
-
1085
-
1086
- if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {
1087
- _forceRemove(currentNode);
1088
-
1089
- return true;
1090
- }
1091
- /* Make sure that older browsers don't get noscript mXSS */
1092
-
1093
-
1094
- if ((tagName === 'noscript' || tagName === 'noembed') && regExpTest(/<\/no(script|embed)/i, currentNode.innerHTML)) {
1095
- _forceRemove(currentNode);
1096
-
1097
- return true;
1098
- }
1099
- /* Sanitize element content to be template-safe */
1100
-
13
+ var neetoIcons = require('@bigbinary/neeto-icons');
14
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
15
+ var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
16
+ var reactQuery = require('react-query');
17
+ var axios = require('axios');
18
+ var zustand = require('zustand');
19
+ var neetoEditor = require('@bigbinary/neeto-editor');
20
+ var formik$1 = require('@bigbinary/neetoui/formik');
21
+ var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
22
+ var yup = require('yup');
23
+ var formik = require('formik');
24
+ var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
1101
25
 
1102
- if (SAFE_FOR_TEMPLATES && currentNode.nodeType === 3) {
1103
- /* Get the element's text content */
1104
- content = currentNode.textContent;
1105
- content = stringReplace(content, MUSTACHE_EXPR, ' ');
1106
- content = stringReplace(content, ERB_EXPR, ' ');
1107
- content = stringReplace(content, TMPLIT_EXPR, ' ');
26
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
1108
27
 
1109
- if (currentNode.textContent !== content) {
1110
- arrayPush(DOMPurify.removed, {
1111
- element: currentNode.cloneNode()
28
+ function _interopNamespace(e) {
29
+ if (e && e.__esModule) return e;
30
+ var n = Object.create(null);
31
+ if (e) {
32
+ Object.keys(e).forEach(function (k) {
33
+ if (k !== 'default') {
34
+ var d = Object.getOwnPropertyDescriptor(e, k);
35
+ Object.defineProperty(n, k, d.get ? d : {
36
+ enumerable: true,
37
+ get: function () { return e[k]; }
1112
38
  });
1113
- currentNode.textContent = content;
1114
- }
1115
- }
1116
- /* Execute a hook if present */
1117
-
1118
-
1119
- _executeHook('afterSanitizeElements', currentNode, null);
1120
-
1121
- return false;
1122
- };
1123
- /**
1124
- * _isValidAttribute
1125
- *
1126
- * @param {string} lcTag Lowercase tag name of containing element.
1127
- * @param {string} lcName Lowercase attribute name.
1128
- * @param {string} value Attribute value.
1129
- * @return {Boolean} Returns true if `value` is valid, otherwise false.
1130
- */
1131
- // eslint-disable-next-line complexity
1132
-
1133
-
1134
- const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {
1135
- /* Make sure attribute cannot clobber */
1136
- if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {
1137
- return false;
1138
- }
1139
- /* Allow valid data-* attributes: At least one character after "-"
1140
- (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)
1141
- XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)
1142
- We don't need to check the value; it's always URI safe. */
1143
-
1144
-
1145
- 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]) {
1146
- if ( // First condition does a very basic check if a) it's basically a valid custom element tagname AND
1147
- // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1148
- // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck
1149
- _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
1150
- // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck
1151
- 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 {
1152
- return false;
1153
- }
1154
- /* Check value is safe. First, is attr inert? If so, is safe */
1155
-
1156
- } 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) ; else {
1157
- return false;
1158
- }
1159
-
1160
- return true;
1161
- };
1162
- /**
1163
- * _basicCustomElementCheck
1164
- * checks if at least one dash is included in tagName, and it's not the first char
1165
- * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name
1166
- * @param {string} tagName name of the tag of the node to sanitize
1167
- */
1168
-
1169
-
1170
- const _basicCustomElementTest = function _basicCustomElementTest(tagName) {
1171
- return tagName.indexOf('-') > 0;
1172
- };
1173
- /**
1174
- * _sanitizeAttributes
1175
- *
1176
- * @protect attributes
1177
- * @protect nodeName
1178
- * @protect removeAttribute
1179
- * @protect setAttribute
1180
- *
1181
- * @param {Node} currentNode to sanitize
1182
- */
1183
-
1184
-
1185
- const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {
1186
- let attr;
1187
- let value;
1188
- let lcName;
1189
- let l;
1190
- /* Execute a hook if present */
1191
-
1192
- _executeHook('beforeSanitizeAttributes', currentNode, null);
1193
-
1194
- const {
1195
- attributes
1196
- } = currentNode;
1197
- /* Check if we have attributes; if not we might have a text node */
1198
-
1199
- if (!attributes) {
1200
- return;
1201
- }
1202
-
1203
- const hookEvent = {
1204
- attrName: '',
1205
- attrValue: '',
1206
- keepAttr: true,
1207
- allowedAttributes: ALLOWED_ATTR
1208
- };
1209
- l = attributes.length;
1210
- /* Go backwards over all attributes; safely remove bad ones */
1211
-
1212
- while (l--) {
1213
- attr = attributes[l];
1214
- const {
1215
- name,
1216
- namespaceURI
1217
- } = attr;
1218
- value = name === 'value' ? attr.value : stringTrim(attr.value);
1219
- lcName = transformCaseFunc(name);
1220
- /* Execute a hook if present */
1221
-
1222
- hookEvent.attrName = lcName;
1223
- hookEvent.attrValue = value;
1224
- hookEvent.keepAttr = true;
1225
- hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set
1226
-
1227
- _executeHook('uponSanitizeAttribute', currentNode, hookEvent);
1228
-
1229
- value = hookEvent.attrValue;
1230
- /* Did the hooks approve of the attribute? */
1231
-
1232
- if (hookEvent.forceKeepAttr) {
1233
- continue;
1234
- }
1235
- /* Remove attribute */
1236
-
1237
-
1238
- _removeAttribute(name, currentNode);
1239
- /* Did the hooks approve of the attribute? */
1240
-
1241
-
1242
- if (!hookEvent.keepAttr) {
1243
- continue;
1244
- }
1245
- /* Work around a security issue in jQuery 3.0 */
1246
-
1247
-
1248
- if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) {
1249
- _removeAttribute(name, currentNode);
1250
-
1251
- continue;
1252
- }
1253
- /* Sanitize attribute content to be template-safe */
1254
-
1255
-
1256
- if (SAFE_FOR_TEMPLATES) {
1257
- value = stringReplace(value, MUSTACHE_EXPR, ' ');
1258
- value = stringReplace(value, ERB_EXPR, ' ');
1259
- value = stringReplace(value, TMPLIT_EXPR, ' ');
1260
- }
1261
- /* Is `value` valid for this attribute? */
1262
-
1263
-
1264
- const lcTag = transformCaseFunc(currentNode.nodeName);
1265
-
1266
- if (!_isValidAttribute(lcTag, lcName, value)) {
1267
- continue;
1268
- }
1269
- /* Full DOM Clobbering protection via namespace isolation,
1270
- * Prefix id and name attributes with `user-content-`
1271
- */
1272
-
1273
-
1274
- if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {
1275
- // Remove the attribute with this value
1276
- _removeAttribute(name, currentNode); // Prefix the value and later re-create the attribute with the sanitized value
1277
-
1278
-
1279
- value = SANITIZE_NAMED_PROPS_PREFIX + value;
1280
- }
1281
- /* Handle attributes that require Trusted Types */
1282
-
1283
-
1284
- if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {
1285
- if (namespaceURI) ; else {
1286
- switch (trustedTypes.getAttributeType(lcTag, lcName)) {
1287
- case 'TrustedHTML':
1288
- value = trustedTypesPolicy.createHTML(value);
1289
- break;
1290
-
1291
- case 'TrustedScriptURL':
1292
- value = trustedTypesPolicy.createScriptURL(value);
1293
- break;
1294
- }
1295
- }
1296
- }
1297
- /* Handle invalid data-* attribute set by try-catching it */
1298
-
1299
-
1300
- try {
1301
- if (namespaceURI) {
1302
- currentNode.setAttributeNS(namespaceURI, name, value);
1303
- } else {
1304
- /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */
1305
- currentNode.setAttribute(name, value);
1306
- }
1307
-
1308
- arrayPop(DOMPurify.removed);
1309
- } catch (_) {}
1310
- }
1311
- /* Execute a hook if present */
1312
-
1313
-
1314
- _executeHook('afterSanitizeAttributes', currentNode, null);
1315
- };
1316
- /**
1317
- * _sanitizeShadowDOM
1318
- *
1319
- * @param {DocumentFragment} fragment to iterate over recursively
1320
- */
1321
-
1322
-
1323
- const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {
1324
- let shadowNode;
1325
-
1326
- const shadowIterator = _createIterator(fragment);
1327
- /* Execute a hook if present */
1328
-
1329
-
1330
- _executeHook('beforeSanitizeShadowDOM', fragment, null);
1331
-
1332
- while (shadowNode = shadowIterator.nextNode()) {
1333
- /* Execute a hook if present */
1334
- _executeHook('uponSanitizeShadowNode', shadowNode, null);
1335
- /* Sanitize tags and elements */
1336
-
1337
-
1338
- if (_sanitizeElements(shadowNode)) {
1339
- continue;
1340
- }
1341
- /* Deep shadow DOM detected */
1342
-
1343
-
1344
- if (shadowNode.content instanceof DocumentFragment) {
1345
- _sanitizeShadowDOM(shadowNode.content);
1346
- }
1347
- /* Check attributes, sanitize if necessary */
1348
-
1349
-
1350
- _sanitizeAttributes(shadowNode);
1351
- }
1352
- /* Execute a hook if present */
1353
-
1354
-
1355
- _executeHook('afterSanitizeShadowDOM', fragment, null);
1356
- };
1357
- /**
1358
- * Sanitize
1359
- * Public method providing core sanitation functionality
1360
- *
1361
- * @param {String|Node} dirty string or DOM node
1362
- * @param {Object} configuration object
1363
- */
1364
- // eslint-disable-next-line complexity
1365
-
1366
-
1367
- DOMPurify.sanitize = function (dirty) {
1368
- let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1369
- let body;
1370
- let importedNode;
1371
- let currentNode;
1372
- let returnNode;
1373
- /* Make sure we have a string to sanitize.
1374
- DO NOT return early, as this will return the wrong type if
1375
- the user has requested a DOM object rather than a string */
1376
-
1377
- IS_EMPTY_INPUT = !dirty;
1378
-
1379
- if (IS_EMPTY_INPUT) {
1380
- dirty = '<!-->';
1381
- }
1382
- /* Stringify, in case dirty is an object */
1383
-
1384
-
1385
- if (typeof dirty !== 'string' && !_isNode(dirty)) {
1386
- // eslint-disable-next-line no-negated-condition
1387
- if (typeof dirty.toString !== 'function') {
1388
- throw typeErrorCreate('toString is not a function');
1389
- } else {
1390
- dirty = dirty.toString();
1391
-
1392
- if (typeof dirty !== 'string') {
1393
- throw typeErrorCreate('dirty is not a string, aborting');
1394
- }
1395
- }
1396
- }
1397
- /* Return dirty HTML if DOMPurify cannot run */
1398
-
1399
-
1400
- if (!DOMPurify.isSupported) {
1401
- return dirty;
1402
- }
1403
- /* Assign config vars */
1404
-
1405
-
1406
- if (!SET_CONFIG) {
1407
- _parseConfig(cfg);
1408
- }
1409
- /* Clean up removed elements */
1410
-
1411
-
1412
- DOMPurify.removed = [];
1413
- /* Check if dirty is correctly typed for IN_PLACE */
1414
-
1415
- if (typeof dirty === 'string') {
1416
- IN_PLACE = false;
1417
- }
1418
-
1419
- if (IN_PLACE) {
1420
- /* Do some early pre-sanitization to avoid unsafe root nodes */
1421
- if (dirty.nodeName) {
1422
- const tagName = transformCaseFunc(dirty.nodeName);
1423
-
1424
- if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {
1425
- throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');
1426
- }
1427
- }
1428
- } else if (dirty instanceof Node) {
1429
- /* If dirty is a DOM element, append to an empty document to avoid
1430
- elements being stripped by the parser */
1431
- body = _initDocument('<!---->');
1432
- importedNode = body.ownerDocument.importNode(dirty, true);
1433
-
1434
- if (importedNode.nodeType === 1 && importedNode.nodeName === 'BODY') {
1435
- /* Node is already a body, use as is */
1436
- body = importedNode;
1437
- } else if (importedNode.nodeName === 'HTML') {
1438
- body = importedNode;
1439
- } else {
1440
- // eslint-disable-next-line unicorn/prefer-dom-node-append
1441
- body.appendChild(importedNode);
1442
- }
1443
- } else {
1444
- /* Exit directly if we have nothing to do */
1445
- if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && // eslint-disable-next-line unicorn/prefer-includes
1446
- dirty.indexOf('<') === -1) {
1447
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;
1448
- }
1449
- /* Initialize the document to work on */
1450
-
1451
-
1452
- body = _initDocument(dirty);
1453
- /* Check we have a DOM node from the data */
1454
-
1455
- if (!body) {
1456
- return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';
1457
- }
1458
- }
1459
- /* Remove first element node (ours) if FORCE_BODY is set */
1460
-
1461
-
1462
- if (body && FORCE_BODY) {
1463
- _forceRemove(body.firstChild);
1464
- }
1465
- /* Get node iterator */
1466
-
1467
-
1468
- const nodeIterator = _createIterator(IN_PLACE ? dirty : body);
1469
- /* Now start iterating over the created document */
1470
-
1471
-
1472
- while (currentNode = nodeIterator.nextNode()) {
1473
- /* Sanitize tags and elements */
1474
- if (_sanitizeElements(currentNode)) {
1475
- continue;
1476
- }
1477
- /* Shadow DOM detected, sanitize it */
1478
-
1479
-
1480
- if (currentNode.content instanceof DocumentFragment) {
1481
- _sanitizeShadowDOM(currentNode.content);
1482
- }
1483
- /* Check attributes, sanitize if necessary */
1484
-
1485
-
1486
- _sanitizeAttributes(currentNode);
1487
- }
1488
- /* If we sanitized `dirty` in-place, return it. */
1489
-
1490
-
1491
- if (IN_PLACE) {
1492
- return dirty;
1493
- }
1494
- /* Return sanitized string or DOM */
1495
-
1496
-
1497
- if (RETURN_DOM) {
1498
- if (RETURN_DOM_FRAGMENT) {
1499
- returnNode = createDocumentFragment.call(body.ownerDocument);
1500
-
1501
- while (body.firstChild) {
1502
- // eslint-disable-next-line unicorn/prefer-dom-node-append
1503
- returnNode.appendChild(body.firstChild);
1504
- }
1505
- } else {
1506
- returnNode = body;
1507
- }
1508
-
1509
- if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmod) {
1510
- /*
1511
- AdoptNode() is not used because internal state is not reset
1512
- (e.g. the past names map of a HTMLFormElement), this is safe
1513
- in theory but we would rather not risk another attack vector.
1514
- The state that is cloned by importNode() is explicitly defined
1515
- by the specs.
1516
- */
1517
- returnNode = importNode.call(originalDocument, returnNode, true);
1518
39
  }
1519
-
1520
- return returnNode;
1521
- }
1522
-
1523
- let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;
1524
- /* Serialize doctype if allowed */
1525
-
1526
- if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {
1527
- serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML;
1528
- }
1529
- /* Sanitize final string template-safe */
1530
-
1531
-
1532
- if (SAFE_FOR_TEMPLATES) {
1533
- serializedHTML = stringReplace(serializedHTML, MUSTACHE_EXPR, ' ');
1534
- serializedHTML = stringReplace(serializedHTML, ERB_EXPR, ' ');
1535
- serializedHTML = stringReplace(serializedHTML, TMPLIT_EXPR, ' ');
1536
- }
1537
-
1538
- return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;
1539
- };
1540
- /**
1541
- * Public method to set the configuration once
1542
- * setConfig
1543
- *
1544
- * @param {Object} cfg configuration object
1545
- */
1546
-
1547
-
1548
- DOMPurify.setConfig = function (cfg) {
1549
- _parseConfig(cfg);
1550
-
1551
- SET_CONFIG = true;
1552
- };
1553
- /**
1554
- * Public method to remove the configuration
1555
- * clearConfig
1556
- *
1557
- */
1558
-
1559
-
1560
- DOMPurify.clearConfig = function () {
1561
- CONFIG = null;
1562
- SET_CONFIG = false;
1563
- };
1564
- /**
1565
- * Public method to check if an attribute value is valid.
1566
- * Uses last set config, if any. Otherwise, uses config defaults.
1567
- * isValidAttribute
1568
- *
1569
- * @param {string} tag Tag name of containing element.
1570
- * @param {string} attr Attribute name.
1571
- * @param {string} value Attribute value.
1572
- * @return {Boolean} Returns true if `value` is valid. Otherwise, returns false.
1573
- */
1574
-
1575
-
1576
- DOMPurify.isValidAttribute = function (tag, attr, value) {
1577
- /* Initialize shared config vars if necessary. */
1578
- if (!CONFIG) {
1579
- _parseConfig({});
1580
- }
1581
-
1582
- const lcTag = transformCaseFunc(tag);
1583
- const lcName = transformCaseFunc(attr);
1584
- return _isValidAttribute(lcTag, lcName, value);
1585
- };
1586
- /**
1587
- * AddHook
1588
- * Public method to add DOMPurify hooks
1589
- *
1590
- * @param {String} entryPoint entry point for the hook to add
1591
- * @param {Function} hookFunction function to execute
1592
- */
1593
-
1594
-
1595
- DOMPurify.addHook = function (entryPoint, hookFunction) {
1596
- if (typeof hookFunction !== 'function') {
1597
- return;
1598
- }
1599
-
1600
- hooks[entryPoint] = hooks[entryPoint] || [];
1601
- arrayPush(hooks[entryPoint], hookFunction);
1602
- };
1603
- /**
1604
- * RemoveHook
1605
- * Public method to remove a DOMPurify hook at a given entryPoint
1606
- * (pops it from the stack of hooks if more are present)
1607
- *
1608
- * @param {String} entryPoint entry point for the hook to remove
1609
- * @return {Function} removed(popped) hook
1610
- */
1611
-
1612
-
1613
- DOMPurify.removeHook = function (entryPoint) {
1614
- if (hooks[entryPoint]) {
1615
- return arrayPop(hooks[entryPoint]);
1616
- }
1617
- };
1618
- /**
1619
- * RemoveHooks
1620
- * Public method to remove all DOMPurify hooks at a given entryPoint
1621
- *
1622
- * @param {String} entryPoint entry point for the hooks to remove
1623
- */
1624
-
1625
-
1626
- DOMPurify.removeHooks = function (entryPoint) {
1627
- if (hooks[entryPoint]) {
1628
- hooks[entryPoint] = [];
1629
- }
1630
- };
1631
- /**
1632
- * RemoveAllHooks
1633
- * Public method to remove all DOMPurify hooks
1634
- *
1635
- */
1636
-
1637
-
1638
- DOMPurify.removeAllHooks = function () {
1639
- hooks = {};
1640
- };
1641
-
1642
- return DOMPurify;
40
+ });
41
+ }
42
+ n["default"] = e;
43
+ return Object.freeze(n);
1643
44
  }
1644
45
 
1645
- var purify = createDOMPurify();
46
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
47
+ var Container__default = /*#__PURE__*/_interopDefaultLegacy(Container);
48
+ var NeetoHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoHeader);
49
+ var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
50
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
51
+ var yup__namespace = /*#__PURE__*/_interopNamespace(yup);
52
+ var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
1646
53
 
1647
54
  function _typeof$1(obj) {
1648
55
  "@babel/helpers - typeof";
@@ -5284,6 +3691,7 @@ var template = {
5284
3691
  "delete": "Delete",
5285
3692
  edit: "Edit",
5286
3693
  saveChanges: "Save changes",
3694
+ send: "Send",
5287
3695
  cancel: "Cancel",
5288
3696
  emailAddress: "Email address",
5289
3697
  phoneNumber: "Phone number",
@@ -5341,45 +3749,6 @@ instance.use(Browser).use(initReactI18next).init({
5341
3749
  order: ["navigator"]
5342
3750
  }
5343
3751
  });
5344
- instance.services.formatter.addCached("boldList", function (lng, options) {
5345
- var formatter = new Intl.ListFormat(lng, options);
5346
- var sanitizer = function sanitizer(value) {
5347
- return purify.sanitize(value, {
5348
- USE_PROFILES: {
5349
- html: true
5350
- }
5351
- });
5352
- };
5353
- return function (value) {
5354
- var boldEmails = value.map(function (email) {
5355
- return "<strong>".concat(email, "</strong>");
5356
- });
5357
- var sanitizedEmails = sanitizer(boldEmails).split(",");
5358
- return formatter.format(sanitizedEmails);
5359
- };
5360
- });
5361
-
5362
- var queryClient = new reactQuery.QueryClient({
5363
- queryCache: new reactQuery.QueryCache(),
5364
- defaultOptions: {
5365
- queries: {
5366
- refetchOnWindowFocus: false,
5367
- keepPreviousData: true
5368
- }
5369
- }
5370
- });
5371
-
5372
- var withReactQuery = function withReactQuery(Component) {
5373
- var QueryWrapper = function QueryWrapper(props) {
5374
- return /*#__PURE__*/React__default["default"].createElement(reactQuery.QueryClientProvider, {
5375
- client: queryClient
5376
- }, /*#__PURE__*/React__default["default"].createElement(Component, props), /*#__PURE__*/React__default["default"].createElement(devtools.ReactQueryDevtools, {
5377
- initialIsOpen: false,
5378
- position: "bottom-right"
5379
- }));
5380
- };
5381
- return QueryWrapper;
5382
- };
5383
3752
 
5384
3753
  var MESSAGE_TEMPLATES = {
5385
3754
  email: {
@@ -5413,10 +3782,9 @@ var MESSAGE_TEMPLATE_INITIAL_STATE = {
5413
3782
  template: {}
5414
3783
  };
5415
3784
  var DEFAULT_PAGE_SIZE = 10;
5416
- var DEFAULT_PAGE_INDEX = 1;
5417
3785
  var DEFAULT_PAGE_PROPERTIES = {
5418
3786
  size: DEFAULT_PAGE_SIZE,
5419
- index: DEFAULT_PAGE_INDEX
3787
+ index: constants.DEFAULT_PAGE_INDEX
5420
3788
  };
5421
3789
 
5422
3790
  var MESSAGE_TEMPLATE_BASE_URL = "/neeto_message_templates_engine/api/v1/message_templates";
@@ -5426,18 +3794,31 @@ var fetchMessageTemplates = function fetchMessageTemplates(params) {
5426
3794
  params: params
5427
3795
  });
5428
3796
  };
5429
- var createMessageTemplate = function createMessageTemplate(params) {
3797
+ var createMessageTemplate = function createMessageTemplate(_ref) {
3798
+ var messageTemplate = _ref.messageTemplate,
3799
+ ownerId = _ref.ownerId;
5430
3800
  return axios__default["default"].post(MESSAGE_TEMPLATE_BASE_URL, {
5431
- messageTemplate: params
3801
+ messageTemplate: messageTemplate,
3802
+ ownerId: ownerId
5432
3803
  });
5433
3804
  };
5434
- var updateMessageTemplate = function updateMessageTemplate(id, params) {
3805
+ var updateMessageTemplate = function updateMessageTemplate(_ref2) {
3806
+ var id = _ref2.id,
3807
+ messageTemplate = _ref2.messageTemplate,
3808
+ ownerId = _ref2.ownerId;
5435
3809
  return axios__default["default"].patch("".concat(MESSAGE_TEMPLATE_BASE_URL, "/").concat(id), {
5436
- messageTemplate: params
3810
+ messageTemplate: messageTemplate,
3811
+ ownerId: ownerId
5437
3812
  });
5438
3813
  };
5439
- var deleteMessageTemplate = function deleteMessageTemplate(id) {
5440
- return axios__default["default"]["delete"]("".concat(MESSAGE_TEMPLATE_BASE_URL, "/").concat(id));
3814
+ var deleteMessageTemplate = function deleteMessageTemplate(_ref3) {
3815
+ var id = _ref3.id,
3816
+ ownerId = _ref3.ownerId;
3817
+ return axios__default["default"]["delete"]("".concat(MESSAGE_TEMPLATE_BASE_URL, "/").concat(id), {
3818
+ data: {
3819
+ ownerId: ownerId
3820
+ }
3821
+ });
5441
3822
  };
5442
3823
  var messageTemplatesApi = {
5443
3824
  fetchAll: fetchMessageTemplates,
@@ -5447,45 +3828,49 @@ var messageTemplatesApi = {
5447
3828
  };
5448
3829
 
5449
3830
  var QUERY_KEYS = {
5450
- MESSAGE_TEMPLATE: "message-templates"
3831
+ NEETO_MESSAGE_TEMPLATES: "neeto-message-templates"
5451
3832
  };
5452
3833
 
3834
+ var ownerIdValue = function ownerIdValue(ownerId) {
3835
+ return ramda.isEmpty(ownerId) ? undefined : ownerId;
3836
+ };
5453
3837
  var useFetchTemplates = function useFetchTemplates(params) {
5454
- return reactQuery.useQuery([QUERY_KEYS.MESSAGE_TEMPLATE, params], function () {
3838
+ return reactQuery.useQuery([QUERY_KEYS.NEETO_MESSAGE_TEMPLATES, params], function () {
5455
3839
  return messageTemplatesApi.fetchAll(params);
5456
3840
  });
5457
3841
  };
5458
- var useCreateTemplate = function useCreateTemplate(options) {
5459
- var queryClient = reactQuery.useQueryClient();
5460
- return reactQuery.useMutation(function (payload) {
5461
- return messageTemplatesApi.create(payload);
3842
+ var useCreateTemplate = function useCreateTemplate(ownerId, options) {
3843
+ return reactUtils.useMutationWithInvalidation(function (messageTemplate) {
3844
+ return messageTemplatesApi.create({
3845
+ messageTemplate: messageTemplate,
3846
+ ownerId: ownerIdValue(ownerId)
3847
+ });
5462
3848
  }, {
5463
- onSuccess: function onSuccess() {
5464
- queryClient.invalidateQueries(QUERY_KEYS.MESSAGE_TEMPLATE);
5465
- options === null || options === void 0 ? void 0 : options.onSuccess();
5466
- }
3849
+ keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES],
3850
+ onSuccess: options === null || options === void 0 ? void 0 : options.onSuccess
5467
3851
  });
5468
3852
  };
5469
- var useUpdateTemplate = function useUpdateTemplate() {
5470
- var queryClient = reactQuery.useQueryClient();
5471
- return reactQuery.useMutation(function (_ref) {
3853
+ var useUpdateTemplate = function useUpdateTemplate(ownerId) {
3854
+ return reactUtils.useMutationWithInvalidation(function (_ref) {
5472
3855
  var id = _ref.id,
5473
3856
  payload = _ref.payload;
5474
- return messageTemplatesApi.update(id, payload);
3857
+ return messageTemplatesApi.update({
3858
+ id: id,
3859
+ messageTemplate: payload,
3860
+ ownerId: ownerIdValue(ownerId)
3861
+ });
5475
3862
  }, {
5476
- onSuccess: function onSuccess() {
5477
- queryClient.invalidateQueries(QUERY_KEYS.MESSAGE_TEMPLATE);
5478
- }
3863
+ keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
5479
3864
  });
5480
3865
  };
5481
- var useDeleteTemplate = function useDeleteTemplate() {
5482
- var queryClient = reactQuery.useQueryClient();
5483
- return reactQuery.useMutation(function (id) {
5484
- return messageTemplatesApi["delete"](id);
3866
+ var useDeleteTemplate = function useDeleteTemplate(ownerId) {
3867
+ return reactUtils.useMutationWithInvalidation(function (id) {
3868
+ return messageTemplatesApi["delete"]({
3869
+ id: id,
3870
+ ownerId: ownerIdValue(ownerId)
3871
+ });
5485
3872
  }, {
5486
- onSuccess: function onSuccess() {
5487
- queryClient.invalidateQueries(QUERY_KEYS.MESSAGE_TEMPLATE);
5488
- }
3873
+ keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
5489
3874
  });
5490
3875
  };
5491
3876
 
@@ -5501,10 +3886,11 @@ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if
5501
3886
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5502
3887
  var RowActions = function RowActions(_ref) {
5503
3888
  var template = _ref.template,
5504
- setManageTemplatePane = _ref.setManageTemplatePane;
3889
+ setManageTemplatePane = _ref.setManageTemplatePane,
3890
+ ownerId = _ref.ownerId;
5505
3891
  var _useTranslation = useTranslation(),
5506
3892
  t = _useTranslation.t;
5507
- var _useUpdateTemplate = useUpdateTemplate(),
3893
+ var _useUpdateTemplate = useUpdateTemplate(ownerId),
5508
3894
  update = _useUpdateTemplate.mutate;
5509
3895
  var Menu = neetoui.Dropdown.Menu,
5510
3896
  MenuItem = neetoui.Dropdown.MenuItem;
@@ -5562,7 +3948,7 @@ var renderSearchProps = function renderSearchProps(label, setSearchTerm, searchT
5562
3948
  value: searchTerm
5563
3949
  };
5564
3950
  };
5565
- var buildTableColumnData = function buildTableColumnData(setManageTemplatePane) {
3951
+ var buildTableColumnData = function buildTableColumnData(setManageTemplatePane, ownerId) {
5566
3952
  return [{
5567
3953
  dataIndex: "name",
5568
3954
  key: "name",
@@ -5576,6 +3962,7 @@ var buildTableColumnData = function buildTableColumnData(setManageTemplatePane)
5576
3962
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
5577
3963
  style: "body2"
5578
3964
  }, name), /*#__PURE__*/React__default["default"].createElement(RowActions, {
3965
+ ownerId: ownerId,
5579
3966
  setManageTemplatePane: setManageTemplatePane,
5580
3967
  template: template
5581
3968
  }));
@@ -6240,7 +4627,7 @@ var useFilters = function useFilters() {
6240
4627
  };
6241
4628
  };
6242
4629
 
6243
- var useTemplates = function useTemplates(type) {
4630
+ var useTemplates = function useTemplates(type, ownerId) {
6244
4631
  var _useState = React.useState(neetoFiltersFrontend.buildFiltersFromURL(buildTableColumnData().filter(ramda.prop("node")))),
6245
4632
  _useState2 = _slicedToArray(_useState, 2),
6246
4633
  filters = _useState2[0],
@@ -6255,16 +4642,17 @@ var useTemplates = function useTemplates(type) {
6255
4642
  pageIndex: pageIndex,
6256
4643
  pageSize: pageSize,
6257
4644
  filters: JSON.stringify(filters),
6258
- templateType: MESSAGE_TEMPLATES[type].value
4645
+ templateType: MESSAGE_TEMPLATES[type].value,
4646
+ ownerId: ramda.isEmpty(ownerId) ? undefined : ownerId
6259
4647
  };
6260
4648
  var _useFetchTemplates = useFetchTemplates(templateParams),
6261
4649
  _useFetchTemplates$da = _useFetchTemplates.data,
6262
4650
  templatesData = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
6263
4651
  isLoadingTemplates = _useFetchTemplates.isLoading,
6264
4652
  isFetching = _useFetchTemplates.isFetching;
6265
- var _useCreateTemplate = useCreateTemplate(),
4653
+ var _useCreateTemplate = useCreateTemplate(ownerId),
6266
4654
  create = _useCreateTemplate.mutate;
6267
- var _useUpdateTemplate = useUpdateTemplate(),
4655
+ var _useUpdateTemplate = useUpdateTemplate(ownerId),
6268
4656
  update = _useUpdateTemplate.mutate;
6269
4657
  var createUpdateTemplate = function createUpdateTemplate(_ref, options) {
6270
4658
  var isEdit = _ref.isEdit,
@@ -6298,10 +4686,11 @@ var List = function List(_ref) {
6298
4686
  pageProperties = _ref.pageProperties,
6299
4687
  label = _ref.label,
6300
4688
  addText = _ref.addText,
6301
- isFilterApplied = _ref.isFilterApplied;
4689
+ isFilterApplied = _ref.isFilterApplied,
4690
+ ownerId = _ref.ownerId;
6302
4691
  var _useTranslation = useTranslation(),
6303
4692
  t = _useTranslation.t;
6304
- var _useDeleteTemplate = useDeleteTemplate(),
4693
+ var _useDeleteTemplate = useDeleteTemplate(ownerId),
6305
4694
  deleteTemplate = _useDeleteTemplate.mutate,
6306
4695
  isDeleting = _useDeleteTemplate.isLoading;
6307
4696
  var templates = templatesData.templates,
@@ -6322,7 +4711,7 @@ var List = function List(_ref) {
6322
4711
  }, !ramda.isEmpty(templates) ? /*#__PURE__*/React__default["default"].createElement(TableWrapper__default["default"], {
6323
4712
  hasPagination: totalCount > pageSize
6324
4713
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Table, {
6325
- columnData: buildTableColumnData(setManageTemplatePane),
4714
+ columnData: buildTableColumnData(setManageTemplatePane, ownerId),
6326
4715
  currentPageNumber: pageIndex,
6327
4716
  defaultPageSize: pageSize,
6328
4717
  loading: isLoading,
@@ -6384,7 +4773,9 @@ var MessageTemplates = function MessageTemplates(_ref) {
6384
4773
  _ref$shouldIncludeTes = _ref.shouldIncludeTestTemplate,
6385
4774
  shouldIncludeTestTemplate = _ref$shouldIncludeTes === void 0 ? true : _ref$shouldIncludeTes,
6386
4775
  _ref$templateVariable = _ref.templateVariables,
6387
- templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable;
4776
+ templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
4777
+ _ref$ownerId = _ref.ownerId,
4778
+ ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId;
6388
4779
  var _useState = React.useState(MESSAGE_TEMPLATE_INITIAL_STATE),
6389
4780
  _useState2 = _slicedToArray(_useState, 2),
6390
4781
  manageTemplatePane = _useState2[0],
@@ -6398,7 +4789,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
6398
4789
  filterColumns = _useFilters.filterColumns,
6399
4790
  setSearchTerm = _useFilters.setSearchTerm,
6400
4791
  searchTerm = _useFilters.searchTerm;
6401
- var _useTemplates = useTemplates(type),
4792
+ var _useTemplates = useTemplates(type, ownerId),
6402
4793
  isLoading = _useTemplates.isLoading,
6403
4794
  templatesData = _useTemplates.templatesData,
6404
4795
  createUpdateTemplate = _useTemplates.createUpdateTemplate,
@@ -6459,6 +4850,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
6459
4850
  label: label,
6460
4851
  labelSingular: labelSingular,
6461
4852
  manageTemplatePane: manageTemplatePane,
4853
+ ownerId: ownerId,
6462
4854
  pageProperties: pageProperties,
6463
4855
  setManageTemplatePane: setManageTemplatePane,
6464
4856
  setPageProperties: setPageProperties,
@@ -6477,7 +4869,6 @@ var MessageTemplates = function MessageTemplates(_ref) {
6477
4869
  }
6478
4870
  }));
6479
4871
  };
6480
- var index$1 = withReactQuery(MessageTemplates);
6481
4872
 
6482
4873
  var formatEditorContent = function formatEditorContent(value) {
6483
4874
  return value === null || value === void 0 ? void 0 : value.replaceAll(/<\/?(?!img)\w*\b[^>]*>/gi, "").trim();
@@ -6506,18 +4897,19 @@ var WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA = yup__namespace.object().shape({
6506
4897
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6507
4898
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6508
4899
  var EmailAndSms = function EmailAndSms(_ref) {
6509
- var isEmailTemplate = _ref.isEmailTemplate,
6510
- onClose = _ref.onClose,
4900
+ var onClose = _ref.onClose,
6511
4901
  templates = _ref.templates,
6512
- handleSubmit = _ref.handleSubmit,
6513
4902
  setInitialFocusField = _ref.setInitialFocusField,
6514
4903
  templateVariables = _ref.templateVariables,
6515
4904
  customFields = _ref.customFields,
6516
4905
  customFieldsInitialValues = _ref.customFieldsInitialValues,
6517
- customFieldsValidationSchema = _ref.customFieldsValidationSchema;
4906
+ customFieldsValidationSchema = _ref.customFieldsValidationSchema,
4907
+ type = _ref.type,
4908
+ handleSubmit = _ref.handleSubmit;
6518
4909
  var editorRef = React.useRef(null);
6519
4910
  var _useTranslation = useTranslation(),
6520
4911
  t = _useTranslation.t;
4912
+ var isEmailTemplate = type === "email";
6521
4913
  var _ref2 = isEmailTemplate ? [SEND_MESSAGE_INITIAL_VALUES, EMAIL_MESSAGE_FORM_SCHEMA] : [ramda.pick(["body"], SEND_MESSAGE_INITIAL_VALUES), SMS_MESSAGE_FORM_VALIDATION_SCHEMA],
6522
4914
  _ref3 = _slicedToArray(_ref2, 2),
6523
4915
  INITIAL_VALUES = _ref3[0],
@@ -6536,8 +4928,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
6536
4928
  onSubmit: handleSubmit
6537
4929
  }
6538
4930
  }, function (_ref4) {
6539
- var dirty = _ref4.dirty,
6540
- isSubmitting = _ref4.isSubmitting,
4931
+ var isSubmitting = _ref4.isSubmitting,
6541
4932
  setValues = _ref4.setValues,
6542
4933
  values = _ref4.values;
6543
4934
  var handleTemplateChange = function handleTemplateChange(value) {
@@ -6554,15 +4945,11 @@ var EmailAndSms = function EmailAndSms(_ref) {
6554
4945
  isSearchable: true,
6555
4946
  innerRef: setInitialFocusField,
6556
4947
  label: t("template.title"),
4948
+ options: pure.renameKeys({
4949
+ name: "label",
4950
+ id: "value"
4951
+ }, templates),
6557
4952
  placeholder: t("sendMessage.selectTemplate"),
6558
- options: templates.map(function (_ref5) {
6559
- var name = _ref5.name,
6560
- id = _ref5.id;
6561
- return {
6562
- label: name,
6563
- value: id
6564
- };
6565
- }),
6566
4953
  onChange: handleTemplateChange
6567
4954
  }), customFields, isEmailTemplate && /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
6568
4955
  required: true,
@@ -6581,8 +4968,8 @@ var EmailAndSms = function EmailAndSms(_ref) {
6581
4968
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
6582
4969
  className: "absolute bottom-0 left-0 flex gap-x-2"
6583
4970
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
6584
- disabled: !dirty || isSubmitting,
6585
- label: t("template.saveChanges"),
4971
+ disabled: isSubmitting,
4972
+ label: t("template.send"),
6586
4973
  loading: isSubmitting,
6587
4974
  type: "submit"
6588
4975
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Button, {
@@ -6642,8 +5029,7 @@ var Whatsapp = function Whatsapp(_ref) {
6642
5029
  onSubmit: handleSubmit
6643
5030
  }
6644
5031
  }, function (_ref3) {
6645
- var dirty = _ref3.dirty,
6646
- isSubmitting = _ref3.isSubmitting,
5032
+ var isSubmitting = _ref3.isSubmitting,
6647
5033
  values = _ref3.values,
6648
5034
  setValues = _ref3.setValues;
6649
5035
  var handleTemplateChange = function handleTemplateChange(value) {
@@ -6665,14 +5051,10 @@ var Whatsapp = function Whatsapp(_ref) {
6665
5051
  defaultValue: initialFormValues.selectedTemplate,
6666
5052
  label: t("template.title"),
6667
5053
  name: "selectedTemplate",
6668
- options: templates.map(function (_ref4) {
6669
- var name = _ref4.name,
6670
- id = _ref4.id;
6671
- return {
6672
- label: name,
6673
- value: id
6674
- };
6675
- }),
5054
+ options: pure.renameKeys({
5055
+ name: "label",
5056
+ id: "value"
5057
+ }, templates),
6676
5058
  onChange: handleTemplateChange
6677
5059
  }), /*#__PURE__*/React__default["default"].createElement(neetoui.Textarea, {
6678
5060
  disabled: true,
@@ -6700,8 +5082,8 @@ var Whatsapp = function Whatsapp(_ref) {
6700
5082
  })), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Footer, {
6701
5083
  className: "absolute bottom-0 left-0 flex gap-x-2"
6702
5084
  }, /*#__PURE__*/React__default["default"].createElement(formik$1.Button, {
6703
- disabled: !dirty || isSubmitting,
6704
- label: t("template.saveChanges"),
5085
+ disabled: isSubmitting,
5086
+ label: t("template.send"),
6705
5087
  loading: isSubmitting,
6706
5088
  type: "submit"
6707
5089
  }), /*#__PURE__*/React__default["default"].createElement(formik$1.Button, {
@@ -6729,7 +5111,9 @@ var SendMessagePane = function SendMessagePane(_ref) {
6729
5111
  _ref$customFieldsVali = _ref.customFieldsValidationSchema,
6730
5112
  customFieldsValidationSchema = _ref$customFieldsVali === void 0 ? {} : _ref$customFieldsVali,
6731
5113
  _ref$templateVariable = _ref.templateVariables,
6732
- templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable;
5114
+ templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
5115
+ _ref$ownerId = _ref.ownerId,
5116
+ ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId;
6733
5117
  var _useTranslation = useTranslation(),
6734
5118
  t = _useTranslation.t;
6735
5119
  var initialFocusField = React.useRef();
@@ -6737,17 +5121,17 @@ var SendMessagePane = function SendMessagePane(_ref) {
6737
5121
  return initialFocusField.current = fieldRef;
6738
5122
  };
6739
5123
  var value = MESSAGE_TEMPLATES[type].value;
5124
+ var isWhatsappTemplate = type === "whatsapp";
6740
5125
  var templateParams = {
6741
5126
  status: "active",
6742
- templateType: value
5127
+ templateType: value,
5128
+ ownerId: ownerId
6743
5129
  };
6744
5130
  var _useFetchTemplates = useFetchTemplates(templateParams),
6745
5131
  _useFetchTemplates$da = _useFetchTemplates.data,
6746
5132
  _useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
6747
5133
  _useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
6748
5134
  templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3;
6749
- var isEmailTemplate = type === "email";
6750
- var isWhatsappTemplate = type === "whatsapp";
6751
5135
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Pane, {
6752
5136
  initialFocusRef: initialFocusField,
6753
5137
  isOpen: isOpen,
@@ -6757,22 +5141,21 @@ var SendMessagePane = function SendMessagePane(_ref) {
6757
5141
  weight: "semibold"
6758
5142
  }, t("common.send"), " ", type)), /*#__PURE__*/React__default["default"].createElement(neetoui.Pane.Body, null, isWhatsappTemplate ? /*#__PURE__*/React__default["default"].createElement(Whatsapp, {
6759
5143
  handleSubmit: handleSubmit,
6760
- templates: templates,
6761
- onClose: onClose
5144
+ onClose: onClose,
5145
+ templates: templates
6762
5146
  }) : /*#__PURE__*/React__default["default"].createElement(EmailAndSms, {
6763
5147
  customFields: customFields,
6764
5148
  customFieldsInitialValues: customFieldsInitialValues,
6765
5149
  customFieldsValidationSchema: customFieldsValidationSchema,
6766
5150
  handleSubmit: handleSubmit,
6767
- isEmailTemplate: isEmailTemplate,
5151
+ onClose: onClose,
6768
5152
  setInitialFocusField: setInitialFocusField,
6769
5153
  templateVariables: templateVariables,
6770
5154
  templates: templates,
6771
- onClose: onClose
5155
+ type: type
6772
5156
  })));
6773
5157
  };
6774
- var index = withReactQuery(SendMessagePane);
6775
5158
 
6776
- exports.MessageTemplates = index$1;
6777
- exports.SendMessagePane = index;
5159
+ exports.MessageTemplates = MessageTemplates;
5160
+ exports.SendMessagePane = SendMessagePane;
6778
5161
  //# sourceMappingURL=index.cjs.js.map