PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0
Elementor Website Builder – more than just a page builder v4.3.0
4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 All 455 releases
elementor / assets / js / ai-media-library.js

ai-media-library.js in Elementor Website Builder – more than just a page builder 4.3.0, at assets/js/ai-media-library.js

30,678 lines 1.0 MB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(react, _wordpress_i18n, _elementor_ui, _elementor_icons, _elementor_ui_TextField) {
2
3 //#region \0rolldown/runtime.js
4 var __create = Object.create;
5 var __defProp = Object.defineProperty;
6 var __name = (target, value) => __defProp(target, "name", {
7 value,
8 configurable: true
9 });
10 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11 var __getOwnPropNames = Object.getOwnPropertyNames;
12 var __getProtoOf = Object.getPrototypeOf;
13 var __hasOwnProp = Object.prototype.hasOwnProperty;
14 var __esmMin = (fn, res, err) => () => {
15 if (err) throw err[0];
16 try {
17 return fn && (res = fn(fn = 0)), res;
18 } catch (e) {
19 throw err = [e], e;
20 }
21 };
22 var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
23 var __exportAll = (all, no_symbols) => {
24 let target = {};
25 for (var name in all) {
26 __defProp(target, name, {
27 get: all[name],
28 enumerable: true
29 });
30 }
31 if (!no_symbols) {
32 __defProp(target, Symbol.toStringTag, { value: "Module" });
33 }
34 return target;
35 };
36 var __copyProps = (to, from, except, desc) => {
37 if (from && typeof from === "object" || typeof from === "function") {
38 for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
39 key = keys[i];
40 if (!__hasOwnProp.call(to, key) && key !== except) {
41 __defProp(to, key, {
42 get: ((k) => from[k]).bind(null, key),
43 enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44 });
45 }
46 }
47 }
48 return to;
49 };
50 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
51 value: mod,
52 enumerable: true
53 }) : target, mod));
54
55 //#endregion
56 let react$1 = __toESM(react, 1);
57 react = __toESM(react);
58 _elementor_ui_TextField = __toESM(_elementor_ui_TextField);
59
60 //#region node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
61 function _arrayWithHoles(r) {
62 if (Array.isArray(r)) return r;
63 }
64 var init_arrayWithHoles = __esmMin((() => {}));
65
66 //#endregion
67 //#region node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
68 function _iterableToArrayLimit(r, l) {
69 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
70 if (null != t) {
71 var e;
72 var n;
73 var i;
74 var u;
75 var a = [];
76 var f = !0;
77 var o = !1;
78 try {
79 if (i = (t = t.call(r)).next, 0 === l) {
80 if (Object(t) !== t) return;
81 f = !1;
82 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
83 } catch (r) {
84 o = !0, n = r;
85 } finally {
86 try {
87 if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return;
88 } finally {
89 if (o) throw n;
90 }
91 }
92 return a;
93 }
94 }
95 var init_iterableToArrayLimit = __esmMin((() => {}));
96
97 //#endregion
98 //#region node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
99 function _arrayLikeToArray$2(r, a) {
100 (null == a || a > r.length) && (a = r.length);
101 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
102 return n;
103 }
104 var init_arrayLikeToArray = __esmMin((() => {
105 __name(_arrayLikeToArray$2, "_arrayLikeToArray");
106 }));
107
108 //#endregion
109 //#region node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
110 function _unsupportedIterableToArray$2(r, a) {
111 if (r) {
112 if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
113 var t = {}.toString.call(r).slice(8, -1);
114 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
115 }
116 }
117 var init_unsupportedIterableToArray = __esmMin((() => {
118 init_arrayLikeToArray();
119 __name(_unsupportedIterableToArray$2, "_unsupportedIterableToArray");
120 }));
121
122 //#endregion
123 //#region node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
124 function _nonIterableRest() {
125 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
126 }
127 var init_nonIterableRest = __esmMin((() => {}));
128
129 //#endregion
130 //#region node_modules/@babel/runtime/helpers/esm/slicedToArray.js
131 function _slicedToArray(r, e) {
132 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest();
133 }
134 var init_slicedToArray = __esmMin((() => {
135 init_arrayWithHoles();
136 init_iterableToArrayLimit();
137 init_unsupportedIterableToArray();
138 init_nonIterableRest();
139 }));
140
141 //#endregion
142 //#region node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js
143 init_slicedToArray();
144 function _taggedTemplateLiteral(e, t) {
145 return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } }));
146 }
147
148 //#endregion
149 //#region node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js
150 /** @license React v16.13.1
151 * react-is.development.js
152 *
153 * Copyright (c) Facebook, Inc. and its affiliates.
154 *
155 * This source code is licensed under the MIT license found in the
156 * LICENSE file in the root directory of this source tree.
157 */
158 var require_react_is_development$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
159 (function() {
160 "use strict";
161 var hasSymbol = typeof Symbol === "function" && Symbol.for;
162 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103;
163 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106;
164 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107;
165 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108;
166 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114;
167 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109;
168 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110;
169 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111;
170 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111;
171 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112;
172 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113;
173 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120;
174 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115;
175 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116;
176 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121;
177 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117;
178 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118;
179 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
180 function isValidElementType(type) {
181 return typeof type === "string" || typeof type === "function" || type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
182 }
183 function typeOf(object) {
184 if (typeof object === "object" && object !== null) {
185 var $$typeof = object.$$typeof;
186 switch ($$typeof) {
187 case REACT_ELEMENT_TYPE:
188 var type = object.type;
189 switch (type) {
190 case REACT_ASYNC_MODE_TYPE:
191 case REACT_CONCURRENT_MODE_TYPE:
192 case REACT_FRAGMENT_TYPE:
193 case REACT_PROFILER_TYPE:
194 case REACT_STRICT_MODE_TYPE:
195 case REACT_SUSPENSE_TYPE: return type;
196 default:
197 var $$typeofType = type && type.$$typeof;
198 switch ($$typeofType) {
199 case REACT_CONTEXT_TYPE:
200 case REACT_FORWARD_REF_TYPE:
201 case REACT_LAZY_TYPE:
202 case REACT_MEMO_TYPE:
203 case REACT_PROVIDER_TYPE: return $$typeofType;
204 default: return $$typeof;
205 }
206 }
207 case REACT_PORTAL_TYPE: return $$typeof;
208 }
209 }
210 }
211 var AsyncMode = REACT_ASYNC_MODE_TYPE;
212 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
213 var ContextConsumer = REACT_CONTEXT_TYPE;
214 var ContextProvider = REACT_PROVIDER_TYPE;
215 var Element = REACT_ELEMENT_TYPE;
216 var ForwardRef = REACT_FORWARD_REF_TYPE;
217 var Fragment = REACT_FRAGMENT_TYPE;
218 var Lazy = REACT_LAZY_TYPE;
219 var Memo = REACT_MEMO_TYPE;
220 var Portal = REACT_PORTAL_TYPE;
221 var Profiler = REACT_PROFILER_TYPE;
222 var StrictMode = REACT_STRICT_MODE_TYPE;
223 var Suspense = REACT_SUSPENSE_TYPE;
224 var hasWarnedAboutDeprecatedIsAsyncMode = false;
225 function isAsyncMode(object) {
226 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
227 hasWarnedAboutDeprecatedIsAsyncMode = true;
228 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
229 }
230 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
231 }
232 function isConcurrentMode(object) {
233 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
234 }
235 function isContextConsumer(object) {
236 return typeOf(object) === REACT_CONTEXT_TYPE;
237 }
238 function isContextProvider(object) {
239 return typeOf(object) === REACT_PROVIDER_TYPE;
240 }
241 function isElement(object) {
242 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
243 }
244 function isForwardRef(object) {
245 return typeOf(object) === REACT_FORWARD_REF_TYPE;
246 }
247 function isFragment(object) {
248 return typeOf(object) === REACT_FRAGMENT_TYPE;
249 }
250 function isLazy(object) {
251 return typeOf(object) === REACT_LAZY_TYPE;
252 }
253 function isMemo(object) {
254 return typeOf(object) === REACT_MEMO_TYPE;
255 }
256 function isPortal(object) {
257 return typeOf(object) === REACT_PORTAL_TYPE;
258 }
259 function isProfiler(object) {
260 return typeOf(object) === REACT_PROFILER_TYPE;
261 }
262 function isStrictMode(object) {
263 return typeOf(object) === REACT_STRICT_MODE_TYPE;
264 }
265 function isSuspense(object) {
266 return typeOf(object) === REACT_SUSPENSE_TYPE;
267 }
268 exports.AsyncMode = AsyncMode;
269 exports.ConcurrentMode = ConcurrentMode;
270 exports.ContextConsumer = ContextConsumer;
271 exports.ContextProvider = ContextProvider;
272 exports.Element = Element;
273 exports.ForwardRef = ForwardRef;
274 exports.Fragment = Fragment;
275 exports.Lazy = Lazy;
276 exports.Memo = Memo;
277 exports.Portal = Portal;
278 exports.Profiler = Profiler;
279 exports.StrictMode = StrictMode;
280 exports.Suspense = Suspense;
281 exports.isAsyncMode = isAsyncMode;
282 exports.isConcurrentMode = isConcurrentMode;
283 exports.isContextConsumer = isContextConsumer;
284 exports.isContextProvider = isContextProvider;
285 exports.isElement = isElement;
286 exports.isForwardRef = isForwardRef;
287 exports.isFragment = isFragment;
288 exports.isLazy = isLazy;
289 exports.isMemo = isMemo;
290 exports.isPortal = isPortal;
291 exports.isProfiler = isProfiler;
292 exports.isStrictMode = isStrictMode;
293 exports.isSuspense = isSuspense;
294 exports.isValidElementType = isValidElementType;
295 exports.typeOf = typeOf;
296 })();
297 }));
298
299 //#endregion
300 //#region node_modules/prop-types/node_modules/react-is/index.js
301 var require_react_is$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
302 module.exports = require_react_is_development$1();
303 }));
304
305 //#endregion
306 //#region node_modules/object-assign/index.js
307 /*
308 object-assign
309 (c) Sindre Sorhus
310 @license MIT
311 */
312 var require_object_assign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
313 var getOwnPropertySymbols = Object.getOwnPropertySymbols;
314 var hasOwnProperty = Object.prototype.hasOwnProperty;
315 var propIsEnumerable = Object.prototype.propertyIsEnumerable;
316 function toObject(val) {
317 if (val === null || val === void 0) throw new TypeError("Object.assign cannot be called with null or undefined");
318 return Object(val);
319 }
320 function shouldUseNative() {
321 try {
322 if (!Object.assign) return false;
323 var test1 = /* @__PURE__ */ new String("abc");
324 test1[5] = "de";
325 if (Object.getOwnPropertyNames(test1)[0] === "5") return false;
326 var test2 = {};
327 for (var i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
328 if (Object.getOwnPropertyNames(test2).map(function(n) {
329 return test2[n];
330 }).join("") !== "0123456789") return false;
331 var test3 = {};
332 "abcdefghijklmnopqrst".split("").forEach(function(letter) {
333 test3[letter] = letter;
334 });
335 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") return false;
336 return true;
337 } catch (err) {
338 return false;
339 }
340 }
341 module.exports = shouldUseNative() ? Object.assign : function(target, source) {
342 var from;
343 var to = toObject(target);
344 var symbols;
345 for (var s = 1; s < arguments.length; s++) {
346 from = Object(arguments[s]);
347 for (var key in from) if (hasOwnProperty.call(from, key)) to[key] = from[key];
348 if (getOwnPropertySymbols) {
349 symbols = getOwnPropertySymbols(from);
350 for (var i = 0; i < symbols.length; i++) if (propIsEnumerable.call(from, symbols[i])) to[symbols[i]] = from[symbols[i]];
351 }
352 }
353 return to;
354 };
355 }));
356
357 //#endregion
358 //#region node_modules/prop-types/lib/ReactPropTypesSecret.js
359 /**
360 * Copyright (c) 2013-present, Facebook, Inc.
361 *
362 * This source code is licensed under the MIT license found in the
363 * LICENSE file in the root directory of this source tree.
364 */
365 var require_ReactPropTypesSecret = /* @__PURE__ */ __commonJSMin(((exports, module) => {
366 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
367 module.exports = ReactPropTypesSecret;
368 }));
369
370 //#endregion
371 //#region node_modules/prop-types/lib/has.js
372 var require_has = /* @__PURE__ */ __commonJSMin(((exports, module) => {
373 module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
374 }));
375
376 //#endregion
377 //#region node_modules/prop-types/checkPropTypes.js
378 /**
379 * Copyright (c) 2013-present, Facebook, Inc.
380 *
381 * This source code is licensed under the MIT license found in the
382 * LICENSE file in the root directory of this source tree.
383 */
384 var require_checkPropTypes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
385 var printWarning = function() {};
386 var ReactPropTypesSecret = require_ReactPropTypesSecret();
387 var loggedTypeFailures = {};
388 var has = require_has();
389 printWarning = function(text) {
390 var message = "Warning: " + text;
391 if (typeof console !== "undefined") console.error(message);
392 try {
393 throw new Error(message);
394 } catch (x) {}
395 };
396 /**
397 * Assert that the values match with the type specs.
398 * Error messages are memorized and will only be shown once.
399 *
400 * @param {object} typeSpecs Map of name to a ReactPropType
401 * @param {object} values Runtime values that need to be type-checked
402 * @param {string} location e.g. "prop", "context", "child context"
403 * @param {string} componentName Name of the component for error messages.
404 * @param {?Function} getStack Returns the component stack.
405 * @private
406 */
407 function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
408 for (var typeSpecName in typeSpecs) if (has(typeSpecs, typeSpecName)) {
409 var error;
410 try {
411 if (typeof typeSpecs[typeSpecName] !== "function") {
412 var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
413 err.name = "Invariant Violation";
414 throw err;
415 }
416 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
417 } catch (ex) {
418 error = ex;
419 }
420 if (error && !(error instanceof Error)) printWarning((componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).");
421 if (error instanceof Error && !(error.message in loggedTypeFailures)) {
422 loggedTypeFailures[error.message] = true;
423 var stack = getStack ? getStack() : "";
424 printWarning("Failed " + location + " type: " + error.message + (stack != null ? stack : ""));
425 }
426 }
427 }
428 /**
429 * Resets warning cache when testing.
430 *
431 * @private
432 */
433 checkPropTypes.resetWarningCache = function() {
434 loggedTypeFailures = {};
435 };
436 module.exports = checkPropTypes;
437 }));
438
439 //#endregion
440 //#region node_modules/prop-types/factoryWithTypeCheckers.js
441 /**
442 * Copyright (c) 2013-present, Facebook, Inc.
443 *
444 * This source code is licensed under the MIT license found in the
445 * LICENSE file in the root directory of this source tree.
446 */
447 var require_factoryWithTypeCheckers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
448 var ReactIs = require_react_is$1();
449 var assign = require_object_assign();
450 var ReactPropTypesSecret = require_ReactPropTypesSecret();
451 var has = require_has();
452 var checkPropTypes = require_checkPropTypes();
453 var printWarning = function() {};
454 printWarning = function(text) {
455 var message = "Warning: " + text;
456 if (typeof console !== "undefined") console.error(message);
457 try {
458 throw new Error(message);
459 } catch (x) {}
460 };
461 function emptyFunctionThatReturnsNull() {
462 return null;
463 }
464 module.exports = function(isValidElement, throwOnDirectAccess) {
465 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
466 var FAUX_ITERATOR_SYMBOL = "@@iterator";
467 /**
468 * Returns the iterator method function contained on the iterable object.
469 *
470 * Be sure to invoke the function with the iterable as context:
471 *
472 * var iteratorFn = getIteratorFn(myIterable);
473 * if (iteratorFn) {
474 * var iterator = iteratorFn.call(myIterable);
475 * ...
476 * }
477 *
478 * @param {?object} maybeIterable
479 * @return {?function}
480 */
481 function getIteratorFn(maybeIterable) {
482 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
483 if (typeof iteratorFn === "function") return iteratorFn;
484 }
485 /**
486 * Collection of methods that allow declaration and validation of props that are
487 * supplied to React components. Example usage:
488 *
489 * var Props = require('ReactPropTypes');
490 * var MyArticle = React.createClass({
491 * propTypes: {
492 * // An optional string prop named "description".
493 * description: Props.string,
494 *
495 * // A required enum prop named "category".
496 * category: Props.oneOf(['News','Photos']).isRequired,
497 *
498 * // A prop named "dialog" that requires an instance of Dialog.
499 * dialog: Props.instanceOf(Dialog).isRequired
500 * },
501 * render: function() { ... }
502 * });
503 *
504 * A more formal specification of how these methods are used:
505 *
506 * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
507 * decl := ReactPropTypes.{type}(.isRequired)?
508 *
509 * Each and every declaration produces a function with the same signature. This
510 * allows the creation of custom validation functions. For example:
511 *
512 * var MyLink = React.createClass({
513 * propTypes: {
514 * // An optional string or URI prop named "href".
515 * href: function(props, propName, componentName) {
516 * var propValue = props[propName];
517 * if (propValue != null && typeof propValue !== 'string' &&
518 * !(propValue instanceof URI)) {
519 * return new Error(
520 * 'Expected a string or an URI for ' + propName + ' in ' +
521 * componentName
522 * );
523 * }
524 * }
525 * },
526 * render: function() {...}
527 * });
528 *
529 * @internal
530 */
531 var ANONYMOUS = "<<anonymous>>";
532 var ReactPropTypes = {
533 array: createPrimitiveTypeChecker("array"),
534 bigint: createPrimitiveTypeChecker("bigint"),
535 bool: createPrimitiveTypeChecker("boolean"),
536 func: createPrimitiveTypeChecker("function"),
537 number: createPrimitiveTypeChecker("number"),
538 object: createPrimitiveTypeChecker("object"),
539 string: createPrimitiveTypeChecker("string"),
540 symbol: createPrimitiveTypeChecker("symbol"),
541 any: createAnyTypeChecker(),
542 arrayOf: createArrayOfTypeChecker,
543 element: createElementTypeChecker(),
544 elementType: createElementTypeTypeChecker(),
545 instanceOf: createInstanceTypeChecker,
546 node: createNodeChecker(),
547 objectOf: createObjectOfTypeChecker,
548 oneOf: createEnumTypeChecker,
549 oneOfType: createUnionTypeChecker,
550 shape: createShapeTypeChecker,
551 exact: createStrictShapeTypeChecker
552 };
553 /**
554 * inlined Object.is polyfill to avoid requiring consumers ship their own
555 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
556 */
557 function is(x, y) {
558 if (x === y) return x !== 0 || 1 / x === 1 / y;
559 else return x !== x && y !== y;
560 }
561 /**
562 * We use an Error-like object for backward compatibility as people may call
563 * PropTypes directly and inspect their output. However, we don't use real
564 * Errors anymore. We don't inspect their stack anyway, and creating them
565 * is prohibitively expensive if they are created too often, such as what
566 * happens in oneOfType() for any type before the one that matched.
567 */
568 function PropTypeError(message, data) {
569 this.message = message;
570 this.data = data && typeof data === "object" ? data : {};
571 this.stack = "";
572 }
573 PropTypeError.prototype = Error.prototype;
574 function createChainableTypeChecker(validate) {
575 var manualPropTypeCallCache = {};
576 var manualPropTypeWarningCount = 0;
577 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
578 componentName = componentName || ANONYMOUS;
579 propFullName = propFullName || propName;
580 if (secret !== ReactPropTypesSecret) {
581 if (throwOnDirectAccess) {
582 var err = /* @__PURE__ */ new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");
583 err.name = "Invariant Violation";
584 throw err;
585 } else if (typeof console !== "undefined") {
586 var cacheKey = componentName + ":" + propName;
587 if (!manualPropTypeCallCache[cacheKey] && manualPropTypeWarningCount < 3) {
588 printWarning("You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.");
589 manualPropTypeCallCache[cacheKey] = true;
590 manualPropTypeWarningCount++;
591 }
592 }
593 }
594 if (props[propName] == null) {
595 if (isRequired) {
596 if (props[propName] === null) return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
597 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
598 }
599 return null;
600 } else return validate(props, propName, componentName, location, propFullName);
601 }
602 var chainedCheckType = checkType.bind(null, false);
603 chainedCheckType.isRequired = checkType.bind(null, true);
604 return chainedCheckType;
605 }
606 function createPrimitiveTypeChecker(expectedType) {
607 function validate(props, propName, componentName, location, propFullName, secret) {
608 var propValue = props[propName];
609 if (getPropType(propValue) !== expectedType) {
610 var preciseType = getPreciseType(propValue);
611 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), { expectedType });
612 }
613 return null;
614 }
615 return createChainableTypeChecker(validate);
616 }
617 function createAnyTypeChecker() {
618 return createChainableTypeChecker(emptyFunctionThatReturnsNull);
619 }
620 function createArrayOfTypeChecker(typeChecker) {
621 function validate(props, propName, componentName, location, propFullName) {
622 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
623 var propValue = props[propName];
624 if (!Array.isArray(propValue)) {
625 var propType = getPropType(propValue);
626 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
627 }
628 for (var i = 0; i < propValue.length; i++) {
629 var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
630 if (error instanceof Error) return error;
631 }
632 return null;
633 }
634 return createChainableTypeChecker(validate);
635 }
636 function createElementTypeChecker() {
637 function validate(props, propName, componentName, location, propFullName) {
638 var propValue = props[propName];
639 if (!isValidElement(propValue)) {
640 var propType = getPropType(propValue);
641 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
642 }
643 return null;
644 }
645 return createChainableTypeChecker(validate);
646 }
647 function createElementTypeTypeChecker() {
648 function validate(props, propName, componentName, location, propFullName) {
649 var propValue = props[propName];
650 if (!ReactIs.isValidElementType(propValue)) {
651 var propType = getPropType(propValue);
652 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type."));
653 }
654 return null;
655 }
656 return createChainableTypeChecker(validate);
657 }
658 function createInstanceTypeChecker(expectedClass) {
659 function validate(props, propName, componentName, location, propFullName) {
660 if (!(props[propName] instanceof expectedClass)) {
661 var expectedClassName = expectedClass.name || ANONYMOUS;
662 var actualClassName = getClassName(props[propName]);
663 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
664 }
665 return null;
666 }
667 return createChainableTypeChecker(validate);
668 }
669 function createEnumTypeChecker(expectedValues) {
670 if (!Array.isArray(expectedValues)) {
671 if (arguments.length > 1) printWarning("Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).");
672 else printWarning("Invalid argument supplied to oneOf, expected an array.");
673 return emptyFunctionThatReturnsNull;
674 }
675 function validate(props, propName, componentName, location, propFullName) {
676 var propValue = props[propName];
677 for (var i = 0; i < expectedValues.length; i++) if (is(propValue, expectedValues[i])) return null;
678 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
679 if (getPreciseType(value) === "symbol") return String(value);
680 return value;
681 });
682 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
683 }
684 return createChainableTypeChecker(validate);
685 }
686 function createObjectOfTypeChecker(typeChecker) {
687 function validate(props, propName, componentName, location, propFullName) {
688 if (typeof typeChecker !== "function") return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
689 var propValue = props[propName];
690 var propType = getPropType(propValue);
691 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
692 for (var key in propValue) if (has(propValue, key)) {
693 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
694 if (error instanceof Error) return error;
695 }
696 return null;
697 }
698 return createChainableTypeChecker(validate);
699 }
700 function createUnionTypeChecker(arrayOfTypeCheckers) {
701 if (!Array.isArray(arrayOfTypeCheckers)) {
702 printWarning("Invalid argument supplied to oneOfType, expected an instance of array.");
703 return emptyFunctionThatReturnsNull;
704 }
705 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
706 var checker = arrayOfTypeCheckers[i];
707 if (typeof checker !== "function") {
708 printWarning("Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i + ".");
709 return emptyFunctionThatReturnsNull;
710 }
711 }
712 function validate(props, propName, componentName, location, propFullName) {
713 var expectedTypes = [];
714 for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
715 var checker = arrayOfTypeCheckers[i];
716 var checkerResult = checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret);
717 if (checkerResult == null) return null;
718 if (checkerResult.data && has(checkerResult.data, "expectedType")) expectedTypes.push(checkerResult.data.expectedType);
719 }
720 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : "";
721 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + "."));
722 }
723 return createChainableTypeChecker(validate);
724 }
725 function createNodeChecker() {
726 function validate(props, propName, componentName, location, propFullName) {
727 if (!isNode(props[propName])) return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
728 return null;
729 }
730 return createChainableTypeChecker(validate);
731 }
732 function invalidValidatorError(componentName, location, propFullName, key, type) {
733 return new PropTypeError((componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`.");
734 }
735 function createShapeTypeChecker(shapeTypes) {
736 function validate(props, propName, componentName, location, propFullName) {
737 var propValue = props[propName];
738 var propType = getPropType(propValue);
739 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
740 for (var key in shapeTypes) {
741 var checker = shapeTypes[key];
742 if (typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
743 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
744 if (error) return error;
745 }
746 return null;
747 }
748 return createChainableTypeChecker(validate);
749 }
750 function createStrictShapeTypeChecker(shapeTypes) {
751 function validate(props, propName, componentName, location, propFullName) {
752 var propValue = props[propName];
753 var propType = getPropType(propValue);
754 if (propType !== "object") return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
755 for (var key in assign({}, props[propName], shapeTypes)) {
756 var checker = shapeTypes[key];
757 if (has(shapeTypes, key) && typeof checker !== "function") return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker));
758 if (!checker) return new PropTypeError("Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " "));
759 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
760 if (error) return error;
761 }
762 return null;
763 }
764 return createChainableTypeChecker(validate);
765 }
766 function isNode(propValue) {
767 switch (typeof propValue) {
768 case "number":
769 case "string":
770 case "undefined": return true;
771 case "boolean": return !propValue;
772 case "object":
773 if (Array.isArray(propValue)) return propValue.every(isNode);
774 if (propValue === null || isValidElement(propValue)) return true;
775 var iteratorFn = getIteratorFn(propValue);
776 if (iteratorFn) {
777 var iterator = iteratorFn.call(propValue);
778 var step;
779 if (iteratorFn !== propValue.entries) {
780 while (!(step = iterator.next()).done) if (!isNode(step.value)) return false;
781 } else while (!(step = iterator.next()).done) {
782 var entry = step.value;
783 if (entry) {
784 if (!isNode(entry[1])) return false;
785 }
786 }
787 } else return false;
788 return true;
789 default: return false;
790 }
791 }
792 function isSymbol(propType, propValue) {
793 if (propType === "symbol") return true;
794 if (!propValue) return false;
795 if (propValue["@@toStringTag"] === "Symbol") return true;
796 if (typeof Symbol === "function" && propValue instanceof Symbol) return true;
797 return false;
798 }
799 function getPropType(propValue) {
800 var propType = typeof propValue;
801 if (Array.isArray(propValue)) return "array";
802 if (propValue instanceof RegExp) return "object";
803 if (isSymbol(propType, propValue)) return "symbol";
804 return propType;
805 }
806 function getPreciseType(propValue) {
807 if (typeof propValue === "undefined" || propValue === null) return "" + propValue;
808 var propType = getPropType(propValue);
809 if (propType === "object") {
810 if (propValue instanceof Date) return "date";
811 else if (propValue instanceof RegExp) return "regexp";
812 }
813 return propType;
814 }
815 function getPostfixForTypeWarning(value) {
816 var type = getPreciseType(value);
817 switch (type) {
818 case "array":
819 case "object": return "an " + type;
820 case "boolean":
821 case "date":
822 case "regexp": return "a " + type;
823 default: return type;
824 }
825 }
826 function getClassName(propValue) {
827 if (!propValue.constructor || !propValue.constructor.name) return ANONYMOUS;
828 return propValue.constructor.name;
829 }
830 ReactPropTypes.checkPropTypes = checkPropTypes;
831 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache;
832 ReactPropTypes.PropTypes = ReactPropTypes;
833 return ReactPropTypes;
834 };
835 }));
836
837 //#endregion
838 //#region node_modules/prop-types/index.js
839 var require_prop_types = /* @__PURE__ */ __commonJSMin(((exports, module) => {
840 var ReactIs = require_react_is$1();
841 var throwOnDirectAccess = true;
842 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess);
843 }));
844
845 //#endregion
846 //#region modules/ai/assets/js/editor/context/requests-ids.js
847 var import_prop_types$13, Context, useRequestIds, getUniqueId, RequestIdsProvider;
848 var init_requests_ids = __esmMin((() => {
849 import_prop_types$13 = /* @__PURE__ */ __toESM(require_prop_types());
850 Context = (0, react.createContext)({});
851 useRequestIds = function useRequestIds() {
852 var context = (0, react.useContext)(Context);
853 if (!context) throw new Error("useRequestIds must be used within a RequestIdsProvider");
854 return context;
855 };
856 getUniqueId = function getUniqueId(prefix) {
857 return prefix + "-" + Math.random().toString(16).substr(2, 7);
858 };
859 window.EDITOR_SESSION_ID = window.EDITOR_SESSION_ID || getUniqueId("editor-session");
860 RequestIdsProvider = function RequestIdsProvider(props) {
861 var editorSessionId = (0, react.useRef)(window.EDITOR_SESSION_ID);
862 var sessionId = (0, react.useRef)("");
863 var generateId = (0, react.useRef)("");
864 var batchId = (0, react.useRef)("");
865 var requestId = (0, react.useRef)("");
866 sessionId.current = getUniqueId("session");
867 var setGenerate = function setGenerate() {
868 generateId.current = getUniqueId("generate");
869 return generateId;
870 };
871 var setBatch = function setBatch() {
872 batchId.current = getUniqueId("batch");
873 return batchId;
874 };
875 var setRequest = function setRequest() {
876 requestId.current = getUniqueId("request");
877 return requestId;
878 };
879 var _useState2 = _slicedToArray((0, react.useState)(0), 2);
880 var usagePercentage = _useState2[0];
881 var setUsagePercentage = _useState2[1];
882 return /*#__PURE__*/ react.default.createElement(Context.Provider, { value: {
883 editorSessionId,
884 sessionId,
885 generateId,
886 batchId,
887 requestId,
888 setGenerate,
889 setBatch,
890 setRequest,
891 usagePercentage,
892 updateUsagePercentage: function updateUsagePercentage(newPercentage) {
893 setUsagePercentage(newPercentage);
894 }
895 } }, props.children);
896 };
897 RequestIdsProvider.propTypes = { children: import_prop_types$13.default.node.isRequired };
898 }));
899
900 //#endregion
901 //#region node_modules/@babel/runtime/helpers/esm/extends.js
902 function _extends$1() {
903 return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
904 for (var e = 1; e < arguments.length; e++) {
905 var t = arguments[e];
906 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
907 }
908 return n;
909 }, _extends$1.apply(null, arguments);
910 }
911 var init_extends = __esmMin((() => {
912 __name(_extends$1, "_extends");
913 }));
914
915 //#endregion
916 //#region node_modules/@babel/runtime/helpers/esm/typeof.js
917 function _typeof$1(o) {
918 "@babel/helpers - typeof";
919 return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
920 return typeof o;
921 } : function(o) {
922 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
923 }, _typeof$1(o);
924 }
925 var init_typeof$1 = __esmMin((() => {
926 __name(_typeof$1, "_typeof");
927 }));
928
929 //#endregion
930 //#region node_modules/@babel/runtime/helpers/esm/toPrimitive.js
931 function toPrimitive$1(t, r) {
932 if ("object" != _typeof$1(t) || !t) return t;
933 var e = t[Symbol.toPrimitive];
934 if (void 0 !== e) {
935 var i = e.call(t, r || "default");
936 if ("object" != _typeof$1(i)) return i;
937 throw new TypeError("@@toPrimitive must return a primitive value.");
938 }
939 return ("string" === r ? String : Number)(t);
940 }
941 var init_toPrimitive$1 = __esmMin((() => {
942 init_typeof$1();
943 __name(toPrimitive$1, "toPrimitive");
944 }));
945
946 //#endregion
947 //#region node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
948 function toPropertyKey$1(t) {
949 var i = toPrimitive$1(t, "string");
950 return "symbol" == _typeof$1(i) ? i : i + "";
951 }
952 var init_toPropertyKey$1 = __esmMin((() => {
953 init_typeof$1();
954 init_toPrimitive$1();
955 __name(toPropertyKey$1, "toPropertyKey");
956 }));
957
958 //#endregion
959 //#region node_modules/@babel/runtime/helpers/esm/defineProperty.js
960 function _defineProperty$1(e, r, t) {
961 return (r = toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
962 value: t,
963 enumerable: !0,
964 configurable: !0,
965 writable: !0
966 }) : e[r] = t, e;
967 }
968 var init_defineProperty$1 = __esmMin((() => {
969 init_toPropertyKey$1();
970 __name(_defineProperty$1, "_defineProperty");
971 }));
972
973 //#endregion
974 //#region node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
975 function asyncGeneratorStep$1(n, t, e, r, o, a, c) {
976 try {
977 var i = n[a](c);
978 var u = i.value;
979 } catch (n) {
980 e(n);
981 return;
982 }
983 i.done ? t(u) : Promise.resolve(u).then(r, o);
984 }
985 function _asyncToGenerator$1(n) {
986 return function() {
987 var t = this;
988 var e = arguments;
989 return new Promise(function(r, o) {
990 var a = n.apply(t, e);
991 function _next(n) {
992 asyncGeneratorStep$1(a, r, o, _next, _throw, "next", n);
993 }
994 function _throw(n) {
995 asyncGeneratorStep$1(a, r, o, _next, _throw, "throw", n);
996 }
997 _next(void 0);
998 });
999 };
1000 }
1001 var init_asyncToGenerator = __esmMin((() => {
1002 __name(asyncGeneratorStep$1, "asyncGeneratorStep");
1003 __name(_asyncToGenerator$1, "_asyncToGenerator");
1004 }));
1005
1006 //#endregion
1007 //#region node_modules/@babel/runtime/helpers/OverloadYield.js
1008 var require_OverloadYield = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1009 function _OverloadYield(e, d) {
1010 this.v = e, this.k = d;
1011 }
1012 module.exports = _OverloadYield, module.exports.__esModule = true, module.exports["default"] = module.exports;
1013 }));
1014
1015 //#endregion
1016 //#region node_modules/@babel/runtime/helpers/regeneratorDefine.js
1017 var require_regeneratorDefine = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1018 function _regeneratorDefine(e, r, n, t) {
1019 var i = Object.defineProperty;
1020 try {
1021 i({}, "", {});
1022 } catch (e) {
1023 i = 0;
1024 }
1025 module.exports = _regeneratorDefine = function regeneratorDefine(e, r, n, t) {
1026 function o(r, n) {
1027 _regeneratorDefine(e, r, function(e) {
1028 return this._invoke(r, n, e);
1029 });
1030 }
1031 r ? i ? i(e, r, {
1032 value: n,
1033 enumerable: !t,
1034 configurable: !t,
1035 writable: !t
1036 }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
1037 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _regeneratorDefine(e, r, n, t);
1038 }
1039 module.exports = _regeneratorDefine, module.exports.__esModule = true, module.exports["default"] = module.exports;
1040 }));
1041
1042 //#endregion
1043 //#region node_modules/@babel/runtime/helpers/regenerator.js
1044 var require_regenerator$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1045 var regeneratorDefine = require_regeneratorDefine();
1046 function _regenerator() {
1047 /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
1048 var e;
1049 var t;
1050 var r = "function" == typeof Symbol ? Symbol : {};
1051 var n = r.iterator || "@@iterator";
1052 var o = r.toStringTag || "@@toStringTag";
1053 function i(r, n, o, i) {
1054 var c = n && n.prototype instanceof Generator ? n : Generator;
1055 var u = Object.create(c.prototype);
1056 return regeneratorDefine(u, "_invoke", function(r, n, o) {
1057 var i;
1058 var c;
1059 var u;
1060 var f = 0;
1061 var p = o || [];
1062 var y = !1;
1063 var G = {
1064 p: 0,
1065 n: 0,
1066 v: e,
1067 a: d,
1068 f: d.bind(e, 4),
1069 d: function d(t, r) {
1070 return i = t, c = 0, u = e, G.n = r, a;
1071 }
1072 };
1073 function d(r, n) {
1074 for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
1075 var o;
1076 var i = p[t];
1077 var d = G.p;
1078 var l = i[2];
1079 r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
1080 }
1081 if (o || r > 1) return a;
1082 throw y = !0, n;
1083 }
1084 return function(o, p, l) {
1085 if (f > 1) throw TypeError("Generator is already running");
1086 for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
1087 i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
1088 try {
1089 if (f = 2, i) {
1090 if (c || (o = "next"), t = i[o]) {
1091 if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
1092 if (!t.done) return t;
1093 u = t.value, c < 2 && (c = 0);
1094 } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
1095 i = e;
1096 } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
1097 } catch (t) {
1098 i = e, c = 1, u = t;
1099 } finally {
1100 f = 1;
1101 }
1102 }
1103 return {
1104 value: t,
1105 done: y
1106 };
1107 };
1108 }(r, o, i), !0), u;
1109 }
1110 var a = {};
1111 function Generator() {}
1112 function GeneratorFunction() {}
1113 function GeneratorFunctionPrototype() {}
1114 t = Object.getPrototypeOf;
1115 var c = [][n] ? t(t([][n]())) : (regeneratorDefine(t = {}, n, function() {
1116 return this;
1117 }), t);
1118 var u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
1119 function f(e) {
1120 return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
1121 }
1122 return GeneratorFunction.prototype = GeneratorFunctionPrototype, regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), regeneratorDefine(u), regeneratorDefine(u, o, "Generator"), regeneratorDefine(u, n, function() {
1123 return this;
1124 }), regeneratorDefine(u, "toString", function() {
1125 return "[object Generator]";
1126 }), (module.exports = _regenerator = function _regenerator() {
1127 return {
1128 w: i,
1129 m: f
1130 };
1131 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
1132 }
1133 module.exports = _regenerator, module.exports.__esModule = true, module.exports["default"] = module.exports;
1134 }));
1135
1136 //#endregion
1137 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncIterator.js
1138 var require_regeneratorAsyncIterator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1139 var OverloadYield = require_OverloadYield();
1140 var regeneratorDefine = require_regeneratorDefine();
1141 function AsyncIterator(t, e) {
1142 function n(r, o, i, f) {
1143 try {
1144 var c = t[r](o);
1145 var u = c.value;
1146 return u instanceof OverloadYield ? e.resolve(u.v).then(function(t) {
1147 n("next", t, i, f);
1148 }, function(t) {
1149 n("throw", t, i, f);
1150 }) : e.resolve(u).then(function(t) {
1151 c.value = t, i(c);
1152 }, function(t) {
1153 return n("throw", t, i, f);
1154 });
1155 } catch (t) {
1156 f(t);
1157 }
1158 }
1159 var r;
1160 this.next || (regeneratorDefine(AsyncIterator.prototype), regeneratorDefine(AsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function() {
1161 return this;
1162 })), regeneratorDefine(this, "_invoke", function(t, o, i) {
1163 function f() {
1164 return new e(function(e, r) {
1165 n(t, i, e, r);
1166 });
1167 }
1168 return r = r ? r.then(f, f) : f();
1169 }, !0);
1170 }
1171 module.exports = AsyncIterator, module.exports.__esModule = true, module.exports["default"] = module.exports;
1172 }));
1173
1174 //#endregion
1175 //#region node_modules/@babel/runtime/helpers/regeneratorAsyncGen.js
1176 var require_regeneratorAsyncGen = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1177 var regenerator = require_regenerator$1();
1178 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
1179 function _regeneratorAsyncGen(r, e, t, o, n) {
1180 return new regeneratorAsyncIterator(regenerator().w(r, e, t, o), n || Promise);
1181 }
1182 module.exports = _regeneratorAsyncGen, module.exports.__esModule = true, module.exports["default"] = module.exports;
1183 }));
1184
1185 //#endregion
1186 //#region node_modules/@babel/runtime/helpers/regeneratorAsync.js
1187 var require_regeneratorAsync = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1188 var regeneratorAsyncGen = require_regeneratorAsyncGen();
1189 function _regeneratorAsync(n, e, r, t, o) {
1190 var a = regeneratorAsyncGen(n, e, r, t, o);
1191 return a.next().then(function(n) {
1192 return n.done ? n.value : a.next();
1193 });
1194 }
1195 module.exports = _regeneratorAsync, module.exports.__esModule = true, module.exports["default"] = module.exports;
1196 }));
1197
1198 //#endregion
1199 //#region node_modules/@babel/runtime/helpers/regeneratorKeys.js
1200 var require_regeneratorKeys = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1201 function _regeneratorKeys(e) {
1202 var n = Object(e);
1203 var r = [];
1204 for (var t in n) r.unshift(t);
1205 return function e() {
1206 for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e;
1207 return e.done = !0, e;
1208 };
1209 }
1210 module.exports = _regeneratorKeys, module.exports.__esModule = true, module.exports["default"] = module.exports;
1211 }));
1212
1213 //#endregion
1214 //#region node_modules/@babel/runtime/helpers/typeof.js
1215 var require_typeof = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1216 function _typeof(o) {
1217 "@babel/helpers - typeof";
1218 return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1219 return typeof o;
1220 } : function(o) {
1221 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1222 }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
1223 }
1224 module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
1225 }));
1226
1227 //#endregion
1228 //#region node_modules/@babel/runtime/helpers/regeneratorValues.js
1229 var require_regeneratorValues = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1230 var _typeof = require_typeof()["default"];
1231 function _regeneratorValues(e) {
1232 if (null != e) {
1233 var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"];
1234 var r = 0;
1235 if (t) return t.call(e);
1236 if ("function" == typeof e.next) return e;
1237 if (!isNaN(e.length)) return { next: function next() {
1238 return e && r >= e.length && (e = void 0), {
1239 value: e && e[r++],
1240 done: !e
1241 };
1242 } };
1243 }
1244 throw new TypeError(_typeof(e) + " is not iterable");
1245 }
1246 module.exports = _regeneratorValues, module.exports.__esModule = true, module.exports["default"] = module.exports;
1247 }));
1248
1249 //#endregion
1250 //#region node_modules/@babel/runtime/helpers/regeneratorRuntime.js
1251 var require_regeneratorRuntime = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1252 var OverloadYield = require_OverloadYield();
1253 var regenerator = require_regenerator$1();
1254 var regeneratorAsync = require_regeneratorAsync();
1255 var regeneratorAsyncGen = require_regeneratorAsyncGen();
1256 var regeneratorAsyncIterator = require_regeneratorAsyncIterator();
1257 var regeneratorKeys = require_regeneratorKeys();
1258 var regeneratorValues = require_regeneratorValues();
1259 function _regeneratorRuntime() {
1260 "use strict";
1261 var r = regenerator();
1262 var e = r.m(_regeneratorRuntime);
1263 var t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor;
1264 function n(r) {
1265 var e = "function" == typeof r && r.constructor;
1266 return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name));
1267 }
1268 var o = {
1269 "throw": 1,
1270 "return": 2,
1271 "break": 3,
1272 "continue": 3
1273 };
1274 function a(r) {
1275 var e;
1276 var t;
1277 return function(n) {
1278 e || (e = {
1279 stop: function stop() {
1280 return t(n.a, 2);
1281 },
1282 "catch": function _catch() {
1283 return n.v;
1284 },
1285 abrupt: function abrupt(r, e) {
1286 return t(n.a, o[r], e);
1287 },
1288 delegateYield: function delegateYield(r, o, a) {
1289 return e.resultName = o, t(n.d, regeneratorValues(r), a);
1290 },
1291 finish: function finish(r) {
1292 return t(n.f, r);
1293 }
1294 }, t = function t(r, _t, o) {
1295 n.p = e.prev, n.n = e.next;
1296 try {
1297 return r(_t, o);
1298 } finally {
1299 e.next = n.n;
1300 }
1301 }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n;
1302 try {
1303 return r.call(this, e);
1304 } finally {
1305 n.p = e.prev, n.n = e.next;
1306 }
1307 };
1308 }
1309 return (module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
1310 return {
1311 wrap: function wrap(e, t, n, o) {
1312 return r.w(a(e), t, n, o && o.reverse());
1313 },
1314 isGeneratorFunction: n,
1315 mark: r.m,
1316 awrap: function awrap(r, e) {
1317 return new OverloadYield(r, e);
1318 },
1319 AsyncIterator: regeneratorAsyncIterator,
1320 async: function async(r, e, t, o, u) {
1321 return (n(e) ? regeneratorAsyncGen : regeneratorAsync)(a(r), e, t, o, u);
1322 },
1323 keys: regeneratorKeys,
1324 values: regeneratorValues
1325 };
1326 }, module.exports.__esModule = true, module.exports["default"] = module.exports)();
1327 }
1328 module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
1329 }));
1330
1331 //#endregion
1332 //#region node_modules/@babel/runtime/regenerator/index.js
1333 var require_regenerator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1334 var runtime = require_regeneratorRuntime()();
1335 module.exports = runtime;
1336 try {
1337 regeneratorRuntime = runtime;
1338 } catch (accidentalStrictMode) {
1339 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
1340 else Function("r", "regeneratorRuntime = r")(runtime);
1341 }
1342 }));
1343
1344 //#endregion
1345 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
1346 function _objectWithoutPropertiesLoose$1(r, e) {
1347 if (null == r) return {};
1348 var t = {};
1349 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1350 if (-1 !== e.indexOf(n)) continue;
1351 t[n] = r[n];
1352 }
1353 return t;
1354 }
1355 var init_objectWithoutPropertiesLoose$1 = __esmMin((() => {
1356 __name(_objectWithoutPropertiesLoose$1, "_objectWithoutPropertiesLoose");
1357 }));
1358
1359 //#endregion
1360 //#region node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
1361 function _objectWithoutProperties$1(e, t) {
1362 if (null == e) return {};
1363 var o;
1364 var r;
1365 var i = _objectWithoutPropertiesLoose$1(e, t);
1366 if (Object.getOwnPropertySymbols) {
1367 var n = Object.getOwnPropertySymbols(e);
1368 for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
1369 }
1370 return i;
1371 }
1372 var init_objectWithoutProperties$1 = __esmMin((() => {
1373 init_objectWithoutPropertiesLoose$1();
1374 __name(_objectWithoutProperties$1, "_objectWithoutProperties");
1375 }));
1376
1377 //#endregion
1378 //#region modules/ai/assets/js/editor/components/loader.js
1379 function ownKeys$32(e, r) {
1380 var t = Object.keys(e);
1381 if (Object.getOwnPropertySymbols) {
1382 var o = Object.getOwnPropertySymbols(e);
1383 r && (o = o.filter(function(r) {
1384 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1385 })), t.push.apply(t, o);
1386 }
1387 return t;
1388 }
1389 function _objectSpread$31(e) {
1390 for (var r = 1; r < arguments.length; r++) {
1391 var t = null != arguments[r] ? arguments[r] : {};
1392 r % 2 ? ownKeys$32(Object(t), !0).forEach(function(r) {
1393 _defineProperty$1(e, r, t[r]);
1394 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$32(Object(t)).forEach(function(r) {
1395 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1396 });
1397 }
1398 return e;
1399 }
1400 var import_prop_types$12, _excluded$33, Loader;
1401 var init_loader = __esmMin((() => {
1402 init_extends();
1403 init_defineProperty$1();
1404 init_objectWithoutProperties$1();
1405 import_prop_types$12 = /* @__PURE__ */ __toESM(require_prop_types());
1406 _excluded$33 = ["sx", "BoxProps"];
1407 __name(ownKeys$32, "ownKeys");
1408 __name(_objectSpread$31, "_objectSpread");
1409 Loader = function Loader(_ref) {
1410 var _ref$sx = _ref.sx;
1411 var sx = _ref$sx === void 0 ? {} : _ref$sx;
1412 var _ref$BoxProps = _ref.BoxProps;
1413 var BoxProps = _ref$BoxProps === void 0 ? {} : _ref$BoxProps;
1414 var props = _objectWithoutProperties$1(_ref, _excluded$33);
1415 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
1416 width: "100%",
1417 display: "flex",
1418 alignItems: "center"
1419 }, BoxProps, { sx: _objectSpread$31({
1420 px: 1.5,
1421 minHeight: function minHeight(theme) {
1422 return theme.spacing(5);
1423 }
1424 }, BoxProps.sx || {}) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, _extends$1({ color: "secondary" }, props, { sx: _objectSpread$31({ width: "100%" }, sx) })));
1425 };
1426 Loader.propTypes = {
1427 sx: import_prop_types$12.default.object,
1428 BoxProps: import_prop_types$12.default.object
1429 };
1430 }));
1431
1432 //#endregion
1433 //#region modules/ai/assets/js/editor/components/ui/search-field.js
1434 var import_prop_types$11, StyledTextField$1, SearchField;
1435 var init_search_field = __esmMin((() => {
1436 init_extends();
1437 import_prop_types$11 = /* @__PURE__ */ __toESM(require_prop_types());
1438 StyledTextField$1 = (0, _elementor_ui.styled)(_elementor_ui.TextField)(function() {
1439 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
1440 backgroundColor: "initial",
1441 boxShadow: "none",
1442 border: 0,
1443 color: "inherit",
1444 outline: 0,
1445 /**
1446 * TODO:
1447 * Find a better solution to get the component padding value dynamically or fix the global CSS override.
1448 * These values are taken from Material UI's source code (the left padding reset was added to match the component style).
1449 */
1450 padding: "16.5px 14px 16.5px 0",
1451 "&.MuiInputBase-inputSizeSmall": { padding: "8.5px 14px 8.5px 0" }
1452 } };
1453 });
1454 SearchField = (0, react.forwardRef)(function(props, ref) {
1455 return /*#__PURE__*/ react.default.createElement(StyledTextField$1, _extends$1({
1456 autoFocus: true,
1457 fullWidth: true,
1458 required: true,
1459 size: "small",
1460 color: "secondary",
1461 InputProps: {
1462 autoComplete: "off",
1463 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_icons.SearchIcon, null))
1464 },
1465 placeholder: props.placeholder,
1466 name: props.name,
1467 value: props.value,
1468 onChange: props.onChange
1469 }, props, { inputRef: ref }));
1470 });
1471 SearchField.propTypes = {
1472 placeholder: import_prop_types$11.default.string,
1473 name: import_prop_types$11.default.string,
1474 value: import_prop_types$11.default.string,
1475 onChange: import_prop_types$11.default.func
1476 };
1477 }));
1478
1479 //#endregion
1480 //#region modules/ai/assets/js/editor/components/prompt-search.js
1481 var PromptSearch;
1482 var init_prompt_search = __esmMin((() => {
1483 init_extends();
1484 init_search_field();
1485 PromptSearch = (0, react.forwardRef)(function(props, ref) {
1486 return /*#__PURE__*/ react.default.createElement(SearchField, _extends$1({
1487 name: "prompt",
1488 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use", "elementor") + "..."
1489 }, props, { ref }));
1490 });
1491 }));
1492
1493 //#endregion
1494 //#region modules/ai/assets/js/editor/components/textarea.js
1495 var import_prop_types$10, Textarea;
1496 var init_textarea = __esmMin((() => {
1497 init_extends();
1498 import_prop_types$10 = /* @__PURE__ */ __toESM(require_prop_types());
1499 Textarea = (0, react.forwardRef)(function(props, ref) {
1500 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
1501 inputRef: ref,
1502 multiline: true,
1503 minRows: 4,
1504 maxRows: 20,
1505 color: "secondary"
1506 }, props));
1507 });
1508 Textarea.propTypes = {
1509 value: import_prop_types$10.default.string,
1510 onChange: import_prop_types$10.default.func,
1511 helperText: import_prop_types$10.default.string
1512 };
1513 }));
1514
1515 //#endregion
1516 //#region modules/ai/assets/js/editor/components/prompt-suggestions.js
1517 var import_prop_types$9, PromptSuggestions;
1518 var init_prompt_suggestions = __esmMin((() => {
1519 import_prop_types$9 = /* @__PURE__ */ __toESM(require_prop_types());
1520 PromptSuggestions = function PromptSuggestions(props) {
1521 var _props$suggestions;
1522 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
1523 variant: "subtitle1",
1524 color: "text.secondary"
1525 }, (0, _wordpress_i18n.__)("Suggested prompts", "elementor") + ":"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
1526 direction: "column",
1527 alignItems: "flex-start",
1528 gap: 1,
1529 sx: { my: 1 }
1530 }, (_props$suggestions = props.suggestions) === null || _props$suggestions === void 0 ? void 0 : _props$suggestions.map(function(option, index) {
1531 var _props$suggestionFilt;
1532 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
1533 key: index,
1534 variant: "outlined",
1535 size: "large",
1536 color: "secondary",
1537 label: ((_props$suggestionFilt = props.suggestionFilter) === null || _props$suggestionFilt === void 0 ? void 0 : _props$suggestionFilt.call(props, option)) || option,
1538 onClick: function onClick() {
1539 return props.onSelect(option);
1540 }
1541 });
1542 })), props.children);
1543 };
1544 PromptSuggestions.propTypes = {
1545 suggestions: import_prop_types$9.default.arrayOf(import_prop_types$9.default.string),
1546 onSelect: import_prop_types$9.default.func.isRequired,
1547 suggestionFilter: import_prop_types$9.default.func,
1548 children: import_prop_types$9.default.node
1549 };
1550 }));
1551
1552 //#endregion
1553 //#region modules/ai/assets/js/editor/components/prompt-library-link.js
1554 var import_prop_types$8, PromptLibraryLink;
1555 var init_prompt_library_link = __esmMin((() => {
1556 import_prop_types$8 = /* @__PURE__ */ __toESM(require_prop_types());
1557 PromptLibraryLink = function PromptLibraryLink(props) {
1558 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
1559 variant: "body2",
1560 color: "text.secondary"
1561 }, (0, _wordpress_i18n.__)("For more suggestions, explore our"), " ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
1562 href: props.libraryLink,
1563 className: "elementor-clickable",
1564 target: "_blank"
1565 }, (0, _wordpress_i18n.__)("prompt library")));
1566 };
1567 PromptLibraryLink.propTypes = { libraryLink: import_prop_types$8.default.string };
1568 }));
1569
1570 //#endregion
1571 //#region modules/ai/assets/js/editor/components/prompt-action-selection.js
1572 init_requests_ids();
1573 init_asyncToGenerator();
1574 var import_regenerator$3 = /* @__PURE__ */ __toESM(require_regenerator());
1575 init_loader();
1576 init_prompt_search();
1577 init_textarea();
1578 init_prompt_suggestions();
1579 init_prompt_library_link();
1580 var import_prop_types$7 = /* @__PURE__ */ __toESM(require_prop_types());
1581 var labelToDashCash = function labelToDashCash(str) {
1582 return str.toLowerCase().replace(/ /g, "-");
1583 };
1584 var PromptActionSelection = function PromptActionSelection(props) {
1585 var actionId = labelToDashCash(props.label);
1586 var _props$wrapperStyle = props.wrapperStyle;
1587 var wrapperStyle = _props$wrapperStyle === void 0 ? { maxWidth: 138 } : _props$wrapperStyle;
1588 return /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
1589 size: "small",
1590 color: "secondary",
1591 fullWidth: true,
1592 sx: wrapperStyle
1593 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: actionId }, props.label), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
1594 id: actionId,
1595 labelId: actionId,
1596 label: props.label,
1597 value: props.value || "",
1598 onChange: props.onChange,
1599 disabled: props.disabled,
1600 sx: { "&.Mui-disabled .MuiSelect-nativeInput": {
1601 backgroundColor: "initial",
1602 opacity: 0
1603 } }
1604 }, props.options.map(function(option) {
1605 var _option$value;
1606 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
1607 dense: true,
1608 key: option.label,
1609 value: (_option$value = option.value) !== null && _option$value !== void 0 ? _option$value : option.label
1610 }, option.label);
1611 })));
1612 };
1613 PromptActionSelection.propTypes = {
1614 label: import_prop_types$7.default.string.isRequired,
1615 options: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({
1616 label: import_prop_types$7.default.string.isRequired,
1617 value: import_prop_types$7.default.string
1618 })).isRequired,
1619 onChange: import_prop_types$7.default.func.isRequired,
1620 value: import_prop_types$7.default.string,
1621 wrapperStyle: import_prop_types$7.default.object,
1622 disabled: import_prop_types$7.default.bool
1623 };
1624
1625 //#endregion
1626 //#region modules/ai/assets/js/editor/components/generate-button.js
1627 var GenerateButton$1;
1628 var init_generate_button = __esmMin((() => {
1629 init_extends();
1630 GenerateButton$1 = function GenerateButton(props) {
1631 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
1632 variant: "contained",
1633 endIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
1634 disabled: !prompt,
1635 "aria-label": (0, _wordpress_i18n.__)("search", "elementor"),
1636 type: "submit",
1637 size: "small"
1638 }, props));
1639 };
1640 }));
1641
1642 //#endregion
1643 //#region modules/ai/assets/js/editor/components/prompt-action.js
1644 init_generate_button();
1645 init_extends();
1646 var PromptAction = function PromptAction(props) {
1647 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, _extends$1({
1648 size: "large",
1649 color: "secondary",
1650 variant: "outlined"
1651 }, props));
1652 };
1653
1654 //#endregion
1655 //#region modules/ai/assets/js/editor/components/prompt-error-message.js
1656 var import_prop_types$6, _excluded$32, PromptErrorMessage;
1657 var init_prompt_error_message = __esmMin((() => {
1658 init_extends();
1659 init_objectWithoutProperties$1();
1660 import_prop_types$6 = /* @__PURE__ */ __toESM(require_prop_types());
1661 _excluded$32 = [
1662 "error",
1663 "onRetry",
1664 "actionPosition"
1665 ];
1666 PromptErrorMessage = function PromptErrorMessage(_ref) {
1667 var error = _ref.error;
1668 var _ref$onRetry = _ref.onRetry;
1669 var onRetry = _ref$onRetry === void 0 ? function() {} : _ref$onRetry;
1670 var _ref$actionPosition = _ref.actionPosition;
1671 var actionPosition = _ref$actionPosition === void 0 ? "default" : _ref$actionPosition;
1672 var props = _objectWithoutProperties$1(_ref, _excluded$32);
1673 function getQuotaReachedTrailMessage(featureName) {
1674 if (!featureName) return {
1675 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("It's time to upgrade.", "elementor")),
1676 description: (0, _wordpress_i18n.__)("Enjoy the free trial? Upgrade now for unlimited access to built-in image, text and custom code generators.", "elementor"),
1677 buttonText: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
1678 buttonAction: function buttonAction() {
1679 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1680 }
1681 };
1682 return {
1683 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("You've used all AI credits for %s.", "elementor"), featureName.toLowerCase())),
1684 description: (0, _wordpress_i18n.__)("Upgrade now to keep using this feature. You still have credits for other AI features (Text, Code, Images, Containers, etc.)", "elementor"),
1685 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
1686 buttonAction: function buttonAction() {
1687 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1688 }
1689 };
1690 }
1691 function getErrorMessage() {
1692 var _error$extra_data;
1693 var errMsg = error.message || error;
1694 var featureName = (_error$extra_data = error.extra_data) === null || _error$extra_data === void 0 ? void 0 : _error$extra_data.featureName;
1695 var messages = {
1696 default: {
1697 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1698 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1699 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1700 buttonAction: onRetry
1701 },
1702 service_outage_internal: {
1703 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1704 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go.", "elementor"),
1705 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1706 buttonAction: onRetry
1707 },
1708 invalid_connect_data: {
1709 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1710 description: /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, (0, _wordpress_i18n.__)("Try exiting Elementor and sign in again.", "elementor"), " ", /*#__PURE__*/ react.default.createElement("a", {
1711 href: "https://elementor.com/help/disconnecting-reconnecting-your-elementor-account/",
1712 target: "_blank",
1713 rel: "noreferrer"
1714 }, (0, _wordpress_i18n.__)("Show me how", "elementor"))),
1715 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
1716 buttonAction: function buttonAction() {
1717 return window.open(window.ElementorAiConfig.connect_url);
1718 }
1719 },
1720 not_connected: {
1721 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("You aren't connected to Elementor AI.", "elementor")),
1722 description: (0, _wordpress_i18n.__)("Elementor AI is just a few clicks away. Connect your account to instantly create texts and custom code.", "elementor"),
1723 buttonText: (0, _wordpress_i18n.__)("Connect", "elementor"),
1724 buttonAction: function buttonAction() {
1725 return window.open(window.ElementorAiConfig.connect_url);
1726 }
1727 },
1728 quota_reached_trail: getQuotaReachedTrailMessage(featureName),
1729 quota_reached_subscription: {
1730 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Looks like you're out of credits.", "elementor")),
1731 description: (0, _wordpress_i18n.__)("Ready to take it to the next level?", "elementor"),
1732 buttonText: (0, _wordpress_i18n.__)("Upgrade now", "elementor"),
1733 buttonAction: function buttonAction() {
1734 return window.open("https://go.elementor.com/ai-popup-purchase-limit-reached/", "_blank");
1735 }
1736 },
1737 rate_limit_network: {
1738 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Whoa! Slow down there.", "elementor")),
1739 description: (0, _wordpress_i18n.__)("We can’t process that many requests so fast. Try again in 15 minutes.", "elementor")
1740 },
1741 invalid_prompts: {
1742 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("We were unable to generate that prompt.", "elementor")),
1743 description: (0, _wordpress_i18n.__)("Seems like the prompt contains words that could generate harmful content. Write a different prompt to continue.", "elementor")
1744 },
1745 service_unavailable: {
1746 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1747 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1748 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1749 buttonAction: onRetry
1750 },
1751 request_timeout_error: {
1752 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("There was a glitch.", "elementor")),
1753 description: (0, _wordpress_i18n.__)("Wait a moment and give it another go, or try tweaking the prompt.", "elementor"),
1754 buttonText: (0, _wordpress_i18n.__)("Try again", "elementor"),
1755 buttonAction: onRetry
1756 },
1757 invalid_token: {
1758 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Try again", "elementor")),
1759 description: (0, _wordpress_i18n.__)("Try exiting Elementor and sign in again.", "elementor"),
1760 buttonText: (0, _wordpress_i18n.__)("Reconnect", "elementor"),
1761 buttonAction: onRetry
1762 },
1763 file_too_large: {
1764 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The file is too large.", "elementor")),
1765 description: (0, _wordpress_i18n.__)("Please upload a file that is less than 4MB.", "elementor")
1766 },
1767 image_resolution_maximum_exceeded: {
1768 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("The image resolution exceeds the maximum allowed size.", "elementor")),
1769 description: (0, _wordpress_i18n.__)("Please upload a file with dimensions less than 2048x2048 pixels.", "elementor")
1770 },
1771 external_service_unavailable: {
1772 text: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, (0, _wordpress_i18n.__)("Temporary external service issue", "elementor")),
1773 description: (0, _wordpress_i18n.__)("It seems that one of our partner services is temporarily unavailable. Please try again in a few minutes.", "elementor"),
1774 buttonText: (0, _wordpress_i18n.__)("Try Again", "elementor"),
1775 buttonAction: onRetry
1776 }
1777 };
1778 return messages[errMsg] || messages.default;
1779 }
1780 var message = getErrorMessage();
1781 var action = (message === null || message === void 0 ? void 0 : message.buttonText) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
1782 color: "inherit",
1783 size: "small",
1784 variant: "outlined",
1785 onClick: message.buttonAction
1786 }, message.buttonText);
1787 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
1788 severity: message.severity || "error",
1789 action: "default" === actionPosition && action
1790 }, props), message.text, message.description, "bottom" === actionPosition && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mt: 1 } }, action));
1791 };
1792 PromptErrorMessage.propTypes = {
1793 error: import_prop_types$6.default.oneOfType([import_prop_types$6.default.object, import_prop_types$6.default.string]),
1794 onRetry: import_prop_types$6.default.func,
1795 actionPosition: import_prop_types$6.default.oneOf(["default", "bottom"])
1796 };
1797 }));
1798
1799 //#endregion
1800 //#region modules/ai/assets/js/editor/api/index.js
1801 function ownKeys$31(e, r) {
1802 var t = Object.keys(e);
1803 if (Object.getOwnPropertySymbols) {
1804 var o = Object.getOwnPropertySymbols(e);
1805 r && (o = o.filter(function(r) {
1806 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1807 })), t.push.apply(t, o);
1808 }
1809 return t;
1810 }
1811 function _objectSpread$30(e) {
1812 for (var r = 1; r < arguments.length; r++) {
1813 var t = null != arguments[r] ? arguments[r] : {};
1814 r % 2 ? ownKeys$31(Object(t), !0).forEach(function(r) {
1815 _defineProperty$1(e, r, t[r]);
1816 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$31(Object(t)).forEach(function(r) {
1817 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1818 });
1819 }
1820 return e;
1821 }
1822 var request, getUserInformation, getRemoteConfig, getCompletionText, getEditText, getCustomCode, getCustomCSS, setGetStarted, setStatusFeedback, getTextToImageGeneration, getImageToImageGeneration, getImageToImageMaskCleanup, getImageToImageMaskGeneration, getImageToImageOutPainting, getImageToImageUpscale, getImageToImageRemoveBackground, getImageToImageIsolateObjects, getImageToImageReplaceBackground, getImagePromptEnhanced, getProductImageUnification, getAnimation, uploadImage, generateLayout, getLayoutPromptEnhanced, getHistory, deleteHistoryItem;
1823 var init_api = __esmMin((() => {
1824 init_defineProperty$1();
1825 __name(ownKeys$31, "ownKeys");
1826 __name(_objectSpread$30, "_objectSpread");
1827 request = function request(endpoint) {
1828 var data = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1829 var immediately = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
1830 var signal = arguments.length > 3 ? arguments[3] : void 0;
1831 if (Object.keys(data).length) if (window.elementorAiCurrentContext) data.context = window.elementorAiCurrentContext;
1832 else data.context = window.elementorWpAiCurrentContext;
1833 return new Promise(function(resolve, reject) {
1834 var ajaxData = elementorCommon.ajax.addRequest(endpoint, {
1835 success: resolve,
1836 error: reject,
1837 data,
1838 unique_id: data.unique_id
1839 }, immediately);
1840 if (signal && ajaxData.jqXhr) signal.addEventListener("abort", ajaxData.jqXhr.abort);
1841 });
1842 };
1843 getUserInformation = function getUserInformation(immediately) {
1844 return request("ai_get_user_information", void 0, immediately);
1845 };
1846 getRemoteConfig = function getRemoteConfig() {
1847 return request("ai_get_remote_config");
1848 };
1849 getCompletionText = function getCompletionText(payload) {
1850 return request("ai_get_completion_text", { payload });
1851 };
1852 getEditText = function getEditText(payload) {
1853 return request("ai_get_edit_text", { payload });
1854 };
1855 getCustomCode = function getCustomCode(payload) {
1856 return request("ai_get_custom_code", { payload });
1857 };
1858 getCustomCSS = function getCustomCSS(payload) {
1859 return request("ai_get_custom_css", { payload });
1860 };
1861 setGetStarted = function setGetStarted() {
1862 return request("ai_set_get_started");
1863 };
1864 setStatusFeedback = function setStatusFeedback(responseId) {
1865 return request("ai_set_status_feedback", { response_id: responseId }, true);
1866 };
1867 getTextToImageGeneration = function getTextToImageGeneration(payload) {
1868 return request("ai_get_text_to_image", { payload });
1869 };
1870 getImageToImageGeneration = function getImageToImageGeneration(payload) {
1871 return request("ai_get_image_to_image", { payload });
1872 };
1873 getImageToImageMaskCleanup = function getImageToImageMaskCleanup(payload) {
1874 return request("ai_get_image_to_image_mask_cleanup", { payload });
1875 };
1876 getImageToImageMaskGeneration = function getImageToImageMaskGeneration(payload) {
1877 return request("ai_get_image_to_image_mask", { payload });
1878 };
1879 getImageToImageOutPainting = function getImageToImageOutPainting(payload) {
1880 return request("ai_get_image_to_image_outpainting", { payload });
1881 };
1882 getImageToImageUpscale = function getImageToImageUpscale(payload) {
1883 return request("ai_get_image_to_image_upscale", { payload });
1884 };
1885 getImageToImageRemoveBackground = function getImageToImageRemoveBackground(payload) {
1886 return request("ai_get_image_to_image_remove_background", { payload });
1887 };
1888 getImageToImageIsolateObjects = function getImageToImageIsolateObjects(payload) {
1889 return request("ai_get_image_to_image_isolate_objects", { payload });
1890 };
1891 getImageToImageReplaceBackground = function getImageToImageReplaceBackground(payload) {
1892 return request("ai_get_image_to_image_replace_background", { payload });
1893 };
1894 getImagePromptEnhanced = function getImagePromptEnhanced(prompt) {
1895 return request("ai_get_image_prompt_enhancer", { prompt });
1896 };
1897 getProductImageUnification = function getProductImageUnification(payload, immediately) {
1898 return request("ai_get_product_image_unification", { payload }, immediately);
1899 };
1900 getAnimation = function getAnimation(payload) {
1901 return request("ai_get_animation", { payload });
1902 };
1903 uploadImage = function uploadImage(image) {
1904 return request("ai_upload_image", _objectSpread$30(_objectSpread$30({}, image), {}, {
1905 editor_post_id: image.image.editor_post_id,
1906 unique_id: image.image.unique_id
1907 }));
1908 };
1909 generateLayout = function generateLayout(requestBody, signal) {
1910 return request("ai_generate_layout", requestBody, true, signal);
1911 };
1912 getLayoutPromptEnhanced = function getLayoutPromptEnhanced(prompt, enhanceType) {
1913 return request("ai_get_layout_prompt_enhancer", {
1914 prompt,
1915 enhance_type: enhanceType
1916 });
1917 };
1918 getHistory = function getHistory(type, page, limit) {
1919 return request("ai_get_history", {
1920 type,
1921 page,
1922 limit
1923 });
1924 };
1925 deleteHistoryItem = function deleteHistoryItem(id) {
1926 return request("ai_delete_history_item", { id });
1927 };
1928 }));
1929
1930 //#endregion
1931 //#region modules/ai/assets/js/editor/hooks/use-prompt.js
1932 function ownKeys$30(e, r) {
1933 var t = Object.keys(e);
1934 if (Object.getOwnPropertySymbols) {
1935 var o = Object.getOwnPropertySymbols(e);
1936 r && (o = o.filter(function(r) {
1937 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1938 })), t.push.apply(t, o);
1939 }
1940 return t;
1941 }
1942 function _objectSpread$29(e) {
1943 for (var r = 1; r < arguments.length; r++) {
1944 var t = null != arguments[r] ? arguments[r] : {};
1945 r % 2 ? ownKeys$30(Object(t), !0).forEach(function(r) {
1946 _defineProperty$1(e, r, t[r]);
1947 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$30(Object(t)).forEach(function(r) {
1948 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1949 });
1950 }
1951 return e;
1952 }
1953 var _excluded$31, normalizeResponse, usePrompt;
1954 var init_use_prompt = __esmMin((() => {
1955 init_defineProperty$1();
1956 init_slicedToArray();
1957 init_objectWithoutProperties$1();
1958 init_api();
1959 _excluded$31 = [
1960 "text",
1961 "response_id",
1962 "usage",
1963 "images"
1964 ];
1965 __name(ownKeys$30, "ownKeys");
1966 __name(_objectSpread$29, "_objectSpread");
1967 normalizeResponse = function normalizeResponse(_ref) {
1968 var text = _ref.text;
1969 var responseId = _ref.response_id;
1970 var usage = _ref.usage;
1971 var images = _ref.images;
1972 var optional = _objectWithoutProperties$1(_ref, _excluded$31);
1973 var creditsData = usage ? usage.quota - usage.usedQuota : 0;
1974 var normalized = {
1975 result: text || images,
1976 responseId,
1977 credits: Math.max(creditsData, 0),
1978 usagePercentage: usage === null || usage === void 0 ? void 0 : usage.usagePercentage
1979 };
1980 if (optional.base_template_id) normalized.baseTemplateId = optional.base_template_id;
1981 normalized.type = optional.template_type;
1982 return normalized;
1983 };
1984 usePrompt = function usePrompt(fetchData, initialState) {
1985 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
1986 var isLoading = _useState2[0];
1987 var setIsLoading = _useState2[1];
1988 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
1989 var error = _useState4[0];
1990 var setError = _useState4[1];
1991 var _useState6 = _slicedToArray((0, react.useState)(initialState), 2);
1992 var data = _useState6[0];
1993 var setData = _useState6[1];
1994 var _useRequestIds = useRequestIds();
1995 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
1996 var usagePercentage = _useRequestIds.usagePercentage;
1997 var send = (0, react.useRef)(/*#__PURE__*/ function() {
1998 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee(payload) {
1999 return import_regenerator$3.default.wrap(function(_context) {
2000 while (1) switch (_context.prev = _context.next) {
2001 case 0: return _context.abrupt("return", payload);
2002 case 1:
2003 case "end": return _context.stop();
2004 }
2005 }, _callee);
2006 }));
2007 return function(_x) {
2008 return _ref2.apply(this, arguments);
2009 };
2010 }());
2011 var sendUsageData = (0, react.useRef)(function() {});
2012 (0, react.useEffect)(function() {
2013 var newUsageValue = data === null || data === void 0 ? void 0 : data.usagePercentage;
2014 if (newUsageValue && newUsageValue !== usagePercentage) updateUsagePercentage(newUsageValue);
2015 }, [
2016 data,
2017 usagePercentage,
2018 updateUsagePercentage
2019 ]);
2020 var _useRequestIds2 = useRequestIds();
2021 var setRequest = _useRequestIds2.setRequest;
2022 var editorSessionId = _useRequestIds2.editorSessionId;
2023 var sessionId = _useRequestIds2.sessionId;
2024 var generateId = _useRequestIds2.generateId;
2025 var batchId = _useRequestIds2.batchId;
2026 send.current = (0, react.useCallback)(/*#__PURE__*/ function() {
2027 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$3.default.mark(function _callee2(payload) {
2028 return import_regenerator$3.default.wrap(function(_context2) {
2029 while (1) switch (_context2.prev = _context2.next) {
2030 case 0: return _context2.abrupt("return", new Promise(function(resolve, reject) {
2031 setError("");
2032 setIsLoading(true);
2033 var requestId = setRequest();
2034 var requestIds = {
2035 editorSessionId: editorSessionId.current,
2036 sessionId: sessionId.current,
2037 generateId: generateId.current,
2038 batchId: batchId.current,
2039 requestId: requestId.current
2040 };
2041 payload = _objectSpread$29(_objectSpread$29({}, payload), {}, { requestIds });
2042 fetchData(payload).then(function(result) {
2043 var normalizedData = normalizeResponse(result);
2044 setData(normalizedData);
2045 resolve(normalizedData);
2046 }).catch(function(err) {
2047 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
2048 setError(finalError);
2049 reject(finalError);
2050 }).finally(function() {
2051 return setIsLoading(false);
2052 });
2053 }));
2054 case 1:
2055 case "end": return _context2.stop();
2056 }
2057 }, _callee2);
2058 }));
2059 return function(_x2) {
2060 return _ref3.apply(this, arguments);
2061 };
2062 }(), [
2063 batchId,
2064 editorSessionId,
2065 fetchData,
2066 generateId,
2067 sessionId,
2068 setRequest
2069 ]);
2070 sendUsageData.current = (0, react.useCallback)(function() {
2071 var usageData = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : data;
2072 return usageData.responseId && setStatusFeedback(usageData.responseId);
2073 }, [data]);
2074 return {
2075 isLoading,
2076 error,
2077 data,
2078 setResult: function setResult(result) {
2079 var responseId = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
2080 var updatedResult = _objectSpread$29({}, data);
2081 updatedResult.result = result;
2082 if (responseId) updatedResult.responseId = responseId;
2083 setData(updatedResult);
2084 },
2085 reset: function reset() {
2086 setData(function(_ref4) {
2087 return {
2088 credits: _ref4.credits,
2089 result: "",
2090 responseId: ""
2091 };
2092 });
2093 setError("");
2094 setIsLoading(false);
2095 },
2096 send: send.current,
2097 sendUsageData: sendUsageData.current
2098 };
2099 };
2100 }));
2101
2102 //#endregion
2103 //#region modules/ai/assets/js/editor/hooks/use-text-prompt.js
2104 init_prompt_error_message();
2105 init_asyncToGenerator();
2106 var import_regenerator$2 = /* @__PURE__ */ __toESM(require_regenerator());
2107 init_api();
2108 init_use_prompt();
2109 var getTextResult = /*#__PURE__*/ function() {
2110 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(payload) {
2111 return import_regenerator$2.default.wrap(function(_context) {
2112 while (1) switch (_context.prev = _context.next) {
2113 case 0:
2114 if (!(payload !== null && payload !== void 0 && payload.instruction)) {
2115 _context.next = 1;
2116 break;
2117 }
2118 return _context.abrupt("return", getEditText(payload));
2119 case 1: return _context.abrupt("return", getCompletionText(payload));
2120 case 2:
2121 case "end": return _context.stop();
2122 }
2123 }, _callee);
2124 }));
2125 return function getTextResult(_x) {
2126 return _ref.apply(this, arguments);
2127 };
2128 }();
2129 var useTextPrompt = function useTextPrompt(initialValue) {
2130 return usePrompt(getTextResult, initialValue);
2131 };
2132
2133 //#endregion
2134 //#region modules/ai/assets/js/editor/actions-data.js
2135 var textAutocomplete, textareaAutocomplete, codeHtmlAutocomplete, codeCssAutocomplete, vocalTones, translateLanguages, motionEffectAutocomplete, hoverEffectAutocomplete;
2136 var init_actions_data = __esmMin((() => {
2137 textAutocomplete = [
2138 (0, _wordpress_i18n.__)("Craft a catchy slogan for", "elementor"),
2139 (0, _wordpress_i18n.__)("Write a strong section header for", "elementor"),
2140 (0, _wordpress_i18n.__)("Create a blog title for", "elementor"),
2141 (0, _wordpress_i18n.__)("Suggest a 4 word headline for", "elementor"),
2142 (0, _wordpress_i18n.__)("Write an attention grabbing title for", "elementor")
2143 ];
2144 textareaAutocomplete = [
2145 (0, _wordpress_i18n.__)("Write a product description for", "elementor"),
2146 (0, _wordpress_i18n.__)("Create a blog post for", "elementor"),
2147 (0, _wordpress_i18n.__)("Craft an about us section for", "elementor"),
2148 (0, _wordpress_i18n.__)("Offer a few sentences to invite visitors to", "elementor"),
2149 (0, _wordpress_i18n.__)("Write microcopy for a submission form that includes", "elementor")
2150 ];
2151 codeHtmlAutocomplete = [
2152 (0, _wordpress_i18n.__)("GA event fired on every button element click (assume GA was loaded)", "elementor"),
2153 (0, _wordpress_i18n.__)("Iframe code to embed a Spotify widget on my web page. My ID is 1234567890", "elementor"),
2154 (0, _wordpress_i18n.__)("Write an embed code of Google Analytics", "elementor"),
2155 (0, _wordpress_i18n.__)("Write an embed code of Facebook Pixel", "elementor"),
2156 (0, _wordpress_i18n.__)("HTML code that embeds the following PDF into a webpage: link to PDF", "elementor")
2157 ];
2158 codeCssAutocomplete = [
2159 (0, _wordpress_i18n.__)("On hover, animate 20% bigger, rotate 10 deg CCW", "elementor"),
2160 (0, _wordpress_i18n.__)("Add a circle-shaped clip mask, semi transparent on hover", "elementor"),
2161 (0, _wordpress_i18n.__)("Rainbow colored animated text gradient", "elementor"),
2162 (0, _wordpress_i18n.__)("Add a 3D shadow to the text", "elementor")
2163 ];
2164 vocalTones = [
2165 { label: (0, _wordpress_i18n.__)("Casual", "elementor") },
2166 { label: (0, _wordpress_i18n.__)("Confidence", "elementor") },
2167 { label: (0, _wordpress_i18n.__)("Formal", "elementor") },
2168 { label: (0, _wordpress_i18n.__)("Friendly", "elementor") },
2169 { label: (0, _wordpress_i18n.__)("Inspirational", "elementor") },
2170 { label: (0, _wordpress_i18n.__)("Motivational", "elementor") },
2171 { label: (0, _wordpress_i18n.__)("Nostalgic", "elementor") },
2172 { label: (0, _wordpress_i18n.__)("Playful", "elementor") },
2173 { label: (0, _wordpress_i18n.__)("Professional", "elementor") },
2174 { label: (0, _wordpress_i18n.__)("Scientific", "elementor") },
2175 { label: (0, _wordpress_i18n.__)("Straightforward", "elementor") },
2176 { label: (0, _wordpress_i18n.__)("Witty", "elementor") }
2177 ];
2178 translateLanguages = [
2179 {
2180 label: (0, _wordpress_i18n.__)("Arabic", "elementor"),
2181 value: "ar-SA"
2182 },
2183 {
2184 label: (0, _wordpress_i18n.__)("Chinese", "elementor"),
2185 value: "zh-CN"
2186 },
2187 {
2188 label: (0, _wordpress_i18n.__)("Czech", "elementor"),
2189 value: "cs-CZ"
2190 },
2191 {
2192 label: (0, _wordpress_i18n.__)("Danish", "elementor"),
2193 value: "da-DK"
2194 },
2195 {
2196 label: (0, _wordpress_i18n.__)("Dutch", "elementor"),
2197 value: "nl-NL"
2198 },
2199 {
2200 label: (0, _wordpress_i18n.__)("English", "elementor"),
2201 value: "en-US"
2202 },
2203 {
2204 label: (0, _wordpress_i18n.__)("Finnish", "elementor"),
2205 value: "fi-FI"
2206 },
2207 {
2208 label: (0, _wordpress_i18n.__)("French", "elementor"),
2209 value: "fr-FR"
2210 },
2211 {
2212 label: (0, _wordpress_i18n.__)("German", "elementor"),
2213 value: "de-DE"
2214 },
2215 {
2216 label: (0, _wordpress_i18n.__)("Greek", "elementor"),
2217 value: "el-GR"
2218 },
2219 {
2220 label: (0, _wordpress_i18n.__)("Hebrew", "elementor"),
2221 value: "he-IL"
2222 },
2223 {
2224 label: (0, _wordpress_i18n.__)("Hungarian", "elementor"),
2225 value: "hu-HU"
2226 },
2227 {
2228 label: (0, _wordpress_i18n.__)("Indonesian", "elementor"),
2229 value: "id-ID"
2230 },
2231 {
2232 label: (0, _wordpress_i18n.__)("Italian", "elementor"),
2233 value: "it-IT"
2234 },
2235 {
2236 label: (0, _wordpress_i18n.__)("Japanese", "elementor"),
2237 value: "ja-JP"
2238 },
2239 {
2240 label: (0, _wordpress_i18n.__)("Korean", "elementor"),
2241 value: "ko-KR"
2242 },
2243 {
2244 label: (0, _wordpress_i18n.__)("Persian", "elementor"),
2245 value: "fa-IR"
2246 },
2247 {
2248 label: (0, _wordpress_i18n.__)("Polish", "elementor"),
2249 value: "pl-PL"
2250 },
2251 {
2252 label: (0, _wordpress_i18n.__)("Portuguese", "elementor"),
2253 value: "pt-PT"
2254 },
2255 {
2256 label: (0, _wordpress_i18n.__)("Russian", "elementor"),
2257 value: "ru-RU"
2258 },
2259 {
2260 label: (0, _wordpress_i18n.__)("Spanish", "elementor"),
2261 value: "es-ES"
2262 },
2263 {
2264 label: (0, _wordpress_i18n.__)("Swedish", "elementor"),
2265 value: "sv-SE"
2266 },
2267 {
2268 label: (0, _wordpress_i18n.__)("Thai", "elementor"),
2269 value: "th-TH"
2270 },
2271 {
2272 label: (0, _wordpress_i18n.__)("Turkish", "elementor"),
2273 value: "tr-TR"
2274 },
2275 {
2276 label: (0, _wordpress_i18n.__)("Vietnamese", "elementor"),
2277 value: "vi-VN"
2278 }
2279 ];
2280 motionEffectAutocomplete = [
2281 (0, _wordpress_i18n.__)("Create Fade out animation on scroll", "elementor"),
2282 (0, _wordpress_i18n.__)("Create a Parallax effect on scroll", "elementor"),
2283 (0, _wordpress_i18n.__)("On scroll, fade in with slight scaling up", "elementor"),
2284 (0, _wordpress_i18n.__)("Move and tilt opposite to mouse position", "elementor"),
2285 (0, _wordpress_i18n.__)("Slide in from the left on load", "elementor")
2286 ];
2287 hoverEffectAutocomplete = [
2288 (0, _wordpress_i18n.__)("Move down on hover", "elementor"),
2289 (0, _wordpress_i18n.__)("Slightly shift right on hover", "elementor"),
2290 (0, _wordpress_i18n.__)("Apply a subtle 3D tilt", "elementor"),
2291 (0, _wordpress_i18n.__)("Rotate gently clockwise on hover", "elementor"),
2292 (0, _wordpress_i18n.__)("Scale down and move up on hover", "elementor")
2293 ];
2294 }));
2295
2296 //#endregion
2297 //#region modules/ai/assets/js/editor/components/prompt-history/history-types.js
2298 var HISTORY_TYPES, TRANSLATED_HISTORY_TYPES_FALLBACK, TRANSLATED_HISTORY_TYPES, getTranslatedPromptHistoryType;
2299 var init_history_types = __esmMin((() => {
2300 init_defineProperty$1();
2301 HISTORY_TYPES = Object.freeze({
2302 ALL: "all",
2303 TEXT: "text",
2304 CODE: "code",
2305 IMAGE: "images",
2306 BLOCK: "blocks"
2307 });
2308 TRANSLATED_HISTORY_TYPES_FALLBACK = (0, _wordpress_i18n.__)("things", "elementor");
2309 TRANSLATED_HISTORY_TYPES = Object.freeze(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1({}, HISTORY_TYPES.TEXT, (0, _wordpress_i18n.__)("texts", "elementor")), HISTORY_TYPES.CODE, (0, _wordpress_i18n.__)("code", "elementor")), HISTORY_TYPES.IMAGE, (0, _wordpress_i18n.__)("images", "elementor")), HISTORY_TYPES.BLOCK, (0, _wordpress_i18n.__)("blocks", "elementor")));
2310 getTranslatedPromptHistoryType = function getTranslatedPromptHistoryType(historyType) {
2311 if (TRANSLATED_HISTORY_TYPES[historyType]) return TRANSLATED_HISTORY_TYPES[historyType];
2312 return TRANSLATED_HISTORY_TYPES_FALLBACK;
2313 };
2314 }));
2315
2316 //#endregion
2317 //#region modules/ai/assets/js/editor/helpers/index.js
2318 var vh;
2319 var init_helpers = __esmMin((() => {
2320 vh = function vh(value) {
2321 return value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0) / 100;
2322 };
2323 }));
2324
2325 //#endregion
2326 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-context.js
2327 var import_prop_types$5, PromptHistoryContext, DIALOG_CONTAINER_SELECTOR, getContainer, getContainerHeight, getContentHeight, setContentHeight, PromptHistoryProvider, usePromptHistoryContext;
2328 var init_prompt_history_context = __esmMin((() => {
2329 init_slicedToArray();
2330 import_prop_types$5 = /* @__PURE__ */ __toESM(require_prop_types());
2331 init_history_types();
2332 init_helpers();
2333 PromptHistoryContext = (0, react.createContext)({});
2334 DIALOG_CONTAINER_SELECTOR = ".e-ai-dialog-content";
2335 getContainer = function getContainer() {
2336 return document.querySelector(DIALOG_CONTAINER_SELECTOR);
2337 };
2338 getContainerHeight = function getContainerHeight() {
2339 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2340 return contentContainer === null || contentContainer === void 0 ? void 0 : contentContainer.clientHeight;
2341 };
2342 getContentHeight = function getContentHeight() {
2343 return document.querySelector(DIALOG_CONTAINER_SELECTOR).children[0].clientHeight + 50;
2344 };
2345 setContentHeight = function setContentHeight(height) {
2346 var contentContainer = document.querySelector(DIALOG_CONTAINER_SELECTOR);
2347 if ("auto" === height) {
2348 contentContainer.style.height = "auto";
2349 return;
2350 }
2351 contentContainer.style.height = "".concat(height, "px");
2352 };
2353 PromptHistoryProvider = function PromptHistoryProvider(_ref) {
2354 var historyType = _ref.historyType;
2355 var children = _ref.children;
2356 var showHistoryState = (0, react.useState)(false);
2357 return /*#__PURE__*/ react.default.createElement(PromptHistoryContext.Provider, { value: {
2358 historyType,
2359 showHistoryState
2360 } }, children);
2361 };
2362 PromptHistoryProvider.propTypes = {
2363 historyType: import_prop_types$5.default.oneOf(Object.values(HISTORY_TYPES)).isRequired,
2364 children: import_prop_types$5.default.node
2365 };
2366 usePromptHistoryContext = function usePromptHistoryContext() {
2367 var _useContext = (0, react.useContext)(PromptHistoryContext);
2368 var historyType = _useContext.historyType;
2369 var showHistoryState = _useContext.showHistoryState;
2370 var _showHistoryState = _slicedToArray(showHistoryState, 2);
2371 var showHistory = _showHistoryState[0];
2372 var setShowHistory = _showHistoryState[1];
2373 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
2374 var showModalWrapper = _useState2[0];
2375 var setShowModalWrapper = _useState2[1];
2376 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
2377 var showPromptHistory = _useState4[0];
2378 var setShowPromptHistory = _useState4[1];
2379 var handleFullScreenHistoryState = function handleFullScreenHistoryState() {
2380 if (showHistory) {
2381 setShowModalWrapper(true);
2382 setTimeout(function() {
2383 return setShowPromptHistory(true);
2384 }, 200);
2385 return;
2386 }
2387 setShowPromptHistory(false);
2388 setTimeout(function() {
2389 return setShowModalWrapper(false);
2390 }, 500);
2391 };
2392 var handleDefaultHistoryState = function handleDefaultHistoryState() {
2393 if (showHistory) {
2394 var currentHeight = getContentHeight();
2395 setContentHeight(currentHeight);
2396 setTimeout(function() {
2397 if (currentHeight < vh(61)) {
2398 setContentHeight(vh(61));
2399 setTimeout(function() {
2400 return setShowModalWrapper(true);
2401 }, 200);
2402 setTimeout(function() {
2403 return setShowPromptHistory(true);
2404 }, 300);
2405 return;
2406 }
2407 setShowModalWrapper(true);
2408 setShowPromptHistory(true);
2409 }, 20);
2410 return;
2411 }
2412 setShowPromptHistory(false);
2413 setTimeout(function() {
2414 setShowModalWrapper(false);
2415 setContentHeight(getContentHeight());
2416 setTimeout(function() {
2417 return setContentHeight("auto");
2418 }, 300);
2419 }, 500);
2420 };
2421 (0, react.useEffect)(function() {
2422 if (showHistory === showModalWrapper && showHistory === showPromptHistory) return;
2423 if (historyType === HISTORY_TYPES.IMAGE) return handleFullScreenHistoryState();
2424 handleDefaultHistoryState();
2425 }, [showHistory]);
2426 return {
2427 historyType,
2428 isOpen: showPromptHistory,
2429 isModalOpen: showModalWrapper,
2430 showHistory,
2431 onOpen: function onOpen() {
2432 setShowHistory(true);
2433 },
2434 onClose: function onClose() {
2435 setShowHistory(false);
2436 },
2437 getContainer,
2438 getContainerHeight
2439 };
2440 };
2441 }));
2442
2443 //#endregion
2444 //#region modules/ai/assets/js/editor/components/prompt-history/context/prompt-history-action-context.js
2445 function _createForOfIteratorHelper$1(r, e) {
2446 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
2447 if (!t) {
2448 if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e && r && "number" == typeof r.length) {
2449 t && (r = t);
2450 var _n = 0;
2451 var F = function F() {};
2452 return {
2453 s: F,
2454 n: function n() {
2455 return _n >= r.length ? { done: !0 } : {
2456 done: !1,
2457 value: r[_n++]
2458 };
2459 },
2460 e: function e(r) {
2461 throw r;
2462 },
2463 f: F
2464 };
2465 }
2466 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2467 }
2468 var o;
2469 var a = !0;
2470 var u = !1;
2471 return {
2472 s: function s() {
2473 t = t.call(r);
2474 },
2475 n: function n() {
2476 var r = t.next();
2477 return a = r.done, r;
2478 },
2479 e: function e(r) {
2480 u = !0, o = r;
2481 },
2482 f: function f() {
2483 try {
2484 a || null == t.return || t.return();
2485 } finally {
2486 if (u) throw o;
2487 }
2488 }
2489 };
2490 }
2491 function _unsupportedIterableToArray$1(r, a) {
2492 if (r) {
2493 if ("string" == typeof r) return _arrayLikeToArray$1(r, a);
2494 var t = {}.toString.call(r).slice(8, -1);
2495 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0;
2496 }
2497 }
2498 function _arrayLikeToArray$1(r, a) {
2499 (null == a || a > r.length) && (a = r.length);
2500 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
2501 return n;
2502 }
2503 var import_prop_types$4, PromptHistoryActionContext, initialActionValue, ACTION_TYPES, ENABLED_ACTIONS_BY_TYPE, PromptHistoryActionProvider, usePromptHistoryAction, useSubscribeOnPromptHistoryAction;
2504 var init_prompt_history_action_context = __esmMin((() => {
2505 init_slicedToArray();
2506 init_defineProperty$1();
2507 import_prop_types$4 = /* @__PURE__ */ __toESM(require_prop_types());
2508 init_history_types();
2509 init_prompt_history_context();
2510 __name(_createForOfIteratorHelper$1, "_createForOfIteratorHelper");
2511 __name(_unsupportedIterableToArray$1, "_unsupportedIterableToArray");
2512 __name(_arrayLikeToArray$1, "_arrayLikeToArray");
2513 PromptHistoryActionContext = (0, react.createContext)({});
2514 initialActionValue = {
2515 type: "",
2516 id: "",
2517 data: null
2518 };
2519 ACTION_TYPES = Object.freeze({
2520 REUSE: "reuse",
2521 EDIT: "edit",
2522 RESTORE: "restore",
2523 REMOVE: "remove"
2524 });
2525 ENABLED_ACTIONS_BY_TYPE = _defineProperty$1(_defineProperty$1(_defineProperty$1({}, HISTORY_TYPES.TEXT, _defineProperty$1(_defineProperty$1(_defineProperty$1({}, ACTION_TYPES.REUSE, true), ACTION_TYPES.EDIT, true), ACTION_TYPES.REMOVE, true)), HISTORY_TYPES.CODE, _defineProperty$1(_defineProperty$1({}, ACTION_TYPES.REUSE, true), ACTION_TYPES.REMOVE, true)), HISTORY_TYPES.IMAGE, _defineProperty$1(_defineProperty$1({}, ACTION_TYPES.RESTORE, true), ACTION_TYPES.REMOVE, true));
2526 PromptHistoryActionProvider = function PromptHistoryActionProvider(_ref) {
2527 var children = _ref.children;
2528 var _useState2 = _slicedToArray((0, react.useState)(initialActionValue), 2);
2529 var state = _useState2[0];
2530 var dispatch = _useState2[1];
2531 return /*#__PURE__*/ react.default.createElement(PromptHistoryActionContext.Provider, { value: {
2532 state,
2533 dispatch
2534 } }, children);
2535 };
2536 PromptHistoryActionProvider.propTypes = { children: import_prop_types$4.default.node };
2537 usePromptHistoryAction = function usePromptHistoryAction() {
2538 var _useContext = (0, react.useContext)(PromptHistoryActionContext);
2539 var state = _useContext.state;
2540 var dispatch = _useContext.dispatch;
2541 var _usePromptHistoryCont = usePromptHistoryContext();
2542 var historyType = _usePromptHistoryCont.historyType;
2543 var onClose = _usePromptHistoryCont.onClose;
2544 var closeModalAfterAction = function closeModalAfterAction(action) {
2545 return function() {
2546 action.apply(void 0, arguments);
2547 onClose();
2548 };
2549 };
2550 return {
2551 promptHistoryAction: state,
2552 onPromptReuse: closeModalAfterAction(function onPromptReuse(id, data) {
2553 return dispatch({
2554 type: ACTION_TYPES.REUSE,
2555 id,
2556 data
2557 });
2558 }),
2559 onResultEdit: closeModalAfterAction(function onResultEdit(id, data) {
2560 return dispatch({
2561 type: ACTION_TYPES.EDIT,
2562 id,
2563 data
2564 });
2565 }),
2566 onImagesRestore: closeModalAfterAction(function onImagesRestore(id, data) {
2567 return dispatch({
2568 type: ACTION_TYPES.RESTORE,
2569 id,
2570 data
2571 });
2572 }),
2573 getAllowedActions: function getAllowedActions() {
2574 return ENABLED_ACTIONS_BY_TYPE[historyType] || {};
2575 }
2576 };
2577 };
2578 useSubscribeOnPromptHistoryAction = function useSubscribeOnPromptHistoryAction(actions) {
2579 var state = (0, react.useContext)(PromptHistoryActionContext).state;
2580 (0, react.useEffect)(function() {
2581 if (!state.type) return;
2582 var _iterator = _createForOfIteratorHelper$1(actions);
2583 var _step;
2584 try {
2585 for (_iterator.s(); !(_step = _iterator.n()).done;) {
2586 var action = _step.value;
2587 if (state.type === (action === null || action === void 0 ? void 0 : action.type)) action === null || action === void 0 || action.handler(state);
2588 }
2589 } catch (err) {
2590 _iterator.e(err);
2591 } finally {
2592 _iterator.f();
2593 }
2594 }, [state]);
2595 };
2596 }));
2597
2598 //#endregion
2599 //#region modules/ai/assets/js/editor/icons/bulb-icon.js
2600 var BulbIcon;
2601 var init_bulb_icon = __esmMin((() => {
2602 init_extends();
2603 BulbIcon = react.default.forwardRef(function(props, ref) {
2604 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({}, props, { ref }), /*#__PURE__*/ react.default.createElement("svg", {
2605 width: "22",
2606 height: "22",
2607 viewBox: "0 0 22 22",
2608 fill: "none",
2609 xmlns: "http://www.w3.org/2000/svg"
2610 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_10743_8902)" }, /*#__PURE__*/ react.default.createElement("path", {
2611 d: "M2.75 10.0833H3.66667M11 2.75V3.66667M18.3333 10.0833H19.25M5.13333 5.13333L5.775 5.775M16.8667 5.13333L16.225 5.775",
2612 stroke: "#2563EB",
2613 strokeWidth: "1.5",
2614 strokeLinecap: "round",
2615 strokeLinejoin: "round"
2616 }), /*#__PURE__*/ react.default.createElement("path", {
2617 d: "M9.16675 16.041C8.70841 15.1243 6.91205 13.2842 6.62523 12.366C6.3384 11.4477 6.34775 10.4626 6.65195 9.54997C6.95615 8.63738 7.53978 7.84362 8.32016 7.28116C9.10054 6.71869 10.0381 6.41602 11.0001 6.41602C11.962 6.41602 12.8996 6.71869 13.68 7.28116C14.4604 7.84362 15.044 8.63738 15.3482 9.54997C15.6524 10.4626 15.6618 11.4477 15.3749 12.366C15.0881 13.2842 13.2917 15.1243 12.8334 16.041C12.8334 16.041 12.7597 17.3762 12.8334 17.8743C12.8334 18.3606 12.6403 18.8269 12.2964 19.1707C11.9526 19.5145 11.4863 19.7077 11.0001 19.7077C10.5139 19.7077 10.0475 19.5145 9.70372 19.1707C9.3599 18.8269 9.16675 18.3606 9.16675 17.8743C9.2405 17.3762 9.16675 16.041 9.16675 16.041Z",
2618 stroke: "#2563EB",
2619 strokeWidth: "1.5",
2620 strokeLinecap: "round",
2621 strokeLinejoin: "round"
2622 }), /*#__PURE__*/ react.default.createElement("path", {
2623 d: "M10.0833 16.5H11.9166",
2624 stroke: "#2563EB",
2625 strokeWidth: "1.5",
2626 strokeLinecap: "round",
2627 strokeLinejoin: "round"
2628 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_10743_8902" }, /*#__PURE__*/ react.default.createElement("rect", {
2629 width: "22",
2630 height: "22",
2631 fill: "white"
2632 })))));
2633 });
2634 }));
2635
2636 //#endregion
2637 //#region modules/ai/assets/js/editor/hooks/use-introduction.js
2638 function useIntroduction(key) {
2639 var _window$elementor$con;
2640 var _window$elementorAdmi;
2641 var _globalConfig$introdu;
2642 var globalConfig = window.elementor ? (_window$elementor$con = window.elementor.config) === null || _window$elementor$con === void 0 ? void 0 : _window$elementor$con.user : (_window$elementorAdmi = window.elementorAdmin) === null || _window$elementorAdmi === void 0 || (_window$elementorAdmi = _window$elementorAdmi.config) === null || _window$elementorAdmi === void 0 ? void 0 : _window$elementorAdmi.user;
2643 var _useState2 = _slicedToArray((0, react.useState)(!!(globalConfig !== null && globalConfig !== void 0 && (_globalConfig$introdu = globalConfig.introduction) !== null && _globalConfig$introdu !== void 0 && _globalConfig$introdu[key])), 2);
2644 var isViewed = _useState2[0];
2645 var setIsViewed = _useState2[1];
2646 function markAsViewed() {
2647 if (!key) return Promise.reject();
2648 return new Promise(function(resolve, reject) {
2649 if (isViewed) reject();
2650 setIsViewed(true);
2651 elementorCommon.ajax.addRequest("introduction_viewed", {
2652 data: { introductionKey: key },
2653 error: function error() {
2654 setIsViewed(false);
2655 reject();
2656 },
2657 success: function success() {
2658 setIsViewed(true);
2659 if (globalConfig !== null && globalConfig !== void 0 && globalConfig.introduction) globalConfig.introduction[key] = true;
2660 resolve();
2661 }
2662 });
2663 });
2664 }
2665 return {
2666 isViewed,
2667 markAsViewed
2668 };
2669 }
2670 var init_use_introduction = __esmMin((() => {
2671 init_slicedToArray();
2672 }));
2673
2674 //#endregion
2675 //#region modules/ai/assets/js/editor/components/voice-promotion-alert.js
2676 function ownKeys$29(e, r) {
2677 var t = Object.keys(e);
2678 if (Object.getOwnPropertySymbols) {
2679 var o = Object.getOwnPropertySymbols(e);
2680 r && (o = o.filter(function(r) {
2681 return Object.getOwnPropertyDescriptor(e, r).enumerable;
2682 })), t.push.apply(t, o);
2683 }
2684 return t;
2685 }
2686 function _objectSpread$28(e) {
2687 for (var r = 1; r < arguments.length; r++) {
2688 var t = null != arguments[r] ? arguments[r] : {};
2689 r % 2 ? ownKeys$29(Object(t), !0).forEach(function(r) {
2690 _defineProperty$1(e, r, t[r]);
2691 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$29(Object(t)).forEach(function(r) {
2692 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2693 });
2694 }
2695 return e;
2696 }
2697 var import_prop_types$3, VoicePromotionAlert;
2698 var init_voice_promotion_alert = __esmMin((() => {
2699 init_defineProperty$1();
2700 init_bulb_icon();
2701 init_use_introduction();
2702 import_prop_types$3 = /* @__PURE__ */ __toESM(require_prop_types());
2703 __name(ownKeys$29, "ownKeys");
2704 __name(_objectSpread$28, "_objectSpread");
2705 VoicePromotionAlert = function VoicePromotionAlert(props) {
2706 var _useIntroduction = useIntroduction(props.introductionKey);
2707 var isViewed = _useIntroduction.isViewed;
2708 var markAsViewed = _useIntroduction.markAsViewed;
2709 if (isViewed) return null;
2710 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
2711 sx: _objectSpread$28({ mt: 2 }, props.sx),
2712 alignItems: "top"
2713 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
2714 severity: "info",
2715 variant: "standard",
2716 icon: /*#__PURE__*/ react.default.createElement(BulbIcon, { sx: { alignSelf: "flex-start" } }),
2717 onClose: markAsViewed
2718 }, (0, _wordpress_i18n.__)("Get improved results from AI by adding personal context.", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
2719 onClick: function onClick() {
2720 return $e.route("panel/global/menu");
2721 },
2722 className: "elementor-clickable",
2723 style: { textDecoration: "none" },
2724 color: "info.main",
2725 href: "#"
2726 }, (0, _wordpress_i18n.__)("Let’s do it", "elementor"))));
2727 };
2728 VoicePromotionAlert.propTypes = {
2729 sx: import_prop_types$3.default.object,
2730 introductionKey: import_prop_types$3.default.string
2731 };
2732 }));
2733
2734 //#endregion
2735 //#region modules/ai/assets/js/editor/pages/form-text/index.js
2736 init_asyncToGenerator();
2737 init_slicedToArray();
2738 init_actions_data();
2739 init_prompt_history_action_context();
2740 init_requests_ids();
2741 init_voice_promotion_alert();
2742 var promptActions = [
2743 {
2744 label: (0, _wordpress_i18n.__)("Simplify language", "elementor"),
2745 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.MessageIcon, { fontSize: "small" }),
2746 value: "Simplify the language of the following message"
2747 },
2748 {
2749 label: (0, _wordpress_i18n.__)("Make it longer", "elementor"),
2750 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ExpandIcon, { fontSize: "small" }),
2751 value: "Make the following message longer"
2752 },
2753 {
2754 label: (0, _wordpress_i18n.__)("Make it shorter", "elementor"),
2755 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.ShrinkIcon, { fontSize: "small" }),
2756 value: "Make the following message shorter"
2757 },
2758 {
2759 label: (0, _wordpress_i18n.__)("Fix spelling & grammar", "elementor"),
2760 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { fontSize: "small" }),
2761 value: "Fix the spelling and grammar of the following message"
2762 }
2763 ];
2764 var promptInstructions = [{
2765 label: (0, _wordpress_i18n.__)("Change tone", "elementor"),
2766 options: vocalTones,
2767 getInstruction: function getInstruction(value) {
2768 return "Change the tone of the following message to ".concat(value);
2769 }
2770 }, {
2771 label: (0, _wordpress_i18n.__)("Translate to", "elementor"),
2772 options: translateLanguages,
2773 getInstruction: function getInstruction(value) {
2774 return "Translate the following message to ".concat(value);
2775 }
2776 }];
2777 var FormText = function FormText(_ref) {
2778 var _initialValue$result;
2779 var _initialValue$credits;
2780 var _additionalOptions$in;
2781 var type = _ref.type;
2782 var onClose = _ref.onClose;
2783 var getControlValue = _ref.getControlValue;
2784 var setControlValue = _ref.setControlValue;
2785 var additionalOptions = _ref.additionalOptions;
2786 var credits = _ref.credits;
2787 var children = _ref.children;
2788 var initialValue = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? "" : getControlValue();
2789 var _useTextPrompt = useTextPrompt({
2790 result: (_initialValue$result = initialValue === null || initialValue === void 0 ? void 0 : initialValue.result) !== null && _initialValue$result !== void 0 ? _initialValue$result : initialValue,
2791 credits: (_initialValue$credits = initialValue === null || initialValue === void 0 ? void 0 : initialValue.credits) !== null && _initialValue$credits !== void 0 ? _initialValue$credits : credits,
2792 responseId: initialValue === null || initialValue === void 0 ? void 0 : initialValue.responseId
2793 });
2794 var data = _useTextPrompt.data;
2795 var isLoading = _useTextPrompt.isLoading;
2796 var txtGenErr = _useTextPrompt.error;
2797 var setResult = _useTextPrompt.setResult;
2798 var reset = _useTextPrompt.reset;
2799 var send = _useTextPrompt.send;
2800 var sendUsageData = _useTextPrompt.sendUsageData;
2801 var error = txtGenErr || (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initError);
2802 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
2803 var prompt = _useState2[0];
2804 var setPrompt = _useState2[1];
2805 var setGenerate = useRequestIds().setGenerate;
2806 useSubscribeOnPromptHistoryAction([{
2807 type: ACTION_TYPES.REUSE,
2808 handler: function handler(action) {
2809 reset();
2810 setPrompt(action.data);
2811 }
2812 }, {
2813 type: ACTION_TYPES.EDIT,
2814 handler: function handler(action) {
2815 setResult(action.data);
2816 }
2817 }]);
2818 var searchField = (0, react.useRef)(null);
2819 var resultField = (0, react.useRef)(null);
2820 var lastRun = (0, react.useRef)((_additionalOptions$in = additionalOptions.initRetry) !== null && _additionalOptions$in !== void 0 ? _additionalOptions$in : function() {});
2821 var autocompleteItems = "textarea" === type ? textareaAutocomplete : textAutocomplete;
2822 var showSuggestions = !prompt;
2823 var handleSubmit = function handleSubmit(event) {
2824 event.preventDefault();
2825 setGenerate();
2826 lastRun.current = function() {
2827 return send({ prompt });
2828 };
2829 lastRun.current();
2830 };
2831 var handleCustomInstruction = /*#__PURE__*/ function() {
2832 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(instruction) {
2833 return import_regenerator$2.default.wrap(function(_context) {
2834 while (1) switch (_context.prev = _context.next) {
2835 case 0:
2836 setGenerate();
2837 lastRun.current = function() {
2838 return send({
2839 input: resultField.current.value,
2840 instruction
2841 });
2842 };
2843 lastRun.current();
2844 case 1:
2845 case "end": return _context.stop();
2846 }
2847 }, _callee);
2848 }));
2849 return function handleCustomInstruction(_x) {
2850 return _ref2.apply(this, arguments);
2851 };
2852 }();
2853 var handleSuggestion = function handleSuggestion(suggestion) {
2854 setPrompt(suggestion + " ");
2855 searchField.current.focus();
2856 };
2857 var applyPrompt = function applyPrompt() {
2858 sendUsageData();
2859 setControlValue(resultField.current.value);
2860 onClose();
2861 };
2862 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
2863 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
2864 error,
2865 onRetry: lastRun.current,
2866 sx: { mb: 2.5 }
2867 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
2868 component: "form",
2869 onSubmit: handleSubmit
2870 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mb: 2.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
2871 ref: searchField,
2872 placeholder: (0, _wordpress_i18n.__)("Describe the text and tone you want to use...", "elementor"),
2873 name: "prompt",
2874 value: prompt,
2875 onChange: function onChange(event) {
2876 return setPrompt(event.target.value);
2877 }
2878 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
2879 suggestions: autocompleteItems,
2880 onSelect: handleSuggestion,
2881 suggestionFilter: function suggestionFilter(suggestion) {
2882 return suggestion + "...";
2883 }
2884 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: "https://go.elementor.com/ai-prompt-library-text/" })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
2885 introductionKey: "ai-context-text-promotion",
2886 sx: { mb: 2 }
2887 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2888 direction: "row",
2889 alignItems: "center",
2890 sx: {
2891 pb: 1.5,
2892 mt: 2
2893 }
2894 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2895 direction: "row",
2896 justifyContent: "flex-end",
2897 flexGrow: 1
2898 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate text", "elementor"))))), data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { mt: 1 } }, /*#__PURE__*/ react.default.createElement(Textarea, {
2899 fullWidth: true,
2900 ref: resultField,
2901 value: data.result,
2902 helperText: (0, _wordpress_i18n.__)("Text generated by AI may be inaccurate or offensive.", "elementor"),
2903 onChange: function onChange(event) {
2904 return setResult(event.target.value);
2905 }
2906 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
2907 container: true,
2908 spacing: 1,
2909 sx: { mt: 2.5 }
2910 }, promptActions.map(function(_ref3) {
2911 var label = _ref3.label;
2912 var icon = _ref3.icon;
2913 var value = _ref3.value;
2914 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Grid, {
2915 item: true,
2916 key: label
2917 }, /*#__PURE__*/ react.default.createElement(PromptAction, {
2918 label,
2919 icon,
2920 onClick: function onClick() {
2921 return handleCustomInstruction(value);
2922 }
2923 }));
2924 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2925 direction: "row",
2926 alignItems: "center",
2927 spacing: 1,
2928 sx: { mt: 2.5 }
2929 }, promptInstructions.map(function(_ref4) {
2930 var label = _ref4.label;
2931 var options = _ref4.options;
2932 var getInstruction = _ref4.getInstruction;
2933 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, {
2934 key: label,
2935 label,
2936 options,
2937 onChange: function onChange(event) {
2938 return handleCustomInstruction(getInstruction(event.target.value));
2939 }
2940 });
2941 })), additionalOptions.hideAiContext ? null : /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, {
2942 introductionKey: "ai-context-text-promotion",
2943 sx: { mb: 2 }
2944 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2945 direction: "row",
2946 alignItems: "center",
2947 sx: { my: 1 }
2948 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2949 direction: "row",
2950 gap: 1,
2951 justifyContent: "flex-end",
2952 flexGrow: 1
2953 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
2954 size: "small",
2955 color: "secondary",
2956 variant: "text",
2957 onClick: reset
2958 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
2959 size: "small",
2960 variant: "contained",
2961 color: "primary",
2962 onClick: applyPrompt
2963 }, (0, _wordpress_i18n.__)("Use text", "elementor"))))));
2964 };
2965 FormText.propTypes = {
2966 type: import_prop_types$7.default.string.isRequired,
2967 controlType: import_prop_types$7.default.string,
2968 onClose: import_prop_types$7.default.func.isRequired,
2969 getControlValue: import_prop_types$7.default.func.isRequired,
2970 setControlValue: import_prop_types$7.default.func.isRequired,
2971 additionalOptions: import_prop_types$7.default.object,
2972 credits: import_prop_types$7.default.number,
2973 usagePercentage: import_prop_types$7.default.number,
2974 children: import_prop_types$7.default.node
2975 };
2976
2977 //#endregion
2978 //#region modules/ai/assets/js/editor/pages/connect/index.js
2979 var Connect = function Connect(_ref) {
2980 var connectUrl = _ref.connectUrl;
2981 var onSuccess = _ref.onSuccess;
2982 var approveButtonRef = (0, react.useRef)();
2983 (0, react.useEffect)(function() {
2984 if (!jQuery.fn.elementorConnect) return;
2985 jQuery(approveButtonRef.current).elementorConnect({
2986 success: function success(_, data) {
2987 return onSuccess(data);
2988 },
2989 error: function error() {
2990 throw new Error("Elementor AI: Failed to connect.");
2991 }
2992 });
2993 }, []);
2994 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
2995 alignItems: "center",
2996 gap: 2
2997 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
2998 color: "text.primary",
2999 fontSize: "60px",
3000 mb: 1
3001 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3002 variant: "h4",
3003 sx: { color: "text.primary" }
3004 }, (0, _wordpress_i18n.__)("Step into the future with Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("Create smarter with AI text and code generators built right into the editor.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3005 variant: "caption",
3006 sx: {
3007 maxWidth: 520,
3008 textAlign: "center"
3009 }
3010 }, " ", (0, _wordpress_i18n.__)("By clicking \"Connect\", I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3011 href: "https://go.elementor.com/ai-terms/",
3012 target: "_blank",
3013 color: "info.main"
3014 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3015 href: "https://go.elementor.com/ai-privacy-policy/",
3016 target: "_blank",
3017 color: "info.main"
3018 }, (0, _wordpress_i18n.__)("Privacy Policy", "elementor")), (0, _wordpress_i18n.__)(" of the Elementor AI service.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3019 ref: approveButtonRef,
3020 href: connectUrl,
3021 variant: "contained",
3022 sx: {
3023 mt: 1,
3024 "&:hover": { color: "primary.contrastText" }
3025 }
3026 }, (0, _wordpress_i18n.__)("Connect", "elementor")));
3027 };
3028 Connect.propTypes = {
3029 connectUrl: import_prop_types$7.default.string.isRequired,
3030 onSuccess: import_prop_types$7.default.func.isRequired
3031 };
3032
3033 //#endregion
3034 //#region modules/ai/assets/js/editor/pages/get-started/index.js
3035 init_asyncToGenerator();
3036 init_slicedToArray();
3037 init_api();
3038 var GetStarted = function GetStarted(_ref) {
3039 var onSuccess = _ref.onSuccess;
3040 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
3041 var isTermsChecked = _useState2[0];
3042 var setIsTermsChecked = _useState2[1];
3043 var onGetStartedClick = /*#__PURE__*/ function() {
3044 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
3045 return import_regenerator$2.default.wrap(function(_context) {
3046 while (1) switch (_context.prev = _context.next) {
3047 case 0:
3048 _context.next = 1;
3049 return setGetStarted();
3050 case 1: onSuccess();
3051 case 2:
3052 case "end": return _context.stop();
3053 }
3054 }, _callee);
3055 }));
3056 return function onGetStartedClick() {
3057 return _ref2.apply(this, arguments);
3058 };
3059 }();
3060 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3061 alignItems: "center",
3062 gap: 1.5
3063 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
3064 color: "text.primary",
3065 fontSize: "60px",
3066 mb: 1
3067 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3068 variant: "h4",
3069 sx: { color: "text.primary" }
3070 }, (0, _wordpress_i18n.__)("Step into the future with Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("Create smarter with AI text and code generators built right into the editor.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3071 direction: "row",
3072 gap: 1.5,
3073 alignItems: "flex-start"
3074 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
3075 id: "e-ai-terms-approval",
3076 color: "secondary",
3077 checked: isTermsChecked,
3078 onClick: function onClick() {
3079 return setIsTermsChecked(function(prevState) {
3080 return !prevState;
3081 });
3082 }
3083 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3084 variant: "caption",
3085 sx: { maxWidth: 520 },
3086 component: "label",
3087 htmlFor: "e-ai-terms-approval"
3088 }, " ", (0, _wordpress_i18n.__)("I approve the ", "elementor"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3089 href: "https://go.elementor.com/ai-terms/",
3090 target: "_blank",
3091 color: "info.main"
3092 }, (0, _wordpress_i18n.__)("Terms of Service", "elementor")), " & ", /*#__PURE__*/ react.default.createElement(_elementor_ui.Link, {
3093 href: "https://go.elementor.com/ai-privacy-policy/",
3094 target: "_blank",
3095 color: "info.main"
3096 }, (0, _wordpress_i18n.__)("Privacy Policy", "elementor")), (0, _wordpress_i18n.__)(" of the Elementor AI service.", "elementor"), /*#__PURE__*/ react.default.createElement("br", null), (0, _wordpress_i18n.__)("This includes consenting to the collection and use of data to improve user experience.", "elementor")))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
3097 disabled: !isTermsChecked,
3098 variant: "contained",
3099 onClick: onGetStartedClick,
3100 sx: {
3101 mt: 1,
3102 "&:hover": { color: "primary.contrastText" }
3103 }
3104 }, (0, _wordpress_i18n.__)("Get Started", "elementor")));
3105 };
3106 GetStarted.propTypes = { onSuccess: import_prop_types$7.default.func.isRequired };
3107
3108 //#endregion
3109 //#region modules/ai/assets/js/editor/hooks/use-user-info.js
3110 init_defineProperty$1();
3111 init_asyncToGenerator();
3112 init_slicedToArray();
3113 init_api();
3114 function ownKeys$28(e, r) {
3115 var t = Object.keys(e);
3116 if (Object.getOwnPropertySymbols) {
3117 var o = Object.getOwnPropertySymbols(e);
3118 r && (o = o.filter(function(r) {
3119 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3120 })), t.push.apply(t, o);
3121 }
3122 return t;
3123 }
3124 __name(ownKeys$28, "ownKeys");
3125 function _objectSpread$27(e) {
3126 for (var r = 1; r < arguments.length; r++) {
3127 var t = null != arguments[r] ? arguments[r] : {};
3128 r % 2 ? ownKeys$28(Object(t), !0).forEach(function(r) {
3129 _defineProperty$1(e, r, t[r]);
3130 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$28(Object(t)).forEach(function(r) {
3131 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3132 });
3133 }
3134 return e;
3135 }
3136 __name(_objectSpread$27, "_objectSpread");
3137 var useUserInfo = function useUserInfo() {
3138 var immediately = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
3139 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
3140 var isLoaded = _useState2[0];
3141 var setIsLoaded = _useState2[1];
3142 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
3143 var isLoading = _useState4[0];
3144 var setIsLoading = _useState4[1];
3145 var _useState6 = _slicedToArray((0, react.useState)({
3146 is_connected: false,
3147 is_get_started: false,
3148 connect_url: "",
3149 usage: {
3150 hasAiSubscription: false,
3151 quota: 0,
3152 usedQuota: 0
3153 }
3154 }), 2);
3155 var userInfo = _useState6[0];
3156 var setUserInfo = _useState6[1];
3157 var credits = userInfo.usage.quota - userInfo.usage.usedQuota;
3158 var usagePercentage = userInfo.usage.quota ? userInfo.usage.usedQuota / userInfo.usage.quota * 100 : 0;
3159 var fetchData = /*#__PURE__*/ function() {
3160 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
3161 var userInfoResult;
3162 return import_regenerator$2.default.wrap(function(_context) {
3163 while (1) switch (_context.prev = _context.next) {
3164 case 0:
3165 setIsLoading(true);
3166 _context.next = 1;
3167 return getUserInformation(immediately);
3168 case 1:
3169 userInfoResult = _context.sent;
3170 setUserInfo(function(prevState) {
3171 return _objectSpread$27(_objectSpread$27({}, prevState), userInfoResult);
3172 });
3173 setIsLoaded(true);
3174 setIsLoading(false);
3175 case 2:
3176 case "end": return _context.stop();
3177 }
3178 }, _callee);
3179 }));
3180 return function fetchData() {
3181 return _ref.apply(this, arguments);
3182 };
3183 }();
3184 if (!isLoaded && !isLoading) fetchData();
3185 return {
3186 isLoading,
3187 isLoaded,
3188 isConnected: userInfo.is_connected,
3189 isGetStarted: userInfo.is_get_started,
3190 connectUrl: userInfo.connect_url,
3191 builderUrl: userInfo.usage.builderUrl,
3192 hasSubscription: userInfo.usage.hasAiSubscription,
3193 credits: credits < 0 ? 0 : credits,
3194 usagePercentage: Math.round(usagePercentage),
3195 fetchData
3196 };
3197 };
3198 useUserInfo.propTypes = { immediately: import_prop_types$7.default.bool };
3199
3200 //#endregion
3201 //#region modules/ai/assets/js/editor/components/dialog-header.js
3202 init_extends();
3203 var StyledElementorLogo = (0, _elementor_ui.styled)(function ElementorLogo(props) {
3204 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 32 32" }, props), /*#__PURE__*/ react.default.createElement("path", {
3205 fillRule: "evenodd",
3206 clipRule: "evenodd",
3207 d: "M2.69648 24.8891C0.938383 22.2579 0 19.1645 0 16C0 11.7566 1.68571 7.68687 4.68629 4.68629C7.68687 1.68571 11.7566 0 16 0C19.1645 0 22.2579 0.938383 24.8891 2.69648C27.5203 4.45459 29.5711 6.95344 30.7821 9.87706C31.9931 12.8007 32.3099 16.0177 31.6926 19.1214C31.0752 22.2251 29.5514 25.0761 27.3137 27.3137C25.0761 29.5514 22.2251 31.0752 19.1214 31.6926C16.0177 32.3099 12.8007 31.9931 9.87706 30.7821C6.95344 29.5711 4.45459 27.5203 2.69648 24.8891ZM12.0006 9.33281H9.33437V22.6665H12.0006V9.33281ZM22.6657 9.33281H14.6669V11.9991H22.6657V9.33281ZM22.6657 14.6654H14.6669V17.3316H22.6657V14.6654ZM22.6657 20.0003H14.6669V22.6665H22.6657V20.0003Z"
3208 }));
3209 })(function(_ref) {
3210 var theme = _ref.theme;
3211 return {
3212 width: theme.spacing(3),
3213 height: theme.spacing(3),
3214 "& path": { fill: theme.palette.text.primary }
3215 };
3216 });
3217 var DialogHeader$1 = function DialogHeader(props) {
3218 var hideAiBetaLogo = props.hideAiBetaLogo;
3219 var onClose = props.onClose;
3220 var children = props.children;
3221 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
3222 sx: { fontWeight: "normal" },
3223 color: "transparent",
3224 position: "relative"
3225 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Toolbar, { variant: "dense" }, !hideAiBetaLogo && /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(StyledElementorLogo, { sx: { mr: 1 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
3226 component: "span",
3227 variant: "subtitle2",
3228 sx: {
3229 fontWeight: "bold",
3230 textTransform: "uppercase"
3231 }
3232 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
3233 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
3234 color: "default",
3235 size: "small",
3236 sx: { ml: 1 }
3237 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
3238 direction: "row",
3239 spacing: 1,
3240 alignItems: "center",
3241 sx: { ml: hideAiBetaLogo ? 0 : "auto" }
3242 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
3243 size: "small",
3244 "aria-label": "close",
3245 onClick: onClose,
3246 sx: { "&.MuiButtonBase-root": { mr: -1 } }
3247 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
3248 };
3249 DialogHeader$1.propTypes = {
3250 onClose: import_prop_types$7.default.func.isRequired,
3251 hideAiBetaLogo: import_prop_types$7.default.bool,
3252 children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node])
3253 };
3254
3255 //#endregion
3256 //#region modules/ai/assets/js/editor/components/wizard-dialog.js
3257 init_extends();
3258 init_defineProperty$1();
3259 init_objectWithoutProperties$1();
3260 var _excluded$30 = ["sx"];
3261 function ownKeys$27(e, r) {
3262 var t = Object.keys(e);
3263 if (Object.getOwnPropertySymbols) {
3264 var o = Object.getOwnPropertySymbols(e);
3265 r && (o = o.filter(function(r) {
3266 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3267 })), t.push.apply(t, o);
3268 }
3269 return t;
3270 }
3271 __name(ownKeys$27, "ownKeys");
3272 function _objectSpread$26(e) {
3273 for (var r = 1; r < arguments.length; r++) {
3274 var t = null != arguments[r] ? arguments[r] : {};
3275 r % 2 ? ownKeys$27(Object(t), !0).forEach(function(r) {
3276 _defineProperty$1(e, r, t[r]);
3277 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$27(Object(t)).forEach(function(r) {
3278 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3279 });
3280 }
3281 return e;
3282 }
3283 __name(_objectSpread$26, "_objectSpread");
3284 var WizardDialog = function WizardDialog(props) {
3285 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
3286 open: true,
3287 onClose: props.onClose,
3288 fullWidth: true,
3289 hideBackdrop: true,
3290 maxWidth: "lg",
3291 PaperProps: { sx: { height: "88vh" } },
3292 sx: { zIndex: 9999 }
3293 }, props.children);
3294 };
3295 WizardDialog.propTypes = {
3296 onClose: import_prop_types$7.default.func.isRequired,
3297 children: import_prop_types$7.default.node.isRequired
3298 };
3299 var WizardDialogContent = function WizardDialogContent(_ref) {
3300 var _ref$sx = _ref.sx;
3301 var sx = _ref$sx === void 0 ? {} : _ref$sx;
3302 var props = _objectWithoutProperties$1(_ref, _excluded$30);
3303 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, _extends$1({}, props, { sx: _objectSpread$26({
3304 display: "flex",
3305 flexDirection: "column",
3306 justifyContent: "center"
3307 }, sx) }));
3308 };
3309 WizardDialogContent.propTypes = { sx: import_prop_types$7.default.object };
3310 WizardDialog.Header = DialogHeader$1;
3311 WizardDialog.Content = WizardDialogContent;
3312
3313 //#endregion
3314 //#region \0@[email protected]/helpers/esm/typeof.js
3315 function _typeof(o) {
3316 "@babel/helpers - typeof";
3317 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
3318 return typeof o;
3319 } : function(o) {
3320 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
3321 }, _typeof(o);
3322 }
3323 var init_typeof = __esmMin((() => {}));
3324
3325 //#endregion
3326 //#region \0@[email protected]/helpers/esm/toPrimitive.js
3327 function toPrimitive(t, r) {
3328 if ("object" != _typeof(t) || !t) return t;
3329 var e = t[Symbol.toPrimitive];
3330 if (void 0 !== e) {
3331 var i = e.call(t, r || "default");
3332 if ("object" != _typeof(i)) return i;
3333 throw new TypeError("@@toPrimitive must return a primitive value.");
3334 }
3335 return ("string" === r ? String : Number)(t);
3336 }
3337 var init_toPrimitive = __esmMin((() => {
3338 init_typeof();
3339 }));
3340
3341 //#endregion
3342 //#region \0@[email protected]/helpers/esm/toPropertyKey.js
3343 function toPropertyKey(t) {
3344 var i = toPrimitive(t, "string");
3345 return "symbol" == _typeof(i) ? i : i + "";
3346 }
3347 var init_toPropertyKey = __esmMin((() => {
3348 init_typeof();
3349 init_toPrimitive();
3350 }));
3351
3352 //#endregion
3353 //#region \0@[email protected]/helpers/esm/defineProperty.js
3354 function _defineProperty(e, r, t) {
3355 return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
3356 value: t,
3357 enumerable: !0,
3358 configurable: !0,
3359 writable: !0
3360 }) : e[r] = t, e;
3361 }
3362 var init_defineProperty = __esmMin((() => {
3363 init_toPropertyKey();
3364 }));
3365
3366 //#endregion
3367 //#region \0@[email protected]/helpers/esm/objectSpread2.js
3368 function ownKeys$26(e, r) {
3369 var t = Object.keys(e);
3370 if (Object.getOwnPropertySymbols) {
3371 var o = Object.getOwnPropertySymbols(e);
3372 r && (o = o.filter(function(r) {
3373 return Object.getOwnPropertyDescriptor(e, r).enumerable;
3374 })), t.push.apply(t, o);
3375 }
3376 return t;
3377 }
3378 function _objectSpread2(e) {
3379 for (var r = 1; r < arguments.length; r++) {
3380 var t = null != arguments[r] ? arguments[r] : {};
3381 r % 2 ? ownKeys$26(Object(t), !0).forEach(function(r) {
3382 _defineProperty(e, r, t[r]);
3383 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$26(Object(t)).forEach(function(r) {
3384 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
3385 });
3386 }
3387 return e;
3388 }
3389 var init_objectSpread2 = __esmMin((() => {
3390 init_defineProperty();
3391 __name(ownKeys$26, "ownKeys");
3392 }));
3393
3394 //#endregion
3395 //#region \0@[email protected]/helpers/esm/objectWithoutPropertiesLoose.js
3396 function _objectWithoutPropertiesLoose(r, e) {
3397 if (null == r) return {};
3398 var t = {};
3399 for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
3400 if (e.includes(n)) continue;
3401 t[n] = r[n];
3402 }
3403 return t;
3404 }
3405 var init_objectWithoutPropertiesLoose = __esmMin((() => {}));
3406
3407 //#endregion
3408 //#region \0@[email protected]/helpers/esm/objectWithoutProperties.js
3409 function _objectWithoutProperties(e, t) {
3410 if (null == e) return {};
3411 var o;
3412 var r;
3413 var i = _objectWithoutPropertiesLoose(e, t);
3414 if (Object.getOwnPropertySymbols) {
3415 var s = Object.getOwnPropertySymbols(e);
3416 for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
3417 }
3418 return i;
3419 }
3420 var init_objectWithoutProperties = __esmMin((() => {
3421 init_objectWithoutPropertiesLoose();
3422 }));
3423
3424 //#endregion
3425 //#region node_modules/react-draggable/node_modules/clsx/dist/clsx.js
3426 var require_clsx = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3427 function r(e) {
3428 var o;
3429 var t;
3430 var f = "";
3431 if ("string" == typeof e || "number" == typeof e) f += e;
3432 else if ("object" == typeof e) if (Array.isArray(e)) {
3433 var n = e.length;
3434 for (o = 0; o < n; o++) e[o] && (t = r(e[o])) && (f && (f += " "), f += t);
3435 } else for (t in e) e[t] && (f && (f += " "), f += t);
3436 return f;
3437 }
3438 function e() {
3439 for (var e, o, t = 0, f = "", n = arguments.length; t < n; t++) (e = arguments[t]) && (o = r(e)) && (f && (f += " "), f += o);
3440 return f;
3441 }
3442 module.exports = e, module.exports.clsx = e;
3443 }));
3444
3445 //#endregion
3446 //#region node_modules/react-draggable/build/cjs/utils/shims.js
3447 var require_shims = /* @__PURE__ */ __commonJSMin(((exports) => {
3448 Object.defineProperty(exports, "__esModule", { value: true });
3449 exports.dontSetMe = dontSetMe;
3450 exports.findInArray = findInArray;
3451 exports.int = int;
3452 exports.isFunction = isFunction;
3453 exports.isNum = isNum;
3454 function findInArray(array, callback) {
3455 for (let i = 0, length = array.length; i < length; i++) if (callback.apply(callback, [
3456 array[i],
3457 i,
3458 array
3459 ])) return array[i];
3460 }
3461 function isFunction(func) {
3462 return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
3463 }
3464 function isNum(num) {
3465 return typeof num === "number" && !isNaN(num);
3466 }
3467 function int(a) {
3468 return parseInt(a, 10);
3469 }
3470 function dontSetMe(props, propName, componentName) {
3471 if (props[propName]) return /* @__PURE__ */ new Error(`Invalid prop ${propName} passed to ${componentName} - do not set this, set it on the child.`);
3472 }
3473 }));
3474
3475 //#endregion
3476 //#region node_modules/react-draggable/build/cjs/utils/getPrefix.js
3477 var require_getPrefix = /* @__PURE__ */ __commonJSMin(((exports) => {
3478 Object.defineProperty(exports, "__esModule", { value: true });
3479 exports.browserPrefixToKey = browserPrefixToKey;
3480 exports.browserPrefixToStyle = browserPrefixToStyle;
3481 exports.default = void 0;
3482 exports.getPrefix = getPrefix;
3483 var prefixes = [
3484 "Moz",
3485 "Webkit",
3486 "O",
3487 "ms"
3488 ];
3489 function getPrefix() {
3490 var _window$document;
3491 let prop = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "transform";
3492 if (typeof window === "undefined") return "";
3493 const style = (_window$document = window.document) === null || _window$document === void 0 || (_window$document = _window$document.documentElement) === null || _window$document === void 0 ? void 0 : _window$document.style;
3494 if (!style) return "";
3495 if (prop in style) return "";
3496 for (let i = 0; i < prefixes.length; i++) if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
3497 return "";
3498 }
3499 function browserPrefixToKey(prop, prefix) {
3500 return prefix ? `${prefix}${kebabToTitleCase(prop)}` : prop;
3501 }
3502 function browserPrefixToStyle(prop, prefix) {
3503 return prefix ? `-${prefix.toLowerCase()}-${prop}` : prop;
3504 }
3505 function kebabToTitleCase(str) {
3506 let out = "";
3507 let shouldCapitalize = true;
3508 for (let i = 0; i < str.length; i++) if (shouldCapitalize) {
3509 out += str[i].toUpperCase();
3510 shouldCapitalize = false;
3511 } else if (str[i] === "-") shouldCapitalize = true;
3512 else out += str[i];
3513 return out;
3514 }
3515 exports.default = getPrefix();
3516 }));
3517
3518 //#endregion
3519 //#region node_modules/react-draggable/build/cjs/utils/domFns.js
3520 var require_domFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3521 init_objectSpread2();
3522 Object.defineProperty(exports, "__esModule", { value: true });
3523 exports.addClassName = addClassName;
3524 exports.addEvent = addEvent;
3525 exports.addUserSelectStyles = addUserSelectStyles;
3526 exports.createCSSTransform = createCSSTransform;
3527 exports.createSVGTransform = createSVGTransform;
3528 exports.getTouch = getTouch;
3529 exports.getTouchIdentifier = getTouchIdentifier;
3530 exports.getTranslation = getTranslation;
3531 exports.innerHeight = innerHeight;
3532 exports.innerWidth = innerWidth;
3533 exports.matchesSelector = matchesSelector;
3534 exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
3535 exports.offsetXYFromParent = offsetXYFromParent;
3536 exports.outerHeight = outerHeight;
3537 exports.outerWidth = outerWidth;
3538 exports.removeClassName = removeClassName;
3539 exports.removeEvent = removeEvent;
3540 exports.scheduleRemoveUserSelectStyles = scheduleRemoveUserSelectStyles;
3541 var _shims = require_shims();
3542 var _getPrefix = _interopRequireWildcard(require_getPrefix());
3543 function _interopRequireWildcard(e, t) {
3544 if ("function" == typeof WeakMap) {
3545 var r = /* @__PURE__ */ new WeakMap();
3546 var n = /* @__PURE__ */ new WeakMap();
3547 }
3548 return (_interopRequireWildcard = function(e, t) {
3549 if (!t && e && e.__esModule) return e;
3550 var o;
3551 var i;
3552 var f = {
3553 __proto__: null,
3554 default: e
3555 };
3556 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3557 if (o = t ? n : r) {
3558 if (o.has(e)) return o.get(e);
3559 o.set(e, f);
3560 }
3561 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
3562 return f;
3563 })(e, t);
3564 }
3565 var matchesSelectorFunc = "";
3566 function matchesSelector(el, selector) {
3567 if (!matchesSelectorFunc) matchesSelectorFunc = (0, _shims.findInArray)([
3568 "matches",
3569 "webkitMatchesSelector",
3570 "mozMatchesSelector",
3571 "msMatchesSelector",
3572 "oMatchesSelector"
3573 ], function(method) {
3574 return (0, _shims.isFunction)(el[method]);
3575 });
3576 if (!(0, _shims.isFunction)(el[matchesSelectorFunc])) return false;
3577 return el[matchesSelectorFunc](selector);
3578 }
3579 function matchesSelectorAndParentsTo(el, selector, baseNode) {
3580 let node = el;
3581 do {
3582 if (matchesSelector(node, selector)) return true;
3583 if (node === baseNode) return false;
3584 node = node.parentNode;
3585 } while (node);
3586 return false;
3587 }
3588 function addEvent(el, event, handler, inputOptions) {
3589 if (!el) return;
3590 const options = _objectSpread2({ capture: true }, inputOptions);
3591 if (el.addEventListener) el.addEventListener(event, handler, options);
3592 else if (el.attachEvent) el.attachEvent("on" + event, handler);
3593 else el["on" + event] = handler;
3594 }
3595 function removeEvent(el, event, handler, inputOptions) {
3596 if (!el) return;
3597 const options = _objectSpread2({ capture: true }, inputOptions);
3598 if (el.removeEventListener) el.removeEventListener(event, handler, options);
3599 else if (el.detachEvent) el.detachEvent("on" + event, handler);
3600 else el["on" + event] = null;
3601 }
3602 function outerHeight(node) {
3603 let height = node.clientHeight;
3604 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3605 height += (0, _shims.int)(computedStyle.borderTopWidth);
3606 height += (0, _shims.int)(computedStyle.borderBottomWidth);
3607 return height;
3608 }
3609 function outerWidth(node) {
3610 let width = node.clientWidth;
3611 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3612 width += (0, _shims.int)(computedStyle.borderLeftWidth);
3613 width += (0, _shims.int)(computedStyle.borderRightWidth);
3614 return width;
3615 }
3616 function innerHeight(node) {
3617 let height = node.clientHeight;
3618 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3619 height -= (0, _shims.int)(computedStyle.paddingTop);
3620 height -= (0, _shims.int)(computedStyle.paddingBottom);
3621 return height;
3622 }
3623 function innerWidth(node) {
3624 let width = node.clientWidth;
3625 const computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
3626 width -= (0, _shims.int)(computedStyle.paddingLeft);
3627 width -= (0, _shims.int)(computedStyle.paddingRight);
3628 return width;
3629 }
3630 function offsetXYFromParent(evt, offsetParent, scale) {
3631 const offsetParentRect = offsetParent === offsetParent.ownerDocument.body ? {
3632 left: 0,
3633 top: 0
3634 } : offsetParent.getBoundingClientRect();
3635 return {
3636 x: (evt.clientX + offsetParent.scrollLeft - offsetParentRect.left) / scale,
3637 y: (evt.clientY + offsetParent.scrollTop - offsetParentRect.top) / scale
3638 };
3639 }
3640 function createCSSTransform(controlPos, positionOffset) {
3641 const translation = getTranslation(controlPos, positionOffset, "px");
3642 return { [(0, _getPrefix.browserPrefixToKey)("transform", _getPrefix.default)]: translation };
3643 }
3644 function createSVGTransform(controlPos, positionOffset) {
3645 return getTranslation(controlPos, positionOffset, "");
3646 }
3647 function getTranslation(_ref, positionOffset, unitSuffix) {
3648 let { x, y } = _ref;
3649 let translation = `translate(${x}${unitSuffix},${y}${unitSuffix})`;
3650 if (positionOffset) translation = `translate(${`${typeof positionOffset.x === "string" ? positionOffset.x : positionOffset.x + unitSuffix}`}, ${`${typeof positionOffset.y === "string" ? positionOffset.y : positionOffset.y + unitSuffix}`})` + translation;
3651 return translation;
3652 }
3653 function getTouch(e, identifier) {
3654 return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, (t) => identifier === t.identifier) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, (t) => identifier === t.identifier);
3655 }
3656 function getTouchIdentifier(e) {
3657 if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
3658 if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
3659 }
3660 function addUserSelectStyles(doc) {
3661 if (!doc) return;
3662 let styleEl = doc.getElementById("react-draggable-style-el");
3663 if (!styleEl) {
3664 styleEl = doc.createElement("style");
3665 styleEl.type = "text/css";
3666 styleEl.id = "react-draggable-style-el";
3667 styleEl.innerHTML = ".react-draggable-transparent-selection *::-moz-selection {all: inherit;}\n";
3668 styleEl.innerHTML += ".react-draggable-transparent-selection *::selection {all: inherit;}\n";
3669 doc.getElementsByTagName("head")[0].appendChild(styleEl);
3670 }
3671 if (doc.body) addClassName(doc.body, "react-draggable-transparent-selection");
3672 }
3673 function scheduleRemoveUserSelectStyles(doc) {
3674 if (window.requestAnimationFrame) window.requestAnimationFrame(() => {
3675 removeUserSelectStyles(doc);
3676 });
3677 else removeUserSelectStyles(doc);
3678 }
3679 function removeUserSelectStyles(doc) {
3680 if (!doc) return;
3681 try {
3682 if (doc.body) removeClassName(doc.body, "react-draggable-transparent-selection");
3683 if (doc.selection) doc.selection.empty();
3684 else {
3685 const selection = (doc.defaultView || window).getSelection();
3686 if (selection && selection.type !== "Caret") selection.removeAllRanges();
3687 }
3688 } catch (e) {}
3689 }
3690 function addClassName(el, className) {
3691 if (el.classList) el.classList.add(className);
3692 else if (!el.className.match(new RegExp(`(?:^|\\s)${className}(?!\\S)`))) el.className += ` ${className}`;
3693 }
3694 function removeClassName(el, className) {
3695 if (el.classList) el.classList.remove(className);
3696 else el.className = el.className.replace(new RegExp(`(?:^|\\s)${className}(?!\\S)`, "g"), "");
3697 }
3698 }));
3699
3700 //#endregion
3701 //#region node_modules/react-draggable/build/cjs/utils/positionFns.js
3702 var require_positionFns = /* @__PURE__ */ __commonJSMin(((exports) => {
3703 Object.defineProperty(exports, "__esModule", { value: true });
3704 exports.canDragX = canDragX;
3705 exports.canDragY = canDragY;
3706 exports.createCoreData = createCoreData;
3707 exports.createDraggableData = createDraggableData;
3708 exports.getBoundPosition = getBoundPosition;
3709 exports.getControlPosition = getControlPosition;
3710 exports.snapToGrid = snapToGrid;
3711 var _shims = require_shims();
3712 var _domFns = require_domFns();
3713 function getBoundPosition(draggable, x, y) {
3714 if (!draggable.props.bounds) return [x, y];
3715 let { bounds } = draggable.props;
3716 bounds = typeof bounds === "string" ? bounds : cloneBounds(bounds);
3717 const node = findDOMNode(draggable);
3718 if (typeof bounds === "string") {
3719 const { ownerDocument } = node;
3720 const ownerWindow = ownerDocument.defaultView;
3721 let boundNode;
3722 if (bounds === "parent") boundNode = node.parentNode;
3723 else boundNode = node.getRootNode().querySelector(bounds);
3724 if (!(boundNode instanceof ownerWindow.HTMLElement)) throw new Error("Bounds selector \"" + bounds + "\" could not find an element.");
3725 const boundNodeEl = boundNode;
3726 const nodeStyle = ownerWindow.getComputedStyle(node);
3727 const boundNodeStyle = ownerWindow.getComputedStyle(boundNodeEl);
3728 bounds = {
3729 left: -node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingLeft) + (0, _shims.int)(nodeStyle.marginLeft),
3730 top: -node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingTop) + (0, _shims.int)(nodeStyle.marginTop),
3731 right: (0, _domFns.innerWidth)(boundNodeEl) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingRight) - (0, _shims.int)(nodeStyle.marginRight),
3732 bottom: (0, _domFns.innerHeight)(boundNodeEl) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingBottom) - (0, _shims.int)(nodeStyle.marginBottom)
3733 };
3734 }
3735 if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
3736 if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom);
3737 if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
3738 if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
3739 return [x, y];
3740 }
3741 function snapToGrid(grid, pendingX, pendingY) {
3742 return [Math.round(pendingX / grid[0]) * grid[0], Math.round(pendingY / grid[1]) * grid[1]];
3743 }
3744 function canDragX(draggable) {
3745 return draggable.props.axis === "both" || draggable.props.axis === "x";
3746 }
3747 function canDragY(draggable) {
3748 return draggable.props.axis === "both" || draggable.props.axis === "y";
3749 }
3750 function getControlPosition(e, touchIdentifier, draggableCore) {
3751 const touchObj = typeof touchIdentifier === "number" ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
3752 if (typeof touchIdentifier === "number" && !touchObj) return null;
3753 const node = findDOMNode(draggableCore);
3754 const offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
3755 return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent, draggableCore.props.scale);
3756 }
3757 function createCoreData(draggable, x, y) {
3758 const isStart = !(0, _shims.isNum)(draggable.lastX);
3759 const node = findDOMNode(draggable);
3760 if (isStart) return {
3761 node,
3762 deltaX: 0,
3763 deltaY: 0,
3764 lastX: x,
3765 lastY: y,
3766 x,
3767 y
3768 };
3769 else return {
3770 node,
3771 deltaX: x - draggable.lastX,
3772 deltaY: y - draggable.lastY,
3773 lastX: draggable.lastX,
3774 lastY: draggable.lastY,
3775 x,
3776 y
3777 };
3778 }
3779 function createDraggableData(draggable, coreData) {
3780 const scale = draggable.props.scale;
3781 return {
3782 node: coreData.node,
3783 x: draggable.state.x + coreData.deltaX / scale,
3784 y: draggable.state.y + coreData.deltaY / scale,
3785 deltaX: coreData.deltaX / scale,
3786 deltaY: coreData.deltaY / scale,
3787 lastX: draggable.state.x,
3788 lastY: draggable.state.y
3789 };
3790 }
3791 function cloneBounds(bounds) {
3792 return {
3793 left: bounds.left,
3794 top: bounds.top,
3795 right: bounds.right,
3796 bottom: bounds.bottom
3797 };
3798 }
3799 function findDOMNode(draggable) {
3800 const node = draggable.findDOMNode();
3801 if (!node) throw new Error("<DraggableCore>: Unmounted during event!");
3802 return node;
3803 }
3804 }));
3805
3806 //#endregion
3807 //#region node_modules/react-draggable/build/cjs/utils/log.js
3808 var require_log = /* @__PURE__ */ __commonJSMin(((exports) => {
3809 Object.defineProperty(exports, "__esModule", { value: true });
3810 exports.default = log;
3811 function log() {}
3812 }));
3813
3814 //#endregion
3815 //#region node_modules/react-draggable/build/cjs/DraggableCore.js
3816 var require_DraggableCore = /* @__PURE__ */ __commonJSMin(((exports) => {
3817 Object.defineProperty(exports, "__esModule", { value: true });
3818 exports.default = void 0;
3819 var React$133 = _interopRequireWildcard((globalThis.React));
3820 var _propTypes = _interopRequireDefault(require_prop_types());
3821 var _reactDom$1 = _interopRequireDefault((globalThis.ReactDOM));
3822 var _domFns = require_domFns();
3823 var _positionFns = require_positionFns();
3824 var _shims = require_shims();
3825 var _log = _interopRequireDefault(require_log());
3826 function _interopRequireDefault(e) {
3827 return e && e.__esModule ? e : { default: e };
3828 }
3829 function _interopRequireWildcard(e, t) {
3830 if ("function" == typeof WeakMap) {
3831 var r = /* @__PURE__ */ new WeakMap();
3832 var n = /* @__PURE__ */ new WeakMap();
3833 }
3834 return (_interopRequireWildcard = function(e, t) {
3835 if (!t && e && e.__esModule) return e;
3836 var o;
3837 var i;
3838 var f = {
3839 __proto__: null,
3840 default: e
3841 };
3842 if (null === e || "object" != typeof e && "function" != typeof e) return f;
3843 if (o = t ? n : r) {
3844 if (o.has(e)) return o.get(e);
3845 o.set(e, f);
3846 }
3847 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
3848 return f;
3849 })(e, t);
3850 }
3851 function _defineProperty(e, r, t) {
3852 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
3853 value: t,
3854 enumerable: !0,
3855 configurable: !0,
3856 writable: !0
3857 }) : e[r] = t, e;
3858 }
3859 function _toPropertyKey(t) {
3860 var i = _toPrimitive(t, "string");
3861 return "symbol" == typeof i ? i : i + "";
3862 }
3863 function _toPrimitive(t, r) {
3864 if ("object" != typeof t || !t) return t;
3865 var e = t[Symbol.toPrimitive];
3866 if (void 0 !== e) {
3867 var i = e.call(t, r || "default");
3868 if ("object" != typeof i) return i;
3869 throw new TypeError("@@toPrimitive must return a primitive value.");
3870 }
3871 return ("string" === r ? String : Number)(t);
3872 }
3873 var eventsFor = {
3874 touch: {
3875 start: "touchstart",
3876 move: "touchmove",
3877 stop: "touchend"
3878 },
3879 mouse: {
3880 start: "mousedown",
3881 move: "mousemove",
3882 stop: "mouseup"
3883 }
3884 };
3885 var dragEventFor = eventsFor.mouse;
3886 var DraggableCore = class extends React$133.Component {
3887 constructor() {
3888 super(...arguments);
3889 _defineProperty(this, "dragging", false);
3890 _defineProperty(this, "lastX", NaN);
3891 _defineProperty(this, "lastY", NaN);
3892 _defineProperty(this, "touchIdentifier", null);
3893 _defineProperty(this, "mounted", false);
3894 _defineProperty(this, "handleDragStart", (e) => {
3895 this.props.onMouseDown(e);
3896 if (!this.props.allowAnyClick && typeof e.button === "number" && e.button !== 0) return false;
3897 const thisNode = this.findDOMNode();
3898 if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) throw new Error("<DraggableCore> not mounted on DragStart!");
3899 const { ownerDocument } = thisNode;
3900 if (this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.handle, thisNode) || this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, this.props.cancel, thisNode)) return;
3901 if (e.type === "touchstart" && !this.props.allowMobileScroll) e.preventDefault();
3902 const touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
3903 this.touchIdentifier = touchIdentifier;
3904 const position = (0, _positionFns.getControlPosition)(e, touchIdentifier, this);
3905 if (position == null) return;
3906 const { x, y } = position;
3907 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3908 (0, _log.default)("DraggableCore: handleDragStart: %j", coreEvent);
3909 (0, _log.default)("calling", this.props.onStart);
3910 if (this.props.onStart(e, coreEvent) === false || this.mounted === false) return;
3911 if (this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
3912 this.dragging = true;
3913 this.lastX = x;
3914 this.lastY = y;
3915 (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, this.handleDrag);
3916 (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, this.handleDragStop);
3917 });
3918 _defineProperty(this, "handleDrag", (e) => {
3919 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
3920 if (position == null) return;
3921 let { x, y } = position;
3922 if (Array.isArray(this.props.grid)) {
3923 let deltaX = x - this.lastX;
3924 let deltaY = y - this.lastY;
3925 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
3926 if (!deltaX && !deltaY) return;
3927 x = this.lastX + deltaX, y = this.lastY + deltaY;
3928 }
3929 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3930 (0, _log.default)("DraggableCore: handleDrag: %j", coreEvent);
3931 if (this.props.onDrag(e, coreEvent) === false || this.mounted === false) {
3932 try {
3933 this.handleDragStop(new MouseEvent("mouseup"));
3934 } catch (err) {
3935 const event = document.createEvent("MouseEvents");
3936 event.initMouseEvent("mouseup", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
3937 this.handleDragStop(event);
3938 }
3939 return;
3940 }
3941 this.lastX = x;
3942 this.lastY = y;
3943 });
3944 _defineProperty(this, "handleDragStop", (e) => {
3945 if (!this.dragging) return;
3946 const position = (0, _positionFns.getControlPosition)(e, this.touchIdentifier, this);
3947 if (position == null) return;
3948 let { x, y } = position;
3949 if (Array.isArray(this.props.grid)) {
3950 let deltaX = x - this.lastX || 0;
3951 let deltaY = y - this.lastY || 0;
3952 [deltaX, deltaY] = (0, _positionFns.snapToGrid)(this.props.grid, deltaX, deltaY);
3953 x = this.lastX + deltaX, y = this.lastY + deltaY;
3954 }
3955 const coreEvent = (0, _positionFns.createCoreData)(this, x, y);
3956 if (this.props.onStop(e, coreEvent) === false || this.mounted === false) return false;
3957 const thisNode = this.findDOMNode();
3958 if (thisNode) {
3959 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(thisNode.ownerDocument);
3960 }
3961 (0, _log.default)("DraggableCore: handleDragStop: %j", coreEvent);
3962 this.dragging = false;
3963 this.lastX = NaN;
3964 this.lastY = NaN;
3965 if (thisNode) {
3966 (0, _log.default)("DraggableCore: Removing handlers");
3967 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, this.handleDrag);
3968 (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, this.handleDragStop);
3969 }
3970 });
3971 _defineProperty(this, "onMouseDown", (e) => {
3972 dragEventFor = eventsFor.mouse;
3973 return this.handleDragStart(e);
3974 });
3975 _defineProperty(this, "onMouseUp", (e) => {
3976 dragEventFor = eventsFor.mouse;
3977 return this.handleDragStop(e);
3978 });
3979 _defineProperty(this, "onTouchStart", (e) => {
3980 dragEventFor = eventsFor.touch;
3981 return this.handleDragStart(e);
3982 });
3983 _defineProperty(this, "onTouchEnd", (e) => {
3984 dragEventFor = eventsFor.touch;
3985 return this.handleDragStop(e);
3986 });
3987 }
3988 componentDidMount() {
3989 this.mounted = true;
3990 const thisNode = this.findDOMNode();
3991 if (thisNode) (0, _domFns.addEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
3992 }
3993 componentWillUnmount() {
3994 this.mounted = false;
3995 const thisNode = this.findDOMNode();
3996 if (thisNode) {
3997 const { ownerDocument } = thisNode;
3998 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
3999 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
4000 (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
4001 (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
4002 (0, _domFns.removeEvent)(thisNode, eventsFor.touch.start, this.onTouchStart, { passive: false });
4003 if (this.props.enableUserSelectHack) (0, _domFns.scheduleRemoveUserSelectStyles)(ownerDocument);
4004 }
4005 }
4006 findDOMNode() {
4007 var _this$props;
4008 var _this$props2;
4009 return ((_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.nodeRef) ? (_this$props2 = this.props) === null || _this$props2 === void 0 || (_this$props2 = _this$props2.nodeRef) === null || _this$props2 === void 0 ? void 0 : _this$props2.current : _reactDom$1.default.findDOMNode(this);
4010 }
4011 render() {
4012 return /*#__PURE__*/ React$133.cloneElement(React$133.Children.only(this.props.children), {
4013 onMouseDown: this.onMouseDown,
4014 onMouseUp: this.onMouseUp,
4015 onTouchEnd: this.onTouchEnd
4016 });
4017 }
4018 };
4019 exports.default = DraggableCore;
4020 _defineProperty(DraggableCore, "displayName", "DraggableCore");
4021 _defineProperty(DraggableCore, "propTypes", {
4022 /**
4023 * `allowAnyClick` allows dragging using any mouse button.
4024 * By default, we only accept the left button.
4025 *
4026 * Defaults to `false`.
4027 */
4028 allowAnyClick: _propTypes.default.bool,
4029 /**
4030 * `allowMobileScroll` turns off cancellation of the 'touchstart' event
4031 * on mobile devices. Only enable this if you are having trouble with click
4032 * events. Prefer using 'handle' / 'cancel' instead.
4033 *
4034 * Defaults to `false`.
4035 */
4036 allowMobileScroll: _propTypes.default.bool,
4037 children: _propTypes.default.node.isRequired,
4038 /**
4039 * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
4040 * with the exception of `onMouseDown`, will not fire.
4041 */
4042 disabled: _propTypes.default.bool,
4043 /**
4044 * By default, we add 'user-select:none' attributes to the document body
4045 * to prevent ugly text selection during drag. If this is causing problems
4046 * for your app, set this to `false`.
4047 */
4048 enableUserSelectHack: _propTypes.default.bool,
4049 /**
4050 * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
4051 * instead of using the parent node.
4052 */
4053 offsetParent: function(props, propName) {
4054 if (props[propName] && props[propName].nodeType !== 1) throw new Error("Draggable's offsetParent must be a DOM Node.");
4055 },
4056 /**
4057 * `grid` specifies the x and y that dragging should snap to.
4058 */
4059 grid: _propTypes.default.arrayOf(_propTypes.default.number),
4060 /**
4061 * `handle` specifies a selector to be used as the handle that initiates drag.
4062 *
4063 * Example:
4064 *
4065 * ```jsx
4066 * let App = React.createClass({
4067 * render: function () {
4068 * return (
4069 * <Draggable handle=".handle">
4070 * <div>
4071 * <div className="handle">Click me to drag</div>
4072 * <div>This is some other content</div>
4073 * </div>
4074 * </Draggable>
4075 * );
4076 * }
4077 * });
4078 * ```
4079 */
4080 handle: _propTypes.default.string,
4081 /**
4082 * `cancel` specifies a selector to be used to prevent drag initialization.
4083 *
4084 * Example:
4085 *
4086 * ```jsx
4087 * let App = React.createClass({
4088 * render: function () {
4089 * return(
4090 * <Draggable cancel=".cancel">
4091 * <div>
4092 * <div className="cancel">You can't drag from here</div>
4093 * <div>Dragging here works fine</div>
4094 * </div>
4095 * </Draggable>
4096 * );
4097 * }
4098 * });
4099 * ```
4100 */
4101 cancel: _propTypes.default.string,
4102 nodeRef: _propTypes.default.object,
4103 /**
4104 * Called when dragging starts.
4105 * If this function returns the boolean false, dragging will be canceled.
4106 */
4107 onStart: _propTypes.default.func,
4108 /**
4109 * Called while dragging.
4110 * If this function returns the boolean false, dragging will be canceled.
4111 */
4112 onDrag: _propTypes.default.func,
4113 /**
4114 * Called when dragging stops.
4115 * If this function returns the boolean false, the drag will remain active.
4116 */
4117 onStop: _propTypes.default.func,
4118 /**
4119 * A workaround option which can be passed if onMouseDown needs to be accessed,
4120 * since it'll always be blocked (as there is internal use of onMouseDown)
4121 */
4122 onMouseDown: _propTypes.default.func,
4123 /**
4124 * `scale`, if set, applies scaling while dragging an element
4125 */
4126 scale: _propTypes.default.number,
4127 /**
4128 * These properties should be defined on the child, not here.
4129 */
4130 className: _shims.dontSetMe,
4131 style: _shims.dontSetMe,
4132 transform: _shims.dontSetMe
4133 });
4134 _defineProperty(DraggableCore, "defaultProps", {
4135 allowAnyClick: false,
4136 allowMobileScroll: false,
4137 disabled: false,
4138 enableUserSelectHack: true,
4139 onStart: function() {},
4140 onDrag: function() {},
4141 onStop: function() {},
4142 onMouseDown: function() {},
4143 scale: 1
4144 });
4145 }));
4146
4147 //#endregion
4148 //#region node_modules/react-draggable/build/cjs/Draggable.js
4149 var require_Draggable = /* @__PURE__ */ __commonJSMin(((exports) => {
4150 init_objectSpread2();
4151 init_objectWithoutProperties();
4152 var _excluded = [
4153 "axis",
4154 "bounds",
4155 "children",
4156 "defaultPosition",
4157 "defaultClassName",
4158 "defaultClassNameDragging",
4159 "defaultClassNameDragged",
4160 "position",
4161 "positionOffset",
4162 "scale"
4163 ];
4164 Object.defineProperty(exports, "__esModule", { value: true });
4165 Object.defineProperty(exports, "DraggableCore", {
4166 enumerable: true,
4167 get: function() {
4168 return _DraggableCore.default;
4169 }
4170 });
4171 exports.default = void 0;
4172 var React$132 = _interopRequireWildcard((globalThis.React));
4173 var _propTypes = _interopRequireDefault(require_prop_types());
4174 var _reactDom = _interopRequireDefault((globalThis.ReactDOM));
4175 var _clsx = require_clsx();
4176 var _domFns = require_domFns();
4177 var _positionFns = require_positionFns();
4178 var _shims = require_shims();
4179 var _DraggableCore = _interopRequireDefault(require_DraggableCore());
4180 var _log = _interopRequireDefault(require_log());
4181 function _interopRequireDefault(e) {
4182 return e && e.__esModule ? e : { default: e };
4183 }
4184 function _interopRequireWildcard(e, t) {
4185 if ("function" == typeof WeakMap) {
4186 var r = /* @__PURE__ */ new WeakMap();
4187 var n = /* @__PURE__ */ new WeakMap();
4188 }
4189 return (_interopRequireWildcard = function(e, t) {
4190 if (!t && e && e.__esModule) return e;
4191 var o;
4192 var i;
4193 var f = {
4194 __proto__: null,
4195 default: e
4196 };
4197 if (null === e || "object" != typeof e && "function" != typeof e) return f;
4198 if (o = t ? n : r) {
4199 if (o.has(e)) return o.get(e);
4200 o.set(e, f);
4201 }
4202 for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);
4203 return f;
4204 })(e, t);
4205 }
4206 function _extends() {
4207 return _extends = Object.assign ? Object.assign.bind() : function(n) {
4208 for (var e = 1; e < arguments.length; e++) {
4209 var t = arguments[e];
4210 for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
4211 }
4212 return n;
4213 }, _extends.apply(null, arguments);
4214 }
4215 function _defineProperty(e, r, t) {
4216 return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
4217 value: t,
4218 enumerable: !0,
4219 configurable: !0,
4220 writable: !0
4221 }) : e[r] = t, e;
4222 }
4223 function _toPropertyKey(t) {
4224 var i = _toPrimitive(t, "string");
4225 return "symbol" == typeof i ? i : i + "";
4226 }
4227 function _toPrimitive(t, r) {
4228 if ("object" != typeof t || !t) return t;
4229 var e = t[Symbol.toPrimitive];
4230 if (void 0 !== e) {
4231 var i = e.call(t, r || "default");
4232 if ("object" != typeof i) return i;
4233 throw new TypeError("@@toPrimitive must return a primitive value.");
4234 }
4235 return ("string" === r ? String : Number)(t);
4236 }
4237 var Draggable = class extends React$132.Component {
4238 static getDerivedStateFromProps(_ref, _ref2) {
4239 let { position } = _ref;
4240 let { prevPropsPosition } = _ref2;
4241 if (position && (!prevPropsPosition || position.x !== prevPropsPosition.x || position.y !== prevPropsPosition.y)) {
4242 (0, _log.default)("Draggable: getDerivedStateFromProps %j", {
4243 position,
4244 prevPropsPosition
4245 });
4246 return {
4247 x: position.x,
4248 y: position.y,
4249 prevPropsPosition: _objectSpread2({}, position)
4250 };
4251 }
4252 return null;
4253 }
4254 constructor(props) {
4255 super(props);
4256 _defineProperty(this, "onDragStart", (e, coreData) => {
4257 (0, _log.default)("Draggable: onDragStart: %j", coreData);
4258 if (this.props.onStart(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4259 this.setState({
4260 dragging: true,
4261 dragged: true
4262 });
4263 });
4264 _defineProperty(this, "onDrag", (e, coreData) => {
4265 if (!this.state.dragging) return false;
4266 (0, _log.default)("Draggable: onDrag: %j", coreData);
4267 const uiData = (0, _positionFns.createDraggableData)(this, coreData);
4268 const newState = {
4269 x: uiData.x,
4270 y: uiData.y,
4271 slackX: 0,
4272 slackY: 0
4273 };
4274 if (this.props.bounds) {
4275 const { x, y } = newState;
4276 newState.x += this.state.slackX;
4277 newState.y += this.state.slackY;
4278 const [newStateX, newStateY] = (0, _positionFns.getBoundPosition)(this, newState.x, newState.y);
4279 newState.x = newStateX;
4280 newState.y = newStateY;
4281 newState.slackX = this.state.slackX + (x - newState.x);
4282 newState.slackY = this.state.slackY + (y - newState.y);
4283 uiData.x = newState.x;
4284 uiData.y = newState.y;
4285 uiData.deltaX = newState.x - this.state.x;
4286 uiData.deltaY = newState.y - this.state.y;
4287 }
4288 if (this.props.onDrag(e, uiData) === false) return false;
4289 this.setState(newState);
4290 });
4291 _defineProperty(this, "onDragStop", (e, coreData) => {
4292 if (!this.state.dragging) return false;
4293 if (this.props.onStop(e, (0, _positionFns.createDraggableData)(this, coreData)) === false) return false;
4294 (0, _log.default)("Draggable: onDragStop: %j", coreData);
4295 const newState = {
4296 dragging: false,
4297 slackX: 0,
4298 slackY: 0
4299 };
4300 if (Boolean(this.props.position)) {
4301 const { x, y } = this.props.position;
4302 newState.x = x;
4303 newState.y = y;
4304 }
4305 this.setState(newState);
4306 });
4307 this.state = {
4308 dragging: false,
4309 dragged: false,
4310 x: props.position ? props.position.x : props.defaultPosition.x,
4311 y: props.position ? props.position.y : props.defaultPosition.y,
4312 prevPropsPosition: _objectSpread2({}, props.position),
4313 slackX: 0,
4314 slackY: 0,
4315 isElementSVG: false
4316 };
4317 if (props.position && !(props.onDrag || props.onStop)) console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.");
4318 }
4319 componentDidMount() {
4320 if (typeof window.SVGElement !== "undefined" && this.findDOMNode() instanceof window.SVGElement) this.setState({ isElementSVG: true });
4321 }
4322 componentWillUnmount() {
4323 if (this.state.dragging) this.setState({ dragging: false });
4324 }
4325 findDOMNode() {
4326 var _this$props$nodeRef$c;
4327 var _this$props;
4328 return (_this$props$nodeRef$c = (_this$props = this.props) === null || _this$props === void 0 || (_this$props = _this$props.nodeRef) === null || _this$props === void 0 ? void 0 : _this$props.current) !== null && _this$props$nodeRef$c !== void 0 ? _this$props$nodeRef$c : _reactDom.default.findDOMNode(this);
4329 }
4330 render() {
4331 const _this$props2 = this.props, { axis, bounds, children, defaultPosition, defaultClassName, defaultClassNameDragging, defaultClassNameDragged, position, positionOffset, scale } = _this$props2, draggableCoreProps = _objectWithoutProperties(_this$props2, _excluded);
4332 let style = {};
4333 let svgTransform = null;
4334 const draggable = !Boolean(position) || this.state.dragging;
4335 const validPosition = position || defaultPosition;
4336 const transformOpts = {
4337 x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : validPosition.x,
4338 y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : validPosition.y
4339 };
4340 if (this.state.isElementSVG) svgTransform = (0, _domFns.createSVGTransform)(transformOpts, positionOffset);
4341 else style = (0, _domFns.createCSSTransform)(transformOpts, positionOffset);
4342 const className = (0, _clsx.clsx)(children.props.className || "", defaultClassName, {
4343 [defaultClassNameDragging]: this.state.dragging,
4344 [defaultClassNameDragged]: this.state.dragged
4345 });
4346 return /*#__PURE__*/ React$132.createElement(_DraggableCore.default, _extends({}, draggableCoreProps, {
4347 onStart: this.onDragStart,
4348 onDrag: this.onDrag,
4349 onStop: this.onDragStop
4350 }), /*#__PURE__*/ React$132.cloneElement(React$132.Children.only(children), {
4351 className,
4352 style: _objectSpread2(_objectSpread2({}, children.props.style), style),
4353 transform: svgTransform
4354 }));
4355 }
4356 };
4357 exports.default = Draggable;
4358 _defineProperty(Draggable, "displayName", "Draggable");
4359 _defineProperty(Draggable, "propTypes", _objectSpread2(_objectSpread2({}, _DraggableCore.default.propTypes), {}, {
4360 /**
4361 * `axis` determines which axis the draggable can move.
4362 *
4363 * Note that all callbacks will still return data as normal. This only
4364 * controls flushing to the DOM.
4365 *
4366 * 'both' allows movement horizontally and vertically.
4367 * 'x' limits movement to horizontal axis.
4368 * 'y' limits movement to vertical axis.
4369 * 'none' limits all movement.
4370 *
4371 * Defaults to 'both'.
4372 */
4373 axis: _propTypes.default.oneOf([
4374 "both",
4375 "x",
4376 "y",
4377 "none"
4378 ]),
4379 /**
4380 * `bounds` determines the range of movement available to the element.
4381 * Available values are:
4382 *
4383 * 'parent' restricts movement within the Draggable's parent node.
4384 *
4385 * Alternatively, pass an object with the following properties, all of which are optional:
4386 *
4387 * {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
4388 *
4389 * All values are in px.
4390 *
4391 * Example:
4392 *
4393 * ```jsx
4394 * let App = React.createClass({
4395 * render: function () {
4396 * return (
4397 * <Draggable bounds={{right: 300, bottom: 300}}>
4398 * <div>Content</div>
4399 * </Draggable>
4400 * );
4401 * }
4402 * });
4403 * ```
4404 */
4405 bounds: _propTypes.default.oneOfType([
4406 _propTypes.default.shape({
4407 left: _propTypes.default.number,
4408 right: _propTypes.default.number,
4409 top: _propTypes.default.number,
4410 bottom: _propTypes.default.number
4411 }),
4412 _propTypes.default.string,
4413 _propTypes.default.oneOf([false])
4414 ]),
4415 defaultClassName: _propTypes.default.string,
4416 defaultClassNameDragging: _propTypes.default.string,
4417 defaultClassNameDragged: _propTypes.default.string,
4418 /**
4419 * `defaultPosition` specifies the x and y that the dragged item should start at
4420 *
4421 * Example:
4422 *
4423 * ```jsx
4424 * let App = React.createClass({
4425 * render: function () {
4426 * return (
4427 * <Draggable defaultPosition={{x: 25, y: 25}}>
4428 * <div>I start with transformX: 25px and transformY: 25px;</div>
4429 * </Draggable>
4430 * );
4431 * }
4432 * });
4433 * ```
4434 */
4435 defaultPosition: _propTypes.default.shape({
4436 x: _propTypes.default.number,
4437 y: _propTypes.default.number
4438 }),
4439 positionOffset: _propTypes.default.shape({
4440 x: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
4441 y: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string])
4442 }),
4443 /**
4444 * `position`, if present, defines the current position of the element.
4445 *
4446 * This is similar to how form elements in React work - if no `position` is supplied, the component
4447 * is uncontrolled.
4448 *
4449 * Example:
4450 *
4451 * ```jsx
4452 * let App = React.createClass({
4453 * render: function () {
4454 * return (
4455 * <Draggable position={{x: 25, y: 25}}>
4456 * <div>I start with transformX: 25px and transformY: 25px;</div>
4457 * </Draggable>
4458 * );
4459 * }
4460 * });
4461 * ```
4462 */
4463 position: _propTypes.default.shape({
4464 x: _propTypes.default.number,
4465 y: _propTypes.default.number
4466 }),
4467 /**
4468 * These properties should be defined on the child, not here.
4469 */
4470 className: _shims.dontSetMe,
4471 style: _shims.dontSetMe,
4472 transform: _shims.dontSetMe
4473 }));
4474 _defineProperty(Draggable, "defaultProps", _objectSpread2(_objectSpread2({}, _DraggableCore.default.defaultProps), {}, {
4475 axis: "both",
4476 bounds: false,
4477 defaultClassName: "react-draggable",
4478 defaultClassNameDragging: "react-draggable-dragging",
4479 defaultClassNameDragged: "react-draggable-dragged",
4480 defaultPosition: {
4481 x: 0,
4482 y: 0
4483 },
4484 scale: 1
4485 }));
4486 }));
4487
4488 //#endregion
4489 //#region node_modules/react-draggable/build/cjs/cjs.js
4490 var require_cjs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4491 var { default: Draggable, DraggableCore } = require_Draggable();
4492 module.exports = Draggable;
4493 module.exports.default = Draggable;
4494 module.exports.DraggableCore = DraggableCore;
4495 }));
4496
4497 //#endregion
4498 //#region modules/ai/assets/js/editor/components/prompt-dialog.js
4499 init_extends();
4500 init_defineProperty$1();
4501 init_slicedToArray();
4502 var import_cjs = /* @__PURE__ */ __toESM(require_cjs());
4503 function ownKeys$25(e, r) {
4504 var t = Object.keys(e);
4505 if (Object.getOwnPropertySymbols) {
4506 var o = Object.getOwnPropertySymbols(e);
4507 r && (o = o.filter(function(r) {
4508 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4509 })), t.push.apply(t, o);
4510 }
4511 return t;
4512 }
4513 __name(ownKeys$25, "ownKeys");
4514 function _objectSpread$25(e) {
4515 for (var r = 1; r < arguments.length; r++) {
4516 var t = null != arguments[r] ? arguments[r] : {};
4517 r % 2 ? ownKeys$25(Object(t), !0).forEach(function(r) {
4518 _defineProperty$1(e, r, t[r]);
4519 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$25(Object(t)).forEach(function(r) {
4520 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4521 });
4522 }
4523 return e;
4524 }
4525 __name(_objectSpread$25, "_objectSpread");
4526 var DraggablePaper = function DraggablePaper(props) {
4527 var _useState2 = _slicedToArray((0, react.useState)({
4528 x: 0,
4529 y: 0
4530 }), 2);
4531 var position = _useState2[0];
4532 var setPosition = _useState2[1];
4533 var paperRef = (0, react.useRef)(null);
4534 var timeout = (0, react.useRef)(null);
4535 var onDrag = function onDrag(_e, _ref) {
4536 var x = _ref.x;
4537 var y = _ref.y;
4538 return setPosition({
4539 x,
4540 y
4541 });
4542 };
4543 var handlePositionBoundaries = function handlePositionBoundaries() {
4544 clearTimeout(timeout.current);
4545 timeout.current = setTimeout(function() {
4546 var _paperRef$current;
4547 var dialogTop = (_paperRef$current = paperRef.current) === null || _paperRef$current === void 0 ? void 0 : _paperRef$current.getBoundingClientRect().top;
4548 if (dialogTop < 0) setPosition(function(prev) {
4549 return _objectSpread$25(_objectSpread$25({}, prev), {}, { y: prev.y - dialogTop });
4550 });
4551 }, 50);
4552 };
4553 (0, react.useEffect)(function() {
4554 var resizeObserver = new ResizeObserver(handlePositionBoundaries);
4555 resizeObserver.observe(paperRef.current);
4556 return function() {
4557 resizeObserver.disconnect();
4558 };
4559 }, []);
4560 return /*#__PURE__*/ react.default.createElement(import_cjs.default, {
4561 position,
4562 onDrag,
4563 handle: ".MuiAppBar-root",
4564 cancel: "[class*=\"MuiDialogContent-root\"]",
4565 bounds: "parent"
4566 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, { ref: paperRef })));
4567 };
4568 var PromptDialog = function PromptDialog(props) {
4569 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
4570 scroll: "paper",
4571 open: true,
4572 fullWidth: true,
4573 hideBackdrop: true,
4574 PaperComponent: DraggablePaper,
4575 disableScrollLock: true,
4576 sx: { "& .MuiDialog-container": {
4577 alignItems: "flex-start",
4578 mt: "18vh"
4579 } },
4580 PaperProps: { sx: {
4581 m: 0,
4582 maxHeight: "76vh"
4583 } }
4584 }, props), props.children);
4585 };
4586 PromptDialog.propTypes = {
4587 onClose: import_prop_types$7.default.func.isRequired,
4588 children: import_prop_types$7.default.node,
4589 maxWidth: import_prop_types$7.default.oneOf([
4590 "xs",
4591 "sm",
4592 "md",
4593 "lg",
4594 "xl",
4595 false
4596 ])
4597 };
4598 PromptDialog.Header = DialogHeader$1;
4599 PromptDialog.Content = _elementor_ui.DialogContent;
4600
4601 //#endregion
4602 //#region modules/ai/assets/js/editor/components/upgrade-chip.js
4603 init_slicedToArray();
4604 var popoverId$1 = "e-ai-upgrade-popover";
4605 var StyledContent$3 = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
4606 var theme = _ref.theme;
4607 return {
4608 position: "relative",
4609 "[data-popper-placement=\"top\"] &": { marginBottom: theme.spacing(2.5) },
4610 "[data-popper-placement=\"bottom\"] &": { marginTop: theme.spacing(2.5) },
4611 padding: theme.spacing(3),
4612 boxShadow: theme.shadows[4],
4613 zIndex: "9999"
4614 };
4615 });
4616 var StyledArrow$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
4617 var theme = _ref2.theme;
4618 return {
4619 width: theme.spacing(5),
4620 height: theme.spacing(2.5),
4621 position: "absolute",
4622 overflow: "hidden",
4623 left: "50% !important",
4624 transform: "translateX(-50%) rotate(var(--rotate, 0deg)) !important",
4625 "[data-popper-placement=\"top\"] &": { top: "100%" },
4626 "[data-popper-placement=\"bottom\"] &": {
4627 "--rotate": "180deg",
4628 top: "calc(".concat(theme.spacing(2.5), " * -1)")
4629 },
4630 "&::after": {
4631 backgroundColor: theme.palette.background.paper,
4632 content: "\"\"",
4633 display: "block",
4634 position: "absolute",
4635 width: theme.spacing(2.5),
4636 height: theme.spacing(2.5),
4637 top: 0,
4638 left: "50%",
4639 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
4640 boxShadow: "1px 1px 5px 0px rgba(0, 0, 0, 0.2)",
4641 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
4642 }
4643 };
4644 });
4645 var upgradeBullets = [
4646 (0, _wordpress_i18n.__)("Get spot-on suggestions from AI Copilot and AI Context with appropriate designs, layouts, and content for your business.", "elementor"),
4647 (0, _wordpress_i18n.__)("Generate professional texts about any topic, in any tone.", "elementor"),
4648 (0, _wordpress_i18n.__)("Effortlessly create or enhance stunning images and bring your ideas to life.", "elementor"),
4649 (0, _wordpress_i18n.__)("Unleash infinite possibilities with the custom code generator.", "elementor"),
4650 (0, _wordpress_i18n.__)("Access 30-days of AI History with the AI Starter plan and 90-days with the Power plan.", "elementor")
4651 ];
4652 var Chip$2 = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
4653 return {
4654 "& .MuiChip-label": { lineHeight: 1.5 },
4655 "& .MuiSvgIcon-root.MuiChip-icon": { fontSize: "1.25rem" }
4656 };
4657 });
4658 var UpgradeChip = function UpgradeChip(_ref3) {
4659 var _ref3$hasSubscription = _ref3.hasSubscription;
4660 var hasSubscription = _ref3$hasSubscription === void 0 ? false : _ref3$hasSubscription;
4661 var _ref3$usagePercentage = _ref3.usagePercentage;
4662 var usagePercentage = _ref3$usagePercentage === void 0 ? 0 : _ref3$usagePercentage;
4663 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
4664 var isPopoverOpen = _useState2[0];
4665 var setIsPopoverOpen = _useState2[1];
4666 var anchorEl = (0, react.useRef)(null);
4667 var arrowEl = (0, react.useRef)(null);
4668 var showPopover = function showPopover() {
4669 return setIsPopoverOpen(true);
4670 };
4671 var hidePopover = function hidePopover() {
4672 return setIsPopoverOpen(false);
4673 };
4674 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
4675 if (hasSubscription) actionUrl = usagePercentage >= 100 ? "https://go.elementor.com/ai-popup-upgrade-limit-reached/" : "https://go.elementor.com/ai-popup-upgrade-limit-reached-80-percent/";
4676 var actionLabel = hasSubscription ? (0, _wordpress_i18n.__)("Upgrade Elementor AI", "elementor") : (0, _wordpress_i18n.__)("Get Elementor AI", "elementor");
4677 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
4678 component: "span",
4679 "aria-owns": isPopoverOpen ? popoverId$1 : void 0,
4680 "aria-haspopup": "true",
4681 onMouseEnter: showPopover,
4682 onMouseLeave: hidePopover,
4683 ref: anchorEl,
4684 display: "flex",
4685 alignItems: "center"
4686 }, /*#__PURE__*/ react.default.createElement(Chip$2, {
4687 color: "promotion",
4688 label: (0, _wordpress_i18n.__)("Upgrade", "elementor"),
4689 icon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4690 size: "small"
4691 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
4692 open: isPopoverOpen,
4693 anchorEl: anchorEl.current,
4694 sx: {
4695 zIndex: "170001",
4696 maxWidth: 300
4697 },
4698 modifiers: [{
4699 name: "arrow",
4700 enabled: true,
4701 options: { element: arrowEl.current }
4702 }]
4703 }, /*#__PURE__*/ react.default.createElement(StyledContent$3, null, /*#__PURE__*/ react.default.createElement(StyledArrow$1, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4704 variant: "h5",
4705 color: "text.primary"
4706 }, (0, _wordpress_i18n.__)("Unlimited access to Elementor AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.List, { sx: { mb: 1 } }, upgradeBullets.map(function(bullet, index) {
4707 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItem, {
4708 key: index,
4709 disableGutters: true,
4710 sx: { alignItems: "flex-start" }
4711 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, null, /*#__PURE__*/ react.default.createElement(_elementor_icons.CheckedCircleIcon, null)), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, { sx: { m: 0 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, bullet)));
4712 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
4713 variant: "contained",
4714 color: "promotion",
4715 size: "small",
4716 href: actionUrl,
4717 target: "_blank",
4718 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, null),
4719 sx: { "&:hover": { color: "promotion.contrastText" } }
4720 }, actionLabel))));
4721 };
4722 UpgradeChip.propTypes = {
4723 hasSubscription: import_prop_types$7.default.bool,
4724 usagePercentage: import_prop_types$7.default.number
4725 };
4726
4727 //#endregion
4728 //#region node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
4729 init_arrayLikeToArray();
4730 function _arrayWithoutHoles(r) {
4731 if (Array.isArray(r)) return _arrayLikeToArray$2(r);
4732 }
4733
4734 //#endregion
4735 //#region node_modules/@babel/runtime/helpers/esm/iterableToArray.js
4736 function _iterableToArray(r) {
4737 if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
4738 }
4739
4740 //#endregion
4741 //#region node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
4742 function _nonIterableSpread() {
4743 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4744 }
4745
4746 //#endregion
4747 //#region node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
4748 init_unsupportedIterableToArray();
4749 function _toConsumableArray(r) {
4750 return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread();
4751 }
4752
4753 //#endregion
4754 //#region modules/ai/assets/js/editor/pages/form-media/context/location-context.js
4755 init_slicedToArray();
4756 init_defineProperty$1();
4757 function ownKeys$24(e, r) {
4758 var t = Object.keys(e);
4759 if (Object.getOwnPropertySymbols) {
4760 var o = Object.getOwnPropertySymbols(e);
4761 r && (o = o.filter(function(r) {
4762 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4763 })), t.push.apply(t, o);
4764 }
4765 return t;
4766 }
4767 __name(ownKeys$24, "ownKeys");
4768 function _objectSpread$24(e) {
4769 for (var r = 1; r < arguments.length; r++) {
4770 var t = null != arguments[r] ? arguments[r] : {};
4771 r % 2 ? ownKeys$24(Object(t), !0).forEach(function(r) {
4772 _defineProperty$1(e, r, t[r]);
4773 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$24(Object(t)).forEach(function(r) {
4774 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4775 });
4776 }
4777 return e;
4778 }
4779 __name(_objectSpread$24, "_objectSpread");
4780 var RoutesContext = (0, react.createContext)(null);
4781 var NAVIGATE = "NAVIGATE";
4782 var BACK = "BACK";
4783 var initialValue$1 = {
4784 current: "",
4785 history: []
4786 };
4787 var reducer$2 = function reducer(state, _ref) {
4788 var type = _ref.type;
4789 var payload = _ref.payload;
4790 switch (type) {
4791 case NAVIGATE: return _objectSpread$24(_objectSpread$24({}, state), {}, {
4792 current: payload,
4793 history: [].concat(_toConsumableArray(state.history), [payload])
4794 });
4795 case BACK: return _objectSpread$24(_objectSpread$24({}, state), {}, {
4796 current: state.history[state.history.length - 2],
4797 history: state.history.slice(0, state.history.length - 1)
4798 });
4799 default: return state;
4800 }
4801 };
4802 var LocationProvider = function LocationProvider(_ref2) {
4803 var children = _ref2.children;
4804 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$2, initialValue$1), 2);
4805 var state = _useReducer2[0];
4806 var dispatch = _useReducer2[1];
4807 return /*#__PURE__*/ react.default.createElement(RoutesContext.Provider, { value: {
4808 state,
4809 dispatch
4810 } }, children);
4811 };
4812 LocationProvider.propTypes = { children: import_prop_types$7.default.node };
4813 var useLocation = function useLocation() {
4814 var current = (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}).current;
4815 var _useContext = (0, react.useContext)(RoutesContext);
4816 var state = _useContext.state;
4817 var dispatch = _useContext.dispatch;
4818 var navigate = function navigate(location) {
4819 dispatch({
4820 type: NAVIGATE,
4821 payload: location
4822 });
4823 };
4824 var back = function back() {
4825 dispatch({ type: BACK });
4826 };
4827 (0, react.useEffect)(function() {
4828 if (current) navigate(current);
4829 }, []);
4830 return {
4831 current: state.current,
4832 history: state.history,
4833 navigate,
4834 back
4835 };
4836 };
4837
4838 //#endregion
4839 //#region modules/ai/assets/js/editor/components/ui/panel.js
4840 init_extends();
4841 init_defineProperty$1();
4842 init_objectWithoutProperties$1();
4843 var _excluded$29 = ["sx"];
4844 function ownKeys$23(e, r) {
4845 var t = Object.keys(e);
4846 if (Object.getOwnPropertySymbols) {
4847 var o = Object.getOwnPropertySymbols(e);
4848 r && (o = o.filter(function(r) {
4849 return Object.getOwnPropertyDescriptor(e, r).enumerable;
4850 })), t.push.apply(t, o);
4851 }
4852 return t;
4853 }
4854 __name(ownKeys$23, "ownKeys");
4855 function _objectSpread$23(e) {
4856 for (var r = 1; r < arguments.length; r++) {
4857 var t = null != arguments[r] ? arguments[r] : {};
4858 r % 2 ? ownKeys$23(Object(t), !0).forEach(function(r) {
4859 _defineProperty$1(e, r, t[r]);
4860 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$23(Object(t)).forEach(function(r) {
4861 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
4862 });
4863 }
4864 return e;
4865 }
4866 __name(_objectSpread$23, "_objectSpread");
4867 var Panel = function Panel(_ref) {
4868 var _ref$sx = _ref.sx;
4869 var sx = _ref$sx === void 0 ? {} : _ref$sx;
4870 var props = _objectWithoutProperties$1(_ref, _excluded$29);
4871 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ sx: _objectSpread$23({
4872 p: 4,
4873 width: 360,
4874 flexShrink: 0,
4875 height: "100%",
4876 overflowY: "auto"
4877 }, sx) }, props), props.children), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, { orientation: "vertical" }));
4878 };
4879 Panel.propTypes = {
4880 children: import_prop_types$7.default.node,
4881 sx: import_prop_types$7.default.object
4882 };
4883
4884 //#endregion
4885 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-loader.js
4886 var GenerateLoader = function GenerateLoader() {
4887 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
4888 alignItems: "center",
4889 justifyContent: "center",
4890 gap: 2,
4891 width: "100%"
4892 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: {
4893 color: "text.primary",
4894 fontSize: "60px",
4895 mb: 1
4896 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
4897 variant: "h5",
4898 sx: { color: "text.primary" }
4899 }, (0, _wordpress_i18n.__)("Bringing your vision to life...", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body1" }, (0, _wordpress_i18n.__)("Hold tight, painting dreams might take a moment.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
4900 px: 1.5,
4901 py: 2.5,
4902 width: "100%",
4903 maxWidth: 600
4904 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, { color: "inherit" })));
4905 };
4906
4907 //#endregion
4908 //#region modules/ai/assets/js/editor/icons/chevron-left-icon.js
4909 init_extends();
4910 var ChevronLeftIcon = react.default.forwardRef(function(props, ref) {
4911 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
4912 fillRule: "evenodd",
4913 clipRule: "evenodd",
4914 d: "M15.5303 18.2803C15.8232 17.9874 15.8232 17.5126 15.5303 17.2197L10.0607 11.75L15.5303 6.28033C15.8232 5.98744 15.8232 5.51256 15.5303 5.21967C15.2374 4.92678 14.7626 4.92678 14.4697 5.21967L8.46967 11.2197C8.17678 11.5126 8.17678 11.9874 8.46967 12.2803L14.4697 18.2803C14.7626 18.5732 15.2374 18.5732 15.5303 18.2803Z"
4915 }));
4916 });
4917
4918 //#endregion
4919 //#region modules/ai/assets/js/editor/pages/form-media/components/back-button.js
4920 init_extends();
4921 init_objectWithoutProperties$1();
4922 var _excluded$28 = ["children"];
4923 var StyledChevronLeftIcon$1 = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
4924 var BackButton$1 = function BackButton(_ref) {
4925 var children = _ref.children;
4926 var props = _objectWithoutProperties$1(_ref, _excluded$28);
4927 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
4928 size: "small",
4929 variant: "text",
4930 color: "secondary",
4931 startIcon: /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon$1, null)
4932 }, props), children || (0, _wordpress_i18n.__)("Back", "elementor"));
4933 };
4934 BackButton$1.propTypes = { children: import_prop_types$7.default.node };
4935
4936 //#endregion
4937 //#region modules/ai/assets/js/editor/pages/form-media/context/global-settings-context.js
4938 var GlobalSettingsContext = (0, react.createContext)({});
4939 var GlobalSettingsProvider = function GlobalSettingsProvider(_ref) {
4940 var settings = _ref.settings;
4941 var children = _ref.children;
4942 return /*#__PURE__*/ react.default.createElement(GlobalSettingsContext.Provider, { value: settings }, children);
4943 };
4944 GlobalSettingsProvider.propTypes = {
4945 settings: import_prop_types$7.default.object,
4946 children: import_prop_types$7.default.node
4947 };
4948 var useGlobalSettings = function useGlobalSettings() {
4949 return (0, react.useContext)(GlobalSettingsContext);
4950 };
4951
4952 //#endregion
4953 //#region modules/ai/assets/js/editor/components/upgrade-banner.js
4954 init_extends();
4955 init_objectWithoutProperties$1();
4956 var _excluded$27 = ["onClose"];
4957 var UpgradeBanner = function UpgradeBanner(_ref) {
4958 var onClose = _ref.onClose;
4959 var props = _objectWithoutProperties$1(_ref, _excluded$27);
4960 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
4961 icon: false,
4962 action: /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertAction, { onClick: function onClick() {
4963 return window.open("https://go.elementor.com/ai-banner-free-upgrade/", "_blank");
4964 } }, (0, _wordpress_i18n.__)("Upgrade", "elementor")),
4965 variant: "filled",
4966 color: "promotion",
4967 onClose
4968 }, props), (0, _wordpress_i18n.__)("You’re using a limited license. Get maximum access to Elementor AI.", "elementor"));
4969 };
4970 UpgradeBanner.propTypes = {
4971 onClose: import_prop_types$7.default.func,
4972 sx: import_prop_types$7.default.object
4973 };
4974
4975 //#endregion
4976 //#region modules/ai/assets/js/editor/helpers/features-enum.js
4977 var FREE_TRIAL_FEATURES_NAMES = {
4978 TEXT: (0, _wordpress_i18n.__)("Text", "elementor"),
4979 IMAGES: (0, _wordpress_i18n.__)("Images", "elementor"),
4980 CODE: (0, _wordpress_i18n.__)("Code", "elementor"),
4981 CONTAINERS: (0, _wordpress_i18n.__)("Containers", "elementor"),
4982 ANIMATION: (0, _wordpress_i18n.__)("Animation", "elementor")
4983 };
4984
4985 //#endregion
4986 //#region modules/ai/assets/js/editor/components/usage-limit-alert.js
4987 init_objectWithoutProperties$1();
4988 init_extends();
4989 init_defineProperty$1();
4990 var _excluded$26 = [
4991 "onClose",
4992 "usagePercentage",
4993 "hasSubscription",
4994 "feature"
4995 ];
4996 var KEY_SUBSCRIPTION = "subscription";
4997 var KEY_NO_SUBSCRIPTION = "noSubscription";
4998 var getUsageTitle = function getUsageTitle(percentage) {
4999 return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("You’ve used %s of credits for this AI feature.", "elementor"), percentage);
5000 };
5001 var CREDITS_95_USAGE_TITLE = getUsageTitle("95%");
5002 var CREDITS_80_USAGE_TITLE = getUsageTitle("80%");
5003 var CREDITS_75_USAGE_TITLE = getUsageTitle("75%");
5004 var DESCRIPTION_SUBSCRIPTION = (0, _wordpress_i18n.__)("Get maximum access.", "elementor");
5005 var FEATURES = Object.keys(FREE_TRIAL_FEATURES_NAMES);
5006 var getDescriptionNoSubscription = function getDescriptionNoSubscription(excludedFeature) {
5007 var featuresList = FEATURES.filter(function(feature) {
5008 return feature !== excludedFeature;
5009 }).map(function(feature) {
5010 return FREE_TRIAL_FEATURES_NAMES[feature];
5011 }).join(", ");
5012 return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Upgrade now to keep using this feature. You still have credits for other AI features (%s, etc.)", "elementor"), featuresList);
5013 };
5014 var alertConfigs = [
5015 {
5016 threshold: 95,
5017 title: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, CREDITS_95_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_95_USAGE_TITLE),
5018 url: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-95-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-95-limit-reach/"),
5019 color: "error"
5020 },
5021 {
5022 threshold: 80,
5023 title: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, CREDITS_80_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_80_USAGE_TITLE),
5024 url: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-80-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-80-limit-reach/"),
5025 color: "warning"
5026 },
5027 {
5028 threshold: 75,
5029 title: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, CREDITS_75_USAGE_TITLE), KEY_NO_SUBSCRIPTION, CREDITS_75_USAGE_TITLE),
5030 url: _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, "https://go.elementor.com/ai-banner-paid-80-limit-reach/"), KEY_NO_SUBSCRIPTION, "https://go.elementor.com/ai-banner-free-80-limit-reach/"),
5031 color: "warning"
5032 }
5033 ];
5034 var UpgradeButton = function UpgradeButton(props) {
5035 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5036 color: "inherit",
5037 variant: "outlined",
5038 sx: { border: "2px solid" }
5039 }, props), (0, _wordpress_i18n.__)("Upgrade now", "elementor"));
5040 };
5041 var UsageLimitAlert = function UsageLimitAlert(_ref) {
5042 _ref.onClose;
5043 var usagePercentage = _ref.usagePercentage;
5044 var hasSubscription = _ref.hasSubscription;
5045 var feature = _ref.feature;
5046 var props = _objectWithoutProperties$1(_ref, _excluded$26);
5047 var config = alertConfigs.find(function(_ref2) {
5048 return usagePercentage >= _ref2.threshold;
5049 });
5050 if (!config) return null;
5051 var subscriptionType = hasSubscription ? KEY_SUBSCRIPTION : KEY_NO_SUBSCRIPTION;
5052 var description = _defineProperty$1(_defineProperty$1({}, KEY_SUBSCRIPTION, DESCRIPTION_SUBSCRIPTION), KEY_NO_SUBSCRIPTION, getDescriptionNoSubscription(feature));
5053 var title = config.title;
5054 var url = config.url;
5055 var color = config.color;
5056 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, _extends$1({
5057 severity: "warning",
5058 action: /*#__PURE__*/ react.default.createElement(UpgradeButton, { onClick: function handleUpgradeClick() {
5059 return window.open(url[subscriptionType], "_blank");
5060 } }),
5061 color
5062 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.AlertTitle, null, title[subscriptionType]), description[subscriptionType]);
5063 };
5064 UsageLimitAlert.propTypes = {
5065 onClose: import_prop_types$7.default.func,
5066 usagePercentage: import_prop_types$7.default.number,
5067 hasSubscription: import_prop_types$7.default.bool,
5068 feature: import_prop_types$7.default.string
5069 };
5070
5071 //#endregion
5072 //#region modules/ai/assets/js/editor/hooks/use-upgrade-message.js
5073 init_use_introduction();
5074 var USAGE_PERCENTAGE_THRESHOLD = 75;
5075 var useUpgradeMessage = function useUpgradeMessage(_ref) {
5076 var usagePercentage = _ref.usagePercentage;
5077 var hasSubscription = _ref.hasSubscription;
5078 var _useIntroduction = useIntroduction("e-ai-upgrade-message");
5079 var isBannerViewed = _useIntroduction.isViewed;
5080 var markBannerAsViewed = _useIntroduction.markAsViewed;
5081 var isFreeUser = !hasSubscription;
5082 return {
5083 showBadge: usagePercentage >= 75 || isFreeUser,
5084 showBanner: !isBannerViewed && isFreeUser && usagePercentage < 75,
5085 markBannerAsViewed
5086 };
5087 };
5088
5089 //#endregion
5090 //#region modules/ai/assets/js/editor/components/usage-messages.js
5091 var UsageMessages = function UsageMessages(_ref) {
5092 var hasSubscription = _ref.hasSubscription;
5093 var usagePercentage = _ref.usagePercentage;
5094 var sx = _ref.sx;
5095 var feature = _ref.feature;
5096 var _useUpgradeMessage = useUpgradeMessage({
5097 usagePercentage,
5098 hasSubscription
5099 });
5100 var showBanner = _useUpgradeMessage.showBanner;
5101 var markBannerAsViewed = _useUpgradeMessage.markBannerAsViewed;
5102 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, showBanner && /*#__PURE__*/ react.default.createElement(UpgradeBanner, {
5103 onClose: markBannerAsViewed,
5104 sx
5105 }), /*#__PURE__*/ react.default.createElement(UsageLimitAlert, {
5106 hasSubscription,
5107 usagePercentage,
5108 sx,
5109 feature
5110 }));
5111 };
5112 UsageMessages.propTypes = {
5113 hasSubscription: import_prop_types$7.default.bool,
5114 usagePercentage: import_prop_types$7.default.number,
5115 sx: import_prop_types$7.default.object,
5116 feature: import_prop_types$7.default.string
5117 };
5118
5119 //#endregion
5120 //#region modules/ai/assets/js/editor/pages/form-media/components/view.js
5121 init_extends();
5122 init_defineProperty$1();
5123 init_objectWithoutProperties$1();
5124 init_loader();
5125 init_prompt_error_message();
5126 var _excluded$25 = ["sx"];
5127 var _excluded2$4 = ["primary", "secondary"];
5128 var _excluded3$2 = ["primary", "secondary"];
5129 var _excluded4$1 = ["children"];
5130 var _excluded5$1 = [
5131 "isLoading",
5132 "isGenerating",
5133 "children"
5134 ];
5135 var _excluded6 = ["sx"];
5136 function ownKeys$22(e, r) {
5137 var t = Object.keys(e);
5138 if (Object.getOwnPropertySymbols) {
5139 var o = Object.getOwnPropertySymbols(e);
5140 r && (o = o.filter(function(r) {
5141 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5142 })), t.push.apply(t, o);
5143 }
5144 return t;
5145 }
5146 __name(ownKeys$22, "ownKeys");
5147 function _objectSpread$22(e) {
5148 for (var r = 1; r < arguments.length; r++) {
5149 var t = null != arguments[r] ? arguments[r] : {};
5150 r % 2 ? ownKeys$22(Object(t), !0).forEach(function(r) {
5151 _defineProperty$1(e, r, t[r]);
5152 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$22(Object(t)).forEach(function(r) {
5153 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5154 });
5155 }
5156 return e;
5157 }
5158 __name(_objectSpread$22, "_objectSpread");
5159 var ViewBackButton = function ViewBackButton(_ref) {
5160 var _ref$sx = _ref.sx;
5161 var sx = _ref$sx === void 0 ? {} : _ref$sx;
5162 var props = _objectWithoutProperties$1(_ref, _excluded$25);
5163 var back = useLocation().back;
5164 if (useGlobalSettings().hideBackButton) return null;
5165 return /*#__PURE__*/ react.default.createElement(BackButton$1, _extends$1({ onClick: function onClick(e) {
5166 e.preventDefault();
5167 back();
5168 } }, props, { sx: _objectSpread$22({
5169 mb: 1,
5170 alignSelf: "flex-start"
5171 }, sx) }));
5172 };
5173 ViewBackButton.propTypes = { sx: import_prop_types$7.default.object };
5174 var PanelHeading = function PanelHeading(_ref2) {
5175 var primary = _ref2.primary;
5176 var secondary = _ref2.secondary;
5177 var props = _objectWithoutProperties$1(_ref2, _excluded2$4);
5178 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5179 spacing: 1,
5180 sx: { mb: 3 }
5181 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h4" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5182 variant: "body1",
5183 color: "secondary"
5184 }, secondary));
5185 };
5186 PanelHeading.propTypes = {
5187 primary: import_prop_types$7.default.string.isRequired,
5188 secondary: import_prop_types$7.default.string
5189 };
5190 var ContentHeading = function ContentHeading(_ref3) {
5191 var primary = _ref3.primary;
5192 var secondary = _ref3.secondary;
5193 var props = _objectWithoutProperties$1(_ref3, _excluded3$2);
5194 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
5195 gap: 1.5,
5196 sx: { mb: 3 }
5197 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h6" }, primary), secondary && /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
5198 variant: "subtitle1",
5199 color: "secondary"
5200 }, secondary));
5201 };
5202 ContentHeading.propTypes = {
5203 primary: import_prop_types$7.default.string.isRequired,
5204 secondary: import_prop_types$7.default.string
5205 };
5206 var View = function View(_ref4) {
5207 var children = _ref4.children;
5208 var props = _objectWithoutProperties$1(_ref4, _excluded4$1);
5209 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5210 className: "e-ai-dialog-content",
5211 display: "flex",
5212 sx: {
5213 overflowY: "auto",
5214 position: "relative"
5215 },
5216 height: "100%"
5217 }, props), children);
5218 };
5219 var Content = function Content(_ref5) {
5220 var _ref5$isLoading = _ref5.isLoading;
5221 var isLoading = _ref5$isLoading === void 0 ? false : _ref5$isLoading;
5222 var _ref5$isGenerating = _ref5.isGenerating;
5223 var isGenerating = _ref5$isGenerating === void 0 ? false : _ref5$isGenerating;
5224 var children = _ref5.children;
5225 var props = _objectWithoutProperties$1(_ref5, _excluded5$1);
5226 if (isGenerating) return /*#__PURE__*/ react.default.createElement(GenerateLoader, null);
5227 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
5228 width: "100%",
5229 maxWidth: 600,
5230 margin: "0 auto",
5231 alignSelf: "center"
5232 } }, /*#__PURE__*/ react.default.createElement(Loader, { color: "inherit" }));
5233 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
5234 sx: {
5235 overflowY: "auto",
5236 p: 4
5237 },
5238 flexGrow: 1
5239 }, props), children);
5240 };
5241 Content.propTypes = {
5242 children: import_prop_types$7.default.node,
5243 isLoading: import_prop_types$7.default.bool,
5244 isGenerating: import_prop_types$7.default.bool
5245 };
5246 var ErrorMessage = function ErrorMessage(_ref6) {
5247 var _ref6$sx = _ref6.sx;
5248 var sx = _ref6$sx === void 0 ? {} : _ref6$sx;
5249 var props = _objectWithoutProperties$1(_ref6, _excluded6);
5250 return /*#__PURE__*/ react.default.createElement(PromptErrorMessage, _extends$1({ actionPosition: "bottom" }, props, { sx: _objectSpread$22({ mb: 2.5 }, sx) }));
5251 };
5252 ErrorMessage.propTypes = { sx: import_prop_types$7.default.object };
5253 var ViewPanel = function ViewPanel(props) {
5254 var _useGlobalSettings2 = useGlobalSettings();
5255 var hasSubscription = _useGlobalSettings2.hasSubscription;
5256 var usagePercentage = _useGlobalSettings2.usagePercentage;
5257 return /*#__PURE__*/ react.default.createElement(Panel, null, /*#__PURE__*/ react.default.createElement(UsageMessages, {
5258 hasSubscription,
5259 usagePercentage,
5260 sx: { mb: 4 },
5261 feature: FREE_TRIAL_FEATURES_NAMES.IMAGES
5262 }), props.children);
5263 };
5264 ViewPanel.propTypes = { children: import_prop_types$7.default.node };
5265 View.Panel = ViewPanel;
5266 View.Content = Content;
5267 View.BackButton = ViewBackButton;
5268 View.ErrorMessage = ErrorMessage;
5269 View.PanelHeading = PanelHeading;
5270 View.ContentHeading = ContentHeading;
5271 View.propTypes = { children: import_prop_types$7.default.node };
5272
5273 //#endregion
5274 //#region modules/ai/assets/js/editor/pages/form-media/constants/index.js
5275 var LOCATIONS = {
5276 RESIZE: "resize",
5277 GENERATE: "generate",
5278 VARIATIONS: "variations",
5279 IMAGE_TOOLS: "image-tools",
5280 IN_PAINTING: "in-painting",
5281 OUT_PAINTING: "out-painting",
5282 REMOVE_BACKGROUND: "remove-background",
5283 REPLACE_BACKGROUND: "replace-background",
5284 REMOVE_TEXT: "remove-text",
5285 CLEANUP: "cleanup",
5286 PRODUCT_IMAGE_UNIFICATION: "product-image-unification",
5287 ISOLATE_OBJECT: "isolate-objects"
5288 };
5289 var IMAGE_PROMPT_SETTINGS = {
5290 IMAGE_TYPE: "image_type",
5291 IMAGE_STYLE: "style_preset",
5292 IMAGE_STRENGTH: "image_strength",
5293 IMAGE_RATIO: "ratio",
5294 IMAGE_ZOOM: "zoom",
5295 IMAGE_UPSCALE: "upscale_to",
5296 IMAGE_BACKGROUND_COLOR: "background_color"
5297 };
5298 var FEATURE_IDENTIFIER = { ISOLATE_OBJECT: "isolate-object" };
5299 var IMAGE_PROMPT_CATEGORIES = {
5300 "": {
5301 label: (0, _wordpress_i18n.__)("None", "elementor"),
5302 subCategories: {}
5303 },
5304 photographic: {
5305 label: (0, _wordpress_i18n.__)("Photographic", "elementor"),
5306 subCategories: {
5307 "": (0, _wordpress_i18n.__)("None", "elementor"),
5308 landscape: (0, _wordpress_i18n.__)("Landscape", "elementor"),
5309 macro: (0, _wordpress_i18n.__)("Macro", "elementor"),
5310 portrait: (0, _wordpress_i18n.__)("Portrait", "elementor"),
5311 "long-exposure": (0, _wordpress_i18n.__)("Long Exposure", "elementor"),
5312 product: (0, _wordpress_i18n.__)("Product", "elementor"),
5313 photorealistic: (0, _wordpress_i18n.__)("Photorealistic", "elementor")
5314 }
5315 },
5316 vector: {
5317 label: (0, _wordpress_i18n.__)("Vector / Logo", "elementor"),
5318 subCategories: {
5319 "": (0, _wordpress_i18n.__)("None", "elementor"),
5320 "typographic-logo": (0, _wordpress_i18n.__)("Typographic Logo", "elementor"),
5321 "shape-logo": (0, _wordpress_i18n.__)("Shape Logo", "elementor"),
5322 "handwritten-logo": (0, _wordpress_i18n.__)("Handwritten Logo", "elementor"),
5323 "line-art-logo": (0, _wordpress_i18n.__)("Line Art Logo", "elementor"),
5324 "old-school-logo": (0, _wordpress_i18n.__)("Old School Logo", "elementor")
5325 }
5326 },
5327 background: {
5328 label: (0, _wordpress_i18n.__)("Background", "elementor"),
5329 subCategories: {
5330 "": (0, _wordpress_i18n.__)("None", "elementor"),
5331 floral: (0, _wordpress_i18n.__)("Floral", "elementor"),
5332 gradient: (0, _wordpress_i18n.__)("Gradient", "elementor"),
5333 mosaic: (0, _wordpress_i18n.__)("Mosaic", "elementor"),
5334 neon: (0, _wordpress_i18n.__)("Neon", "elementor"),
5335 bokeh: (0, _wordpress_i18n.__)("Bokeh", "elementor")
5336 }
5337 },
5338 handmade: {
5339 label: (0, _wordpress_i18n.__)("Handmade", "elementor"),
5340 subCategories: {
5341 "": (0, _wordpress_i18n.__)("None", "elementor"),
5342 doodle: (0, _wordpress_i18n.__)("Doodle", "elementor"),
5343 "line-art": (0, _wordpress_i18n.__)("Line Art", "elementor"),
5344 "oil-painting": (0, _wordpress_i18n.__)("Oil Painting", "elementor"),
5345 "pencil-drawing": (0, _wordpress_i18n.__)("Pencil Drawing", "elementor"),
5346 watercolor: (0, _wordpress_i18n.__)("Watercolor", "elementor")
5347 }
5348 },
5349 "digital-art": {
5350 label: (0, _wordpress_i18n.__)("Digital Art", "elementor"),
5351 subCategories: {
5352 "": (0, _wordpress_i18n.__)("None", "elementor"),
5353 amine: (0, _wordpress_i18n.__)("Anime", "elementor"),
5354 cartoon: (0, _wordpress_i18n.__)("Cartoon", "elementor"),
5355 cinematic: (0, _wordpress_i18n.__)("Cinematic", "elementor"),
5356 "comic-book": (0, _wordpress_i18n.__)("Comic Book", "elementor"),
5357 "fantasy-art": (0, _wordpress_i18n.__)("Fantasy Art", "elementor"),
5358 isometric: (0, _wordpress_i18n.__)("Isometric", "elementor"),
5359 vector: (0, _wordpress_i18n.__)("Vector", "elementor"),
5360 "pixel-art": (0, _wordpress_i18n.__)("Pixel Art", "elementor"),
5361 "low-poly": (0, _wordpress_i18n.__)("Low Poly", "elementor"),
5362 "neon-punk": (0, _wordpress_i18n.__)("Neon Punk", "elementor")
5363 }
5364 },
5365 "3d": {
5366 label: (0, _wordpress_i18n.__)("3D", "elementor"),
5367 subCategories: {
5368 "": (0, _wordpress_i18n.__)("None", "elementor"),
5369 clay: (0, _wordpress_i18n.__)("Clay", "elementor"),
5370 digital: (0, _wordpress_i18n.__)("Digital", "elementor"),
5371 origami: (0, _wordpress_i18n.__)("Origami", "elementor"),
5372 stone: (0, _wordpress_i18n.__)("Stone", "elementor"),
5373 wood: (0, _wordpress_i18n.__)("Wood", "elementor")
5374 }
5375 }
5376 };
5377 var IMAGE_ASPECT_RATIO = {
5378 "1:1": {
5379 width: 512,
5380 height: 512,
5381 label: (0, _wordpress_i18n.__)("Square", "elementor") + " (1:1)"
5382 },
5383 "3:2": {
5384 width: 640,
5385 height: 448,
5386 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (3:2)"
5387 },
5388 "4:3": {
5389 width: 640,
5390 height: 448,
5391 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (4:3)"
5392 },
5393 "16:9": {
5394 width: 704,
5395 height: 384,
5396 label: (0, _wordpress_i18n.__)("Landscape", "elementor") + " (16:9)"
5397 },
5398 "2:3": {
5399 width: 448,
5400 height: 640,
5401 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (2:3)"
5402 },
5403 "3:4": {
5404 width: 448,
5405 height: 640,
5406 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (3:4)"
5407 },
5408 "9:16": {
5409 width: 384,
5410 height: 704,
5411 label: (0, _wordpress_i18n.__)("Portrait", "elementor") + " (9:16)"
5412 }
5413 };
5414 var IMAGE_PLACEHOLDERS_HOSTS = { WIREFRAME: "gene-\\d+\\.live\\.strattic\\.io" };
5415
5416 //#endregion
5417 //#region modules/ai/assets/js/editor/components/ui/overlay.js
5418 var Overlay = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
5419 var theme = _ref.theme;
5420 return {
5421 width: "100%",
5422 height: "100%",
5423 position: "absolute",
5424 backgroundColor: "rgba(0,0,0,0.5)",
5425 transition: "opacity ".concat(theme.transitions.duration.short, "ms ").concat(theme.transitions.easing.easeInOut),
5426 opacity: 0,
5427 "&:hover": { opacity: 1 }
5428 };
5429 });
5430
5431 //#endregion
5432 //#region modules/ai/assets/js/editor/components/ui/overlay-bar.js
5433 var OverlayBar = (0, _elementor_ui.styled)(_elementor_ui.Stack)(function(_ref) {
5434 var theme = _ref.theme;
5435 var position = _ref.position;
5436 var style = {
5437 width: "100%",
5438 position: "absolute",
5439 left: 0,
5440 padding: theme.spacing(2.5)
5441 };
5442 if ("top" === position) style.top = 0;
5443 else if ("bottom" === position) style.bottom = 0;
5444 return style;
5445 });
5446
5447 //#endregion
5448 //#region modules/ai/assets/js/editor/components/ui/overlay-bar-text.js
5449 init_extends();
5450 init_objectWithoutProperties$1();
5451 var _excluded$24 = ["children"];
5452 var OverlayBarText = function OverlayBarText(_ref) {
5453 var children = _ref.children;
5454 var props = _objectWithoutProperties$1(_ref, _excluded$24);
5455 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({
5456 variant: "caption",
5457 color: "common.white"
5458 }, props), children);
5459 };
5460 OverlayBarText.propTypes = { children: import_prop_types$7.default.node };
5461
5462 //#endregion
5463 //#region modules/ai/assets/js/editor/pages/form-media/components/gallery.js
5464 init_defineProperty$1();
5465 init_slicedToArray();
5466 init_extends();
5467 init_objectWithoutProperties$1();
5468 var _excluded$23 = ["children"];
5469 var _excluded2$3 = [
5470 "alt",
5471 "src",
5472 "text",
5473 "children",
5474 "aspectRatio",
5475 "variant",
5476 "OverlayBarProps",
5477 "numImagesInRow",
5478 "overlay",
5479 "onSelectChange",
5480 "checkboxColor",
5481 "isLoading",
5482 "initialChecked"
5483 ];
5484 function ownKeys$21(e, r) {
5485 var t = Object.keys(e);
5486 if (Object.getOwnPropertySymbols) {
5487 var o = Object.getOwnPropertySymbols(e);
5488 r && (o = o.filter(function(r) {
5489 return Object.getOwnPropertyDescriptor(e, r).enumerable;
5490 })), t.push.apply(t, o);
5491 }
5492 return t;
5493 }
5494 __name(ownKeys$21, "ownKeys");
5495 function _objectSpread$21(e) {
5496 for (var r = 1; r < arguments.length; r++) {
5497 var t = null != arguments[r] ? arguments[r] : {};
5498 r % 2 ? ownKeys$21(Object(t), !0).forEach(function(r) {
5499 _defineProperty$1(e, r, t[r]);
5500 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$21(Object(t)).forEach(function(r) {
5501 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
5502 });
5503 }
5504 return e;
5505 }
5506 __name(_objectSpread$21, "_objectSpread");
5507 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
5508 var Gallery = function Gallery(_ref) {
5509 var children = _ref.children;
5510 var props = _objectWithoutProperties$1(_ref, _excluded$23);
5511 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageList, _extends$1({
5512 width: "100%",
5513 cols: 2,
5514 gap: 24
5515 }, props), children);
5516 };
5517 Gallery.propTypes = { children: import_prop_types$7.default.node };
5518 var GalleryImage = function GalleryImage(_ref2) {
5519 var _elementorCommon$conf;
5520 var _elementorCommon;
5521 var alt = _ref2.alt;
5522 var src = _ref2.src;
5523 var text = _ref2.text;
5524 var children = _ref2.children;
5525 var _ref2$aspectRatio = _ref2.aspectRatio;
5526 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
5527 var _ref2$variant = _ref2.variant;
5528 var variant = _ref2$variant === void 0 ? "contained" : _ref2$variant;
5529 var _ref2$OverlayBarProps = _ref2.OverlayBarProps;
5530 var OverlayBarProps = _ref2$OverlayBarProps === void 0 ? {} : _ref2$OverlayBarProps;
5531 var _ref2$numImagesInRow = _ref2.numImagesInRow;
5532 var numImagesInRow = _ref2$numImagesInRow === void 0 ? 2 : _ref2$numImagesInRow;
5533 var _ref2$overlay = _ref2.overlay;
5534 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
5535 var _ref2$onSelectChange = _ref2.onSelectChange;
5536 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
5537 var _ref2$checkboxColor = _ref2.checkboxColor;
5538 var checkboxColor = _ref2$checkboxColor === void 0 ? "rgba(0, 0, 0, 0.54)" : _ref2$checkboxColor;
5539 var _ref2$isLoading = _ref2.isLoading;
5540 var isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading;
5541 var _ref2$initialChecked = _ref2.initialChecked;
5542 var initialChecked = _ref2$initialChecked === void 0 ? false : _ref2$initialChecked;
5543 var props = _objectWithoutProperties$1(_ref2, _excluded2$3);
5544 var _useState2 = _slicedToArray((0, react.useState)(initialChecked), 2);
5545 var isChecked = _useState2[0];
5546 var setIsChecked = _useState2[1];
5547 var style = {};
5548 var isRTL = (_elementorCommon$conf = (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 || (_elementorCommon = _elementorCommon.config) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.isRTL) !== null && _elementorCommon$conf !== void 0 ? _elementorCommon$conf : true;
5549 (0, react.useEffect)(function() {
5550 setIsChecked(initialChecked);
5551 }, [initialChecked]);
5552 if ("thumbnail" === variant) {
5553 style.width = "100%";
5554 style.maxHeight = "238px";
5555 style.minWidth = "230px";
5556 } else {
5557 style.width = "auto";
5558 style.height = "auto";
5559 style.maxWidth = "100%";
5560 style.maxHeight = "1:1" === aspectRatio ? "initial" : "100%";
5561 style.objectFit = "contain";
5562 style.aspectRatio = aspectRatio.replace(":", " / ");
5563 }
5564 return /*#__PURE__*/ react.default.createElement(_elementor_ui.ImageListItem, props, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5565 display: "flex",
5566 justifyContent: "center",
5567 alignItems: "center",
5568 sx: {
5569 bgcolor: "action.selected",
5570 height: "contained" === variant && numImagesInRow <= 2 ? 336 : "auto",
5571 position: "relative",
5572 overflow: "hidden"
5573 }
5574 }, /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
5575 sx: _objectSpread$21(_objectSpread$21({}, style), {}, {
5576 width: "100%",
5577 height: "100% "
5578 }),
5579 animation: "wave",
5580 variant: "rounded"
5581 }, /*#__PURE__*/ react.default.createElement("img", {
5582 alt,
5583 src,
5584 style: _objectSpread$21(_objectSpread$21({}, style), {}, { visibility: "hidden" })
5585 })) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, onSelectChange && /*#__PURE__*/ react.default.createElement(_elementor_ui.Checkbox, {
5586 onClick: function onClick() {
5587 var newVal = !isChecked;
5588 setIsChecked(newVal);
5589 onSelectChange(newVal);
5590 },
5591 checked: isChecked,
5592 sx: {
5593 position: "absolute",
5594 top: 0,
5595 left: isRTL ? void 0 : 0,
5596 right: isRTL ? 0 : void 0,
5597 "& .MuiSvgIcon-root": { color: checkboxColor }
5598 }
5599 }), /*#__PURE__*/ react.default.createElement("img", {
5600 alt,
5601 src,
5602 style
5603 })))), overlay && children && /*#__PURE__*/ react.default.createElement(Overlay, null, /*#__PURE__*/ react.default.createElement(OverlayBar, _extends$1({
5604 gap: 1,
5605 position: "bottom"
5606 }, OverlayBarProps), text && /*#__PURE__*/ react.default.createElement(OverlayBarText, null, text), children)));
5607 };
5608 GalleryImage.propTypes = {
5609 alt: import_prop_types$7.default.string,
5610 src: import_prop_types$7.default.string,
5611 text: import_prop_types$7.default.string,
5612 children: import_prop_types$7.default.node,
5613 BoxProps: import_prop_types$7.default.object,
5614 OverlayBarProps: import_prop_types$7.default.object,
5615 aspectRatio: import_prop_types$7.default.oneOf(aspectRatios),
5616 variant: import_prop_types$7.default.oneOf(["contained", "thumbnail"]),
5617 numImagesInRow: import_prop_types$7.default.number,
5618 overlay: import_prop_types$7.default.bool,
5619 onSelectChange: import_prop_types$7.default.func,
5620 checkboxColor: import_prop_types$7.default.string,
5621 initialChecked: import_prop_types$7.default.bool,
5622 isLoading: import_prop_types$7.default.bool
5623 };
5624 Gallery.Image = GalleryImage;
5625
5626 //#endregion
5627 //#region modules/ai/assets/js/editor/pages/form-media/components/image-form.js
5628 init_extends();
5629 init_objectWithoutProperties$1();
5630 var _excluded$22 = ["children"];
5631 var ImageForm = function ImageForm(_ref) {
5632 var children = _ref.children;
5633 var props = _objectWithoutProperties$1(_ref, _excluded$22);
5634 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ component: "form" }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: 2.5 }, children));
5635 };
5636 ImageForm.propTypes = { children: import_prop_types$7.default.node };
5637
5638 //#endregion
5639 //#region modules/ai/assets/js/editor/icons/wand-icon.js
5640 init_extends();
5641 var WandIcon = react.default.forwardRef(function(props, ref) {
5642 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5643 fillRule: "evenodd",
5644 clipRule: "evenodd",
5645 d: "M9 2.25C9.41421 2.25 9.75 2.58579 9.75 3C9.75 3.33152 9.8817 3.64946 10.1161 3.88388C10.3505 4.1183 10.6685 4.25 11 4.25C11.4142 4.25 11.75 4.58579 11.75 5C11.75 5.41421 11.4142 5.75 11 5.75C10.6685 5.75 10.3505 5.8817 10.1161 6.11612C9.8817 6.35054 9.75 6.66848 9.75 7C9.75 7.41421 9.41421 7.75 9 7.75C8.58579 7.75 8.25 7.41421 8.25 7C8.25 6.66848 8.1183 6.35054 7.88388 6.11612C7.64946 5.8817 7.33152 5.75 7 5.75C6.58579 5.75 6.25 5.41421 6.25 5C6.25 4.58579 6.58579 4.25 7 4.25C7.33152 4.25 7.64946 4.1183 7.88388 3.88388C8.1183 3.64946 8.25 3.33152 8.25 3C8.25 2.58579 8.58579 2.25 9 2.25ZM9 4.88746C8.98182 4.90673 8.96333 4.92576 8.94454 4.94454C8.92576 4.96333 8.90673 4.98182 8.88746 5C8.90673 5.01818 8.92576 5.03667 8.94454 5.05546C8.96333 5.07424 8.98182 5.09327 9 5.11254C9.01818 5.09327 9.03667 5.07424 9.05546 5.05546C9.07424 5.03667 9.09327 5.01818 9.11254 5C9.09327 4.98182 9.07424 4.96333 9.05546 4.94454C9.03667 4.92576 9.01818 4.90673 9 4.88746Z"
5646 }), /*#__PURE__*/ react.default.createElement("path", {
5647 fillRule: "evenodd",
5648 clipRule: "evenodd",
5649 d: "M18.5303 2.46967C18.2374 2.17678 17.7626 2.17678 17.4697 2.46967L2.46967 17.4697C2.17678 17.7626 2.17678 18.2374 2.46967 18.5303L5.46967 21.5303C5.76256 21.8232 6.23744 21.8232 6.53033 21.5303L21.5303 6.53033C21.8232 6.23744 21.8232 5.76256 21.5303 5.46967L18.5303 2.46967ZM18 7.93934L19.9393 6L18 4.06066L16.0607 6L18 7.93934ZM15 7.06066L16.9393 9L6 19.9393L4.06066 18L15 7.06066Z"
5650 }), /*#__PURE__*/ react.default.createElement("path", {
5651 fillRule: "evenodd",
5652 clipRule: "evenodd",
5653 d: "M19.75 13C19.75 12.5858 19.4142 12.25 19 12.25C18.5858 12.25 18.25 12.5858 18.25 13C18.25 13.3315 18.1183 13.6495 17.8839 13.8839C17.6495 14.1183 17.3315 14.25 17 14.25C16.5858 14.25 16.25 14.5858 16.25 15C16.25 15.4142 16.5858 15.75 17 15.75C17.3315 15.75 17.6495 15.8817 17.8839 16.1161C18.1183 16.3505 18.25 16.6685 18.25 17C18.25 17.4142 18.5858 17.75 19 17.75C19.4142 17.75 19.75 17.4142 19.75 17C19.75 16.6685 19.8817 16.3505 20.1161 16.1161C20.3505 15.8817 20.6685 15.75 21 15.75C21.4142 15.75 21.75 15.4142 21.75 15C21.75 14.5858 21.4142 14.25 21 14.25C20.6685 14.25 20.3505 14.1183 20.1161 13.8839C19.8817 13.6495 19.75 13.3315 19.75 13ZM18.9445 14.9445C18.9633 14.9258 18.9818 14.9067 19 14.8875C19.0182 14.9067 19.0367 14.9258 19.0555 14.9445C19.0742 14.9633 19.0933 14.9818 19.1125 15C19.0933 15.0182 19.0742 15.0367 19.0555 15.0555C19.0367 15.0742 19.0182 15.0933 19 15.1125C18.9818 15.0933 18.9633 15.0742 18.9445 15.0555C18.9258 15.0367 18.9067 15.0182 18.8875 15C18.9067 14.9818 18.9258 14.9633 18.9445 14.9445Z"
5654 }));
5655 });
5656
5657 //#endregion
5658 //#region modules/ai/assets/js/editor/pages/form-media/components/enhance-button.js
5659 init_extends();
5660 init_objectWithoutProperties$1();
5661 var _excluded$21 = ["isLoading"];
5662 var StyledWandIcon = (0, _elementor_ui.withDirection)(WandIcon);
5663 var EnhanceButton = function EnhanceButton(_ref) {
5664 var isLoading = _ref.isLoading;
5665 var props = _objectWithoutProperties$1(_ref, _excluded$21);
5666 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Enhance prompt", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
5667 component: "span",
5668 sx: { cursor: props.disabled ? "default" : "pointer" }
5669 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
5670 size: "small",
5671 color: "secondary"
5672 }, props), isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.CircularProgress, {
5673 color: "secondary",
5674 size: 20
5675 }) : /*#__PURE__*/ react.default.createElement(StyledWandIcon, { fontSize: "small" }))));
5676 };
5677 EnhanceButton.propTypes = {
5678 disabled: import_prop_types$7.default.bool,
5679 isLoading: import_prop_types$7.default.bool
5680 };
5681
5682 //#endregion
5683 //#region modules/ai/assets/js/editor/pages/form-layout/context/config.js
5684 var MODE_LAYOUT = "layout";
5685 var MODE_VARIATION = "variation";
5686 var LAYOUT_APP_MODES = [MODE_LAYOUT, MODE_VARIATION];
5687 var ConfigContext = react.default.createContext({});
5688 var useConfig = function useConfig() {
5689 return react.default.useContext(ConfigContext);
5690 };
5691 var ConfigProvider = function ConfigProvider(props) {
5692 return /*#__PURE__*/ react.default.createElement(ConfigContext.Provider, { value: {
5693 mode: props.mode,
5694 attachmentsTypes: props.attachmentsTypes,
5695 onClose: props.onClose,
5696 onConnect: props.onConnect,
5697 onData: props.onData,
5698 onInsert: props.onInsert,
5699 onSelect: props.onSelect,
5700 onGenerate: props.onGenerate,
5701 currentContext: props.currentContext,
5702 hasPro: props.hasPro
5703 } }, props.children);
5704 };
5705 ConfigProvider.propTypes = {
5706 mode: import_prop_types$7.default.oneOf(LAYOUT_APP_MODES).isRequired,
5707 children: import_prop_types$7.default.node.isRequired,
5708 attachmentsTypes: import_prop_types$7.default.object.isRequired,
5709 onClose: import_prop_types$7.default.func.isRequired,
5710 onConnect: import_prop_types$7.default.func.isRequired,
5711 onData: import_prop_types$7.default.func.isRequired,
5712 onInsert: import_prop_types$7.default.func.isRequired,
5713 onSelect: import_prop_types$7.default.func.isRequired,
5714 onGenerate: import_prop_types$7.default.func.isRequired,
5715 currentContext: import_prop_types$7.default.object,
5716 hasPro: import_prop_types$7.default.bool
5717 };
5718
5719 //#endregion
5720 //#region modules/ai/assets/js/editor/hooks/use-prompt-enhancer.js
5721 init_api();
5722 init_use_prompt();
5723 var enhancePromptMap = /* @__PURE__ */ new Map([["media", getImagePromptEnhanced], ["layout", getLayoutPromptEnhanced]]);
5724 var getResult = function getResult(prompt, type, enhanceType) {
5725 if (!enhancePromptMap.has(type)) throw new Error("Invalid prompt type: ".concat(type));
5726 return enhancePromptMap.get(type)(prompt, enhanceType);
5727 };
5728 /**
5729 * Hook to enhance a prompt.
5730 *
5731 * @param {string} prompt
5732 * @param {'media' | 'layout'} type
5733 * @return {{enhancedPrompt: string | undefined, isEnhancing: boolean, enhance: (function(...[*]): Promise)}}
5734 */
5735 var usePromptEnhancer = function usePromptEnhancer(prompt, type) {
5736 var mode = useConfig().mode;
5737 var _usePrompt = usePrompt(function() {
5738 return getResult(prompt, type, mode);
5739 }, prompt);
5740 var enhancedData = _usePrompt.data;
5741 var isEnhancing = _usePrompt.isLoading;
5742 return {
5743 enhance: _usePrompt.send,
5744 isEnhancing,
5745 enhancedPrompt: enhancedData === null || enhancedData === void 0 ? void 0 : enhancedData.result
5746 };
5747 };
5748
5749 //#endregion
5750 //#region modules/ai/assets/js/editor/pages/form-media/components/prompt-field.js
5751 init_extends();
5752 init_objectWithoutProperties$1();
5753 init_textarea();
5754 var _excluded$20 = ["disabled", "onChange"];
5755 var PromptField = function PromptField(_ref) {
5756 var disabled = _ref.disabled;
5757 var _onChange = _ref.onChange;
5758 var props = _objectWithoutProperties$1(_ref, _excluded$20);
5759 var _usePromptEnhancer = usePromptEnhancer(props.value, "media");
5760 var enhance = _usePromptEnhancer.enhance;
5761 var isEnhancing = _usePromptEnhancer.isEnhancing;
5762 return /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
5763 minRows: 3,
5764 maxRows: 6,
5765 InputProps: { endAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, {
5766 position: "end",
5767 sx: {
5768 position: "absolute",
5769 bottom: "24px",
5770 right: "8px"
5771 }
5772 }, /*#__PURE__*/ react.default.createElement(EnhanceButton, {
5773 isLoading: isEnhancing,
5774 disabled: disabled || isEnhancing || !props.value,
5775 onClick: function onClick() {
5776 enhance(prompt).then(function(_ref2) {
5777 var result = _ref2.result;
5778 return _onChange(result);
5779 });
5780 }
5781 })) },
5782 sx: { "& .MuiInputBase-input.MuiOutlinedInput-input.MuiInputBase-inputMultiline": {
5783 pb: 5,
5784 width: "89%"
5785 } },
5786 onKeyDown: function onKeyDown(event) {
5787 if ("Tab" === event.key) {
5788 event.preventDefault();
5789 _onChange(props.placeholder);
5790 }
5791 }
5792 }, props, {
5793 onChange: function onChange(event) {
5794 return _onChange(event.target.value);
5795 },
5796 disabled: disabled || isEnhancing
5797 }));
5798 };
5799 PromptField.propTypes = {
5800 value: import_prop_types$7.default.string,
5801 disabled: import_prop_types$7.default.bool,
5802 placeholder: import_prop_types$7.default.string,
5803 onChange: import_prop_types$7.default.func.isRequired
5804 };
5805
5806 //#endregion
5807 //#region modules/ai/assets/js/editor/pages/form-media/components/image-type-select.js
5808 init_extends();
5809 init_slicedToArray();
5810 init_use_introduction();
5811 var StyledNewChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
5812 return { "& .MuiChip-label": {
5813 fontSize: "0.75rem",
5814 fontWeight: "normal"
5815 } };
5816 });
5817 var showLabel = function showLabel(label, key, isViewed, markAsViewed) {
5818 if (isViewed) return {
5819 label,
5820 value: key
5821 };
5822 return {
5823 label: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
5824 direction: "row",
5825 width: "100%",
5826 justifyContent: "space-between",
5827 alignItems: "center"
5828 }, label, /*#__PURE__*/ react.default.createElement(StyledNewChip, {
5829 label: "New",
5830 color: "info",
5831 variant: "standard",
5832 size: "tiny"
5833 })),
5834 value: key,
5835 onClick: function onClick() {
5836 return markAsViewed();
5837 }
5838 };
5839 };
5840 var changeImageType = function changeImageType(e, props, markVectorAsViewed) {
5841 if ("vector" === e.target.value) markVectorAsViewed();
5842 if (props.onChange) props.onChange(e);
5843 };
5844 var ImageTypeSelect = function ImageTypeSelect(props) {
5845 var _useIntroduction = useIntroduction("e-ai-image-vector-option");
5846 var isVectorViewed = _useIntroduction.isViewed;
5847 var markVectorAsViewed = _useIntroduction.markAsViewed;
5848 var imageTypesWithNewChip = Object.entries(IMAGE_PROMPT_CATEGORIES).map(function(_ref) {
5849 var _ref2 = _slicedToArray(_ref, 2);
5850 var key = _ref2[0];
5851 var label = _ref2[1].label;
5852 if ("vector" === key) return showLabel(label, key, isVectorViewed, markVectorAsViewed);
5853 return {
5854 label,
5855 value: key
5856 };
5857 });
5858 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5859 options: imageTypesWithNewChip,
5860 wrapperStyle: { width: "100%" },
5861 label: (0, _wordpress_i18n.__)("Image type", "elementor")
5862 }, props, { onChange: function onChange(e) {
5863 changeImageType(e, props, markVectorAsViewed);
5864 } }));
5865 };
5866 ImageTypeSelect.propTypes = {
5867 onChange: import_prop_types$7.default.func,
5868 value: import_prop_types$7.default.string,
5869 disabled: import_prop_types$7.default.bool
5870 };
5871
5872 //#endregion
5873 //#region modules/ai/assets/js/editor/pages/form-media/components/image-style-select.js
5874 init_extends();
5875 init_slicedToArray();
5876 init_objectWithoutProperties$1();
5877 var _excluded$19 = ["type"];
5878 var ImageStyleSelect = function ImageStyleSelect(_ref) {
5879 var _IMAGE_PROMPT_CATEGOR;
5880 var _ref$type = _ref.type;
5881 var type = _ref$type === void 0 ? "" : _ref$type;
5882 var props = _objectWithoutProperties$1(_ref, _excluded$19);
5883 var imageStyles = Object.entries(((_IMAGE_PROMPT_CATEGOR = IMAGE_PROMPT_CATEGORIES[type]) === null || _IMAGE_PROMPT_CATEGOR === void 0 ? void 0 : _IMAGE_PROMPT_CATEGOR.subCategories) || {}).map(function(_ref2) {
5884 var _ref3 = _slicedToArray(_ref2, 2);
5885 var value = _ref3[0];
5886 return {
5887 label: _ref3[1],
5888 value
5889 };
5890 });
5891 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5892 options: imageStyles,
5893 wrapperStyle: { width: "100%" },
5894 label: (0, _wordpress_i18n.__)("Style", "elementor")
5895 }, props));
5896 };
5897 ImageStyleSelect.propTypes = { type: import_prop_types$7.default.string.isRequired };
5898
5899 //#endregion
5900 //#region modules/ai/assets/js/editor/pages/form-media/components/image-ratio-select.js
5901 init_extends();
5902 init_slicedToArray();
5903 var imageRatios = Object.entries(IMAGE_ASPECT_RATIO).map(function(_ref) {
5904 var _ref2 = _slicedToArray(_ref, 2);
5905 var value = _ref2[0];
5906 return {
5907 label: _ref2[1].label,
5908 value
5909 };
5910 });
5911 var ImageRatioSelect = function ImageRatioSelect(props) {
5912 return /*#__PURE__*/ react.default.createElement(PromptActionSelection, _extends$1({
5913 options: imageRatios,
5914 wrapperStyle: { width: "100%" },
5915 label: (0, _wordpress_i18n.__)("Aspect ratio", "elementor")
5916 }, props));
5917 };
5918
5919 //#endregion
5920 //#region modules/ai/assets/js/editor/icons/refresh-icon.js
5921 init_extends();
5922 var RefreshIcon = react.default.forwardRef(function(props, ref) {
5923 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
5924 fillRule: "evenodd",
5925 clipRule: "evenodd",
5926 d: "M7.55012 4.45178C9.23098 3.48072 11.1845 3.08925 13.1097 3.33767C15.035 3.58609 16.8251 4.46061 18.2045 5.82653C19.5838 7.19245 20.4757 8.97399 20.743 10.8967C20.8 11.307 20.5136 11.6858 20.1033 11.7428C19.6931 11.7998 19.3142 11.5135 19.2572 11.1032C19.0353 9.50635 18.2945 8.02677 17.149 6.89236C16.0035 5.75795 14.5167 5.03165 12.9178 4.82534C11.3189 4.61902 9.69644 4.94414 8.30047 5.75061C7.24361 6.36117 6.36093 7.22198 5.72541 8.24995H8.00009C8.41431 8.24995 8.75009 8.58574 8.75009 8.99995C8.75009 9.41417 8.41431 9.74995 8.00009 9.74995H4.51686C4.5055 9.75021 4.49412 9.75021 4.48272 9.74995H4.00009C3.58588 9.74995 3.25009 9.41417 3.25009 8.99995V4.99995C3.25009 4.58574 3.58588 4.24995 4.00009 4.24995C4.41431 4.24995 4.75009 4.58574 4.75009 4.99995V7.00691C5.48358 5.96916 6.43655 5.0951 7.55012 4.45178Z"
5927 }), /*#__PURE__*/ react.default.createElement("path", {
5928 fillRule: "evenodd",
5929 clipRule: "evenodd",
5930 d: "M3.89686 12.2571C4.30713 12.2001 4.68594 12.4864 4.74295 12.8967C4.96487 14.4936 5.70565 15.9731 6.85119 17.1075C7.99673 18.242 9.48347 18.9683 11.0824 19.1746C12.6813 19.3809 14.3037 19.0558 15.6997 18.2493C16.7566 17.6387 17.6393 16.7779 18.2748 15.75H16.0001C15.5859 15.75 15.2501 15.4142 15.2501 15C15.2501 14.5857 15.5859 14.25 16.0001 14.25H19.4833C19.4947 14.2497 19.5061 14.2497 19.5175 14.25H20.0001C20.4143 14.25 20.7501 14.5857 20.7501 15V19C20.7501 19.4142 20.4143 19.75 20.0001 19.75C19.5859 19.75 19.2501 19.4142 19.2501 19V16.993C18.5166 18.0307 17.5636 18.9048 16.4501 19.5481C14.7692 20.5192 12.8157 20.9107 10.8904 20.6622C8.9652 20.4138 7.17504 19.5393 5.79572 18.1734C4.4164 16.8074 3.52443 15.0259 3.25723 13.1032C3.20022 12.6929 3.48658 12.3141 3.89686 12.2571Z"
5931 }));
5932 });
5933
5934 //#endregion
5935 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-again-submit.js
5936 init_extends();
5937 var GenerateAgainSubmit = function GenerateAgainSubmit(props) {
5938 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5939 fullWidth: true,
5940 type: "submit",
5941 variant: "contained",
5942 color: "secondary",
5943 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null),
5944 sx: { color: "background.paper" }
5945 }, props), (0, _wordpress_i18n.__)("Generate again", "elementor"));
5946 };
5947
5948 //#endregion
5949 //#region modules/ai/assets/js/editor/pages/form-media/components/new-prompt-button.js
5950 init_extends();
5951 var NewPromptButton = function NewPromptButton(props) {
5952 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
5953 fullWidth: true,
5954 variant: "text",
5955 color: "secondary"
5956 }, props), (0, _wordpress_i18n.__)("New prompt", "elementor"));
5957 };
5958
5959 //#endregion
5960 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-images-submit.js
5961 init_extends();
5962 init_generate_button();
5963 init_voice_promotion_alert();
5964 var GenerateImagesSubmit = function GenerateImagesSubmit(props) {
5965 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(GenerateButton$1, _extends$1({
5966 size: "medium",
5967 fullWidth: true
5968 }, props), (0, _wordpress_i18n.__)("Generate images", "elementor")), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-media-promotion" }));
5969 };
5970
5971 //#endregion
5972 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-size.js
5973 var useImageSize = function useImageSize(aspectRatio) {
5974 var _IMAGE_ASPECT_RATIO$a = IMAGE_ASPECT_RATIO[aspectRatio];
5975 return {
5976 width: _IMAGE_ASPECT_RATIO$a.width,
5977 height: _IMAGE_ASPECT_RATIO$a.height
5978 };
5979 };
5980
5981 //#endregion
5982 //#region modules/ai/assets/js/editor/hooks/use-image-navigation.js
5983 init_slicedToArray();
5984 var initialIndex = -1;
5985 var useImageNavigation = function useImageNavigation(images) {
5986 var _useState2 = _slicedToArray((0, react.useState)(initialIndex), 2);
5987 var zoomIndex = _useState2[0];
5988 var setZoomIndex = _useState2[1];
5989 return {
5990 zoomIndex,
5991 setZoomIndex,
5992 actions: {
5993 reset: function reset() {
5994 return setZoomIndex(initialIndex);
5995 },
5996 prev: function prev() {
5997 var prevImage = zoomIndex + 1;
5998 if (prevImage >= images.length) prevImage = 0;
5999 setZoomIndex(prevImage);
6000 },
6001 next: function next() {
6002 var nextImage = zoomIndex - 1;
6003 if (nextImage < 0) nextImage = images.length - 1;
6004 setZoomIndex(nextImage);
6005 }
6006 }
6007 };
6008 };
6009
6010 //#endregion
6011 //#region modules/ai/assets/js/editor/icons/chevron-right-icon.js
6012 init_extends();
6013 var ChevronRightIcon = react.default.forwardRef(function(props, ref) {
6014 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6015 fillRule: "evenodd",
6016 clipRule: "evenodd",
6017 d: "M8.46967 18.2803C8.17678 17.9874 8.17678 17.5126 8.46967 17.2197L13.9393 11.75L8.46967 6.28033C8.17678 5.98744 8.17678 5.51256 8.46967 5.21967C8.76256 4.92678 9.23744 4.92678 9.53033 5.21967L15.5303 11.2197C15.8232 11.5126 15.8232 11.9874 15.5303 12.2803L9.53033 18.2803C9.23744 18.5732 8.76256 18.5732 8.46967 18.2803Z"
6018 }));
6019 });
6020
6021 //#endregion
6022 //#region modules/ai/assets/js/editor/pages/form-media/components/image-slider.js
6023 init_defineProperty$1();
6024 init_extends();
6025 init_objectWithoutProperties$1();
6026 var _excluded$18 = [
6027 "onPrev",
6028 "onNext",
6029 "children"
6030 ];
6031 var _excluded2$2 = [
6032 "children",
6033 "startAction",
6034 "sx"
6035 ];
6036 var _excluded3$1 = ["src", "alt"];
6037 function ownKeys$20(e, r) {
6038 var t = Object.keys(e);
6039 if (Object.getOwnPropertySymbols) {
6040 var o = Object.getOwnPropertySymbols(e);
6041 r && (o = o.filter(function(r) {
6042 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6043 })), t.push.apply(t, o);
6044 }
6045 return t;
6046 }
6047 __name(ownKeys$20, "ownKeys");
6048 function _objectSpread$20(e) {
6049 for (var r = 1; r < arguments.length; r++) {
6050 var t = null != arguments[r] ? arguments[r] : {};
6051 r % 2 ? ownKeys$20(Object(t), !0).forEach(function(r) {
6052 _defineProperty$1(e, r, t[r]);
6053 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$20(Object(t)).forEach(function(r) {
6054 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6055 });
6056 }
6057 return e;
6058 }
6059 __name(_objectSpread$20, "_objectSpread");
6060 var StyledChevronLeftIcon = (0, _elementor_ui.withDirection)(ChevronLeftIcon);
6061 var StyledChevronRightIcon = (0, _elementor_ui.withDirection)(ChevronRightIcon);
6062 var ImageSlider = function ImageSlider(_ref) {
6063 var onPrev = _ref.onPrev;
6064 var onNext = _ref.onNext;
6065 var children = _ref.children;
6066 var props = _objectWithoutProperties$1(_ref, _excluded$18);
6067 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, _extends$1({
6068 alignItems: "flex-start",
6069 spacing: .5
6070 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6071 direction: "row",
6072 spacing: 2.5,
6073 alignSelf: "center",
6074 alignItems: "center"
6075 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6076 onClick: onPrev,
6077 size: "large",
6078 color: "secondary"
6079 }, /*#__PURE__*/ react.default.createElement(StyledChevronLeftIcon, null)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6080 spacing: .5,
6081 justifyContent: "space-around",
6082 alignItems: "center"
6083 }, children), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
6084 onClick: onNext,
6085 size: "large",
6086 color: "secondary"
6087 }, /*#__PURE__*/ react.default.createElement(StyledChevronRightIcon, null))));
6088 };
6089 ImageSlider.propTypes = {
6090 onPrev: import_prop_types$7.default.func.isRequired,
6091 onNext: import_prop_types$7.default.func.isRequired,
6092 children: import_prop_types$7.default.node.isRequired
6093 };
6094 var Actions$1 = function Actions(_ref2) {
6095 var children = _ref2.children;
6096 var startAction = _ref2.startAction;
6097 var _ref2$sx = _ref2.sx;
6098 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6099 var props = _objectWithoutProperties$1(_ref2, _excluded2$2);
6100 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6101 display: "flex",
6102 justifyContent: "flex-end",
6103 alignItems: "center",
6104 width: "100%"
6105 }, props, { sx: _objectSpread$20({ mb: 1.5 }, sx) }), startAction, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6106 direction: "row",
6107 spacing: 2,
6108 justifyContent: "flex-end",
6109 flexGrow: 1,
6110 width: "100%"
6111 }, children));
6112 };
6113 Actions$1.propTypes = {
6114 sx: import_prop_types$7.default.object,
6115 startAction: import_prop_types$7.default.node,
6116 children: import_prop_types$7.default.node.isRequired
6117 };
6118 var Image$2 = function Image(_ref3) {
6119 var src = _ref3.src;
6120 var _ref3$alt = _ref3.alt;
6121 var alt = _ref3$alt === void 0 ? "" : _ref3$alt;
6122 var props = _objectWithoutProperties$1(_ref3, _excluded3$1);
6123 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
6124 display: "flex",
6125 justifyContent: "center",
6126 alignItems: "center"
6127 }, /*#__PURE__*/ react.default.createElement("img", _extends$1({
6128 src,
6129 alt
6130 }, props)));
6131 };
6132 Image$2.propTypes = {
6133 alt: import_prop_types$7.default.string,
6134 src: import_prop_types$7.default.string.isRequired
6135 };
6136 ImageSlider.Actions = Actions$1;
6137 ImageSlider.Image = Image$2;
6138
6139 //#endregion
6140 //#region modules/ai/assets/js/editor/icons/copy-icon.js
6141 init_extends();
6142 var CopyIcon$1 = react.default.forwardRef(function(props, ref) {
6143 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6144 fillRule: "evenodd",
6145 clipRule: "evenodd",
6146 d: "M9 3.75C8.30964 3.75 7.75 4.30964 7.75 5V15C7.75 15.6904 8.30964 16.25 9 16.25H19C19.6904 16.25 20.25 15.6904 20.25 15V5C20.25 4.30964 19.6904 3.75 19 3.75H9ZM6.25 5C6.25 3.48122 7.48122 2.25 9 2.25H19C20.5188 2.25 21.75 3.48122 21.75 5V15C21.75 16.5188 20.5188 17.75 19 17.75H9C7.48122 17.75 6.25 16.5188 6.25 15V5Z"
6147 }), /*#__PURE__*/ react.default.createElement("path", {
6148 fillRule: "evenodd",
6149 clipRule: "evenodd",
6150 d: "M5 7.75C4.66848 7.75 4.35054 7.8817 4.11612 8.11612C3.8817 8.35054 3.75 8.66848 3.75 9V19C3.75 19.3315 3.8817 19.6495 4.11612 19.8839C4.35054 20.1183 4.66848 20.25 5 20.25H15C15.3315 20.25 15.6495 20.1183 15.8839 19.8839C16.1183 19.6495 16.25 19.3315 16.25 19V17C16.25 16.5858 16.5858 16.25 17 16.25C17.4142 16.25 17.75 16.5858 17.75 17V19C17.75 19.7293 17.4603 20.4288 16.9445 20.9445C16.4288 21.4603 15.7293 21.75 15 21.75H5C4.27065 21.75 3.57118 21.4603 3.05546 20.9445C2.53973 20.4288 2.25 19.7293 2.25 19V9C2.25 8.27065 2.53973 7.57118 3.05546 7.05546C3.57118 6.53973 4.27065 6.25 5 6.25H7C7.41421 6.25 7.75 6.58579 7.75 7C7.75 7.41421 7.41421 7.75 7 7.75H5Z"
6151 }));
6152 });
6153
6154 //#endregion
6155 //#region modules/ai/assets/js/editor/icons/edit-icon.js
6156 init_extends();
6157 var EditIcon$1 = react.default.forwardRef(function(props, ref) {
6158 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6159 fillRule: "evenodd",
6160 clipRule: "evenodd",
6161 d: "M13.9697 4.96967C14.6408 4.29858 15.5509 3.92157 16.5 3.92157C17.4491 3.92157 18.3592 4.29858 19.0303 4.96967C19.7014 5.64075 20.0784 6.55094 20.0784 7.5C20.0784 8.44905 19.7014 9.35924 19.0303 10.0303L8.53033 20.5303C8.38968 20.671 8.19891 20.75 8 20.75H4C3.58579 20.75 3.25 20.4142 3.25 20V16C3.25 15.8011 3.32902 15.6103 3.46967 15.4697L13.9697 4.96967ZM16.5 5.42157C15.9488 5.42157 15.4201 5.64055 15.0303 6.03033L4.75 16.3107V19.25H7.68934L17.9697 8.96967C18.3595 8.57989 18.5784 8.05123 18.5784 7.5C18.5784 6.94876 18.3595 6.42011 17.9697 6.03033C17.5799 5.64055 17.0512 5.42157 16.5 5.42157Z"
6162 }), /*#__PURE__*/ react.default.createElement("path", {
6163 fillRule: "evenodd",
6164 clipRule: "evenodd",
6165 d: "M12.9697 5.96967C13.2626 5.67677 13.7374 5.67677 14.0303 5.96967L18.0303 9.96967C18.3232 10.2626 18.3232 10.7374 18.0303 11.0303C17.7374 11.3232 17.2626 11.3232 16.9697 11.0303L12.9697 7.03033C12.6768 6.73743 12.6768 6.26256 12.9697 5.96967Z"
6166 }));
6167 });
6168
6169 //#endregion
6170 //#region modules/ai/assets/js/editor/icons/download-icon.js
6171 init_extends();
6172 var DownloadIcon = react.default.forwardRef(function(props, ref) {
6173 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6174 fillRule: "evenodd",
6175 clipRule: "evenodd",
6176 d: "M4 16.25C4.41421 16.25 4.75 16.5858 4.75 17V19C4.75 19.3315 4.8817 19.6495 5.11612 19.8839C5.35054 20.1183 5.66848 20.25 6 20.25H18C18.3315 20.25 18.6495 20.1183 18.8839 19.8839C19.1183 19.6495 19.25 19.3315 19.25 19V17C19.25 16.5858 19.5858 16.25 20 16.25C20.4142 16.25 20.75 16.5858 20.75 17V19C20.75 19.7293 20.4603 20.4288 19.9445 20.9445C19.4288 21.4603 18.7293 21.75 18 21.75H6C5.27065 21.75 4.57118 21.4603 4.05546 20.9445C3.53973 20.4288 3.25 19.7293 3.25 19V17C3.25 16.5858 3.58579 16.25 4 16.25Z"
6177 }), /*#__PURE__*/ react.default.createElement("path", {
6178 fillRule: "evenodd",
6179 clipRule: "evenodd",
6180 d: "M6.46967 10.4697C6.76256 10.1768 7.23744 10.1768 7.53033 10.4697L12 14.9393L16.4697 10.4697C16.7626 10.1768 17.2374 10.1768 17.5303 10.4697C17.8232 10.7626 17.8232 11.2374 17.5303 11.5303L12.5303 16.5303C12.2374 16.8232 11.7626 16.8232 11.4697 16.5303L6.46967 11.5303C6.17678 11.2374 6.17678 10.7626 6.46967 10.4697Z"
6181 }), /*#__PURE__*/ react.default.createElement("path", {
6182 fillRule: "evenodd",
6183 clipRule: "evenodd",
6184 d: "M12 3.25C12.4142 3.25 12.75 3.58579 12.75 4V16C12.75 16.4142 12.4142 16.75 12 16.75C11.5858 16.75 11.25 16.4142 11.25 16V4C11.25 3.58579 11.5858 3.25 12 3.25Z"
6185 }));
6186 });
6187
6188 //#endregion
6189 //#region modules/ai/assets/js/editor/icons/zoom-in-icon.js
6190 init_extends();
6191 var ZoomInIcon = react.default.forwardRef(function(props, ref) {
6192 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
6193 fillRule: "evenodd",
6194 clipRule: "evenodd",
6195 d: "M10 3.75C6.54822 3.75 3.75 6.54822 3.75 10C3.75 13.4518 6.54822 16.25 10 16.25C13.4518 16.25 16.25 13.4518 16.25 10C16.25 6.54822 13.4518 3.75 10 3.75ZM2.25 10C2.25 5.71979 5.71979 2.25 10 2.25C14.2802 2.25 17.75 5.71979 17.75 10C17.75 14.2802 14.2802 17.75 10 17.75C5.71979 17.75 2.25 14.2802 2.25 10Z"
6196 }), /*#__PURE__*/ react.default.createElement("path", {
6197 fillRule: "evenodd",
6198 clipRule: "evenodd",
6199 d: "M6.25 10C6.25 9.58579 6.58579 9.25 7 9.25H13C13.4142 9.25 13.75 9.58579 13.75 10C13.75 10.4142 13.4142 10.75 13 10.75H7C6.58579 10.75 6.25 10.4142 6.25 10Z"
6200 }), /*#__PURE__*/ react.default.createElement("path", {
6201 fillRule: "evenodd",
6202 clipRule: "evenodd",
6203 d: "M10 6.25C10.4142 6.25 10.75 6.58579 10.75 7V13C10.75 13.4142 10.4142 13.75 10 13.75C9.58579 13.75 9.25 13.4142 9.25 13V7C9.25 6.58579 9.58579 6.25 10 6.25Z"
6204 }), /*#__PURE__*/ react.default.createElement("path", {
6205 fillRule: "evenodd",
6206 clipRule: "evenodd",
6207 d: "M14.4697 14.4697C14.7626 14.1768 15.2374 14.1768 15.5303 14.4697L21.5303 20.4697C21.8232 20.7626 21.8232 21.2374 21.5303 21.5303C21.2374 21.8232 20.7626 21.8232 20.4697 21.5303L14.4697 15.5303C14.1768 15.2374 14.1768 14.7626 14.4697 14.4697Z"
6208 }));
6209 });
6210
6211 //#endregion
6212 //#region modules/ai/assets/js/editor/pages/form-media/components/image-actions.js
6213 init_defineProperty$1();
6214 init_objectWithoutProperties$1();
6215 init_extends();
6216 var _excluded$17 = ["children"];
6217 var _excluded2$1 = ["sx"];
6218 var _excluded3 = ["sx"];
6219 var _excluded4 = ["sx"];
6220 var _excluded5 = ["sx"];
6221 function ownKeys$19(e, r) {
6222 var t = Object.keys(e);
6223 if (Object.getOwnPropertySymbols) {
6224 var o = Object.getOwnPropertySymbols(e);
6225 r && (o = o.filter(function(r) {
6226 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6227 })), t.push.apply(t, o);
6228 }
6229 return t;
6230 }
6231 __name(ownKeys$19, "ownKeys");
6232 function _objectSpread$19(e) {
6233 for (var r = 1; r < arguments.length; r++) {
6234 var t = null != arguments[r] ? arguments[r] : {};
6235 r % 2 ? ownKeys$19(Object(t), !0).forEach(function(r) {
6236 _defineProperty$1(e, r, t[r]);
6237 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$19(Object(t)).forEach(function(r) {
6238 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6239 });
6240 }
6241 return e;
6242 }
6243 __name(_objectSpread$19, "_objectSpread");
6244 var StyledEditSvgIcon = (0, _elementor_ui.withDirection)(EditIcon$1);
6245 var StyledCopySvgIcon = (0, _elementor_ui.withDirection)(CopyIcon$1);
6246 var StyledZoomInIcon = (0, _elementor_ui.withDirection)(ZoomInIcon);
6247 var Tooltip$5 = function Tooltip(props) {
6248 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ PopperProps: { sx: { "&.MuiTooltip-popper .MuiTooltip-tooltip.MuiTooltip-tooltipPlacementBottom": { mt: 1 } } } }, props));
6249 };
6250 var ImageActions = function ImageActions(_ref) {
6251 var children = _ref.children;
6252 var props = _objectWithoutProperties$1(_ref, _excluded$17);
6253 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6254 display: "flex",
6255 justifyContent: "space-between",
6256 alignItems: "center",
6257 width: "100%",
6258 gap: 1
6259 }, props), children);
6260 };
6261 ImageActions.propTypes = { children: import_prop_types$7.default.node };
6262 var UseImage = function UseImage(_ref2) {
6263 var sx = _ref2.sx;
6264 var props = _objectWithoutProperties$1(_ref2, _excluded2$1);
6265 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6266 size: "small",
6267 variant: "contained",
6268 startIcon: /*#__PURE__*/ react.default.createElement(DownloadIcon, null),
6269 sx
6270 }, props), (0, _wordpress_i18n.__)("Use Image", "elementor"));
6271 };
6272 UseImage.propTypes = { sx: import_prop_types$7.default.object };
6273 var EditImage = function EditImage(props) {
6274 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
6275 size: "small",
6276 color: "secondary",
6277 startIcon: /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)
6278 }, props), (0, _wordpress_i18n.__)("Edit", "elementor"));
6279 };
6280 var EditIcon = function EditIcon(_ref3) {
6281 var _ref3$sx = _ref3.sx;
6282 var sx = _ref3$sx === void 0 ? {} : _ref3$sx;
6283 var props = _objectWithoutProperties$1(_ref3, _excluded3);
6284 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Edit", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({ sx: _objectSpread$19({
6285 mr: -1.5,
6286 ml: .5,
6287 color: "common.white",
6288 "&:hover": { color: "common.white" }
6289 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledEditSvgIcon, null)));
6290 };
6291 EditIcon.propTypes = { sx: import_prop_types$7.default.object };
6292 var ZoomIcon = function ZoomIcon(_ref4) {
6293 var _ref4$sx = _ref4.sx;
6294 var sx = _ref4$sx === void 0 ? {} : _ref4$sx;
6295 var props = _objectWithoutProperties$1(_ref4, _excluded4);
6296 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Zoom", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
6297 color: "secondary",
6298 "aria-label": (0, _wordpress_i18n.__)("Zoom", "elementor"),
6299 sx: _objectSpread$19({
6300 color: "common.white",
6301 "&:hover": { color: "common.white" }
6302 }, sx)
6303 }, props), /*#__PURE__*/ react.default.createElement(StyledZoomInIcon, null)));
6304 };
6305 ZoomIcon.propTypes = { sx: import_prop_types$7.default.object };
6306 var CopyIcon = function CopyIcon(_ref5) {
6307 var _ref5$sx = _ref5.sx;
6308 var sx = _ref5$sx === void 0 ? {} : _ref5$sx;
6309 var props = _objectWithoutProperties$1(_ref5, _excluded5);
6310 return /*#__PURE__*/ react.default.createElement(Tooltip$5, { title: (0, _wordpress_i18n.__)("Copy prompt", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({ sx: _objectSpread$19({
6311 mr: -1.5,
6312 ml: .5,
6313 color: "common.white",
6314 "&:hover": { color: "common.white" }
6315 }, sx) }, props), /*#__PURE__*/ react.default.createElement(StyledCopySvgIcon, null)));
6316 };
6317 CopyIcon.propTypes = { sx: import_prop_types$7.default.object };
6318 ImageActions.UseImage = UseImage;
6319 ImageActions.EditImage = EditImage;
6320 ImageActions.EditIcon = EditIcon;
6321 ImageActions.ZoomIcon = ZoomIcon;
6322 ImageActions.CopyIcon = CopyIcon;
6323
6324 //#endregion
6325 //#region modules/ai/assets/js/editor/pages/form-media/components/single-image-preview.js
6326 init_defineProperty$1();
6327 init_extends();
6328 init_objectWithoutProperties$1();
6329 var _excluded$16 = ["children"];
6330 var _excluded2 = ["children", "sx"];
6331 function ownKeys$18(e, r) {
6332 var t = Object.keys(e);
6333 if (Object.getOwnPropertySymbols) {
6334 var o = Object.getOwnPropertySymbols(e);
6335 r && (o = o.filter(function(r) {
6336 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6337 })), t.push.apply(t, o);
6338 }
6339 return t;
6340 }
6341 __name(ownKeys$18, "ownKeys");
6342 function _objectSpread$18(e) {
6343 for (var r = 1; r < arguments.length; r++) {
6344 var t = null != arguments[r] ? arguments[r] : {};
6345 r % 2 ? ownKeys$18(Object(t), !0).forEach(function(r) {
6346 _defineProperty$1(e, r, t[r]);
6347 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$18(Object(t)).forEach(function(r) {
6348 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6349 });
6350 }
6351 return e;
6352 }
6353 __name(_objectSpread$18, "_objectSpread");
6354 var SingleImagePreview = function SingleImagePreview(_ref) {
6355 var children = _ref.children;
6356 var props = _objectWithoutProperties$1(_ref, _excluded$16);
6357 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ display: "flex" }, props), children);
6358 };
6359 SingleImagePreview.propTypes = { children: import_prop_types$7.default.node.isRequired };
6360 var Actions = function Actions(_ref2) {
6361 var children = _ref2.children;
6362 var _ref2$sx = _ref2.sx;
6363 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
6364 var props = _objectWithoutProperties$1(_ref2, _excluded2);
6365 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({
6366 display: "flex",
6367 width: "100%",
6368 justifyContent: "flex-end",
6369 alignItems: "center"
6370 }, props, { sx: _objectSpread$18({ mb: 1.5 }, sx) }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6371 direction: "row",
6372 spacing: 2,
6373 justifyContent: "flex-end",
6374 width: "100%"
6375 }, children));
6376 };
6377 Actions.propTypes = {
6378 sx: import_prop_types$7.default.object,
6379 children: import_prop_types$7.default.node.isRequired
6380 };
6381 var Image$1 = function Image(_ref3) {
6382 var src = _ref3.src;
6383 var alt = _ref3.alt;
6384 var _ref3$style = _ref3.style;
6385 var style = _ref3$style === void 0 ? {} : _ref3$style;
6386 var _ref3$isLoading = _ref3.isLoading;
6387 var isLoading = _ref3$isLoading === void 0 ? false : _ref3$isLoading;
6388 var children = _ref3.children;
6389 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { margin: "0 auto" }, children, isLoading ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
6390 sx: _objectSpread$18({
6391 maxWidth: "100%",
6392 width: "auto",
6393 maxHeight: "100%"
6394 }, style),
6395 animation: "wave",
6396 variant: "rounded"
6397 }) : /*#__PURE__*/ react.default.createElement("img", {
6398 src,
6399 alt,
6400 style: _objectSpread$18({
6401 maxWidth: "100%",
6402 width: "auto",
6403 maxHeight: "100%"
6404 }, style)
6405 }));
6406 };
6407 Image$1.propTypes = {
6408 style: import_prop_types$7.default.object,
6409 children: import_prop_types$7.default.node,
6410 src: import_prop_types$7.default.string.isRequired,
6411 alt: import_prop_types$7.default.string.isRequired,
6412 isLoading: import_prop_types$7.default.bool
6413 };
6414 SingleImagePreview.Actions = Actions;
6415 SingleImagePreview.Image = Image$1;
6416
6417 //#endregion
6418 //#region modules/ai/assets/js/editor/pages/form-media/components/images-display.js
6419 init_extends();
6420 init_defineProperty$1();
6421 init_objectWithoutProperties$1();
6422 var _excluded$15 = ["children", "sx"];
6423 function ownKeys$17(e, r) {
6424 var t = Object.keys(e);
6425 if (Object.getOwnPropertySymbols) {
6426 var o = Object.getOwnPropertySymbols(e);
6427 r && (o = o.filter(function(r) {
6428 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6429 })), t.push.apply(t, o);
6430 }
6431 return t;
6432 }
6433 __name(ownKeys$17, "ownKeys");
6434 function _objectSpread$17(e) {
6435 for (var r = 1; r < arguments.length; r++) {
6436 var t = null != arguments[r] ? arguments[r] : {};
6437 r % 2 ? ownKeys$17(Object(t), !0).forEach(function(r) {
6438 _defineProperty$1(e, r, t[r]);
6439 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$17(Object(t)).forEach(function(r) {
6440 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6441 });
6442 }
6443 return e;
6444 }
6445 __name(_objectSpread$17, "_objectSpread");
6446 var Container = function Container(_ref) {
6447 var children = _ref.children;
6448 var _ref$sx = _ref.sx;
6449 var sx = _ref$sx === void 0 ? {} : _ref$sx;
6450 var props = _objectWithoutProperties$1(_ref, _excluded$15);
6451 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, _extends$1({ flexGrow: 1 }, props, { sx: _objectSpread$17({ overflowY: "auto" }, sx) }), children);
6452 };
6453 Container.propTypes = {
6454 sx: import_prop_types$7.default.object,
6455 children: import_prop_types$7.default.node
6456 };
6457 var ImagesDisplay = function ImagesDisplay(_ref2) {
6458 var images = _ref2.images;
6459 var _ref2$aspectRatio = _ref2.aspectRatio;
6460 var aspectRatio = _ref2$aspectRatio === void 0 ? "1:1" : _ref2$aspectRatio;
6461 var _ref2$onUseImage = _ref2.onUseImage;
6462 var onUseImage = _ref2$onUseImage === void 0 ? null : _ref2$onUseImage;
6463 var _ref2$onEditImage = _ref2.onEditImage;
6464 var onEditImage = _ref2$onEditImage === void 0 ? null : _ref2$onEditImage;
6465 var _ref2$transparentCont = _ref2.transparentContainer;
6466 var transparentContainer = _ref2$transparentCont === void 0 ? false : _ref2$transparentCont;
6467 var _ref2$cols = _ref2.cols;
6468 var cols = _ref2$cols === void 0 ? 2 : _ref2$cols;
6469 var _ref2$overlay = _ref2.overlay;
6470 var overlay = _ref2$overlay === void 0 ? true : _ref2$overlay;
6471 var _ref2$onSelectChange = _ref2.onSelectChange;
6472 var onSelectChange = _ref2$onSelectChange === void 0 ? null : _ref2$onSelectChange;
6473 var _useImageNavigation = useImageNavigation(images);
6474 var zoomIndex = _useImageNavigation.zoomIndex;
6475 var setZoomIndex = _useImageNavigation.setZoomIndex;
6476 var actions = _useImageNavigation.actions;
6477 var _useImageSize = useImageSize(aspectRatio);
6478 var width = _useImageSize.width;
6479 var height = _useImageSize.height;
6480 if (zoomIndex > -1) {
6481 var currentImage = images[zoomIndex];
6482 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(ImageSlider, {
6483 onPrev: actions.prev,
6484 onNext: actions.next
6485 }, /*#__PURE__*/ react.default.createElement(ImageSlider.Actions, { startAction: /*#__PURE__*/ react.default.createElement(BackButton$1, { onClick: actions.reset }) }, onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditImage, { onClick: function onClick() {
6486 return onEditImage(currentImage);
6487 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6488 return onUseImage(currentImage);
6489 } })), /*#__PURE__*/ react.default.createElement(ImageSlider.Image, {
6490 src: currentImage.image_url,
6491 style: {
6492 maxWidth: "630px",
6493 width: "100%",
6494 height: "auto"
6495 }
6496 })));
6497 }
6498 if (1 === images.length) {
6499 var image = images[0];
6500 var singleImageStyle = {
6501 width,
6502 height
6503 };
6504 if (transparentContainer) {
6505 singleImageStyle.backgroundImage = "linear-gradient(45deg, #bbb 25%, transparent 25%), linear-gradient(-45deg, #bbb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #bbb 75%), linear-gradient(-45deg, transparent 75%, #bbb 75%)";
6506 singleImageStyle.backgroundSize = "20px 20px";
6507 singleImageStyle.backgroundPosition = "0 0, 0 10px, 10px -10px, -10px 0px";
6508 }
6509 return /*#__PURE__*/ react.default.createElement(Container, { flexDirection: "column" }, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
6510 src: image.image_url || image.url,
6511 style: singleImageStyle,
6512 alt: "generated-image",
6513 isLoading: image.isLoading
6514 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditImage, { onClick: function onClick() {
6515 return onEditImage(image);
6516 } }), onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
6517 return onUseImage(image);
6518 } })))));
6519 }
6520 return /*#__PURE__*/ react.default.createElement(Container, null, /*#__PURE__*/ react.default.createElement(Gallery, { cols }, images.map(function(image, index) {
6521 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
6522 key: "result-".concat(image.seed),
6523 alt: "generated-".concat(index),
6524 src: image.image_url,
6525 aspectRatio,
6526 "data-testid": "e-gallery-image",
6527 numImagesInRow: cols,
6528 overlay,
6529 onSelectChange: onSelectChange ? function(isChecked) {
6530 return onSelectChange(image.productId, isChecked);
6531 } : null,
6532 checkboxColor: image.checkboxColor,
6533 initialChecked: image.isChecked,
6534 isLoading: image.isLoading
6535 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, onUseImage && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
6536 onClick: function onClick() {
6537 return onUseImage(image);
6538 },
6539 size: "medium",
6540 fullWidth: true
6541 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
6542 direction: "row",
6543 spacing: .25,
6544 alignItems: "center"
6545 }, /*#__PURE__*/ react.default.createElement(ImageActions.ZoomIcon, {
6546 onClick: function onClick() {
6547 return setZoomIndex(index);
6548 },
6549 size: "medium"
6550 }), onEditImage && /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, {
6551 onClick: function onClick() {
6552 return onEditImage(image);
6553 },
6554 size: "medium"
6555 }))));
6556 })));
6557 };
6558 ImagesDisplay.propTypes = {
6559 images: import_prop_types$7.default.array,
6560 aspectRatio: import_prop_types$7.default.string,
6561 onUseImage: import_prop_types$7.default.func,
6562 onEditImage: import_prop_types$7.default.func,
6563 transparentContainer: import_prop_types$7.default.bool,
6564 cols: import_prop_types$7.default.number,
6565 overlay: import_prop_types$7.default.bool,
6566 onSelectChange: import_prop_types$7.default.func
6567 };
6568 ImagesDisplay.Container = Container;
6569
6570 //#endregion
6571 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-prompt-settings.js
6572 init_defineProperty$1();
6573 init_slicedToArray();
6574 function ownKeys$16(e, r) {
6575 var t = Object.keys(e);
6576 if (Object.getOwnPropertySymbols) {
6577 var o = Object.getOwnPropertySymbols(e);
6578 r && (o = o.filter(function(r) {
6579 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6580 })), t.push.apply(t, o);
6581 }
6582 return t;
6583 }
6584 __name(ownKeys$16, "ownKeys");
6585 function _objectSpread$16(e) {
6586 for (var r = 1; r < arguments.length; r++) {
6587 var t = null != arguments[r] ? arguments[r] : {};
6588 r % 2 ? ownKeys$16(Object(t), !0).forEach(function(r) {
6589 _defineProperty$1(e, r, t[r]);
6590 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$16(Object(t)).forEach(function(r) {
6591 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6592 });
6593 }
6594 return e;
6595 }
6596 __name(_objectSpread$16, "_objectSpread");
6597 var IMAGE_TYPE = IMAGE_PROMPT_SETTINGS.IMAGE_TYPE;
6598 var IMAGE_STYLE = IMAGE_PROMPT_SETTINGS.IMAGE_STYLE;
6599 var IMAGE_STRENGTH = IMAGE_PROMPT_SETTINGS.IMAGE_STRENGTH;
6600 var IMAGE_RATIO = IMAGE_PROMPT_SETTINGS.IMAGE_RATIO;
6601 var IMAGE_ZOOM = IMAGE_PROMPT_SETTINGS.IMAGE_ZOOM;
6602 var IMAGE_UPSCALE = IMAGE_PROMPT_SETTINGS.IMAGE_UPSCALE;
6603 var IMAGE_BACKGROUND_COLOR = IMAGE_PROMPT_SETTINGS.IMAGE_BACKGROUND_COLOR;
6604 var DEFAULT_TYPE = "";
6605 var DEFAULT_STYLE = "";
6606 var DEFAULT_STRENGTH = 0;
6607 var DEFAULT_RATIO = "1:1";
6608 var DEFAULT_ZOOM = "1";
6609 var DEFAULT_UPSCALE = "512";
6610 var DEFAULT_COLOR = "#FFFFFF";
6611 var usePromptSettings = function usePromptSettings() {
6612 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
6613 var _ref$type = _ref.type;
6614 var type = _ref$type === void 0 ? DEFAULT_TYPE : _ref$type;
6615 var _ref$style = _ref.style;
6616 var style = _ref$style === void 0 ? DEFAULT_STYLE : _ref$style;
6617 var _ref$imageWeight = _ref.imageWeight;
6618 var imageWeight = _ref$imageWeight === void 0 ? DEFAULT_STRENGTH : _ref$imageWeight;
6619 var _ref$aspectRatio = _ref.aspectRatio;
6620 var aspectRatio = _ref$aspectRatio === void 0 ? DEFAULT_RATIO : _ref$aspectRatio;
6621 var _ref$zoom = _ref.zoom;
6622 var zoom = _ref$zoom === void 0 ? DEFAULT_ZOOM : _ref$zoom;
6623 var _ref$upScaleTo = _ref.upScaleTo;
6624 var upScaleTo = _ref$upScaleTo === void 0 ? DEFAULT_UPSCALE : _ref$upScaleTo;
6625 var _ref$bgColor = _ref.bgColor;
6626 var bgColor = _ref$bgColor === void 0 ? DEFAULT_COLOR : _ref$bgColor;
6627 var _useState2 = _slicedToArray((0, react.useState)(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1({}, IMAGE_TYPE, type), IMAGE_STYLE, style), IMAGE_STRENGTH, imageWeight), IMAGE_RATIO, aspectRatio), IMAGE_ZOOM, zoom), IMAGE_UPSCALE, upScaleTo), IMAGE_BACKGROUND_COLOR, bgColor)), 2);
6628 var settings = _useState2[0];
6629 var setSettings = _useState2[1];
6630 return {
6631 settings,
6632 updateSettings: function updateSettings(updated) {
6633 return setSettings(function(prev) {
6634 return _objectSpread$16(_objectSpread$16({}, prev), updated);
6635 });
6636 },
6637 resetSettings: function resetSettings() {
6638 setSettings(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1(_defineProperty$1({}, IMAGE_TYPE, type), IMAGE_STYLE, DEFAULT_STYLE), IMAGE_STRENGTH, DEFAULT_STRENGTH), IMAGE_RATIO, aspectRatio), IMAGE_ZOOM, DEFAULT_ZOOM), IMAGE_UPSCALE, DEFAULT_UPSCALE), IMAGE_BACKGROUND_COLOR, bgColor));
6639 }
6640 };
6641 };
6642
6643 //#endregion
6644 //#region modules/ai/assets/js/editor/hooks/use-images-preload.js
6645 init_slicedToArray();
6646 var loadImage$1 = function loadImage(url) {
6647 return new Promise(function(resolve, reject) {
6648 var loadImg = new Image();
6649 loadImg.src = url;
6650 loadImg.onload = function() {
6651 return resolve(url);
6652 };
6653 loadImg.onerror = function(err) {
6654 return reject(err);
6655 };
6656 });
6657 };
6658 var useImagesPreload = function useImagesPreload() {
6659 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6660 var ready = _useState2[0];
6661 var setReady = _useState2[1];
6662 return {
6663 ready,
6664 preloadImages: function preloadImages(images) {
6665 setReady(false);
6666 Promise.all(images.map(function(url) {
6667 return loadImage$1(url);
6668 })).then(function() {
6669 return setReady(true);
6670 }).catch(function(err) {
6671 return console.log("Failed to load images", err);
6672 });
6673 }
6674 };
6675 };
6676
6677 //#endregion
6678 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-suggested-images.js
6679 init_slicedToArray();
6680 var shuffleImages = function shuffleImages(images) {
6681 return images.map(function(image) {
6682 return [Math.random(), image];
6683 }).sort(function(_ref, _ref2) {
6684 return _slicedToArray(_ref, 1)[0] - _slicedToArray(_ref2, 1)[0];
6685 }).map(function(_ref5) {
6686 return _slicedToArray(_ref5, 2)[1];
6687 });
6688 };
6689 var checkImageTypeIgnoreStyle = function checkImageTypeIgnoreStyle(imageType, selectedType) {
6690 return _slicedToArray(imageType.split("/"), 1)[0] === selectedType;
6691 };
6692 var useSuggestedImages = function useSuggestedImages(_ref7) {
6693 var selectedType = _ref7.selectedType;
6694 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6695 var isLoading = _useState2[0];
6696 var setIsLoading = _useState2[1];
6697 var _useState4 = _slicedToArray((0, react.useState)({ images: [] }), 2);
6698 var data = _useState4[0];
6699 var setImagesState = _useState4[1];
6700 var _useImagesPreload = useImagesPreload();
6701 var ready = _useImagesPreload.ready;
6702 var preloadImages = _useImagesPreload.preloadImages;
6703 var imagesData = (0, react.useMemo)(function() {
6704 var shuffledImages = shuffleImages(data.images);
6705 if (!selectedType) return shuffledImages;
6706 var categoryImages = shuffledImages.filter(function(_ref8) {
6707 var imageType = _ref8.imageType;
6708 return checkImageTypeIgnoreStyle(imageType, selectedType);
6709 });
6710 return categoryImages.length ? categoryImages : shuffledImages;
6711 }, [selectedType, data]);
6712 var fetchImages = function fetchImages() {
6713 setIsLoading(true);
6714 fetch("https://my.elementor.com/ai/images-prompt-gallery/ai-gallery.json").then(function(response) {
6715 return response.json();
6716 }).then(function(json) {
6717 return setImagesState(json);
6718 }).catch(function(e) {
6719 return console.log(e.message);
6720 }).finally(function() {
6721 return setIsLoading(false);
6722 });
6723 };
6724 (0, react.useEffect)(function() {
6725 if (0 === (data === null || data === void 0 ? void 0 : data.images.length)) {
6726 fetchImages();
6727 return;
6728 }
6729 preloadImages(data.images.map(function(_ref9) {
6730 return _ref9.thumbnailUrl;
6731 }));
6732 }, [data]);
6733 return {
6734 imagesData,
6735 isLoading: !ready || isLoading
6736 };
6737 };
6738
6739 //#endregion
6740 //#region modules/ai/assets/js/editor/pages/form-media/utils/index.js
6741 init_asyncToGenerator();
6742 init_defineProperty$1();
6743 init_slicedToArray();
6744 function ownKeys$15(e, r) {
6745 var t = Object.keys(e);
6746 if (Object.getOwnPropertySymbols) {
6747 var o = Object.getOwnPropertySymbols(e);
6748 r && (o = o.filter(function(r) {
6749 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6750 })), t.push.apply(t, o);
6751 }
6752 return t;
6753 }
6754 __name(ownKeys$15, "ownKeys");
6755 function _objectSpread$15(e) {
6756 for (var r = 1; r < arguments.length; r++) {
6757 var t = null != arguments[r] ? arguments[r] : {};
6758 r % 2 ? ownKeys$15(Object(t), !0).forEach(function(r) {
6759 _defineProperty$1(e, r, t[r]);
6760 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$15(Object(t)).forEach(function(r) {
6761 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6762 });
6763 }
6764 return e;
6765 }
6766 __name(_objectSpread$15, "_objectSpread");
6767 var getAspectRatioSizes = function getAspectRatioSizes(width, height) {
6768 var aspectRatios = Object.keys(IMAGE_ASPECT_RATIO);
6769 var targetRatio = width / height;
6770 var closestRatio = aspectRatios[0];
6771 var minDiff = Infinity;
6772 aspectRatios.forEach(function(ratio) {
6773 var _ratio$split$map2 = _slicedToArray(ratio.split(":").map(Number), 2);
6774 var w = _ratio$split$map2[0];
6775 var h = _ratio$split$map2[1];
6776 var diff = Math.abs(targetRatio - w / h);
6777 if (diff < minDiff) {
6778 minDiff = diff;
6779 closestRatio = ratio;
6780 }
6781 });
6782 return _objectSpread$15({ ratio: closestRatio }, IMAGE_ASPECT_RATIO[closestRatio]);
6783 };
6784 var fetchImageAsBase64 = /*#__PURE__*/ function() {
6785 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(url) {
6786 var response;
6787 var blob;
6788 var reader;
6789 var _t;
6790 return import_regenerator$2.default.wrap(function(_context) {
6791 while (1) switch (_context.prev = _context.next) {
6792 case 0:
6793 _context.prev = 0;
6794 _context.next = 1;
6795 return fetch(url);
6796 case 1:
6797 response = _context.sent;
6798 _context.next = 2;
6799 return response.blob();
6800 case 2:
6801 blob = _context.sent;
6802 reader = new FileReader();
6803 return _context.abrupt("return", new Promise(function(resolve, reject) {
6804 reader.onloadend = function() {
6805 resolve(reader.result);
6806 };
6807 reader.onerror = reject;
6808 reader.readAsDataURL(blob);
6809 }));
6810 case 3:
6811 _context.prev = 3;
6812 _t = _context["catch"](0);
6813 throw _t;
6814 case 4:
6815 case "end": return _context.stop();
6816 }
6817 }, _callee, null, [[0, 3]]);
6818 }));
6819 return function fetchImageAsBase64(_x) {
6820 return _ref.apply(this, arguments);
6821 };
6822 }();
6823
6824 //#endregion
6825 //#region modules/ai/assets/js/editor/pages/form-media/context/edit-image-context.js
6826 init_slicedToArray();
6827 init_defineProperty$1();
6828 function ownKeys$14(e, r) {
6829 var t = Object.keys(e);
6830 if (Object.getOwnPropertySymbols) {
6831 var o = Object.getOwnPropertySymbols(e);
6832 r && (o = o.filter(function(r) {
6833 return Object.getOwnPropertyDescriptor(e, r).enumerable;
6834 })), t.push.apply(t, o);
6835 }
6836 return t;
6837 }
6838 __name(ownKeys$14, "ownKeys");
6839 function _objectSpread$14(e) {
6840 for (var r = 1; r < arguments.length; r++) {
6841 var t = null != arguments[r] ? arguments[r] : {};
6842 r % 2 ? ownKeys$14(Object(t), !0).forEach(function(r) {
6843 _defineProperty$1(e, r, t[r]);
6844 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$14(Object(t)).forEach(function(r) {
6845 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
6846 });
6847 }
6848 return e;
6849 }
6850 __name(_objectSpread$14, "_objectSpread");
6851 var EditImageContext = (0, react.createContext)({});
6852 var SET_STATE = "SET_STATE";
6853 var SET_ASPECT_RATIO = "SET_ASPECT_RATIO";
6854 var SET_LOADING = "SET_LOADING";
6855 var RESET = "RESET";
6856 var initialValue = {
6857 id: "",
6858 url: "",
6859 isLoading: false,
6860 aspectRatio: "1:1"
6861 };
6862 var reducer$1 = function reducer(state, _ref) {
6863 var type = _ref.type;
6864 var payload = _ref.payload;
6865 switch (type) {
6866 case SET_STATE: return _objectSpread$14(_objectSpread$14({}, state), payload);
6867 case SET_ASPECT_RATIO: return _objectSpread$14(_objectSpread$14({}, state), {}, { aspectRatio: payload });
6868 case SET_LOADING: return _objectSpread$14(_objectSpread$14({}, state), {}, { isLoading: payload });
6869 case RESET: return initialValue;
6870 default: throw Error("Unknown action.");
6871 }
6872 };
6873 var EditImageProvider = function EditImageProvider(_ref2) {
6874 var children = _ref2.children;
6875 var imageData = _ref2.imageData;
6876 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer$1, _objectSpread$14(_objectSpread$14({}, initialValue), imageData)), 2);
6877 var state = _useReducer2[0];
6878 var dispatch = _useReducer2[1];
6879 return /*#__PURE__*/ react.default.createElement(EditImageContext.Provider, { value: {
6880 state,
6881 dispatch
6882 } }, children);
6883 };
6884 EditImageProvider.propTypes = {
6885 children: import_prop_types$7.default.node,
6886 imageData: import_prop_types$7.default.object
6887 };
6888 var useEditImage = function useEditImage() {
6889 var _useContext = (0, react.useContext)(EditImageContext);
6890 var state = _useContext.state;
6891 var dispatch = _useContext.dispatch;
6892 var id = state.id;
6893 var url = state.url;
6894 var aspectRatio = state.aspectRatio;
6895 var isLoading = state.isLoading;
6896 var _useImageSize = useImageSize(aspectRatio);
6897 var width = _useImageSize.width;
6898 var height = _useImageSize.height;
6899 var setEditImage = function setEditImage(payload) {
6900 return dispatch({
6901 type: SET_STATE,
6902 payload
6903 });
6904 };
6905 var setAspectRatio = function setAspectRatio(payload) {
6906 return dispatch({
6907 type: SET_ASPECT_RATIO,
6908 payload
6909 });
6910 };
6911 var reset = function reset() {
6912 return dispatch({ type: RESET });
6913 };
6914 (0, react.useEffect)(function() {
6915 if (!id) return;
6916 dispatch({
6917 type: SET_LOADING,
6918 payload: true
6919 });
6920 var img = new Image();
6921 img.src = url;
6922 img.onload = function() {
6923 var ratio = getAspectRatioSizes(img.width, img.height).ratio;
6924 dispatch({
6925 type: SET_STATE,
6926 payload: {
6927 aspectRatio: ratio,
6928 isLoading: false
6929 }
6930 });
6931 };
6932 }, [id]);
6933 return {
6934 editImage: state,
6935 isLoading,
6936 aspectRatio,
6937 width,
6938 height,
6939 setEditImage,
6940 setAspectRatio,
6941 reset
6942 };
6943 };
6944
6945 //#endregion
6946 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-upload.js
6947 init_slicedToArray();
6948 init_api();
6949 var useImageUpload = function useImageUpload() {
6950 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
6951 var isUploading = _useState2[0];
6952 var setIsUploading = _useState2[1];
6953 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
6954 var uploadError = _useState4[0];
6955 var setUploadError = _useState4[1];
6956 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
6957 var attachmentData = _useState6[0];
6958 var setAttachmentData = _useState6[1];
6959 return {
6960 upload: function upload(_ref) {
6961 var image = _ref.image;
6962 var prompt = _ref.prompt;
6963 return new Promise(function(resolve, reject) {
6964 setUploadError("");
6965 setAttachmentData({});
6966 setIsUploading(true);
6967 uploadImage({
6968 image,
6969 prompt
6970 }).then(function(result) {
6971 setAttachmentData(result);
6972 resolve(result);
6973 }).catch(function(err) {
6974 var error = (err === null || err === void 0 ? void 0 : err.responseText) || err;
6975 setUploadError(error);
6976 reject(error);
6977 }).finally(function() {
6978 return setIsUploading(false);
6979 });
6980 });
6981 },
6982 resetUpload: function resetUpload() {
6983 setUploadError("");
6984 setAttachmentData({});
6985 setIsUploading(false);
6986 },
6987 isUploading,
6988 uploadError,
6989 attachmentData
6990 };
6991 };
6992
6993 //#endregion
6994 //#region modules/ai/assets/js/editor/pages/form-media/context/global-actions-context.js
6995 var GlobalActionsContext = (0, react.createContext)({});
6996 var GlobalActionsProvider = function GlobalActionsProvider(_ref) {
6997 var actions = _ref.actions;
6998 var children = _ref.children;
6999 return /*#__PURE__*/ react.default.createElement(GlobalActionsContext.Provider, { value: actions }, children);
7000 };
7001 GlobalActionsProvider.propTypes = {
7002 actions: import_prop_types$7.default.object,
7003 children: import_prop_types$7.default.node
7004 };
7005 var useGlobalActions = function useGlobalActions() {
7006 return (0, react.useContext)(GlobalActionsContext);
7007 };
7008
7009 //#endregion
7010 //#region node_modules/@babel/runtime/helpers/esm/classCallCheck.js
7011 function _classCallCheck(a, n) {
7012 if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
7013 }
7014
7015 //#endregion
7016 //#region node_modules/@babel/runtime/helpers/esm/createClass.js
7017 init_toPropertyKey$1();
7018 function _defineProperties(e, r) {
7019 for (var t = 0; t < r.length; t++) {
7020 var o = r[t];
7021 o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey$1(o.key), o);
7022 }
7023 }
7024 function _createClass(e, r, t) {
7025 return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
7026 }
7027
7028 //#endregion
7029 //#region assets/dev/js/editor/utils/files-upload-handler.js
7030 var FilesUploadHandler = /*#__PURE__*/ function() {
7031 function FilesUploadHandler() {
7032 _classCallCheck(this, FilesUploadHandler);
7033 }
7034 return _createClass(FilesUploadHandler, null, [
7035 {
7036 key: "isUploadEnabled",
7037 value: function isUploadEnabled(mediaType) {
7038 if (!["svg", "application/json"].includes(mediaType)) return true;
7039 return elementorCommon.config.filesUpload.unfilteredFiles;
7040 }
7041 },
7042 {
7043 key: "setUploadTypeCaller",
7044 value: function setUploadTypeCaller(frame) {
7045 frame.uploader.uploader.param("uploadTypeCaller", "elementor-wp-media-upload");
7046 }
7047 },
7048 {
7049 key: "getUnfilteredFilesNonAdminDialog",
7050 value: function getUnfilteredFilesNonAdminDialog() {
7051 return elementorCommon.dialogsManager.createWidget("alert", {
7052 id: "e-unfiltered-files-disabled-dialog",
7053 headerMessage: (0, _wordpress_i18n.__)("Sorry, you can't upload that file yet", "elementor"),
7054 message: (0, _wordpress_i18n.__)("This is because JSON files may pose a security risk.", "elementor") + "<br><br>" + (0, _wordpress_i18n.__)("To upload them anyway, ask the site administrator to enable unfiltered file uploads.", "elementor"),
7055 strings: { confirm: (0, _wordpress_i18n.__)("Got it", "elementor") }
7056 });
7057 }
7058 },
7059 {
7060 key: "getUnfilteredFilesNotEnabledDialog",
7061 value: function getUnfilteredFilesNotEnabledDialog(callback) {
7062 var elementorInstance = window.elementorAdmin || window.elementor;
7063 if (!elementorInstance.config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7064 return elementorInstance.helpers.getSimpleDialog("e-enable-unfiltered-files-dialog", (0, _wordpress_i18n.__)("Enable Unfiltered File Uploads", "elementor"), (0, _wordpress_i18n.__)("Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.", "elementor"), (0, _wordpress_i18n.__)("Enable", "elementor"), function onConfirm() {
7065 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", {}, true);
7066 elementorCommon.config.filesUpload.unfilteredFiles = true;
7067 callback();
7068 });
7069 }
7070 },
7071 {
7072 key: "getUnfilteredFilesNotEnabledImportTemplateDialog",
7073 value: function getUnfilteredFilesNotEnabledImportTemplateDialog(callback) {
7074 if (!(window.elementorAdmin || window.elementor).config.user.is_administrator) return this.getUnfilteredFilesNonAdminDialog();
7075 return elementorCommon.dialogsManager.createWidget("confirm", {
7076 id: "e-enable-unfiltered-files-dialog-import-template",
7077 headerMessage: (0, _wordpress_i18n.__)("Enable Unfiltered File Uploads", "elementor"),
7078 message: (0, _wordpress_i18n.__)("Before you enable unfiltered files upload, note that such files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.", "elementor") + "<br /><br />" + (0, _wordpress_i18n.__)("If you do not enable uploading unfiltered files, any SVG or JSON (including lottie) files used in the uploaded template will not be imported.", "elementor"),
7079 position: {
7080 my: "center center",
7081 at: "center center"
7082 },
7083 strings: {
7084 confirm: (0, _wordpress_i18n.__)("Enable and Import", "elementor"),
7085 cancel: (0, _wordpress_i18n.__)("Import Without Enabling", "elementor")
7086 },
7087 onConfirm: function onConfirm() {
7088 elementorCommon.ajax.addRequest("enable_unfiltered_files_upload", { success: function success() {
7089 elementorCommon.config.filesUpload.unfilteredFiles = true;
7090 callback();
7091 } }, true);
7092 },
7093 onCancel: function onCancel() {
7094 return callback();
7095 }
7096 });
7097 }
7098 }
7099 ]);
7100 }();
7101
7102 //#endregion
7103 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-actions.js
7104 init_objectWithoutProperties$1();
7105 init_asyncToGenerator();
7106 init_defineProperty$1();
7107 var _excluded$14 = ["image"];
7108 function ownKeys$13(e, r) {
7109 var t = Object.keys(e);
7110 if (Object.getOwnPropertySymbols) {
7111 var o = Object.getOwnPropertySymbols(e);
7112 r && (o = o.filter(function(r) {
7113 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7114 })), t.push.apply(t, o);
7115 }
7116 return t;
7117 }
7118 __name(ownKeys$13, "ownKeys");
7119 function _objectSpread$13(e) {
7120 for (var r = 1; r < arguments.length; r++) {
7121 var t = null != arguments[r] ? arguments[r] : {};
7122 r % 2 ? ownKeys$13(Object(t), !0).forEach(function(r) {
7123 _defineProperty$1(e, r, t[r]);
7124 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$13(Object(t)).forEach(function(r) {
7125 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7126 });
7127 }
7128 return e;
7129 }
7130 __name(_objectSpread$13, "_objectSpread");
7131 var normalizeImageData = function normalizeImageData(imageToUpload) {
7132 if (!(imageToUpload !== null && imageToUpload !== void 0 && imageToUpload.imageUrl)) return imageToUpload;
7133 return _objectSpread$13(_objectSpread$13({}, imageToUpload), {}, {
7134 image_url: imageToUpload.imageUrl,
7135 use_gallery_image: true
7136 });
7137 };
7138 var useImageActions = function useImageActions() {
7139 var _useEditImage = useEditImage();
7140 var editImage = _useEditImage.editImage;
7141 var setEditImage = _useEditImage.setEditImage;
7142 var _useGlobalActions = useGlobalActions();
7143 var setControlValue = _useGlobalActions.setControlValue;
7144 var saveAndClose = _useGlobalActions.saveAndClose;
7145 var _useImageUpload = useImageUpload();
7146 var attachmentData = _useImageUpload.attachmentData;
7147 var isUploading = _useImageUpload.isUploading;
7148 var uploadError = _useImageUpload.uploadError;
7149 var uploadImage = _useImageUpload.upload;
7150 var resetUpload = _useImageUpload.resetUpload;
7151 var ensureSVGUploading = function ensureSVGUploading(imageUrl) {
7152 if (!imageUrl) return true;
7153 var imageExtension = new URL(imageUrl).pathname.split(".").pop();
7154 var isUploadAllowed = window._wpPluploadSettings.defaults.filters.mime_types[0].extensions.split(",").includes(imageExtension) || elementorCommon.config.filesUpload.unfilteredFiles;
7155 if (!isUploadAllowed) {
7156 var dialog = FilesUploadHandler.getUnfilteredFilesNotEnabledDialog(function() {});
7157 dialog.getElements("widget").css("z-index", "170001");
7158 dialog.show();
7159 }
7160 return isUploadAllowed;
7161 };
7162 var upload = function upload(imageToUpload, prompt) {
7163 if (!ensureSVGUploading(imageToUpload.image_url)) return Promise.reject(/* @__PURE__ */ new Error("SVG Uploading is not allowed"));
7164 return uploadImage({
7165 image: normalizeImageData(imageToUpload),
7166 prompt: prompt || imageToUpload.prompt
7167 });
7168 };
7169 var getFinalImage = /*#__PURE__*/ function() {
7170 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(imageToUpload, prompt) {
7171 var isImageAlreadyUploaded;
7172 var _result;
7173 var result;
7174 return import_regenerator$2.default.wrap(function(_context) {
7175 while (1) switch (_context.prev = _context.next) {
7176 case 0:
7177 isImageAlreadyUploaded = editImage.url === imageToUpload.url;
7178 if (!isImageAlreadyUploaded) {
7179 _context.next = 1;
7180 break;
7181 }
7182 editImage.image, _result = _objectWithoutProperties$1(editImage, _excluded$14);
7183 return _context.abrupt("return", _result);
7184 case 1:
7185 _context.next = 2;
7186 return upload(imageToUpload, prompt);
7187 case 2:
7188 result = _context.sent;
7189 return _context.abrupt("return", result === null || result === void 0 ? void 0 : result.image);
7190 case 3:
7191 case "end": return _context.stop();
7192 }
7193 }, _callee);
7194 }));
7195 return function getFinalImage(_x, _x2) {
7196 return _ref.apply(this, arguments);
7197 };
7198 }();
7199 return {
7200 use: /* @__PURE__ */ function() {
7201 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3(imageToUpload, prompt) {
7202 var result;
7203 return import_regenerator$2.default.wrap(function(_context3) {
7204 while (1) switch (_context3.prev = _context3.next) {
7205 case 0:
7206 _context3.next = 1;
7207 return getFinalImage(imageToUpload, prompt);
7208 case 1:
7209 result = _context3.sent;
7210 setControlValue(result);
7211 saveAndClose();
7212 case 2:
7213 case "end": return _context3.stop();
7214 }
7215 }, _callee3);
7216 }));
7217 return function use(_x5, _x6) {
7218 return _ref3.apply(this, arguments);
7219 };
7220 }(),
7221 edit: /* @__PURE__ */ function() {
7222 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2(imageToUpload, prompt) {
7223 var result;
7224 return import_regenerator$2.default.wrap(function(_context2) {
7225 while (1) switch (_context2.prev = _context2.next) {
7226 case 0:
7227 _context2.next = 1;
7228 return upload(imageToUpload, prompt);
7229 case 1:
7230 result = _context2.sent;
7231 setEditImage(result.image);
7232 case 2:
7233 case "end": return _context2.stop();
7234 }
7235 }, _callee2);
7236 }));
7237 return function edit(_x3, _x4) {
7238 return _ref2.apply(this, arguments);
7239 };
7240 }(),
7241 reset: resetUpload,
7242 error: uploadError,
7243 data: attachmentData,
7244 isLoading: isUploading,
7245 useMultipleImages: /* @__PURE__ */ function() {
7246 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee6(imagesToUpload) {
7247 var results;
7248 return import_regenerator$2.default.wrap(function(_context6) {
7249 while (1) switch (_context6.prev = _context6.next) {
7250 case 0:
7251 _context6.next = 1;
7252 return Promise.all(imagesToUpload.map(/*#__PURE__*/ function() {
7253 var _ref5 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee4(img) {
7254 return import_regenerator$2.default.wrap(function(_context4) {
7255 while (1) switch (_context4.prev = _context4.next) {
7256 case 0:
7257 _context4.next = 1;
7258 return getFinalImage(img, null).catch(function(_) {
7259 return null;
7260 });
7261 case 1: return _context4.abrupt("return", _context4.sent);
7262 case 2:
7263 case "end": return _context4.stop();
7264 }
7265 }, _callee4);
7266 }));
7267 return function(_x8) {
7268 return _ref5.apply(this, arguments);
7269 };
7270 }()));
7271 case 1:
7272 results = _context6.sent;
7273 _context6.next = 2;
7274 return Promise.all(results.filter(function(result) {
7275 return result;
7276 }).map(/*#__PURE__*/ function() {
7277 var _ref6 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee5(result) {
7278 return import_regenerator$2.default.wrap(function(_context5) {
7279 while (1) switch (_context5.prev = _context5.next) {
7280 case 0:
7281 _context5.next = 1;
7282 return setControlValue(result);
7283 case 1: return _context5.abrupt("return", _context5.sent);
7284 case 2:
7285 case "end": return _context5.stop();
7286 }
7287 }, _callee5);
7288 }));
7289 return function(_x9) {
7290 return _ref6.apply(this, arguments);
7291 };
7292 }()));
7293 case 2:
7294 case "end": return _context6.stop();
7295 }
7296 }, _callee6);
7297 }));
7298 return function useMultipleImages(_x7) {
7299 return _ref4.apply(this, arguments);
7300 };
7301 }()
7302 };
7303 };
7304
7305 //#endregion
7306 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/components/images-placeholder.js
7307 var ImagesPlaceholder = function ImagesPlaceholder() {
7308 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7309 sx: { overflowY: "scroll" },
7310 flexGrow: 1
7311 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7312 display: "grid",
7313 gridTemplateColumns: "repeat(2, 1fr)",
7314 gap: 3
7315 }, Array(4).fill(true).map(function(_, index) {
7316 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7317 key: "placeholder-".concat(index),
7318 display: "flex",
7319 justifyContent: "center",
7320 alignItems: "center",
7321 sx: {
7322 bgcolor: "action.selected",
7323 height: 336
7324 }
7325 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, {
7326 color: "secondary",
7327 sx: { fontSize: 36 }
7328 }));
7329 })));
7330 };
7331 ImagesPlaceholder.propTypes = {};
7332
7333 //#endregion
7334 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/index.js
7335 init_defineProperty$1();
7336 init_slicedToArray();
7337 init_prompt_history_action_context();
7338 init_prompt_library_link();
7339 init_requests_ids();
7340 function ownKeys$12(e, r) {
7341 var t = Object.keys(e);
7342 if (Object.getOwnPropertySymbols) {
7343 var o = Object.getOwnPropertySymbols(e);
7344 r && (o = o.filter(function(r) {
7345 return Object.getOwnPropertyDescriptor(e, r).enumerable;
7346 })), t.push.apply(t, o);
7347 }
7348 return t;
7349 }
7350 __name(ownKeys$12, "ownKeys");
7351 function _objectSpread$12(e) {
7352 for (var r = 1; r < arguments.length; r++) {
7353 var t = null != arguments[r] ? arguments[r] : {};
7354 r % 2 ? ownKeys$12(Object(t), !0).forEach(function(r) {
7355 _defineProperty$1(e, r, t[r]);
7356 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$12(Object(t)).forEach(function(r) {
7357 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
7358 });
7359 }
7360 return e;
7361 }
7362 __name(_objectSpread$12, "_objectSpread");
7363 var getPromptPlaceholder = function getPromptPlaceholder(images) {
7364 if (!(images !== null && images !== void 0 && images.length)) return (0, _wordpress_i18n.__)("describe your image", "elementor");
7365 return images[Math.floor(Math.random() * images.length)].prompt;
7366 };
7367 var Generate = function Generate(_ref) {
7368 var textToImageHook = _ref.textToImageHook;
7369 var _ref$predefinedPrompt = _ref.predefinedPrompt;
7370 var predefinedPrompt = _ref$predefinedPrompt === void 0 ? "" : _ref$predefinedPrompt;
7371 var _ref$initialSettings = _ref.initialSettings;
7372 var initialSettings = _ref$initialSettings === void 0 ? {} : _ref$initialSettings;
7373 var _useState2 = _slicedToArray((0, react.useState)(predefinedPrompt), 2);
7374 var prompt = _useState2[0];
7375 var setPrompt = _useState2[1];
7376 var setGenerate = useRequestIds().setGenerate;
7377 var initialImageType = useGlobalSettings().initialImageType;
7378 var _usePromptSettings = usePromptSettings(_objectSpread$12({ type: initialImageType }, initialSettings));
7379 var settings = _usePromptSettings.settings;
7380 var updateSettings = _usePromptSettings.updateSettings;
7381 var resetSettings = _usePromptSettings.resetSettings;
7382 var _useSuggestedImages = useSuggestedImages({ selectedType: settings[IMAGE_TYPE] });
7383 var suggestedImages = _useSuggestedImages.imagesData;
7384 var isPreloading = _useSuggestedImages.isLoading;
7385 var promptPlaceholder = getPromptPlaceholder(suggestedImages);
7386 var _textToImageHook = textToImageHook({});
7387 var generatedImages = _textToImageHook.data;
7388 var setResult = _textToImageHook.setResult;
7389 var send = _textToImageHook.send;
7390 var isGenerating = _textToImageHook.isLoading;
7391 var error = _textToImageHook.error;
7392 var reset = _textToImageHook.reset;
7393 var _useImageActions = useImageActions();
7394 var use = _useImageActions.use;
7395 var edit = _useImageActions.edit;
7396 var isUploading = _useImageActions.isLoading;
7397 var isLoading = isPreloading || isGenerating || isUploading;
7398 var generateAspectRatio = (0, react.useMemo)(function() {
7399 return settings[IMAGE_RATIO];
7400 }, [generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result]);
7401 var handleSubmit = function handleSubmit(event) {
7402 event.preventDefault();
7403 setGenerate();
7404 if (!settings[IMAGE_STYLE]) settings[IMAGE_STYLE] = "general";
7405 send({
7406 prompt,
7407 settings
7408 });
7409 };
7410 var handleCopyPrompt = function handleCopyPrompt(_ref2) {
7411 var selectedPrompt = _ref2.prompt;
7412 var imageType = _ref2.imageType;
7413 setPrompt(selectedPrompt);
7414 var _imageType$split2 = _slicedToArray(imageType.split("/"), 2);
7415 var type = _imageType$split2[0];
7416 var style = _imageType$split2[1];
7417 updateSettings(_defineProperty$1(_defineProperty$1({}, IMAGE_TYPE, type), IMAGE_STYLE, style));
7418 };
7419 useSubscribeOnPromptHistoryAction([{
7420 type: ACTION_TYPES.RESTORE,
7421 handler: function handler(action) {
7422 var _action$data;
7423 var _action$data2;
7424 var _action$data3;
7425 var _action$data4;
7426 handleCopyPrompt({
7427 prompt: (_action$data = action.data) === null || _action$data === void 0 ? void 0 : _action$data.prompt,
7428 imageType: ((_action$data2 = action.data) === null || _action$data2 === void 0 ? void 0 : _action$data2.imageType) || ""
7429 });
7430 updateSettings(_defineProperty$1({}, IMAGE_RATIO, (_action$data3 = action.data) === null || _action$data3 === void 0 ? void 0 : _action$data3.ratio));
7431 setResult((_action$data4 = action.data) === null || _action$data4 === void 0 ? void 0 : _action$data4.images, action.id);
7432 }
7433 }]);
7434 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
7435 primary: (0, _wordpress_i18n.__)("Imagine anything create everything", "elementor"),
7436 secondary: (0, _wordpress_i18n.__)("Generate images by selecting the desired type and style, and entering a prompt.", "elementor")
7437 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7438 error,
7439 onRetry: handleSubmit
7440 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
7441 "data-testid": "e-image-prompt",
7442 value: prompt,
7443 disabled: isLoading,
7444 placeholder: promptPlaceholder,
7445 onChange: setPrompt
7446 }), /*#__PURE__*/ react.default.createElement(ImageTypeSelect, {
7447 disabled: isLoading,
7448 value: settings[IMAGE_TYPE],
7449 onChange: function onChange(event) {
7450 return updateSettings(_defineProperty$1({}, IMAGE_TYPE, event.target.value));
7451 }
7452 }), /*#__PURE__*/ react.default.createElement(ImageStyleSelect, {
7453 type: settings[IMAGE_TYPE],
7454 value: settings[IMAGE_STYLE],
7455 disabled: isLoading || !settings[IMAGE_TYPE] || false,
7456 onChange: function onChange(event) {
7457 return updateSettings(_defineProperty$1({}, IMAGE_STYLE, event.target.value));
7458 }
7459 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
7460 disabled: isLoading,
7461 value: settings[IMAGE_RATIO],
7462 onChange: function onChange(event) {
7463 return updateSettings(_defineProperty$1({}, IMAGE_RATIO, event.target.value));
7464 }
7465 }), generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
7466 gap: 2,
7467 sx: { my: 2.5 }
7468 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading || "" === prompt }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
7469 disabled: isLoading,
7470 onClick: function onClick() {
7471 resetSettings();
7472 setPrompt("");
7473 reset();
7474 }
7475 })) : /*#__PURE__*/ react.default.createElement(GenerateImagesSubmit, { disabled: isLoading || "" === prompt }))), /*#__PURE__*/ react.default.createElement(View.Content, {
7476 isLoading: isPreloading || isUploading,
7477 isGenerating
7478 }, generatedImages !== null && generatedImages !== void 0 && generatedImages.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
7479 images: generatedImages === null || generatedImages === void 0 ? void 0 : generatedImages.result,
7480 aspectRatio: generateAspectRatio,
7481 onUseImage: use,
7482 onEditImage: edit
7483 }) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, predefinedPrompt ? /*#__PURE__*/ react.default.createElement(ImagesPlaceholder, null) : /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(View.ContentHeading, { primary: (0, _wordpress_i18n.__)("Spark your imagination with images generated by our community", "elementor") }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { mb: 3 } }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: "https://go.elementor.com/ai-prompt-library-image/" })), /*#__PURE__*/ react.default.createElement(Gallery, { cols: 3 }, suggestedImages === null || suggestedImages === void 0 ? void 0 : suggestedImages.map(function(suggestedPrompt) {
7484 return /*#__PURE__*/ react.default.createElement(Gallery.Image, {
7485 variant: "thumbnail",
7486 key: suggestedPrompt.prompt,
7487 alt: suggestedPrompt.prompt,
7488 text: suggestedPrompt.prompt,
7489 src: suggestedPrompt.thumbnailUrl
7490 }, /*#__PURE__*/ react.default.createElement(ImageActions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
7491 onClick: function onClick() {
7492 return use(suggestedPrompt);
7493 },
7494 fullWidth: true
7495 }), /*#__PURE__*/ react.default.createElement(ImageActions.CopyIcon, { onClick: function onClick() {
7496 return handleCopyPrompt(suggestedPrompt);
7497 } }), /*#__PURE__*/ react.default.createElement(ImageActions.EditIcon, { onClick: function onClick() {
7498 return edit(suggestedPrompt);
7499 } })));
7500 }))))));
7501 };
7502 Generate.propTypes = {
7503 predefinedPrompt: import_prop_types$7.default.string,
7504 textToImageHook: import_prop_types$7.default.func,
7505 initialSettings: import_prop_types$7.default.object
7506 };
7507
7508 //#endregion
7509 //#region modules/ai/assets/js/editor/icons/expand-icon.js
7510 init_extends();
7511 var ExpandIcon$1 = react.default.forwardRef(function(props, ref) {
7512 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7513 fillRule: "evenodd",
7514 clipRule: "evenodd",
7515 d: "M16 3.25C15.5858 3.25 15.25 3.58579 15.25 4C15.25 4.41421 15.5858 4.75 16 4.75H18.1893L13.4697 9.46967C13.1768 9.76256 13.1768 10.2374 13.4697 10.5303C13.7626 10.8232 14.2374 10.8232 14.5303 10.5303L19.25 5.81066V8C19.25 8.41421 19.5858 8.75 20 8.75C20.4142 8.75 20.75 8.41421 20.75 8V4C20.75 3.80806 20.6768 3.61612 20.5303 3.46967C20.4584 3.39776 20.3755 3.34351 20.2871 3.30691C20.1987 3.27024 20.1017 3.25 20 3.25H16ZM4 15.25C4.41421 15.25 4.75 15.5858 4.75 16V18.1893L9.46967 13.4697C9.76256 13.1768 10.2374 13.1768 10.5303 13.4697C10.8232 13.7626 10.8232 14.2374 10.5303 14.5303L5.81066 19.25H8C8.41421 19.25 8.75 19.5858 8.75 20C8.75 20.4142 8.41421 20.75 8 20.75H4C3.80806 20.75 3.61612 20.6768 3.46967 20.5303C3.39776 20.4584 3.34351 20.3755 3.30691 20.2871C3.27024 20.1987 3.25 20.1017 3.25 20V16C3.25 15.5858 3.58579 15.25 4 15.25ZM20.75 16V20C20.75 20.1017 20.7298 20.1987 20.6931 20.2871C20.6565 20.3755 20.6022 20.4584 20.5303 20.5303C20.4584 20.6022 20.3755 20.6565 20.2871 20.6931C20.2099 20.7251 20.1262 20.7446 20.0386 20.749C20.0258 20.7497 20.0129 20.75 20 20.75H16C15.5858 20.75 15.25 20.4142 15.25 20C15.25 19.5858 15.5858 19.25 16 19.25H18.1893L13.4697 14.5303C13.1768 14.2374 13.1768 13.7626 13.4697 13.4697C13.7626 13.1768 14.2374 13.1768 14.5303 13.4697L19.25 18.1893V16C19.25 15.5858 19.5858 15.25 20 15.25C20.4142 15.25 20.75 15.5858 20.75 16ZM3.71291 3.30691C3.80134 3.27024 3.89831 3.25 4 3.25H8C8.41421 3.25 8.75 3.58579 8.75 4C8.75 4.41421 8.41421 4.75 8 4.75H5.81066L10.5303 9.46967C10.8232 9.76256 10.8232 10.2374 10.5303 10.5303C10.2374 10.8232 9.76256 10.8232 9.46967 10.5303L4.75 5.81066V8C4.75 8.41421 4.41421 8.75 4 8.75C3.58579 8.75 3.25 8.41421 3.25 8V4C3.25 3.7937 3.33329 3.60686 3.46808 3.47126C3.46861 3.47073 3.46914 3.4702 3.46967 3.46967C3.4702 3.46914 3.47073 3.46861 3.47126 3.46808C3.5428 3.39696 3.62511 3.34324 3.71291 3.30691Z"
7516 }));
7517 });
7518
7519 //#endregion
7520 //#region modules/ai/assets/js/editor/icons/brush-icon.js
7521 init_extends();
7522 var BrushIcon = react.default.forwardRef(function(props, ref) {
7523 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7524 fillRule: "evenodd",
7525 clipRule: "evenodd",
7526 d: "M20.8815 2.25919C20.9203 2.25301 20.9599 2.24983 21 2.24988C21.0827 2.24978 21.1629 2.26335 21.2384 2.2887C21.367 2.33162 21.4784 2.40776 21.5642 2.5058C21.6895 2.64891 21.76 2.83868 21.749 3.03992C21.7477 3.06492 21.7452 3.08966 21.7414 3.11407C21.3311 6.09743 20.124 8.91507 18.2472 11.2703C16.5079 13.4529 14.2532 15.1635 11.6906 16.2509C11.8289 17.1168 11.7249 18.0054 11.3884 18.8177C11.0289 19.6857 10.4201 20.4275 9.63896 20.9495C8.85782 21.4714 7.93946 21.75 7 21.75H3C2.58579 21.75 2.25 21.4142 2.25 21V17C2.25 16.0605 2.52858 15.1421 3.05052 14.361C3.57246 13.5799 4.3143 12.9711 5.18225 12.6115C5.99455 12.2751 6.88314 12.1711 7.74905 12.3094C8.83643 9.74682 10.547 7.49212 12.7296 5.75287C15.0837 3.87693 17.8998 2.67012 20.8815 2.25919ZM10.0984 16.0649C10.077 16.0082 10.0629 15.9506 10.0557 15.893C9.89413 15.4471 9.63624 15.04 9.2981 14.7019C8.96001 14.3638 8.55301 14.1059 8.10721 13.9444C8.04953 13.9372 7.99178 13.9231 7.93499 13.9016C7.90509 13.8903 7.87632 13.8773 7.84877 13.8628C7.77794 13.8436 7.70633 13.8268 7.63404 13.8124C7.0036 13.687 6.35014 13.7514 5.75628 13.9974C5.16242 14.2433 4.65484 14.6599 4.29772 15.1944C3.94061 15.7288 3.75 16.3572 3.75 17V20.25H7C7.64279 20.25 8.27114 20.0594 8.8056 19.7022C9.34006 19.3451 9.75662 18.8376 10.0026 18.2437C10.2486 17.6498 10.313 16.9964 10.1876 16.3659C10.1732 16.2935 10.1563 16.2218 10.1371 16.1509C10.1226 16.1234 10.1097 16.0947 10.0984 16.0649ZM10.3588 13.6412C10.7069 13.9894 10.9969 14.3876 11.2204 14.8204C12.2258 14.3839 13.1782 13.8417 14.0621 13.2048C13.3066 11.827 12.173 10.6933 10.7952 9.93782C10.1583 10.8218 9.61603 11.7741 9.17957 12.7795C9.61238 13.0031 10.0106 13.293 10.3588 13.6412ZM11.7434 8.75107C13.1943 9.59789 14.4021 10.8057 15.2489 12.2565C15.9093 11.6727 16.5204 11.0304 17.0741 10.3355C18.5698 8.45849 19.5983 6.25889 20.0821 3.9179C17.7411 4.40165 15.5415 5.43018 13.6644 6.92595C12.9696 7.47964 12.3273 8.0907 11.7434 8.75107Z"
7527 }));
7528 });
7529
7530 //#endregion
7531 //#region modules/ai/assets/js/editor/icons/evolve-icon.js
7532 init_extends();
7533 var EvolveIcon = react.default.forwardRef(function(props, ref) {
7534 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7535 fillRule: "evenodd",
7536 clipRule: "evenodd",
7537 d: "M2.30691 2.71291C2.27024 2.80134 2.25 2.89831 2.25 3V8C2.25 8.41421 2.58579 8.75 3 8.75C3.41421 8.75 3.75 8.41421 3.75 8V4.81066L10.0056 11.0663L10.0057 11.0663C10.8022 11.8631 11.2497 12.9434 11.25 14.07V14.0702V15V21C11.25 21.4142 11.5858 21.75 12 21.75C12.4142 21.75 12.75 21.4142 12.75 21V15V14.0702V14.07C12.7503 12.9434 13.1979 11.863 13.9944 11.0663L20.25 4.81066V8C20.25 8.41421 20.5858 8.75 21 8.75C21.4142 8.75 21.75 8.41421 21.75 8V3C21.75 2.98706 21.7497 2.97419 21.749 2.96141C21.7446 2.87376 21.7251 2.79009 21.6931 2.71291C21.6565 2.62445 21.6022 2.54158 21.5303 2.46967C21.4584 2.39776 21.3755 2.34351 21.2871 2.30691C21.1987 2.27024 21.1017 2.25 21 2.25H16C15.5858 2.25 15.25 2.58579 15.25 3C15.25 3.41421 15.5858 3.75 16 3.75H19.1893L12.9337 10.0057L12.9336 10.0057C12.5656 10.3739 12.2526 10.7867 12 11.2316C11.7474 10.7867 11.4344 10.3739 11.0664 10.0057L11.0663 10.0057L4.81066 3.75H8C8.41421 3.75 8.75 3.41421 8.75 3C8.75 2.58579 8.41421 2.25 8 2.25H3C2.7937 2.25 2.60686 2.33329 2.47126 2.46808C2.47073 2.46861 2.4702 2.46914 2.46967 2.46967C2.46914 2.4702 2.46861 2.47073 2.46808 2.47126C2.39696 2.5428 2.34324 2.62511 2.30691 2.71291Z"
7538 }));
7539 });
7540
7541 //#endregion
7542 //#region modules/ai/assets/js/editor/icons/enlarger-icon.js
7543 init_extends();
7544 var ExpandIcon = react.default.forwardRef(function(props, ref) {
7545 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7546 fillRule: "evenodd",
7547 clipRule: "evenodd",
7548 d: "M5.11612 5.11612C5.35054 4.8817 5.66848 4.75 6 4.75H18C18.3315 4.75 18.6495 4.8817 18.8839 5.11612C19.1183 5.35054 19.25 5.66848 19.25 6V18C19.25 18.3315 19.1183 18.6495 18.8839 18.8839C18.6495 19.1183 18.3315 19.25 18 19.25H11.7335C11.7444 19.1709 11.75 19.0908 11.75 19.01V14.01C11.75 13.8051 11.7141 13.604 11.6457 13.4149L16.25 8.81066V11C16.25 11.4142 16.5858 11.75 17 11.75C17.4142 11.75 17.75 11.4142 17.75 11V7C17.75 6.89831 17.7298 6.80134 17.6931 6.71291C17.6565 6.62445 17.6022 6.54158 17.5303 6.46967C17.4584 6.39776 17.3755 6.34351 17.2871 6.30691C17.1993 6.27051 17.1031 6.2503 17.0022 6.25C17.0015 6.25 17.0007 6.25 17 6.25H16.9997H13C12.5858 6.25 12.25 6.58579 12.25 7C12.25 7.41421 12.5858 7.75 13 7.75H15.1893L10.5803 12.359C10.3956 12.2941 10.1995 12.26 10 12.26H5C4.91585 12.26 4.83232 12.2661 4.75 12.278V6C4.75 5.66848 4.8817 5.35054 5.11612 5.11612ZM4.75 14.01V18C4.75 18.3315 4.8817 18.6495 5.11612 18.8839C5.35054 19.1183 5.66848 19.25 6 19.25H10.07C10.11 19.2383 10.1468 19.2168 10.1768 19.1868C10.2237 19.1399 10.25 19.0763 10.25 19.01V14.01C10.25 13.9437 10.2237 13.8801 10.1768 13.8332C10.1299 13.7863 10.0663 13.76 10 13.76H5C4.9337 13.76 4.87011 13.7863 4.82322 13.8332C4.77634 13.8801 4.75 13.9437 4.75 14.01ZM3.25 14.01V6C3.25 5.27065 3.53973 4.57118 4.05546 4.05546C4.57118 3.53973 5.27065 3.25 6 3.25H18C18.7293 3.25 19.4288 3.53973 19.9445 4.05546C20.4603 4.57118 20.75 5.27065 20.75 6V18C20.75 18.7293 20.4603 19.4288 19.9445 19.9445C19.4288 20.4603 18.7293 20.75 18 20.75H10.187C10.1251 20.7566 10.0627 20.76 10 20.76H5C4.53587 20.76 4.09075 20.5756 3.76256 20.2474C3.43438 19.9193 3.25 19.4741 3.25 19.01V18V14.01Z"
7549 }));
7550 });
7551
7552 //#endregion
7553 //#region modules/ai/assets/js/editor/icons/remove-bg.js
7554 init_extends();
7555 var RemoveBackgroundIcon = react.default.forwardRef(function(props, ref) {
7556 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M5.74996 2.50038C5.74996 2.2242 5.52607 2.00031 5.24989 2.00031C4.9737 2.00031 4.74981 2.2242 4.74981 2.50038V2.50705C4.74981 2.78323 4.9737 3.00712 5.24989 3.00712C5.52607 3.00712 5.74996 2.78323 5.74996 2.50705V2.50038Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M7.9997 2.00031C8.27588 2.00031 8.49978 2.2242 8.49978 2.50038V2.50705C8.49978 2.78323 8.27588 3.00712 7.9997 3.00712C7.72352 3.00712 7.49963 2.78323 7.49963 2.50705V2.50038C7.49963 2.2242 7.72352 2.00031 7.9997 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M11.2496 2.50038C11.2496 2.2242 11.0257 2.00031 10.7495 2.00031C10.4733 2.00031 10.2494 2.2242 10.2494 2.50038V2.50705C10.2494 2.78323 10.4733 3.00712 10.7495 3.00712C11.0257 3.00712 11.2496 2.78323 11.2496 2.50705V2.50038Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.4993 2.00031C13.7755 2.00031 13.9994 2.2242 13.9994 2.50038V2.50705C13.9994 2.78323 13.7755 3.00712 13.4993 3.00712C13.2231 3.00712 12.9993 2.78323 12.9993 2.50705V2.50038C12.9993 2.2242 13.2231 2.00031 13.4993 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.9994 5.25019C13.9994 4.97401 13.7755 4.75012 13.4993 4.75012C13.2231 4.75012 12.9993 4.97401 12.9993 5.25019V5.25686C12.9993 5.53304 13.2231 5.75694 13.4993 5.75694C13.7755 5.75694 13.9994 5.53304 13.9994 5.25686V5.25019Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M13.9994 8.00001C13.9994 7.72382 13.7755 7.49993 13.4993 7.49993C13.2231 7.49993 12.9993 7.72382 12.9993 8.00001V8.00667C12.9993 8.28286 13.2231 8.50675 13.4993 8.50675C13.7755 8.50675 13.9994 8.28286 13.9994 8.00667V8.00001Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M2.50007 7.49993C2.77626 7.49993 3.00015 7.72382 3.00015 8.00001V8.00667C3.00015 8.28286 2.77626 8.50675 2.50007 8.50675C2.22389 8.50675 2 8.28286 2 8.00667V8.00001C2 7.72382 2.22389 7.49993 2.50007 7.49993Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M3.00015 5.25019C3.00015 4.97401 2.77626 4.75012 2.50007 4.75012C2.22389 4.75012 2 4.97401 2 5.25019V5.25686C2 5.53304 2.22389 5.75694 2.50007 5.75694C2.77626 5.75694 3.00015 5.53304 3.00015 5.25686V5.25019Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M2.50007 2.00031C2.77626 2.00031 3.00015 2.2242 3.00015 2.50038V2.50705C3.00015 2.78323 2.77626 3.00712 2.50007 3.00712C2.22389 3.00712 2 2.78323 2 2.50705V2.50038C2 2.2242 2.22389 2.00031 2.50007 2.00031Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.37461 7.31255C9.94411 7.31255 10.4058 6.85088 10.4058 6.28137C10.4058 5.71187 9.94411 5.25019 9.37461 5.25019C8.8051 5.25019 8.34343 5.71187 8.34343 6.28137C8.34343 6.85088 8.8051 7.31255 9.37461 7.31255Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.37461 9.21061L7.6724 7.44357L7.66567 7.43672C7.27331 7.04478 6.79598 6.81248 6.28107 6.81248C5.76615 6.81248 5.28883 7.04478 4.89647 7.43672L4.88973 7.44358L2.13992 10.2982C2.05015 10.3913 2 10.5157 2 10.6451V13.4996C2 13.7758 2.22389 13.9997 2.50007 13.9997H13.4993C13.7755 13.9997 13.9994 13.7758 13.9994 13.4996V10.6451C13.9994 10.6365 13.9992 10.6279 13.9988 10.6194C13.9958 10.562 13.9833 10.5072 13.9627 10.4566C13.9409 10.403 13.9093 10.3523 13.8681 10.3073C13.8651 10.304 13.8621 10.3008 13.859 10.2976L12.4846 8.87085L12.4778 8.86399C12.0855 8.47205 11.6082 8.23975 11.0932 8.23975C10.5783 8.23975 10.101 8.47205 9.70864 8.86399L9.70191 8.87084L9.37461 9.21061ZM5.60649 8.14113L3.00015 10.8468V12.9996H12.9993V10.8468L11.7678 9.5684C11.5234 9.32549 11.2897 9.2399 11.0932 9.2399C10.8968 9.2399 10.6631 9.32549 10.4187 9.5684L10.069 9.93142L11.1097 11.0118C11.3013 11.2107 11.2954 11.5272 11.0965 11.7188C10.8975 11.9104 10.581 11.9045 10.3894 11.7056L9.01604 10.28C9.01482 10.2787 9.01361 10.2775 9.01241 10.2762L6.95564 8.14113C6.7112 7.89822 6.4775 7.81263 6.28107 7.81263C6.08463 7.81263 5.85094 7.89822 5.60649 8.14113Z" }));
7557 });
7558
7559 //#endregion
7560 //#region modules/ai/assets/js/editor/icons/replace-bg.js
7561 init_extends();
7562 var ReplaceBackgroundIcon = react.default.forwardRef(function(props, ref) {
7563 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M4.35355 1.64645C4.54882 1.84171 4.54882 2.15829 4.35355 2.35355L2.35355 4.35355C2.15829 4.54882 1.84171 4.54882 1.64645 4.35355C1.45118 4.15829 1.45118 3.84171 1.64645 3.64645L3.64645 1.64645C3.84171 1.45118 4.15829 1.45118 4.35355 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M7.68689 1.64645C7.88215 1.84171 7.88215 2.15829 7.68689 2.35355L2.35355 7.68689C2.15829 7.88215 1.84171 7.88215 1.64645 7.68689C1.45118 7.49162 1.45118 7.17504 1.64645 6.97978L6.97978 1.64645C7.17504 1.45118 7.49162 1.45118 7.68689 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M11.0202 1.64645C11.2155 1.84171 11.2155 2.15829 11.0202 2.35355L6.68689 6.68689C6.49162 6.88215 6.17504 6.88215 5.97978 6.68689C5.78452 6.49162 5.78452 6.17504 5.97978 5.97978L10.3131 1.64645C10.5084 1.45118 10.825 1.45118 11.0202 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 1.64645C14.5488 1.84171 14.5488 2.15829 14.3536 2.35355L11.0202 5.68689C10.825 5.88215 10.5084 5.88215 10.3131 5.68689C10.1179 5.49162 10.1179 5.17504 10.3131 4.97978L13.6464 1.64645C13.8417 1.45118 14.1583 1.45118 14.3536 1.64645Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 4.97978C14.5488 5.17504 14.5488 5.49162 14.3536 5.68689L12.0202 8.02022C11.825 8.21548 11.5084 8.21548 11.3131 8.02022C11.1179 7.82496 11.1179 7.50838 11.3131 7.31311L13.6464 4.97978C13.8417 4.78452 14.1583 4.78452 14.3536 4.97978Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M14.3536 8.31311C14.5488 8.50838 14.5488 8.82496 14.3536 9.02022L14.0202 9.35355C13.825 9.54882 13.5084 9.54882 13.3131 9.35355C13.1179 9.15829 13.1179 8.84171 13.3131 8.64645L13.6464 8.31311C13.8417 8.11785 14.1583 8.11785 14.3536 8.31311Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M10.3333 7C10.3333 7.55228 9.88562 8 9.33333 8C8.78105 8 8.33333 7.55228 8.33333 7C8.33333 6.44772 8.78105 6 9.33333 6C9.88562 6 10.3333 6.44772 10.3333 7Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M6.33333 8.5C6.14679 8.5 5.92267 8.58153 5.6867 8.81725C5.67587 8.82806 5.66455 8.83838 5.65278 8.84816L2.5 11.4665V13.5H13.5V11.2318C13.5 10.9556 13.7239 10.7318 14 10.7318C14.2761 10.7318 14.5 10.9556 14.5 11.2318V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V11.2318C1.5 11.0831 1.56617 10.9421 1.68056 10.8471L4.99717 8.09274C5.37661 7.72073 5.83674 7.5 6.33333 7.5C6.83746 7.5 7.304 7.72747 7.6867 8.10976L7.69343 8.11662L11.0268 11.5769C11.2183 11.7758 11.2124 12.0923 11.0136 12.2839C10.8147 12.4755 10.4981 12.4696 10.3066 12.2707L6.97679 8.81408C6.74199 8.5808 6.51904 8.5 6.33333 8.5Z" }), /*#__PURE__*/ react.default.createElement("path", { d: "M10.3564 10.1984L9.69343 10.8866C9.50185 11.0854 9.18532 11.0914 8.98645 10.8998C8.78757 10.7082 8.78166 10.3917 8.97324 10.1928L9.6399 9.50073L9.64663 9.49387C10.4992 8.64223 11.843 8.83788 12.6387 9.45172C12.6435 9.45538 12.6482 9.45913 12.6528 9.46297L14.3194 10.8471C14.5319 11.0235 14.5611 11.3388 14.3846 11.5512C14.2082 11.7636 13.893 11.7928 13.6806 11.6164L12.0213 10.2384C11.4855 9.82976 10.7405 9.81862 10.3564 10.1984Z" }));
7564 });
7565
7566 //#endregion
7567 //#region modules/ai/assets/js/editor/icons/cleanup-icon.js
7568 init_extends();
7569 var Cleanup$1 = react.default.forwardRef(function(props, ref) {
7570 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7571 fillRule: "evenodd",
7572 clipRule: "evenodd",
7573 d: "M10.6668 11.8334H3.66679C3.53235 11.8334 3.40357 11.7792 3.30952 11.6832L0.505518 8.81921L0.504041 8.81772C0.287672 8.59928 0.16626 8.30423 0.16626 7.99671C0.16626 7.68849 0.288225 7.3928 0.505518 7.17421L0.506568 7.17316L7.17323 0.506492L7.17429 0.505442C7.39288 0.288149 7.68857 0.166183 7.99679 0.166183C8.30501 0.166183 8.6007 0.288149 8.81929 0.505442L8.82034 0.50649L12.1547 3.84088C12.372 4.05947 12.494 4.35516 12.494 4.66338C12.494 4.97134 12.3722 5.26679 12.1553 5.48533L12.1547 5.48588L6.86473 10.8334H10.6668C10.9429 10.8334 11.1668 11.0572 11.1668 11.3334C11.1668 11.6095 10.9429 11.8334 10.6668 11.8334ZM7.87959 1.21435C7.91079 1.18349 7.9529 1.16618 7.99679 1.16618C8.04067 1.16618 8.08278 1.18349 8.11398 1.21434L11.4455 4.54588C11.4763 4.57707 11.494 4.61951 11.494 4.66338C11.494 4.70741 11.4766 4.74965 11.4455 4.78088L11.4447 4.78174L10.0411 6.20059L6.46721 2.62673L7.87959 1.21435ZM5.7601 3.33383L1.21473 7.87921C1.18387 7.91041 1.16626 7.95282 1.16626 7.99671C1.16626 8.04074 1.18368 8.08298 1.21473 8.11421L1.2174 8.11691L3.877 10.8334H5.4581L9.33779 6.91152L5.7601 3.33383Z"
7574 }));
7575 });
7576
7577 //#endregion
7578 //#region modules/ai/assets/js/editor/icons/isolate-object-icon.js
7579 init_extends();
7580 var IsolateObjectIcon = react.default.forwardRef(function(props, ref) {
7581 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 16 16" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
7582 fillRule: "evenodd",
7583 clipRule: "evenodd",
7584 d: "M2.6665 2.16699C2.94265 2.16699 3.1665 2.39085 3.1665 2.66699V2.67366C3.1665 2.9498 2.94265 3.17366 2.6665 3.17366C2.39036 3.17366 2.1665 2.9498 2.1665 2.67366V2.66699C2.1665 2.39085 2.39036 2.16699 2.6665 2.16699ZM5.33317 2.16699C5.60931 2.16699 5.83317 2.39085 5.83317 2.66699V2.67366C5.83317 2.9498 5.60931 3.17366 5.33317 3.17366C5.05703 3.17366 4.83317 2.9498 4.83317 2.67366V2.66699C4.83317 2.39085 5.05703 2.16699 5.33317 2.16699ZM7.99984 2.16699C8.27598 2.16699 8.49984 2.39085 8.49984 2.66699V2.67366C8.49984 2.9498 8.27598 3.17366 7.99984 3.17366C7.72369 3.17366 7.49984 2.9498 7.49984 2.67366V2.66699C7.49984 2.39085 7.72369 2.16699 7.99984 2.16699ZM10.6665 2.16699C10.9426 2.16699 11.1665 2.39085 11.1665 2.66699V2.67366C11.1665 2.9498 10.9426 3.17366 10.6665 3.17366C10.3904 3.17366 10.1665 2.9498 10.1665 2.67366V2.66699C10.1665 2.39085 10.3904 2.16699 10.6665 2.16699ZM13.3332 2.16699C13.6093 2.16699 13.8332 2.39085 13.8332 2.66699V2.67366C13.8332 2.9498 13.6093 3.17366 13.3332 3.17366C13.057 3.17366 12.8332 2.9498 12.8332 2.67366V2.66699C12.8332 2.39085 13.057 2.16699 13.3332 2.16699ZM2.6665 4.83366C2.94265 4.83366 3.1665 5.05752 3.1665 5.33366V5.34033C3.1665 5.61647 2.94265 5.84033 2.6665 5.84033C2.39036 5.84033 2.1665 5.61647 2.1665 5.34033V5.33366C2.1665 5.05752 2.39036 4.83366 2.6665 4.83366ZM4.83317 5.33366C4.83317 5.05752 5.05703 4.83366 5.33317 4.83366H10.6665C10.9426 4.83366 11.1665 5.05752 11.1665 5.33366V10.667C11.1665 10.9431 10.9426 11.167 10.6665 11.167H5.33317C5.05703 11.167 4.83317 10.9431 4.83317 10.667V5.33366ZM5.83317 5.83366V10.167H10.1665V5.83366H5.83317ZM13.3332 4.83366C13.6093 4.83366 13.8332 5.05752 13.8332 5.33366V5.34033C13.8332 5.61647 13.6093 5.84033 13.3332 5.84033C13.057 5.84033 12.8332 5.61647 12.8332 5.34033V5.33366C12.8332 5.05752 13.057 4.83366 13.3332 4.83366ZM2.6665 7.50033C2.94265 7.50033 3.1665 7.72418 3.1665 8.00033V8.00699C3.1665 8.28313 2.94265 8.50699 2.6665 8.50699C2.39036 8.50699 2.1665 8.28313 2.1665 8.00699V8.00033C2.1665 7.72418 2.39036 7.50033 2.6665 7.50033ZM13.3332 7.50033C13.6093 7.50033 13.8332 7.72418 13.8332 8.00033V8.00699C13.8332 8.28313 13.6093 8.50699 13.3332 8.50699C13.057 8.50699 12.8332 8.28313 12.8332 8.00699V8.00033C12.8332 7.72418 13.057 7.50033 13.3332 7.50033ZM2.6665 10.167C2.94265 10.167 3.1665 10.3908 3.1665 10.667V10.6737C3.1665 10.9498 2.94265 11.1737 2.6665 11.1737C2.39036 11.1737 2.1665 10.9498 2.1665 10.6737V10.667C2.1665 10.3908 2.39036 10.167 2.6665 10.167ZM13.3332 10.167C13.6093 10.167 13.8332 10.3908 13.8332 10.667V10.6737C13.8332 10.9498 13.6093 11.1737 13.3332 11.1737C13.057 11.1737 12.8332 10.9498 12.8332 10.6737V10.667C12.8332 10.3908 13.057 10.167 13.3332 10.167ZM2.6665 12.8337C2.94265 12.8337 3.1665 13.0575 3.1665 13.3337V13.3403C3.1665 13.6165 2.94265 13.8403 2.6665 13.8403C2.39036 13.8403 2.1665 13.6165 2.1665 13.3403V13.3337C2.1665 13.0575 2.39036 12.8337 2.6665 12.8337ZM5.33317 12.8337C5.60931 12.8337 5.83317 13.0575 5.83317 13.3337V13.3403C5.83317 13.6165 5.60931 13.8403 5.33317 13.8403C5.05703 13.8403 4.83317 13.6165 4.83317 13.3403V13.3337C4.83317 13.0575 5.05703 12.8337 5.33317 12.8337ZM7.99984 12.8337C8.27598 12.8337 8.49984 13.0575 8.49984 13.3337V13.3403C8.49984 13.6165 8.27598 13.8403 7.99984 13.8403C7.72369 13.8403 7.49984 13.6165 7.49984 13.3403V13.3337C7.49984 13.0575 7.72369 12.8337 7.99984 12.8337ZM10.6665 12.8337C10.9426 12.8337 11.1665 13.0575 11.1665 13.3337V13.3403C11.1665 13.6165 10.9426 13.8403 10.6665 13.8403C10.3904 13.8403 10.1665 13.6165 10.1665 13.3403V13.3337C10.1665 13.0575 10.3904 12.8337 10.6665 12.8337ZM13.3332 12.8337C13.6093 12.8337 13.8332 13.0575 13.8332 13.3337V13.3403C13.8332 13.6165 13.6093 13.8403 13.3332 13.8403C13.057 13.8403 12.8332 13.6165 12.8332 13.3403V13.3337C12.8332 13.0575 13.057 12.8337 13.3332 12.8337Z"
7585 }));
7586 });
7587
7588 //#endregion
7589 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-panel.js
7590 init_use_introduction();
7591 var TeaserDrawing = function TeaserDrawing() {
7592 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, {
7593 viewBox: "0 0 184 80",
7594 sx: {
7595 width: 184,
7596 height: 80
7597 }
7598 }, /*#__PURE__*/ react.default.createElement("g", { clipPath: "url(#clip0_3127_96542)" }, /*#__PURE__*/ react.default.createElement("path", {
7599 fillRule: "evenodd",
7600 clipRule: "evenodd",
7601 d: "M49.6014 1.36364C49.6014 0.610521 48.9907 0 48.2373 0C47.4839 0 46.8731 0.610521 46.8731 1.36364C46.8731 1.9664 46.6336 2.54448 46.2072 2.9707C45.7808 3.39692 45.2025 3.63636 44.5995 3.63636C43.8461 3.63636 43.2354 4.24689 43.2354 5C43.2354 5.75311 43.8461 6.36364 44.5995 6.36364C45.2025 6.36364 45.7808 6.60308 46.2072 7.0293C46.6336 7.45552 46.8731 8.0336 46.8731 8.63636C46.8731 9.38948 47.4839 10 48.2373 10C48.9907 10 49.6014 9.38948 49.6014 8.63636C49.6014 8.0336 49.8409 7.45552 50.2673 7.0293C50.6937 6.60308 51.272 6.36364 51.875 6.36364C52.6284 6.36364 53.2392 5.75311 53.2392 5C53.2392 4.24689 52.6284 3.63636 51.875 3.63636C51.272 3.63636 50.6937 3.39692 50.2673 2.9707C49.8409 2.54448 49.6014 1.9664 49.6014 1.36364ZM48.1364 4.89917C48.1706 4.86501 48.2042 4.83041 48.2373 4.79538C48.2703 4.83041 48.304 4.86501 48.3381 4.89917C48.3723 4.93333 48.4069 4.96694 48.4419 5C48.4069 5.03306 48.3723 5.06667 48.3381 5.10083C48.304 5.13499 48.2703 5.16959 48.2373 5.20462C48.2042 5.16959 48.1706 5.13499 48.1364 5.10083C48.1022 5.06667 48.0676 5.03306 48.0326 5C48.0676 4.96694 48.1022 4.93333 48.1364 4.89917Z",
7602 fill: "#69727D"
7603 }), /*#__PURE__*/ react.default.createElement("path", {
7604 fillRule: "evenodd",
7605 clipRule: "evenodd",
7606 d: "M66.6927 22.3677C66.6927 21.6177 66.082 21.0098 65.3286 21.0098C64.5752 21.0098 63.9644 21.6177 63.9644 22.3677C63.9644 22.9679 63.7249 23.5436 63.2985 23.968C62.8721 24.3924 62.2938 24.6309 61.6908 24.6309C60.9374 24.6309 60.3267 25.2388 60.3267 25.9888C60.3267 26.7387 60.9374 27.3467 61.6908 27.3467C62.2938 27.3467 62.8721 27.5851 63.2985 28.0096C63.7249 28.434 63.9644 29.0096 63.9644 29.6099C63.9644 30.3598 64.5752 30.9678 65.3286 30.9678C66.082 30.9678 66.6927 30.3598 66.6927 29.6099C66.6927 29.0096 66.9323 28.434 67.3586 28.0096C67.785 27.5851 68.3633 27.3467 68.9663 27.3467C69.7197 27.3467 70.3305 26.7387 70.3305 25.9888C70.3305 25.2388 69.7197 24.6309 68.9663 24.6309C68.3633 24.6309 67.785 24.3924 67.3586 23.968C66.9323 23.5436 66.6927 22.9679 66.6927 22.3677ZM65.2277 25.8884C65.2619 25.8544 65.2955 25.8199 65.3286 25.785C65.3616 25.8199 65.3953 25.8544 65.4294 25.8884C65.4636 25.9224 65.4982 25.9559 65.5333 25.9888C65.4982 26.0217 65.4636 26.0552 65.4294 26.0892C65.3953 26.1232 65.3616 26.1577 65.3286 26.1925C65.2955 26.1577 65.2619 26.1232 65.2277 26.0892C65.1935 26.0552 65.1589 26.0217 65.1239 25.9888C65.1589 25.9559 65.1935 25.9224 65.2277 25.8884Z",
7607 fill: "#69727D"
7608 }), /*#__PURE__*/ react.default.createElement("path", {
7609 d: "M53.9717 12L57.2198 17.0456L3.24796 51.4731L-0.000164873 46.4275L53.9717 12Z",
7610 fill: "#69727D"
7611 }), /*#__PURE__*/ react.default.createElement("path", {
7612 d: "M64.9761 5L68.2242 10.0456L57.2612 17.0387L54.013 11.9931L64.9761 5Z",
7613 fill: "#E6E8EA"
7614 }), /*#__PURE__*/ react.default.createElement("path", {
7615 fillRule: "evenodd",
7616 clipRule: "evenodd",
7617 d: "M65.7284 9.49923L64.432 7.48537L56.5088 12.5394L57.8052 14.5533L65.7284 9.49923ZM64.9761 5L54.013 11.9931L57.2612 17.0387L68.2242 10.0456L64.9761 5Z",
7618 fill: "#69727D"
7619 }), /*#__PURE__*/ react.default.createElement("path", {
7620 fillRule: "evenodd",
7621 clipRule: "evenodd",
7622 d: "M128 41C128 43.7687 121.671 46.2089 112.052 47.6451L114.482 74.7976C114.494 74.8647 114.5 74.9322 114.5 75C114.5 75.0001 114.5 75.0002 114.5 75.0003C114.513 75.1456 114.487 75.2779 114.43 75.3982C113.514 77.9735 103.8 80 91.95 80C79.496 80 69.4 77.7614 69.4 75C69.4 74.8146 69.4456 74.6315 69.5343 74.4513L71.2141 47.5326C62.0087 46.0835 56 43.6977 56 41C56 36.5817 72.1177 33 92 33C111.882 33 128 36.5817 128 41Z",
7623 fill: "#69727D"
7624 }), /*#__PURE__*/ react.default.createElement("path", {
7625 d: "M106.685 3.08259C112.562 16.564 109.338 34.1761 106.713 41.4407C106.713 41.4407 105.151 41.9127 100.894 41.9715C96.6371 42.0303 95.0251 41.9866 95.0251 41.4558C95.0252 40.9249 94.6272 34.6461 96.4177 22.3308C98.0343 11.2116 102.692 5.02553 105.448 2.75675C105.865 2.4137 106.47 2.58777 106.685 3.08259Z",
7626 fill: "#E6E8EA"
7627 }), /*#__PURE__*/ react.default.createElement("path", {
7628 fillRule: "evenodd",
7629 clipRule: "evenodd",
7630 d: "M104.883 4.66783C105.347 4.17219 106.14 4.35208 106.38 4.9873C108.716 11.1748 109.254 18.1507 108.889 24.5355C108.513 31.1152 107.184 36.9856 105.954 40.5842C105.778 40.6166 105.55 40.6541 105.265 40.6927C104.388 40.8119 102.974 40.9423 100.88 40.9712C98.7385 41.0008 97.3196 41.0031 96.4377 40.9371C96.2614 40.9239 96.1203 40.9088 96.0088 40.8935C95.9567 39.0573 95.8782 32.9919 97.4073 22.4743C98.766 13.1288 102.302 7.42438 104.883 4.66783ZM106.713 41.4403L107.002 42.3975C107.305 42.3062 107.546 42.0773 107.653 41.7802C109 38.0524 110.481 31.7376 110.886 24.6496C111.29 17.5654 110.626 9.61894 107.602 2.68255C107.147 1.63949 105.792 1.17814 104.812 1.98425C101.838 4.43294 97.0752 10.8574 95.4281 22.1866C93.7715 33.5811 93.975 39.865 94.0187 41.2138C94.0225 41.3324 94.0251 41.4128 94.0251 41.4552C94.025 42.261 94.695 42.5983 95.0067 42.7098C95.3591 42.8358 95.8079 42.8956 96.2886 42.9316C97.2769 43.0055 98.7924 43.0002 100.908 42.971C103.071 42.9411 104.566 42.806 105.534 42.6745C106.018 42.6088 106.371 42.5438 106.61 42.4932C106.729 42.4679 106.82 42.4461 106.885 42.4296C106.917 42.4214 106.943 42.4144 106.962 42.409L106.987 42.4021L106.996 42.3995L106.999 42.3984L107.001 42.398C107.001 42.398 107.002 42.3975 106.713 41.4403ZM106.426 40.4822L106.428 40.4817L106.43 40.4812C106.43 40.4812 106.429 40.4814 106.426 40.4822Z",
7631 fill: "#69727D"
7632 }), /*#__PURE__*/ react.default.createElement("path", {
7633 fillRule: "evenodd",
7634 clipRule: "evenodd",
7635 d: "M104.22 13.8372C104.787 15.7536 104.996 18.3439 104.953 21.2589C104.907 24.4148 104.569 27.8559 104.134 31.0529C103.7 34.2469 103.172 37.1799 102.753 39.3152C102.544 40.3824 102.361 41.2491 102.232 41.8481C102.22 41.9009 102.209 41.9516 102.199 42.0001H100.503C100.526 38.5025 100.676 33.4168 101.183 28.2866C101.724 22.8227 102.66 17.4299 104.22 13.8372ZM103 43.0001C103.974 43.2266 103.974 43.2264 103.974 43.2262L103.978 43.2093L103.989 43.1613C103.999 43.1192 104.013 43.0571 104.031 42.976C104.067 42.814 104.12 42.5763 104.186 42.2713C104.318 41.6613 104.503 40.7819 104.716 39.7006C105.14 37.5391 105.675 34.5658 106.116 31.3223C106.556 28.0818 106.905 24.5541 106.953 21.2881C107 18.0456 106.753 14.9635 105.943 12.6671C105.815 12.3045 105.676 11.9539 105.512 11.6797C105.394 11.4809 105.045 10.9388 104.371 10.9076C103.702 10.8766 103.301 11.3772 103.156 11.5722C102.959 11.8385 102.774 12.1912 102.594 12.5778C100.767 16.4945 99.7565 22.3931 99.1929 28.0897C98.6258 33.8211 98.5 39.4812 98.5 43.0001V44.0001H103.794L103.974 43.2262L103 43.0001Z",
7636 fill: "#69727D"
7637 }), /*#__PURE__*/ react.default.createElement("path", {
7638 d: "M79.2952 3.08259C73.4181 16.564 76.6423 34.1761 79.2676 41.4407C79.2676 41.4407 80.8299 41.9127 85.0867 41.9715C89.3434 42.0303 90.9554 41.9866 90.9554 41.4558C90.9553 40.9249 91.3533 34.6461 89.5628 22.3308C87.9462 11.2116 83.2888 5.02553 80.5325 2.75675C80.1157 2.4137 79.511 2.58777 79.2952 3.08259Z",
7639 fill: "#E6E8EA"
7640 }), /*#__PURE__*/ react.default.createElement("path", {
7641 fillRule: "evenodd",
7642 clipRule: "evenodd",
7643 d: "M81.0978 4.66783C80.6337 4.17219 79.8403 4.35208 79.6005 4.9873C77.2644 11.1748 76.7267 18.1507 77.0914 24.5355C77.4671 31.1152 78.7963 36.9856 80.0267 40.5842C80.2028 40.6166 80.4308 40.6541 80.7155 40.6927C81.5929 40.8119 83.0069 40.9423 85.1005 40.9712C87.242 41.0008 88.6609 41.0031 89.5427 40.9371C89.7191 40.9239 89.8602 40.9088 89.9716 40.8935C90.0238 39.0573 90.1023 32.9919 88.5732 22.4743C87.2145 13.1288 83.6789 7.42438 81.0978 4.66783ZM79.2676 41.4403L78.9784 42.3975C78.676 42.3062 78.4345 42.0773 78.3271 41.7802C76.98 38.0524 75.4994 31.7376 75.0946 24.6496C74.69 17.5654 75.3547 9.61894 78.3786 2.68255C78.8333 1.63949 80.1887 1.17814 81.168 1.98425C84.1429 4.43294 88.9053 10.8574 90.5524 22.1866C92.209 33.5811 92.0055 39.865 91.9618 41.2138C91.958 41.3324 91.9554 41.4128 91.9554 41.4552C91.9554 42.261 91.2855 42.5983 90.9737 42.7098C90.6214 42.8358 90.1726 42.8956 89.6919 42.9316C88.7036 43.0055 87.1881 43.0002 85.0728 42.971C82.9096 42.9411 81.4141 42.806 80.4462 42.6745C79.9621 42.6088 79.6094 42.5438 79.3707 42.4932C79.2514 42.4679 79.1605 42.4461 79.0958 42.4296C79.0635 42.4214 79.0377 42.4144 79.0182 42.409L78.9937 42.4021L78.9849 42.3995L78.9814 42.3984L78.9798 42.398C78.9798 42.398 78.9784 42.3975 79.2676 41.4403ZM79.5541 40.4822L79.5526 40.4817L79.5507 40.4812C79.5507 40.4812 79.5514 40.4814 79.5541 40.4822Z",
7644 fill: "#69727D"
7645 }), /*#__PURE__*/ react.default.createElement("path", {
7646 fillRule: "evenodd",
7647 clipRule: "evenodd",
7648 d: "M81.7604 13.8372C81.1939 15.7536 80.9847 18.3439 81.0272 21.2589C81.0733 24.4148 81.4118 27.8559 81.8464 31.0529C82.2805 34.2469 82.8081 37.1799 83.2274 39.3152C83.4369 40.3824 83.6192 41.2491 83.7488 41.8481C83.7603 41.9009 83.7713 41.9516 83.7819 42.0001H85.4771C85.4542 38.5025 85.3049 33.4168 84.7973 28.2866C84.2567 22.8227 83.32 17.4299 81.7604 13.8372ZM82.9805 43.0001C82.0065 43.2266 82.0064 43.2264 82.0064 43.2262L82.0025 43.2093L81.9914 43.1613C81.9818 43.1192 81.9677 43.0571 81.9494 42.976C81.913 42.814 81.8602 42.5763 81.7941 42.2713C81.6621 41.6613 81.4772 40.7819 81.2648 39.7006C80.8404 37.5391 80.3054 34.5658 79.8646 31.3223C79.4241 28.0818 79.0751 24.5541 79.0275 21.2881C78.9801 18.0456 79.227 14.9635 80.0375 12.6671C80.1655 12.3045 80.305 11.9539 80.4683 11.6797C80.5868 11.4809 80.9351 10.9388 81.6092 10.9076C82.2782 10.8766 82.6793 11.3772 82.8241 11.5722C83.0217 11.8385 83.2064 12.1912 83.3867 12.5778C85.2136 16.4945 86.224 22.3931 86.7876 28.0897C87.3546 33.8211 87.4805 39.4812 87.4805 43.0001V44.0001H82.1863L82.0064 43.2262L82.9805 43.0001Z",
7649 fill: "#69727D"
7650 })), /*#__PURE__*/ react.default.createElement("defs", null, /*#__PURE__*/ react.default.createElement("clipPath", { id: "clip0_3127_96542" }, /*#__PURE__*/ react.default.createElement("rect", {
7651 width: "184",
7652 height: "80",
7653 fill: "white"
7654 }))));
7655 };
7656 var ImageToolsContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
7657 var theme = _ref.theme;
7658 return { height: "calc(100% - ".concat(theme.spacing(13), ")") };
7659 });
7660 var ToolsTeaserContainer = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
7661 return {
7662 position: "sticky",
7663 top: "100%",
7664 padding: _ref2.theme.spacing(4, 0, 1)
7665 };
7666 });
7667 var StyledChip = (0, _elementor_ui.styled)(_elementor_ui.Chip)(function() {
7668 return {
7669 position: "absolute",
7670 top: 8,
7671 right: 8,
7672 "& .MuiChip-label": {
7673 fontSize: "0.75rem",
7674 fontWeight: "normal"
7675 }
7676 };
7677 });
7678 var ImageToolsPanel = function ImageToolsPanel() {
7679 var navigate = useLocation().navigate;
7680 var _useIntroduction = useIntroduction("e-ai-image-isolate-tool");
7681 var isIsolateViewed = _useIntroduction.isViewed;
7682 var markIsolateAsViewed = _useIntroduction.markAsViewed;
7683 var tools = [
7684 {
7685 label: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
7686 Icon: ExpandIcon$1,
7687 onClick: function onClick() {
7688 return navigate(LOCATIONS.OUT_PAINTING);
7689 }
7690 },
7691 {
7692 label: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
7693 Icon: BrushIcon,
7694 onClick: function onClick() {
7695 return navigate(LOCATIONS.IN_PAINTING);
7696 }
7697 },
7698 {
7699 label: (0, _wordpress_i18n.__)("Resize", "elementor"),
7700 Icon: ExpandIcon,
7701 onClick: function onClick() {
7702 return navigate(LOCATIONS.RESIZE);
7703 }
7704 },
7705 {
7706 label: (0, _wordpress_i18n.__)("Variations", "elementor"),
7707 Icon: EvolveIcon,
7708 onClick: function onClick() {
7709 return navigate(LOCATIONS.VARIATIONS);
7710 }
7711 },
7712 {
7713 label: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
7714 Icon: RemoveBackgroundIcon,
7715 onClick: function onClick() {
7716 return navigate(LOCATIONS.REMOVE_BACKGROUND);
7717 }
7718 },
7719 {
7720 label: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
7721 Icon: ReplaceBackgroundIcon,
7722 onClick: function onClick() {
7723 return navigate(LOCATIONS.REPLACE_BACKGROUND);
7724 }
7725 },
7726 {
7727 label: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
7728 Icon: Cleanup$1,
7729 onClick: function onClick() {
7730 return navigate(LOCATIONS.CLEANUP);
7731 }
7732 },
7733 {
7734 label: (0, _wordpress_i18n.__)("Isolate object", "elementor"),
7735 Icon: IsolateObjectIcon,
7736 ChipParam: !isIsolateViewed ? /*#__PURE__*/ react.default.createElement(StyledChip, {
7737 label: "New",
7738 color: "info",
7739 variant: "standard",
7740 size: "tiny"
7741 }) : null,
7742 onClick: function onClick() {
7743 markIsolateAsViewed();
7744 navigate(LOCATIONS.ISOLATE_OBJECT);
7745 }
7746 }
7747 ];
7748 return /*#__PURE__*/ react.default.createElement(ImageToolsContainer, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7749 display: "grid",
7750 gridTemplateColumns: "repeat(2, 1fr)",
7751 gap: 1,
7752 justifyContent: "center"
7753 }, tools.map(function(_ref3) {
7754 var label = _ref3.label;
7755 var Icon = _ref3.Icon;
7756 var ChipParam = _ref3.ChipParam;
7757 var onClick = _ref3.onClick;
7758 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
7759 onClick,
7760 key: label,
7761 variant: "outlined",
7762 color: "secondary",
7763 disabled: false,
7764 sx: {
7765 py: 3,
7766 fontSize: "12px",
7767 height: "auto",
7768 borderRadius: "4px"
7769 }
7770 }, ChipParam, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7771 display: "flex",
7772 justifyContent: "center",
7773 alignItems: "center",
7774 flexDirection: "column"
7775 }, /*#__PURE__*/ react.default.createElement(Icon, { sx: { mb: .5 } }), label));
7776 })), /*#__PURE__*/ react.default.createElement(ToolsTeaserContainer, {
7777 display: "flex",
7778 flexDirection: "column",
7779 alignItems: "center"
7780 }, /*#__PURE__*/ react.default.createElement(TeaserDrawing, null), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
7781 variant: "body2",
7782 align: "center",
7783 color: "secondary",
7784 sx: { mt: 2 }
7785 }, (0, _wordpress_i18n.__)("Stay tuned! More incredible AI tools are coming your way soon.", "elementor"))));
7786 };
7787 ImageToolsPanel.propTypes = {
7788 generateNewPrompt: import_prop_types$7.default.func,
7789 panelActive: import_prop_types$7.default.bool
7790 };
7791
7792 //#endregion
7793 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/image-tools-content.js
7794 var ImageToolsContent = function ImageToolsContent() {
7795 var _useEditImage = useEditImage();
7796 var editImage = _useEditImage.editImage;
7797 var width = _useEditImage.width;
7798 var height = _useEditImage.height;
7799 var use = useImageActions().use;
7800 return /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7801 src: editImage.url,
7802 style: {
7803 width,
7804 height
7805 },
7806 alt: editImage.alt || (0, _wordpress_i18n.__)("Image preview", "elementor")
7807 }, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Actions, null, /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, { onClick: function onClick() {
7808 return use(editImage);
7809 } }))));
7810 };
7811
7812 //#endregion
7813 //#region modules/ai/assets/js/editor/pages/form-media/views/image-tools/index.js
7814 var ImageTools = function ImageTools() {
7815 var navigate = useLocation().navigate;
7816 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, { onClick: function onClick() {
7817 return navigate(LOCATIONS.GENERATE);
7818 } }, (0, _wordpress_i18n.__)("Generate with a prompt", "elementor")), /*#__PURE__*/ react.default.createElement(View.PanelHeading, { primary: (0, _wordpress_i18n.__)("Edit with AI", "elementor") }), /*#__PURE__*/ react.default.createElement(ImageToolsPanel, null)), /*#__PURE__*/ react.default.createElement(View.Content, null, /*#__PURE__*/ react.default.createElement(ImageToolsContent, null)));
7819 };
7820
7821 //#endregion
7822 //#region modules/ai/assets/js/editor/pages/form-media/components/generate-submit.js
7823 init_extends();
7824 var GenerateSubmit = function GenerateSubmit(props) {
7825 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
7826 fullWidth: true,
7827 size: "medium",
7828 type: "submit",
7829 variant: "contained"
7830 }, props), props.children || (0, _wordpress_i18n.__)("Generate", "elementor"));
7831 };
7832 GenerateSubmit.propTypes = { children: import_prop_types$7.default.node };
7833
7834 //#endregion
7835 //#region modules/ai/assets/js/editor/pages/form-media/hooks/use-image-prompt.js
7836 init_use_prompt();
7837 var useImagePrompt = function useImagePrompt() {
7838 var promptData = usePrompt.apply(void 0, arguments);
7839 var _useGlobalActions = useGlobalActions();
7840 var setHasUnsavedChanges = _useGlobalActions.setHasUnsavedChanges;
7841 var state = _useGlobalActions.state;
7842 (0, react.useEffect)(function() {
7843 var _promptData$data;
7844 if ((_promptData$data = promptData.data) !== null && _promptData$data !== void 0 && _promptData$data.result) setHasUnsavedChanges(true);
7845 }, [promptData.data]);
7846 (0, react.useEffect)(function() {
7847 if (state.isAllSaved) promptData.sendUsageData();
7848 }, [state.isAllSaved]);
7849 return promptData;
7850 };
7851
7852 //#endregion
7853 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/hooks/use-resize.js
7854 init_api();
7855 var useResize = function useResize(initialValue) {
7856 return useImagePrompt(function fetchAction(payload) {
7857 return getImageToImageUpscale(payload);
7858 }, initialValue);
7859 };
7860
7861 //#endregion
7862 //#region modules/ai/assets/js/editor/pages/form-media/views/resize/index.js
7863 init_defineProperty$1();
7864 init_requests_ids();
7865 var Resize = function Resize() {
7866 var _useEditImage = useEditImage();
7867 var editImage = _useEditImage.editImage;
7868 var initialEditImageWidth = _useEditImage.width;
7869 var setGenerate = useRequestIds().setGenerate;
7870 var _useImageActions = useImageActions();
7871 var use = _useImageActions.use;
7872 var edit = _useImageActions.edit;
7873 var isUploading = _useImageActions.isLoading;
7874 var _usePromptSettings = usePromptSettings();
7875 var settings = _usePromptSettings.settings;
7876 var updateSettings = _usePromptSettings.updateSettings;
7877 var _useResize = useResize();
7878 var data = _useResize.data;
7879 var send = _useResize.send;
7880 var isGenerating = _useResize.isLoading;
7881 var error = _useResize.error;
7882 var isLoading = isGenerating || isUploading;
7883 var handleSubmit = function handleSubmit(event) {
7884 event.preventDefault();
7885 setGenerate();
7886 send({
7887 promptSettings: settings,
7888 image: editImage
7889 });
7890 };
7891 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
7892 primary: (0, _wordpress_i18n.__)("Resize", "elementor"),
7893 secondary: (0, _wordpress_i18n.__)("Make an image larger and improve it’s resolution.", "elementor")
7894 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
7895 error,
7896 onRetry: handleSubmit
7897 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { spacing: .2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7898 display: "flex",
7899 justifyContent: "space-between",
7900 alignItems: "center"
7901 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, "512px"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, "2048px")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Slider, {
7902 marks: true,
7903 step: 64,
7904 min: 512,
7905 max: 2048,
7906 id: "upscale_to",
7907 color: "secondary",
7908 name: "upscale_to",
7909 disabled: isLoading,
7910 defaultValue: initialEditImageWidth,
7911 valueLabelDisplay: "auto",
7912 "aria-label": (0, _wordpress_i18n.__)("Upscale to", "elementor"),
7913 onChange: function onChange(_, value) {
7914 return updateSettings(_defineProperty$1({}, IMAGE_UPSCALE, value));
7915 }
7916 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
7917 display: "flex",
7918 justifyContent: "space-between",
7919 alignItems: "center"
7920 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, (0, _wordpress_i18n.__)("Current", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "caption" }, (0, _wordpress_i18n.__)("Output", "elementor")))), /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
7921 onUseImage: use,
7922 onEditImage: edit,
7923 images: data.result,
7924 aspectRatio: editImage.aspectRatio
7925 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
7926 src: editImage.url,
7927 alt: editImage.alt,
7928 style: {
7929 width: editImage.width,
7930 height: editImage.height
7931 }
7932 }))));
7933 };
7934
7935 //#endregion
7936 //#region node_modules/react-sketch-canvas/dist/react-sketch-canvas.esm.js
7937 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
7938 try {
7939 var info = gen[key](arg);
7940 var value = info.value;
7941 } catch (error) {
7942 reject(error);
7943 return;
7944 }
7945 if (info.done) resolve(value);
7946 else Promise.resolve(value).then(_next, _throw);
7947 }
7948 function _asyncToGenerator(fn) {
7949 return function() {
7950 var self = this;
7951 var args = arguments;
7952 return new Promise(function(resolve, reject) {
7953 var gen = fn.apply(self, args);
7954 function _next(value) {
7955 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
7956 }
7957 function _throw(err) {
7958 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
7959 }
7960 _next(void 0);
7961 });
7962 };
7963 }
7964 function _extends() {
7965 _extends = Object.assign || function(target) {
7966 for (var i = 1; i < arguments.length; i++) {
7967 var source = arguments[i];
7968 for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
7969 }
7970 return target;
7971 };
7972 return _extends.apply(this, arguments);
7973 }
7974 var runtime = { exports: {} };
7975 /**
7976 * Copyright (c) 2014-present, Facebook, Inc.
7977 *
7978 * This source code is licensed under the MIT license found in the
7979 * LICENSE file in the root directory of this source tree.
7980 */
7981 (function(module) {
7982 var runtime = function(exports) {
7983 var Op = Object.prototype;
7984 var hasOwn = Op.hasOwnProperty;
7985 var undefined$1;
7986 var $Symbol = typeof Symbol === "function" ? Symbol : {};
7987 var iteratorSymbol = $Symbol.iterator || "@@iterator";
7988 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
7989 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
7990 function define(obj, key, value) {
7991 Object.defineProperty(obj, key, {
7992 value,
7993 enumerable: true,
7994 configurable: true,
7995 writable: true
7996 });
7997 return obj[key];
7998 }
7999 try {
8000 define({}, "");
8001 } catch (err) {
8002 define = function(obj, key, value) {
8003 return obj[key] = value;
8004 };
8005 }
8006 function wrap(innerFn, outerFn, self, tryLocsList) {
8007 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
8008 var generator = Object.create(protoGenerator.prototype);
8009 generator._invoke = makeInvokeMethod(innerFn, self, new Context(tryLocsList || []));
8010 return generator;
8011 }
8012 exports.wrap = wrap;
8013 function tryCatch(fn, obj, arg) {
8014 try {
8015 return {
8016 type: "normal",
8017 arg: fn.call(obj, arg)
8018 };
8019 } catch (err) {
8020 return {
8021 type: "throw",
8022 arg: err
8023 };
8024 }
8025 }
8026 var GenStateSuspendedStart = "suspendedStart";
8027 var GenStateSuspendedYield = "suspendedYield";
8028 var GenStateExecuting = "executing";
8029 var GenStateCompleted = "completed";
8030 var ContinueSentinel = {};
8031 function Generator() {}
8032 function GeneratorFunction() {}
8033 function GeneratorFunctionPrototype() {}
8034 var IteratorPrototype = {};
8035 define(IteratorPrototype, iteratorSymbol, function() {
8036 return this;
8037 });
8038 var getProto = Object.getPrototypeOf;
8039 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
8040 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) IteratorPrototype = NativeIteratorPrototype;
8041 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
8042 GeneratorFunction.prototype = GeneratorFunctionPrototype;
8043 define(Gp, "constructor", GeneratorFunctionPrototype);
8044 define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
8045 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction");
8046 function defineIteratorMethods(prototype) {
8047 [
8048 "next",
8049 "throw",
8050 "return"
8051 ].forEach(function(method) {
8052 define(prototype, method, function(arg) {
8053 return this._invoke(method, arg);
8054 });
8055 });
8056 }
8057 exports.isGeneratorFunction = function(genFun) {
8058 var ctor = typeof genFun === "function" && genFun.constructor;
8059 return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
8060 };
8061 exports.mark = function(genFun) {
8062 if (Object.setPrototypeOf) Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
8063 else {
8064 genFun.__proto__ = GeneratorFunctionPrototype;
8065 define(genFun, toStringTagSymbol, "GeneratorFunction");
8066 }
8067 genFun.prototype = Object.create(Gp);
8068 return genFun;
8069 };
8070 exports.awrap = function(arg) {
8071 return { __await: arg };
8072 };
8073 function AsyncIterator(generator, PromiseImpl) {
8074 function invoke(method, arg, resolve, reject) {
8075 var record = tryCatch(generator[method], generator, arg);
8076 if (record.type === "throw") reject(record.arg);
8077 else {
8078 var result = record.arg;
8079 var value = result.value;
8080 if (value && typeof value === "object" && hasOwn.call(value, "__await")) return PromiseImpl.resolve(value.__await).then(function(value) {
8081 invoke("next", value, resolve, reject);
8082 }, function(err) {
8083 invoke("throw", err, resolve, reject);
8084 });
8085 return PromiseImpl.resolve(value).then(function(unwrapped) {
8086 result.value = unwrapped;
8087 resolve(result);
8088 }, function(error) {
8089 return invoke("throw", error, resolve, reject);
8090 });
8091 }
8092 }
8093 var previousPromise;
8094 function enqueue(method, arg) {
8095 function callInvokeWithMethodAndArg() {
8096 return new PromiseImpl(function(resolve, reject) {
8097 invoke(method, arg, resolve, reject);
8098 });
8099 }
8100 return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
8101 }
8102 this._invoke = enqueue;
8103 }
8104 defineIteratorMethods(AsyncIterator.prototype);
8105 define(AsyncIterator.prototype, asyncIteratorSymbol, function() {
8106 return this;
8107 });
8108 exports.AsyncIterator = AsyncIterator;
8109 exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
8110 if (PromiseImpl === void 0) PromiseImpl = Promise;
8111 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
8112 return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function(result) {
8113 return result.done ? result.value : iter.next();
8114 });
8115 };
8116 function makeInvokeMethod(innerFn, self, context) {
8117 var state = GenStateSuspendedStart;
8118 return function invoke(method, arg) {
8119 if (state === GenStateExecuting) throw new Error("Generator is already running");
8120 if (state === GenStateCompleted) {
8121 if (method === "throw") throw arg;
8122 return doneResult();
8123 }
8124 context.method = method;
8125 context.arg = arg;
8126 while (true) {
8127 var delegate = context.delegate;
8128 if (delegate) {
8129 var delegateResult = maybeInvokeDelegate(delegate, context);
8130 if (delegateResult) {
8131 if (delegateResult === ContinueSentinel) continue;
8132 return delegateResult;
8133 }
8134 }
8135 if (context.method === "next") context.sent = context._sent = context.arg;
8136 else if (context.method === "throw") {
8137 if (state === GenStateSuspendedStart) {
8138 state = GenStateCompleted;
8139 throw context.arg;
8140 }
8141 context.dispatchException(context.arg);
8142 } else if (context.method === "return") context.abrupt("return", context.arg);
8143 state = GenStateExecuting;
8144 var record = tryCatch(innerFn, self, context);
8145 if (record.type === "normal") {
8146 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
8147 if (record.arg === ContinueSentinel) continue;
8148 return {
8149 value: record.arg,
8150 done: context.done
8151 };
8152 } else if (record.type === "throw") {
8153 state = GenStateCompleted;
8154 context.method = "throw";
8155 context.arg = record.arg;
8156 }
8157 }
8158 };
8159 }
8160 function maybeInvokeDelegate(delegate, context) {
8161 var method = delegate.iterator[context.method];
8162 if (method === undefined$1) {
8163 context.delegate = null;
8164 if (context.method === "throw") {
8165 if (delegate.iterator["return"]) {
8166 context.method = "return";
8167 context.arg = undefined$1;
8168 maybeInvokeDelegate(delegate, context);
8169 if (context.method === "throw") return ContinueSentinel;
8170 }
8171 context.method = "throw";
8172 context.arg = /* @__PURE__ */ new TypeError("The iterator does not provide a 'throw' method");
8173 }
8174 return ContinueSentinel;
8175 }
8176 var record = tryCatch(method, delegate.iterator, context.arg);
8177 if (record.type === "throw") {
8178 context.method = "throw";
8179 context.arg = record.arg;
8180 context.delegate = null;
8181 return ContinueSentinel;
8182 }
8183 var info = record.arg;
8184 if (!info) {
8185 context.method = "throw";
8186 context.arg = /* @__PURE__ */ new TypeError("iterator result is not an object");
8187 context.delegate = null;
8188 return ContinueSentinel;
8189 }
8190 if (info.done) {
8191 context[delegate.resultName] = info.value;
8192 context.next = delegate.nextLoc;
8193 if (context.method !== "return") {
8194 context.method = "next";
8195 context.arg = undefined$1;
8196 }
8197 } else return info;
8198 context.delegate = null;
8199 return ContinueSentinel;
8200 }
8201 defineIteratorMethods(Gp);
8202 define(Gp, toStringTagSymbol, "Generator");
8203 define(Gp, iteratorSymbol, function() {
8204 return this;
8205 });
8206 define(Gp, "toString", function() {
8207 return "[object Generator]";
8208 });
8209 function pushTryEntry(locs) {
8210 var entry = { tryLoc: locs[0] };
8211 if (1 in locs) entry.catchLoc = locs[1];
8212 if (2 in locs) {
8213 entry.finallyLoc = locs[2];
8214 entry.afterLoc = locs[3];
8215 }
8216 this.tryEntries.push(entry);
8217 }
8218 function resetTryEntry(entry) {
8219 var record = entry.completion || {};
8220 record.type = "normal";
8221 delete record.arg;
8222 entry.completion = record;
8223 }
8224 function Context(tryLocsList) {
8225 this.tryEntries = [{ tryLoc: "root" }];
8226 tryLocsList.forEach(pushTryEntry, this);
8227 this.reset(true);
8228 }
8229 exports.keys = function(object) {
8230 var keys = [];
8231 for (var key in object) keys.push(key);
8232 keys.reverse();
8233 return function next() {
8234 while (keys.length) {
8235 var key = keys.pop();
8236 if (key in object) {
8237 next.value = key;
8238 next.done = false;
8239 return next;
8240 }
8241 }
8242 next.done = true;
8243 return next;
8244 };
8245 };
8246 function values(iterable) {
8247 if (iterable) {
8248 var iteratorMethod = iterable[iteratorSymbol];
8249 if (iteratorMethod) return iteratorMethod.call(iterable);
8250 if (typeof iterable.next === "function") return iterable;
8251 if (!isNaN(iterable.length)) {
8252 var i = -1;
8253 var next = function next() {
8254 while (++i < iterable.length) if (hasOwn.call(iterable, i)) {
8255 next.value = iterable[i];
8256 next.done = false;
8257 return next;
8258 }
8259 next.value = undefined$1;
8260 next.done = true;
8261 return next;
8262 };
8263 return next.next = next;
8264 }
8265 }
8266 return { next: doneResult };
8267 }
8268 exports.values = values;
8269 function doneResult() {
8270 return {
8271 value: undefined$1,
8272 done: true
8273 };
8274 }
8275 Context.prototype = {
8276 constructor: Context,
8277 reset: function(skipTempReset) {
8278 this.prev = 0;
8279 this.next = 0;
8280 this.sent = this._sent = undefined$1;
8281 this.done = false;
8282 this.delegate = null;
8283 this.method = "next";
8284 this.arg = undefined$1;
8285 this.tryEntries.forEach(resetTryEntry);
8286 if (!skipTempReset) {
8287 for (var name in this) if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) this[name] = undefined$1;
8288 }
8289 },
8290 stop: function() {
8291 this.done = true;
8292 var rootRecord = this.tryEntries[0].completion;
8293 if (rootRecord.type === "throw") throw rootRecord.arg;
8294 return this.rval;
8295 },
8296 dispatchException: function(exception) {
8297 if (this.done) throw exception;
8298 var context = this;
8299 function handle(loc, caught) {
8300 record.type = "throw";
8301 record.arg = exception;
8302 context.next = loc;
8303 if (caught) {
8304 context.method = "next";
8305 context.arg = undefined$1;
8306 }
8307 return !!caught;
8308 }
8309 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8310 var entry = this.tryEntries[i];
8311 var record = entry.completion;
8312 if (entry.tryLoc === "root") return handle("end");
8313 if (entry.tryLoc <= this.prev) {
8314 var hasCatch = hasOwn.call(entry, "catchLoc");
8315 var hasFinally = hasOwn.call(entry, "finallyLoc");
8316 if (hasCatch && hasFinally) {
8317 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8318 else if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8319 } else if (hasCatch) {
8320 if (this.prev < entry.catchLoc) return handle(entry.catchLoc, true);
8321 } else if (hasFinally) {
8322 if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
8323 } else throw new Error("try statement without catch or finally");
8324 }
8325 }
8326 },
8327 abrupt: function(type, arg) {
8328 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8329 var entry = this.tryEntries[i];
8330 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
8331 var finallyEntry = entry;
8332 break;
8333 }
8334 }
8335 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) finallyEntry = null;
8336 var record = finallyEntry ? finallyEntry.completion : {};
8337 record.type = type;
8338 record.arg = arg;
8339 if (finallyEntry) {
8340 this.method = "next";
8341 this.next = finallyEntry.finallyLoc;
8342 return ContinueSentinel;
8343 }
8344 return this.complete(record);
8345 },
8346 complete: function(record, afterLoc) {
8347 if (record.type === "throw") throw record.arg;
8348 if (record.type === "break" || record.type === "continue") this.next = record.arg;
8349 else if (record.type === "return") {
8350 this.rval = this.arg = record.arg;
8351 this.method = "return";
8352 this.next = "end";
8353 } else if (record.type === "normal" && afterLoc) this.next = afterLoc;
8354 return ContinueSentinel;
8355 },
8356 finish: function(finallyLoc) {
8357 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8358 var entry = this.tryEntries[i];
8359 if (entry.finallyLoc === finallyLoc) {
8360 this.complete(entry.completion, entry.afterLoc);
8361 resetTryEntry(entry);
8362 return ContinueSentinel;
8363 }
8364 }
8365 },
8366 "catch": function(tryLoc) {
8367 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
8368 var entry = this.tryEntries[i];
8369 if (entry.tryLoc === tryLoc) {
8370 var record = entry.completion;
8371 if (record.type === "throw") {
8372 var thrown = record.arg;
8373 resetTryEntry(entry);
8374 }
8375 return thrown;
8376 }
8377 }
8378 throw new Error("illegal catch attempt");
8379 },
8380 delegateYield: function(iterable, resultName, nextLoc) {
8381 this.delegate = {
8382 iterator: values(iterable),
8383 resultName,
8384 nextLoc
8385 };
8386 if (this.method === "next") this.arg = undefined$1;
8387 return ContinueSentinel;
8388 }
8389 };
8390 return exports;
8391 }(module.exports);
8392 try {
8393 regeneratorRuntime = runtime;
8394 } catch (accidentalStrictMode) {
8395 if (typeof globalThis === "object") globalThis.regeneratorRuntime = runtime;
8396 else Function("r", "regeneratorRuntime = r")(runtime);
8397 }
8398 })(runtime);
8399 var _regeneratorRuntime$19 = runtime.exports;
8400 /**
8401 * Generate SVG Path tag from the given points
8402 */
8403 var SvgPath = function SvgPath(_ref) {
8404 var paths = _ref.paths;
8405 var id = _ref.id;
8406 var strokeWidth = _ref.strokeWidth;
8407 var strokeColor = _ref.strokeColor;
8408 var _ref$command = _ref.command;
8409 var command = _ref$command === void 0 ? bezierCommand : _ref$command;
8410 if (paths.length === 1) {
8411 var _paths$ = paths[0];
8412 var x = _paths$.x;
8413 var y = _paths$.y;
8414 var radius = strokeWidth / 2;
8415 return react.createElement("circle", {
8416 key: id,
8417 id,
8418 cx: x,
8419 cy: y,
8420 r: radius,
8421 stroke: strokeColor,
8422 fill: strokeColor
8423 });
8424 }
8425 var d = paths.reduce(function(acc, point, i, a) {
8426 return i === 0 ? "M " + point.x + "," + point.y : acc + " " + command(point, i, a);
8427 }, "");
8428 return react.createElement("path", {
8429 key: id,
8430 id,
8431 d,
8432 fill: "none",
8433 strokeLinecap: "round",
8434 stroke: strokeColor,
8435 strokeWidth
8436 });
8437 };
8438 var line = function line(pointA, pointB) {
8439 var lengthX = pointB.x - pointA.x;
8440 var lengthY = pointB.y - pointA.y;
8441 return {
8442 length: Math.sqrt(Math.pow(lengthX, 2) + Math.pow(lengthY, 2)),
8443 angle: Math.atan2(lengthY, lengthX)
8444 };
8445 };
8446 var controlPoint = function controlPoint(controlPoints) {
8447 var current = controlPoints.current;
8448 var next = controlPoints.next;
8449 var previous = controlPoints.previous;
8450 var reverse = controlPoints.reverse;
8451 var p = previous || current;
8452 var n = next || current;
8453 var smoothing = .2;
8454 var o = line(p, n);
8455 var angle = o.angle + (reverse ? Math.PI : 0);
8456 var length = o.length * smoothing;
8457 return [current.x + Math.cos(angle) * length, current.y + Math.sin(angle) * length];
8458 };
8459 var bezierCommand = function bezierCommand(point, i, a) {
8460 var cpsX = null;
8461 var cpsY = null;
8462 switch (i) {
8463 case 0:
8464 var _controlPoint = controlPoint({ current: point });
8465 cpsX = _controlPoint[0];
8466 cpsY = _controlPoint[1];
8467 break;
8468 case 1:
8469 var _controlPoint2 = controlPoint({
8470 current: a[i - 1],
8471 next: point
8472 });
8473 cpsX = _controlPoint2[0];
8474 cpsY = _controlPoint2[1];
8475 break;
8476 default:
8477 var _controlPoint3 = controlPoint({
8478 current: a[i - 1],
8479 previous: a[i - 2],
8480 next: point
8481 });
8482 cpsX = _controlPoint3[0];
8483 cpsY = _controlPoint3[1];
8484 break;
8485 }
8486 var _controlPoint4 = controlPoint({
8487 current: point,
8488 previous: a[i - 1],
8489 next: a[i + 1],
8490 reverse: true
8491 });
8492 var cpeX = _controlPoint4[0];
8493 var cpeY = _controlPoint4[1];
8494 return "C " + cpsX + "," + cpsY + " " + cpeX + "," + cpeY + " " + point.x + ", " + point.y;
8495 };
8496 var Paths = function Paths(_ref2) {
8497 var id = _ref2.id;
8498 var paths = _ref2.paths;
8499 return react.createElement(react.Fragment, null, paths.map(function(path, index) {
8500 return react.createElement(SvgPath, {
8501 key: id + "__" + index,
8502 paths: path.paths,
8503 id: id + "__" + index,
8504 strokeWidth: path.strokeWidth,
8505 strokeColor: path.strokeColor,
8506 command: bezierCommand
8507 });
8508 }));
8509 };
8510 var loadImage = function loadImage(url) {
8511 return new Promise(function(resolve, reject) {
8512 var img = new Image();
8513 img.addEventListener("load", function() {
8514 if (img.width > 0) resolve(img);
8515 reject("Image not found");
8516 });
8517 img.addEventListener("error", function(err) {
8518 return reject(err);
8519 });
8520 img.src = url;
8521 img.setAttribute("crossorigin", "anonymous");
8522 });
8523 };
8524 function getCanvasWithViewBox(canvas) {
8525 var _canvas$firstChild;
8526 var svgCanvas = (_canvas$firstChild = canvas.firstChild) == null ? void 0 : _canvas$firstChild.cloneNode(true);
8527 var width = canvas.offsetWidth;
8528 var height = canvas.offsetHeight;
8529 svgCanvas.setAttribute("viewBox", "0 0 " + width + " " + height);
8530 svgCanvas.setAttribute("width", width.toString());
8531 svgCanvas.setAttribute("height", height.toString());
8532 return {
8533 svgCanvas,
8534 width,
8535 height
8536 };
8537 }
8538 var Canvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8539 var paths = props.paths;
8540 var isDrawing = props.isDrawing;
8541 var onPointerDown = props.onPointerDown;
8542 var onPointerMove = props.onPointerMove;
8543 var onPointerUp = props.onPointerUp;
8544 var _props$id = props.id;
8545 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8546 var _props$width = props.width;
8547 var width = _props$width === void 0 ? "100%" : _props$width;
8548 var _props$height = props.height;
8549 var height = _props$height === void 0 ? "100%" : _props$height;
8550 var _props$className = props.className;
8551 var className = _props$className === void 0 ? "react-sketch-canvas" : _props$className;
8552 var _props$canvasColor = props.canvasColor;
8553 var canvasColor = _props$canvasColor === void 0 ? "red" : _props$canvasColor;
8554 var _props$backgroundImag = props.backgroundImage;
8555 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8556 var _props$exportWithBack = props.exportWithBackgroundImage;
8557 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8558 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8559 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8560 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8561 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8562 var _props$style = props.style;
8563 var style = _props$style === void 0 ? {
8564 border: "0.0625rem solid #9c9c9c",
8565 borderRadius: "0.25rem"
8566 } : _props$style;
8567 var _props$svgStyle = props.svgStyle;
8568 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8569 var canvasRef = react.useRef(null);
8570 var getCoordinates = function getCoordinates(pointerEvent) {
8571 var _canvasRef$current;
8572 var _window$scrollX;
8573 var _window$scrollY;
8574 var boundingArea = (_canvasRef$current = canvasRef.current) == null ? void 0 : _canvasRef$current.getBoundingClientRect();
8575 var scrollLeft = (_window$scrollX = window.scrollX) != null ? _window$scrollX : 0;
8576 var scrollTop = (_window$scrollY = window.scrollY) != null ? _window$scrollY : 0;
8577 if (!boundingArea) return {
8578 x: 0,
8579 y: 0
8580 };
8581 return {
8582 x: pointerEvent.pageX - boundingArea.left - scrollLeft,
8583 y: pointerEvent.pageY - boundingArea.top - scrollTop
8584 };
8585 };
8586 var handlePointerDown = function handlePointerDown(event) {
8587 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8588 if (event.pointerType === "mouse" && event.button !== 0) return;
8589 onPointerDown(getCoordinates(event));
8590 };
8591 var handlePointerMove = function handlePointerMove(event) {
8592 if (!isDrawing) return;
8593 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8594 onPointerMove(getCoordinates(event));
8595 };
8596 var handlePointerUp = function handlePointerUp(event) {
8597 if (event.pointerType === "mouse" && event.button !== 0) return;
8598 if (allowOnlyPointerType !== "all" && event.pointerType !== allowOnlyPointerType) return;
8599 onPointerUp();
8600 };
8601 react.useImperativeHandle(ref, function() {
8602 return {
8603 exportImage: function exportImage(imageType) {
8604 return new Promise(/*#__PURE__*/ function() {
8605 var _ref = _asyncToGenerator(/*#__PURE__*/ _regeneratorRuntime$19.mark(function _callee(resolve, reject) {
8606 var canvas;
8607 var _getCanvasWithViewBox;
8608 var svgCanvas;
8609 var _width;
8610 var _height;
8611 var canvasSketch;
8612 var loadImagePromises;
8613 var img;
8614 return _regeneratorRuntime$19.wrap(function _callee$(_context) {
8615 while (1) switch (_context.prev = _context.next) {
8616 case 0:
8617 _context.prev = 0;
8618 canvas = canvasRef.current;
8619 if (canvas) {
8620 _context.next = 4;
8621 break;
8622 }
8623 throw Error("Canvas not rendered yet");
8624 case 4:
8625 _getCanvasWithViewBox = getCanvasWithViewBox(canvas), svgCanvas = _getCanvasWithViewBox.svgCanvas, _width = _getCanvasWithViewBox.width, _height = _getCanvasWithViewBox.height;
8626 canvasSketch = "data:image/svg+xml;base64," + btoa(svgCanvas.outerHTML);
8627 _context.next = 8;
8628 return loadImage(canvasSketch);
8629 case 8:
8630 _context.t0 = _context.sent;
8631 loadImagePromises = [_context.t0];
8632 if (!exportWithBackgroundImage) {
8633 _context.next = 21;
8634 break;
8635 }
8636 _context.prev = 11;
8637 _context.next = 14;
8638 return loadImage(backgroundImage);
8639 case 14:
8640 img = _context.sent;
8641 loadImagePromises.push(img);
8642 _context.next = 21;
8643 break;
8644 case 18:
8645 _context.prev = 18;
8646 _context.t1 = _context["catch"](11);
8647 console.warn("exportWithBackgroundImage props is set without a valid background image URL. This option is ignored");
8648 case 21:
8649 Promise.all(loadImagePromises).then(function(images) {
8650 var renderCanvas = document.createElement("canvas");
8651 renderCanvas.setAttribute("width", _width.toString());
8652 renderCanvas.setAttribute("height", _height.toString());
8653 var context = renderCanvas.getContext("2d");
8654 if (!context) throw Error("Canvas not rendered yet");
8655 images.reverse().forEach(function(image) {
8656 context.drawImage(image, 0, 0);
8657 });
8658 resolve(renderCanvas.toDataURL("image/" + imageType));
8659 })["catch"](function(e) {
8660 throw e;
8661 });
8662 _context.next = 27;
8663 break;
8664 case 24:
8665 _context.prev = 24;
8666 _context.t2 = _context["catch"](0);
8667 reject(_context.t2);
8668 case 27:
8669 case "end": return _context.stop();
8670 }
8671 }, _callee, null, [[0, 24], [11, 18]]);
8672 }));
8673 return function(_x, _x2) {
8674 return _ref.apply(this, arguments);
8675 };
8676 }());
8677 },
8678 exportSvg: function exportSvg() {
8679 return new Promise(function(resolve, reject) {
8680 try {
8681 var _canvasRef$current2;
8682 var canvas = (_canvasRef$current2 = canvasRef.current) != null ? _canvasRef$current2 : null;
8683 if (canvas !== null) {
8684 var _svgCanvas$querySelec;
8685 var _svgCanvas$querySelec2;
8686 var svgCanvas = getCanvasWithViewBox(canvas).svgCanvas;
8687 if (exportWithBackgroundImage) {
8688 resolve(svgCanvas.outerHTML);
8689 return;
8690 }
8691 (_svgCanvas$querySelec = svgCanvas.querySelector("#" + id + "__background")) == null || _svgCanvas$querySelec.remove();
8692 (_svgCanvas$querySelec2 = svgCanvas.querySelector("#" + id + "__canvas-background")) == null || _svgCanvas$querySelec2.setAttribute("fill", canvasColor);
8693 resolve(svgCanvas.outerHTML);
8694 }
8695 reject(/* @__PURE__ */ new Error("Canvas not loaded"));
8696 } catch (e) {
8697 reject(e);
8698 }
8699 });
8700 }
8701 };
8702 });
8703 react.useEffect(function() {
8704 document.addEventListener("pointerup", handlePointerUp);
8705 return function() {
8706 document.removeEventListener("pointerup", handlePointerUp);
8707 };
8708 }, [handlePointerUp]);
8709 var eraserPaths = paths.filter(function(path) {
8710 return !path.drawMode;
8711 });
8712 var currentGroup = 0;
8713 var pathGroups = paths.reduce(function(arrayGroup, path) {
8714 if (!path.drawMode) {
8715 currentGroup += 1;
8716 return arrayGroup;
8717 }
8718 if (arrayGroup[currentGroup] === void 0) arrayGroup[currentGroup] = [];
8719 arrayGroup[currentGroup].push(path);
8720 return arrayGroup;
8721 }, [[]]);
8722 return react.createElement("div", {
8723 role: "presentation",
8724 ref: canvasRef,
8725 className,
8726 style: _extends({
8727 touchAction: "none",
8728 width,
8729 height
8730 }, style),
8731 "touch-action": "none",
8732 onPointerDown: handlePointerDown,
8733 onPointerMove: handlePointerMove,
8734 onPointerUp: handlePointerUp
8735 }, react.createElement("svg", {
8736 version: "1.1",
8737 baseProfile: "full",
8738 xmlns: "http://www.w3.org/2000/svg",
8739 xmlnsXlink: "http://www.w3.org/1999/xlink",
8740 style: _extends({
8741 width: "100%",
8742 height: "100%"
8743 }, svgStyle),
8744 id
8745 }, react.createElement("g", {
8746 id: id + "__eraser-stroke-group",
8747 display: "none"
8748 }, react.createElement("rect", {
8749 id: id + "__mask-background",
8750 x: "0",
8751 y: "0",
8752 width: "100%",
8753 height: "100%",
8754 fill: "white"
8755 }), eraserPaths.map(function(eraserPath, i) {
8756 return react.createElement(SvgPath, {
8757 key: id + "__eraser-" + i,
8758 id: id + "__eraser-" + i,
8759 paths: eraserPath.paths,
8760 strokeColor: "#000000",
8761 strokeWidth: eraserPath.strokeWidth
8762 });
8763 })), react.createElement("defs", null, backgroundImage && react.createElement("pattern", {
8764 id: id + "__background",
8765 x: "0",
8766 y: "0",
8767 width: "100%",
8768 height: "100%",
8769 patternUnits: "userSpaceOnUse"
8770 }, react.createElement("image", {
8771 x: "0",
8772 y: "0",
8773 width: "100%",
8774 height: "100%",
8775 xlinkHref: backgroundImage,
8776 preserveAspectRatio: preserveBackgroundImageAspectRatio
8777 })), eraserPaths.map(function(_, i) {
8778 return react.createElement("mask", {
8779 id: id + "__eraser-mask-" + i,
8780 key: id + "__eraser-mask-" + i,
8781 maskUnits: "userSpaceOnUse"
8782 }, react.createElement("use", { href: "#" + id + "__mask-background" }), Array.from({ length: eraserPaths.length - i }, function(_, j) {
8783 return j + i;
8784 }).map(function(k) {
8785 return react.createElement("use", {
8786 key: k.toString(),
8787 href: "#" + id + "__eraser-" + k.toString()
8788 });
8789 }));
8790 })), react.createElement("g", { id: id + "__canvas-background-group" }, react.createElement("rect", {
8791 id: id + "__canvas-background",
8792 x: "0",
8793 y: "0",
8794 width: "100%",
8795 height: "100%",
8796 fill: backgroundImage ? "url(#" + id + "__background)" : canvasColor
8797 })), pathGroups.map(function(pathGroup, i) {
8798 return react.createElement("g", {
8799 id: id + "__stroke-group-" + i,
8800 key: id + "__stroke-group-" + i,
8801 mask: "url(#" + id + "__eraser-mask-" + i + ")"
8802 }, react.createElement(Paths, {
8803 id,
8804 paths: pathGroup
8805 }));
8806 })));
8807 });
8808 var ReactSketchCanvas = /*#__PURE__*/ react.forwardRef(function(props, ref) {
8809 var _props$id = props.id;
8810 var id = _props$id === void 0 ? "react-sketch-canvas" : _props$id;
8811 var _props$width = props.width;
8812 var width = _props$width === void 0 ? "100%" : _props$width;
8813 var _props$height = props.height;
8814 var height = _props$height === void 0 ? "100%" : _props$height;
8815 var _props$className = props.className;
8816 var className = _props$className === void 0 ? "" : _props$className;
8817 var _props$canvasColor = props.canvasColor;
8818 var canvasColor = _props$canvasColor === void 0 ? "white" : _props$canvasColor;
8819 var _props$strokeColor = props.strokeColor;
8820 var strokeColor = _props$strokeColor === void 0 ? "red" : _props$strokeColor;
8821 var _props$backgroundImag = props.backgroundImage;
8822 var backgroundImage = _props$backgroundImag === void 0 ? "" : _props$backgroundImag;
8823 var _props$exportWithBack = props.exportWithBackgroundImage;
8824 var exportWithBackgroundImage = _props$exportWithBack === void 0 ? false : _props$exportWithBack;
8825 var _props$preserveBackgr = props.preserveBackgroundImageAspectRatio;
8826 var preserveBackgroundImageAspectRatio = _props$preserveBackgr === void 0 ? "none" : _props$preserveBackgr;
8827 var _props$strokeWidth = props.strokeWidth;
8828 var strokeWidth = _props$strokeWidth === void 0 ? 4 : _props$strokeWidth;
8829 var _props$eraserWidth = props.eraserWidth;
8830 var eraserWidth = _props$eraserWidth === void 0 ? 8 : _props$eraserWidth;
8831 var _props$allowOnlyPoint = props.allowOnlyPointerType;
8832 var allowOnlyPointerType = _props$allowOnlyPoint === void 0 ? "all" : _props$allowOnlyPoint;
8833 var _props$style = props.style;
8834 var style = _props$style === void 0 ? {
8835 border: "0.0625rem solid #9c9c9c",
8836 borderRadius: "0.25rem"
8837 } : _props$style;
8838 var _props$svgStyle = props.svgStyle;
8839 var svgStyle = _props$svgStyle === void 0 ? {} : _props$svgStyle;
8840 var _props$onChange = props.onChange;
8841 var onChange = _props$onChange === void 0 ? function(_paths) {} : _props$onChange;
8842 var _props$onStroke = props.onStroke;
8843 var onStroke = _props$onStroke === void 0 ? function(_path, _isEraser) {} : _props$onStroke;
8844 var _props$withTimestamp = props.withTimestamp;
8845 var withTimestamp = _props$withTimestamp === void 0 ? false : _props$withTimestamp;
8846 var svgCanvas = react.createRef();
8847 var _React$useState = react.useState(true);
8848 var drawMode = _React$useState[0];
8849 var setDrawMode = _React$useState[1];
8850 var _React$useState2 = react.useState(false);
8851 var isDrawing = _React$useState2[0];
8852 var setIsDrawing = _React$useState2[1];
8853 var _React$useState3 = react.useState([]);
8854 var resetStack = _React$useState3[0];
8855 var setResetStack = _React$useState3[1];
8856 var _React$useState4 = react.useState([]);
8857 var undoStack = _React$useState4[0];
8858 var setUndoStack = _React$useState4[1];
8859 var _React$useState5 = react.useState([]);
8860 var currentPaths = _React$useState5[0];
8861 var setCurrentPaths = _React$useState5[1];
8862 var liftStrokeUp = react.useCallback(function() {
8863 var _currentPaths$slice$;
8864 var _currentPaths$slice;
8865 var lastStroke = (_currentPaths$slice$ = (_currentPaths$slice = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice[0]) != null ? _currentPaths$slice$ : null;
8866 if (lastStroke === null) {
8867 console.warn("No stroke found!");
8868 return;
8869 }
8870 onStroke(lastStroke, !lastStroke.drawMode);
8871 }, [isDrawing]);
8872 react.useEffect(function() {
8873 liftStrokeUp();
8874 }, [isDrawing]);
8875 react.useEffect(function() {
8876 onChange(currentPaths);
8877 }, [currentPaths]);
8878 react.useImperativeHandle(ref, function() {
8879 return {
8880 eraseMode: function eraseMode(erase) {
8881 setDrawMode(!erase);
8882 },
8883 clearCanvas: function clearCanvas() {
8884 setResetStack([].concat(currentPaths));
8885 setCurrentPaths([]);
8886 },
8887 undo: function undo() {
8888 if (resetStack.length !== 0) {
8889 setCurrentPaths([].concat(resetStack));
8890 setResetStack([]);
8891 return;
8892 }
8893 setUndoStack(function(undoStack) {
8894 return [].concat(undoStack, currentPaths.slice(-1));
8895 });
8896 setCurrentPaths(function(currentPaths) {
8897 return currentPaths.slice(0, -1);
8898 });
8899 },
8900 redo: function redo() {
8901 if (undoStack.length === 0) return;
8902 setCurrentPaths(function(currentPaths) {
8903 return [].concat(currentPaths, undoStack.slice(-1));
8904 });
8905 setUndoStack(function(undoStack) {
8906 return undoStack.slice(0, -1);
8907 });
8908 },
8909 exportImage: function exportImage(imageType) {
8910 var _svgCanvas$current;
8911 var exportImage = (_svgCanvas$current = svgCanvas.current) == null ? void 0 : _svgCanvas$current.exportImage;
8912 if (!exportImage) throw Error("Export function called before canvas loaded");
8913 else return exportImage(imageType);
8914 },
8915 exportSvg: function exportSvg() {
8916 return new Promise(function(resolve, reject) {
8917 var _svgCanvas$current2;
8918 var exportSvg = (_svgCanvas$current2 = svgCanvas.current) == null ? void 0 : _svgCanvas$current2.exportSvg;
8919 if (!exportSvg) reject(Error("Export function called before canvas loaded"));
8920 else exportSvg().then(function(data) {
8921 resolve(data);
8922 })["catch"](function(e) {
8923 reject(e);
8924 });
8925 });
8926 },
8927 exportPaths: function exportPaths() {
8928 return new Promise(function(resolve, reject) {
8929 try {
8930 resolve(currentPaths);
8931 } catch (e) {
8932 reject(e);
8933 }
8934 });
8935 },
8936 loadPaths: function loadPaths(paths) {
8937 setCurrentPaths(function(currentPaths) {
8938 return [].concat(currentPaths, paths);
8939 });
8940 },
8941 getSketchingTime: function getSketchingTime() {
8942 return new Promise(function(resolve, reject) {
8943 if (!withTimestamp) reject(/* @__PURE__ */ new Error("Set 'withTimestamp' prop to get sketching time"));
8944 try {
8945 resolve(currentPaths.reduce(function(totalSketchingTime, path) {
8946 var _path$startTimestamp;
8947 var _path$endTimestamp;
8948 var startTimestamp = (_path$startTimestamp = path.startTimestamp) != null ? _path$startTimestamp : 0;
8949 return totalSketchingTime + (((_path$endTimestamp = path.endTimestamp) != null ? _path$endTimestamp : 0) - startTimestamp);
8950 }, 0));
8951 } catch (e) {
8952 reject(e);
8953 }
8954 });
8955 },
8956 resetCanvas: function resetCanvas() {
8957 setResetStack([]);
8958 setUndoStack([]);
8959 setCurrentPaths([]);
8960 }
8961 };
8962 });
8963 return react.createElement(Canvas, {
8964 ref: svgCanvas,
8965 id,
8966 width,
8967 height,
8968 className,
8969 canvasColor,
8970 backgroundImage,
8971 exportWithBackgroundImage,
8972 preserveBackgroundImageAspectRatio,
8973 allowOnlyPointerType,
8974 style,
8975 svgStyle,
8976 paths: currentPaths,
8977 isDrawing,
8978 onPointerDown: function handlePointerDown(point) {
8979 setIsDrawing(true);
8980 setUndoStack([]);
8981 var stroke = {
8982 drawMode,
8983 strokeColor: drawMode ? strokeColor : "#000000",
8984 strokeWidth: drawMode ? strokeWidth : eraserWidth,
8985 paths: [point]
8986 };
8987 if (withTimestamp) stroke = _extends({}, stroke, {
8988 startTimestamp: Date.now(),
8989 endTimestamp: 0
8990 });
8991 setCurrentPaths(function(currentPaths) {
8992 return [].concat(currentPaths, [stroke]);
8993 });
8994 },
8995 onPointerMove: function handlePointerMove(point) {
8996 if (!isDrawing) return;
8997 var currentStroke = currentPaths.slice(-1)[0];
8998 var updatedStroke = _extends({}, currentStroke, { paths: [].concat(currentStroke.paths, [point]) });
8999 setCurrentPaths(function(currentPaths) {
9000 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9001 });
9002 },
9003 onPointerUp: function handlePointerUp() {
9004 var _currentPaths$slice$2;
9005 var _currentPaths$slice2;
9006 if (!isDrawing) return;
9007 setIsDrawing(false);
9008 if (!withTimestamp) return;
9009 var currentStroke = (_currentPaths$slice$2 = (_currentPaths$slice2 = currentPaths.slice(-1)) == null ? void 0 : _currentPaths$slice2[0]) != null ? _currentPaths$slice$2 : null;
9010 if (currentStroke === null) return;
9011 var updatedStroke = _extends({}, currentStroke, { endTimestamp: Date.now() });
9012 setCurrentPaths(function(currentPaths) {
9013 return [].concat(currentPaths.slice(0, -1), [updatedStroke]);
9014 });
9015 }
9016 });
9017 });
9018
9019 //#endregion
9020 //#region modules/ai/assets/js/editor/icons/undo-icon.js
9021 init_extends();
9022 var UndoIcon = react.default.forwardRef(function(props, ref) {
9023 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M9.53033 6.53033C9.82322 6.23744 9.82322 5.76256 9.53033 5.46967C9.23744 5.17678 8.76256 5.17678 8.46967 5.46967L4.46967 9.46967C4.39776 9.54158 4.34351 9.62445 4.30691 9.71291C4.27024 9.80134 4.25 9.89831 4.25 10C4.25 10.1017 4.27024 10.1987 4.30691 10.2871C4.34351 10.3755 4.39776 10.4584 4.46967 10.5303L8.46967 14.5303C8.76256 14.8232 9.23744 14.8232 9.53033 14.5303C9.82322 14.2374 9.82322 13.7626 9.53033 13.4697L6.81066 10.75H16C16.862 10.75 17.6886 11.0924 18.2981 11.7019C18.9076 12.3114 19.25 13.138 19.25 14C19.25 14.862 18.9076 15.6886 18.2981 16.2981C17.6886 16.9076 16.862 17.25 16 17.25H15C14.5858 17.25 14.25 17.5858 14.25 18C14.25 18.4142 14.5858 18.75 15 18.75H16C17.2598 18.75 18.468 18.2496 19.3588 17.3588C20.2496 16.468 20.75 15.2598 20.75 14C20.75 12.7402 20.2496 11.532 19.3588 10.6412C18.468 9.75044 17.2598 9.25 16 9.25H6.81066L9.53033 6.53033Z" }));
9024 });
9025
9026 //#endregion
9027 //#region modules/ai/assets/js/editor/icons/redo-icon.js
9028 init_extends();
9029 var RedoIcon = react.default.forwardRef(function(props, ref) {
9030 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M15.5303 5.46967C15.2374 5.17678 14.7626 5.17678 14.4697 5.46967C14.1768 5.76256 14.1768 6.23744 14.4697 6.53033L17.1893 9.25H8C6.74022 9.25 5.53204 9.75044 4.64124 10.6412C3.75044 11.532 3.25 12.7402 3.25 14C3.25 15.2598 3.75044 16.468 4.64124 17.3588C5.53204 18.2496 6.74022 18.75 8 18.75H9C9.41421 18.75 9.75 18.4142 9.75 18C9.75 17.5858 9.41421 17.25 9 17.25H8C7.13805 17.25 6.3114 16.9076 5.7019 16.2981C5.09241 15.6886 4.75 14.862 4.75 14C4.75 13.138 5.09241 12.3114 5.7019 11.7019C6.3114 11.0924 7.13805 10.75 8 10.75H17.1893L14.4697 13.4697C14.1768 13.7626 14.1768 14.2374 14.4697 14.5303C14.7626 14.8232 15.2374 14.8232 15.5303 14.5303L19.5303 10.5303C19.6768 10.3839 19.75 10.1919 19.75 10C19.75 9.89831 19.7298 9.80134 19.6931 9.71291C19.6565 9.62445 19.6022 9.54158 19.5303 9.46967L15.5303 5.46967Z" }));
9031 });
9032
9033 //#endregion
9034 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/in-painting-content.js
9035 init_asyncToGenerator();
9036 init_slicedToArray();
9037 var STROKE_SELECT_WIDTH$1 = 120;
9038 var BRUSH_COLOR$1 = "rgba(255, 255, 255)";
9039 var CANVAS_COLOR$1 = "rgba(0, 0, 0)";
9040 var StyledUndoIcon$1 = (0, _elementor_ui.withDirection)(UndoIcon);
9041 var StyledRedoIcon$1 = (0, _elementor_ui.withDirection)(RedoIcon);
9042 var BrushCursor$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9043 return "size" === prop;
9044 } })(function(_ref) {
9045 var theme = _ref.theme;
9046 var size = _ref.size;
9047 return {
9048 position: "absolute",
9049 width: size,
9050 height: size,
9051 borderRadius: "50%",
9052 backgroundColor: BRUSH_COLOR$1,
9053 pointerEvents: "none",
9054 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
9055 border: "1px solid #fff"
9056 };
9057 });
9058 var BrishSizeIcon$1 = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
9059 return "size" === prop;
9060 } })(function(_ref2) {
9061 var theme = _ref2.theme;
9062 var size = _ref2.size;
9063 return {
9064 width: size / 2,
9065 height: size / 2,
9066 borderRadius: "50%",
9067 backgroundColor: theme.palette.secondary.main
9068 };
9069 });
9070 var InPaintingContent = function InPaintingContent(_ref3) {
9071 var editImage = _ref3.editImage;
9072 var setMask = _ref3.setMask;
9073 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
9074 var canvasWidth = _ref3.width;
9075 var canvasHeight = _ref3.height;
9076 var sketchRef = (0, react.useRef)();
9077 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
9078 var stroke = _useState2[0];
9079 var setStroke = _useState2[1];
9080 var brushCursorRef = (0, react.useRef)();
9081 (0, react.useEffect)(function() {
9082 var canvas = document.querySelector(".eui-in-painting-canvas");
9083 var positionElement = function positionElement(e) {
9084 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
9085 var left = _canvas$getBoundingCl.left;
9086 var top = _canvas$getBoundingCl.top;
9087 var width = _canvas$getBoundingCl.width;
9088 var height = _canvas$getBoundingCl.height;
9089 var x = e.clientX - left;
9090 var y = e.clientY - top;
9091 if (x > 0 && x < width && y > 0 && y < height) {
9092 brushCursorRef.current.style.left = "".concat(x, "px");
9093 brushCursorRef.current.style.top = "".concat(y, "px");
9094 }
9095 };
9096 window.addEventListener("mousemove", positionElement);
9097 return function() {
9098 window.removeEventListener("mousemove", positionElement);
9099 };
9100 }, [stroke]);
9101 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9102 alignItems: "flex-start",
9103 spacing: .5,
9104 flexGrow: 1
9105 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9106 width: "100%",
9107 direction: "row",
9108 spacing: 3,
9109 alignSelf: "center",
9110 justifyContent: "center",
9111 sx: { marginBottom: "20px !important" }
9112 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9113 direction: "row",
9114 gap: 1
9115 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
9116 variant: "outlined",
9117 color: "secondary",
9118 onClick: function onClick() {
9119 return sketchRef.current.undo();
9120 },
9121 sx: { px: 0 }
9122 }, /*#__PURE__*/ react.default.createElement(StyledUndoIcon$1, null))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Redo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
9123 variant: "outlined",
9124 color: "secondary",
9125 onClick: function onClick() {
9126 return sketchRef.current.redo();
9127 },
9128 sx: { px: 0 }
9129 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon$1, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
9130 size: "small",
9131 color: "secondary",
9132 sx: { minWidth: STROKE_SELECT_WIDTH$1 }
9133 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
9134 autoWidth: true,
9135 label: "Stroke",
9136 value: stroke,
9137 id: "demo-simple-select",
9138 labelId: "demo-simple-select-label",
9139 onChange: function onChange(e) {
9140 return setStroke(e.target.value);
9141 },
9142 MenuProps: {
9143 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH$1 } },
9144 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH$1 } }
9145 },
9146 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
9147 mr: .25,
9148 width: "initial",
9149 minWidth: "initial",
9150 justifyContent: "flex-start"
9151 } }
9152 }, [
9153 10,
9154 20,
9155 30,
9156 40,
9157 50
9158 ].map(function(value) {
9159 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
9160 key: "stroke-width-option-" + value,
9161 value
9162 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9163 direction: "row",
9164 alignItems: "center",
9165 gap: 1
9166 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
9167 width: 30,
9168 display: "flex",
9169 justifyContent: "center"
9170 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon$1, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
9171 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
9172 margin: "0 auto",
9173 position: "relative",
9174 cursor: "none",
9175 overflow: "hidden"
9176 } }, /*#__PURE__*/ react.default.createElement(BrushCursor$1, {
9177 ref: brushCursorRef,
9178 size: stroke
9179 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
9180 className: "eui-in-painting-canvas",
9181 withViewBox: true,
9182 ref: sketchRef,
9183 height: canvasHeight + "px",
9184 width: canvasWidth + "px",
9185 strokeWidth: stroke,
9186 strokeColor: BRUSH_COLOR$1,
9187 canvasColor: CANVAS_COLOR$1,
9188 backgroundImage: editImage.url,
9189 onStroke: function onStroke() {
9190 return setIsCanvasChanged(true);
9191 },
9192 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
9193 var svg;
9194 return import_regenerator$2.default.wrap(function(_context) {
9195 while (1) switch (_context.prev = _context.next) {
9196 case 0:
9197 _context.next = 1;
9198 return sketchRef.current.exportSvg();
9199 case 1:
9200 svg = _context.sent;
9201 setMask(svg);
9202 case 2:
9203 case "end": return _context.stop();
9204 }
9205 }, _callee);
9206 }))
9207 })));
9208 };
9209 InPaintingContent.propTypes = {
9210 setMask: import_prop_types$7.default.func.isRequired,
9211 setIsCanvasChanged: import_prop_types$7.default.func.isRequired,
9212 width: import_prop_types$7.default.number.isRequired,
9213 height: import_prop_types$7.default.number.isRequired,
9214 editImage: import_prop_types$7.default.object.isRequired
9215 };
9216
9217 //#endregion
9218 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/hooks/use-in-painting.js
9219 init_api();
9220 var useInPainting = function useInPainting(initialValue) {
9221 return useImagePrompt(function fetchAction(payload) {
9222 return getImageToImageMaskGeneration(payload);
9223 }, initialValue);
9224 };
9225
9226 //#endregion
9227 //#region modules/ai/assets/js/editor/pages/form-media/views/in-painting/index.js
9228 init_asyncToGenerator();
9229 init_slicedToArray();
9230 init_requests_ids();
9231 var InPainting = function InPainting() {
9232 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
9233 var prompt = _useState2[0];
9234 var setPrompt = _useState2[1];
9235 var setGenerate = useRequestIds().setGenerate;
9236 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
9237 var mask = _useState4[0];
9238 var setMask = _useState4[1];
9239 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
9240 var isCanvasChanged = _useState6[0];
9241 var setIsCanvasChanged = _useState6[1];
9242 var _usePromptSettings = usePromptSettings();
9243 var settings = _usePromptSettings.settings;
9244 var resetSettings = _usePromptSettings.resetSettings;
9245 var _useEditImage = useEditImage();
9246 var editImage = _useEditImage.editImage;
9247 var width = _useEditImage.width;
9248 var height = _useEditImage.height;
9249 var _useImageActions = useImageActions();
9250 var use = _useImageActions.use;
9251 var edit = _useImageActions.edit;
9252 var isUploading = _useImageActions.isLoading;
9253 var _useInPainting = useInPainting();
9254 var data = _useInPainting.data;
9255 var send = _useInPainting.send;
9256 var isGenerating = _useInPainting.isLoading;
9257 var error = _useInPainting.error;
9258 var reset = _useInPainting.reset;
9259 var isLoading = isGenerating || isUploading;
9260 var handleSubmit = /*#__PURE__*/ function() {
9261 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
9262 var finalPrompt;
9263 return import_regenerator$2.default.wrap(function(_context) {
9264 while (1) switch (_context.prev = _context.next) {
9265 case 0:
9266 event.preventDefault();
9267 finalPrompt = prompt || "Remove object and fill based on the surroundings";
9268 setGenerate();
9269 send({
9270 prompt: finalPrompt,
9271 settings,
9272 image: editImage,
9273 mask
9274 });
9275 case 1:
9276 case "end": return _context.stop();
9277 }
9278 }, _callee);
9279 }));
9280 return function handleSubmit(_x) {
9281 return _ref.apply(this, arguments);
9282 };
9283 }();
9284 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
9285 primary: (0, _wordpress_i18n.__)("Generative Fill", "elementor"),
9286 secondary: (0, _wordpress_i18n.__)("Mark an area and edit it with a prompt.", "elementor")
9287 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
9288 error,
9289 onRetry: handleSubmit
9290 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
9291 value: prompt,
9292 disabled: isLoading,
9293 onChange: setPrompt,
9294 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the marked area (English only)", "elementor")
9295 }), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9296 gap: 2,
9297 sx: { my: 2.5 }
9298 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
9299 disabled: isLoading,
9300 onClick: function onClick() {
9301 resetSettings();
9302 setPrompt("");
9303 reset();
9304 }
9305 })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading || !prompt || !isCanvasChanged }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
9306 images: data.result,
9307 aspectRatio: editImage.aspectRatio,
9308 onUseImage: use,
9309 onEditImage: edit
9310 }) : /*#__PURE__*/ react.default.createElement(InPaintingContent, {
9311 editImage,
9312 width,
9313 height,
9314 setMask,
9315 setIsCanvasChanged
9316 })));
9317 };
9318
9319 //#endregion
9320 //#region node_modules/react-avatar-editor/dist/index.js
9321 var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9322 (function(e, t) {
9323 "object" == typeof exports && "undefined" != typeof module ? module.exports = t(require_prop_types(), (globalThis.React)) : "function" == typeof define && define.amd ? define(["prop-types", "react"], t) : (e = "undefined" != typeof globalThis ? globalThis : e || self).AvatarEditor = t(e.PropTypes, e.React);
9324 })(exports, function(e, t) {
9325 "use strict";
9326 function o(e) {
9327 return e && "object" == typeof e && "default" in e ? e : { default: e };
9328 }
9329 var n = o(e);
9330 var i = o(t);
9331 function r(e, t) {
9332 for (var o = 0; o < t.length; o++) {
9333 var n = t[o];
9334 n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
9335 }
9336 }
9337 function s(e, t, o) {
9338 return t in e ? Object.defineProperty(e, t, {
9339 value: o,
9340 enumerable: !0,
9341 configurable: !0,
9342 writable: !0
9343 }) : e[t] = o, e;
9344 }
9345 function u() {
9346 return (u = Object.assign || function(e) {
9347 for (var t = 1; t < arguments.length; t++) {
9348 var o = arguments[t];
9349 for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (e[n] = o[n]);
9350 }
9351 return e;
9352 }).apply(this, arguments);
9353 }
9354 function a(t, e) {
9355 var o;
9356 var n = Object.keys(t);
9357 return Object.getOwnPropertySymbols && (o = Object.getOwnPropertySymbols(t), e && (o = o.filter(function(e) {
9358 return Object.getOwnPropertyDescriptor(t, e).enumerable;
9359 })), n.push.apply(n, o)), n;
9360 }
9361 function y(t) {
9362 for (var e = 1; e < arguments.length; e++) {
9363 var o = null != arguments[e] ? arguments[e] : {};
9364 e % 2 ? a(Object(o), !0).forEach(function(e) {
9365 s(t, e, o[e]);
9366 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(o)) : a(Object(o)).forEach(function(e) {
9367 Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(o, e));
9368 });
9369 }
9370 return t;
9371 }
9372 function h(e) {
9373 return (h = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
9374 return e.__proto__ || Object.getPrototypeOf(e);
9375 })(e);
9376 }
9377 function c(e, t) {
9378 return (c = Object.setPrototypeOf || function(e, t) {
9379 return e.__proto__ = t, e;
9380 })(e, t);
9381 }
9382 function l(e, t) {
9383 if (null == e) return {};
9384 var o;
9385 var n = function(e, t) {
9386 if (null == e) return {};
9387 for (var o, n = {}, a = Object.keys(e), r = 0; r < a.length; r++) o = a[r], 0 <= t.indexOf(o) || (n[o] = e[o]);
9388 return n;
9389 }(e, t);
9390 if (Object.getOwnPropertySymbols) for (var a = Object.getOwnPropertySymbols(e), r = 0; r < a.length; r++) o = a[r], 0 <= t.indexOf(o) || Object.prototype.propertyIsEnumerable.call(e, o) && (n[o] = e[o]);
9391 return n;
9392 }
9393 function d(e) {
9394 if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
9395 return e;
9396 }
9397 function p(r) {
9398 var i = function() {
9399 if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
9400 if (Reflect.construct.sham) return !1;
9401 if ("function" == typeof Proxy) return !0;
9402 try {
9403 return Date.prototype.toString.call(Reflect.construct(Date, [], function() {})), !0;
9404 } catch (e) {
9405 return !1;
9406 }
9407 }();
9408 return function() {
9409 var e;
9410 var t;
9411 var o;
9412 var n;
9413 var a = h(r);
9414 return t = i ? (e = h(this).constructor, Reflect.construct(a, arguments, e)) : a.apply(this, arguments), o = this, !(n = t) || "object" != typeof n && "function" != typeof n ? d(o) : n;
9415 };
9416 }
9417 function m(e, t) {
9418 return function(e) {
9419 if (Array.isArray(e)) return e;
9420 }(e) || function(e, t) {
9421 if ("undefined" == typeof Symbol || !(Symbol.iterator in Object(e))) return;
9422 var o = [];
9423 var n = !0;
9424 var a = !1;
9425 var r = void 0;
9426 try {
9427 for (var i, s = e[Symbol.iterator](); !(n = (i = s.next()).done) && (o.push(i.value), !t || o.length !== t); n = !0);
9428 } catch (e) {
9429 a = !0, r = e;
9430 } finally {
9431 try {
9432 n || null == s.return || s.return();
9433 } finally {
9434 if (a) throw r;
9435 }
9436 }
9437 return o;
9438 }(e, t) || g(e, t) || function() {
9439 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9440 }();
9441 }
9442 function g(e, t) {
9443 if (e) {
9444 if ("string" == typeof e) return f(e, t);
9445 var o = Object.prototype.toString.call(e).slice(8, -1);
9446 return "Object" === o && e.constructor && (o = e.constructor.name), "Map" === o || "Set" === o ? Array.from(e) : "Arguments" === o || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o) ? f(e, t) : void 0;
9447 }
9448 }
9449 function f(e, t) {
9450 (null == t || t > e.length) && (t = e.length);
9451 for (var o = 0, n = new Array(t); o < t; o++) n[o] = e[o];
9452 return n;
9453 }
9454 function v(a, r) {
9455 return new Promise(function(e, t) {
9456 var o;
9457 var n = new Image();
9458 n.onload = function() {
9459 return e(n);
9460 }, n.onerror = t, !1 == (null !== (o = a) && !!o.match(/^\s*data:([a-z]+\/[a-z]+(;[a-z-]+=[a-z-]+)?)?(;base64)?,[a-z0-9!$&',()*+;=\-._~:@/?%\s]*\s*$/i)) && r && (n.crossOrigin = r), n.src = a;
9461 });
9462 }
9463 var b;
9464 var w = !("undefined" == typeof window || "undefined" == typeof navigator || !("ontouchstart" in window || 0 < navigator.msMaxTouchPoints));
9465 var M = "undefined" != typeof File;
9466 var O = {
9467 touch: {
9468 react: {
9469 down: "onTouchStart",
9470 mouseDown: "onMouseDown",
9471 drag: "onTouchMove",
9472 move: "onTouchMove",
9473 mouseMove: "onMouseMove",
9474 up: "onTouchEnd",
9475 mouseUp: "onMouseUp"
9476 },
9477 native: {
9478 down: "touchstart",
9479 mouseDown: "mousedown",
9480 drag: "touchmove",
9481 move: "touchmove",
9482 mouseMove: "mousemove",
9483 up: "touchend",
9484 mouseUp: "mouseup"
9485 }
9486 },
9487 desktop: {
9488 react: {
9489 down: "onMouseDown",
9490 drag: "onDragOver",
9491 move: "onMouseMove",
9492 up: "onMouseUp"
9493 },
9494 native: {
9495 down: "mousedown",
9496 drag: "dragStart",
9497 move: "mousemove",
9498 up: "mouseup"
9499 }
9500 }
9501 };
9502 var I = w ? O.touch : O.desktop;
9503 var P = "undefined" != typeof window && window.devicePixelRatio ? window.devicePixelRatio : 1;
9504 var C = {
9505 x: .5,
9506 y: .5
9507 };
9508 var x = function() {
9509 (function(e, t) {
9510 if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
9511 e.prototype = Object.create(t && t.prototype, { constructor: {
9512 value: e,
9513 writable: !0,
9514 configurable: !0
9515 } }), t && c(e, t);
9516 })(a, i["default"].Component);
9517 var e;
9518 var t;
9519 var o;
9520 var n = p(a);
9521 function a(e) {
9522 var v;
9523 return function(e, t) {
9524 if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
9525 }(this, a), s(d(v = n.call(this, e)), "state", {
9526 drag: !1,
9527 my: null,
9528 mx: null,
9529 image: C
9530 }), s(d(v), "handleImageReady", function(e) {
9531 var t = v.getInitialSize(e.width, e.height);
9532 t.resource = e, t.x = .5, t.y = .5, t.backgroundColor = v.props.backgroundColor, v.setState({
9533 drag: !1,
9534 image: t
9535 }, v.props.onImageReady), v.props.onLoadSuccess(t);
9536 }), s(d(v), "clearImage", function() {
9537 v.canvas.getContext("2d").clearRect(0, 0, v.canvas.width, v.canvas.height), v.setState({ image: C });
9538 }), s(d(v), "handleMouseDown", function(e) {
9539 (e = e || window.event).preventDefault(), v.setState({
9540 drag: !0,
9541 mx: null,
9542 my: null
9543 });
9544 }), s(d(v), "handleMouseUp", function() {
9545 v.state.drag && (v.setState({ drag: !1 }), v.props.onMouseUp());
9546 }), s(d(v), "handleMouseMove", function(e) {
9547 var t;
9548 var o;
9549 var n;
9550 var a;
9551 var r;
9552 var i;
9553 var s;
9554 var u;
9555 var h;
9556 var c;
9557 var l;
9558 var d;
9559 var p;
9560 var g;
9561 var f;
9562 var m;
9563 e = e || window.event, !1 !== v.state.drag && (e.preventDefault(), n = {
9564 mx: t = e.targetTouches ? e.targetTouches[0].pageX : e.clientX,
9565 my: o = e.targetTouches ? e.targetTouches[0].pageY : e.clientY
9566 }, m = v.props.rotate, m = (m %= 360) < 0 ? m + 360 : m, v.state.mx && v.state.my && (a = v.state.mx - t, r = v.state.my - o, i = v.state.image.width * v.props.scale, s = v.state.image.height * v.props.scale, h = (u = v.getCroppingRect()).x, c = u.y, h *= i, c *= s, l = function(e) {
9567 return e * (Math.PI / 180);
9568 }, d = Math.cos(l(m)), g = c + -a * (p = Math.sin(l(m))) + r * d, f = {
9569 x: (h + a * d + r * p) / i + 1 / v.props.scale * v.getXScale() / 2,
9570 y: g / s + 1 / v.props.scale * v.getYScale() / 2
9571 }, v.props.onPositionChange(f), n.image = y(y({}, v.state.image), f)), v.setState(n), v.props.onMouseMove(e));
9572 }), s(d(v), "setCanvas", function(e) {
9573 v.canvas = e;
9574 }), v.canvas = null, v;
9575 }
9576 return e = a, (t = [
9577 {
9578 key: "componentDidMount",
9579 value: function() {
9580 this.props.disableHiDPIScaling && (P = 1);
9581 var e;
9582 var t;
9583 var o = this.canvas.getContext("2d");
9584 this.props.image && this.loadImage(this.props.image), this.paint(o), document && (e = !!function() {
9585 var t = !1;
9586 try {
9587 var e = Object.defineProperty({}, "passive", { get: function() {
9588 t = !0;
9589 } });
9590 window.addEventListener("test", e, e), window.removeEventListener("test", e, e);
9591 } catch (e) {
9592 t = !1;
9593 }
9594 return t;
9595 }() && { passive: !1 }, t = I.native, document.addEventListener(t.move, this.handleMouseMove, e), document.addEventListener(t.up, this.handleMouseUp, e), w && (document.addEventListener(t.mouseMove, this.handleMouseMove, e), document.addEventListener(t.mouseUp, this.handleMouseUp, e)));
9596 }
9597 },
9598 {
9599 key: "componentDidUpdate",
9600 value: function(e, t) {
9601 this.props.image && this.props.image !== e.image || this.props.width !== e.width || this.props.height !== e.height || this.props.backgroundColor !== e.backgroundColor ? this.loadImage(this.props.image) : this.props.image || t.image === C || this.clearImage();
9602 var o = this.canvas.getContext("2d");
9603 o.clearRect(0, 0, this.canvas.width, this.canvas.height), this.paint(o), this.paintImage(o, this.state.image, this.props.border), e.image === this.props.image && e.width === this.props.width && e.height === this.props.height && e.position === this.props.position && e.scale === this.props.scale && e.rotate === this.props.rotate && t.my === this.state.my && t.mx === this.state.mx && t.image.x === this.state.image.x && t.image.y === this.state.image.y && t.backgroundColor === this.state.backgroundColor || this.props.onImageChange();
9604 }
9605 },
9606 {
9607 key: "componentWillUnmount",
9608 value: function() {
9609 var e;
9610 document && (e = I.native, document.removeEventListener(e.move, this.handleMouseMove, !1), document.removeEventListener(e.up, this.handleMouseUp, !1), w && (document.removeEventListener(e.mouseMove, this.handleMouseMove, !1), document.removeEventListener(e.mouseUp, this.handleMouseUp, !1)));
9611 }
9612 },
9613 {
9614 key: "isVertical",
9615 value: function() {
9616 return !this.props.disableCanvasRotation && this.props.rotate % 180 != 0;
9617 }
9618 },
9619 {
9620 key: "getBorders",
9621 value: function(e) {
9622 var t = 0 < arguments.length && void 0 !== e ? e : this.props.border;
9623 return Array.isArray(t) ? t : [t, t];
9624 }
9625 },
9626 {
9627 key: "getDimensions",
9628 value: function() {
9629 var e = this.props;
9630 var t = e.width;
9631 var o = e.height;
9632 var n = e.rotate;
9633 var a = e.border;
9634 var r = {};
9635 var i = m(this.getBorders(a), 2);
9636 var s = i[0];
9637 var u = i[1];
9638 var h = t;
9639 var c = o;
9640 return this.isVertical() ? (r.width = c, r.height = h) : (r.width = h, r.height = c), r.width += 2 * s, r.height += 2 * u, {
9641 canvas: r,
9642 rotate: n,
9643 width: t,
9644 height: o,
9645 border: a
9646 };
9647 }
9648 },
9649 {
9650 key: "getImage",
9651 value: function() {
9652 var e = this.getCroppingRect();
9653 var t = this.state.image;
9654 e.x *= t.resource.width, e.y *= t.resource.height, e.width *= t.resource.width, e.height *= t.resource.height;
9655 var o = document.createElement("canvas");
9656 this.isVertical() ? (o.width = e.height, o.height = e.width) : (o.width = e.width, o.height = e.height);
9657 var n = o.getContext("2d");
9658 return n.translate(o.width / 2, o.height / 2), n.rotate(this.props.rotate * Math.PI / 180), n.translate(-o.width / 2, -o.height / 2), this.isVertical() && n.translate((o.width - o.height) / 2, (o.height - o.width) / 2), t.backgroundColor && (n.fillStyle = t.backgroundColor, n.fillRect(-e.x, -e.y, t.resource.width, t.resource.height)), n.drawImage(t.resource, -e.x, -e.y), o;
9659 }
9660 },
9661 {
9662 key: "getImageScaledToCanvas",
9663 value: function() {
9664 var e = this.getDimensions();
9665 var t = e.width;
9666 var o = e.height;
9667 var n = document.createElement("canvas");
9668 return this.isVertical() ? (n.width = o, n.height = t) : (n.width = t, n.height = o), this.paintImage(n.getContext("2d"), this.state.image, 0, 1), n;
9669 }
9670 },
9671 {
9672 key: "getXScale",
9673 value: function() {
9674 var e = this.props.width / this.props.height;
9675 var t = this.state.image.width / this.state.image.height;
9676 return Math.min(1, e / t);
9677 }
9678 },
9679 {
9680 key: "getYScale",
9681 value: function() {
9682 var e = this.props.height / this.props.width;
9683 var t = this.state.image.height / this.state.image.width;
9684 return Math.min(1, e / t);
9685 }
9686 },
9687 {
9688 key: "getCroppingRect",
9689 value: function() {
9690 var e = this.props.position || {
9691 x: this.state.image.x,
9692 y: this.state.image.y
9693 };
9694 var t = 1 / this.props.scale * this.getXScale();
9695 var o = 1 / this.props.scale * this.getYScale();
9696 var n = {
9697 x: e.x - t / 2,
9698 y: e.y - o / 2,
9699 width: t,
9700 height: o
9701 };
9702 var a = 0;
9703 var r = 1 - n.width;
9704 var i = 0;
9705 var s = 1 - n.height;
9706 return (this.props.disableBoundaryChecks || 1 < t || 1 < o) && (a = -n.width, i = -n.height, s = r = 1), y(y({}, n), {}, {
9707 x: Math.max(a, Math.min(n.x, r)),
9708 y: Math.max(i, Math.min(n.y, s))
9709 });
9710 }
9711 },
9712 {
9713 key: "loadImage",
9714 value: function(e) {
9715 var t;
9716 M && e instanceof File ? this.loadingImage = (t = e, new Promise(function(o, n) {
9717 var e = new FileReader();
9718 e.onload = function(e) {
9719 try {
9720 o(v(e.target.result));
9721 } catch (e) {
9722 n(e);
9723 }
9724 }, e.readAsDataURL(t);
9725 }).then(this.handleImageReady).catch(this.props.onLoadFailure)) : "string" == typeof e && (this.loadingImage = v(e, this.props.crossOrigin).then(this.handleImageReady).catch(this.props.onLoadFailure));
9726 }
9727 },
9728 {
9729 key: "getInitialSize",
9730 value: function(e, t) {
9731 var o;
9732 var n;
9733 var a = this.getDimensions();
9734 return t / e < a.height / a.width ? n = e * ((o = this.getDimensions().height) / t) : o = t * ((n = this.getDimensions().width) / e), {
9735 height: o,
9736 width: n
9737 };
9738 }
9739 },
9740 {
9741 key: "paintImage",
9742 value: function(e, t, o, n) {
9743 var a;
9744 var r = 3 < arguments.length && void 0 !== n ? n : P;
9745 t.resource && (a = this.calculatePosition(t, o), e.save(), e.translate(e.canvas.width / 2, e.canvas.height / 2), e.rotate(this.props.rotate * Math.PI / 180), e.translate(-e.canvas.width / 2, -e.canvas.height / 2), this.isVertical() && e.translate((e.canvas.width - e.canvas.height) / 2, (e.canvas.height - e.canvas.width) / 2), e.scale(r, r), e.globalCompositeOperation = "destination-over", e.drawImage(t.resource, a.x, a.y, a.width, a.height), t.backgroundColor && (e.fillStyle = t.backgroundColor, e.fillRect(a.x, a.y, a.width, a.height)), e.restore());
9746 }
9747 },
9748 {
9749 key: "calculatePosition",
9750 value: function(e, t) {
9751 e = e || this.state.image;
9752 var o = m(this.getBorders(t), 2);
9753 var n = o[0];
9754 var a = o[1];
9755 var r = this.getCroppingRect();
9756 var i = e.width * this.props.scale;
9757 var s = e.height * this.props.scale;
9758 var u = -r.x * i;
9759 var h = -r.y * s;
9760 return this.isVertical() ? (u += a, h += n) : (u += n, h += a), {
9761 x: u,
9762 y: h,
9763 height: s,
9764 width: i
9765 };
9766 }
9767 },
9768 {
9769 key: "paint",
9770 value: function(e) {
9771 e.save(), e.scale(P, P), e.translate(0, 0), e.fillStyle = "rgba(" + this.props.color.slice(0, 4).join(",") + ")";
9772 var t;
9773 var o;
9774 var n;
9775 var a;
9776 var r;
9777 var i;
9778 var s;
9779 var u;
9780 var h = this.props.borderRadius;
9781 var c = this.getDimensions();
9782 var l = m(this.getBorders(c.border), 2);
9783 var d = l[0];
9784 var p = l[1];
9785 var g = c.canvas.height;
9786 var f = c.canvas.width;
9787 var h = Math.max(h, 0);
9788 h = Math.min(h, f / 2 - d, g / 2 - p), e.beginPath(), t = e, a = f - 2 * (o = d), r = g - 2 * (n = p), 0 === (i = h) ? t.rect(o, n, a, r) : (s = a - i, u = r - i, t.translate(o, n), t.arc(i, i, i, Math.PI, 1.5 * Math.PI), t.lineTo(s, 0), t.arc(s, i, i, 1.5 * Math.PI, 2 * Math.PI), t.lineTo(a, u), t.arc(s, u, i, 2 * Math.PI, .5 * Math.PI), t.lineTo(i, r), t.arc(i, u, i, .5 * Math.PI, Math.PI), t.translate(-o, -n)), e.rect(f, 0, -f, g), e.fill("evenodd"), e.restore();
9789 }
9790 },
9791 {
9792 key: "render",
9793 value: function() {
9794 var e = this.props;
9795 var t = (e.scale, e.rotate, e.image, e.border, e.borderRadius, e.width, e.height, e.position, e.color, e.backgroundColor, e.style);
9796 var o = (e.crossOrigin, e.onLoadFailure, e.onLoadSuccess, e.onImageReady, e.onImageChange, e.onMouseUp, e.onMouseMove, e.onPositionChange, e.disableBoundaryChecks, e.disableHiDPIScaling, e.disableCanvasRotation, l(e, [
9797 "scale",
9798 "rotate",
9799 "image",
9800 "border",
9801 "borderRadius",
9802 "width",
9803 "height",
9804 "position",
9805 "color",
9806 "backgroundColor",
9807 "style",
9808 "crossOrigin",
9809 "onLoadFailure",
9810 "onLoadSuccess",
9811 "onImageReady",
9812 "onImageChange",
9813 "onMouseUp",
9814 "onMouseMove",
9815 "onPositionChange",
9816 "disableBoundaryChecks",
9817 "disableHiDPIScaling",
9818 "disableCanvasRotation"
9819 ]));
9820 var n = this.getDimensions();
9821 var a = {
9822 width: n.canvas.width,
9823 height: n.canvas.height,
9824 cursor: this.state.drag ? "grabbing" : "grab",
9825 touchAction: "none"
9826 };
9827 var r = {
9828 width: n.canvas.width * P,
9829 height: n.canvas.height * P,
9830 style: y(y({}, a), t)
9831 };
9832 return r[I.react.down] = this.handleMouseDown, w && (r[I.react.mouseDown] = this.handleMouseDown), i.default.createElement("canvas", u({ ref: this.setCanvas }, r, o));
9833 }
9834 }
9835 ]) && r(e.prototype, t), o && r(e, o), a;
9836 }();
9837 return s(x, "propTypes", {
9838 scale: n.default.number,
9839 rotate: n.default.number,
9840 image: n.default.oneOfType([n.default.string].concat(function(e) {
9841 if (Array.isArray(e)) return f(e);
9842 }(b = M ? [n.default.instanceOf(File)] : []) || function(e) {
9843 if ("undefined" != typeof Symbol && Symbol.iterator in Object(e)) return Array.from(e);
9844 }(b) || g(b) || function() {
9845 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9846 }())),
9847 border: n.default.oneOfType([n.default.number, n.default.arrayOf(n.default.number)]),
9848 borderRadius: n.default.number,
9849 width: n.default.number,
9850 height: n.default.number,
9851 position: n.default.shape({
9852 x: n.default.number,
9853 y: n.default.number
9854 }),
9855 color: n.default.arrayOf(n.default.number),
9856 backgroundColor: n.default.string,
9857 crossOrigin: n.default.oneOf([
9858 "",
9859 "anonymous",
9860 "use-credentials"
9861 ]),
9862 onLoadFailure: n.default.func,
9863 onLoadSuccess: n.default.func,
9864 onImageReady: n.default.func,
9865 onImageChange: n.default.func,
9866 onMouseUp: n.default.func,
9867 onMouseMove: n.default.func,
9868 onPositionChange: n.default.func,
9869 disableBoundaryChecks: n.default.bool,
9870 disableHiDPIScaling: n.default.bool,
9871 disableCanvasRotation: n.default.bool
9872 }), s(x, "defaultProps", {
9873 scale: 1,
9874 rotate: 0,
9875 border: 25,
9876 borderRadius: 0,
9877 width: 200,
9878 height: 200,
9879 color: [
9880 0,
9881 0,
9882 0,
9883 .5
9884 ],
9885 onLoadFailure: function() {},
9886 onLoadSuccess: function() {},
9887 onImageReady: function() {},
9888 onImageChange: function() {},
9889 onMouseUp: function() {},
9890 onMouseMove: function() {},
9891 onPositionChange: function() {},
9892 disableBoundaryChecks: !1,
9893 disableHiDPIScaling: !1,
9894 disableCanvasRotation: !0
9895 }), x;
9896 });
9897 }));
9898
9899 //#endregion
9900 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/out-painting-content.js
9901 init_asyncToGenerator();
9902 var import_dist = /* @__PURE__ */ __toESM(require_dist());
9903 var OutPaintingContent = function OutPaintingContent(_ref) {
9904 var scale = _ref.scale;
9905 var setMask = _ref.setMask;
9906 var editImage = _ref.editImage;
9907 var aspectRatio = _ref.aspectRatio;
9908 var setImageSize = _ref.setImageSize;
9909 var setPosition = _ref.setPosition;
9910 var cropperRef = (0, react.useRef)();
9911 var position = (0, react.useRef)({
9912 x: .5,
9913 y: .5
9914 });
9915 var _useImageSize = useImageSize(aspectRatio);
9916 var width = _useImageSize.width;
9917 var height = _useImageSize.height;
9918 var imageSize = {
9919 width,
9920 height
9921 };
9922 var updateMask = /*#__PURE__*/ function() {
9923 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
9924 var imageDataURL;
9925 return import_regenerator$2.default.wrap(function(_context) {
9926 while (1) switch (_context.prev = _context.next) {
9927 case 0:
9928 _context.next = 1;
9929 return cropperRef.current.getImageScaledToCanvas().toDataURL();
9930 case 1:
9931 imageDataURL = _context.sent;
9932 setMask(imageDataURL);
9933 case 2:
9934 case "end": return _context.stop();
9935 }
9936 }, _callee);
9937 }));
9938 return function updateMask() {
9939 return _ref2.apply(this, arguments);
9940 };
9941 }();
9942 var _onPositionChange = /*#__PURE__*/ function() {
9943 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2(args) {
9944 return import_regenerator$2.default.wrap(function(_context2) {
9945 while (1) switch (_context2.prev = _context2.next) {
9946 case 0:
9947 position.current = {
9948 x: args.x,
9949 y: args.y
9950 };
9951 _context2.next = 1;
9952 return updateMask();
9953 case 1: setPosition(position.current);
9954 case 2:
9955 case "end": return _context2.stop();
9956 }
9957 }, _callee2);
9958 }));
9959 return function onPositionChange(_x) {
9960 return _ref3.apply(this, arguments);
9961 };
9962 }();
9963 var onImageChange = /*#__PURE__*/ function() {
9964 var _ref4 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3() {
9965 return import_regenerator$2.default.wrap(function(_context3) {
9966 while (1) switch (_context3.prev = _context3.next) {
9967 case 0:
9968 imageSize = {
9969 width: imageSize.width * scale,
9970 height: imageSize.height * scale
9971 };
9972 _context3.next = 1;
9973 return updateMask();
9974 case 1: setImageSize(imageSize);
9975 case 2:
9976 case "end": return _context3.stop();
9977 }
9978 }, _callee3);
9979 }));
9980 return function onImageChange() {
9981 return _ref4.apply(this, arguments);
9982 };
9983 }();
9984 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
9985 alignItems: "center",
9986 spacing: .5,
9987 flexGrow: 1
9988 }, /*#__PURE__*/ react.default.createElement(import_dist.default, {
9989 ref: cropperRef,
9990 image: editImage.url,
9991 style: {
9992 backgroundImage: "linear-gradient(45deg, #bbb 25%, transparent 25%), linear-gradient(-45deg, #bbb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #bbb 75%), linear-gradient(-45deg, transparent 75%, #bbb 75%)",
9993 backgroundSize: "20px 20px",
9994 backgroundPosition: "0 0, 0 10px, 10px -10px, -10px 0px",
9995 outline: "2px dashed #000",
9996 marginTop: "12px"
9997 },
9998 color: [
9999 0,
10000 0,
10001 0,
10002 .9
10003 ],
10004 rotate: 0,
10005 border: 0,
10006 allowZoomOut: true,
10007 backgroundColor: "transparent",
10008 showGrid: true,
10009 onImageChange,
10010 onPositionChange: function onPositionChange(args) {
10011 return _onPositionChange(args);
10012 },
10013 width,
10014 height,
10015 scale
10016 }));
10017 };
10018 OutPaintingContent.propTypes = {
10019 scale: import_prop_types$7.default.number.isRequired,
10020 setMask: import_prop_types$7.default.func.isRequired,
10021 editImage: import_prop_types$7.default.object.isRequired,
10022 aspectRatio: import_prop_types$7.default.string.isRequired,
10023 setImageSize: import_prop_types$7.default.func.isRequired,
10024 setPosition: import_prop_types$7.default.func.isRequired
10025 };
10026
10027 //#endregion
10028 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/hooks/use-out-painting.js
10029 init_api();
10030 var useOutPainting = function useOutPainting(initialValue) {
10031 return useImagePrompt(function fetchAction(payload) {
10032 return getImageToImageOutPainting(payload);
10033 }, initialValue);
10034 };
10035
10036 //#endregion
10037 //#region modules/ai/assets/js/editor/pages/form-media/views/out-painting/index.js
10038 init_defineProperty$1();
10039 init_asyncToGenerator();
10040 init_slicedToArray();
10041 init_requests_ids();
10042 var OutPainting = function OutPainting() {
10043 var _useState2 = _slicedToArray((0, react.useState)({
10044 width: 0,
10045 height: 0
10046 }), 2);
10047 var imageSize = _useState2[0];
10048 var setImageSize = _useState2[1];
10049 var _useState4 = _slicedToArray((0, react.useState)({
10050 x: .5,
10051 y: .5
10052 }), 2);
10053 var position = _useState4[0];
10054 var setPosition = _useState4[1];
10055 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
10056 var mask = _useState6[0];
10057 var setMask = _useState6[1];
10058 var setGenerate = useRequestIds().setGenerate;
10059 var _useEditImage = useEditImage();
10060 var editImage = _useEditImage.editImage;
10061 var initialAspectRatio = _useEditImage.aspectRatio;
10062 var _usePromptSettings = usePromptSettings({ aspectRatio: initialAspectRatio });
10063 var settings = _usePromptSettings.settings;
10064 var updateSettings = _usePromptSettings.updateSettings;
10065 var _useImageActions = useImageActions();
10066 var use = _useImageActions.use;
10067 var edit = _useImageActions.edit;
10068 var isUploading = _useImageActions.isLoading;
10069 var _useOutPainting = useOutPainting();
10070 var data = _useOutPainting.data;
10071 var send = _useOutPainting.send;
10072 var isGenerating = _useOutPainting.isLoading;
10073 var error = _useOutPainting.error;
10074 var isLoading = isGenerating || isUploading;
10075 var generatedAspectRatio = (0, react.useMemo)(function() {
10076 return settings[IMAGE_RATIO];
10077 }, [data === null || data === void 0 ? void 0 : data.result]);
10078 var hasGeneratedResult = !!(data !== null && data !== void 0 && data.result);
10079 var handleSubmit = /*#__PURE__*/ function() {
10080 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
10081 var imageBase64;
10082 return import_regenerator$2.default.wrap(function(_context) {
10083 while (1) switch (_context.prev = _context.next) {
10084 case 0:
10085 event.preventDefault();
10086 setGenerate();
10087 _context.next = 1;
10088 return fetchImageAsBase64(editImage.url);
10089 case 1:
10090 imageBase64 = _context.sent;
10091 send({
10092 settings,
10093 image: editImage,
10094 mask,
10095 size: imageSize,
10096 position,
10097 image_base64: imageBase64
10098 });
10099 case 2:
10100 case "end": return _context.stop();
10101 }
10102 }, _callee);
10103 }));
10104 return function handleSubmit(_x) {
10105 return _ref.apply(this, arguments);
10106 };
10107 }();
10108 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10109 primary: (0, _wordpress_i18n.__)("Expand Image", "elementor"),
10110 secondary: (0, _wordpress_i18n.__)("Position image in it’s new size to generate content around the edges.", "elementor")
10111 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10112 error,
10113 onRetry: handleSubmit
10114 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
10115 disabled: isLoading || hasGeneratedResult,
10116 value: settings[IMAGE_RATIO],
10117 onChange: function onChange(event) {
10118 return updateSettings(_defineProperty$1({}, IMAGE_RATIO, event.target.value));
10119 }
10120 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, { sx: {
10121 width: "100%",
10122 mb: 2.5
10123 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slider, {
10124 marks: true,
10125 id: "zoom",
10126 name: "zoom",
10127 max: 1,
10128 min: .1,
10129 step: .1,
10130 color: "secondary",
10131 defaultValue: 1,
10132 disabled: isLoading || hasGeneratedResult,
10133 valueLabelDisplay: "auto",
10134 "aria-labelledby": "image-size-slider",
10135 "aria-label": (0, _wordpress_i18n.__)("Reference strength", "elementor"),
10136 onChange: function onChange(_, value) {
10137 return updateSettings(_defineProperty$1({}, IMAGE_ZOOM, value));
10138 }
10139 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
10140 id: "image-size-slider",
10141 variant: "caption",
10142 gutterBottom: true
10143 }, (0, _wordpress_i18n.__)("Original image size", "elementor"))), data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10144 gap: 2,
10145 sx: { my: 2.5 }
10146 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, hasGeneratedResult ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10147 onUseImage: use,
10148 onEditImage: edit,
10149 images: data.result,
10150 aspectRatio: generatedAspectRatio
10151 }) : /*#__PURE__*/ react.default.createElement(OutPaintingContent, {
10152 setMask,
10153 editImage,
10154 scale: settings[IMAGE_ZOOM],
10155 aspectRatio: settings[IMAGE_RATIO],
10156 setImageSize,
10157 setPosition
10158 })));
10159 };
10160
10161 //#endregion
10162 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/hooks/use-image-to-image.js
10163 init_api();
10164 var useImageToImage = function useImageToImage(initialValue) {
10165 return useImagePrompt(function fetchAction(payload) {
10166 return getImageToImageGeneration(payload);
10167 }, initialValue);
10168 };
10169
10170 //#endregion
10171 //#region modules/ai/assets/js/editor/pages/form-media/views/variations/index.js
10172 init_slicedToArray();
10173 init_requests_ids();
10174 var IMAGE_WEIGHT_DEFAULT = 45;
10175 var Variations = function Variations() {
10176 var _data$result;
10177 var prompt = _slicedToArray((0, react.useState)(""), 1)[0];
10178 var setGenerate = useRequestIds().setGenerate;
10179 var _useEditImage = useEditImage();
10180 var editImage = _useEditImage.editImage;
10181 var initialAspectRatio = _useEditImage.aspectRatio;
10182 var settings = usePromptSettings({
10183 aspectRatio: initialAspectRatio,
10184 imageWeight: IMAGE_WEIGHT_DEFAULT
10185 }).settings;
10186 var _useImageToImage = useImageToImage();
10187 var data = _useImageToImage.data;
10188 var send = _useImageToImage.send;
10189 var isGenerating = _useImageToImage.isLoading;
10190 var error = _useImageToImage.error;
10191 var _useImageActions = useImageActions();
10192 var use = _useImageActions.use;
10193 var edit = _useImageActions.edit;
10194 var isUploading = _useImageActions.isLoading;
10195 var isLoading = isGenerating || isUploading;
10196 var generatedAspectRatio = (0, react.useMemo)(function() {
10197 return settings[IMAGE_RATIO];
10198 }, [data === null || data === void 0 ? void 0 : data.result]);
10199 var handleSubmit = function handleSubmit(event) {
10200 event.preventDefault();
10201 setGenerate();
10202 send({
10203 prompt,
10204 settings,
10205 image: editImage
10206 });
10207 };
10208 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10209 primary: (0, _wordpress_i18n.__)("Variations", "elementor"),
10210 secondary: (0, _wordpress_i18n.__)("Create new versions of the original image.", "elementor")
10211 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10212 error,
10213 onRetry: handleSubmit
10214 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
10215 display: "flex",
10216 alignItems: "center",
10217 justifyContent: "center",
10218 bgcolor: "action.selected"
10219 } }, /*#__PURE__*/ react.default.createElement("img", {
10220 src: (editImage === null || editImage === void 0 ? void 0 : editImage.image_url) || (editImage === null || editImage === void 0 ? void 0 : editImage.url),
10221 alt: prompt,
10222 style: {
10223 width: "auto",
10224 height: "auto",
10225 maxWidth: "100%",
10226 maxHeight: 166,
10227 objectFit: "contained"
10228 }
10229 })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10230 gap: 2,
10231 sx: { my: 2.5 }
10232 }, (data === null || data === void 0 || (_data$result = data.result) === null || _data$result === void 0 ? void 0 : _data$result.length) > 0 ? /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }) : /*#__PURE__*/ react.default.createElement(GenerateImagesSubmit, { disabled: isLoading })))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10233 images: data.result,
10234 aspectRatio: generatedAspectRatio,
10235 onUseImage: use,
10236 onEditImage: edit
10237 }) : /*#__PURE__*/ react.default.createElement(ImagesPlaceholder, null)));
10238 };
10239 Variations.propTypes = {};
10240
10241 //#endregion
10242 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/hooks/use-replace-background.js
10243 init_api();
10244 var useReplaceBackground = function useReplaceBackground(initialValue) {
10245 return useImagePrompt(function fetchAction(payload) {
10246 return getImageToImageReplaceBackground(payload);
10247 }, initialValue);
10248 };
10249
10250 //#endregion
10251 //#region modules/ai/assets/js/editor/pages/form-media/views/replace-background/index.js
10252 init_slicedToArray();
10253 init_requests_ids();
10254 var ReplaceBackground = function ReplaceBackground() {
10255 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10256 var prompt = _useState2[0];
10257 var setPrompt = _useState2[1];
10258 var setGenerate = useRequestIds().setGenerate;
10259 var editImage = useEditImage().editImage;
10260 var _useImageActions = useImageActions();
10261 var use = _useImageActions.use;
10262 var edit = _useImageActions.edit;
10263 var isUploading = _useImageActions.isLoading;
10264 var _useReplaceBackground = useReplaceBackground();
10265 var data = _useReplaceBackground.data;
10266 var send = _useReplaceBackground.send;
10267 var isGenerating = _useReplaceBackground.isLoading;
10268 var error = _useReplaceBackground.error;
10269 var navigate = useLocation().navigate;
10270 var isLoading = isGenerating || isUploading;
10271 var handleSubmit = function handleSubmit(event) {
10272 event.preventDefault();
10273 setGenerate();
10274 send({
10275 prompt,
10276 image: editImage
10277 });
10278 };
10279 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10280 primary: (0, _wordpress_i18n.__)("Replace Background", "elementor"),
10281 secondary: (0, _wordpress_i18n.__)("Generate a new background with a prompt.", "elementor")
10282 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10283 error,
10284 onRetry: handleSubmit
10285 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(PromptField, {
10286 value: prompt,
10287 disabled: isLoading,
10288 onChange: setPrompt,
10289 placeholder: (0, _wordpress_i18n.__)("Describe what you want to generate in the background (English only)", "elementor")
10290 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
10291 disabled: isLoading || "" === prompt,
10292 color: data !== null && data !== void 0 && data.result ? "secondary" : "primary"
10293 }, data !== null && data !== void 0 && data.result ? (0, _wordpress_i18n.__)("Generate Again", "elementor") : (0, _wordpress_i18n.__)("Replace Background", "elementor")), (data === null || data === void 0 ? void 0 : data.result) && /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10294 disabled: isLoading,
10295 onClick: function onClick() {
10296 return navigate(LOCATIONS.GENERATE);
10297 }
10298 }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10299 onUseImage: use,
10300 onEditImage: edit,
10301 images: data.result,
10302 aspectRatio: editImage.aspectRatio
10303 }) : /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10304 src: editImage.url,
10305 alt: editImage.alt,
10306 style: {
10307 width: editImage.width,
10308 height: editImage.height
10309 }
10310 }))));
10311 };
10312
10313 //#endregion
10314 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/hooks/use-remove-background.js
10315 init_api();
10316 var useRemoveBackground = function useRemoveBackground(initialValue) {
10317 return useImagePrompt(function fetchAction(payload) {
10318 return getImageToImageRemoveBackground(payload);
10319 }, initialValue);
10320 };
10321
10322 //#endregion
10323 //#region modules/ai/assets/js/editor/pages/form-media/views/remove-background/index.js
10324 init_requests_ids();
10325 var RemoveBackground = function RemoveBackground() {
10326 var editImage = useEditImage().editImage;
10327 var setGenerate = useRequestIds().setGenerate;
10328 var _useImageActions = useImageActions();
10329 var use = _useImageActions.use;
10330 var edit = _useImageActions.edit;
10331 var isUploading = _useImageActions.isLoading;
10332 var _useRemoveBackground = useRemoveBackground();
10333 var data = _useRemoveBackground.data;
10334 var send = _useRemoveBackground.send;
10335 var isGenerating = _useRemoveBackground.isLoading;
10336 var error = _useRemoveBackground.error;
10337 var navigate = useLocation().navigate;
10338 var isLoading = isGenerating || isUploading;
10339 var _useImageSize = useImageSize(editImage.aspectRatio);
10340 var width = _useImageSize.width;
10341 var height = _useImageSize.height;
10342 var handleSubmit = function handleSubmit(event) {
10343 event.preventDefault();
10344 setGenerate();
10345 send({ image: editImage });
10346 };
10347 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10348 primary: (0, _wordpress_i18n.__)("Remove Background", "elementor"),
10349 secondary: (0, _wordpress_i18n.__)("Create an image of the subject with a transparent background", "elementor")
10350 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10351 error,
10352 onRetry: handleSubmit
10353 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10354 variant: "contained",
10355 disabled: isLoading,
10356 onClick: function onClick() {
10357 return navigate(LOCATIONS.GENERATE);
10358 }
10359 }) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading }, (0, _wordpress_i18n.__)("Remove Background", "elementor")))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10360 transparentContainer: true,
10361 onUseImage: use,
10362 onEditImage: edit,
10363 images: data.result,
10364 aspectRatio: editImage.aspectRatio
10365 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
10366 src: editImage.url,
10367 alt: editImage.alt,
10368 style: {
10369 width,
10370 height
10371 }
10372 })))));
10373 };
10374
10375 //#endregion
10376 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/cleanup-content.js
10377 init_asyncToGenerator();
10378 init_slicedToArray();
10379 var STROKE_SELECT_WIDTH = 120;
10380 var BRUSH_COLOR = "rgba(255, 255, 255)";
10381 var CANVAS_COLOR = "rgba(0, 0, 0)";
10382 var StyledUndoIcon = (0, _elementor_ui.withDirection)(UndoIcon);
10383 var StyledRedoIcon = (0, _elementor_ui.withDirection)(RedoIcon);
10384 var BrushCursor = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10385 return "size" === prop;
10386 } })(function(_ref) {
10387 var theme = _ref.theme;
10388 var size = _ref.size;
10389 return {
10390 position: "absolute",
10391 width: size,
10392 height: size,
10393 borderRadius: "50%",
10394 backgroundColor: BRUSH_COLOR,
10395 pointerEvents: "none",
10396 transform: "translate(".concat("rtl" === theme.direction ? "50%" : "-50%", ", -50%)"),
10397 border: "1px solid #fff"
10398 };
10399 });
10400 var BrishSizeIcon = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
10401 return "size" === prop;
10402 } })(function(_ref2) {
10403 var theme = _ref2.theme;
10404 var size = _ref2.size;
10405 return {
10406 width: size / 2,
10407 height: size / 2,
10408 borderRadius: "50%",
10409 backgroundColor: theme.palette.secondary.main
10410 };
10411 });
10412 var CleanupContent = function CleanupContent(_ref3) {
10413 var editImage = _ref3.editImage;
10414 var setMask = _ref3.setMask;
10415 var setIsCanvasChanged = _ref3.setIsCanvasChanged;
10416 var canvasWidth = _ref3.width;
10417 var canvasHeight = _ref3.height;
10418 var sketchRef = (0, react.useRef)();
10419 var _useState2 = _slicedToArray((0, react.useState)(30), 2);
10420 var stroke = _useState2[0];
10421 var setStroke = _useState2[1];
10422 var brushCursorRef = (0, react.useRef)();
10423 (0, react.useEffect)(function() {
10424 var canvas = document.querySelector(".eui-in-painting-canvas");
10425 var positionElement = function positionElement(e) {
10426 var _canvas$getBoundingCl = canvas.getBoundingClientRect();
10427 var left = _canvas$getBoundingCl.left;
10428 var top = _canvas$getBoundingCl.top;
10429 var width = _canvas$getBoundingCl.width;
10430 var height = _canvas$getBoundingCl.height;
10431 var x = e.clientX - left;
10432 var y = e.clientY - top;
10433 if (x > 0 && x < width && y > 0 && y < height) {
10434 brushCursorRef.current.style.left = "".concat(x, "px");
10435 brushCursorRef.current.style.top = "".concat(y, "px");
10436 }
10437 };
10438 window.addEventListener("mousemove", positionElement);
10439 return function() {
10440 window.removeEventListener("mousemove", positionElement);
10441 };
10442 }, [stroke]);
10443 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10444 alignItems: "flex-start",
10445 spacing: .5,
10446 flexGrow: 1
10447 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10448 width: "100%",
10449 direction: "row",
10450 spacing: 3,
10451 alignSelf: "center",
10452 justifyContent: "center",
10453 sx: { mb: 2.5 }
10454 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10455 direction: "row",
10456 gap: 1
10457 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Undo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
10458 variant: "outlined",
10459 color: "secondary",
10460 onClick: function onClick() {
10461 return sketchRef.current.undo();
10462 },
10463 sx: { px: 0 }
10464 }, /*#__PURE__*/ react.default.createElement(StyledUndoIcon, null))), /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Redo", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
10465 variant: "outlined",
10466 color: "secondary",
10467 onClick: function onClick() {
10468 return sketchRef.current.redo();
10469 },
10470 sx: { px: 0 }
10471 }, /*#__PURE__*/ react.default.createElement(StyledRedoIcon, null)))), /*#__PURE__*/ react.default.createElement(_elementor_ui.FormControl, {
10472 size: "small",
10473 color: "secondary",
10474 sx: { minWidth: STROKE_SELECT_WIDTH }
10475 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.InputLabel, { id: "stroke" }, "Stroke"), /*#__PURE__*/ react.default.createElement(_elementor_ui.Select, {
10476 autoWidth: true,
10477 label: "Stroke",
10478 value: stroke,
10479 id: "demo-simple-select",
10480 labelId: "demo-simple-select-label",
10481 onChange: function onChange(e) {
10482 return setStroke(e.target.value);
10483 },
10484 MenuProps: {
10485 PaperProps: { sx: { maxWidth: STROKE_SELECT_WIDTH } },
10486 MenuListProps: { sx: { minWidth: STROKE_SELECT_WIDTH } }
10487 },
10488 sx: { "& .MuiSelect-select .MuiListItemIcon-root": {
10489 mr: .25,
10490 width: "initial",
10491 minWidth: "initial",
10492 justifyContent: "flex-start"
10493 } }
10494 }, [
10495 10,
10496 20,
10497 30,
10498 40,
10499 50
10500 ].map(function(value) {
10501 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
10502 key: "stroke-width-option-" + value,
10503 value
10504 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10505 direction: "row",
10506 alignItems: "center",
10507 gap: 1
10508 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, { sx: {
10509 width: 30,
10510 display: "flex",
10511 justifyContent: "center"
10512 } }, /*#__PURE__*/ react.default.createElement(BrishSizeIcon, { size: value })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, null, value)));
10513 })))), /*#__PURE__*/ react.default.createElement("div", { style: {
10514 margin: "0 auto",
10515 position: "relative",
10516 cursor: "none",
10517 overflow: "hidden"
10518 } }, /*#__PURE__*/ react.default.createElement(BrushCursor, {
10519 ref: brushCursorRef,
10520 size: stroke
10521 }), /*#__PURE__*/ react.default.createElement(ReactSketchCanvas, {
10522 className: "eui-in-painting-canvas",
10523 withViewBox: true,
10524 ref: sketchRef,
10525 height: canvasHeight + "px",
10526 width: canvasWidth + "px",
10527 strokeWidth: stroke,
10528 strokeColor: BRUSH_COLOR,
10529 canvasColor: CANVAS_COLOR,
10530 backgroundImage: editImage.url,
10531 onStroke: function onStroke() {
10532 return setIsCanvasChanged(true);
10533 },
10534 onChange: /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
10535 var svg;
10536 return import_regenerator$2.default.wrap(function(_context) {
10537 while (1) switch (_context.prev = _context.next) {
10538 case 0:
10539 _context.next = 1;
10540 return sketchRef.current.exportSvg();
10541 case 1:
10542 svg = _context.sent;
10543 setMask(svg);
10544 case 2:
10545 case "end": return _context.stop();
10546 }
10547 }, _callee);
10548 }))
10549 })));
10550 };
10551 CleanupContent.propTypes = {
10552 setMask: import_prop_types$7.default.func.isRequired,
10553 setIsCanvasChanged: import_prop_types$7.default.func.isRequired,
10554 width: import_prop_types$7.default.number.isRequired,
10555 height: import_prop_types$7.default.number.isRequired,
10556 editImage: import_prop_types$7.default.object.isRequired
10557 };
10558
10559 //#endregion
10560 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/hooks/use-cleanup.js
10561 init_api();
10562 var useCleanup = function useCleanup(initialValue) {
10563 return useImagePrompt(function fetchAction(payload) {
10564 return getImageToImageMaskCleanup(payload);
10565 }, initialValue);
10566 };
10567
10568 //#endregion
10569 //#region modules/ai/assets/js/editor/pages/form-media/views/cleanup/index.js
10570 init_asyncToGenerator();
10571 init_slicedToArray();
10572 init_requests_ids();
10573 var Cleanup = function Cleanup() {
10574 var setGenerate = useRequestIds().setGenerate;
10575 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
10576 var mask = _useState2[0];
10577 var setMask = _useState2[1];
10578 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
10579 var isCanvasChanged = _useState4[0];
10580 var setIsCanvasChanged = _useState4[1];
10581 var _usePromptSettings = usePromptSettings();
10582 var settings = _usePromptSettings.settings;
10583 var resetSettings = _usePromptSettings.resetSettings;
10584 var _useEditImage = useEditImage();
10585 var editImage = _useEditImage.editImage;
10586 var width = _useEditImage.width;
10587 var height = _useEditImage.height;
10588 var _useImageActions = useImageActions();
10589 var use = _useImageActions.use;
10590 var edit = _useImageActions.edit;
10591 var isUploading = _useImageActions.isLoading;
10592 var _useCleanup = useCleanup();
10593 var data = _useCleanup.data;
10594 var send = _useCleanup.send;
10595 var isGenerating = _useCleanup.isLoading;
10596 var error = _useCleanup.error;
10597 var reset = _useCleanup.reset;
10598 var isLoading = isGenerating || isUploading;
10599 var handleSubmit = /*#__PURE__*/ function() {
10600 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
10601 return import_regenerator$2.default.wrap(function(_context) {
10602 while (1) switch (_context.prev = _context.next) {
10603 case 0:
10604 event.preventDefault();
10605 setGenerate();
10606 send({
10607 settings,
10608 image: editImage,
10609 mask
10610 });
10611 case 1:
10612 case "end": return _context.stop();
10613 }
10614 }, _callee);
10615 }));
10616 return function handleSubmit(_x) {
10617 return _ref.apply(this, arguments);
10618 };
10619 }();
10620 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
10621 primary: (0, _wordpress_i18n.__)("Cleanup", "elementor"),
10622 secondary: (0, _wordpress_i18n.__)("Remove unwanted area from your image.", "elementor")
10623 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
10624 error,
10625 onRetry: handleSubmit
10626 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
10627 gap: 2,
10628 sx: { my: 2.5 }
10629 }, /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }), /*#__PURE__*/ react.default.createElement(NewPromptButton, {
10630 disabled: isLoading,
10631 onClick: function onClick() {
10632 resetSettings();
10633 reset();
10634 }
10635 })) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading || !isCanvasChanged }))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
10636 images: data.result,
10637 aspectRatio: editImage.aspectRatio,
10638 onUseImage: use,
10639 onEditImage: edit
10640 }) : /*#__PURE__*/ react.default.createElement(CleanupContent, {
10641 editImage,
10642 width,
10643 height,
10644 setMask,
10645 setIsCanvasChanged
10646 })));
10647 };
10648
10649 //#endregion
10650 //#region modules/ai/assets/js/editor/pages/form-media/views/generate/hooks/use-text-to-image.js
10651 init_api();
10652 var useTextToImage = function useTextToImage(initialValue) {
10653 return useImagePrompt(getTextToImageGeneration, initialValue);
10654 };
10655
10656 //#endregion
10657 //#region node_modules/react-colorful/dist/index.mjs
10658 function u() {
10659 return (u = Object.assign || function(e) {
10660 for (var r = 1; r < arguments.length; r++) {
10661 var t = arguments[r];
10662 for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
10663 }
10664 return e;
10665 }).apply(this, arguments);
10666 }
10667 function c(e, r) {
10668 if (null == e) return {};
10669 var t;
10670 var n;
10671 var o = {};
10672 var a = Object.keys(e);
10673 for (n = 0; n < a.length; n++) r.indexOf(t = a[n]) >= 0 || (o[t] = e[t]);
10674 return o;
10675 }
10676 function i(e) {
10677 var t = (0, react$1.useRef)(e);
10678 var n = (0, react$1.useRef)(function(e) {
10679 t.current && t.current(e);
10680 });
10681 return t.current = e, n.current;
10682 }
10683 var s = function(e, r, t) {
10684 return void 0 === r && (r = 0), void 0 === t && (t = 1), e > t ? t : e < r ? r : e;
10685 };
10686 var f = function(e) {
10687 return "touches" in e;
10688 };
10689 var v = function(e) {
10690 return e && e.ownerDocument.defaultView || self;
10691 };
10692 var d = function(e, r, t) {
10693 var n = e.getBoundingClientRect();
10694 var o = f(r) ? function(e, r) {
10695 for (var t = 0; t < e.length; t++) if (e[t].identifier === r) return e[t];
10696 return e[0];
10697 }(r.touches, t) : r;
10698 return {
10699 left: s((o.pageX - (n.left + v(e).pageXOffset)) / n.width),
10700 top: s((o.pageY - (n.top + v(e).pageYOffset)) / n.height)
10701 };
10702 };
10703 var h = function(e) {
10704 !f(e) && e.preventDefault();
10705 };
10706 var m$1 = react$1.default.memo(function(o) {
10707 var a = o.onMove;
10708 var l = o.onKey;
10709 var s = c(o, ["onMove", "onKey"]);
10710 var m = (0, react$1.useRef)(null);
10711 var g = i(a);
10712 var p = i(l);
10713 var b = (0, react$1.useRef)(null);
10714 var _ = (0, react$1.useRef)(!1);
10715 var x = (0, react$1.useMemo)(function() {
10716 var e = function(e) {
10717 h(e), (f(e) ? e.touches.length > 0 : e.buttons > 0) && m.current ? g(d(m.current, e, b.current)) : t(!1);
10718 };
10719 var r = function() {
10720 return t(!1);
10721 };
10722 function t(t) {
10723 var n = _.current;
10724 var o = v(m.current);
10725 var a = t ? o.addEventListener : o.removeEventListener;
10726 a(n ? "touchmove" : "mousemove", e), a(n ? "touchend" : "mouseup", r);
10727 }
10728 return [
10729 function(e) {
10730 var r = e.nativeEvent;
10731 var n = m.current;
10732 if (n && (h(r), !function(e, r) {
10733 return r && !f(e);
10734 }(r, _.current) && n)) {
10735 if (f(r)) {
10736 _.current = !0;
10737 var o = r.changedTouches || [];
10738 o.length && (b.current = o[0].identifier);
10739 }
10740 n.focus(), g(d(n, r, b.current)), t(!0);
10741 }
10742 },
10743 function(e) {
10744 var r = e.which || e.keyCode;
10745 r < 37 || r > 40 || (e.preventDefault(), p({
10746 left: 39 === r ? .05 : 37 === r ? -.05 : 0,
10747 top: 40 === r ? .05 : 38 === r ? -.05 : 0
10748 }));
10749 },
10750 t
10751 ];
10752 }, [p, g]);
10753 var C = x[0];
10754 var E = x[1];
10755 var H = x[2];
10756 return (0, react$1.useEffect)(function() {
10757 return H;
10758 }, [H]), react$1.default.createElement("div", u({}, s, {
10759 onTouchStart: C,
10760 onMouseDown: C,
10761 className: "react-colorful__interactive",
10762 ref: m,
10763 onKeyDown: E,
10764 tabIndex: 0,
10765 role: "slider"
10766 }));
10767 });
10768 var g = function(e) {
10769 return e.filter(Boolean).join(" ");
10770 };
10771 var p = function(r) {
10772 var t = r.color;
10773 var n = r.left;
10774 var o = r.top;
10775 var a = void 0 === o ? .5 : o;
10776 var l = g(["react-colorful__pointer", r.className]);
10777 return react$1.default.createElement("div", {
10778 className: l,
10779 style: {
10780 top: 100 * a + "%",
10781 left: 100 * n + "%"
10782 }
10783 }, react$1.default.createElement("div", {
10784 className: "react-colorful__pointer-fill",
10785 style: { backgroundColor: t }
10786 }));
10787 };
10788 var b = function(e, r, t) {
10789 return void 0 === r && (r = 0), void 0 === t && (t = Math.pow(10, r)), Math.round(t * e) / t;
10790 };
10791 var _ = {
10792 grad: .9,
10793 turn: 360,
10794 rad: 360 / (2 * Math.PI)
10795 };
10796 var x = function(e) {
10797 return L(C(e));
10798 };
10799 var C = function(e) {
10800 return "#" === e[0] && (e = e.substring(1)), e.length < 6 ? {
10801 r: parseInt(e[0] + e[0], 16),
10802 g: parseInt(e[1] + e[1], 16),
10803 b: parseInt(e[2] + e[2], 16),
10804 a: 4 === e.length ? b(parseInt(e[3] + e[3], 16) / 255, 2) : 1
10805 } : {
10806 r: parseInt(e.substring(0, 2), 16),
10807 g: parseInt(e.substring(2, 4), 16),
10808 b: parseInt(e.substring(4, 6), 16),
10809 a: 8 === e.length ? b(parseInt(e.substring(6, 8), 16) / 255, 2) : 1
10810 };
10811 };
10812 var w = function(e) {
10813 return K(I(e));
10814 };
10815 var y = function(e) {
10816 var r = e.s;
10817 var t = e.v;
10818 var n = e.a;
10819 var o = (200 - r) * t / 100;
10820 return {
10821 h: b(e.h),
10822 s: b(o > 0 && o < 200 ? r * t / 100 / (o <= 100 ? o : 200 - o) * 100 : 0),
10823 l: b(o / 2),
10824 a: b(n, 2)
10825 };
10826 };
10827 var q = function(e) {
10828 var r = y(e);
10829 return "hsl(" + r.h + ", " + r.s + "%, " + r.l + "%)";
10830 };
10831 var I = function(e) {
10832 var r = e.h;
10833 var t = e.s;
10834 var n = e.v;
10835 var o = e.a;
10836 r = r / 360 * 6, t /= 100, n /= 100;
10837 var a = Math.floor(r);
10838 var l = n * (1 - t);
10839 var u = n * (1 - (r - a) * t);
10840 var c = n * (1 - (1 - r + a) * t);
10841 var i = a % 6;
10842 return {
10843 r: b(255 * [
10844 n,
10845 u,
10846 l,
10847 l,
10848 c,
10849 n
10850 ][i]),
10851 g: b(255 * [
10852 c,
10853 n,
10854 n,
10855 u,
10856 l,
10857 l
10858 ][i]),
10859 b: b(255 * [
10860 l,
10861 l,
10862 c,
10863 n,
10864 n,
10865 u
10866 ][i]),
10867 a: b(o, 2)
10868 };
10869 };
10870 var D = function(e) {
10871 var r = e.toString(16);
10872 return r.length < 2 ? "0" + r : r;
10873 };
10874 var K = function(e) {
10875 var r = e.r;
10876 var t = e.g;
10877 var n = e.b;
10878 var o = e.a;
10879 var a = o < 1 ? D(b(255 * o)) : "";
10880 return "#" + D(r) + D(t) + D(n) + a;
10881 };
10882 var L = function(e) {
10883 var r = e.r;
10884 var t = e.g;
10885 var n = e.b;
10886 var o = e.a;
10887 var a = Math.max(r, t, n);
10888 var l = a - Math.min(r, t, n);
10889 var u = l ? a === r ? (t - n) / l : a === t ? 2 + (n - r) / l : 4 + (r - t) / l : 0;
10890 return {
10891 h: b(60 * (u < 0 ? u + 6 : u)),
10892 s: b(a ? l / a * 100 : 0),
10893 v: b(a / 255 * 100),
10894 a: o
10895 };
10896 };
10897 var S = react$1.default.memo(function(r) {
10898 var t = r.hue;
10899 var n = r.onChange;
10900 var o = g(["react-colorful__hue", r.className]);
10901 return react$1.default.createElement("div", { className: o }, react$1.default.createElement(m$1, {
10902 onMove: function(e) {
10903 n({ h: 360 * e.left });
10904 },
10905 onKey: function(e) {
10906 n({ h: s(t + 360 * e.left, 0, 360) });
10907 },
10908 "aria-label": "Hue",
10909 "aria-valuenow": b(t),
10910 "aria-valuemax": "360",
10911 "aria-valuemin": "0"
10912 }, react$1.default.createElement(p, {
10913 className: "react-colorful__hue-pointer",
10914 left: t / 360,
10915 color: q({
10916 h: t,
10917 s: 100,
10918 v: 100,
10919 a: 1
10920 })
10921 })));
10922 });
10923 var T = react$1.default.memo(function(r) {
10924 var t = r.hsva;
10925 var n = r.onChange;
10926 var o = { backgroundColor: q({
10927 h: t.h,
10928 s: 100,
10929 v: 100,
10930 a: 1
10931 }) };
10932 return react$1.default.createElement("div", {
10933 className: "react-colorful__saturation",
10934 style: o
10935 }, react$1.default.createElement(m$1, {
10936 onMove: function(e) {
10937 n({
10938 s: 100 * e.left,
10939 v: 100 - 100 * e.top
10940 });
10941 },
10942 onKey: function(e) {
10943 n({
10944 s: s(t.s + 100 * e.left, 0, 100),
10945 v: s(t.v - 100 * e.top, 0, 100)
10946 });
10947 },
10948 "aria-label": "Color",
10949 "aria-valuetext": "Saturation " + b(t.s) + "%, Brightness " + b(t.v) + "%"
10950 }, react$1.default.createElement(p, {
10951 className: "react-colorful__saturation-pointer",
10952 top: 1 - t.v / 100,
10953 left: t.s / 100,
10954 color: q(t)
10955 })));
10956 });
10957 var F = function(e, r) {
10958 if (e === r) return !0;
10959 for (var t in e) if (e[t] !== r[t]) return !1;
10960 return !0;
10961 };
10962 var X = function(e, r) {
10963 return e.toLowerCase() === r.toLowerCase() || F(C(e), C(r));
10964 };
10965 function Y(e, t, l) {
10966 var u = i(l);
10967 var c = (0, react$1.useState)(function() {
10968 return e.toHsva(t);
10969 });
10970 var s = c[0];
10971 var f = c[1];
10972 var v = (0, react$1.useRef)({
10973 color: t,
10974 hsva: s
10975 });
10976 (0, react$1.useEffect)(function() {
10977 if (!e.equal(t, v.current.color)) {
10978 var r = e.toHsva(t);
10979 v.current = {
10980 hsva: r,
10981 color: t
10982 }, f(r);
10983 }
10984 }, [t, e]), (0, react$1.useEffect)(function() {
10985 var r;
10986 F(s, v.current.hsva) || e.equal(r = e.fromHsva(s), v.current.color) || (v.current = {
10987 hsva: s,
10988 color: r
10989 }, u(r));
10990 }, [
10991 s,
10992 e,
10993 u
10994 ]);
10995 return [s, (0, react$1.useCallback)(function(e) {
10996 f(function(r) {
10997 return Object.assign({}, r, e);
10998 });
10999 }, [])];
11000 }
11001 var R;
11002 var V = "undefined" != typeof window ? react$1.useLayoutEffect : react$1.useEffect;
11003 var $ = function() {
11004 return R || ("undefined" != typeof __webpack_nonce__ ? __webpack_nonce__ : void 0);
11005 };
11006 var J = /* @__PURE__ */ new Map();
11007 var Q = function(e) {
11008 V(function() {
11009 var r = e.current ? e.current.ownerDocument : document;
11010 if (void 0 !== r && !J.has(r)) {
11011 var t = r.createElement("style");
11012 t.innerHTML = ".react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:\"\";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill-opacity=\".05\"><path d=\"M8 0h8v8H8zM0 8h8v8H0z\"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}", J.set(r, t);
11013 var n = $();
11014 n && t.setAttribute("nonce", n), r.head.appendChild(t);
11015 }
11016 }, []);
11017 };
11018 var U = function(t) {
11019 var n = t.className;
11020 var o = t.colorModel;
11021 var a = t.color;
11022 var l = void 0 === a ? o.defaultColor : a;
11023 var i = t.onChange;
11024 var s = c(t, [
11025 "className",
11026 "colorModel",
11027 "color",
11028 "onChange"
11029 ]);
11030 var f = (0, react$1.useRef)(null);
11031 Q(f);
11032 var v = Y(o, l, i);
11033 var d = v[0];
11034 var h = v[1];
11035 var m = g(["react-colorful", n]);
11036 return react$1.default.createElement("div", u({}, s, {
11037 ref: f,
11038 className: m
11039 }), react$1.default.createElement(T, {
11040 hsva: d,
11041 onChange: h
11042 }), react$1.default.createElement(S, {
11043 hue: d.h,
11044 onChange: h,
11045 className: "react-colorful__last-control"
11046 }));
11047 };
11048 var W = {
11049 defaultColor: "000",
11050 toHsva: x,
11051 fromHsva: function(e) {
11052 return w({
11053 h: e.h,
11054 s: e.s,
11055 v: e.v,
11056 a: 1
11057 });
11058 },
11059 equal: X
11060 };
11061 var Z = function(r) {
11062 return react$1.default.createElement(U, u({}, r, { colorModel: W }));
11063 };
11064
11065 //#endregion
11066 //#region modules/ai/assets/js/editor/pages/form-media/components/color-picker.js
11067 init_defineProperty$1();
11068 init_slicedToArray();
11069 function ownKeys$11(e, r) {
11070 var t = Object.keys(e);
11071 if (Object.getOwnPropertySymbols) {
11072 var o = Object.getOwnPropertySymbols(e);
11073 r && (o = o.filter(function(r) {
11074 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11075 })), t.push.apply(t, o);
11076 }
11077 return t;
11078 }
11079 __name(ownKeys$11, "ownKeys");
11080 function _objectSpread$11(e) {
11081 for (var r = 1; r < arguments.length; r++) {
11082 var t = null != arguments[r] ? arguments[r] : {};
11083 r % 2 ? ownKeys$11(Object(t), !0).forEach(function(r) {
11084 _defineProperty$1(e, r, t[r]);
11085 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$11(Object(t)).forEach(function(r) {
11086 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11087 });
11088 }
11089 return e;
11090 }
11091 __name(_objectSpread$11, "_objectSpread");
11092 var ColorInput = function ColorInput(_ref) {
11093 var _elementorCommon$conf;
11094 var _elementorCommon;
11095 var label = _ref.label;
11096 var color = _ref.color;
11097 var onChange = _ref.onChange;
11098 var disabled = _ref.disabled;
11099 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11100 var isOpened = _useState2[0];
11101 var setIsOpened = _useState2[1];
11102 var anchorEl = (0, react.useRef)();
11103 var _useState4 = _slicedToArray((0, react.useState)(170001), 2);
11104 var zIndex = _useState4[0];
11105 var setZIndex = _useState4[1];
11106 var isRTL = (_elementorCommon$conf = (_elementorCommon = elementorCommon) === null || _elementorCommon === void 0 || (_elementorCommon = _elementorCommon.config) === null || _elementorCommon === void 0 ? void 0 : _elementorCommon.isRTL) !== null && _elementorCommon$conf !== void 0 ? _elementorCommon$conf : true;
11107 (0, react.useEffect)(function() {
11108 if (anchorEl.current) {
11109 var element = anchorEl.current;
11110 var currentZIndex = 0;
11111 while (element && element !== document.body) {
11112 var computedZIndex = window.getComputedStyle(element).zIndex;
11113 if (computedZIndex !== "auto") {
11114 currentZIndex = parseInt(computedZIndex, 10) || 0;
11115 break;
11116 }
11117 element = element.parentElement;
11118 }
11119 setZIndex(currentZIndex > 0 ? currentZIndex + 1 : 170001);
11120 }
11121 }, [isOpened]);
11122 var handleClick = function handleClick() {
11123 return setIsOpened(true);
11124 };
11125 var handleClose = function handleClose() {
11126 setIsOpened(false);
11127 };
11128 var handleKeyDown = function handleKeyDown(event) {
11129 if ("Enter" === event.key || " " === event.key) {
11130 event.preventDefault();
11131 handleClick();
11132 }
11133 };
11134 var handleTextFieldChange = function handleTextFieldChange(event) {
11135 onChange("#".concat(event.target.value));
11136 };
11137 var handleColorPickerChange = function handleColorPickerChange(colorValue) {
11138 onChange(colorValue);
11139 };
11140 var id = isOpened ? "simple-popover" : void 0;
11141 return /*#__PURE__*/ react.default.createElement("div", {
11142 className: "el-ai-color-input-wrapper",
11143 style: _objectSpread$11({
11144 display: "flex",
11145 alignItems: "center"
11146 }, disabled ? {
11147 pointerEvents: "none",
11148 opacity: .5
11149 } : {})
11150 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.FormLabel, { sx: {
11151 whiteSpace: "nowrap",
11152 flex: 4
11153 } }, label), /*#__PURE__*/ react.default.createElement("button", {
11154 type: "button",
11155 onClick: handleClick,
11156 onKeyDown: handleKeyDown,
11157 style: {
11158 cursor: "pointer",
11159 borderRadius: "4px",
11160 marginRight: "8px",
11161 marginLeft: "8px",
11162 background: color,
11163 width: "100%",
11164 height: "auto",
11165 borderColor: "rgba(0, 0, 0, 0.23)",
11166 borderWidth: "1px",
11167 borderStyle: "solid",
11168 aspectRatio: "1 / 1",
11169 flex: 1.1
11170 },
11171 "aria-describedby": id,
11172 ref: anchorEl
11173 }), /*#__PURE__*/ react.default.createElement(StyledTextField, {
11174 value: color.substring(1, 7),
11175 color: "secondary",
11176 fullWidth: true,
11177 InputProps: {
11178 autoComplete: "off",
11179 color: "secondary",
11180 sx: { height: "100%" },
11181 startAdornment: /*#__PURE__*/ react.default.createElement(_elementor_ui.InputAdornment, { position: "start" }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11182 variant: "body1",
11183 color: "secondary"
11184 }, "#"))
11185 },
11186 onChange: handleTextFieldChange,
11187 sx: {
11188 flex: 3,
11189 height: "40px"
11190 }
11191 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
11192 id,
11193 anchorOrigin: {
11194 vertical: "bottom",
11195 horizontal: isRTL ? "right" : "left"
11196 },
11197 transformOrigin: {
11198 vertical: "top",
11199 horizontal: isRTL ? "right" : "left"
11200 },
11201 onClose: handleClose,
11202 open: isOpened,
11203 anchorEl: anchorEl.current,
11204 style: {
11205 zIndex,
11206 overflow: "hidden"
11207 }
11208 }, /*#__PURE__*/ react.default.createElement("div", {
11209 className: "el-ai-custom-color-picker",
11210 style: {
11211 height: "min-content",
11212 overflow: "hidden"
11213 }
11214 }, /*#__PURE__*/ react.default.createElement(Z, {
11215 color,
11216 onChange: handleColorPickerChange
11217 }))));
11218 };
11219 var StyledTextField = (0, _elementor_ui.styled)(_elementor_ui_TextField.default)(function() {
11220 return { ".wp-admin & .MuiInputBase-input, & .MuiInputBase-input:focus": {
11221 backgroundColor: "initial",
11222 boxShadow: "none",
11223 border: 0,
11224 color: "inherit",
11225 outline: 0,
11226 padding: 0,
11227 fontFamily: "inherit",
11228 minHeight: "2.4375em"
11229 } };
11230 });
11231 ColorInput.propTypes = {
11232 label: import_prop_types$7.default.string,
11233 color: import_prop_types$7.default.string,
11234 onChange: import_prop_types$7.default.func.isRequired,
11235 disabled: import_prop_types$7.default.bool
11236 };
11237
11238 //#endregion
11239 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/hooks/use-product-image-unification.js
11240 init_api();
11241 var useProductImageUnification = function useProductImageUnification(initialValue) {
11242 return useImagePrompt((0, react.useRef)(function(payload) {
11243 return getProductImageUnification(payload, true);
11244 }).current, initialValue);
11245 };
11246
11247 //#endregion
11248 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/components/product-image.js
11249 init_defineProperty$1();
11250 var ProductImage = function ProductImage(_ref) {
11251 var productId = _ref.productId;
11252 var ratio = _ref.ratio;
11253 var bgColor = _ref.bgColor;
11254 var image = _ref.image;
11255 var onUpdate = _ref.onUpdate;
11256 var isUploading = useImageActions().isLoading;
11257 var _useProductImageUnifi = useProductImageUnification(_defineProperty$1(_defineProperty$1(_defineProperty$1({ productId }, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor), "image", image));
11258 var data = _useProductImageUnifi.data;
11259 var isGenerating = _useProductImageUnifi.isLoading;
11260 var error = _useProductImageUnifi.error;
11261 var send = _useProductImageUnifi.send;
11262 var sendUsageData = _useProductImageUnifi.sendUsageData;
11263 (0, react.useEffect)(function() {
11264 if (onUpdate) onUpdate(data, isGenerating || isUploading, error, send, productId, ratio, bgColor, image, sendUsageData);
11265 }, [
11266 data,
11267 isGenerating,
11268 error,
11269 send,
11270 productId,
11271 ratio,
11272 bgColor,
11273 image,
11274 isUploading,
11275 onUpdate,
11276 sendUsageData
11277 ]);
11278 return /*#__PURE__*/ react.default.createElement("div", { style: { visibility: "hidden" } });
11279 };
11280 ProductImage.propTypes = {
11281 productId: import_prop_types$7.default.number,
11282 ratio: import_prop_types$7.default.string,
11283 bgColor: import_prop_types$7.default.string,
11284 image: import_prop_types$7.default.object,
11285 onUpdate: import_prop_types$7.default.func
11286 };
11287
11288 //#endregion
11289 //#region modules/ai/assets/js/editor/pages/form-media/views/product-image-unification/index.js
11290 init_defineProperty$1();
11291 init_asyncToGenerator();
11292 init_slicedToArray();
11293 init_requests_ids();
11294 function ownKeys$10(e, r) {
11295 var t = Object.keys(e);
11296 if (Object.getOwnPropertySymbols) {
11297 var o = Object.getOwnPropertySymbols(e);
11298 r && (o = o.filter(function(r) {
11299 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11300 })), t.push.apply(t, o);
11301 }
11302 return t;
11303 }
11304 __name(ownKeys$10, "ownKeys");
11305 function _objectSpread$10(e) {
11306 for (var r = 1; r < arguments.length; r++) {
11307 var t = null != arguments[r] ? arguments[r] : {};
11308 r % 2 ? ownKeys$10(Object(t), !0).forEach(function(r) {
11309 _defineProperty$1(e, r, t[r]);
11310 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$10(Object(t)).forEach(function(r) {
11311 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11312 });
11313 }
11314 return e;
11315 }
11316 __name(_objectSpread$10, "_objectSpread");
11317 var ProductImageUnification = function ProductImageUnification(_ref) {
11318 var _products$images$leng;
11319 var _products$images;
11320 var _Object$values;
11321 var _products$images$leng2;
11322 var _products$images2;
11323 var _products$images$leng3;
11324 var _products$images3;
11325 var _errorlessProducts$le;
11326 var _products$images4;
11327 var onClose = _ref.onClose;
11328 var setGenerate = useRequestIds().setGenerate;
11329 var products = useEditImage().editImage;
11330 var _usePromptSettings = usePromptSettings();
11331 var settings = _usePromptSettings.settings;
11332 var updateSettings = _usePromptSettings.updateSettings;
11333 var _useState2 = _slicedToArray((0, react.useState)({}), 2);
11334 var productsData = _useState2[0];
11335 var setProductsData = _useState2[1];
11336 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11337 var loadingMap = _useState4[0];
11338 var setLoadingMap = _useState4[1];
11339 var _useState6 = _slicedToArray((0, react.useState)({}), 2);
11340 var errorMap = _useState6[0];
11341 var setErrorMap = _useState6[1];
11342 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
11343 var checkboxColorMap = _useState8[0];
11344 var setCheckboxColorMap = _useState8[1];
11345 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
11346 var wasGeneratedOnce = _useState0[0];
11347 var setWasGeneratedOnce = _useState0[1];
11348 var useMultipleImages = useImageActions().useMultipleImages;
11349 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
11350 var isSavingImages = _useState10[0];
11351 var setIsSavingImages = _useState10[1];
11352 var errorlessProducts = Object.values(productsData).filter(function(_ref2) {
11353 var _errorMap$productId;
11354 return !((_errorMap$productId = errorMap[_ref2.productId]) !== null && _errorMap$productId !== void 0 && _errorMap$productId.errorGenerating);
11355 });
11356 var use = (0, react.useCallback)(/*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
11357 var generatedImages;
11358 var imagesToSave;
11359 return import_regenerator$2.default.wrap(function(_context) {
11360 while (1) switch (_context.prev = _context.next) {
11361 case 0:
11362 setIsSavingImages(true);
11363 generatedImages = errorlessProducts.filter(function(_ref4) {
11364 var data = _ref4.data;
11365 return _ref4.wasGenerated && (data === null || data === void 0 ? void 0 : data.isChecked) && (data === null || data === void 0 ? void 0 : data.productId) !== void 0;
11366 });
11367 imagesToSave = generatedImages.map(function(_ref5) {
11368 var data = _ref5.data;
11369 return _objectSpread$10(_objectSpread$10({}, data), {}, {
11370 editor_post_id: data.productId,
11371 unique_id: "ai-product-unification-".concat(data.productId)
11372 });
11373 });
11374 _context.next = 1;
11375 return useMultipleImages(imagesToSave);
11376 case 1:
11377 generatedImages.forEach(function(_ref6) {
11378 var sendUsageData = _ref6.sendUsageData;
11379 sendUsageData();
11380 });
11381 onClose();
11382 case 2:
11383 case "end": return _context.stop();
11384 }
11385 }, _callee);
11386 })), [
11387 onClose,
11388 errorlessProducts,
11389 useMultipleImages
11390 ]);
11391 var generatedAspectRatio = (0, react.useMemo)(function() {
11392 return settings[IMAGE_RATIO];
11393 }, [settings]);
11394 var generatedBgColor = (0, react.useMemo)(function() {
11395 return settings[IMAGE_BACKGROUND_COLOR];
11396 }, [settings]);
11397 var onProductUpdate = (0, react.useCallback)(function(res, isLoadingResult, errorGenerating, _req, productId, ratio, bgColor, image, sendUsageData) {
11398 setLoadingMap(function(prevState) {
11399 return _objectSpread$10(_objectSpread$10({}, prevState), {}, _defineProperty$1({}, productId, !!isLoadingResult));
11400 });
11401 setErrorMap(function(prevState) {
11402 return _objectSpread$10(_objectSpread$10({}, prevState), {}, _defineProperty$1({}, productId, { errorGenerating }));
11403 });
11404 setProductsData(function(prevState) {
11405 var _res$result;
11406 var _ref7;
11407 var _res$result$;
11408 var _res$result2;
11409 var _prevState$productId;
11410 var _prevState$productId$;
11411 var _prevState$productId2;
11412 var _checkboxColorMap$pro;
11413 return _objectSpread$10(_objectSpread$10({}, prevState), {}, _defineProperty$1({}, productId, _objectSpread$10(_objectSpread$10({}, prevState[productId]), {}, {
11414 productId,
11415 res,
11416 req: function req() {
11417 return _req({
11418 postId: productId,
11419 settings: _defineProperty$1(_defineProperty$1({}, IMAGE_RATIO, ratio), IMAGE_BACKGROUND_COLOR, bgColor),
11420 image
11421 });
11422 },
11423 sendUsageData,
11424 wasGenerated: (res === null || res === void 0 || (_res$result = res.result) === null || _res$result === void 0 ? void 0 : _res$result[0]) !== void 0,
11425 data: _objectSpread$10(_objectSpread$10({ productId }, !errorGenerating ? (_ref7 = (_res$result$ = res === null || res === void 0 || (_res$result2 = res.result) === null || _res$result2 === void 0 ? void 0 : _res$result2[0]) !== null && _res$result$ !== void 0 ? _res$result$ : image) !== null && _ref7 !== void 0 ? _ref7 : (_prevState$productId = prevState[productId]) === null || _prevState$productId === void 0 ? void 0 : _prevState$productId.image : {}), {}, {
11426 seed: productId,
11427 isChecked: (_prevState$productId$ = (_prevState$productId2 = prevState[productId]) === null || _prevState$productId2 === void 0 || (_prevState$productId2 = _prevState$productId2.data) === null || _prevState$productId2 === void 0 ? void 0 : _prevState$productId2.isChecked) !== null && _prevState$productId$ !== void 0 ? _prevState$productId$ : true,
11428 isLoading: isLoadingResult,
11429 checkboxColor: (_checkboxColorMap$pro = checkboxColorMap[productId]) !== null && _checkboxColorMap$pro !== void 0 ? _checkboxColorMap$pro : "rgba(0, 0, 0, 0.54)"
11430 })
11431 })));
11432 });
11433 }, [checkboxColorMap]);
11434 var isLoading = errorlessProducts.some(function(_ref8) {
11435 return loadingMap[_ref8.productId];
11436 });
11437 var isError = Object.values(errorMap).length && Object.values(errorMap).every(function(_ref9) {
11438 return _ref9.errorGenerating;
11439 });
11440 var thumbnailThreshold = 10;
11441 var exceedThumbnailThreshold = ((_products$images$leng = products === null || products === void 0 || (_products$images = products.images) === null || _products$images === void 0 ? void 0 : _products$images.length) !== null && _products$images$leng !== void 0 ? _products$images$leng : 0) - thumbnailThreshold > 0;
11442 var selectedProducts = errorlessProducts.filter(function(_ref0) {
11443 var data = _ref0.data;
11444 return data.isChecked && !data.isLoading;
11445 });
11446 var handleSubmit = (0, react.useCallback)(function(event) {
11447 event.preventDefault();
11448 setGenerate();
11449 setWasGeneratedOnce(true);
11450 var isLightColor = function isLightColor(color) {
11451 var rgb = parseInt(color.slice(1), 16);
11452 var r = rgb >> 16 & 255;
11453 var g = rgb >> 8 & 255;
11454 var b = rgb >> 0 & 255;
11455 return .299 * r + .587 * g + .114 * b > 128;
11456 };
11457 var productsToUnify = (errorlessProducts.length ? errorlessProducts : Object.values(productsData)).filter(function(product) {
11458 var _product$data;
11459 return ((_product$data = product.data) === null || _product$data === void 0 ? void 0 : _product$data.isChecked) && product.req;
11460 });
11461 var newCheckboxColor = isLightColor(generatedBgColor) ? "rgba(0, 0, 0, 0.54)" : "rgba( 255, 255, 255, 0.7 )";
11462 if (productsToUnify.find(function(product) {
11463 return checkboxColorMap[product.productId] !== newCheckboxColor;
11464 })) setCheckboxColorMap(function(prevState) {
11465 var newColorMap = _objectSpread$10({}, prevState);
11466 productsToUnify.forEach(function(product) {
11467 newColorMap[product.productId] = newCheckboxColor;
11468 });
11469 return newColorMap;
11470 });
11471 productsToUnify.forEach(function(product) {
11472 return product.req().catch(function() {});
11473 });
11474 }, [
11475 checkboxColorMap,
11476 errorlessProducts,
11477 generatedBgColor,
11478 productsData,
11479 setGenerate
11480 ]);
11481 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
11482 primary: (0, _wordpress_i18n.__)("Unify images", "elementor"),
11483 secondary: (0, _wordpress_i18n.__)("Select a set of parameters and AI will automate your adjustments:", "elementor")
11484 }), isError && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11485 error: (_Object$values = Object.values(errorMap)) === null || _Object$values === void 0 || (_Object$values = _Object$values[0]) === null || _Object$values === void 0 ? void 0 : _Object$values.errorGenerating,
11486 onRetry: handleSubmit
11487 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { gap: 2 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11488 display: "flex",
11489 flexWrap: "wrap",
11490 width: "100%",
11491 "& .MuiAvatar-root": { margin: .5 }
11492 } }, products === null || products === void 0 ? void 0 : products.images.slice(0, exceedThumbnailThreshold ? thumbnailThreshold - 1 : thumbnailThreshold).map(function(img) {
11493 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11494 key: img.productId,
11495 alt: img.productId + "",
11496 src: img.image_url,
11497 variant: "square",
11498 sx: {
11499 width: 50,
11500 height: 50
11501 }
11502 });
11503 }), exceedThumbnailThreshold && /*#__PURE__*/ react.default.createElement(_elementor_ui.Avatar, {
11504 variant: "square",
11505 sx: {
11506 bgcolor: "lightgray",
11507 width: 50,
11508 height: 50
11509 }
11510 }, ((_products$images$leng2 = products === null || products === void 0 || (_products$images2 = products.images) === null || _products$images2 === void 0 ? void 0 : _products$images2.length) !== null && _products$images$leng2 !== void 0 ? _products$images$leng2 : 0) - (thumbnailThreshold - 1))), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11511 gap: 2,
11512 sx: { my: 2.5 }
11513 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11514 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11515 color: generatedBgColor,
11516 onChange: function onChange(color) {
11517 return updateSettings(_defineProperty$1({}, IMAGE_BACKGROUND_COLOR, color));
11518 },
11519 disabled: isLoading
11520 }), /*#__PURE__*/ react.default.createElement(ImageRatioSelect, {
11521 disabled: true,
11522 value: generatedAspectRatio,
11523 onChange: function onChange(event) {
11524 return updateSettings(_defineProperty$1({}, IMAGE_RATIO, event.target.value));
11525 }
11526 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11527 gap: 2,
11528 sx: { my: 2.5 }
11529 }, wasGeneratedOnce ? /*#__PURE__*/ react.default.createElement(GenerateAgainSubmit, { disabled: isLoading }) : /*#__PURE__*/ react.default.createElement(GenerateSubmit, { disabled: isLoading })))))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isSavingImages }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11530 display: "flex",
11531 flexDirection: "column",
11532 height: "100%",
11533 alignItems: "center",
11534 justifyContent: "center",
11535 minHeight: "76vh"
11536 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11537 flex: 1,
11538 overflowY: "auto",
11539 display: "flex",
11540 flexDirection: "column",
11541 height: "100%",
11542 alignItems: "center",
11543 justifyContent: "center",
11544 overflowX: "hidden"
11545 } }, wasGeneratedOnce ? /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, errorlessProducts.length > 1 && errorlessProducts.some(function(_ref1) {
11546 return !_ref1.data.isLoading;
11547 }) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
11548 display: "flex",
11549 flexDirection: "row",
11550 alignItems: "inherit",
11551 justifyContent: "space-between",
11552 width: "100%"
11553 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11554 variant: "body2",
11555 color: "secondary"
11556 }, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("%1$d/%2$d selected", "elementor"), selectedProducts.length, (_products$images$leng3 = products === null || products === void 0 || (_products$images3 = products.images) === null || _products$images3 === void 0 ? void 0 : _products$images3.length) !== null && _products$images$leng3 !== void 0 ? _products$images$leng3 : 0)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11557 variant: "text",
11558 color: "secondary",
11559 onClick: function onClick() {
11560 var isChecked = !selectedProducts.some(function(product) {
11561 var _product$data2;
11562 return (_product$data2 = product.data) === null || _product$data2 === void 0 ? void 0 : _product$data2.isChecked;
11563 });
11564 setProductsData(function(prevState) {
11565 var newState = _objectSpread$10({}, prevState);
11566 Object.values(newState).forEach(function(product) {
11567 var _product$data3;
11568 if (isChecked !== ((_product$data3 = product.data) === null || _product$data3 === void 0 ? void 0 : _product$data3.isChecked)) newState[product.productId] = _objectSpread$10(_objectSpread$10({}, product), {}, { data: _objectSpread$10(_objectSpread$10({}, product.data), {}, { isChecked }) });
11569 });
11570 return newState;
11571 });
11572 }
11573 }, selectedProducts.some(function(product) {
11574 var _product$data4;
11575 return (_product$data4 = product.data) === null || _product$data4 === void 0 ? void 0 : _product$data4.isChecked;
11576 }) ? (0, _wordpress_i18n.__)("Clear all", "elementor") : (0, _wordpress_i18n.__)("Select all", "elementor"))), /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
11577 images: errorlessProducts.map(function(product) {
11578 return product.data;
11579 }),
11580 cols: function getCols() {
11581 var dataLength = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1;
11582 return Math.min(Math.ceil(Math.sqrt(dataLength !== null && dataLength !== void 0 ? dataLength : 1)), 4);
11583 }((_errorlessProducts$le = errorlessProducts.length) !== null && _errorlessProducts$le !== void 0 ? _errorlessProducts$le : 1),
11584 overlay: false,
11585 onSelectChange: function onSelectChange(productId, isChecked) {
11586 return setProductsData(function(prevState) {
11587 var _prevState$productId3;
11588 if ((_prevState$productId3 = prevState[productId]) !== null && _prevState$productId3 !== void 0 && _prevState$productId3.data) prevState[productId].data.isChecked = isChecked;
11589 return _objectSpread$10({}, prevState);
11590 });
11591 }
11592 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
11593 component: "img",
11594 src: window.UnifyProductImagesConfig.placeholder,
11595 alt: (0, _wordpress_i18n.__)("Example GIF", "elementor")
11596 })), wasGeneratedOnce && !isError && errorlessProducts.length && errorlessProducts.some(function(_ref10) {
11597 var data = _ref10.data;
11598 var errorGenerating = _ref10.errorGenerating;
11599 var wasGenerated = _ref10.wasGenerated;
11600 return (data === null || data === void 0 ? void 0 : data.isChecked) && !(data !== null && data !== void 0 && data.isLoadingResult) && !errorGenerating && wasGenerated;
11601 }) && /*#__PURE__*/ react.default.createElement(ImageActions.UseImage, {
11602 onClick: use,
11603 sx: {
11604 alignSelf: "flex-end",
11605 mt: 2
11606 }
11607 }))), (_products$images4 = products.images) === null || _products$images4 === void 0 ? void 0 : _products$images4.filter(function(img) {
11608 return img.productId;
11609 }).map(function(img) {
11610 return /*#__PURE__*/ react.default.createElement(ProductImage, {
11611 key: "product-".concat(img.productId),
11612 productId: img.productId,
11613 ratio: settings[IMAGE_RATIO],
11614 bgColor: settings[IMAGE_BACKGROUND_COLOR],
11615 image: img,
11616 onUpdate: onProductUpdate
11617 });
11618 }));
11619 };
11620 ProductImageUnification.propTypes = { onClose: import_prop_types$7.default.func };
11621
11622 //#endregion
11623 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/hooks/use-isolate-objects.js
11624 init_api();
11625 var useIsolateObject = function useIsolateObject(initialValue) {
11626 return useImagePrompt(function fetchAction(payload) {
11627 return getImageToImageIsolateObjects(payload);
11628 }, initialValue);
11629 };
11630
11631 //#endregion
11632 //#region modules/ai/assets/js/editor/pages/form-media/views/isolate-objects/index.js
11633 init_defineProperty$1();
11634 init_requests_ids();
11635 var IsolateObject = function IsolateObject() {
11636 var editImage = useEditImage().editImage;
11637 var setGenerate = useRequestIds().setGenerate;
11638 var _useImageActions = useImageActions();
11639 var use = _useImageActions.use;
11640 var edit = _useImageActions.edit;
11641 var isUploading = _useImageActions.isLoading;
11642 var _usePromptSettings = usePromptSettings();
11643 var settings = _usePromptSettings.settings;
11644 var updateSettings = _usePromptSettings.updateSettings;
11645 var _useIsolateObject = useIsolateObject();
11646 var data = _useIsolateObject.data;
11647 var send = _useIsolateObject.send;
11648 var isGenerating = _useIsolateObject.isLoading;
11649 var error = _useIsolateObject.error;
11650 var isLoading = isGenerating || isUploading;
11651 var _useImageSize = useImageSize(editImage.aspectRatio);
11652 var width = _useImageSize.width;
11653 var height = _useImageSize.height;
11654 var generatedAspectRatio = (0, react.useMemo)(function() {
11655 return settings[IMAGE_RATIO];
11656 }, [settings]);
11657 var generatedBgColor = (0, react.useMemo)(function() {
11658 return settings[IMAGE_BACKGROUND_COLOR];
11659 }, [settings]);
11660 var handleSubmit = function handleSubmit(event) {
11661 event.preventDefault();
11662 setGenerate();
11663 send({
11664 image: editImage,
11665 settings: _defineProperty$1(_defineProperty$1({}, IMAGE_RATIO, generatedAspectRatio), IMAGE_BACKGROUND_COLOR, generatedBgColor),
11666 featureIdentifier: FEATURE_IDENTIFIER.ISOLATE_OBJECT
11667 });
11668 };
11669 return /*#__PURE__*/ react.default.createElement(View, null, /*#__PURE__*/ react.default.createElement(View.Panel, null, /*#__PURE__*/ react.default.createElement(View.BackButton, null), /*#__PURE__*/ react.default.createElement(View.PanelHeading, {
11670 primary: (0, _wordpress_i18n.__)("Isolate Object", "elementor"),
11671 secondary: (0, _wordpress_i18n.__)("Remove the background, center your object, and add a drop shadow for a clean look.", "elementor")
11672 }), error && /*#__PURE__*/ react.default.createElement(View.ErrorMessage, {
11673 error,
11674 onRetry: handleSubmit
11675 }), /*#__PURE__*/ react.default.createElement(ImageForm, { onSubmit: handleSubmit }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
11676 gap: 2,
11677 sx: { my: 2.5 }
11678 }, /*#__PURE__*/ react.default.createElement(ColorInput, {
11679 label: (0, _wordpress_i18n.__)("Background Color", "elementor"),
11680 color: generatedBgColor,
11681 onChange: function onChange(color) {
11682 return updateSettings(_defineProperty$1({}, IMAGE_BACKGROUND_COLOR, color));
11683 },
11684 disabled: isLoading
11685 }), /*#__PURE__*/ react.default.createElement(GenerateSubmit, {
11686 disabled: isLoading,
11687 loading: isLoading
11688 }, (0, _wordpress_i18n.__)("Isolate Object", "elementor"))))), /*#__PURE__*/ react.default.createElement(View.Content, { isGenerating: isLoading }, data !== null && data !== void 0 && data.result ? /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(ImagesDisplay, {
11689 transparentContainer: true,
11690 onUseImage: use,
11691 onEditImage: edit,
11692 images: data.result,
11693 aspectRatio: editImage.aspectRatio
11694 })) : /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview, null, /*#__PURE__*/ react.default.createElement(SingleImagePreview.Image, {
11695 src: editImage.url,
11696 alt: editImage.alt,
11697 style: {
11698 width,
11699 height
11700 }
11701 })))));
11702 };
11703
11704 //#endregion
11705 //#region modules/ai/assets/js/editor/pages/form-media/media-outlet.js
11706 init_loader();
11707 init_prompt_history_action_context();
11708 var MediaOutlet = function MediaOutlet(_ref) {
11709 var _ref$additionalOption = _ref.additionalOptions;
11710 var additionalOptions = _ref$additionalOption === void 0 ? null : _ref$additionalOption;
11711 var _ref$onClose = _ref.onClose;
11712 var onClose = _ref$onClose === void 0 ? null : _ref$onClose;
11713 var editImage = useEditImage().editImage;
11714 var _useLocation = useLocation({ current: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) || LOCATIONS.GENERATE });
11715 var current = _useLocation.current;
11716 var navigate = _useLocation.navigate;
11717 (0, react.useEffect)(function() {
11718 if ((additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location) && additionalOptions.location !== LOCATIONS.GENERATE) {
11719 navigate(additionalOptions.location);
11720 return;
11721 }
11722 if (editImage.url) if (new RegExp(IMAGE_PLACEHOLDERS_HOSTS.WIREFRAME).test(new URL(editImage.url).host)) navigate(LOCATIONS.GENERATE);
11723 else if ("url" === editImage.source || editImage.id) navigate(LOCATIONS.IMAGE_TOOLS);
11724 else navigate(LOCATIONS.GENERATE);
11725 }, [
11726 editImage.id,
11727 editImage.url,
11728 editImage.source,
11729 additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.location
11730 ]);
11731 useSubscribeOnPromptHistoryAction([{
11732 type: ACTION_TYPES.RESTORE,
11733 handler: function handler() {
11734 if (current !== LOCATIONS.GENERATE) navigate(LOCATIONS.GENERATE);
11735 }
11736 }]);
11737 if (!current) return /*#__PURE__*/ react.default.createElement(View, { alignItems: "center" }, /*#__PURE__*/ react.default.createElement(Loader, null));
11738 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, current === LOCATIONS.GENERATE && /*#__PURE__*/ react.default.createElement(Generate, {
11739 textToImageHook: additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.textToImageHook ? additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.textToImageHook : useTextToImage,
11740 predefinedPrompt: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.predefinedPrompt,
11741 initialSettings: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.initialSettings
11742 }), current === LOCATIONS.IMAGE_TOOLS && /*#__PURE__*/ react.default.createElement(ImageTools, null), current === LOCATIONS.VARIATIONS && /*#__PURE__*/ react.default.createElement(Variations, null), current === LOCATIONS.IN_PAINTING && /*#__PURE__*/ react.default.createElement(InPainting, null), current === LOCATIONS.OUT_PAINTING && /*#__PURE__*/ react.default.createElement(OutPainting, null), current === LOCATIONS.RESIZE && /*#__PURE__*/ react.default.createElement(Resize, null), current === LOCATIONS.REPLACE_BACKGROUND && /*#__PURE__*/ react.default.createElement(ReplaceBackground, null), current === LOCATIONS.REMOVE_BACKGROUND && /*#__PURE__*/ react.default.createElement(RemoveBackground, null), current === LOCATIONS.CLEANUP && /*#__PURE__*/ react.default.createElement(Cleanup, null), current === LOCATIONS.PRODUCT_IMAGE_UNIFICATION && /*#__PURE__*/ react.default.createElement(ProductImageUnification, { onClose }), current === LOCATIONS.ISOLATE_OBJECT && /*#__PURE__*/ react.default.createElement(IsolateObject, null));
11743 };
11744 MediaOutlet.propTypes = {
11745 additionalOptions: import_prop_types$7.default.object,
11746 onClose: import_prop_types$7.default.func
11747 };
11748
11749 //#endregion
11750 //#region modules/ai/assets/js/editor/pages/form-media/components/unsaved-changes-alert.js
11751 init_extends();
11752 init_objectWithoutProperties$1();
11753 var _excluded$13 = ["onClose", "onCancel"];
11754 var UnsavedChangesAlert$1 = function UnsavedChangesAlert(_ref) {
11755 var onClose = _ref.onClose;
11756 var onCancel = _ref.onCancel;
11757 var props = _objectWithoutProperties$1(_ref, _excluded$13);
11758 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
11759 sx: { zIndex: 2e5 },
11760 "aria-labelledby": "unsaved-changes-alert-title",
11761 "aria-describedby": "unsaved-changes-alert-description"
11762 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogTitle, { id: "unsaved-changes-alert-title" }, (0, _wordpress_i18n.__)("Leave Elementor AI?", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContentText, { id: "unsaved-changes-alert-description" }, (0, _wordpress_i18n.__)("Images will be gone forever and we won’t be able to recover them.", "elementor"))), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogActions, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11763 onClick: onCancel,
11764 color: "secondary"
11765 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
11766 onClick: onClose,
11767 color: "error",
11768 variant: "contained"
11769 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
11770 };
11771 UnsavedChangesAlert$1.propTypes = {
11772 onClose: import_prop_types$7.default.func,
11773 onCancel: import_prop_types$7.default.func
11774 };
11775
11776 //#endregion
11777 //#region modules/ai/assets/js/editor/components/prompt-history/history-button.js
11778 init_extends();
11779 init_objectWithoutProperties$1();
11780 var _excluded$12 = ["isActive"];
11781 var _templateObject$8;
11782 var StyledHistoryButton = (0, _elementor_ui.styled)(_elementor_ui.IconButton)(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteral([
11783 "\n margin-right: ",
11784 ";\n\n ",
11785 "\n"
11786 ])), function(_ref) {
11787 return _ref.theme.spacing(2);
11788 }, function(_ref2) {
11789 var isActive = _ref2.isActive;
11790 var theme = _ref2.theme;
11791 return isActive && "\n background-color: ".concat(theme.palette.action.hover, ";\n color: ").concat(theme.palette.text.tertiary, ";\n ");
11792 });
11793 var PromptHistoryButton = function PromptHistoryButton(_ref3) {
11794 var isActive = _ref3.isActive;
11795 var props = _objectWithoutProperties$1(_ref3, _excluded$12);
11796 return /*#__PURE__*/ react.default.createElement(StyledHistoryButton, _extends$1({
11797 "aria-label": (0, _wordpress_i18n.__)("Show prompt history", "elementor"),
11798 type: "button",
11799 size: "small",
11800 isActive
11801 }, props), /*#__PURE__*/ react.default.createElement(_elementor_icons.HistoryIcon, null));
11802 };
11803 PromptHistoryButton.propTypes = { isActive: import_prop_types$7.default.bool.isRequired };
11804
11805 //#endregion
11806 //#region modules/ai/assets/js/editor/hooks/use-prompt-history.js
11807 init_asyncToGenerator();
11808 init_slicedToArray();
11809 init_defineProperty$1();
11810 init_api();
11811 function ownKeys$9(e, r) {
11812 var t = Object.keys(e);
11813 if (Object.getOwnPropertySymbols) {
11814 var o = Object.getOwnPropertySymbols(e);
11815 r && (o = o.filter(function(r) {
11816 return Object.getOwnPropertyDescriptor(e, r).enumerable;
11817 })), t.push.apply(t, o);
11818 }
11819 return t;
11820 }
11821 __name(ownKeys$9, "ownKeys");
11822 function _objectSpread$9(e) {
11823 for (var r = 1; r < arguments.length; r++) {
11824 var t = null != arguments[r] ? arguments[r] : {};
11825 r % 2 ? ownKeys$9(Object(t), !0).forEach(function(r) {
11826 _defineProperty$1(e, r, t[r]);
11827 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function(r) {
11828 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
11829 });
11830 }
11831 return e;
11832 }
11833 __name(_objectSpread$9, "_objectSpread");
11834 var getImageThumbnailURL = function getImageThumbnailURL(base, imageURL) {
11835 if (!base) return imageURL;
11836 return "".concat(base, "/?o=").concat(btoa(imageURL, false));
11837 };
11838 var normalizeItems = function normalizeItems(response) {
11839 var meta = response.meta;
11840 var items = response.items;
11841 return items === null || items === void 0 ? void 0 : items.map(function(item) {
11842 var _item$request;
11843 var _item$request2;
11844 var _item$request3;
11845 var _item$response;
11846 var _item$response2;
11847 var _item$response3;
11848 return {
11849 id: item === null || item === void 0 ? void 0 : item.elementorApiId,
11850 date: item === null || item === void 0 ? void 0 : item.createdAt,
11851 action: item === null || item === void 0 ? void 0 : item.action,
11852 prompt: item === null || item === void 0 || (_item$request = item.request) === null || _item$request === void 0 ? void 0 : _item$request.prompt,
11853 imageType: item === null || item === void 0 || (_item$request2 = item.request) === null || _item$request2 === void 0 ? void 0 : _item$request2.image_type,
11854 ratio: item === null || item === void 0 || (_item$request3 = item.request) === null || _item$request3 === void 0 ? void 0 : _item$request3.ratio,
11855 text: item === null || item === void 0 || (_item$response = item.response) === null || _item$response === void 0 || (_item$response = _item$response.results) === null || _item$response === void 0 ? void 0 : _item$response.text,
11856 images: item === null || item === void 0 || (_item$response2 = item.response) === null || _item$response2 === void 0 || (_item$response2 = _item$response2.results) === null || _item$response2 === void 0 ? void 0 : _item$response2.images,
11857 thumbnails: item === null || item === void 0 || (_item$response3 = item.response) === null || _item$response3 === void 0 || (_item$response3 = _item$response3.results) === null || _item$response3 === void 0 || (_item$response3 = _item$response3.images) === null || _item$response3 === void 0 ? void 0 : _item$response3.map(function(image) {
11858 return _objectSpread$9(_objectSpread$9({}, image), {}, { image_url: getImageThumbnailURL(meta.thumbnailUrl, image.image_url) });
11859 })
11860 };
11861 });
11862 };
11863 var usePromptHistory = function usePromptHistory(historyType) {
11864 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11865 var isLoading = _useState2[0];
11866 var setIsLoading = _useState2[1];
11867 var _useState4 = _slicedToArray((0, react.useState)({}), 2);
11868 var data = _useState4[0];
11869 var setData = _useState4[1];
11870 var _useState6 = _slicedToArray((0, react.useState)(""), 2);
11871 var error = _useState6[0];
11872 var setError = _useState6[1];
11873 var fetchData = /*#__PURE__*/ function() {
11874 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(_ref) {
11875 var page;
11876 var limit;
11877 return import_regenerator$2.default.wrap(function(_context) {
11878 while (1) switch (_context.prev = _context.next) {
11879 case 0:
11880 page = _ref.page, limit = _ref.limit;
11881 return _context.abrupt("return", new Promise(function(resolve, reject) {
11882 setIsLoading(true);
11883 getHistory(historyType, page, limit).then(function(response) {
11884 var clone = JSON.parse(JSON.stringify(data));
11885 clone.meta = response.meta;
11886 clone.items = [].concat(_toConsumableArray((clone === null || clone === void 0 ? void 0 : clone.items) || []), _toConsumableArray(normalizeItems(response)));
11887 setData(clone);
11888 resolve(true);
11889 }).catch(function(err) {
11890 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
11891 setError(finalError);
11892 reject(finalError);
11893 }).finally(function() {
11894 return setIsLoading(false);
11895 });
11896 }));
11897 case 1:
11898 case "end": return _context.stop();
11899 }
11900 }, _callee);
11901 }));
11902 return function fetchData(_x) {
11903 return _ref2.apply(this, arguments);
11904 };
11905 }();
11906 return {
11907 isLoading,
11908 error,
11909 items: data.items,
11910 meta: data.meta,
11911 fetchData,
11912 deleteItemById: function deleteItemById(id) {
11913 var itemIndex = data.items.findIndex(function(item) {
11914 return item.id === id;
11915 });
11916 if (-1 === itemIndex) return false;
11917 var clone = JSON.parse(JSON.stringify(data));
11918 clone.items.splice(itemIndex, 1);
11919 setData(clone);
11920 return true;
11921 }
11922 };
11923 };
11924
11925 //#endregion
11926 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-header.js
11927 var StyledContent$2 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref) {
11928 var theme = _ref.theme;
11929 return {
11930 marginTop: 0,
11931 padding: theme.spacing(1.5),
11932 borderBottom: "1px solid ".concat(theme.palette.action.focus),
11933 display: "flex",
11934 alignItems: "center",
11935 justifyContent: "space-between"
11936 };
11937 });
11938 var PromptHistoryModalHeader = function PromptHistoryModalHeader(_ref2) {
11939 var onClose = _ref2.onClose;
11940 return /*#__PURE__*/ react.default.createElement(StyledContent$2, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
11941 fontWeight: "bolder",
11942 variant: "h6",
11943 sx: { userSelect: "none" }
11944 }, (0, _wordpress_i18n.__)("History", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
11945 size: "small",
11946 "aria-label": (0, _wordpress_i18n.__)("Hide prompt history", "elementor"),
11947 onClick: onClose
11948 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, { fontSize: "small" })));
11949 };
11950 PromptHistoryModalHeader.propTypes = { onClose: import_prop_types$7.default.func.isRequired };
11951
11952 //#endregion
11953 //#region modules/ai/assets/js/editor/hooks/use-delete-prompt-history-item.js
11954 init_asyncToGenerator();
11955 init_slicedToArray();
11956 init_api();
11957 var useDeletePromptHistoryItem = function useDeletePromptHistoryItem() {
11958 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
11959 var isLoading = _useState2[0];
11960 var setIsLoading = _useState2[1];
11961 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
11962 var error = _useState4[0];
11963 var setError = _useState4[1];
11964 return {
11965 isLoading,
11966 error,
11967 deleteItem: /* @__PURE__ */ function() {
11968 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(id) {
11969 return import_regenerator$2.default.wrap(function(_context) {
11970 while (1) switch (_context.prev = _context.next) {
11971 case 0: return _context.abrupt("return", new Promise(function(resolve, reject) {
11972 setError("");
11973 setIsLoading(true);
11974 deleteHistoryItem(id).then(function() {
11975 resolve(true);
11976 }).catch(function(err) {
11977 var finalError = (err === null || err === void 0 ? void 0 : err.responseText) || err;
11978 setError(finalError);
11979 reject(finalError);
11980 }).finally(function() {
11981 return setIsLoading(false);
11982 });
11983 }));
11984 case 1:
11985 case "end": return _context.stop();
11986 }
11987 }, _callee);
11988 }));
11989 return function deleteItem(_x) {
11990 return _ref.apply(this, arguments);
11991 };
11992 }()
11993 };
11994 };
11995
11996 //#endregion
11997 //#region modules/ai/assets/js/editor/helpers/date-helpers.js
11998 /**
11999 * Formats a date (like wp_date() in PHP), translating it into site's locale.
12000 *
12001 * @param {string} format PHP-style formatting string.
12002 * @param {Date | string | undefined} date Date object
12003 * @param {string | number | undefined=} timezone Timezone to output result in or a UTC offset. Defaults to timezone from site.
12004 * @return {string}
12005 */
12006 var translateDate = function translateDate(format, date, timezone) {
12007 var _window$wp;
12008 if ((_window$wp = window.wp) !== null && _window$wp !== void 0 && _window$wp.date) {
12009 var _window$wp2;
12010 var dateI18n = ((_window$wp2 = window.wp) === null || _window$wp2 === void 0 ? void 0 : _window$wp2.date).dateI18n;
12011 return dateI18n(format, date, timezone);
12012 }
12013 return date;
12014 };
12015 /**
12016 * Returns difference in days between two dates
12017 *
12018 * @param {Date} firstDate
12019 * @param {Date} secondDate
12020 * @return {number} Positive or negative number in days
12021 */
12022 var daysDiff = function daysDiff(firstDate, secondDate) {
12023 var MS_PER_DAY = 1e3 * 60 * 60 * 24;
12024 var firstUTC = Date.UTC(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate());
12025 var secondUTC = Date.UTC(secondDate.getFullYear(), secondDate.getMonth(), secondDate.getDate());
12026 return Math.floor((secondUTC - firstUTC) / MS_PER_DAY);
12027 };
12028
12029 //#endregion
12030 //#region modules/ai/assets/js/editor/icons/restore-icon.js
12031 init_extends();
12032 var RestoreIcon = react.default.forwardRef(function(props, ref) {
12033 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12034 fillRule: "evenodd",
12035 d: "M11.913 3.22a8.781 8.781 0 0 1 3.367.634.75.75 0 1 1-.56 1.392A7.281 7.281 0 0 0 8.25 18.24V15a.75.75 0 0 1 1.5 0v4.433a.73.73 0 0 1 0 .034V20a.75.75 0 0 1-.75.75H4a.75.75 0 0 1 0-1.5h3.045a8.782 8.782 0 0 1 4.868-16.03ZM18.37 6.41a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM13 19.19a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM16.84 17.62a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM19.37 14.35a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0v-.01a.75.75 0 0 1 .75-.75ZM19.94 10.25a.75.75 0 0 1 .75.75v.01a.75.75 0 0 1-1.5 0V11a.75.75 0 0 1 .75-.75Z",
12036 clipRule: "evenodd"
12037 }));
12038 });
12039
12040 //#endregion
12041 //#region modules/ai/assets/js/editor/components/tooltip.js
12042 init_extends();
12043 init_objectWithoutProperties$1();
12044 var _excluded$11 = ["children"];
12045 var Tooltip$2 = function Tooltip(_ref) {
12046 var children = _ref.children;
12047 var props = _objectWithoutProperties$1(_ref, _excluded$11);
12048 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, _extends$1({ componentsProps: { tooltip: { sx: {
12049 "&.MuiTooltip-tooltip[class*=\"MuiTooltip-tooltipPlacement\"]": {
12050 m: 0,
12051 fontSize: "10px",
12052 fontWeight: 500,
12053 lineHeight: "1.4em"
12054 },
12055 py: .5,
12056 px: 1
12057 } } } }, props), children);
12058 };
12059 Tooltip$2.propTypes = { children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node]) };
12060
12061 //#endregion
12062 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-action-button.js
12063 init_extends();
12064 init_objectWithoutProperties$1();
12065 var _excluded$10 = ["tooltipTitle"];
12066 var ActionButton = function ActionButton(_ref) {
12067 var tooltipTitle = _ref.tooltipTitle;
12068 var props = _objectWithoutProperties$1(_ref, _excluded$10);
12069 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12070 title: tooltipTitle,
12071 placement: "top"
12072 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, _extends$1({
12073 type: "button",
12074 size: "small",
12075 disableRipple: true,
12076 disableFocusRipple: true,
12077 disableTouchRipple: true
12078 }, props)));
12079 };
12080 ActionButton.propTypes = { tooltipTitle: import_prop_types$7.default.string.isRequired };
12081
12082 //#endregion
12083 //#region modules/ai/assets/js/editor/icons/text-icon.js
12084 init_extends();
12085 var TextIcon = react.default.forwardRef(function(props, ref) {
12086 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12087 fillRule: "evenodd",
12088 d: "M4.25 5A.75.75 0 0 1 5 4.25h14a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0V5.75H5.75V7a.75.75 0 0 1-1.5 0V5Z",
12089 clipRule: "evenodd"
12090 }), /*#__PURE__*/ react.default.createElement("path", {
12091 fillRule: "evenodd",
12092 d: "M12 4.25a.75.75 0 0 1 .75.75v14a.75.75 0 0 1-1.5 0V5a.75.75 0 0 1 .75-.75Z",
12093 clipRule: "evenodd"
12094 }), /*#__PURE__*/ react.default.createElement("path", {
12095 fillRule: "evenodd",
12096 d: "M9.25 19a.75.75 0 0 1 .75-.75h4a.75.75 0 0 1 0 1.5h-4a.75.75 0 0 1-.75-.75Z",
12097 clipRule: "evenodd"
12098 }));
12099 });
12100
12101 //#endregion
12102 //#region modules/ai/assets/js/editor/icons/code-icon.js
12103 init_extends();
12104 var CodeIcon = react.default.forwardRef(function(props, ref) {
12105 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
12106 fillRule: "evenodd",
12107 d: "M7.53 7.47a.75.75 0 0 1 0 1.06L4.06 12l3.47 3.47a.75.75 0 1 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 0ZM16.47 7.47a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1 0 1.06l-4 4a.75.75 0 1 1-1.06-1.06L19.94 12l-3.47-3.47a.75.75 0 0 1 0-1.06ZM14.182 3.272a.75.75 0 0 1 .546.91l-4 16a.75.75 0 0 1-1.456-.364l4-16a.75.75 0 0 1 .91-.546Z",
12108 clipRule: "evenodd"
12109 }));
12110 });
12111
12112 //#endregion
12113 //#region modules/ai/assets/js/editor/components/prompt-history/parts/action-icon.js
12114 var FALLBACK_ICON = /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { "data-testid": "e-ph-fi" });
12115 var ICONS_BY_ACTIONS = Object.freeze({
12116 "enhance-image-prompt": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12117 "get-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12118 "edit-text": /*#__PURE__*/ react.default.createElement(TextIcon, null),
12119 "custom-css": /*#__PURE__*/ react.default.createElement(CodeIcon, null),
12120 "custom-code": /*#__PURE__*/ react.default.createElement(CodeIcon, null)
12121 });
12122 var PromptHistoryActionIcon = function PromptHistoryActionIcon(_ref) {
12123 var action = _ref.action;
12124 if (ICONS_BY_ACTIONS[action]) return ICONS_BY_ACTIONS[action];
12125 return FALLBACK_ICON;
12126 };
12127 PromptHistoryActionIcon.propTypes = { action: import_prop_types$7.default.string.isRequired };
12128
12129 //#endregion
12130 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-title.js
12131 var _templateObject$7;
12132 var StyledTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n"])), function(_ref) {
12133 return _ref.theme.spacing(.5);
12134 });
12135 var PromptHistoryItemTitle = function PromptHistoryItemTitle(_ref2) {
12136 var prompt = _ref2.prompt;
12137 return /*#__PURE__*/ react.default.createElement(Tooltip$2, {
12138 title: prompt,
12139 arrow: false,
12140 placement: "bottom-start"
12141 }, /*#__PURE__*/ react.default.createElement(StyledTitle, {
12142 variant: "body2",
12143 noWrap: true,
12144 paragraph: true
12145 }, prompt));
12146 };
12147 PromptHistoryItemTitle.propTypes = { prompt: import_prop_types$7.default.string.isRequired };
12148
12149 //#endregion
12150 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item-secondary-content.js
12151 var _templateObject$6;
12152 var _templateObject2$3;
12153 var StyledDateSubtitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteral(["\n color: ", ";\n"])), function(_ref) {
12154 return _ref.theme.palette.secondary.light;
12155 });
12156 var StyledImage = (0, _elementor_ui.styled)("img")(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteral(["\n height: 72px;\n width: 72px;\n object-fit: cover;\n margin-right: ", ";\n"])), function(_ref2) {
12157 return _ref2.theme.spacing(.5);
12158 });
12159 var PromptHistoryItemSecondaryContent = function PromptHistoryItemSecondaryContent(_ref3) {
12160 var date = _ref3.date;
12161 var thumbnails = _ref3.thumbnails;
12162 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12163 direction: "column",
12164 width: "90%"
12165 }, /*#__PURE__*/ react.default.createElement(StyledDateSubtitle, { variant: "caption" }, date), (thumbnails === null || thumbnails === void 0 ? void 0 : thumbnails.length) > 0 && /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12166 flexDirection: "row",
12167 mt: 1
12168 }, thumbnails.map(
12169 /**
12170 * @param {Object} thumb
12171 * @return {React.ReactNode}
12172 */
12173 function(thumb) {
12174 return /*#__PURE__*/ react.default.createElement(StyledImage, {
12175 key: "thumbnail-".concat(thumb.seed),
12176 alt: "",
12177 src: thumb.image_url
12178 });
12179 }
12180 )));
12181 };
12182 PromptHistoryItemSecondaryContent.propTypes = {
12183 date: import_prop_types$7.default.string.isRequired,
12184 thumbnails: import_prop_types$7.default.array
12185 };
12186
12187 //#endregion
12188 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-item.js
12189 init_objectWithoutProperties$1();
12190 init_prompt_history_action_context();
12191 var _excluded$9 = [
12192 "id",
12193 "date",
12194 "onHistoryItemDelete"
12195 ];
12196 var _templateObject$5;
12197 var _templateObject2$2;
12198 var _templateObject3;
12199 var _templateObject4;
12200 var StyledListItem = (0, _elementor_ui.styled)(_elementor_ui.ListItem)(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteral(["\n & .e-prompt-history-item-actions {\n position: absolute;\n top: -9999px;\n }\n\n &:hover,\n &:focus-visible,\n &:focus-within {\n .MuiTypography-body2 {\n font-weight: 700;\n max-width: ", ";\n }\n\n .e-prompt-history-item-actions {\n position: relative;\n top: -3px;\n }\n }\n"])), function(_ref) {
12201 var actionsCount = _ref.actionsCount;
12202 return "calc(100% - ".concat(actionsCount, " * 26px)");
12203 });
12204 var StyledListItemButton = (0, _elementor_ui.styled)(_elementor_ui.ListItemButton)(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteral(["\n padding: ", ";\n align-items: flex-start;\n cursor: inherit;\n"])), function(_ref2) {
12205 return _ref2.theme.spacing(.5, 2);
12206 });
12207 var StyledListItemIcon = (0, _elementor_ui.styled)(_elementor_ui.ListItemIcon)(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([
12208 "\n min-width: auto;\n\n & > .MuiSvgIcon-root {\n margin-right: ",
12209 ";\n font-size: 1rem;\n position: relative;\n top: ",
12210 ";\n }\n"
12211 ])), function(_ref3) {
12212 return _ref3.theme.spacing(1.5);
12213 }, function(_ref4) {
12214 return _ref4.theme.spacing(.5);
12215 });
12216 var StyledButtonsWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n & .MuiSvgIcon-root {\n font-size: 1rem;\n }\n"])));
12217 var PromptHistoryItem = function PromptHistoryItem(_ref5) {
12218 var id = _ref5.id;
12219 var date = _ref5.date;
12220 var onHistoryItemDelete = _ref5.onHistoryItemDelete;
12221 var props = _objectWithoutProperties$1(_ref5, _excluded$9);
12222 var _usePromptHistoryActi = usePromptHistoryAction();
12223 var getAllowedActions = _usePromptHistoryActi.getAllowedActions;
12224 var onPromptReuse = _usePromptHistoryActi.onPromptReuse;
12225 var onResultEdit = _usePromptHistoryActi.onResultEdit;
12226 var onImagesRestore = _usePromptHistoryActi.onImagesRestore;
12227 var action = props.action;
12228 var prompt = props.prompt;
12229 var text = props.text;
12230 var images = props.images;
12231 var thumbnails = props.thumbnails;
12232 var imageType = props.imageType;
12233 var ratio = props.ratio;
12234 var allowedActions = getAllowedActions();
12235 return /*#__PURE__*/ react.default.createElement(StyledListItem, {
12236 tabIndex: "0",
12237 "data-testid": "e-ph-i",
12238 disableGutters: true,
12239 disablePadding: true,
12240 actionsCount: Object.keys(allowedActions).length
12241 }, /*#__PURE__*/ react.default.createElement(StyledListItemButton, {
12242 component: "div",
12243 role: void 0
12244 }, /*#__PURE__*/ react.default.createElement(StyledListItemIcon, null, /*#__PURE__*/ react.default.createElement(PromptHistoryActionIcon, { action })), /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemText, {
12245 disableTypography: true,
12246 primary: /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12247 direction: "row",
12248 justifyContent: "space-between",
12249 alignItems: "center",
12250 height: "16px"
12251 }, /*#__PURE__*/ react.default.createElement(PromptHistoryItemTitle, { prompt }), /*#__PURE__*/ react.default.createElement(StyledButtonsWrapper, { className: "e-prompt-history-item-actions" }, allowedActions[ACTION_TYPES.REMOVE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12252 onClick: function onClick() {
12253 return onHistoryItemDelete(id);
12254 },
12255 "aria-label": (0, _wordpress_i18n.__)("Remove item", "elementor"),
12256 tooltipTitle: (0, _wordpress_i18n.__)("Remove", "elementor")
12257 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, null)), allowedActions[ACTION_TYPES.REUSE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12258 onClick: function onClick() {
12259 return onPromptReuse(id, prompt);
12260 },
12261 "aria-label": (0, _wordpress_i18n.__)("Reuse prompt", "elementor"),
12262 tooltipTitle: (0, _wordpress_i18n.__)("Reuse prompt", "elementor")
12263 }, /*#__PURE__*/ react.default.createElement(RefreshIcon, null)), allowedActions[ACTION_TYPES.RESTORE] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12264 onClick: function onClick() {
12265 return onImagesRestore(id, {
12266 prompt,
12267 images,
12268 imageType,
12269 ratio
12270 });
12271 },
12272 "aria-label": (0, _wordpress_i18n.__)("Restore", "elementor"),
12273 tooltipTitle: (0, _wordpress_i18n.__)("Restore", "elementor")
12274 }, /*#__PURE__*/ react.default.createElement(RestoreIcon, null)), allowedActions[ACTION_TYPES.EDIT] && /*#__PURE__*/ react.default.createElement(ActionButton, {
12275 onClick: function onClick() {
12276 return onResultEdit(id, text);
12277 },
12278 "aria-label": (0, _wordpress_i18n.__)("Edit result", "elementor"),
12279 tooltipTitle: (0, _wordpress_i18n.__)("Edit", "elementor")
12280 }, /*#__PURE__*/ react.default.createElement(EditIcon$1, null)))),
12281 secondary: /*#__PURE__*/ react.default.createElement(PromptHistoryItemSecondaryContent, {
12282 date,
12283 thumbnails
12284 })
12285 })));
12286 };
12287 PromptHistoryItem.propTypes = {
12288 id: import_prop_types$7.default.string.isRequired,
12289 action: import_prop_types$7.default.string.isRequired,
12290 prompt: import_prop_types$7.default.string.isRequired,
12291 date: import_prop_types$7.default.string.isRequired,
12292 onHistoryItemDelete: import_prop_types$7.default.func.isRequired,
12293 text: import_prop_types$7.default.string,
12294 images: import_prop_types$7.default.array,
12295 thumbnails: import_prop_types$7.default.array,
12296 imageType: import_prop_types$7.default.string,
12297 ratio: import_prop_types$7.default.string
12298 };
12299
12300 //#endregion
12301 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-period.js
12302 init_extends();
12303 init_objectWithoutProperties$1();
12304 var _excluded$8 = ["id", "date"];
12305 var StyledPeriodList = (0, _elementor_ui.styled)(_elementor_ui.List)(function(_ref) {
12306 var theme = _ref.theme;
12307 return { borderBottom: "1px solid ".concat(theme.palette.action.focus) };
12308 });
12309 var StyledPeriodTitle = (0, _elementor_ui.styled)(_elementor_ui.Typography)(function(_ref2) {
12310 var theme = _ref2.theme;
12311 return {
12312 padding: theme.spacing(1.5, 2),
12313 color: theme.palette.secondary.light
12314 };
12315 });
12316 var DATE_FORMAT = (0, _wordpress_i18n.__)("F j, g:i A", "elementor");
12317 var PromptHistoryPeriod = function PromptHistoryPeriod(_ref3) {
12318 var periodTitle = _ref3.periodTitle;
12319 var historyItems = _ref3.historyItems;
12320 var _onHistoryItemDelete = _ref3.onHistoryItemDelete;
12321 return /*#__PURE__*/ react.default.createElement(StyledPeriodList, {
12322 "data-testid": "e-ph-p",
12323 subheader: /*#__PURE__*/ react.default.createElement(_elementor_ui.ListSubheader, {
12324 disableSticky: true,
12325 disableGutters: true
12326 }, /*#__PURE__*/ react.default.createElement(StyledPeriodTitle, {
12327 variant: "body2",
12328 role: "heading",
12329 "aria-level": "6"
12330 }, periodTitle))
12331 }, historyItems.map(function(_ref4) {
12332 var id = _ref4.id;
12333 var date = _ref4.date;
12334 var props = _objectWithoutProperties$1(_ref4, _excluded$8);
12335 return /*#__PURE__*/ react.default.createElement(PromptHistoryItem, _extends$1({
12336 key: id,
12337 date: translateDate(DATE_FORMAT, date),
12338 onHistoryItemDelete: function onHistoryItemDelete() {
12339 return _onHistoryItemDelete(id);
12340 },
12341 id
12342 }, props));
12343 }));
12344 };
12345 PromptHistoryPeriod.propTypes = {
12346 periodTitle: import_prop_types$7.default.string.isRequired,
12347 historyItems: import_prop_types$7.default.array.isRequired,
12348 onHistoryItemDelete: import_prop_types$7.default.func.isRequired
12349 };
12350
12351 //#endregion
12352 //#region modules/ai/assets/js/editor/components/prompt-history/helpers/history-period-helpers.js
12353 init_defineProperty$1();
12354 function _createForOfIteratorHelper(r, e) {
12355 var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
12356 if (!t) {
12357 if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
12358 t && (r = t);
12359 var _n = 0;
12360 var F = function F() {};
12361 return {
12362 s: F,
12363 n: function n() {
12364 return _n >= r.length ? { done: !0 } : {
12365 done: !1,
12366 value: r[_n++]
12367 };
12368 },
12369 e: function e(r) {
12370 throw r;
12371 },
12372 f: F
12373 };
12374 }
12375 throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
12376 }
12377 var o;
12378 var a = !0;
12379 var u = !1;
12380 return {
12381 s: function s() {
12382 t = t.call(r);
12383 },
12384 n: function n() {
12385 var r = t.next();
12386 return a = r.done, r;
12387 },
12388 e: function e(r) {
12389 u = !0, o = r;
12390 },
12391 f: function f() {
12392 try {
12393 a || null == t.return || t.return();
12394 } finally {
12395 if (u) throw o;
12396 }
12397 }
12398 };
12399 }
12400 function _unsupportedIterableToArray(r, a) {
12401 if (r) {
12402 if ("string" == typeof r) return _arrayLikeToArray(r, a);
12403 var t = {}.toString.call(r).slice(8, -1);
12404 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
12405 }
12406 }
12407 function _arrayLikeToArray(r, a) {
12408 (null == a || a > r.length) && (a = r.length);
12409 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
12410 return n;
12411 }
12412 var DATE_KEY = "date";
12413 var LAST_7_DAYS_KEY = "7-days";
12414 var LAST_30_DAYS_KEY = "30-days";
12415 var MONTH_FORMAT = (0, _wordpress_i18n.__)("F", "elementor");
12416 /**
12417 * Sorts items in ascending order by date.
12418 *
12419 * @param {Array} historyData
12420 * @return {Array}
12421 */
12422 var sortPromptHistoryData = function sortPromptHistoryData(historyData) {
12423 return _toConsumableArray(historyData).sort(function(a, b) {
12424 return new Date(b[DATE_KEY]) - new Date(a[DATE_KEY]);
12425 });
12426 };
12427 /**
12428 * Groups prompt history data by time periods.
12429 *
12430 * @param {Array} historyData
12431 * @return {Object.<string, {label: string, items: any[]}>}
12432 */
12433 var groupPromptHistoryData = function groupPromptHistoryData(historyData) {
12434 var data = sortPromptHistoryData(historyData);
12435 var currentDate = /* @__PURE__ */ new Date();
12436 var result = _defineProperty$1(_defineProperty$1({}, LAST_7_DAYS_KEY, {
12437 label: (0, _wordpress_i18n.__)("Last 7 days", "elementor"),
12438 items: []
12439 }), LAST_30_DAYS_KEY, {
12440 label: (0, _wordpress_i18n.__)("Last 30 days", "elementor"),
12441 items: []
12442 });
12443 var _iterator = _createForOfIteratorHelper(data);
12444 var _step;
12445 try {
12446 for (_iterator.s(); !(_step = _iterator.n()).done;) {
12447 var item = _step.value;
12448 var date = new Date(item[DATE_KEY]);
12449 var diff = daysDiff(date, currentDate);
12450 if (diff <= 7) {
12451 result[LAST_7_DAYS_KEY].items.push(item);
12452 continue;
12453 }
12454 if (diff <= 30) {
12455 result[LAST_30_DAYS_KEY].items.push(item);
12456 continue;
12457 }
12458 var month = date.getMonth();
12459 if (!result[month]) result[month] = {
12460 label: translateDate(MONTH_FORMAT, date),
12461 items: []
12462 };
12463 result[month].items.push(item);
12464 }
12465 } catch (err) {
12466 _iterator.e(err);
12467 } finally {
12468 _iterator.f();
12469 }
12470 return result;
12471 };
12472 var renderPeriods = function renderPeriods(_ref) {
12473 var _groupData$LAST_7_DAY;
12474 var _groupData$LAST_30_DA;
12475 var items = _ref.items;
12476 var onDelete = _ref.onDelete;
12477 var groupData = groupPromptHistoryData(items);
12478 var periods = [];
12479 if ((_groupData$LAST_7_DAY = groupData["7-days"]) !== null && _groupData$LAST_7_DAY !== void 0 && (_groupData$LAST_7_DAY = _groupData$LAST_7_DAY.items) !== null && _groupData$LAST_7_DAY !== void 0 && _groupData$LAST_7_DAY.length) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12480 periodTitle: groupData[LAST_7_DAYS_KEY].label,
12481 onHistoryItemDelete: onDelete,
12482 historyItems: groupData[LAST_7_DAYS_KEY].items
12483 }));
12484 if ((_groupData$LAST_30_DA = groupData["30-days"]) !== null && _groupData$LAST_30_DA !== void 0 && (_groupData$LAST_30_DA = _groupData$LAST_30_DA.items) !== null && _groupData$LAST_30_DA !== void 0 && _groupData$LAST_30_DA.length) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12485 periodTitle: groupData[LAST_30_DAYS_KEY].label,
12486 onHistoryItemDelete: onDelete,
12487 historyItems: groupData[LAST_30_DAYS_KEY].items
12488 }));
12489 for (var i = 12; i >= 0; i--) if (groupData[i]) periods.push(/*#__PURE__*/ react.default.createElement(PromptHistoryPeriod, {
12490 periodTitle: groupData[i].label,
12491 onHistoryItemDelete: onDelete,
12492 historyItems: groupData[i].items
12493 }));
12494 return periods;
12495 };
12496
12497 //#endregion
12498 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-empty.js
12499 init_history_types();
12500 var PromptHistoryEmpty = function PromptHistoryEmpty(_ref) {
12501 var historyType = _ref.historyType;
12502 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12503 justifyContent: "center",
12504 sx: {
12505 height: "100%",
12506 textAlign: "center"
12507 },
12508 "data-testid": "e-ph-empty"
12509 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "h6" }, (0, _wordpress_i18n.__)("Prepare to be amazed", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body1" }, (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("This is where you'll find all the %s you've generated using Elementor AI.", "elementor"), getTranslatedPromptHistoryType(historyType))));
12510 };
12511 PromptHistoryEmpty.propTypes = { historyType: import_prop_types$7.default.oneOf(Object.values(HISTORY_TYPES)).isRequired };
12512
12513 //#endregion
12514 //#region node_modules/react-infinite-scroller/src/InfiniteScroll.js
12515 init_objectWithoutProperties();
12516 init_defineProperty();
12517 var _excluded$7 = [
12518 "children",
12519 "element",
12520 "hasMore",
12521 "initialLoad",
12522 "isReverse",
12523 "loader",
12524 "loadMore",
12525 "pageStart",
12526 "ref",
12527 "threshold",
12528 "useCapture",
12529 "useWindow",
12530 "getScrollParent"
12531 ];
12532 var InfiniteScroll = class extends react.Component {
12533 constructor(props) {
12534 super(props);
12535 this.scrollListener = this.scrollListener.bind(this);
12536 this.eventListenerOptions = this.eventListenerOptions.bind(this);
12537 this.mousewheelListener = this.mousewheelListener.bind(this);
12538 }
12539 componentDidMount() {
12540 this.pageLoaded = this.props.pageStart;
12541 this.options = this.eventListenerOptions();
12542 this.attachScrollListener();
12543 }
12544 componentDidUpdate() {
12545 if (this.props.isReverse && this.loadMore) {
12546 const parentElement = this.getParentElement(this.scrollComponent);
12547 parentElement.scrollTop = parentElement.scrollHeight - this.beforeScrollHeight + this.beforeScrollTop;
12548 this.loadMore = false;
12549 }
12550 this.attachScrollListener();
12551 }
12552 componentWillUnmount() {
12553 this.detachScrollListener();
12554 this.detachMousewheelListener();
12555 }
12556 isPassiveSupported() {
12557 let passive = false;
12558 const testOptions = { get passive() {
12559 passive = true;
12560 } };
12561 try {
12562 document.addEventListener("test", null, testOptions);
12563 document.removeEventListener("test", null, testOptions);
12564 } catch (e) {}
12565 return passive;
12566 }
12567 eventListenerOptions() {
12568 let options = this.props.useCapture;
12569 if (this.isPassiveSupported()) options = {
12570 useCapture: this.props.useCapture,
12571 passive: true
12572 };
12573 else options = { passive: false };
12574 return options;
12575 }
12576 setDefaultLoader(loader) {
12577 this.defaultLoader = loader;
12578 }
12579 detachMousewheelListener() {
12580 let scrollEl = window;
12581 if (this.props.useWindow === false) scrollEl = this.scrollComponent.parentNode;
12582 scrollEl.removeEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12583 }
12584 detachScrollListener() {
12585 let scrollEl = window;
12586 if (this.props.useWindow === false) scrollEl = this.getParentElement(this.scrollComponent);
12587 scrollEl.removeEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12588 scrollEl.removeEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12589 }
12590 getParentElement(el) {
12591 const scrollParent = this.props.getScrollParent && this.props.getScrollParent();
12592 if (scrollParent != null) return scrollParent;
12593 return el && el.parentNode;
12594 }
12595 filterProps(props) {
12596 return props;
12597 }
12598 attachScrollListener() {
12599 const parentElement = this.getParentElement(this.scrollComponent);
12600 if (!this.props.hasMore || !parentElement) return;
12601 let scrollEl = window;
12602 if (this.props.useWindow === false) scrollEl = parentElement;
12603 scrollEl.addEventListener("mousewheel", this.mousewheelListener, this.options ? this.options : this.props.useCapture);
12604 scrollEl.addEventListener("scroll", this.scrollListener, this.options ? this.options : this.props.useCapture);
12605 scrollEl.addEventListener("resize", this.scrollListener, this.options ? this.options : this.props.useCapture);
12606 if (this.props.initialLoad) this.scrollListener();
12607 }
12608 mousewheelListener(e) {
12609 if (e.deltaY === 1 && !this.isPassiveSupported()) e.preventDefault();
12610 }
12611 scrollListener() {
12612 const el = this.scrollComponent;
12613 const scrollEl = window;
12614 const parentNode = this.getParentElement(el);
12615 let offset;
12616 if (this.props.useWindow) {
12617 const doc = document.documentElement || document.body.parentNode || document.body;
12618 const scrollTop = scrollEl.pageYOffset !== void 0 ? scrollEl.pageYOffset : doc.scrollTop;
12619 if (this.props.isReverse) offset = scrollTop;
12620 else offset = this.calculateOffset(el, scrollTop);
12621 } else if (this.props.isReverse) offset = parentNode.scrollTop;
12622 else offset = el.scrollHeight - parentNode.scrollTop - parentNode.clientHeight;
12623 if (offset < Number(this.props.threshold) && el && el.offsetParent !== null) {
12624 this.detachScrollListener();
12625 this.beforeScrollHeight = parentNode.scrollHeight;
12626 this.beforeScrollTop = parentNode.scrollTop;
12627 if (typeof this.props.loadMore === "function") {
12628 this.props.loadMore(this.pageLoaded += 1);
12629 this.loadMore = true;
12630 }
12631 }
12632 }
12633 calculateOffset(el, scrollTop) {
12634 if (!el) return 0;
12635 return this.calculateTopPosition(el) + (el.offsetHeight - scrollTop - window.innerHeight);
12636 }
12637 calculateTopPosition(el) {
12638 if (!el) return 0;
12639 return el.offsetTop + this.calculateTopPosition(el.offsetParent);
12640 }
12641 render() {
12642 const renderProps = this.filterProps(this.props);
12643 const { children, element, hasMore, initialLoad, isReverse, loader, loadMore, pageStart, ref, threshold, useCapture, useWindow, getScrollParent } = renderProps, props = _objectWithoutProperties(renderProps, _excluded$7);
12644 props.ref = (node) => {
12645 this.scrollComponent = node;
12646 if (ref) ref(node);
12647 };
12648 const childrenArray = [children];
12649 if (hasMore) {
12650 if (loader) isReverse ? childrenArray.unshift(loader) : childrenArray.push(loader);
12651 else if (this.defaultLoader) isReverse ? childrenArray.unshift(this.defaultLoader) : childrenArray.push(this.defaultLoader);
12652 }
12653 return react.default.createElement(element, props, childrenArray);
12654 }
12655 };
12656 _defineProperty(InfiniteScroll, "propTypes", {
12657 children: import_prop_types$7.default.node.isRequired,
12658 element: import_prop_types$7.default.node,
12659 hasMore: import_prop_types$7.default.bool,
12660 initialLoad: import_prop_types$7.default.bool,
12661 isReverse: import_prop_types$7.default.bool,
12662 loader: import_prop_types$7.default.node,
12663 loadMore: import_prop_types$7.default.func.isRequired,
12664 pageStart: import_prop_types$7.default.number,
12665 ref: import_prop_types$7.default.func,
12666 getScrollParent: import_prop_types$7.default.func,
12667 threshold: import_prop_types$7.default.number,
12668 useCapture: import_prop_types$7.default.bool,
12669 useWindow: import_prop_types$7.default.bool
12670 });
12671 _defineProperty(InfiniteScroll, "defaultProps", {
12672 element: "div",
12673 hasMore: false,
12674 initialLoad: true,
12675 pageStart: 0,
12676 ref: null,
12677 threshold: 250,
12678 useWindow: true,
12679 isReverse: false,
12680 useCapture: false,
12681 loader: null,
12682 getScrollParent: null
12683 });
12684
12685 //#endregion
12686 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-upgrade.js
12687 init_defineProperty$1();
12688 init_history_types();
12689 var VARIANT_FULL = "full";
12690 var VARIANT_SMALL = "small";
12691 var messages = _defineProperty$1(_defineProperty$1({}, VARIANT_FULL, (0, _wordpress_i18n.__)("Want to see your %s generation history for as far as the past 90 days?", "elementor")), VARIANT_SMALL, (0, _wordpress_i18n.__)("Want to see your %s generation history for the past 90 days?", "elementor"));
12692 var actionUrl = "https://go.elementor.com/ai-popup-purchase-dropdown/";
12693 var getMessage = function getMessage(variant, historyType) {
12694 return (0, _wordpress_i18n.sprintf)(messages[variant] || messages[VARIANT_FULL], getTranslatedPromptHistoryType(historyType));
12695 };
12696 var PromptHistoryUpgrade = function PromptHistoryUpgrade(_ref) {
12697 var variant = _ref.variant;
12698 var historyType = _ref.historyType;
12699 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
12700 justifyContent: "center",
12701 sx: {
12702 height: VARIANT_SMALL === variant ? "auto" : "100%",
12703 textAlign: "center",
12704 p: 2
12705 },
12706 "data-testid": "e-ph-upgrade-".concat(variant)
12707 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
12708 variant: "body1",
12709 sx: { marginBottom: 2 }
12710 }, getMessage(variant, historyType)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
12711 variant: "contained",
12712 color: "promotion",
12713 size: "small",
12714 href: actionUrl,
12715 target: "_blank",
12716 rel: "noopener noreferrer",
12717 startIcon: /*#__PURE__*/ react.default.createElement(_elementor_icons.UpgradeIcon, null),
12718 sx: {
12719 width: "50%",
12720 alignSelf: "center",
12721 "&:hover": { color: "promotion.contrastText" }
12722 }
12723 }, (0, _wordpress_i18n.__)("Upgrade now", "elementor")));
12724 };
12725 PromptHistoryUpgrade.propTypes = {
12726 variant: import_prop_types$7.default.oneOf([VARIANT_FULL, VARIANT_SMALL]).isRequired,
12727 historyType: import_prop_types$7.default.oneOf(Object.values(HISTORY_TYPES)).isRequired
12728 };
12729
12730 //#endregion
12731 //#region modules/ai/assets/js/editor/components/prompt-history/parts/modal-container.js
12732 init_extends();
12733 init_objectWithoutProperties$1();
12734 init_prompt_history_context();
12735 var _excluded$6 = ["children"];
12736 var _templateObject$4;
12737 var StyledContent$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteral([
12738 "\n width: 360px;\n position: relative;\n margin-top: ",
12739 ";\n margin-right: ",
12740 ";\n background-color: ",
12741 ";\n border-radius: ",
12742 ";\n height: ",
12743 ";\n\n @media screen and (max-width: 456px) {\n width: 320px;\n }\n\n @media screen and (max-width: 420px) {\n width: 230px;\n }\n"
12744 ])), function(_ref) {
12745 return _ref.theme.spacing(2);
12746 }, function(_ref2) {
12747 return _ref2.theme.spacing(2);
12748 }, function(_ref3) {
12749 return _ref3.theme.palette.background.paper;
12750 }, function(_ref4) {
12751 var theme = _ref4.theme;
12752 return "".concat(theme.shape.borderRadius, "px");
12753 }, function(_ref5) {
12754 var height = _ref5.height;
12755 return "calc( ".concat(height, "px - 32px )");
12756 });
12757 var ModalContainer = function ModalContainer(_ref6) {
12758 var children = _ref6.children;
12759 var props = _objectWithoutProperties$1(_ref6, _excluded$6);
12760 var _usePromptHistoryCont = usePromptHistoryContext();
12761 var isOpen = _usePromptHistoryCont.isOpen;
12762 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12763 var onClose = _usePromptHistoryCont.onClose;
12764 var getContainerHeight = _usePromptHistoryCont.getContainerHeight;
12765 var getContainer = _usePromptHistoryCont.getContainer;
12766 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Modal, _extends$1({
12767 container: getContainer(),
12768 open: isModalOpen,
12769 hideBackdrop: true,
12770 onClose,
12771 sx: { position: "absolute" }
12772 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.Backdrop, {
12773 open: true,
12774 sx: {
12775 position: "absolute",
12776 justifyContent: "flex-end",
12777 alignItems: "flex-start"
12778 },
12779 "aria-hidden": false
12780 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Slide, {
12781 direction: "left",
12782 in: isOpen,
12783 timeout: 500,
12784 easing: "ease-in-out"
12785 }, /*#__PURE__*/ react.default.createElement(StyledContent$1, {
12786 "aria-label": (0, _wordpress_i18n.__)("Prompt history modal", "elementor"),
12787 height: getContainerHeight()
12788 }, children))));
12789 };
12790 ModalContainer.propTypes = {
12791 isOpen: import_prop_types$7.default.bool.isRequired,
12792 isModalOpen: import_prop_types$7.default.bool.isRequired,
12793 onClose: import_prop_types$7.default.func.isRequired,
12794 children: import_prop_types$7.default.oneOfType([import_prop_types$7.default.arrayOf(import_prop_types$7.default.node), import_prop_types$7.default.node])
12795 };
12796
12797 //#endregion
12798 //#region modules/ai/assets/js/editor/components/prompt-history/history-modal.js
12799 init_asyncToGenerator();
12800 init_prompt_error_message();
12801 init_prompt_history_context();
12802 var ITEMS_LIMIT = 10;
12803 var FREE_PLAN_ERRORS = ["invalid_connect_data", "no_subscription"];
12804 var PromptHistoryModal = function PromptHistoryModal(props) {
12805 var lastRun = (0, react.useRef)(function() {});
12806 var scrollContainer = (0, react.useRef)(null);
12807 var _usePromptHistoryCont = usePromptHistoryContext();
12808 var historyType = _usePromptHistoryCont.historyType;
12809 var onClose = _usePromptHistoryCont.onClose;
12810 var _usePromptHistory = usePromptHistory(historyType);
12811 var items = _usePromptHistory.items;
12812 var meta = _usePromptHistory.meta;
12813 var isHistoryFetchingInProgress = _usePromptHistory.isLoading;
12814 var historyFetchingError = _usePromptHistory.error;
12815 var fetchData = _usePromptHistory.fetchData;
12816 var deleteItemFromState = _usePromptHistory.deleteItemById;
12817 var _useDeletePromptHisto = useDeletePromptHistoryItem();
12818 var isDeletingInProgress = _useDeletePromptHisto.isLoading;
12819 var historyDeletingError = _useDeletePromptHisto.error;
12820 var deleteItem = _useDeletePromptHisto.deleteItem;
12821 var error = historyFetchingError || historyDeletingError;
12822 var isLoading = isHistoryFetchingInProgress || isDeletingInProgress;
12823 var isLastPage = meta && (meta === null || meta === void 0 ? void 0 : meta.currentPage) === (meta === null || meta === void 0 ? void 0 : meta.totalPages);
12824 var showUpgrade = (items === null || items === void 0 ? void 0 : items.length) > 0 && (meta === null || meta === void 0 ? void 0 : meta.allowedDays) < 90 && isLastPage;
12825 (0, react.useEffect)(function() {
12826 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
12827 return import_regenerator$2.default.wrap(function(_context) {
12828 while (1) switch (_context.prev = _context.next) {
12829 case 0: return _context.abrupt("return", fetchData({
12830 page: 1,
12831 limit: ITEMS_LIMIT
12832 }));
12833 case 1:
12834 case "end": return _context.stop();
12835 }
12836 }, _callee);
12837 }));
12838 lastRun.current();
12839 }, []);
12840 var loadNext = function loadNext() {
12841 if (isLoading || isLastPage) return;
12842 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee2() {
12843 return import_regenerator$2.default.wrap(function(_context2) {
12844 while (1) switch (_context2.prev = _context2.next) {
12845 case 0: return _context2.abrupt("return", fetchData({
12846 page: meta.currentPage + 1,
12847 limit: ITEMS_LIMIT
12848 }));
12849 case 1:
12850 case "end": return _context2.stop();
12851 }
12852 }, _callee2);
12853 }));
12854 lastRun.current();
12855 };
12856 var onHistoryItemDelete = /*#__PURE__*/ function() {
12857 var _ref3 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee4(id) {
12858 return import_regenerator$2.default.wrap(function(_context4) {
12859 while (1) switch (_context4.prev = _context4.next) {
12860 case 0:
12861 lastRun.current = /*#__PURE__*/ _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee3() {
12862 return import_regenerator$2.default.wrap(function(_context3) {
12863 while (1) switch (_context3.prev = _context3.next) {
12864 case 0:
12865 _context3.next = 1;
12866 return deleteItem(id);
12867 case 1: return _context3.abrupt("return", _context3.sent);
12868 case 2:
12869 case "end": return _context3.stop();
12870 }
12871 }, _callee3);
12872 }));
12873 _context4.next = 1;
12874 return lastRun.current();
12875 case 1: if (!historyDeletingError) deleteItemFromState(id);
12876 case 2:
12877 case "end": return _context4.stop();
12878 }
12879 }, _callee4);
12880 }));
12881 return function onHistoryItemDelete(_x) {
12882 return _ref3.apply(this, arguments);
12883 };
12884 }();
12885 return /*#__PURE__*/ react.default.createElement(ModalContainer, props, /*#__PURE__*/ react.default.createElement(PromptHistoryModalHeader, { onClose }), error && !FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
12886 error,
12887 onRetry: lastRun.current,
12888 sx: {
12889 position: "absolute",
12890 zIndex: 1,
12891 marginTop: isLoading ? .5 : "revert"
12892 }
12893 }), isLoading && /*#__PURE__*/ react.default.createElement(_elementor_ui.LinearProgress, {
12894 role: "progressbar",
12895 "aria-label": (0, _wordpress_i18n.__)("Loading", "elementor"),
12896 color: "secondary"
12897 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
12898 sx: {
12899 overflowY: "scroll",
12900 height: "85%"
12901 },
12902 ref: scrollContainer
12903 }, error && FREE_PLAN_ERRORS.includes(error) && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12904 variant: "full",
12905 historyType
12906 }), !error && 0 === (items === null || items === void 0 ? void 0 : items.length) && /*#__PURE__*/ react.default.createElement(PromptHistoryEmpty, { historyType }), (items === null || items === void 0 ? void 0 : items.length) > 0 && /*#__PURE__*/ react.default.createElement(InfiniteScroll, {
12907 loadMore: loadNext,
12908 getScrollParent: function getScrollParent() {
12909 return scrollContainer.current;
12910 },
12911 useWindow: false,
12912 isReverse: false,
12913 threshold: 30,
12914 initialLoad: false,
12915 hasMore: !isLastPage
12916 }, renderPeriods({
12917 items,
12918 onDelete: onHistoryItemDelete
12919 })), showUpgrade && /*#__PURE__*/ react.default.createElement(PromptHistoryUpgrade, {
12920 variant: "small",
12921 historyType
12922 })));
12923 };
12924
12925 //#endregion
12926 //#region modules/ai/assets/js/editor/components/prompt-history/index.js
12927 init_prompt_history_context();
12928 var PROMPT_HISTORY_MODAL_ID = "prompt-history-modal";
12929 var PromptHistory = function PromptHistory() {
12930 var _usePromptHistoryCont = usePromptHistoryContext();
12931 var isOpen = _usePromptHistoryCont.isOpen;
12932 var isModalOpen = _usePromptHistoryCont.isModalOpen;
12933 var onOpen = _usePromptHistoryCont.onOpen;
12934 var onClose = _usePromptHistoryCont.onClose;
12935 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptHistoryButton, {
12936 isActive: isOpen,
12937 onClick: function onClick() {
12938 return isOpen ? onClose() : onOpen();
12939 },
12940 "aria-haspopup": "dialog",
12941 "aria-controls": PROMPT_HISTORY_MODAL_ID
12942 }), isModalOpen && /*#__PURE__*/ react.default.createElement(PromptHistoryModal, { id: PROMPT_HISTORY_MODAL_ID }));
12943 };
12944
12945 //#endregion
12946 //#region modules/ai/assets/js/editor/pages/form-media/index.js
12947 init_extends();
12948 init_slicedToArray();
12949 init_defineProperty$1();
12950 function ownKeys$8(e, r) {
12951 var t = Object.keys(e);
12952 if (Object.getOwnPropertySymbols) {
12953 var o = Object.getOwnPropertySymbols(e);
12954 r && (o = o.filter(function(r) {
12955 return Object.getOwnPropertyDescriptor(e, r).enumerable;
12956 })), t.push.apply(t, o);
12957 }
12958 return t;
12959 }
12960 __name(ownKeys$8, "ownKeys");
12961 function _objectSpread$8(e) {
12962 for (var r = 1; r < arguments.length; r++) {
12963 var t = null != arguments[r] ? arguments[r] : {};
12964 r % 2 ? ownKeys$8(Object(t), !0).forEach(function(r) {
12965 _defineProperty$1(e, r, t[r]);
12966 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function(r) {
12967 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
12968 });
12969 }
12970 return e;
12971 }
12972 __name(_objectSpread$8, "_objectSpread");
12973 var initialData = {
12974 isAllSaved: false,
12975 hasUnsavedChanges: false
12976 };
12977 var SET_UNSAVED_CHANGES = "SET_UNSAVED_CHANGES";
12978 var SAVE_AND_CLOSE = "SAVE_AND_CLOSE";
12979 var reducer = function reducer(state, _ref) {
12980 var type = _ref.type;
12981 var payload = _ref.payload;
12982 switch (type) {
12983 case SET_UNSAVED_CHANGES: return _objectSpread$8(_objectSpread$8({}, state), {}, {
12984 hasUnsavedChanges: payload,
12985 isAllSaved: payload ? false : state.isAllSaved
12986 });
12987 case SAVE_AND_CLOSE: return _objectSpread$8(_objectSpread$8({}, state), {}, {
12988 isAllSaved: true,
12989 hasUnsavedChanges: false
12990 });
12991 default: throw Error("Unknown action.");
12992 }
12993 };
12994 var FormMedia = function FormMedia(_ref2) {
12995 var onClose = _ref2.onClose;
12996 var DialogProps = _ref2.DialogProps;
12997 var getControlValue = _ref2.getControlValue;
12998 var setControlValue = _ref2.setControlValue;
12999 var additionalOptions = _ref2.additionalOptions;
13000 var maybeRenderUpgradeChip = _ref2.maybeRenderUpgradeChip;
13001 var hasSubscription = _ref2.hasSubscription;
13002 var usagePercentage = _ref2.usagePercentage;
13003 var _useReducer2 = _slicedToArray((0, react.useReducer)(reducer, initialData), 2);
13004 var state = _useReducer2[0];
13005 var dispatch = _useReducer2[1];
13006 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
13007 var showUnsavedChangeAlert = _useState2[0];
13008 var setShowUnsavedChangeAlert = _useState2[1];
13009 var setHasUnsavedChanges = function setHasUnsavedChanges(payload) {
13010 return dispatch({
13011 type: SET_UNSAVED_CHANGES,
13012 payload
13013 });
13014 };
13015 var saveAndClose = function saveAndClose() {
13016 return dispatch({ type: SAVE_AND_CLOSE });
13017 };
13018 var onCloseIntent = function onCloseIntent() {
13019 if (state.hasUnsavedChanges) {
13020 setShowUnsavedChangeAlert(true);
13021 return;
13022 }
13023 onClose();
13024 };
13025 var editImageInitialData = getControlValue() === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultValue) ? {} : getControlValue();
13026 var globalSettings = {
13027 initialImageType: (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.defaultImageType) || "",
13028 hasSubscription,
13029 usagePercentage,
13030 hideBackButton: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideBackButton
13031 };
13032 var globalActions = {
13033 state,
13034 getControlValue,
13035 setControlValue,
13036 saveAndClose,
13037 close: onCloseIntent,
13038 setHasUnsavedChanges
13039 };
13040 (0, react.useEffect)(function() {
13041 if (state.isAllSaved) onClose();
13042 }, [state.isAllSaved]);
13043 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({
13044 id: "e-form-media",
13045 onClose: function onClose() {
13046 return onCloseIntent();
13047 },
13048 maxWidth: "lg"
13049 }, DialogProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
13050 onClose: function onClose() {
13051 return onCloseIntent();
13052 },
13053 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
13054 }, !additionalOptions.withoutHistory && /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), /*#__PURE__*/ react.default.createElement(GlobalSettingsProvider, { settings: globalSettings }, /*#__PURE__*/ react.default.createElement(GlobalActionsProvider, { actions: globalActions }, /*#__PURE__*/ react.default.createElement(LocationProvider, null, /*#__PURE__*/ react.default.createElement(EditImageProvider, { imageData: editImageInitialData }, /*#__PURE__*/ react.default.createElement(MediaOutlet, {
13055 additionalOptions,
13056 onClose
13057 })))))), showUnsavedChangeAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert$1, {
13058 onClose,
13059 onCancel: function onCancel() {
13060 return setShowUnsavedChangeAlert(false);
13061 },
13062 open: true
13063 }));
13064 };
13065 FormMedia.propTypes = {
13066 onClose: import_prop_types$7.default.func.isRequired,
13067 DialogProps: import_prop_types$7.default.object,
13068 getControlValue: import_prop_types$7.default.func.isRequired,
13069 setControlValue: import_prop_types$7.default.func.isRequired,
13070 additionalOptions: import_prop_types$7.default.object,
13071 credits: import_prop_types$7.default.number,
13072 maybeRenderUpgradeChip: import_prop_types$7.default.func,
13073 hasSubscription: import_prop_types$7.default.bool,
13074 usagePercentage: import_prop_types$7.default.number
13075 };
13076
13077 //#endregion
13078 //#region modules/ai/assets/js/editor/hooks/use-animation-prompt.js
13079 init_typeof$1();
13080 init_slicedToArray();
13081 init_defineProperty$1();
13082 init_asyncToGenerator();
13083 init_api();
13084 init_use_prompt();
13085 function ownKeys$7(e, r) {
13086 var t = Object.keys(e);
13087 if (Object.getOwnPropertySymbols) {
13088 var o = Object.getOwnPropertySymbols(e);
13089 r && (o = o.filter(function(r) {
13090 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13091 })), t.push.apply(t, o);
13092 }
13093 return t;
13094 }
13095 __name(ownKeys$7, "ownKeys");
13096 function _objectSpread$7(e) {
13097 for (var r = 1; r < arguments.length; r++) {
13098 var t = null != arguments[r] ? arguments[r] : {};
13099 r % 2 ? ownKeys$7(Object(t), !0).forEach(function(r) {
13100 _defineProperty$1(e, r, t[r]);
13101 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function(r) {
13102 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13103 });
13104 }
13105 return e;
13106 }
13107 __name(_objectSpread$7, "_objectSpread");
13108 var getAnimationResult = /*#__PURE__*/ function() {
13109 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(payload, motionEffectType) {
13110 return import_regenerator$2.default.wrap(function(_context) {
13111 while (1) switch (_context.prev = _context.next) {
13112 case 0: return _context.abrupt("return", getAnimation(_objectSpread$7(_objectSpread$7({}, payload), {}, { motionEffectType })));
13113 case 1:
13114 case "end": return _context.stop();
13115 }
13116 }, _callee);
13117 }));
13118 return function getAnimationResult(_x, _x2) {
13119 return _ref.apply(this, arguments);
13120 };
13121 }();
13122 var useAnimationPrompt = function useAnimationPrompt(motionEffectType, widgetType, initialValue) {
13123 var _usePrompt = usePrompt(function(payload) {
13124 return getAnimationResult(payload, motionEffectType);
13125 }, initialValue);
13126 var data = _usePrompt.data;
13127 var isLoading = _usePrompt.isLoading;
13128 var error = _usePrompt.error;
13129 var reset = _usePrompt.reset;
13130 var send = _usePrompt.send;
13131 var sendUsageData = _usePrompt.sendUsageData;
13132 var getControlData = function getControlData(controlKey) {
13133 var _elementor$widgetsCac;
13134 var _elementor$widgetsCac2;
13135 return {
13136 label: (_elementor$widgetsCac = elementor.widgetsCache) === null || _elementor$widgetsCac === void 0 || (_elementor$widgetsCac = _elementor$widgetsCac[widgetType !== null && widgetType !== void 0 ? widgetType : ""]) === null || _elementor$widgetsCac === void 0 || (_elementor$widgetsCac = _elementor$widgetsCac.controls[controlKey]) === null || _elementor$widgetsCac === void 0 ? void 0 : _elementor$widgetsCac.label,
13137 innerTab: (_elementor$widgetsCac2 = elementor.widgetsCache) === null || _elementor$widgetsCac2 === void 0 || (_elementor$widgetsCac2 = _elementor$widgetsCac2[widgetType !== null && widgetType !== void 0 ? widgetType : ""]) === null || _elementor$widgetsCac2 === void 0 || (_elementor$widgetsCac2 = _elementor$widgetsCac2.controls[controlKey]) === null || _elementor$widgetsCac2 === void 0 ? void 0 : _elementor$widgetsCac2.inner_tab
13138 };
13139 };
13140 var processMotionEffects = function processMotionEffects(jsonObject) {
13141 var result = {};
13142 var firstChild = jsonObject[Object.keys(jsonObject)[0]];
13143 var firstEnableControlKey = Object.keys(firstChild)[0];
13144 result[firstEnableControlKey] = {
13145 isParent: true,
13146 label: getControlData(firstEnableControlKey).label,
13147 value: jsonObject.enabled[firstEnableControlKey],
13148 tabs: 0
13149 };
13150 var processOtherProps = function processOtherProps(props) {
13151 for (var _i = 0, _Object$entries = Object.entries(props); _i < _Object$entries.length; _i++) {
13152 var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2);
13153 var key = _Object$entries$_i[0];
13154 var value = _Object$entries$_i[1];
13155 if ("enabled" === key && value) {
13156 var enableControlKey = Object.keys(value)[0];
13157 result[enableControlKey] = {
13158 isParent: false,
13159 label: getControlData(enableControlKey).label,
13160 value: value[enableControlKey],
13161 tabs: 1
13162 };
13163 } else {
13164 if ("none" === value || "normal" === value) continue;
13165 result[key] = { value };
13166 }
13167 }
13168 };
13169 for (var _i2 = 0, _Object$entries2 = Object.entries(jsonObject); _i2 < _Object$entries2.length; _i2++) {
13170 var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2);
13171 var propKey = _Object$entries2$_i[0];
13172 var propValue = _Object$entries2$_i[1];
13173 if (propKey !== "enabled" && "object" === _typeof$1(propValue)) processOtherProps(propValue);
13174 }
13175 return result;
13176 };
13177 var processEntranceEffects = function processEntranceEffects(jsonObject) {
13178 var result = {};
13179 var firstChildKey = Object.keys(jsonObject)[0];
13180 var firstChild = jsonObject[firstChildKey];
13181 result[firstChildKey] = {
13182 isParent: true,
13183 label: getControlData(firstChildKey).label,
13184 value: firstChild,
13185 tabs: 0
13186 };
13187 result[firstChild] = {
13188 isParent: false,
13189 label: firstChild,
13190 tabs: 1
13191 };
13192 var processProps = function processProps(props) {
13193 for (var _i3 = 0, _Object$entries3 = Object.entries(props); _i3 < _Object$entries3.length; _i3++) {
13194 var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2);
13195 var key = _Object$entries3$_i[0];
13196 var value = _Object$entries3$_i[1];
13197 if ("none" === value || "normal" === value) continue;
13198 result[key] = { value };
13199 }
13200 };
13201 for (var _i4 = 0, _Object$entries4 = Object.entries(jsonObject); _i4 < _Object$entries4.length; _i4++) {
13202 var _Object$entries4$_i = _slicedToArray(_Object$entries4[_i4], 2);
13203 var propKey = _Object$entries4$_i[0];
13204 var propValue = _Object$entries4$_i[1];
13205 if (propKey !== firstChildKey && "object" === _typeof$1(propValue)) processProps(propValue);
13206 }
13207 return result;
13208 };
13209 var processHoverEffects = function processHoverEffects(jsonObject) {
13210 var result = {};
13211 var isHoverLabelAdded = false;
13212 var processProps = function processProps(props) {
13213 for (var _i5 = 0, _Object$entries5 = Object.entries(props); _i5 < _Object$entries5.length; _i5++) {
13214 var _Object$entries5$_i = _slicedToArray(_Object$entries5[_i5], 2);
13215 var key = _Object$entries5$_i[0];
13216 var value = _Object$entries5$_i[1];
13217 if ("enabled" === key && value) {
13218 var enableControlKey = Object.keys(value)[0];
13219 var _getControlData = getControlData(enableControlKey);
13220 var label = _getControlData.label;
13221 var innerTab = _getControlData.innerTab;
13222 if (!isHoverLabelAdded) {
13223 result[innerTab] = {
13224 isParent: true,
13225 label: getControlData(innerTab).label,
13226 tabs: 0
13227 };
13228 isHoverLabelAdded = true;
13229 }
13230 result[enableControlKey] = {
13231 isParent: false,
13232 label,
13233 value: value[enableControlKey],
13234 tabs: 1
13235 };
13236 } else {
13237 if ("none" === value || "normal" === value) continue;
13238 result[key] = { value };
13239 }
13240 }
13241 };
13242 for (var _i6 = 0, _Object$entries6 = Object.entries(jsonObject); _i6 < _Object$entries6.length; _i6++) {
13243 var propValue = _slicedToArray(_Object$entries6[_i6], 2)[1];
13244 if ("object" === _typeof$1(propValue)) processProps(propValue);
13245 }
13246 return result;
13247 };
13248 var digestResult = function digestResult(jsonString) {
13249 var result = {};
13250 function traverse(currentObj) {
13251 if (!currentObj || _typeof$1(currentObj) !== "object") return;
13252 for (var key in currentObj) {
13253 if (!currentObj.hasOwnProperty(key)) continue;
13254 if (["scrolling_effects", "mouse_effects"].includes(key)) {
13255 result = _objectSpread$7(_objectSpread$7({}, result), processMotionEffects(currentObj[key]));
13256 continue;
13257 }
13258 if ("entrance_effects" === key) {
13259 result = _objectSpread$7(_objectSpread$7({}, result), processEntranceEffects(currentObj[key]));
13260 continue;
13261 }
13262 if ("hover_effects" === key) {
13263 result = _objectSpread$7(_objectSpread$7({}, result), processHoverEffects(currentObj[key]));
13264 return;
13265 }
13266 traverse(currentObj[key]);
13267 }
13268 }
13269 traverse(JSON.parse(jsonString));
13270 return result;
13271 };
13272 (0, react.useEffect)(function() {
13273 if (data.result) data.result = digestResult(data.result);
13274 }, [data]);
13275 return {
13276 data,
13277 isLoading,
13278 error,
13279 reset,
13280 send,
13281 sendUsageData
13282 };
13283 };
13284
13285 //#endregion
13286 //#region modules/ai/assets/js/editor/pages/form-animation/index.js
13287 init_asyncToGenerator();
13288 init_slicedToArray();
13289 init_actions_data();
13290 init_loader();
13291 init_prompt_search();
13292 init_prompt_suggestions();
13293 init_generate_button();
13294 init_prompt_error_message();
13295 init_requests_ids();
13296 init_voice_promotion_alert();
13297 var CodeDisplayWrapper$1 = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
13298 return {
13299 "& p": {
13300 mb: "10px",
13301 fontSize: "14px",
13302 lineHeight: "1.5"
13303 },
13304 "& pre": { position: "relative" },
13305 "& textarea": {
13306 fontSize: "13px",
13307 lineHeight: "1.7"
13308 }
13309 };
13310 });
13311 var FormAnimation = function FormAnimation(_ref) {
13312 var onClose = _ref.onClose;
13313 var getControlValue = _ref.getControlValue;
13314 var setControlValue = _ref.setControlValue;
13315 var additionalOptions = _ref.additionalOptions;
13316 var credits = _ref.credits;
13317 var children = _ref.children;
13318 var _useAnimationPrompt = useAnimationPrompt(additionalOptions.animationType, additionalOptions.widgetType, credits);
13319 var data = _useAnimationPrompt.data;
13320 var isLoading = _useAnimationPrompt.isLoading;
13321 var error = _useAnimationPrompt.error;
13322 var reset = _useAnimationPrompt.reset;
13323 var send = _useAnimationPrompt.send;
13324 var sendUsageData = _useAnimationPrompt.sendUsageData;
13325 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
13326 var prompt = _useState2[0];
13327 var setPrompt = _useState2[1];
13328 var setGenerate = useRequestIds().setGenerate;
13329 var _useState4 = _slicedToArray((0, react.useState)(""), 2);
13330 var animationSummary = _useState4[0];
13331 var setAnimationSummary = _useState4[1];
13332 var _useState6 = _slicedToArray((0, react.useState)(), 2);
13333 var prevControlValue = _useState6[0];
13334 var setPrevControlValue = _useState6[1];
13335 var lastRun = (0, react.useRef)(function() {});
13336 var autocompleteItems = "hover" === additionalOptions.animationType ? hoverEffectAutocomplete : motionEffectAutocomplete;
13337 var showSuggestions = !prompt;
13338 var handleSubmit = /*#__PURE__*/ function() {
13339 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(event) {
13340 return import_regenerator$2.default.wrap(function(_context) {
13341 while (1) switch (_context.prev = _context.next) {
13342 case 0:
13343 event.preventDefault();
13344 setGenerate();
13345 lastRun.current = function() {
13346 return send({ prompt });
13347 };
13348 _context.next = 1;
13349 return lastRun.current();
13350 case 1:
13351 case "end": return _context.stop();
13352 }
13353 }, _callee);
13354 }));
13355 return function handleSubmit(_x) {
13356 return _ref2.apply(this, arguments);
13357 };
13358 }();
13359 (0, react.useEffect)(function() {
13360 if (data.result) showPreview(data.result);
13361 }, [data]);
13362 (0, react.useEffect)(function() {
13363 return function() {
13364 restorePrevSettings();
13365 };
13366 }, []);
13367 var showPreview = function showPreview(result) {
13368 var summary = Object.keys(result).filter(function(key) {
13369 return result[key].label;
13370 }).map(function(key) {
13371 var item = result[key];
13372 var tabs = "&nbsp;".repeat(item.tabs);
13373 var bulletIcon = item.tabs > 0 ? "&#8226; " : "";
13374 var label = item.isParent ? "<br/><b>".concat(item.label, ":</b>") : "".concat(bulletIcon, " ").concat(item.label);
13375 return "".concat(tabs).concat(label);
13376 }).join("<br/>");
13377 var title = "".concat((0, _wordpress_i18n.__)("Here’s a breakdown of what was done for creating the animation", "elementor"));
13378 setAnimationSummary("<b>".concat(title, ":</b><br/>").concat(summary));
13379 setPrevControlValue(getControlValue());
13380 elementor.documents.getCurrent().history.setActive(false);
13381 setControlValue(getValidElementor(result));
13382 };
13383 var restorePrevSettings = function restorePrevSettings() {
13384 setControlValue(prevControlValue);
13385 elementor.documents.getCurrent().history.setActive(true);
13386 };
13387 var getValidElementor = function getValidElementor(result) {
13388 return Object.entries(result).filter(function(_ref3) {
13389 return _slicedToArray(_ref3, 2)[1].hasOwnProperty("value");
13390 }).reduce(function(previousValue, _ref5) {
13391 var _ref6 = _slicedToArray(_ref5, 2);
13392 var key = _ref6[0];
13393 previousValue[key] = _ref6[1].value;
13394 return previousValue;
13395 }, {});
13396 };
13397 var applyPrompt = function applyPrompt(result) {
13398 sendUsageData();
13399 restorePrevSettings();
13400 setControlValue(getValidElementor(result));
13401 onClose();
13402 };
13403 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
13404 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
13405 error,
13406 onRetry: lastRun.current,
13407 sx: { mb: 2.5 }
13408 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13409 component: "form",
13410 onSubmit: handleSubmit
13411 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
13412 placeholder: (0, _wordpress_i18n.__)("Describe the animation you want to create...", "elementor"),
13413 name: "prompt",
13414 value: prompt,
13415 color: "secondary",
13416 onChange: function onChange(event) {
13417 return setPrompt(event.target.value);
13418 }
13419 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
13420 suggestions: autocompleteItems,
13421 onSelect: setPrompt
13422 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13423 direction: "row",
13424 alignItems: "center",
13425 sx: {
13426 py: 1.5,
13427 mt: 4
13428 }
13429 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13430 direction: "row",
13431 justifyContent: "flex-end",
13432 flexGrow: 1
13433 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate Animation", "elementor"))))), data.result && animationSummary && /*#__PURE__*/ react.default.createElement(CodeDisplayWrapper$1, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
13434 backgroundColor: "rgba(0, 0, 0, 0.06); ",
13435 padding: "1em",
13436 borderRadius: "4px",
13437 width: "100%",
13438 height: "260px",
13439 overflowX: "auto"
13440 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
13441 variant: "body1",
13442 dangerouslySetInnerHTML: { __html: animationSummary }
13443 })), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-animation-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13444 direction: "row",
13445 alignItems: "center",
13446 sx: { mt: 4 }
13447 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
13448 direction: "row",
13449 gap: 1,
13450 justifyContent: "flex-end",
13451 flexGrow: 1
13452 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13453 size: "small",
13454 color: "secondary",
13455 variant: "text",
13456 onClick: function onClick() {
13457 restorePrevSettings();
13458 reset();
13459 }
13460 }, (0, _wordpress_i18n.__)("New prompt", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13461 size: "small",
13462 variant: "contained",
13463 color: "primary",
13464 onClick: function onClick() {
13465 return applyPrompt(data.result);
13466 }
13467 }, (0, _wordpress_i18n.__)("Use animation", "elementor"))))));
13468 };
13469 FormAnimation.propTypes = {
13470 onClose: import_prop_types$7.default.func.isRequired,
13471 getControlValue: import_prop_types$7.default.func.isRequired,
13472 setControlValue: import_prop_types$7.default.func.isRequired,
13473 additionalOptions: import_prop_types$7.default.shape({
13474 animationType: import_prop_types$7.default.string,
13475 widgetType: import_prop_types$7.default.string
13476 }),
13477 credits: import_prop_types$7.default.number,
13478 children: import_prop_types$7.default.node
13479 };
13480
13481 //#endregion
13482 //#region \0vite/preload-helper.js
13483 var scriptRel, assetsURL, seen, __vitePreload;
13484 var init_preload_helper = __esmMin((() => {
13485 scriptRel = "modulepreload";
13486 assetsURL = function(dep) {
13487 return "/" + dep;
13488 };
13489 seen = {};
13490 __vitePreload = function preload(baseModule, deps, importerUrl) {
13491 let promise = Promise.resolve();
13492 if (false && deps && deps.length > 0) {
13493 const links = document.getElementsByTagName("link");
13494 const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
13495 const cspNonce = (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta === null || cspNonceMeta === void 0 ? void 0 : cspNonceMeta.getAttribute("nonce"));
13496 function allSettled(promises) {
13497 return Promise.all(promises.map((p) => Promise.resolve(p).then((value) => ({
13498 status: "fulfilled",
13499 value
13500 }), (reason) => ({
13501 status: "rejected",
13502 reason
13503 }))));
13504 }
13505 function importMetaResolve(specifier) {
13506 if ({}.resolve) return {}.resolve(specifier);
13507 return new URL(
13508 specifier,
13509 /** #__KEEP__ */
13510 {}.url
13511 ).href;
13512 }
13513 promise = allSettled(deps.map((dep) => {
13514 dep = assetsURL(dep, importerUrl);
13515 dep = importMetaResolve(dep);
13516 if (dep in seen) return;
13517 seen[dep] = true;
13518 const isCss = dep.endsWith(".css");
13519 for (let i = links.length - 1; i >= 0; i--) {
13520 const link = links[i];
13521 if (link.href === dep && (!isCss || link.rel === "stylesheet")) return;
13522 }
13523 const link = document.createElement("link");
13524 link.rel = isCss ? "stylesheet" : scriptRel;
13525 if (!isCss) link.as = "script";
13526 link.crossOrigin = "";
13527 link.href = dep;
13528 if (cspNonce) link.setAttribute("nonce", cspNonce);
13529 document.head.appendChild(link);
13530 if (isCss) return new Promise((res, rej) => {
13531 link.addEventListener("load", res);
13532 link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
13533 });
13534 }));
13535 }
13536 function handlePreloadError(err) {
13537 const e = new Event("vite:preloadError", { cancelable: true });
13538 e.payload = err;
13539 window.dispatchEvent(e);
13540 if (!e.defaultPrevented) throw err;
13541 }
13542 return promise.then((res) => {
13543 for (const item of res || []) {
13544 if (item.status !== "rejected") continue;
13545 handlePreloadError(item.reason);
13546 }
13547 return baseModule().catch(handlePreloadError);
13548 });
13549 };
13550 }));
13551
13552 //#endregion
13553 //#region modules/ai/assets/js/editor/pages/form-code/code-block.js
13554 var import_prop_types$2, _excluded$5, CodeBlock;
13555 var init_code_block = __esmMin((() => {
13556 init_extends();
13557 init_objectWithoutProperties$1();
13558 import_prop_types$2 = /* @__PURE__ */ __toESM(require_prop_types());
13559 init_textarea();
13560 _excluded$5 = [
13561 "node",
13562 "inline",
13563 "children",
13564 "defaultValue",
13565 "onInsert"
13566 ];
13567 CodeBlock = function CodeBlock(_ref) {
13568 _ref.node;
13569 var inline = _ref.inline;
13570 var children = _ref.children;
13571 var defaultValue = _ref.defaultValue;
13572 var onInsert = _ref.onInsert;
13573 var props = _objectWithoutProperties$1(_ref, _excluded$5);
13574 var codeBlockInput = (0, react.useRef)(null);
13575 if (inline) return /*#__PURE__*/ react.default.createElement("code", props);
13576 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
13577 sx: { position: "relative" },
13578 dir: "ltr"
13579 }, /*#__PURE__*/ react.default.createElement(Textarea, _extends$1({
13580 fullWidth: true,
13581 ref: codeBlockInput,
13582 defaultValue: children[0],
13583 sx: { mb: 1 },
13584 helperText: (0, _wordpress_i18n.__)("Code generated by AI may be inaccurate.", "elementor")
13585 }, props)), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
13586 size: "small",
13587 variant: "contained",
13588 onClick: function onClick() {
13589 return onInsert(defaultValue + "\n" + codeBlockInput.current.value);
13590 },
13591 sx: {
13592 position: "absolute",
13593 right: "11px /* @noflip */",
13594 bottom: "44px"
13595 }
13596 }, (0, _wordpress_i18n.__)("Insert", "elementor")));
13597 };
13598 CodeBlock.propTypes = {
13599 node: import_prop_types$2.default.object,
13600 inline: import_prop_types$2.default.bool,
13601 children: import_prop_types$2.default.arrayOf(import_prop_types$2.default.node).isRequired,
13602 defaultValue: import_prop_types$2.default.string,
13603 onInsert: import_prop_types$2.default.func.isRequired
13604 };
13605 }));
13606
13607 //#endregion
13608 //#region modules/ai/assets/js/editor/hooks/use-code-prompt.js
13609 function ownKeys$6(e, r) {
13610 var t = Object.keys(e);
13611 if (Object.getOwnPropertySymbols) {
13612 var o = Object.getOwnPropertySymbols(e);
13613 r && (o = o.filter(function(r) {
13614 return Object.getOwnPropertyDescriptor(e, r).enumerable;
13615 })), t.push.apply(t, o);
13616 }
13617 return t;
13618 }
13619 function _objectSpread$6(e) {
13620 for (var r = 1; r < arguments.length; r++) {
13621 var t = null != arguments[r] ? arguments[r] : {};
13622 r % 2 ? ownKeys$6(Object(t), !0).forEach(function(r) {
13623 _defineProperty$1(e, r, t[r]);
13624 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function(r) {
13625 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
13626 });
13627 }
13628 return e;
13629 }
13630 var import_regenerator$1, getCodeResult, useCodePrompt;
13631 var init_use_code_prompt = __esmMin((() => {
13632 init_defineProperty$1();
13633 init_asyncToGenerator();
13634 import_regenerator$1 = /* @__PURE__ */ __toESM(require_regenerator());
13635 init_api();
13636 init_use_prompt();
13637 __name(ownKeys$6, "ownKeys");
13638 __name(_objectSpread$6, "_objectSpread");
13639 getCodeResult = /*#__PURE__*/ function() {
13640 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$1.default.mark(function _callee(payload, _ref) {
13641 var codeLanguage;
13642 var htmlMarkup;
13643 var elementId;
13644 return import_regenerator$1.default.wrap(function(_context) {
13645 while (1) switch (_context.prev = _context.next) {
13646 case 0:
13647 codeLanguage = _ref.codeLanguage, htmlMarkup = _ref.htmlMarkup, elementId = _ref.elementId;
13648 if (!("css" === codeLanguage)) {
13649 _context.next = 1;
13650 break;
13651 }
13652 return _context.abrupt("return", getCustomCSS(_objectSpread$6(_objectSpread$6({}, payload), {}, {
13653 html_markup: htmlMarkup,
13654 element_id: elementId
13655 })));
13656 case 1: return _context.abrupt("return", getCustomCode(_objectSpread$6(_objectSpread$6({}, payload), {}, { language: codeLanguage })));
13657 case 2:
13658 case "end": return _context.stop();
13659 }
13660 }, _callee);
13661 }));
13662 return function getCodeResult(_x, _x2) {
13663 return _ref2.apply(this, arguments);
13664 };
13665 }();
13666 useCodePrompt = function useCodePrompt(_ref3) {
13667 var codeLanguage = _ref3.codeLanguage;
13668 var htmlMarkup = _ref3.htmlMarkup;
13669 var elementId = _ref3.elementId;
13670 var credits = _ref3.initialCredits;
13671 return usePrompt(function(payload) {
13672 return getCodeResult(payload, {
13673 codeLanguage,
13674 htmlMarkup,
13675 elementId
13676 });
13677 }, { credits });
13678 };
13679 }));
13680
13681 //#endregion
13682 //#region modules/ai/assets/js/editor/pages/form-code/splitTextResult.js
13683 function splitText(inputText) {
13684 if (!inputText) return {};
13685 var codeMatch = inputText.match(/```([\s\S]*?)```/);
13686 var code = codeMatch ? "```".concat(codeMatch[1], "```").trim() : "";
13687 var detailsMatch = inputText.match(/```[\s\S]*?```([\s\S]*)/);
13688 return {
13689 code,
13690 details: detailsMatch === null || detailsMatch === void 0 ? void 0 : detailsMatch[1].trim()
13691 };
13692 }
13693 var init_splitTextResult = __esmMin((() => {}));
13694
13695 //#endregion
13696 //#region node_modules/react-markdown/lib/uri-transformer.js
13697 /**
13698 * @param {string} uri
13699 * @returns {string}
13700 */
13701 function uriTransformer(uri) {
13702 const url = (uri || "").trim();
13703 const first = url.charAt(0);
13704 if (first === "#" || first === "/") return url;
13705 const colon = url.indexOf(":");
13706 if (colon === -1) return url;
13707 let index = -1;
13708 while (++index < protocols.length) {
13709 const protocol = protocols[index];
13710 if (colon === protocol.length && url.slice(0, protocol.length).toLowerCase() === protocol) return url;
13711 }
13712 index = url.indexOf("?");
13713 if (index !== -1 && colon > index) return url;
13714 index = url.indexOf("#");
13715 if (index !== -1 && colon > index) return url;
13716 return "javascript:void(0)";
13717 }
13718 var protocols;
13719 var init_uri_transformer = __esmMin((() => {
13720 protocols = [
13721 "http",
13722 "https",
13723 "mailto",
13724 "tel"
13725 ];
13726 }));
13727
13728 //#endregion
13729 //#region node_modules/vfile/node_modules/is-buffer/index.js
13730 var require_is_buffer$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13731 /*!
13732 * Determine if an object is a Buffer
13733 *
13734 * @author Feross Aboukhadijeh <https://feross.org>
13735 * @license MIT
13736 */
13737 module.exports = function isBuffer(obj) {
13738 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
13739 };
13740 }));
13741
13742 //#endregion
13743 //#region node_modules/unist-util-stringify-position/lib/index.js
13744 /**
13745 * @typedef {import('unist').Node} Node
13746 * @typedef {import('unist').Point} Point
13747 * @typedef {import('unist').Position} Position
13748 */
13749 /**
13750 * @typedef NodeLike
13751 * @property {string} type
13752 * @property {PositionLike | null | undefined} [position]
13753 *
13754 * @typedef PositionLike
13755 * @property {PointLike | null | undefined} [start]
13756 * @property {PointLike | null | undefined} [end]
13757 *
13758 * @typedef PointLike
13759 * @property {number | null | undefined} [line]
13760 * @property {number | null | undefined} [column]
13761 * @property {number | null | undefined} [offset]
13762 */
13763 /**
13764 * Serialize the positional info of a point, position (start and end points),
13765 * or node.
13766 *
13767 * @param {Node | NodeLike | Position | PositionLike | Point | PointLike | null | undefined} [value]
13768 * Node, position, or point.
13769 * @returns {string}
13770 * Pretty printed positional info of a node (`string`).
13771 *
13772 * In the format of a range `ls:cs-le:ce` (when given `node` or `position`)
13773 * or a point `l:c` (when given `point`), where `l` stands for line, `c` for
13774 * column, `s` for `start`, and `e` for end.
13775 * An empty string (`''`) is returned if the given value is neither `node`,
13776 * `position`, nor `point`.
13777 */
13778 function stringifyPosition(value) {
13779 if (!value || typeof value !== "object") return "";
13780 if ("position" in value || "type" in value) return position$1(value.position);
13781 if ("start" in value || "end" in value) return position$1(value);
13782 if ("line" in value || "column" in value) return point$2(value);
13783 return "";
13784 }
13785 /**
13786 * @param {Point | PointLike | null | undefined} point
13787 * @returns {string}
13788 */
13789 function point$2(point) {
13790 return index(point && point.line) + ":" + index(point && point.column);
13791 }
13792 /**
13793 * @param {Position | PositionLike | null | undefined} pos
13794 * @returns {string}
13795 */
13796 function position$1(pos) {
13797 return point$2(pos && pos.start) + "-" + point$2(pos && pos.end);
13798 }
13799 /**
13800 * @param {number | null | undefined} value
13801 * @returns {number}
13802 */
13803 function index(value) {
13804 return value && typeof value === "number" ? value : 1;
13805 }
13806 var init_lib$15 = __esmMin((() => {
13807 __name(point$2, "point");
13808 __name(position$1, "position");
13809 }));
13810
13811 //#endregion
13812 //#region node_modules/unist-util-stringify-position/index.js
13813 var init_unist_util_stringify_position = __esmMin((() => {
13814 init_lib$15();
13815 }));
13816
13817 //#endregion
13818 //#region node_modules/vfile-message/lib/index.js
13819 var VFileMessage;
13820 var init_lib$14 = __esmMin((() => {
13821 init_unist_util_stringify_position();
13822 VFileMessage = class extends Error {
13823 /**
13824 * Create a message for `reason` at `place` from `origin`.
13825 *
13826 * When an error is passed in as `reason`, the `stack` is copied.
13827 *
13828 * @param {string | Error | VFileMessage} reason
13829 * Reason for message, uses the stack and message of the error if given.
13830 *
13831 * > 👉 **Note**: you should use markdown.
13832 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
13833 * Place in file where the message occurred.
13834 * @param {string | null | undefined} [origin]
13835 * Place in code where the message originates (example:
13836 * `'my-package:my-rule'` or `'my-rule'`).
13837 * @returns
13838 * Instance of `VFileMessage`.
13839 */
13840 constructor(reason, place, origin) {
13841 /** @type {[string | null, string | null]} */
13842 const parts = [null, null];
13843 /** @type {Position} */
13844 let position = {
13845 start: {
13846 line: null,
13847 column: null
13848 },
13849 end: {
13850 line: null,
13851 column: null
13852 }
13853 };
13854 super();
13855 if (typeof place === "string") {
13856 origin = place;
13857 place = void 0;
13858 }
13859 if (typeof origin === "string") {
13860 const index = origin.indexOf(":");
13861 if (index === -1) parts[1] = origin;
13862 else {
13863 parts[0] = origin.slice(0, index);
13864 parts[1] = origin.slice(index + 1);
13865 }
13866 }
13867 if (place) {
13868 if ("type" in place || "position" in place) {
13869 if (place.position) position = place.position;
13870 } else if ("start" in place || "end" in place) position = place;
13871 else if ("line" in place || "column" in place) position.start = place;
13872 }
13873 /**
13874 * Serialized positional info of error.
13875 *
13876 * On normal errors, this would be something like `ParseError`, buit in
13877 * `VFile` messages we use this space to show where an error happened.
13878 */
13879 this.name = stringifyPosition(place) || "1:1";
13880 /**
13881 * Reason for message.
13882 *
13883 * @type {string}
13884 */
13885 this.message = typeof reason === "object" ? reason.message : reason;
13886 /**
13887 * Stack of message.
13888 *
13889 * This is used by normal errors to show where something happened in
13890 * programming code, irrelevant for `VFile` messages,
13891 *
13892 * @type {string}
13893 */
13894 this.stack = "";
13895 if (typeof reason === "object" && reason.stack) this.stack = reason.stack;
13896 /**
13897 * Reason for message.
13898 *
13899 * > 👉 **Note**: you should use markdown.
13900 *
13901 * @type {string}
13902 */
13903 this.reason = this.message;
13904 /**
13905 * State of problem.
13906 *
13907 * * `true` — marks associated file as no longer processable (error)
13908 * * `false` — necessitates a (potential) change (warning)
13909 * * `null | undefined` — for things that might not need changing (info)
13910 *
13911 * @type {boolean | null | undefined}
13912 */
13913 this.fatal;
13914 /**
13915 * Starting line of error.
13916 *
13917 * @type {number | null}
13918 */
13919 this.line = position.start.line;
13920 /**
13921 * Starting column of error.
13922 *
13923 * @type {number | null}
13924 */
13925 this.column = position.start.column;
13926 /**
13927 * Full unist position.
13928 *
13929 * @type {Position | null}
13930 */
13931 this.position = position;
13932 /**
13933 * Namespace of message (example: `'my-package'`).
13934 *
13935 * @type {string | null}
13936 */
13937 this.source = parts[0];
13938 /**
13939 * Category of message (example: `'my-rule'`).
13940 *
13941 * @type {string | null}
13942 */
13943 this.ruleId = parts[1];
13944 /**
13945 * Path of a file (used throughout the `VFile` ecosystem).
13946 *
13947 * @type {string | null}
13948 */
13949 this.file;
13950 /**
13951 * Specify the source value that’s being reported, which is deemed
13952 * incorrect.
13953 *
13954 * @type {string | null}
13955 */
13956 this.actual;
13957 /**
13958 * Suggest acceptable values that can be used instead of `actual`.
13959 *
13960 * @type {Array<string> | null}
13961 */
13962 this.expected;
13963 /**
13964 * Link to docs for the message.
13965 *
13966 * > 👉 **Note**: this must be an absolute URL that can be passed as `x`
13967 * > to `new URL(x)`.
13968 *
13969 * @type {string | null}
13970 */
13971 this.url;
13972 /**
13973 * Long form description of the message (you should use markdown).
13974 *
13975 * @type {string | null}
13976 */
13977 this.note;
13978 }
13979 };
13980 VFileMessage.prototype.file = "";
13981 VFileMessage.prototype.name = "";
13982 VFileMessage.prototype.reason = "";
13983 VFileMessage.prototype.message = "";
13984 VFileMessage.prototype.stack = "";
13985 VFileMessage.prototype.fatal = null;
13986 VFileMessage.prototype.column = null;
13987 VFileMessage.prototype.line = null;
13988 VFileMessage.prototype.source = null;
13989 VFileMessage.prototype.ruleId = null;
13990 VFileMessage.prototype.position = null;
13991 }));
13992
13993 //#endregion
13994 //#region node_modules/vfile-message/index.js
13995 var init_vfile_message = __esmMin((() => {
13996 init_lib$14();
13997 }));
13998
13999 //#endregion
14000 //#region node_modules/vfile/lib/minpath.browser.js
14001 /**
14002 * Get the basename from a path.
14003 *
14004 * @param {string} path
14005 * File path.
14006 * @param {string | undefined} [ext]
14007 * Extension to strip.
14008 * @returns {string}
14009 * Stem or basename.
14010 */
14011 function basename(path, ext) {
14012 if (ext !== void 0 && typeof ext !== "string") throw new TypeError("\"ext\" argument must be a string");
14013 assertPath$1(path);
14014 let start = 0;
14015 let end = -1;
14016 let index = path.length;
14017 /** @type {boolean | undefined} */
14018 let seenNonSlash;
14019 if (ext === void 0 || ext.length === 0 || ext.length > path.length) {
14020 while (index--) if (path.charCodeAt(index) === 47) {
14021 if (seenNonSlash) {
14022 start = index + 1;
14023 break;
14024 }
14025 } else if (end < 0) {
14026 seenNonSlash = true;
14027 end = index + 1;
14028 }
14029 return end < 0 ? "" : path.slice(start, end);
14030 }
14031 if (ext === path) return "";
14032 let firstNonSlashEnd = -1;
14033 let extIndex = ext.length - 1;
14034 while (index--) if (path.charCodeAt(index) === 47) {
14035 if (seenNonSlash) {
14036 start = index + 1;
14037 break;
14038 }
14039 } else {
14040 if (firstNonSlashEnd < 0) {
14041 seenNonSlash = true;
14042 firstNonSlashEnd = index + 1;
14043 }
14044 if (extIndex > -1) if (path.charCodeAt(index) === ext.charCodeAt(extIndex--)) {
14045 if (extIndex < 0) end = index;
14046 } else {
14047 extIndex = -1;
14048 end = firstNonSlashEnd;
14049 }
14050 }
14051 if (start === end) end = firstNonSlashEnd;
14052 else if (end < 0) end = path.length;
14053 return path.slice(start, end);
14054 }
14055 /**
14056 * Get the dirname from a path.
14057 *
14058 * @param {string} path
14059 * File path.
14060 * @returns {string}
14061 * File path.
14062 */
14063 function dirname(path) {
14064 assertPath$1(path);
14065 if (path.length === 0) return ".";
14066 let end = -1;
14067 let index = path.length;
14068 /** @type {boolean | undefined} */
14069 let unmatchedSlash;
14070 while (--index) if (path.charCodeAt(index) === 47) {
14071 if (unmatchedSlash) {
14072 end = index;
14073 break;
14074 }
14075 } else if (!unmatchedSlash) unmatchedSlash = true;
14076 return end < 0 ? path.charCodeAt(0) === 47 ? "/" : "." : end === 1 && path.charCodeAt(0) === 47 ? "//" : path.slice(0, end);
14077 }
14078 /**
14079 * Get an extname from a path.
14080 *
14081 * @param {string} path
14082 * File path.
14083 * @returns {string}
14084 * Extname.
14085 */
14086 function extname(path) {
14087 assertPath$1(path);
14088 let index = path.length;
14089 let end = -1;
14090 let startPart = 0;
14091 let startDot = -1;
14092 let preDotState = 0;
14093 /** @type {boolean | undefined} */
14094 let unmatchedSlash;
14095 while (index--) {
14096 const code = path.charCodeAt(index);
14097 if (code === 47) {
14098 if (unmatchedSlash) {
14099 startPart = index + 1;
14100 break;
14101 }
14102 continue;
14103 }
14104 if (end < 0) {
14105 unmatchedSlash = true;
14106 end = index + 1;
14107 }
14108 if (code === 46) {
14109 if (startDot < 0) startDot = index;
14110 else if (preDotState !== 1) preDotState = 1;
14111 } else if (startDot > -1) preDotState = -1;
14112 }
14113 if (startDot < 0 || end < 0 || preDotState === 0 || preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) return "";
14114 return path.slice(startDot, end);
14115 }
14116 /**
14117 * Join segments from a path.
14118 *
14119 * @param {Array<string>} segments
14120 * Path segments.
14121 * @returns {string}
14122 * File path.
14123 */
14124 function join(...segments) {
14125 let index = -1;
14126 /** @type {string | undefined} */
14127 let joined;
14128 while (++index < segments.length) {
14129 assertPath$1(segments[index]);
14130 if (segments[index]) joined = joined === void 0 ? segments[index] : joined + "/" + segments[index];
14131 }
14132 return joined === void 0 ? "." : normalize$1(joined);
14133 }
14134 /**
14135 * Normalize a basic file path.
14136 *
14137 * @param {string} path
14138 * File path.
14139 * @returns {string}
14140 * File path.
14141 */
14142 function normalize$1(path) {
14143 assertPath$1(path);
14144 const absolute = path.charCodeAt(0) === 47;
14145 let value = normalizeString(path, !absolute);
14146 if (value.length === 0 && !absolute) value = ".";
14147 if (value.length > 0 && path.charCodeAt(path.length - 1) === 47) value += "/";
14148 return absolute ? "/" + value : value;
14149 }
14150 /**
14151 * Resolve `.` and `..` elements in a path with directory names.
14152 *
14153 * @param {string} path
14154 * File path.
14155 * @param {boolean} allowAboveRoot
14156 * Whether `..` can move above root.
14157 * @returns {string}
14158 * File path.
14159 */
14160 function normalizeString(path, allowAboveRoot) {
14161 let result = "";
14162 let lastSegmentLength = 0;
14163 let lastSlash = -1;
14164 let dots = 0;
14165 let index = -1;
14166 /** @type {number | undefined} */
14167 let code;
14168 /** @type {number} */
14169 let lastSlashIndex;
14170 while (++index <= path.length) {
14171 if (index < path.length) code = path.charCodeAt(index);
14172 else if (code === 47) break;
14173 else code = 47;
14174 if (code === 47) {
14175 if (lastSlash === index - 1 || dots === 1) {} else if (lastSlash !== index - 1 && dots === 2) {
14176 if (result.length < 2 || lastSegmentLength !== 2 || result.charCodeAt(result.length - 1) !== 46 || result.charCodeAt(result.length - 2) !== 46) {
14177 if (result.length > 2) {
14178 lastSlashIndex = result.lastIndexOf("/");
14179 if (lastSlashIndex !== result.length - 1) {
14180 if (lastSlashIndex < 0) {
14181 result = "";
14182 lastSegmentLength = 0;
14183 } else {
14184 result = result.slice(0, lastSlashIndex);
14185 lastSegmentLength = result.length - 1 - result.lastIndexOf("/");
14186 }
14187 lastSlash = index;
14188 dots = 0;
14189 continue;
14190 }
14191 } else if (result.length > 0) {
14192 result = "";
14193 lastSegmentLength = 0;
14194 lastSlash = index;
14195 dots = 0;
14196 continue;
14197 }
14198 }
14199 if (allowAboveRoot) {
14200 result = result.length > 0 ? result + "/.." : "..";
14201 lastSegmentLength = 2;
14202 }
14203 } else {
14204 if (result.length > 0) result += "/" + path.slice(lastSlash + 1, index);
14205 else result = path.slice(lastSlash + 1, index);
14206 lastSegmentLength = index - lastSlash - 1;
14207 }
14208 lastSlash = index;
14209 dots = 0;
14210 } else if (code === 46 && dots > -1) dots++;
14211 else dots = -1;
14212 }
14213 return result;
14214 }
14215 /**
14216 * Make sure `path` is a string.
14217 *
14218 * @param {string} path
14219 * File path.
14220 * @returns {asserts path is string}
14221 * Nothing.
14222 */
14223 function assertPath$1(path) {
14224 if (typeof path !== "string") throw new TypeError("Path must be a string. Received " + JSON.stringify(path));
14225 }
14226 var path;
14227 var init_minpath_browser = __esmMin((() => {
14228 path = {
14229 basename,
14230 dirname,
14231 extname,
14232 join,
14233 sep: "/"
14234 };
14235 __name(normalize$1, "normalize");
14236 __name(assertPath$1, "assertPath");
14237 }));
14238
14239 //#endregion
14240 //#region node_modules/vfile/lib/minproc.browser.js
14241 function cwd() {
14242 return "/";
14243 }
14244 var proc;
14245 var init_minproc_browser = __esmMin((() => {
14246 proc = { cwd };
14247 }));
14248
14249 //#endregion
14250 //#region node_modules/vfile/lib/minurl.shared.js
14251 /**
14252 * @typedef URL
14253 * @property {string} hash
14254 * @property {string} host
14255 * @property {string} hostname
14256 * @property {string} href
14257 * @property {string} origin
14258 * @property {string} password
14259 * @property {string} pathname
14260 * @property {string} port
14261 * @property {string} protocol
14262 * @property {string} search
14263 * @property {any} searchParams
14264 * @property {string} username
14265 * @property {() => string} toString
14266 * @property {() => string} toJSON
14267 */
14268 /**
14269 * Check if `fileUrlOrPath` looks like a URL.
14270 *
14271 * @param {unknown} fileUrlOrPath
14272 * File path or URL.
14273 * @returns {fileUrlOrPath is URL}
14274 * Whether it’s a URL.
14275 */
14276 function isUrl(fileUrlOrPath) {
14277 return fileUrlOrPath !== null && typeof fileUrlOrPath === "object" && fileUrlOrPath.href && fileUrlOrPath.origin;
14278 }
14279 var init_minurl_shared = __esmMin((() => {}));
14280
14281 //#endregion
14282 //#region node_modules/vfile/lib/minurl.browser.js
14283 /**
14284 * @param {string | URL} path
14285 * File URL.
14286 * @returns {string}
14287 * File URL.
14288 */
14289 function urlToPath(path) {
14290 if (typeof path === "string") path = new URL(path);
14291 else if (!isUrl(path)) {
14292 /** @type {NodeJS.ErrnoException} */
14293 const error = /* @__PURE__ */ new TypeError("The \"path\" argument must be of type string or an instance of URL. Received `" + path + "`");
14294 error.code = "ERR_INVALID_ARG_TYPE";
14295 throw error;
14296 }
14297 if (path.protocol !== "file:") {
14298 /** @type {NodeJS.ErrnoException} */
14299 const error = /* @__PURE__ */ new TypeError("The URL must be of scheme file");
14300 error.code = "ERR_INVALID_URL_SCHEME";
14301 throw error;
14302 }
14303 return getPathFromURLPosix(path);
14304 }
14305 /**
14306 * Get a path from a POSIX URL.
14307 *
14308 * @param {URL} url
14309 * URL.
14310 * @returns {string}
14311 * File path.
14312 */
14313 function getPathFromURLPosix(url) {
14314 if (url.hostname !== "") {
14315 /** @type {NodeJS.ErrnoException} */
14316 const error = /* @__PURE__ */ new TypeError("File URL host must be \"localhost\" or empty on darwin");
14317 error.code = "ERR_INVALID_FILE_URL_HOST";
14318 throw error;
14319 }
14320 const pathname = url.pathname;
14321 let index = -1;
14322 while (++index < pathname.length) if (pathname.charCodeAt(index) === 37 && pathname.charCodeAt(index + 1) === 50) {
14323 const third = pathname.charCodeAt(index + 2);
14324 if (third === 70 || third === 102) {
14325 /** @type {NodeJS.ErrnoException} */
14326 const error = /* @__PURE__ */ new TypeError("File URL path must not include encoded / characters");
14327 error.code = "ERR_INVALID_FILE_URL_PATH";
14328 throw error;
14329 }
14330 }
14331 return decodeURIComponent(pathname);
14332 }
14333 var init_minurl_browser = __esmMin((() => {
14334 init_minurl_shared();
14335 }));
14336
14337 //#endregion
14338 //#region node_modules/vfile/lib/index.js
14339 /**
14340 * Assert that `part` is not a path (as in, does not contain `path.sep`).
14341 *
14342 * @param {string | null | undefined} part
14343 * File path part.
14344 * @param {string} name
14345 * Part name.
14346 * @returns {void}
14347 * Nothing.
14348 */
14349 function assertPart(part, name) {
14350 if (part && part.includes(path.sep)) throw new Error("`" + name + "` cannot be a path: did not expect `" + path.sep + "`");
14351 }
14352 /**
14353 * Assert that `part` is not empty.
14354 *
14355 * @param {string | undefined} part
14356 * Thing.
14357 * @param {string} name
14358 * Part name.
14359 * @returns {asserts part is string}
14360 * Nothing.
14361 */
14362 function assertNonEmpty(part, name) {
14363 if (!part) throw new Error("`" + name + "` cannot be empty");
14364 }
14365 /**
14366 * Assert `path` exists.
14367 *
14368 * @param {string | undefined} path
14369 * Path.
14370 * @param {string} name
14371 * Dependency name.
14372 * @returns {asserts path is string}
14373 * Nothing.
14374 */
14375 function assertPath(path, name) {
14376 if (!path) throw new Error("Setting `" + name + "` requires `path` to be set too");
14377 }
14378 /**
14379 * Assert `value` is a buffer.
14380 *
14381 * @param {unknown} value
14382 * thing.
14383 * @returns {value is Buffer}
14384 * Whether `value` is a Node.js buffer.
14385 */
14386 function buffer(value) {
14387 return (0, import_is_buffer$1.default)(value);
14388 }
14389 var import_is_buffer$1, order, VFile;
14390 var init_lib$13 = __esmMin((() => {
14391 import_is_buffer$1 = /* @__PURE__ */ __toESM(require_is_buffer$1(), 1);
14392 init_vfile_message();
14393 init_minpath_browser();
14394 init_minproc_browser();
14395 init_minurl_browser();
14396 order = [
14397 "history",
14398 "path",
14399 "basename",
14400 "stem",
14401 "extname",
14402 "dirname"
14403 ];
14404 VFile = class {
14405 /**
14406 * Create a new virtual file.
14407 *
14408 * `options` is treated as:
14409 *
14410 * * `string` or `Buffer` — `{value: options}`
14411 * * `URL` — `{path: options}`
14412 * * `VFile` — shallow copies its data over to the new file
14413 * * `object` — all fields are shallow copied over to the new file
14414 *
14415 * Path related fields are set in the following order (least specific to
14416 * most specific): `history`, `path`, `basename`, `stem`, `extname`,
14417 * `dirname`.
14418 *
14419 * You cannot set `dirname` or `extname` without setting either `history`,
14420 * `path`, `basename`, or `stem` too.
14421 *
14422 * @param {Compatible | null | undefined} [value]
14423 * File value.
14424 * @returns
14425 * New instance.
14426 */
14427 constructor(value) {
14428 /** @type {Options | VFile} */
14429 let options;
14430 if (!value) options = {};
14431 else if (typeof value === "string" || buffer(value)) options = { value };
14432 else if (isUrl(value)) options = { path: value };
14433 else options = value;
14434 /**
14435 * Place to store custom information (default: `{}`).
14436 *
14437 * It’s OK to store custom data directly on the file but moving it to
14438 * `data` is recommended.
14439 *
14440 * @type {Data}
14441 */
14442 this.data = {};
14443 /**
14444 * List of messages associated with the file.
14445 *
14446 * @type {Array<VFileMessage>}
14447 */
14448 this.messages = [];
14449 /**
14450 * List of filepaths the file moved between.
14451 *
14452 * The first is the original path and the last is the current path.
14453 *
14454 * @type {Array<string>}
14455 */
14456 this.history = [];
14457 /**
14458 * Base of `path` (default: `process.cwd()` or `'/'` in browsers).
14459 *
14460 * @type {string}
14461 */
14462 this.cwd = proc.cwd();
14463 /**
14464 * Raw value.
14465 *
14466 * @type {Value}
14467 */
14468 this.value;
14469 /**
14470 * Whether a file was saved to disk.
14471 *
14472 * This is used by vfile reporters.
14473 *
14474 * @type {boolean}
14475 */
14476 this.stored;
14477 /**
14478 * Custom, non-string, compiled, representation.
14479 *
14480 * This is used by unified to store non-string results.
14481 * One example is when turning markdown into React nodes.
14482 *
14483 * @type {unknown}
14484 */
14485 this.result;
14486 /**
14487 * Source map.
14488 *
14489 * This type is equivalent to the `RawSourceMap` type from the `source-map`
14490 * module.
14491 *
14492 * @type {Map | null | undefined}
14493 */
14494 this.map;
14495 let index = -1;
14496 while (++index < order.length) {
14497 const prop = order[index];
14498 if (prop in options && options[prop] !== void 0 && options[prop] !== null) this[prop] = prop === "history" ? [...options[prop]] : options[prop];
14499 }
14500 /** @type {string} */
14501 let prop;
14502 for (prop in options) if (!order.includes(prop)) this[prop] = options[prop];
14503 }
14504 /**
14505 * Get the full path (example: `'~/index.min.js'`).
14506 *
14507 * @returns {string}
14508 */
14509 get path() {
14510 return this.history[this.history.length - 1];
14511 }
14512 /**
14513 * Set the full path (example: `'~/index.min.js'`).
14514 *
14515 * Cannot be nullified.
14516 * You can set a file URL (a `URL` object with a `file:` protocol) which will
14517 * be turned into a path with `url.fileURLToPath`.
14518 *
14519 * @param {string | URL} path
14520 */
14521 set path(path) {
14522 if (isUrl(path)) path = urlToPath(path);
14523 assertNonEmpty(path, "path");
14524 if (this.path !== path) this.history.push(path);
14525 }
14526 /**
14527 * Get the parent path (example: `'~'`).
14528 */
14529 get dirname() {
14530 return typeof this.path === "string" ? path.dirname(this.path) : void 0;
14531 }
14532 /**
14533 * Set the parent path (example: `'~'`).
14534 *
14535 * Cannot be set if there’s no `path` yet.
14536 */
14537 set dirname(dirname) {
14538 assertPath(this.basename, "dirname");
14539 this.path = path.join(dirname || "", this.basename);
14540 }
14541 /**
14542 * Get the basename (including extname) (example: `'index.min.js'`).
14543 */
14544 get basename() {
14545 return typeof this.path === "string" ? path.basename(this.path) : void 0;
14546 }
14547 /**
14548 * Set basename (including extname) (`'index.min.js'`).
14549 *
14550 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14551 * on windows).
14552 * Cannot be nullified (use `file.path = file.dirname` instead).
14553 */
14554 set basename(basename) {
14555 assertNonEmpty(basename, "basename");
14556 assertPart(basename, "basename");
14557 this.path = path.join(this.dirname || "", basename);
14558 }
14559 /**
14560 * Get the extname (including dot) (example: `'.js'`).
14561 */
14562 get extname() {
14563 return typeof this.path === "string" ? path.extname(this.path) : void 0;
14564 }
14565 /**
14566 * Set the extname (including dot) (example: `'.js'`).
14567 *
14568 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14569 * on windows).
14570 * Cannot be set if there’s no `path` yet.
14571 */
14572 set extname(extname) {
14573 assertPart(extname, "extname");
14574 assertPath(this.dirname, "extname");
14575 if (extname) {
14576 if (extname.charCodeAt(0) !== 46) throw new Error("`extname` must start with `.`");
14577 if (extname.includes(".", 1)) throw new Error("`extname` cannot contain multiple dots");
14578 }
14579 this.path = path.join(this.dirname, this.stem + (extname || ""));
14580 }
14581 /**
14582 * Get the stem (basename w/o extname) (example: `'index.min'`).
14583 */
14584 get stem() {
14585 return typeof this.path === "string" ? path.basename(this.path, this.extname) : void 0;
14586 }
14587 /**
14588 * Set the stem (basename w/o extname) (example: `'index.min'`).
14589 *
14590 * Cannot contain path separators (`'/'` on unix, macOS, and browsers, `'\'`
14591 * on windows).
14592 * Cannot be nullified (use `file.path = file.dirname` instead).
14593 */
14594 set stem(stem) {
14595 assertNonEmpty(stem, "stem");
14596 assertPart(stem, "stem");
14597 this.path = path.join(this.dirname || "", stem + (this.extname || ""));
14598 }
14599 /**
14600 * Serialize the file.
14601 *
14602 * @param {BufferEncoding | null | undefined} [encoding='utf8']
14603 * Character encoding to understand `value` as when it’s a `Buffer`
14604 * (default: `'utf8'`).
14605 * @returns {string}
14606 * Serialized file.
14607 */
14608 toString(encoding) {
14609 return (this.value || "").toString(encoding || void 0);
14610 }
14611 /**
14612 * Create a warning message associated with the file.
14613 *
14614 * Its `fatal` is set to `false` and `file` is set to the current file path.
14615 * Its added to `file.messages`.
14616 *
14617 * @param {string | Error | VFileMessage} reason
14618 * Reason for message, uses the stack and message of the error if given.
14619 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14620 * Place in file where the message occurred.
14621 * @param {string | null | undefined} [origin]
14622 * Place in code where the message originates (example:
14623 * `'my-package:my-rule'` or `'my-rule'`).
14624 * @returns {VFileMessage}
14625 * Message.
14626 */
14627 message(reason, place, origin) {
14628 const message = new VFileMessage(reason, place, origin);
14629 if (this.path) {
14630 message.name = this.path + ":" + message.name;
14631 message.file = this.path;
14632 }
14633 message.fatal = false;
14634 this.messages.push(message);
14635 return message;
14636 }
14637 /**
14638 * Create an info message associated with the file.
14639 *
14640 * Its `fatal` is set to `null` and `file` is set to the current file path.
14641 * Its added to `file.messages`.
14642 *
14643 * @param {string | Error | VFileMessage} reason
14644 * Reason for message, uses the stack and message of the error if given.
14645 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14646 * Place in file where the message occurred.
14647 * @param {string | null | undefined} [origin]
14648 * Place in code where the message originates (example:
14649 * `'my-package:my-rule'` or `'my-rule'`).
14650 * @returns {VFileMessage}
14651 * Message.
14652 */
14653 info(reason, place, origin) {
14654 const message = this.message(reason, place, origin);
14655 message.fatal = null;
14656 return message;
14657 }
14658 /**
14659 * Create a fatal error associated with the file.
14660 *
14661 * Its `fatal` is set to `true` and `file` is set to the current file path.
14662 * Its added to `file.messages`.
14663 *
14664 * > 👉 **Note**: a fatal error means that a file is no longer processable.
14665 *
14666 * @param {string | Error | VFileMessage} reason
14667 * Reason for message, uses the stack and message of the error if given.
14668 * @param {Node | NodeLike | Position | Point | null | undefined} [place]
14669 * Place in file where the message occurred.
14670 * @param {string | null | undefined} [origin]
14671 * Place in code where the message originates (example:
14672 * `'my-package:my-rule'` or `'my-rule'`).
14673 * @returns {never}
14674 * Message.
14675 * @throws {VFileMessage}
14676 * Message.
14677 */
14678 fail(reason, place, origin) {
14679 const message = this.message(reason, place, origin);
14680 message.fatal = true;
14681 throw message;
14682 }
14683 };
14684 }));
14685
14686 //#endregion
14687 //#region node_modules/vfile/index.js
14688 var init_vfile = __esmMin((() => {
14689 init_lib$13();
14690 }));
14691
14692 //#endregion
14693 //#region node_modules/bail/index.js
14694 /**
14695 * Throw a given error.
14696 *
14697 * @param {Error|null|undefined} [error]
14698 * Maybe error.
14699 * @returns {asserts error is null|undefined}
14700 */
14701 function bail(error) {
14702 if (error) throw error;
14703 }
14704 var init_bail = __esmMin((() => {}));
14705
14706 //#endregion
14707 //#region node_modules/unified/node_modules/is-buffer/index.js
14708 var require_is_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14709 /*!
14710 * Determine if an object is a Buffer
14711 *
14712 * @author Feross Aboukhadijeh <https://feross.org>
14713 * @license MIT
14714 */
14715 module.exports = function isBuffer(obj) {
14716 return obj != null && obj.constructor != null && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
14717 };
14718 }));
14719
14720 //#endregion
14721 //#region node_modules/extend/index.js
14722 var require_extend = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14723 var hasOwn = Object.prototype.hasOwnProperty;
14724 var toStr = Object.prototype.toString;
14725 var defineProperty = Object.defineProperty;
14726 var gOPD = Object.getOwnPropertyDescriptor;
14727 var isArray = function isArray(arr) {
14728 if (typeof Array.isArray === "function") return Array.isArray(arr);
14729 return toStr.call(arr) === "[object Array]";
14730 };
14731 var isPlainObject = function isPlainObject(obj) {
14732 if (!obj || toStr.call(obj) !== "[object Object]") return false;
14733 var hasOwnConstructor = hasOwn.call(obj, "constructor");
14734 var hasIsPrototypeOf = obj.constructor && obj.constructor.prototype && hasOwn.call(obj.constructor.prototype, "isPrototypeOf");
14735 if (obj.constructor && !hasOwnConstructor && !hasIsPrototypeOf) return false;
14736 var key;
14737 for (key in obj);
14738 return typeof key === "undefined" || hasOwn.call(obj, key);
14739 };
14740 var setProperty = function setProperty(target, options) {
14741 if (defineProperty && options.name === "__proto__") defineProperty(target, options.name, {
14742 enumerable: true,
14743 configurable: true,
14744 value: options.newValue,
14745 writable: true
14746 });
14747 else target[options.name] = options.newValue;
14748 };
14749 var getProperty = function getProperty(obj, name) {
14750 if (name === "__proto__") {
14751 if (!hasOwn.call(obj, name)) return;
14752 else if (gOPD) return gOPD(obj, name).value;
14753 }
14754 return obj[name];
14755 };
14756 module.exports = function extend() {
14757 var options;
14758 var name;
14759 var src;
14760 var copy;
14761 var copyIsArray;
14762 var clone;
14763 var target = arguments[0];
14764 var i = 1;
14765 var length = arguments.length;
14766 var deep = false;
14767 if (typeof target === "boolean") {
14768 deep = target;
14769 target = arguments[1] || {};
14770 i = 2;
14771 }
14772 if (target == null || typeof target !== "object" && typeof target !== "function") target = {};
14773 for (; i < length; ++i) {
14774 options = arguments[i];
14775 if (options != null) for (name in options) {
14776 src = getProperty(target, name);
14777 copy = getProperty(options, name);
14778 if (target !== copy) {
14779 if (deep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) {
14780 if (copyIsArray) {
14781 copyIsArray = false;
14782 clone = src && isArray(src) ? src : [];
14783 } else clone = src && isPlainObject(src) ? src : {};
14784 setProperty(target, {
14785 name,
14786 newValue: extend(deep, clone, copy)
14787 });
14788 } else if (typeof copy !== "undefined") setProperty(target, {
14789 name,
14790 newValue: copy
14791 });
14792 }
14793 }
14794 }
14795 return target;
14796 };
14797 }));
14798
14799 //#endregion
14800 //#region node_modules/is-plain-obj/index.js
14801 function isPlainObject(value) {
14802 if (typeof value !== "object" || value === null) return false;
14803 const prototype = Object.getPrototypeOf(value);
14804 return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
14805 }
14806 var init_is_plain_obj = __esmMin((() => {}));
14807
14808 //#endregion
14809 //#region node_modules/trough/lib/index.js
14810 /**
14811 * @typedef {(error?: Error | null | undefined, ...output: Array<any>) => void} Callback
14812 * Callback.
14813 *
14814 * @typedef {(...input: Array<any>) => any} Middleware
14815 * Ware.
14816 *
14817 * @typedef Pipeline
14818 * Pipeline.
14819 * @property {Run} run
14820 * Run the pipeline.
14821 * @property {Use} use
14822 * Add middleware.
14823 *
14824 * @typedef {(...input: Array<any>) => void} Run
14825 * Call all middleware.
14826 *
14827 * Calls `done` on completion with either an error or the output of the
14828 * last middleware.
14829 *
14830 * > 👉 **Note**: as the length of input defines whether async functions get a
14831 * > `next` function,
14832 * > it’s recommended to keep `input` at one value normally.
14833
14834 *
14835 * @typedef {(fn: Middleware) => Pipeline} Use
14836 * Add middleware.
14837 */
14838 /**
14839 * Create new middleware.
14840 *
14841 * @returns {Pipeline}
14842 * Pipeline.
14843 */
14844 function trough() {
14845 /** @type {Array<Middleware>} */
14846 const fns = [];
14847 /** @type {Pipeline} */
14848 const pipeline = {
14849 run,
14850 use
14851 };
14852 return pipeline;
14853 /** @type {Run} */
14854 function run(...values) {
14855 let middlewareIndex = -1;
14856 /** @type {Callback} */
14857 const callback = values.pop();
14858 if (typeof callback !== "function") throw new TypeError("Expected function as last argument, not " + callback);
14859 next(null, ...values);
14860 /**
14861 * Run the next `fn`, or we’re done.
14862 *
14863 * @param {Error | null | undefined} error
14864 * @param {Array<any>} output
14865 */
14866 function next(error, ...output) {
14867 const fn = fns[++middlewareIndex];
14868 let index = -1;
14869 if (error) {
14870 callback(error);
14871 return;
14872 }
14873 while (++index < values.length) if (output[index] === null || output[index] === void 0) output[index] = values[index];
14874 values = output;
14875 if (fn) wrap$1(fn, next)(...output);
14876 else callback(null, ...output);
14877 }
14878 }
14879 /** @type {Use} */
14880 function use(middelware) {
14881 if (typeof middelware !== "function") throw new TypeError("Expected `middelware` to be a function, not " + middelware);
14882 fns.push(middelware);
14883 return pipeline;
14884 }
14885 }
14886 /**
14887 * Wrap `middleware` into a uniform interface.
14888 *
14889 * You can pass all input to the resulting function.
14890 * `callback` is then called with the output of `middleware`.
14891 *
14892 * If `middleware` accepts more arguments than the later given in input,
14893 * an extra `done` function is passed to it after that input,
14894 * which must be called by `middleware`.
14895 *
14896 * The first value in `input` is the main input value.
14897 * All other input values are the rest input values.
14898 * The values given to `callback` are the input values,
14899 * merged with every non-nullish output value.
14900 *
14901 * * if `middleware` throws an error,
14902 * returns a promise that is rejected,
14903 * or calls the given `done` function with an error,
14904 * `callback` is called with that error
14905 * * if `middleware` returns a value or returns a promise that is resolved,
14906 * that value is the main output value
14907 * * if `middleware` calls `done`,
14908 * all non-nullish values except for the first one (the error) overwrite the
14909 * output values
14910 *
14911 * @param {Middleware} middleware
14912 * Function to wrap.
14913 * @param {Callback} callback
14914 * Callback called with the output of `middleware`.
14915 * @returns {Run}
14916 * Wrapped middleware.
14917 */
14918 function wrap$1(middleware, callback) {
14919 /** @type {boolean} */
14920 let called;
14921 return wrapped;
14922 /**
14923 * Call `middleware`.
14924 * @this {any}
14925 * @param {Array<any>} parameters
14926 * @returns {void}
14927 */
14928 function wrapped(...parameters) {
14929 const fnExpectsCallback = middleware.length > parameters.length;
14930 /** @type {any} */
14931 let result;
14932 if (fnExpectsCallback) parameters.push(done);
14933 try {
14934 result = middleware.apply(this, parameters);
14935 } catch (error) {
14936 const exception = error;
14937 if (fnExpectsCallback && called) throw exception;
14938 return done(exception);
14939 }
14940 if (!fnExpectsCallback) if (result && result.then && typeof result.then === "function") result.then(then, done);
14941 else if (result instanceof Error) done(result);
14942 else then(result);
14943 }
14944 /**
14945 * Call `callback`, only once.
14946 *
14947 * @type {Callback}
14948 */
14949 function done(error, ...output) {
14950 if (!called) {
14951 called = true;
14952 callback(error, ...output);
14953 }
14954 }
14955 /**
14956 * Call `done` with one value.
14957 *
14958 * @param {any} [value]
14959 */
14960 function then(value) {
14961 done(null, value);
14962 }
14963 }
14964 var init_lib$12 = __esmMin((() => {
14965 __name(wrap$1, "wrap");
14966 }));
14967
14968 //#endregion
14969 //#region node_modules/trough/index.js
14970 var init_trough = __esmMin((() => {
14971 init_lib$12();
14972 }));
14973
14974 //#endregion
14975 //#region node_modules/unified/lib/index.js
14976 /**
14977 * @returns {Processor}
14978 */
14979 function base() {
14980 const transformers = trough();
14981 /** @type {Processor['attachers']} */
14982 const attachers = [];
14983 /** @type {Record<string, unknown>} */
14984 let namespace = {};
14985 /** @type {boolean|undefined} */
14986 let frozen;
14987 let freezeIndex = -1;
14988 processor.data = data;
14989 processor.Parser = void 0;
14990 processor.Compiler = void 0;
14991 processor.freeze = freeze;
14992 processor.attachers = attachers;
14993 processor.use = use;
14994 processor.parse = parse;
14995 processor.stringify = stringify;
14996 processor.run = run;
14997 processor.runSync = runSync;
14998 processor.process = process;
14999 processor.processSync = processSync;
15000 return processor;
15001 /** @type {Processor} */
15002 function processor() {
15003 const destination = base();
15004 let index = -1;
15005 while (++index < attachers.length) destination.use(...attachers[index]);
15006 destination.data((0, import_extend.default)(true, {}, namespace));
15007 return destination;
15008 }
15009 /**
15010 * @param {string|Record<string, unknown>} [key]
15011 * @param {unknown} [value]
15012 * @returns {unknown}
15013 */
15014 function data(key, value) {
15015 if (typeof key === "string") {
15016 if (arguments.length === 2) {
15017 assertUnfrozen("data", frozen);
15018 namespace[key] = value;
15019 return processor;
15020 }
15021 return own$6.call(namespace, key) && namespace[key] || null;
15022 }
15023 if (key) {
15024 assertUnfrozen("data", frozen);
15025 namespace = key;
15026 return processor;
15027 }
15028 return namespace;
15029 }
15030 /** @type {Processor['freeze']} */
15031 function freeze() {
15032 if (frozen) return processor;
15033 while (++freezeIndex < attachers.length) {
15034 const [attacher, ...options] = attachers[freezeIndex];
15035 if (options[0] === false) continue;
15036 if (options[0] === true) options[0] = void 0;
15037 /** @type {Transformer|void} */
15038 const transformer = attacher.call(processor, ...options);
15039 if (typeof transformer === "function") transformers.use(transformer);
15040 }
15041 frozen = true;
15042 freezeIndex = Number.POSITIVE_INFINITY;
15043 return processor;
15044 }
15045 /**
15046 * @param {Pluggable|null|undefined} [value]
15047 * @param {...unknown} options
15048 * @returns {Processor}
15049 */
15050 function use(value, ...options) {
15051 /** @type {Record<string, unknown>|undefined} */
15052 let settings;
15053 assertUnfrozen("use", frozen);
15054 if (value === null || value === void 0) {} else if (typeof value === "function") addPlugin(value, ...options);
15055 else if (typeof value === "object") if (Array.isArray(value)) addList(value);
15056 else addPreset(value);
15057 else throw new TypeError("Expected usable value, not `" + value + "`");
15058 if (settings) namespace.settings = Object.assign(namespace.settings || {}, settings);
15059 return processor;
15060 /**
15061 * @param {import('..').Pluggable<unknown[]>} value
15062 * @returns {void}
15063 */
15064 function add(value) {
15065 if (typeof value === "function") addPlugin(value);
15066 else if (typeof value === "object") if (Array.isArray(value)) {
15067 const [plugin, ...options] = value;
15068 addPlugin(plugin, ...options);
15069 } else addPreset(value);
15070 else throw new TypeError("Expected usable value, not `" + value + "`");
15071 }
15072 /**
15073 * @param {Preset} result
15074 * @returns {void}
15075 */
15076 function addPreset(result) {
15077 addList(result.plugins);
15078 if (result.settings) settings = Object.assign(settings || {}, result.settings);
15079 }
15080 /**
15081 * @param {PluggableList|null|undefined} [plugins]
15082 * @returns {void}
15083 */
15084 function addList(plugins) {
15085 let index = -1;
15086 if (plugins === null || plugins === void 0) {} else if (Array.isArray(plugins)) while (++index < plugins.length) {
15087 const thing = plugins[index];
15088 add(thing);
15089 }
15090 else throw new TypeError("Expected a list of plugins, not `" + plugins + "`");
15091 }
15092 /**
15093 * @param {Plugin} plugin
15094 * @param {...unknown} [value]
15095 * @returns {void}
15096 */
15097 function addPlugin(plugin, value) {
15098 let index = -1;
15099 /** @type {Processor['attachers'][number]|undefined} */
15100 let entry;
15101 while (++index < attachers.length) if (attachers[index][0] === plugin) {
15102 entry = attachers[index];
15103 break;
15104 }
15105 if (entry) {
15106 if (isPlainObject(entry[1]) && isPlainObject(value)) value = (0, import_extend.default)(true, entry[1], value);
15107 entry[1] = value;
15108 } else attachers.push([...arguments]);
15109 }
15110 }
15111 /** @type {Processor['parse']} */
15112 function parse(doc) {
15113 processor.freeze();
15114 const file = vfile(doc);
15115 const Parser = processor.Parser;
15116 assertParser("parse", Parser);
15117 if (newable(Parser, "parse")) return new Parser(String(file), file).parse();
15118 return Parser(String(file), file);
15119 }
15120 /** @type {Processor['stringify']} */
15121 function stringify(node, doc) {
15122 processor.freeze();
15123 const file = vfile(doc);
15124 const Compiler = processor.Compiler;
15125 assertCompiler("stringify", Compiler);
15126 assertNode(node);
15127 if (newable(Compiler, "compile")) return new Compiler(node, file).compile();
15128 return Compiler(node, file);
15129 }
15130 /**
15131 * @param {Node} node
15132 * @param {VFileCompatible|RunCallback} [doc]
15133 * @param {RunCallback} [callback]
15134 * @returns {Promise<Node>|void}
15135 */
15136 function run(node, doc, callback) {
15137 assertNode(node);
15138 processor.freeze();
15139 if (!callback && typeof doc === "function") {
15140 callback = doc;
15141 doc = void 0;
15142 }
15143 if (!callback) return new Promise(executor);
15144 executor(null, callback);
15145 /**
15146 * @param {null|((node: Node) => void)} resolve
15147 * @param {(error: Error) => void} reject
15148 * @returns {void}
15149 */
15150 function executor(resolve, reject) {
15151 transformers.run(node, vfile(doc), done);
15152 /**
15153 * @param {Error|null} error
15154 * @param {Node} tree
15155 * @param {VFile} file
15156 * @returns {void}
15157 */
15158 function done(error, tree, file) {
15159 tree = tree || node;
15160 if (error) reject(error);
15161 else if (resolve) resolve(tree);
15162 else callback(null, tree, file);
15163 }
15164 }
15165 }
15166 /** @type {Processor['runSync']} */
15167 function runSync(node, file) {
15168 /** @type {Node|undefined} */
15169 let result;
15170 /** @type {boolean|undefined} */
15171 let complete;
15172 processor.run(node, file, done);
15173 assertDone("runSync", "run", complete);
15174 return result;
15175 /**
15176 * @param {Error|null} [error]
15177 * @param {Node} [tree]
15178 * @returns {void}
15179 */
15180 function done(error, tree) {
15181 bail(error);
15182 result = tree;
15183 complete = true;
15184 }
15185 }
15186 /**
15187 * @param {VFileCompatible} doc
15188 * @param {ProcessCallback} [callback]
15189 * @returns {Promise<VFile>|undefined}
15190 */
15191 function process(doc, callback) {
15192 processor.freeze();
15193 assertParser("process", processor.Parser);
15194 assertCompiler("process", processor.Compiler);
15195 if (!callback) return new Promise(executor);
15196 executor(null, callback);
15197 /**
15198 * @param {null|((file: VFile) => void)} resolve
15199 * @param {(error?: Error|null|undefined) => void} reject
15200 * @returns {void}
15201 */
15202 function executor(resolve, reject) {
15203 const file = vfile(doc);
15204 processor.run(processor.parse(file), file, (error, tree, file) => {
15205 if (error || !tree || !file) done(error);
15206 else {
15207 /** @type {unknown} */
15208 const result = processor.stringify(tree, file);
15209 if (result === void 0 || result === null) {} else if (looksLikeAVFileValue(result)) file.value = result;
15210 else file.result = result;
15211 done(error, file);
15212 }
15213 });
15214 /**
15215 * @param {Error|null|undefined} [error]
15216 * @param {VFile|undefined} [file]
15217 * @returns {void}
15218 */
15219 function done(error, file) {
15220 if (error || !file) reject(error);
15221 else if (resolve) resolve(file);
15222 else callback(null, file);
15223 }
15224 }
15225 }
15226 /** @type {Processor['processSync']} */
15227 function processSync(doc) {
15228 /** @type {boolean|undefined} */
15229 let complete;
15230 processor.freeze();
15231 assertParser("processSync", processor.Parser);
15232 assertCompiler("processSync", processor.Compiler);
15233 const file = vfile(doc);
15234 processor.process(file, done);
15235 assertDone("processSync", "process", complete);
15236 return file;
15237 /**
15238 * @param {Error|null|undefined} [error]
15239 * @returns {void}
15240 */
15241 function done(error) {
15242 complete = true;
15243 bail(error);
15244 }
15245 }
15246 }
15247 /**
15248 * Check if `value` is a constructor.
15249 *
15250 * @param {unknown} value
15251 * @param {string} name
15252 * @returns {boolean}
15253 */
15254 function newable(value, name) {
15255 return typeof value === "function" && value.prototype && (keys(value.prototype) || name in value.prototype);
15256 }
15257 /**
15258 * Check if `value` is an object with keys.
15259 *
15260 * @param {Record<string, unknown>} value
15261 * @returns {boolean}
15262 */
15263 function keys(value) {
15264 /** @type {string} */
15265 let key;
15266 for (key in value) if (own$6.call(value, key)) return true;
15267 return false;
15268 }
15269 /**
15270 * Assert a parser is available.
15271 *
15272 * @param {string} name
15273 * @param {unknown} value
15274 * @returns {asserts value is Parser}
15275 */
15276 function assertParser(name, value) {
15277 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Parser`");
15278 }
15279 /**
15280 * Assert a compiler is available.
15281 *
15282 * @param {string} name
15283 * @param {unknown} value
15284 * @returns {asserts value is Compiler}
15285 */
15286 function assertCompiler(name, value) {
15287 if (typeof value !== "function") throw new TypeError("Cannot `" + name + "` without `Compiler`");
15288 }
15289 /**
15290 * Assert the processor is not frozen.
15291 *
15292 * @param {string} name
15293 * @param {unknown} frozen
15294 * @returns {asserts frozen is false}
15295 */
15296 function assertUnfrozen(name, frozen) {
15297 if (frozen) throw new Error("Cannot call `" + name + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.");
15298 }
15299 /**
15300 * Assert `node` is a unist node.
15301 *
15302 * @param {unknown} node
15303 * @returns {asserts node is Node}
15304 */
15305 function assertNode(node) {
15306 if (!isPlainObject(node) || typeof node.type !== "string") throw new TypeError("Expected node, got `" + node + "`");
15307 }
15308 /**
15309 * Assert that `complete` is `true`.
15310 *
15311 * @param {string} name
15312 * @param {string} asyncName
15313 * @param {unknown} complete
15314 * @returns {asserts complete is true}
15315 */
15316 function assertDone(name, asyncName, complete) {
15317 if (!complete) throw new Error("`" + name + "` finished async. Use `" + asyncName + "` instead");
15318 }
15319 /**
15320 * @param {VFileCompatible} [value]
15321 * @returns {VFile}
15322 */
15323 function vfile(value) {
15324 return looksLikeAVFile(value) ? value : new VFile(value);
15325 }
15326 /**
15327 * @param {VFileCompatible} [value]
15328 * @returns {value is VFile}
15329 */
15330 function looksLikeAVFile(value) {
15331 return Boolean(value && typeof value === "object" && "message" in value && "messages" in value);
15332 }
15333 /**
15334 * @param {unknown} [value]
15335 * @returns {value is VFileValue}
15336 */
15337 function looksLikeAVFileValue(value) {
15338 return typeof value === "string" || (0, import_is_buffer.default)(value);
15339 }
15340 var import_is_buffer, import_extend, unified, own$6;
15341 var init_lib$11 = __esmMin((() => {
15342 init_bail();
15343 import_is_buffer = /* @__PURE__ */ __toESM(require_is_buffer(), 1);
15344 import_extend = /* @__PURE__ */ __toESM(require_extend(), 1);
15345 init_is_plain_obj();
15346 init_trough();
15347 init_vfile();
15348 unified = base().freeze();
15349 own$6 = {}.hasOwnProperty;
15350 }));
15351
15352 //#endregion
15353 //#region node_modules/unified/index.js
15354 var init_unified = __esmMin((() => {
15355 init_lib$11();
15356 }));
15357
15358 //#endregion
15359 //#region node_modules/mdast-util-to-string/lib/index.js
15360 /**
15361 * Get the text content of a node or list of nodes.
15362 *
15363 * Prefers the node’s plain-text fields, otherwise serializes its children,
15364 * and if the given value is an array, serialize the nodes in it.
15365 *
15366 * @param {unknown} value
15367 * Thing to serialize, typically `Node`.
15368 * @param {Options | null | undefined} [options]
15369 * Configuration (optional).
15370 * @returns {string}
15371 * Serialized `value`.
15372 */
15373 function toString(value, options) {
15374 const settings = options || emptyOptions;
15375 return one$1(value, typeof settings.includeImageAlt === "boolean" ? settings.includeImageAlt : true, typeof settings.includeHtml === "boolean" ? settings.includeHtml : true);
15376 }
15377 /**
15378 * One node or several nodes.
15379 *
15380 * @param {unknown} value
15381 * Thing to serialize.
15382 * @param {boolean} includeImageAlt
15383 * Include image `alt`s.
15384 * @param {boolean} includeHtml
15385 * Include HTML.
15386 * @returns {string}
15387 * Serialized node.
15388 */
15389 function one$1(value, includeImageAlt, includeHtml) {
15390 if (node(value)) {
15391 if ("value" in value) return value.type === "html" && !includeHtml ? "" : value.value;
15392 if (includeImageAlt && "alt" in value && value.alt) return value.alt;
15393 if ("children" in value) return all$1(value.children, includeImageAlt, includeHtml);
15394 }
15395 if (Array.isArray(value)) return all$1(value, includeImageAlt, includeHtml);
15396 return "";
15397 }
15398 /**
15399 * Serialize a list of nodes.
15400 *
15401 * @param {Array<unknown>} values
15402 * Thing to serialize.
15403 * @param {boolean} includeImageAlt
15404 * Include image `alt`s.
15405 * @param {boolean} includeHtml
15406 * Include HTML.
15407 * @returns {string}
15408 * Serialized nodes.
15409 */
15410 function all$1(values, includeImageAlt, includeHtml) {
15411 /** @type {Array<string>} */
15412 const result = [];
15413 let index = -1;
15414 while (++index < values.length) result[index] = one$1(values[index], includeImageAlt, includeHtml);
15415 return result.join("");
15416 }
15417 /**
15418 * Check if `value` looks like a node.
15419 *
15420 * @param {unknown} value
15421 * Thing.
15422 * @returns {value is Node}
15423 * Whether `value` is a node.
15424 */
15425 function node(value) {
15426 return Boolean(value && typeof value === "object");
15427 }
15428 var emptyOptions;
15429 var init_lib$10 = __esmMin((() => {
15430 emptyOptions = {};
15431 __name(one$1, "one");
15432 __name(all$1, "all");
15433 }));
15434
15435 //#endregion
15436 //#region node_modules/mdast-util-to-string/index.js
15437 var init_mdast_util_to_string = __esmMin((() => {
15438 init_lib$10();
15439 }));
15440
15441 //#endregion
15442 //#region node_modules/micromark-util-chunked/index.js
15443 /**
15444 * Like `Array#splice`, but smarter for giant arrays.
15445 *
15446 * `Array#splice` takes all items to be inserted as individual argument which
15447 * causes a stack overflow in V8 when trying to insert 100k items for instance.
15448 *
15449 * Otherwise, this does not return the removed items, and takes `items` as an
15450 * array instead of rest parameters.
15451 *
15452 * @template {unknown} T
15453 * Item type.
15454 * @param {Array<T>} list
15455 * List to operate on.
15456 * @param {number} start
15457 * Index to remove/insert at (can be negative).
15458 * @param {number} remove
15459 * Number of items to remove.
15460 * @param {Array<T>} items
15461 * Items to inject into `list`.
15462 * @returns {void}
15463 * Nothing.
15464 */
15465 function splice(list, start, remove, items) {
15466 const end = list.length;
15467 let chunkStart = 0;
15468 /** @type {Array<unknown>} */
15469 let parameters;
15470 if (start < 0) start = -start > end ? 0 : end + start;
15471 else start = start > end ? end : start;
15472 remove = remove > 0 ? remove : 0;
15473 if (items.length < 1e4) {
15474 parameters = Array.from(items);
15475 parameters.unshift(start, remove);
15476 list.splice(...parameters);
15477 } else {
15478 if (remove) list.splice(start, remove);
15479 while (chunkStart < items.length) {
15480 parameters = items.slice(chunkStart, chunkStart + 1e4);
15481 parameters.unshift(start, 0);
15482 list.splice(...parameters);
15483 chunkStart += 1e4;
15484 start += 1e4;
15485 }
15486 }
15487 }
15488 /**
15489 * Append `items` (an array) at the end of `list` (another array).
15490 * When `list` was empty, returns `items` instead.
15491 *
15492 * This prevents a potentially expensive operation when `list` is empty,
15493 * and adds items in batches to prevent V8 from hanging.
15494 *
15495 * @template {unknown} T
15496 * Item type.
15497 * @param {Array<T>} list
15498 * List to operate on.
15499 * @param {Array<T>} items
15500 * Items to add to `list`.
15501 * @returns {Array<T>}
15502 * Either `list` or `items`.
15503 */
15504 function push(list, items) {
15505 if (list.length > 0) {
15506 splice(list, list.length, 0, items);
15507 return list;
15508 }
15509 return items;
15510 }
15511 var init_micromark_util_chunked = __esmMin((() => {}));
15512
15513 //#endregion
15514 //#region node_modules/micromark-util-combine-extensions/index.js
15515 /**
15516 * Combine multiple syntax extensions into one.
15517 *
15518 * @param {Array<Extension>} extensions
15519 * List of syntax extensions.
15520 * @returns {NormalizedExtension}
15521 * A single combined extension.
15522 */
15523 function combineExtensions(extensions) {
15524 /** @type {NormalizedExtension} */
15525 const all = {};
15526 let index = -1;
15527 while (++index < extensions.length) syntaxExtension(all, extensions[index]);
15528 return all;
15529 }
15530 /**
15531 * Merge `extension` into `all`.
15532 *
15533 * @param {NormalizedExtension} all
15534 * Extension to merge into.
15535 * @param {Extension} extension
15536 * Extension to merge.
15537 * @returns {void}
15538 */
15539 function syntaxExtension(all, extension) {
15540 /** @type {keyof Extension} */
15541 let hook;
15542 for (hook in extension) {
15543 /** @type {Record<string, unknown>} */
15544 const left = (hasOwnProperty.call(all, hook) ? all[hook] : void 0) || (all[hook] = {});
15545 /** @type {Record<string, unknown> | undefined} */
15546 const right = extension[hook];
15547 /** @type {string} */
15548 let code;
15549 if (right) for (code in right) {
15550 if (!hasOwnProperty.call(left, code)) left[code] = [];
15551 const value = right[code];
15552 constructs(left[code], Array.isArray(value) ? value : value ? [value] : []);
15553 }
15554 }
15555 }
15556 /**
15557 * Merge `list` into `existing` (both lists of constructs).
15558 * Mutates `existing`.
15559 *
15560 * @param {Array<unknown>} existing
15561 * @param {Array<unknown>} list
15562 * @returns {void}
15563 */
15564 function constructs(existing, list) {
15565 let index = -1;
15566 /** @type {Array<unknown>} */
15567 const before = [];
15568 while (++index < list.length) (list[index].add === "after" ? existing : before).push(list[index]);
15569 splice(existing, 0, 0, before);
15570 }
15571 var hasOwnProperty;
15572 var init_micromark_util_combine_extensions = __esmMin((() => {
15573 init_micromark_util_chunked();
15574 hasOwnProperty = {}.hasOwnProperty;
15575 }));
15576
15577 //#endregion
15578 //#region node_modules/micromark-util-character/lib/unicode-punctuation-regex.js
15579 var unicodePunctuationRegex;
15580 var init_unicode_punctuation_regex = __esmMin((() => {
15581 unicodePunctuationRegex = /[!-\/:-@\[-`\{-~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/;
15582 }));
15583
15584 //#endregion
15585 //#region node_modules/micromark-util-character/index.js
15586 /**
15587 * Check whether a character code is an ASCII control character.
15588 *
15589 * An **ASCII control** is a character in the inclusive range U+0000 NULL (NUL)
15590 * to U+001F (US), or U+007F (DEL).
15591 *
15592 * @param {Code} code
15593 * Code.
15594 * @returns {boolean}
15595 * Whether it matches.
15596 */
15597 function asciiControl(code) {
15598 return code !== null && (code < 32 || code === 127);
15599 }
15600 /**
15601 * Check whether a character code is a markdown line ending.
15602 *
15603 * A **markdown line ending** is the virtual characters M-0003 CARRIAGE RETURN
15604 * LINE FEED (CRLF), M-0004 LINE FEED (LF) and M-0005 CARRIAGE RETURN (CR).
15605 *
15606 * In micromark, the actual character U+000A LINE FEED (LF) and U+000D CARRIAGE
15607 * RETURN (CR) are replaced by these virtual characters depending on whether
15608 * they occurred together.
15609 *
15610 * @param {Code} code
15611 * Code.
15612 * @returns {boolean}
15613 * Whether it matches.
15614 */
15615 function markdownLineEnding(code) {
15616 return code !== null && code < -2;
15617 }
15618 /**
15619 * Check whether a character code is a markdown line ending (see
15620 * `markdownLineEnding`) or markdown space (see `markdownSpace`).
15621 *
15622 * @param {Code} code
15623 * Code.
15624 * @returns {boolean}
15625 * Whether it matches.
15626 */
15627 function markdownLineEndingOrSpace(code) {
15628 return code !== null && (code < 0 || code === 32);
15629 }
15630 /**
15631 * Check whether a character code is a markdown space.
15632 *
15633 * A **markdown space** is the concrete character U+0020 SPACE (SP) and the
15634 * virtual characters M-0001 VIRTUAL SPACE (VS) and M-0002 HORIZONTAL TAB (HT).
15635 *
15636 * In micromark, the actual character U+0009 CHARACTER TABULATION (HT) is
15637 * replaced by one M-0002 HORIZONTAL TAB (HT) and between 0 and 3 M-0001 VIRTUAL
15638 * SPACE (VS) characters, depending on the column at which the tab occurred.
15639 *
15640 * @param {Code} code
15641 * Code.
15642 * @returns {boolean}
15643 * Whether it matches.
15644 */
15645 function markdownSpace(code) {
15646 return code === -2 || code === -1 || code === 32;
15647 }
15648 /**
15649 * Create a code check from a regex.
15650 *
15651 * @param {RegExp} regex
15652 * @returns {(code: Code) => boolean}
15653 */
15654 function regexCheck(regex) {
15655 return check;
15656 /**
15657 * Check whether a code matches the bound regex.
15658 *
15659 * @param {Code} code
15660 * Character code.
15661 * @returns {boolean}
15662 * Whether the character code matches the bound regex.
15663 */
15664 function check(code) {
15665 return code !== null && regex.test(String.fromCharCode(code));
15666 }
15667 }
15668 var asciiAlpha, asciiAlphanumeric, asciiAtext, asciiDigit, asciiHexDigit, asciiPunctuation, unicodePunctuation, unicodeWhitespace;
15669 var init_micromark_util_character = __esmMin((() => {
15670 init_unicode_punctuation_regex();
15671 asciiAlpha = regexCheck(/[A-Za-z]/);
15672 asciiAlphanumeric = regexCheck(/[\dA-Za-z]/);
15673 asciiAtext = regexCheck(/[#-'*+\--9=?A-Z^-~]/);
15674 asciiDigit = regexCheck(/\d/);
15675 asciiHexDigit = regexCheck(/[\dA-Fa-f]/);
15676 asciiPunctuation = regexCheck(/[!-/:-@[-`{-~]/);
15677 unicodePunctuation = regexCheck(unicodePunctuationRegex);
15678 unicodeWhitespace = regexCheck(/\s/);
15679 }));
15680
15681 //#endregion
15682 //#region node_modules/micromark-factory-space/index.js
15683 /**
15684 * Parse spaces and tabs.
15685 *
15686 * There is no `nok` parameter:
15687 *
15688 * * spaces in markdown are often optional, in which case this factory can be
15689 * used and `ok` will be switched to whether spaces were found or not
15690 * * one line ending or space can be detected with `markdownSpace(code)` right
15691 * before using `factorySpace`
15692 *
15693 * ###### Examples
15694 *
15695 * Where `␉` represents a tab (plus how much it expands) and `␠` represents a
15696 * single space.
15697 *
15698 * ```markdown
15699 * ␉
15700 * ␠␠␠␠
15701 * ␉␠
15702 * ```
15703 *
15704 * @param {Effects} effects
15705 * Context.
15706 * @param {State} ok
15707 * State switched to when successful.
15708 * @param {TokenType} type
15709 * Type (`' \t'`).
15710 * @param {number | undefined} [max=Infinity]
15711 * Max (exclusive).
15712 * @returns
15713 * Start state.
15714 */
15715 function factorySpace(effects, ok, type, max) {
15716 const limit = max ? max - 1 : Number.POSITIVE_INFINITY;
15717 let size = 0;
15718 return start;
15719 /** @type {State} */
15720 function start(code) {
15721 if (markdownSpace(code)) {
15722 effects.enter(type);
15723 return prefix(code);
15724 }
15725 return ok(code);
15726 }
15727 /** @type {State} */
15728 function prefix(code) {
15729 if (markdownSpace(code) && size++ < limit) {
15730 effects.consume(code);
15731 return prefix;
15732 }
15733 effects.exit(type);
15734 return ok(code);
15735 }
15736 }
15737 var init_micromark_factory_space = __esmMin((() => {
15738 init_micromark_util_character();
15739 }));
15740
15741 //#endregion
15742 //#region node_modules/micromark/lib/initialize/content.js
15743 /**
15744 * @this {TokenizeContext}
15745 * @type {Initializer}
15746 */
15747 function initializeContent(effects) {
15748 const contentStart = effects.attempt(this.parser.constructs.contentInitial, afterContentStartConstruct, paragraphInitial);
15749 /** @type {Token} */
15750 let previous;
15751 return contentStart;
15752 /** @type {State} */
15753 function afterContentStartConstruct(code) {
15754 if (code === null) {
15755 effects.consume(code);
15756 return;
15757 }
15758 effects.enter("lineEnding");
15759 effects.consume(code);
15760 effects.exit("lineEnding");
15761 return factorySpace(effects, contentStart, "linePrefix");
15762 }
15763 /** @type {State} */
15764 function paragraphInitial(code) {
15765 effects.enter("paragraph");
15766 return lineStart(code);
15767 }
15768 /** @type {State} */
15769 function lineStart(code) {
15770 const token = effects.enter("chunkText", {
15771 contentType: "text",
15772 previous
15773 });
15774 if (previous) previous.next = token;
15775 previous = token;
15776 return data(code);
15777 }
15778 /** @type {State} */
15779 function data(code) {
15780 if (code === null) {
15781 effects.exit("chunkText");
15782 effects.exit("paragraph");
15783 effects.consume(code);
15784 return;
15785 }
15786 if (markdownLineEnding(code)) {
15787 effects.consume(code);
15788 effects.exit("chunkText");
15789 return lineStart;
15790 }
15791 effects.consume(code);
15792 return data;
15793 }
15794 }
15795 var content$1;
15796 var init_content$1 = __esmMin((() => {
15797 init_micromark_factory_space();
15798 init_micromark_util_character();
15799 content$1 = { tokenize: initializeContent };
15800 }));
15801
15802 //#endregion
15803 //#region node_modules/micromark/lib/initialize/document.js
15804 /**
15805 * @this {TokenizeContext}
15806 * @type {Initializer}
15807 */
15808 function initializeDocument(effects) {
15809 const self = this;
15810 /** @type {Array<StackItem>} */
15811 const stack = [];
15812 let continued = 0;
15813 /** @type {TokenizeContext | undefined} */
15814 let childFlow;
15815 /** @type {Token | undefined} */
15816 let childToken;
15817 /** @type {number} */
15818 let lineStartOffset;
15819 return start;
15820 /** @type {State} */
15821 function start(code) {
15822 if (continued < stack.length) {
15823 const item = stack[continued];
15824 self.containerState = item[1];
15825 return effects.attempt(item[0].continuation, documentContinue, checkNewContainers)(code);
15826 }
15827 return checkNewContainers(code);
15828 }
15829 /** @type {State} */
15830 function documentContinue(code) {
15831 continued++;
15832 if (self.containerState._closeFlow) {
15833 self.containerState._closeFlow = void 0;
15834 if (childFlow) closeFlow();
15835 const indexBeforeExits = self.events.length;
15836 let indexBeforeFlow = indexBeforeExits;
15837 /** @type {Point | undefined} */
15838 let point;
15839 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
15840 point = self.events[indexBeforeFlow][1].end;
15841 break;
15842 }
15843 exitContainers(continued);
15844 let index = indexBeforeExits;
15845 while (index < self.events.length) {
15846 self.events[index][1].end = Object.assign({}, point);
15847 index++;
15848 }
15849 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
15850 self.events.length = index;
15851 return checkNewContainers(code);
15852 }
15853 return start(code);
15854 }
15855 /** @type {State} */
15856 function checkNewContainers(code) {
15857 if (continued === stack.length) {
15858 if (!childFlow) return documentContinued(code);
15859 if (childFlow.currentConstruct && childFlow.currentConstruct.concrete) return flowStart(code);
15860 self.interrupt = Boolean(childFlow.currentConstruct && !childFlow._gfmTableDynamicInterruptHack);
15861 }
15862 self.containerState = {};
15863 return effects.check(containerConstruct, thereIsANewContainer, thereIsNoNewContainer)(code);
15864 }
15865 /** @type {State} */
15866 function thereIsANewContainer(code) {
15867 if (childFlow) closeFlow();
15868 exitContainers(continued);
15869 return documentContinued(code);
15870 }
15871 /** @type {State} */
15872 function thereIsNoNewContainer(code) {
15873 self.parser.lazy[self.now().line] = continued !== stack.length;
15874 lineStartOffset = self.now().offset;
15875 return flowStart(code);
15876 }
15877 /** @type {State} */
15878 function documentContinued(code) {
15879 self.containerState = {};
15880 return effects.attempt(containerConstruct, containerContinue, flowStart)(code);
15881 }
15882 /** @type {State} */
15883 function containerContinue(code) {
15884 continued++;
15885 stack.push([self.currentConstruct, self.containerState]);
15886 return documentContinued(code);
15887 }
15888 /** @type {State} */
15889 function flowStart(code) {
15890 if (code === null) {
15891 if (childFlow) closeFlow();
15892 exitContainers(0);
15893 effects.consume(code);
15894 return;
15895 }
15896 childFlow = childFlow || self.parser.flow(self.now());
15897 effects.enter("chunkFlow", {
15898 contentType: "flow",
15899 previous: childToken,
15900 _tokenizer: childFlow
15901 });
15902 return flowContinue(code);
15903 }
15904 /** @type {State} */
15905 function flowContinue(code) {
15906 if (code === null) {
15907 writeToChild(effects.exit("chunkFlow"), true);
15908 exitContainers(0);
15909 effects.consume(code);
15910 return;
15911 }
15912 if (markdownLineEnding(code)) {
15913 effects.consume(code);
15914 writeToChild(effects.exit("chunkFlow"));
15915 continued = 0;
15916 self.interrupt = void 0;
15917 return start;
15918 }
15919 effects.consume(code);
15920 return flowContinue;
15921 }
15922 /**
15923 * @param {Token} token
15924 * @param {boolean | undefined} [eof]
15925 * @returns {void}
15926 */
15927 function writeToChild(token, eof) {
15928 const stream = self.sliceStream(token);
15929 if (eof) stream.push(null);
15930 token.previous = childToken;
15931 if (childToken) childToken.next = token;
15932 childToken = token;
15933 childFlow.defineSkip(token.start);
15934 childFlow.write(stream);
15935 if (self.parser.lazy[token.start.line]) {
15936 let index = childFlow.events.length;
15937 while (index--) if (childFlow.events[index][1].start.offset < lineStartOffset && (!childFlow.events[index][1].end || childFlow.events[index][1].end.offset > lineStartOffset)) return;
15938 const indexBeforeExits = self.events.length;
15939 let indexBeforeFlow = indexBeforeExits;
15940 /** @type {boolean | undefined} */
15941 let seen;
15942 /** @type {Point | undefined} */
15943 let point;
15944 while (indexBeforeFlow--) if (self.events[indexBeforeFlow][0] === "exit" && self.events[indexBeforeFlow][1].type === "chunkFlow") {
15945 if (seen) {
15946 point = self.events[indexBeforeFlow][1].end;
15947 break;
15948 }
15949 seen = true;
15950 }
15951 exitContainers(continued);
15952 index = indexBeforeExits;
15953 while (index < self.events.length) {
15954 self.events[index][1].end = Object.assign({}, point);
15955 index++;
15956 }
15957 splice(self.events, indexBeforeFlow + 1, 0, self.events.slice(indexBeforeExits));
15958 self.events.length = index;
15959 }
15960 }
15961 /**
15962 * @param {number} size
15963 * @returns {void}
15964 */
15965 function exitContainers(size) {
15966 let index = stack.length;
15967 while (index-- > size) {
15968 const entry = stack[index];
15969 self.containerState = entry[1];
15970 entry[0].exit.call(self, effects);
15971 }
15972 stack.length = size;
15973 }
15974 function closeFlow() {
15975 childFlow.write([null]);
15976 childToken = void 0;
15977 childFlow = void 0;
15978 self.containerState._closeFlow = void 0;
15979 }
15980 }
15981 /**
15982 * @this {TokenizeContext}
15983 * @type {Tokenizer}
15984 */
15985 function tokenizeContainer(effects, ok, nok) {
15986 return factorySpace(effects, effects.attempt(this.parser.constructs.document, ok, nok), "linePrefix", this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4);
15987 }
15988 var document$2, containerConstruct;
15989 var init_document = __esmMin((() => {
15990 init_micromark_factory_space();
15991 init_micromark_util_character();
15992 init_micromark_util_chunked();
15993 document$2 = { tokenize: initializeDocument };
15994 containerConstruct = { tokenize: tokenizeContainer };
15995 }));
15996
15997 //#endregion
15998 //#region node_modules/micromark-util-classify-character/index.js
15999 /**
16000 * Classify whether a code represents whitespace, punctuation, or something
16001 * else.
16002 *
16003 * Used for attention (emphasis, strong), whose sequences can open or close
16004 * based on the class of surrounding characters.
16005 *
16006 * > 👉 **Note**: eof (`null`) is seen as whitespace.
16007 *
16008 * @param {Code} code
16009 * Code.
16010 * @returns {typeof constants.characterGroupWhitespace | typeof constants.characterGroupPunctuation | undefined}
16011 * Group.
16012 */
16013 function classifyCharacter(code) {
16014 if (code === null || markdownLineEndingOrSpace(code) || unicodeWhitespace(code)) return 1;
16015 if (unicodePunctuation(code)) return 2;
16016 }
16017 var init_micromark_util_classify_character = __esmMin((() => {
16018 init_micromark_util_character();
16019 }));
16020
16021 //#endregion
16022 //#region node_modules/micromark-util-resolve-all/index.js
16023 /**
16024 * @typedef {import('micromark-util-types').Event} Event
16025 * @typedef {import('micromark-util-types').Resolver} Resolver
16026 * @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
16027 */
16028 /**
16029 * Call all `resolveAll`s.
16030 *
16031 * @param {Array<{resolveAll?: Resolver | undefined}>} constructs
16032 * List of constructs, optionally with `resolveAll`s.
16033 * @param {Array<Event>} events
16034 * List of events.
16035 * @param {TokenizeContext} context
16036 * Context used by `tokenize`.
16037 * @returns {Array<Event>}
16038 * Changed events.
16039 */
16040 function resolveAll(constructs, events, context) {
16041 /** @type {Array<Resolver>} */
16042 const called = [];
16043 let index = -1;
16044 while (++index < constructs.length) {
16045 const resolve = constructs[index].resolveAll;
16046 if (resolve && !called.includes(resolve)) {
16047 events = resolve(events, context);
16048 called.push(resolve);
16049 }
16050 }
16051 return events;
16052 }
16053 var init_micromark_util_resolve_all = __esmMin((() => {}));
16054
16055 //#endregion
16056 //#region node_modules/micromark-core-commonmark/lib/attention.js
16057 /**
16058 * Take all events and resolve attention to emphasis or strong.
16059 *
16060 * @type {Resolver}
16061 */
16062 function resolveAllAttention(events, context) {
16063 let index = -1;
16064 /** @type {number} */
16065 let open;
16066 /** @type {Token} */
16067 let group;
16068 /** @type {Token} */
16069 let text;
16070 /** @type {Token} */
16071 let openingSequence;
16072 /** @type {Token} */
16073 let closingSequence;
16074 /** @type {number} */
16075 let use;
16076 /** @type {Array<Event>} */
16077 let nextEvents;
16078 /** @type {number} */
16079 let offset;
16080 while (++index < events.length) if (events[index][0] === "enter" && events[index][1].type === "attentionSequence" && events[index][1]._close) {
16081 open = index;
16082 while (open--) if (events[open][0] === "exit" && events[open][1].type === "attentionSequence" && events[open][1]._open && context.sliceSerialize(events[open][1]).charCodeAt(0) === context.sliceSerialize(events[index][1]).charCodeAt(0)) {
16083 if ((events[open][1]._close || events[index][1]._open) && (events[index][1].end.offset - events[index][1].start.offset) % 3 && !((events[open][1].end.offset - events[open][1].start.offset + events[index][1].end.offset - events[index][1].start.offset) % 3)) continue;
16084 use = events[open][1].end.offset - events[open][1].start.offset > 1 && events[index][1].end.offset - events[index][1].start.offset > 1 ? 2 : 1;
16085 const start = Object.assign({}, events[open][1].end);
16086 const end = Object.assign({}, events[index][1].start);
16087 movePoint(start, -use);
16088 movePoint(end, use);
16089 openingSequence = {
16090 type: use > 1 ? "strongSequence" : "emphasisSequence",
16091 start,
16092 end: Object.assign({}, events[open][1].end)
16093 };
16094 closingSequence = {
16095 type: use > 1 ? "strongSequence" : "emphasisSequence",
16096 start: Object.assign({}, events[index][1].start),
16097 end
16098 };
16099 text = {
16100 type: use > 1 ? "strongText" : "emphasisText",
16101 start: Object.assign({}, events[open][1].end),
16102 end: Object.assign({}, events[index][1].start)
16103 };
16104 group = {
16105 type: use > 1 ? "strong" : "emphasis",
16106 start: Object.assign({}, openingSequence.start),
16107 end: Object.assign({}, closingSequence.end)
16108 };
16109 events[open][1].end = Object.assign({}, openingSequence.start);
16110 events[index][1].start = Object.assign({}, closingSequence.end);
16111 nextEvents = [];
16112 if (events[open][1].end.offset - events[open][1].start.offset) nextEvents = push(nextEvents, [[
16113 "enter",
16114 events[open][1],
16115 context
16116 ], [
16117 "exit",
16118 events[open][1],
16119 context
16120 ]]);
16121 nextEvents = push(nextEvents, [
16122 [
16123 "enter",
16124 group,
16125 context
16126 ],
16127 [
16128 "enter",
16129 openingSequence,
16130 context
16131 ],
16132 [
16133 "exit",
16134 openingSequence,
16135 context
16136 ],
16137 [
16138 "enter",
16139 text,
16140 context
16141 ]
16142 ]);
16143 nextEvents = push(nextEvents, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + 1, index), context));
16144 nextEvents = push(nextEvents, [
16145 [
16146 "exit",
16147 text,
16148 context
16149 ],
16150 [
16151 "enter",
16152 closingSequence,
16153 context
16154 ],
16155 [
16156 "exit",
16157 closingSequence,
16158 context
16159 ],
16160 [
16161 "exit",
16162 group,
16163 context
16164 ]
16165 ]);
16166 if (events[index][1].end.offset - events[index][1].start.offset) {
16167 offset = 2;
16168 nextEvents = push(nextEvents, [[
16169 "enter",
16170 events[index][1],
16171 context
16172 ], [
16173 "exit",
16174 events[index][1],
16175 context
16176 ]]);
16177 } else offset = 0;
16178 splice(events, open - 1, index - open + 3, nextEvents);
16179 index = open + nextEvents.length - offset - 2;
16180 break;
16181 }
16182 }
16183 index = -1;
16184 while (++index < events.length) if (events[index][1].type === "attentionSequence") events[index][1].type = "data";
16185 return events;
16186 }
16187 /**
16188 * @this {TokenizeContext}
16189 * @type {Tokenizer}
16190 */
16191 function tokenizeAttention(effects, ok) {
16192 const attentionMarkers = this.parser.constructs.attentionMarkers.null;
16193 const previous = this.previous;
16194 const before = classifyCharacter(previous);
16195 /** @type {NonNullable<Code>} */
16196 let marker;
16197 return start;
16198 /**
16199 * Before a sequence.
16200 *
16201 * ```markdown
16202 * > | **
16203 * ^
16204 * ```
16205 *
16206 * @type {State}
16207 */
16208 function start(code) {
16209 marker = code;
16210 effects.enter("attentionSequence");
16211 return inside(code);
16212 }
16213 /**
16214 * In a sequence.
16215 *
16216 * ```markdown
16217 * > | **
16218 * ^^
16219 * ```
16220 *
16221 * @type {State}
16222 */
16223 function inside(code) {
16224 if (code === marker) {
16225 effects.consume(code);
16226 return inside;
16227 }
16228 const token = effects.exit("attentionSequence");
16229 const after = classifyCharacter(code);
16230 const open = !after || after === 2 && before || attentionMarkers.includes(code);
16231 const close = !before || before === 2 && after || attentionMarkers.includes(previous);
16232 token._open = Boolean(marker === 42 ? open : open && (before || !close));
16233 token._close = Boolean(marker === 42 ? close : close && (after || !open));
16234 return ok(code);
16235 }
16236 }
16237 /**
16238 * Move a point a bit.
16239 *
16240 * Note: `move` only works inside lines! It’s not possible to move past other
16241 * chunks (replacement characters, tabs, or line endings).
16242 *
16243 * @param {Point} point
16244 * @param {number} offset
16245 * @returns {void}
16246 */
16247 function movePoint(point, offset) {
16248 point.column += offset;
16249 point.offset += offset;
16250 point._bufferIndex += offset;
16251 }
16252 var attention;
16253 var init_attention = __esmMin((() => {
16254 init_micromark_util_chunked();
16255 init_micromark_util_classify_character();
16256 init_micromark_util_resolve_all();
16257 attention = {
16258 name: "attention",
16259 tokenize: tokenizeAttention,
16260 resolveAll: resolveAllAttention
16261 };
16262 }));
16263
16264 //#endregion
16265 //#region node_modules/micromark-core-commonmark/lib/autolink.js
16266 /**
16267 * @this {TokenizeContext}
16268 * @type {Tokenizer}
16269 */
16270 function tokenizeAutolink(effects, ok, nok) {
16271 let size = 0;
16272 return start;
16273 /**
16274 * Start of an autolink.
16275 *
16276 * ```markdown
16277 * > | a<https://example.com>b
16278 * ^
16279 * > | a<[email protected]>b
16280 * ^
16281 * ```
16282 *
16283 * @type {State}
16284 */
16285 function start(code) {
16286 effects.enter("autolink");
16287 effects.enter("autolinkMarker");
16288 effects.consume(code);
16289 effects.exit("autolinkMarker");
16290 effects.enter("autolinkProtocol");
16291 return open;
16292 }
16293 /**
16294 * After `<`, at protocol or atext.
16295 *
16296 * ```markdown
16297 * > | a<https://example.com>b
16298 * ^
16299 * > | a<[email protected]>b
16300 * ^
16301 * ```
16302 *
16303 * @type {State}
16304 */
16305 function open(code) {
16306 if (asciiAlpha(code)) {
16307 effects.consume(code);
16308 return schemeOrEmailAtext;
16309 }
16310 return emailAtext(code);
16311 }
16312 /**
16313 * At second byte of protocol or atext.
16314 *
16315 * ```markdown
16316 * > | a<https://example.com>b
16317 * ^
16318 * > | a<[email protected]>b
16319 * ^
16320 * ```
16321 *
16322 * @type {State}
16323 */
16324 function schemeOrEmailAtext(code) {
16325 if (code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) {
16326 size = 1;
16327 return schemeInsideOrEmailAtext(code);
16328 }
16329 return emailAtext(code);
16330 }
16331 /**
16332 * In ambiguous protocol or atext.
16333 *
16334 * ```markdown
16335 * > | a<https://example.com>b
16336 * ^
16337 * > | a<[email protected]>b
16338 * ^
16339 * ```
16340 *
16341 * @type {State}
16342 */
16343 function schemeInsideOrEmailAtext(code) {
16344 if (code === 58) {
16345 effects.consume(code);
16346 size = 0;
16347 return urlInside;
16348 }
16349 if ((code === 43 || code === 45 || code === 46 || asciiAlphanumeric(code)) && size++ < 32) {
16350 effects.consume(code);
16351 return schemeInsideOrEmailAtext;
16352 }
16353 size = 0;
16354 return emailAtext(code);
16355 }
16356 /**
16357 * After protocol, in URL.
16358 *
16359 * ```markdown
16360 * > | a<https://example.com>b
16361 * ^
16362 * ```
16363 *
16364 * @type {State}
16365 */
16366 function urlInside(code) {
16367 if (code === 62) {
16368 effects.exit("autolinkProtocol");
16369 effects.enter("autolinkMarker");
16370 effects.consume(code);
16371 effects.exit("autolinkMarker");
16372 effects.exit("autolink");
16373 return ok;
16374 }
16375 if (code === null || code === 32 || code === 60 || asciiControl(code)) return nok(code);
16376 effects.consume(code);
16377 return urlInside;
16378 }
16379 /**
16380 * In email atext.
16381 *
16382 * ```markdown
16383 * > | a<[email protected]>b
16384 * ^
16385 * ```
16386 *
16387 * @type {State}
16388 */
16389 function emailAtext(code) {
16390 if (code === 64) {
16391 effects.consume(code);
16392 return emailAtSignOrDot;
16393 }
16394 if (asciiAtext(code)) {
16395 effects.consume(code);
16396 return emailAtext;
16397 }
16398 return nok(code);
16399 }
16400 /**
16401 * In label, after at-sign or dot.
16402 *
16403 * ```markdown
16404 * > | a<[email protected]>b
16405 * ^ ^
16406 * ```
16407 *
16408 * @type {State}
16409 */
16410 function emailAtSignOrDot(code) {
16411 return asciiAlphanumeric(code) ? emailLabel(code) : nok(code);
16412 }
16413 /**
16414 * In label, where `.` and `>` are allowed.
16415 *
16416 * ```markdown
16417 * > | a<[email protected]>b
16418 * ^
16419 * ```
16420 *
16421 * @type {State}
16422 */
16423 function emailLabel(code) {
16424 if (code === 46) {
16425 effects.consume(code);
16426 size = 0;
16427 return emailAtSignOrDot;
16428 }
16429 if (code === 62) {
16430 effects.exit("autolinkProtocol").type = "autolinkEmail";
16431 effects.enter("autolinkMarker");
16432 effects.consume(code);
16433 effects.exit("autolinkMarker");
16434 effects.exit("autolink");
16435 return ok;
16436 }
16437 return emailValue(code);
16438 }
16439 /**
16440 * In label, where `.` and `>` are *not* allowed.
16441 *
16442 * Though, this is also used in `emailLabel` to parse other values.
16443 *
16444 * ```markdown
16445 * > | a<[email protected]>b
16446 * ^
16447 * ```
16448 *
16449 * @type {State}
16450 */
16451 function emailValue(code) {
16452 if ((code === 45 || asciiAlphanumeric(code)) && size++ < 63) {
16453 const next = code === 45 ? emailValue : emailLabel;
16454 effects.consume(code);
16455 return next;
16456 }
16457 return nok(code);
16458 }
16459 }
16460 var autolink;
16461 var init_autolink = __esmMin((() => {
16462 init_micromark_util_character();
16463 autolink = {
16464 name: "autolink",
16465 tokenize: tokenizeAutolink
16466 };
16467 }));
16468
16469 //#endregion
16470 //#region node_modules/micromark-core-commonmark/lib/blank-line.js
16471 /**
16472 * @this {TokenizeContext}
16473 * @type {Tokenizer}
16474 */
16475 function tokenizeBlankLine(effects, ok, nok) {
16476 return start;
16477 /**
16478 * Start of blank line.
16479 *
16480 * > 👉 **Note**: `␠` represents a space character.
16481 *
16482 * ```markdown
16483 * > | ␠␠␊
16484 * ^
16485 * > | ␊
16486 * ^
16487 * ```
16488 *
16489 * @type {State}
16490 */
16491 function start(code) {
16492 return markdownSpace(code) ? factorySpace(effects, after, "linePrefix")(code) : after(code);
16493 }
16494 /**
16495 * At eof/eol, after optional whitespace.
16496 *
16497 * > 👉 **Note**: `␠` represents a space character.
16498 *
16499 * ```markdown
16500 * > | ␠␠␊
16501 * ^
16502 * > | ␊
16503 * ^
16504 * ```
16505 *
16506 * @type {State}
16507 */
16508 function after(code) {
16509 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
16510 }
16511 }
16512 var blankLine;
16513 var init_blank_line = __esmMin((() => {
16514 init_micromark_factory_space();
16515 init_micromark_util_character();
16516 blankLine = {
16517 tokenize: tokenizeBlankLine,
16518 partial: true
16519 };
16520 }));
16521
16522 //#endregion
16523 //#region node_modules/micromark-core-commonmark/lib/block-quote.js
16524 /**
16525 * @this {TokenizeContext}
16526 * @type {Tokenizer}
16527 */
16528 function tokenizeBlockQuoteStart(effects, ok, nok) {
16529 const self = this;
16530 return start;
16531 /**
16532 * Start of block quote.
16533 *
16534 * ```markdown
16535 * > | > a
16536 * ^
16537 * ```
16538 *
16539 * @type {State}
16540 */
16541 function start(code) {
16542 if (code === 62) {
16543 const state = self.containerState;
16544 if (!state.open) {
16545 effects.enter("blockQuote", { _container: true });
16546 state.open = true;
16547 }
16548 effects.enter("blockQuotePrefix");
16549 effects.enter("blockQuoteMarker");
16550 effects.consume(code);
16551 effects.exit("blockQuoteMarker");
16552 return after;
16553 }
16554 return nok(code);
16555 }
16556 /**
16557 * After `>`, before optional whitespace.
16558 *
16559 * ```markdown
16560 * > | > a
16561 * ^
16562 * ```
16563 *
16564 * @type {State}
16565 */
16566 function after(code) {
16567 if (markdownSpace(code)) {
16568 effects.enter("blockQuotePrefixWhitespace");
16569 effects.consume(code);
16570 effects.exit("blockQuotePrefixWhitespace");
16571 effects.exit("blockQuotePrefix");
16572 return ok;
16573 }
16574 effects.exit("blockQuotePrefix");
16575 return ok(code);
16576 }
16577 }
16578 /**
16579 * Start of block quote continuation.
16580 *
16581 * ```markdown
16582 * | > a
16583 * > | > b
16584 * ^
16585 * ```
16586 *
16587 * @this {TokenizeContext}
16588 * @type {Tokenizer}
16589 */
16590 function tokenizeBlockQuoteContinuation(effects, ok, nok) {
16591 const self = this;
16592 return contStart;
16593 /**
16594 * Start of block quote continuation.
16595 *
16596 * Also used to parse the first block quote opening.
16597 *
16598 * ```markdown
16599 * | > a
16600 * > | > b
16601 * ^
16602 * ```
16603 *
16604 * @type {State}
16605 */
16606 function contStart(code) {
16607 if (markdownSpace(code)) return factorySpace(effects, contBefore, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
16608 return contBefore(code);
16609 }
16610 /**
16611 * At `>`, after optional whitespace.
16612 *
16613 * Also used to parse the first block quote opening.
16614 *
16615 * ```markdown
16616 * | > a
16617 * > | > b
16618 * ^
16619 * ```
16620 *
16621 * @type {State}
16622 */
16623 function contBefore(code) {
16624 return effects.attempt(blockQuote, ok, nok)(code);
16625 }
16626 }
16627 /** @type {Exiter} */
16628 function exit(effects) {
16629 effects.exit("blockQuote");
16630 }
16631 var blockQuote;
16632 var init_block_quote = __esmMin((() => {
16633 init_micromark_factory_space();
16634 init_micromark_util_character();
16635 blockQuote = {
16636 name: "blockQuote",
16637 tokenize: tokenizeBlockQuoteStart,
16638 continuation: { tokenize: tokenizeBlockQuoteContinuation },
16639 exit
16640 };
16641 }));
16642
16643 //#endregion
16644 //#region node_modules/micromark-core-commonmark/lib/character-escape.js
16645 /**
16646 * @this {TokenizeContext}
16647 * @type {Tokenizer}
16648 */
16649 function tokenizeCharacterEscape(effects, ok, nok) {
16650 return start;
16651 /**
16652 * Start of character escape.
16653 *
16654 * ```markdown
16655 * > | a\*b
16656 * ^
16657 * ```
16658 *
16659 * @type {State}
16660 */
16661 function start(code) {
16662 effects.enter("characterEscape");
16663 effects.enter("escapeMarker");
16664 effects.consume(code);
16665 effects.exit("escapeMarker");
16666 return inside;
16667 }
16668 /**
16669 * After `\`, at punctuation.
16670 *
16671 * ```markdown
16672 * > | a\*b
16673 * ^
16674 * ```
16675 *
16676 * @type {State}
16677 */
16678 function inside(code) {
16679 if (asciiPunctuation(code)) {
16680 effects.enter("characterEscapeValue");
16681 effects.consume(code);
16682 effects.exit("characterEscapeValue");
16683 effects.exit("characterEscape");
16684 return ok;
16685 }
16686 return nok(code);
16687 }
16688 }
16689 var characterEscape;
16690 var init_character_escape = __esmMin((() => {
16691 init_micromark_util_character();
16692 characterEscape = {
16693 name: "characterEscape",
16694 tokenize: tokenizeCharacterEscape
16695 };
16696 }));
16697
16698 //#endregion
16699 //#region node_modules/decode-named-character-reference/index.dom.js
16700 /**
16701 * @param {string} value
16702 * @returns {string | false}
16703 */
16704 function decodeNamedCharacterReference(value) {
16705 const characterReference = "&" + value + ";";
16706 element.innerHTML = characterReference;
16707 const character = element.textContent;
16708 if (character.charCodeAt(character.length - 1) === 59 && value !== "semi") return false;
16709 return character === characterReference ? false : character;
16710 }
16711 var element;
16712 var init_index_dom = __esmMin((() => {
16713 element = document.createElement("i");
16714 }));
16715
16716 //#endregion
16717 //#region node_modules/micromark-core-commonmark/lib/character-reference.js
16718 /**
16719 * @this {TokenizeContext}
16720 * @type {Tokenizer}
16721 */
16722 function tokenizeCharacterReference(effects, ok, nok) {
16723 const self = this;
16724 let size = 0;
16725 /** @type {number} */
16726 let max;
16727 /** @type {(code: Code) => boolean} */
16728 let test;
16729 return start;
16730 /**
16731 * Start of character reference.
16732 *
16733 * ```markdown
16734 * > | a&amp;b
16735 * ^
16736 * > | a&#123;b
16737 * ^
16738 * > | a&#x9;b
16739 * ^
16740 * ```
16741 *
16742 * @type {State}
16743 */
16744 function start(code) {
16745 effects.enter("characterReference");
16746 effects.enter("characterReferenceMarker");
16747 effects.consume(code);
16748 effects.exit("characterReferenceMarker");
16749 return open;
16750 }
16751 /**
16752 * After `&`, at `#` for numeric references or alphanumeric for named
16753 * references.
16754 *
16755 * ```markdown
16756 * > | a&amp;b
16757 * ^
16758 * > | a&#123;b
16759 * ^
16760 * > | a&#x9;b
16761 * ^
16762 * ```
16763 *
16764 * @type {State}
16765 */
16766 function open(code) {
16767 if (code === 35) {
16768 effects.enter("characterReferenceMarkerNumeric");
16769 effects.consume(code);
16770 effects.exit("characterReferenceMarkerNumeric");
16771 return numeric;
16772 }
16773 effects.enter("characterReferenceValue");
16774 max = 31;
16775 test = asciiAlphanumeric;
16776 return value(code);
16777 }
16778 /**
16779 * After `#`, at `x` for hexadecimals or digit for decimals.
16780 *
16781 * ```markdown
16782 * > | a&#123;b
16783 * ^
16784 * > | a&#x9;b
16785 * ^
16786 * ```
16787 *
16788 * @type {State}
16789 */
16790 function numeric(code) {
16791 if (code === 88 || code === 120) {
16792 effects.enter("characterReferenceMarkerHexadecimal");
16793 effects.consume(code);
16794 effects.exit("characterReferenceMarkerHexadecimal");
16795 effects.enter("characterReferenceValue");
16796 max = 6;
16797 test = asciiHexDigit;
16798 return value;
16799 }
16800 effects.enter("characterReferenceValue");
16801 max = 7;
16802 test = asciiDigit;
16803 return value(code);
16804 }
16805 /**
16806 * After markers (`&#x`, `&#`, or `&`), in value, before `;`.
16807 *
16808 * The character reference kind defines what and how many characters are
16809 * allowed.
16810 *
16811 * ```markdown
16812 * > | a&amp;b
16813 * ^^^
16814 * > | a&#123;b
16815 * ^^^
16816 * > | a&#x9;b
16817 * ^
16818 * ```
16819 *
16820 * @type {State}
16821 */
16822 function value(code) {
16823 if (code === 59 && size) {
16824 const token = effects.exit("characterReferenceValue");
16825 if (test === asciiAlphanumeric && !decodeNamedCharacterReference(self.sliceSerialize(token))) return nok(code);
16826 effects.enter("characterReferenceMarker");
16827 effects.consume(code);
16828 effects.exit("characterReferenceMarker");
16829 effects.exit("characterReference");
16830 return ok;
16831 }
16832 if (test(code) && size++ < max) {
16833 effects.consume(code);
16834 return value;
16835 }
16836 return nok(code);
16837 }
16838 }
16839 var characterReference;
16840 var init_character_reference = __esmMin((() => {
16841 init_index_dom();
16842 init_micromark_util_character();
16843 characterReference = {
16844 name: "characterReference",
16845 tokenize: tokenizeCharacterReference
16846 };
16847 }));
16848
16849 //#endregion
16850 //#region node_modules/micromark-core-commonmark/lib/code-fenced.js
16851 /**
16852 * @this {TokenizeContext}
16853 * @type {Tokenizer}
16854 */
16855 function tokenizeCodeFenced(effects, ok, nok) {
16856 const self = this;
16857 /** @type {Construct} */
16858 const closeStart = {
16859 tokenize: tokenizeCloseStart,
16860 partial: true
16861 };
16862 let initialPrefix = 0;
16863 let sizeOpen = 0;
16864 /** @type {NonNullable<Code>} */
16865 let marker;
16866 return start;
16867 /**
16868 * Start of code.
16869 *
16870 * ```markdown
16871 * > | ~~~js
16872 * ^
16873 * | alert(1)
16874 * | ~~~
16875 * ```
16876 *
16877 * @type {State}
16878 */
16879 function start(code) {
16880 return beforeSequenceOpen(code);
16881 }
16882 /**
16883 * In opening fence, after prefix, at sequence.
16884 *
16885 * ```markdown
16886 * > | ~~~js
16887 * ^
16888 * | alert(1)
16889 * | ~~~
16890 * ```
16891 *
16892 * @type {State}
16893 */
16894 function beforeSequenceOpen(code) {
16895 const tail = self.events[self.events.length - 1];
16896 initialPrefix = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
16897 marker = code;
16898 effects.enter("codeFenced");
16899 effects.enter("codeFencedFence");
16900 effects.enter("codeFencedFenceSequence");
16901 return sequenceOpen(code);
16902 }
16903 /**
16904 * In opening fence sequence.
16905 *
16906 * ```markdown
16907 * > | ~~~js
16908 * ^
16909 * | alert(1)
16910 * | ~~~
16911 * ```
16912 *
16913 * @type {State}
16914 */
16915 function sequenceOpen(code) {
16916 if (code === marker) {
16917 sizeOpen++;
16918 effects.consume(code);
16919 return sequenceOpen;
16920 }
16921 if (sizeOpen < 3) return nok(code);
16922 effects.exit("codeFencedFenceSequence");
16923 return markdownSpace(code) ? factorySpace(effects, infoBefore, "whitespace")(code) : infoBefore(code);
16924 }
16925 /**
16926 * In opening fence, after the sequence (and optional whitespace), before info.
16927 *
16928 * ```markdown
16929 * > | ~~~js
16930 * ^
16931 * | alert(1)
16932 * | ~~~
16933 * ```
16934 *
16935 * @type {State}
16936 */
16937 function infoBefore(code) {
16938 if (code === null || markdownLineEnding(code)) {
16939 effects.exit("codeFencedFence");
16940 return self.interrupt ? ok(code) : effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
16941 }
16942 effects.enter("codeFencedFenceInfo");
16943 effects.enter("chunkString", { contentType: "string" });
16944 return info(code);
16945 }
16946 /**
16947 * In info.
16948 *
16949 * ```markdown
16950 * > | ~~~js
16951 * ^
16952 * | alert(1)
16953 * | ~~~
16954 * ```
16955 *
16956 * @type {State}
16957 */
16958 function info(code) {
16959 if (code === null || markdownLineEnding(code)) {
16960 effects.exit("chunkString");
16961 effects.exit("codeFencedFenceInfo");
16962 return infoBefore(code);
16963 }
16964 if (markdownSpace(code)) {
16965 effects.exit("chunkString");
16966 effects.exit("codeFencedFenceInfo");
16967 return factorySpace(effects, metaBefore, "whitespace")(code);
16968 }
16969 if (code === 96 && code === marker) return nok(code);
16970 effects.consume(code);
16971 return info;
16972 }
16973 /**
16974 * In opening fence, after info and whitespace, before meta.
16975 *
16976 * ```markdown
16977 * > | ~~~js eval
16978 * ^
16979 * | alert(1)
16980 * | ~~~
16981 * ```
16982 *
16983 * @type {State}
16984 */
16985 function metaBefore(code) {
16986 if (code === null || markdownLineEnding(code)) return infoBefore(code);
16987 effects.enter("codeFencedFenceMeta");
16988 effects.enter("chunkString", { contentType: "string" });
16989 return meta(code);
16990 }
16991 /**
16992 * In meta.
16993 *
16994 * ```markdown
16995 * > | ~~~js eval
16996 * ^
16997 * | alert(1)
16998 * | ~~~
16999 * ```
17000 *
17001 * @type {State}
17002 */
17003 function meta(code) {
17004 if (code === null || markdownLineEnding(code)) {
17005 effects.exit("chunkString");
17006 effects.exit("codeFencedFenceMeta");
17007 return infoBefore(code);
17008 }
17009 if (code === 96 && code === marker) return nok(code);
17010 effects.consume(code);
17011 return meta;
17012 }
17013 /**
17014 * At eol/eof in code, before a non-lazy closing fence or content.
17015 *
17016 * ```markdown
17017 * > | ~~~js
17018 * ^
17019 * > | alert(1)
17020 * ^
17021 * | ~~~
17022 * ```
17023 *
17024 * @type {State}
17025 */
17026 function atNonLazyBreak(code) {
17027 return effects.attempt(closeStart, after, contentBefore)(code);
17028 }
17029 /**
17030 * Before code content, not a closing fence, at eol.
17031 *
17032 * ```markdown
17033 * | ~~~js
17034 * > | alert(1)
17035 * ^
17036 * | ~~~
17037 * ```
17038 *
17039 * @type {State}
17040 */
17041 function contentBefore(code) {
17042 effects.enter("lineEnding");
17043 effects.consume(code);
17044 effects.exit("lineEnding");
17045 return contentStart;
17046 }
17047 /**
17048 * Before code content, not a closing fence.
17049 *
17050 * ```markdown
17051 * | ~~~js
17052 * > | alert(1)
17053 * ^
17054 * | ~~~
17055 * ```
17056 *
17057 * @type {State}
17058 */
17059 function contentStart(code) {
17060 return initialPrefix > 0 && markdownSpace(code) ? factorySpace(effects, beforeContentChunk, "linePrefix", initialPrefix + 1)(code) : beforeContentChunk(code);
17061 }
17062 /**
17063 * Before code content, after optional prefix.
17064 *
17065 * ```markdown
17066 * | ~~~js
17067 * > | alert(1)
17068 * ^
17069 * | ~~~
17070 * ```
17071 *
17072 * @type {State}
17073 */
17074 function beforeContentChunk(code) {
17075 if (code === null || markdownLineEnding(code)) return effects.check(nonLazyContinuation, atNonLazyBreak, after)(code);
17076 effects.enter("codeFlowValue");
17077 return contentChunk(code);
17078 }
17079 /**
17080 * In code content.
17081 *
17082 * ```markdown
17083 * | ~~~js
17084 * > | alert(1)
17085 * ^^^^^^^^
17086 * | ~~~
17087 * ```
17088 *
17089 * @type {State}
17090 */
17091 function contentChunk(code) {
17092 if (code === null || markdownLineEnding(code)) {
17093 effects.exit("codeFlowValue");
17094 return beforeContentChunk(code);
17095 }
17096 effects.consume(code);
17097 return contentChunk;
17098 }
17099 /**
17100 * After code.
17101 *
17102 * ```markdown
17103 * | ~~~js
17104 * | alert(1)
17105 * > | ~~~
17106 * ^
17107 * ```
17108 *
17109 * @type {State}
17110 */
17111 function after(code) {
17112 effects.exit("codeFenced");
17113 return ok(code);
17114 }
17115 /**
17116 * @this {TokenizeContext}
17117 * @type {Tokenizer}
17118 */
17119 function tokenizeCloseStart(effects, ok, nok) {
17120 let size = 0;
17121 return startBefore;
17122 /**
17123 *
17124 *
17125 * @type {State}
17126 */
17127 function startBefore(code) {
17128 effects.enter("lineEnding");
17129 effects.consume(code);
17130 effects.exit("lineEnding");
17131 return start;
17132 }
17133 /**
17134 * Before closing fence, at optional whitespace.
17135 *
17136 * ```markdown
17137 * | ~~~js
17138 * | alert(1)
17139 * > | ~~~
17140 * ^
17141 * ```
17142 *
17143 * @type {State}
17144 */
17145 function start(code) {
17146 effects.enter("codeFencedFence");
17147 return markdownSpace(code) ? factorySpace(effects, beforeSequenceClose, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : beforeSequenceClose(code);
17148 }
17149 /**
17150 * In closing fence, after optional whitespace, at sequence.
17151 *
17152 * ```markdown
17153 * | ~~~js
17154 * | alert(1)
17155 * > | ~~~
17156 * ^
17157 * ```
17158 *
17159 * @type {State}
17160 */
17161 function beforeSequenceClose(code) {
17162 if (code === marker) {
17163 effects.enter("codeFencedFenceSequence");
17164 return sequenceClose(code);
17165 }
17166 return nok(code);
17167 }
17168 /**
17169 * In closing fence sequence.
17170 *
17171 * ```markdown
17172 * | ~~~js
17173 * | alert(1)
17174 * > | ~~~
17175 * ^
17176 * ```
17177 *
17178 * @type {State}
17179 */
17180 function sequenceClose(code) {
17181 if (code === marker) {
17182 size++;
17183 effects.consume(code);
17184 return sequenceClose;
17185 }
17186 if (size >= sizeOpen) {
17187 effects.exit("codeFencedFenceSequence");
17188 return markdownSpace(code) ? factorySpace(effects, sequenceCloseAfter, "whitespace")(code) : sequenceCloseAfter(code);
17189 }
17190 return nok(code);
17191 }
17192 /**
17193 * After closing fence sequence, after optional whitespace.
17194 *
17195 * ```markdown
17196 * | ~~~js
17197 * | alert(1)
17198 * > | ~~~
17199 * ^
17200 * ```
17201 *
17202 * @type {State}
17203 */
17204 function sequenceCloseAfter(code) {
17205 if (code === null || markdownLineEnding(code)) {
17206 effects.exit("codeFencedFence");
17207 return ok(code);
17208 }
17209 return nok(code);
17210 }
17211 }
17212 }
17213 /**
17214 * @this {TokenizeContext}
17215 * @type {Tokenizer}
17216 */
17217 function tokenizeNonLazyContinuation(effects, ok, nok) {
17218 const self = this;
17219 return start;
17220 /**
17221 *
17222 *
17223 * @type {State}
17224 */
17225 function start(code) {
17226 if (code === null) return nok(code);
17227 effects.enter("lineEnding");
17228 effects.consume(code);
17229 effects.exit("lineEnding");
17230 return lineStart;
17231 }
17232 /**
17233 *
17234 *
17235 * @type {State}
17236 */
17237 function lineStart(code) {
17238 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
17239 }
17240 }
17241 var nonLazyContinuation, codeFenced;
17242 var init_code_fenced = __esmMin((() => {
17243 init_micromark_factory_space();
17244 init_micromark_util_character();
17245 nonLazyContinuation = {
17246 tokenize: tokenizeNonLazyContinuation,
17247 partial: true
17248 };
17249 codeFenced = {
17250 name: "codeFenced",
17251 tokenize: tokenizeCodeFenced,
17252 concrete: true
17253 };
17254 }));
17255
17256 //#endregion
17257 //#region node_modules/micromark-core-commonmark/lib/code-indented.js
17258 /**
17259 * @this {TokenizeContext}
17260 * @type {Tokenizer}
17261 */
17262 function tokenizeCodeIndented(effects, ok, nok) {
17263 const self = this;
17264 return start;
17265 /**
17266 * Start of code (indented).
17267 *
17268 * > **Parsing note**: it is not needed to check if this first line is a
17269 * > filled line (that it has a non-whitespace character), because blank lines
17270 * > are parsed already, so we never run into that.
17271 *
17272 * ```markdown
17273 * > | aaa
17274 * ^
17275 * ```
17276 *
17277 * @type {State}
17278 */
17279 function start(code) {
17280 effects.enter("codeIndented");
17281 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17282 }
17283 /**
17284 * At start, after 1 or 4 spaces.
17285 *
17286 * ```markdown
17287 * > | aaa
17288 * ^
17289 * ```
17290 *
17291 * @type {State}
17292 */
17293 function afterPrefix(code) {
17294 const tail = self.events[self.events.length - 1];
17295 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? atBreak(code) : nok(code);
17296 }
17297 /**
17298 * At a break.
17299 *
17300 * ```markdown
17301 * > | aaa
17302 * ^ ^
17303 * ```
17304 *
17305 * @type {State}
17306 */
17307 function atBreak(code) {
17308 if (code === null) return after(code);
17309 if (markdownLineEnding(code)) return effects.attempt(furtherStart, atBreak, after)(code);
17310 effects.enter("codeFlowValue");
17311 return inside(code);
17312 }
17313 /**
17314 * In code content.
17315 *
17316 * ```markdown
17317 * > | aaa
17318 * ^^^^
17319 * ```
17320 *
17321 * @type {State}
17322 */
17323 function inside(code) {
17324 if (code === null || markdownLineEnding(code)) {
17325 effects.exit("codeFlowValue");
17326 return atBreak(code);
17327 }
17328 effects.consume(code);
17329 return inside;
17330 }
17331 /** @type {State} */
17332 function after(code) {
17333 effects.exit("codeIndented");
17334 return ok(code);
17335 }
17336 }
17337 /**
17338 * @this {TokenizeContext}
17339 * @type {Tokenizer}
17340 */
17341 function tokenizeFurtherStart(effects, ok, nok) {
17342 const self = this;
17343 return furtherStart;
17344 /**
17345 * At eol, trying to parse another indent.
17346 *
17347 * ```markdown
17348 * > | aaa
17349 * ^
17350 * | bbb
17351 * ```
17352 *
17353 * @type {State}
17354 */
17355 function furtherStart(code) {
17356 if (self.parser.lazy[self.now().line]) return nok(code);
17357 if (markdownLineEnding(code)) {
17358 effects.enter("lineEnding");
17359 effects.consume(code);
17360 effects.exit("lineEnding");
17361 return furtherStart;
17362 }
17363 return factorySpace(effects, afterPrefix, "linePrefix", 5)(code);
17364 }
17365 /**
17366 * At start, after 1 or 4 spaces.
17367 *
17368 * ```markdown
17369 * > | aaa
17370 * ^
17371 * ```
17372 *
17373 * @type {State}
17374 */
17375 function afterPrefix(code) {
17376 const tail = self.events[self.events.length - 1];
17377 return tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4 ? ok(code) : markdownLineEnding(code) ? furtherStart(code) : nok(code);
17378 }
17379 }
17380 var codeIndented, furtherStart;
17381 var init_code_indented = __esmMin((() => {
17382 init_micromark_factory_space();
17383 init_micromark_util_character();
17384 codeIndented = {
17385 name: "codeIndented",
17386 tokenize: tokenizeCodeIndented
17387 };
17388 furtherStart = {
17389 tokenize: tokenizeFurtherStart,
17390 partial: true
17391 };
17392 }));
17393
17394 //#endregion
17395 //#region node_modules/micromark-core-commonmark/lib/code-text.js
17396 /** @type {Resolver} */
17397 function resolveCodeText(events) {
17398 let tailExitIndex = events.length - 4;
17399 let headEnterIndex = 3;
17400 /** @type {number} */
17401 let index;
17402 /** @type {number | undefined} */
17403 let enter;
17404 if ((events[headEnterIndex][1].type === "lineEnding" || events[headEnterIndex][1].type === "space") && (events[tailExitIndex][1].type === "lineEnding" || events[tailExitIndex][1].type === "space")) {
17405 index = headEnterIndex;
17406 while (++index < tailExitIndex) if (events[index][1].type === "codeTextData") {
17407 events[headEnterIndex][1].type = "codeTextPadding";
17408 events[tailExitIndex][1].type = "codeTextPadding";
17409 headEnterIndex += 2;
17410 tailExitIndex -= 2;
17411 break;
17412 }
17413 }
17414 index = headEnterIndex - 1;
17415 tailExitIndex++;
17416 while (++index <= tailExitIndex) if (enter === void 0) {
17417 if (index !== tailExitIndex && events[index][1].type !== "lineEnding") enter = index;
17418 } else if (index === tailExitIndex || events[index][1].type === "lineEnding") {
17419 events[enter][1].type = "codeTextData";
17420 if (index !== enter + 2) {
17421 events[enter][1].end = events[index - 1][1].end;
17422 events.splice(enter + 2, index - enter - 2);
17423 tailExitIndex -= index - enter - 2;
17424 index = enter + 2;
17425 }
17426 enter = void 0;
17427 }
17428 return events;
17429 }
17430 /**
17431 * @this {TokenizeContext}
17432 * @type {Previous}
17433 */
17434 function previous(code) {
17435 return code !== 96 || this.events[this.events.length - 1][1].type === "characterEscape";
17436 }
17437 /**
17438 * @this {TokenizeContext}
17439 * @type {Tokenizer}
17440 */
17441 function tokenizeCodeText(effects, ok, nok) {
17442 let sizeOpen = 0;
17443 /** @type {number} */
17444 let size;
17445 /** @type {Token} */
17446 let token;
17447 return start;
17448 /**
17449 * Start of code (text).
17450 *
17451 * ```markdown
17452 * > | `a`
17453 * ^
17454 * > | \`a`
17455 * ^
17456 * ```
17457 *
17458 * @type {State}
17459 */
17460 function start(code) {
17461 effects.enter("codeText");
17462 effects.enter("codeTextSequence");
17463 return sequenceOpen(code);
17464 }
17465 /**
17466 * In opening sequence.
17467 *
17468 * ```markdown
17469 * > | `a`
17470 * ^
17471 * ```
17472 *
17473 * @type {State}
17474 */
17475 function sequenceOpen(code) {
17476 if (code === 96) {
17477 effects.consume(code);
17478 sizeOpen++;
17479 return sequenceOpen;
17480 }
17481 effects.exit("codeTextSequence");
17482 return between(code);
17483 }
17484 /**
17485 * Between something and something else.
17486 *
17487 * ```markdown
17488 * > | `a`
17489 * ^^
17490 * ```
17491 *
17492 * @type {State}
17493 */
17494 function between(code) {
17495 if (code === null) return nok(code);
17496 if (code === 32) {
17497 effects.enter("space");
17498 effects.consume(code);
17499 effects.exit("space");
17500 return between;
17501 }
17502 if (code === 96) {
17503 token = effects.enter("codeTextSequence");
17504 size = 0;
17505 return sequenceClose(code);
17506 }
17507 if (markdownLineEnding(code)) {
17508 effects.enter("lineEnding");
17509 effects.consume(code);
17510 effects.exit("lineEnding");
17511 return between;
17512 }
17513 effects.enter("codeTextData");
17514 return data(code);
17515 }
17516 /**
17517 * In data.
17518 *
17519 * ```markdown
17520 * > | `a`
17521 * ^
17522 * ```
17523 *
17524 * @type {State}
17525 */
17526 function data(code) {
17527 if (code === null || code === 32 || code === 96 || markdownLineEnding(code)) {
17528 effects.exit("codeTextData");
17529 return between(code);
17530 }
17531 effects.consume(code);
17532 return data;
17533 }
17534 /**
17535 * In closing sequence.
17536 *
17537 * ```markdown
17538 * > | `a`
17539 * ^
17540 * ```
17541 *
17542 * @type {State}
17543 */
17544 function sequenceClose(code) {
17545 if (code === 96) {
17546 effects.consume(code);
17547 size++;
17548 return sequenceClose;
17549 }
17550 if (size === sizeOpen) {
17551 effects.exit("codeTextSequence");
17552 effects.exit("codeText");
17553 return ok(code);
17554 }
17555 token.type = "codeTextData";
17556 return data(code);
17557 }
17558 }
17559 var codeText;
17560 var init_code_text = __esmMin((() => {
17561 init_micromark_util_character();
17562 codeText = {
17563 name: "codeText",
17564 tokenize: tokenizeCodeText,
17565 resolve: resolveCodeText,
17566 previous
17567 };
17568 }));
17569
17570 //#endregion
17571 //#region node_modules/micromark-util-subtokenize/index.js
17572 /**
17573 * Tokenize subcontent.
17574 *
17575 * @param {Array<Event>} events
17576 * List of events.
17577 * @returns {boolean}
17578 * Whether subtokens were found.
17579 */
17580 function subtokenize(events) {
17581 /** @type {Record<string, number>} */
17582 const jumps = {};
17583 let index = -1;
17584 /** @type {Event} */
17585 let event;
17586 /** @type {number | undefined} */
17587 let lineIndex;
17588 /** @type {number} */
17589 let otherIndex;
17590 /** @type {Event} */
17591 let otherEvent;
17592 /** @type {Array<Event>} */
17593 let parameters;
17594 /** @type {Array<Event>} */
17595 let subevents;
17596 /** @type {boolean | undefined} */
17597 let more;
17598 while (++index < events.length) {
17599 while (index in jumps) index = jumps[index];
17600 event = events[index];
17601 if (index && event[1].type === "chunkFlow" && events[index - 1][1].type === "listItemPrefix") {
17602 subevents = event[1]._tokenizer.events;
17603 otherIndex = 0;
17604 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "lineEndingBlank") otherIndex += 2;
17605 if (otherIndex < subevents.length && subevents[otherIndex][1].type === "content") while (++otherIndex < subevents.length) {
17606 if (subevents[otherIndex][1].type === "content") break;
17607 if (subevents[otherIndex][1].type === "chunkText") {
17608 subevents[otherIndex][1]._isInFirstContentOfListItem = true;
17609 otherIndex++;
17610 }
17611 }
17612 }
17613 if (event[0] === "enter") {
17614 if (event[1].contentType) {
17615 Object.assign(jumps, subcontent(events, index));
17616 index = jumps[index];
17617 more = true;
17618 }
17619 } else if (event[1]._container) {
17620 otherIndex = index;
17621 lineIndex = void 0;
17622 while (otherIndex--) {
17623 otherEvent = events[otherIndex];
17624 if (otherEvent[1].type === "lineEnding" || otherEvent[1].type === "lineEndingBlank") {
17625 if (otherEvent[0] === "enter") {
17626 if (lineIndex) events[lineIndex][1].type = "lineEndingBlank";
17627 otherEvent[1].type = "lineEnding";
17628 lineIndex = otherIndex;
17629 }
17630 } else break;
17631 }
17632 if (lineIndex) {
17633 event[1].end = Object.assign({}, events[lineIndex][1].start);
17634 parameters = events.slice(lineIndex, index);
17635 parameters.unshift(event);
17636 splice(events, lineIndex, index - lineIndex + 1, parameters);
17637 }
17638 }
17639 }
17640 return !more;
17641 }
17642 /**
17643 * Tokenize embedded tokens.
17644 *
17645 * @param {Array<Event>} events
17646 * @param {number} eventIndex
17647 * @returns {Record<string, number>}
17648 */
17649 function subcontent(events, eventIndex) {
17650 const token = events[eventIndex][1];
17651 const context = events[eventIndex][2];
17652 let startPosition = eventIndex - 1;
17653 /** @type {Array<number>} */
17654 const startPositions = [];
17655 const tokenizer = token._tokenizer || context.parser[token.contentType](token.start);
17656 const childEvents = tokenizer.events;
17657 /** @type {Array<[number, number]>} */
17658 const jumps = [];
17659 /** @type {Record<string, number>} */
17660 const gaps = {};
17661 /** @type {Array<Chunk>} */
17662 let stream;
17663 /** @type {Token | undefined} */
17664 let previous;
17665 let index = -1;
17666 /** @type {Token | undefined} */
17667 let current = token;
17668 let adjust = 0;
17669 let start = 0;
17670 const breaks = [start];
17671 while (current) {
17672 while (events[++startPosition][1] !== current);
17673 startPositions.push(startPosition);
17674 if (!current._tokenizer) {
17675 stream = context.sliceStream(current);
17676 if (!current.next) stream.push(null);
17677 if (previous) tokenizer.defineSkip(current.start);
17678 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = true;
17679 tokenizer.write(stream);
17680 if (current._isInFirstContentOfListItem) tokenizer._gfmTasklistFirstContentOfListItem = void 0;
17681 }
17682 previous = current;
17683 current = current.next;
17684 }
17685 current = token;
17686 while (++index < childEvents.length) if (childEvents[index][0] === "exit" && childEvents[index - 1][0] === "enter" && childEvents[index][1].type === childEvents[index - 1][1].type && childEvents[index][1].start.line !== childEvents[index][1].end.line) {
17687 start = index + 1;
17688 breaks.push(start);
17689 current._tokenizer = void 0;
17690 current.previous = void 0;
17691 current = current.next;
17692 }
17693 tokenizer.events = [];
17694 if (current) {
17695 current._tokenizer = void 0;
17696 current.previous = void 0;
17697 } else breaks.pop();
17698 index = breaks.length;
17699 while (index--) {
17700 const slice = childEvents.slice(breaks[index], breaks[index + 1]);
17701 const start = startPositions.pop();
17702 jumps.unshift([start, start + slice.length - 1]);
17703 splice(events, start, 2, slice);
17704 }
17705 index = -1;
17706 while (++index < jumps.length) {
17707 gaps[adjust + jumps[index][0]] = adjust + jumps[index][1];
17708 adjust += jumps[index][1] - jumps[index][0] - 1;
17709 }
17710 return gaps;
17711 }
17712 var init_micromark_util_subtokenize = __esmMin((() => {
17713 init_micromark_util_chunked();
17714 }));
17715
17716 //#endregion
17717 //#region node_modules/micromark-core-commonmark/lib/content.js
17718 /**
17719 * Content is transparent: it’s parsed right now. That way, definitions are also
17720 * parsed right now: before text in paragraphs (specifically, media) are parsed.
17721 *
17722 * @type {Resolver}
17723 */
17724 function resolveContent(events) {
17725 subtokenize(events);
17726 return events;
17727 }
17728 /**
17729 * @this {TokenizeContext}
17730 * @type {Tokenizer}
17731 */
17732 function tokenizeContent(effects, ok) {
17733 /** @type {Token | undefined} */
17734 let previous;
17735 return chunkStart;
17736 /**
17737 * Before a content chunk.
17738 *
17739 * ```markdown
17740 * > | abc
17741 * ^
17742 * ```
17743 *
17744 * @type {State}
17745 */
17746 function chunkStart(code) {
17747 effects.enter("content");
17748 previous = effects.enter("chunkContent", { contentType: "content" });
17749 return chunkInside(code);
17750 }
17751 /**
17752 * In a content chunk.
17753 *
17754 * ```markdown
17755 * > | abc
17756 * ^^^
17757 * ```
17758 *
17759 * @type {State}
17760 */
17761 function chunkInside(code) {
17762 if (code === null) return contentEnd(code);
17763 if (markdownLineEnding(code)) return effects.check(continuationConstruct, contentContinue, contentEnd)(code);
17764 effects.consume(code);
17765 return chunkInside;
17766 }
17767 /**
17768 *
17769 *
17770 * @type {State}
17771 */
17772 function contentEnd(code) {
17773 effects.exit("chunkContent");
17774 effects.exit("content");
17775 return ok(code);
17776 }
17777 /**
17778 *
17779 *
17780 * @type {State}
17781 */
17782 function contentContinue(code) {
17783 effects.consume(code);
17784 effects.exit("chunkContent");
17785 previous.next = effects.enter("chunkContent", {
17786 contentType: "content",
17787 previous
17788 });
17789 previous = previous.next;
17790 return chunkInside;
17791 }
17792 }
17793 /**
17794 * @this {TokenizeContext}
17795 * @type {Tokenizer}
17796 */
17797 function tokenizeContinuation(effects, ok, nok) {
17798 const self = this;
17799 return startLookahead;
17800 /**
17801 *
17802 *
17803 * @type {State}
17804 */
17805 function startLookahead(code) {
17806 effects.exit("chunkContent");
17807 effects.enter("lineEnding");
17808 effects.consume(code);
17809 effects.exit("lineEnding");
17810 return factorySpace(effects, prefixed, "linePrefix");
17811 }
17812 /**
17813 *
17814 *
17815 * @type {State}
17816 */
17817 function prefixed(code) {
17818 if (code === null || markdownLineEnding(code)) return nok(code);
17819 const tail = self.events[self.events.length - 1];
17820 if (!self.parser.constructs.disable.null.includes("codeIndented") && tail && tail[1].type === "linePrefix" && tail[2].sliceSerialize(tail[1], true).length >= 4) return ok(code);
17821 return effects.interrupt(self.parser.constructs.flow, nok, ok)(code);
17822 }
17823 }
17824 var content, continuationConstruct;
17825 var init_content = __esmMin((() => {
17826 init_micromark_factory_space();
17827 init_micromark_util_character();
17828 init_micromark_util_subtokenize();
17829 content = {
17830 tokenize: tokenizeContent,
17831 resolve: resolveContent
17832 };
17833 continuationConstruct = {
17834 tokenize: tokenizeContinuation,
17835 partial: true
17836 };
17837 }));
17838
17839 //#endregion
17840 //#region node_modules/micromark-factory-destination/index.js
17841 /**
17842 * Parse destinations.
17843 *
17844 * ###### Examples
17845 *
17846 * ```markdown
17847 * <a>
17848 * <a\>b>
17849 * <a b>
17850 * <a)>
17851 * a
17852 * a\)b
17853 * a(b)c
17854 * a(b)
17855 * ```
17856 *
17857 * @param {Effects} effects
17858 * Context.
17859 * @param {State} ok
17860 * State switched to when successful.
17861 * @param {State} nok
17862 * State switched to when unsuccessful.
17863 * @param {TokenType} type
17864 * Type for whole (`<a>` or `b`).
17865 * @param {TokenType} literalType
17866 * Type when enclosed (`<a>`).
17867 * @param {TokenType} literalMarkerType
17868 * Type for enclosing (`<` and `>`).
17869 * @param {TokenType} rawType
17870 * Type when not enclosed (`b`).
17871 * @param {TokenType} stringType
17872 * Type for the value (`a` or `b`).
17873 * @param {number | undefined} [max=Infinity]
17874 * Depth of nested parens (inclusive).
17875 * @returns {State}
17876 * Start state.
17877 */ function factoryDestination(effects, ok, nok, type, literalType, literalMarkerType, rawType, stringType, max) {
17878 const limit = max || Number.POSITIVE_INFINITY;
17879 let balance = 0;
17880 return start;
17881 /**
17882 * Start of destination.
17883 *
17884 * ```markdown
17885 * > | <aa>
17886 * ^
17887 * > | aa
17888 * ^
17889 * ```
17890 *
17891 * @type {State}
17892 */
17893 function start(code) {
17894 if (code === 60) {
17895 effects.enter(type);
17896 effects.enter(literalType);
17897 effects.enter(literalMarkerType);
17898 effects.consume(code);
17899 effects.exit(literalMarkerType);
17900 return enclosedBefore;
17901 }
17902 if (code === null || code === 32 || code === 41 || asciiControl(code)) return nok(code);
17903 effects.enter(type);
17904 effects.enter(rawType);
17905 effects.enter(stringType);
17906 effects.enter("chunkString", { contentType: "string" });
17907 return raw(code);
17908 }
17909 /**
17910 * After `<`, at an enclosed destination.
17911 *
17912 * ```markdown
17913 * > | <aa>
17914 * ^
17915 * ```
17916 *
17917 * @type {State}
17918 */
17919 function enclosedBefore(code) {
17920 if (code === 62) {
17921 effects.enter(literalMarkerType);
17922 effects.consume(code);
17923 effects.exit(literalMarkerType);
17924 effects.exit(literalType);
17925 effects.exit(type);
17926 return ok;
17927 }
17928 effects.enter(stringType);
17929 effects.enter("chunkString", { contentType: "string" });
17930 return enclosed(code);
17931 }
17932 /**
17933 * In enclosed destination.
17934 *
17935 * ```markdown
17936 * > | <aa>
17937 * ^
17938 * ```
17939 *
17940 * @type {State}
17941 */
17942 function enclosed(code) {
17943 if (code === 62) {
17944 effects.exit("chunkString");
17945 effects.exit(stringType);
17946 return enclosedBefore(code);
17947 }
17948 if (code === null || code === 60 || markdownLineEnding(code)) return nok(code);
17949 effects.consume(code);
17950 return code === 92 ? enclosedEscape : enclosed;
17951 }
17952 /**
17953 * After `\`, at a special character.
17954 *
17955 * ```markdown
17956 * > | <a\*a>
17957 * ^
17958 * ```
17959 *
17960 * @type {State}
17961 */
17962 function enclosedEscape(code) {
17963 if (code === 60 || code === 62 || code === 92) {
17964 effects.consume(code);
17965 return enclosed;
17966 }
17967 return enclosed(code);
17968 }
17969 /**
17970 * In raw destination.
17971 *
17972 * ```markdown
17973 * > | aa
17974 * ^
17975 * ```
17976 *
17977 * @type {State}
17978 */
17979 function raw(code) {
17980 if (!balance && (code === null || code === 41 || markdownLineEndingOrSpace(code))) {
17981 effects.exit("chunkString");
17982 effects.exit(stringType);
17983 effects.exit(rawType);
17984 effects.exit(type);
17985 return ok(code);
17986 }
17987 if (balance < limit && code === 40) {
17988 effects.consume(code);
17989 balance++;
17990 return raw;
17991 }
17992 if (code === 41) {
17993 effects.consume(code);
17994 balance--;
17995 return raw;
17996 }
17997 if (code === null || code === 32 || code === 40 || asciiControl(code)) return nok(code);
17998 effects.consume(code);
17999 return code === 92 ? rawEscape : raw;
18000 }
18001 /**
18002 * After `\`, at special character.
18003 *
18004 * ```markdown
18005 * > | a\*a
18006 * ^
18007 * ```
18008 *
18009 * @type {State}
18010 */
18011 function rawEscape(code) {
18012 if (code === 40 || code === 41 || code === 92) {
18013 effects.consume(code);
18014 return raw;
18015 }
18016 return raw(code);
18017 }
18018 }
18019 var init_micromark_factory_destination = __esmMin((() => {
18020 init_micromark_util_character();
18021 }));
18022
18023 //#endregion
18024 //#region node_modules/micromark-factory-label/index.js
18025 /**
18026 * Parse labels.
18027 *
18028 * > 👉 **Note**: labels in markdown are capped at 999 characters in the string.
18029 *
18030 * ###### Examples
18031 *
18032 * ```markdown
18033 * [a]
18034 * [a
18035 * b]
18036 * [a\]b]
18037 * ```
18038 *
18039 * @this {TokenizeContext}
18040 * Tokenize context.
18041 * @param {Effects} effects
18042 * Context.
18043 * @param {State} ok
18044 * State switched to when successful.
18045 * @param {State} nok
18046 * State switched to when unsuccessful.
18047 * @param {TokenType} type
18048 * Type of the whole label (`[a]`).
18049 * @param {TokenType} markerType
18050 * Type for the markers (`[` and `]`).
18051 * @param {TokenType} stringType
18052 * Type for the identifier (`a`).
18053 * @returns {State}
18054 * Start state.
18055 */ function factoryLabel(effects, ok, nok, type, markerType, stringType) {
18056 const self = this;
18057 let size = 0;
18058 /** @type {boolean} */
18059 let seen;
18060 return start;
18061 /**
18062 * Start of label.
18063 *
18064 * ```markdown
18065 * > | [a]
18066 * ^
18067 * ```
18068 *
18069 * @type {State}
18070 */
18071 function start(code) {
18072 effects.enter(type);
18073 effects.enter(markerType);
18074 effects.consume(code);
18075 effects.exit(markerType);
18076 effects.enter(stringType);
18077 return atBreak;
18078 }
18079 /**
18080 * In label, at something, before something else.
18081 *
18082 * ```markdown
18083 * > | [a]
18084 * ^
18085 * ```
18086 *
18087 * @type {State}
18088 */
18089 function atBreak(code) {
18090 if (size > 999 || code === null || code === 91 || code === 93 && !seen || code === 94 && !size && "_hiddenFootnoteSupport" in self.parser.constructs) return nok(code);
18091 if (code === 93) {
18092 effects.exit(stringType);
18093 effects.enter(markerType);
18094 effects.consume(code);
18095 effects.exit(markerType);
18096 effects.exit(type);
18097 return ok;
18098 }
18099 if (markdownLineEnding(code)) {
18100 effects.enter("lineEnding");
18101 effects.consume(code);
18102 effects.exit("lineEnding");
18103 return atBreak;
18104 }
18105 effects.enter("chunkString", { contentType: "string" });
18106 return labelInside(code);
18107 }
18108 /**
18109 * In label, in text.
18110 *
18111 * ```markdown
18112 * > | [a]
18113 * ^
18114 * ```
18115 *
18116 * @type {State}
18117 */
18118 function labelInside(code) {
18119 if (code === null || code === 91 || code === 93 || markdownLineEnding(code) || size++ > 999) {
18120 effects.exit("chunkString");
18121 return atBreak(code);
18122 }
18123 effects.consume(code);
18124 if (!seen) seen = !markdownSpace(code);
18125 return code === 92 ? labelEscape : labelInside;
18126 }
18127 /**
18128 * After `\`, at a special character.
18129 *
18130 * ```markdown
18131 * > | [a\*a]
18132 * ^
18133 * ```
18134 *
18135 * @type {State}
18136 */
18137 function labelEscape(code) {
18138 if (code === 91 || code === 92 || code === 93) {
18139 effects.consume(code);
18140 size++;
18141 return labelInside;
18142 }
18143 return labelInside(code);
18144 }
18145 }
18146 var init_micromark_factory_label = __esmMin((() => {
18147 init_micromark_util_character();
18148 }));
18149
18150 //#endregion
18151 //#region node_modules/micromark-factory-title/index.js
18152 /**
18153 * Parse titles.
18154 *
18155 * ###### Examples
18156 *
18157 * ```markdown
18158 * "a"
18159 * 'b'
18160 * (c)
18161 * "a
18162 * b"
18163 * 'a
18164 * b'
18165 * (a\)b)
18166 * ```
18167 *
18168 * @param {Effects} effects
18169 * Context.
18170 * @param {State} ok
18171 * State switched to when successful.
18172 * @param {State} nok
18173 * State switched to when unsuccessful.
18174 * @param {TokenType} type
18175 * Type of the whole title (`"a"`, `'b'`, `(c)`).
18176 * @param {TokenType} markerType
18177 * Type for the markers (`"`, `'`, `(`, and `)`).
18178 * @param {TokenType} stringType
18179 * Type for the value (`a`).
18180 * @returns {State}
18181 * Start state.
18182 */ function factoryTitle(effects, ok, nok, type, markerType, stringType) {
18183 /** @type {NonNullable<Code>} */
18184 let marker;
18185 return start;
18186 /**
18187 * Start of title.
18188 *
18189 * ```markdown
18190 * > | "a"
18191 * ^
18192 * ```
18193 *
18194 * @type {State}
18195 */
18196 function start(code) {
18197 if (code === 34 || code === 39 || code === 40) {
18198 effects.enter(type);
18199 effects.enter(markerType);
18200 effects.consume(code);
18201 effects.exit(markerType);
18202 marker = code === 40 ? 41 : code;
18203 return begin;
18204 }
18205 return nok(code);
18206 }
18207 /**
18208 * After opening marker.
18209 *
18210 * This is also used at the closing marker.
18211 *
18212 * ```markdown
18213 * > | "a"
18214 * ^
18215 * ```
18216 *
18217 * @type {State}
18218 */
18219 function begin(code) {
18220 if (code === marker) {
18221 effects.enter(markerType);
18222 effects.consume(code);
18223 effects.exit(markerType);
18224 effects.exit(type);
18225 return ok;
18226 }
18227 effects.enter(stringType);
18228 return atBreak(code);
18229 }
18230 /**
18231 * At something, before something else.
18232 *
18233 * ```markdown
18234 * > | "a"
18235 * ^
18236 * ```
18237 *
18238 * @type {State}
18239 */
18240 function atBreak(code) {
18241 if (code === marker) {
18242 effects.exit(stringType);
18243 return begin(marker);
18244 }
18245 if (code === null) return nok(code);
18246 if (markdownLineEnding(code)) {
18247 effects.enter("lineEnding");
18248 effects.consume(code);
18249 effects.exit("lineEnding");
18250 return factorySpace(effects, atBreak, "linePrefix");
18251 }
18252 effects.enter("chunkString", { contentType: "string" });
18253 return inside(code);
18254 }
18255 /**
18256 *
18257 *
18258 * @type {State}
18259 */
18260 function inside(code) {
18261 if (code === marker || code === null || markdownLineEnding(code)) {
18262 effects.exit("chunkString");
18263 return atBreak(code);
18264 }
18265 effects.consume(code);
18266 return code === 92 ? escape : inside;
18267 }
18268 /**
18269 * After `\`, at a special character.
18270 *
18271 * ```markdown
18272 * > | "a\*b"
18273 * ^
18274 * ```
18275 *
18276 * @type {State}
18277 */
18278 function escape(code) {
18279 if (code === marker || code === 92) {
18280 effects.consume(code);
18281 return inside;
18282 }
18283 return inside(code);
18284 }
18285 }
18286 var init_micromark_factory_title = __esmMin((() => {
18287 init_micromark_factory_space();
18288 init_micromark_util_character();
18289 }));
18290
18291 //#endregion
18292 //#region node_modules/micromark-factory-whitespace/index.js
18293 /**
18294 * Parse spaces and tabs.
18295 *
18296 * There is no `nok` parameter:
18297 *
18298 * * line endings or spaces in markdown are often optional, in which case this
18299 * factory can be used and `ok` will be switched to whether spaces were found
18300 * or not
18301 * * one line ending or space can be detected with
18302 * `markdownLineEndingOrSpace(code)` right before using `factoryWhitespace`
18303 *
18304 * @param {Effects} effects
18305 * Context.
18306 * @param {State} ok
18307 * State switched to when successful.
18308 * @returns
18309 * Start state.
18310 */
18311 function factoryWhitespace(effects, ok) {
18312 /** @type {boolean} */
18313 let seen;
18314 return start;
18315 /** @type {State} */
18316 function start(code) {
18317 if (markdownLineEnding(code)) {
18318 effects.enter("lineEnding");
18319 effects.consume(code);
18320 effects.exit("lineEnding");
18321 seen = true;
18322 return start;
18323 }
18324 if (markdownSpace(code)) return factorySpace(effects, start, seen ? "linePrefix" : "lineSuffix")(code);
18325 return ok(code);
18326 }
18327 }
18328 var init_micromark_factory_whitespace = __esmMin((() => {
18329 init_micromark_factory_space();
18330 init_micromark_util_character();
18331 }));
18332
18333 //#endregion
18334 //#region node_modules/micromark-util-normalize-identifier/index.js
18335 /**
18336 * Normalize an identifier (as found in references, definitions).
18337 *
18338 * Collapses markdown whitespace, trim, and then lower- and uppercase.
18339 *
18340 * Some characters are considered “uppercase”, such as U+03F4 (`ϴ`), but if their
18341 * lowercase counterpart (U+03B8 (`θ`)) is uppercased will result in a different
18342 * uppercase character (U+0398 (`Θ`)).
18343 * So, to get a canonical form, we perform both lower- and uppercase.
18344 *
18345 * Using uppercase last makes sure keys will never interact with default
18346 * prototypal values (such as `constructor`): nothing in the prototype of
18347 * `Object` is uppercase.
18348 *
18349 * @param {string} value
18350 * Identifier to normalize.
18351 * @returns {string}
18352 * Normalized identifier.
18353 */
18354 function normalizeIdentifier(value) {
18355 return value.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
18356 }
18357 var init_micromark_util_normalize_identifier = __esmMin((() => {}));
18358
18359 //#endregion
18360 //#region node_modules/micromark-core-commonmark/lib/definition.js
18361 /**
18362 * @this {TokenizeContext}
18363 * @type {Tokenizer}
18364 */
18365 function tokenizeDefinition(effects, ok, nok) {
18366 const self = this;
18367 /** @type {string} */
18368 let identifier;
18369 return start;
18370 /**
18371 * At start of a definition.
18372 *
18373 * ```markdown
18374 * > | [a]: b "c"
18375 * ^
18376 * ```
18377 *
18378 * @type {State}
18379 */
18380 function start(code) {
18381 effects.enter("definition");
18382 return before(code);
18383 }
18384 /**
18385 * After optional whitespace, at `[`.
18386 *
18387 * ```markdown
18388 * > | [a]: b "c"
18389 * ^
18390 * ```
18391 *
18392 * @type {State}
18393 */
18394 function before(code) {
18395 return factoryLabel.call(self, effects, labelAfter, nok, "definitionLabel", "definitionLabelMarker", "definitionLabelString")(code);
18396 }
18397 /**
18398 * After label.
18399 *
18400 * ```markdown
18401 * > | [a]: b "c"
18402 * ^
18403 * ```
18404 *
18405 * @type {State}
18406 */
18407 function labelAfter(code) {
18408 identifier = normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1));
18409 if (code === 58) {
18410 effects.enter("definitionMarker");
18411 effects.consume(code);
18412 effects.exit("definitionMarker");
18413 return markerAfter;
18414 }
18415 return nok(code);
18416 }
18417 /**
18418 * After marker.
18419 *
18420 * ```markdown
18421 * > | [a]: b "c"
18422 * ^
18423 * ```
18424 *
18425 * @type {State}
18426 */
18427 function markerAfter(code) {
18428 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, destinationBefore)(code) : destinationBefore(code);
18429 }
18430 /**
18431 * Before destination.
18432 *
18433 * ```markdown
18434 * > | [a]: b "c"
18435 * ^
18436 * ```
18437 *
18438 * @type {State}
18439 */
18440 function destinationBefore(code) {
18441 return factoryDestination(effects, destinationAfter, nok, "definitionDestination", "definitionDestinationLiteral", "definitionDestinationLiteralMarker", "definitionDestinationRaw", "definitionDestinationString")(code);
18442 }
18443 /**
18444 * After destination.
18445 *
18446 * ```markdown
18447 * > | [a]: b "c"
18448 * ^
18449 * ```
18450 *
18451 * @type {State}
18452 */
18453 function destinationAfter(code) {
18454 return effects.attempt(titleBefore, after, after)(code);
18455 }
18456 /**
18457 * After definition.
18458 *
18459 * ```markdown
18460 * > | [a]: b
18461 * ^
18462 * > | [a]: b "c"
18463 * ^
18464 * ```
18465 *
18466 * @type {State}
18467 */
18468 function after(code) {
18469 return markdownSpace(code) ? factorySpace(effects, afterWhitespace, "whitespace")(code) : afterWhitespace(code);
18470 }
18471 /**
18472 * After definition, after optional whitespace.
18473 *
18474 * ```markdown
18475 * > | [a]: b
18476 * ^
18477 * > | [a]: b "c"
18478 * ^
18479 * ```
18480 *
18481 * @type {State}
18482 */
18483 function afterWhitespace(code) {
18484 if (code === null || markdownLineEnding(code)) {
18485 effects.exit("definition");
18486 self.parser.defined.push(identifier);
18487 return ok(code);
18488 }
18489 return nok(code);
18490 }
18491 }
18492 /**
18493 * @this {TokenizeContext}
18494 * @type {Tokenizer}
18495 */
18496 function tokenizeTitleBefore(effects, ok, nok) {
18497 return titleBefore;
18498 /**
18499 * After destination, at whitespace.
18500 *
18501 * ```markdown
18502 * > | [a]: b
18503 * ^
18504 * > | [a]: b "c"
18505 * ^
18506 * ```
18507 *
18508 * @type {State}
18509 */
18510 function titleBefore(code) {
18511 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, beforeMarker)(code) : nok(code);
18512 }
18513 /**
18514 * At title.
18515 *
18516 * ```markdown
18517 * | [a]: b
18518 * > | "c"
18519 * ^
18520 * ```
18521 *
18522 * @type {State}
18523 */
18524 function beforeMarker(code) {
18525 return factoryTitle(effects, titleAfter, nok, "definitionTitle", "definitionTitleMarker", "definitionTitleString")(code);
18526 }
18527 /**
18528 * After title.
18529 *
18530 * ```markdown
18531 * > | [a]: b "c"
18532 * ^
18533 * ```
18534 *
18535 * @type {State}
18536 */
18537 function titleAfter(code) {
18538 return markdownSpace(code) ? factorySpace(effects, titleAfterOptionalWhitespace, "whitespace")(code) : titleAfterOptionalWhitespace(code);
18539 }
18540 /**
18541 * After title, after optional whitespace.
18542 *
18543 * ```markdown
18544 * > | [a]: b "c"
18545 * ^
18546 * ```
18547 *
18548 * @type {State}
18549 */
18550 function titleAfterOptionalWhitespace(code) {
18551 return code === null || markdownLineEnding(code) ? ok(code) : nok(code);
18552 }
18553 }
18554 var definition, titleBefore;
18555 var init_definition = __esmMin((() => {
18556 init_micromark_factory_destination();
18557 init_micromark_factory_label();
18558 init_micromark_factory_space();
18559 init_micromark_factory_title();
18560 init_micromark_factory_whitespace();
18561 init_micromark_util_character();
18562 init_micromark_util_normalize_identifier();
18563 definition = {
18564 name: "definition",
18565 tokenize: tokenizeDefinition
18566 };
18567 titleBefore = {
18568 tokenize: tokenizeTitleBefore,
18569 partial: true
18570 };
18571 }));
18572
18573 //#endregion
18574 //#region node_modules/micromark-core-commonmark/lib/hard-break-escape.js
18575 /**
18576 * @this {TokenizeContext}
18577 * @type {Tokenizer}
18578 */
18579 function tokenizeHardBreakEscape(effects, ok, nok) {
18580 return start;
18581 /**
18582 * Start of a hard break (escape).
18583 *
18584 * ```markdown
18585 * > | a\
18586 * ^
18587 * | b
18588 * ```
18589 *
18590 * @type {State}
18591 */
18592 function start(code) {
18593 effects.enter("hardBreakEscape");
18594 effects.consume(code);
18595 return after;
18596 }
18597 /**
18598 * After `\`, at eol.
18599 *
18600 * ```markdown
18601 * > | a\
18602 * ^
18603 * | b
18604 * ```
18605 *
18606 * @type {State}
18607 */
18608 function after(code) {
18609 if (markdownLineEnding(code)) {
18610 effects.exit("hardBreakEscape");
18611 return ok(code);
18612 }
18613 return nok(code);
18614 }
18615 }
18616 var hardBreakEscape;
18617 var init_hard_break_escape = __esmMin((() => {
18618 init_micromark_util_character();
18619 hardBreakEscape = {
18620 name: "hardBreakEscape",
18621 tokenize: tokenizeHardBreakEscape
18622 };
18623 }));
18624
18625 //#endregion
18626 //#region node_modules/micromark-core-commonmark/lib/heading-atx.js
18627 /** @type {Resolver} */
18628 function resolveHeadingAtx(events, context) {
18629 let contentEnd = events.length - 2;
18630 let contentStart = 3;
18631 /** @type {Token} */
18632 let content;
18633 /** @type {Token} */
18634 let text;
18635 if (events[contentStart][1].type === "whitespace") contentStart += 2;
18636 if (contentEnd - 2 > contentStart && events[contentEnd][1].type === "whitespace") contentEnd -= 2;
18637 if (events[contentEnd][1].type === "atxHeadingSequence" && (contentStart === contentEnd - 1 || contentEnd - 4 > contentStart && events[contentEnd - 2][1].type === "whitespace")) contentEnd -= contentStart + 1 === contentEnd ? 2 : 4;
18638 if (contentEnd > contentStart) {
18639 content = {
18640 type: "atxHeadingText",
18641 start: events[contentStart][1].start,
18642 end: events[contentEnd][1].end
18643 };
18644 text = {
18645 type: "chunkText",
18646 start: events[contentStart][1].start,
18647 end: events[contentEnd][1].end,
18648 contentType: "text"
18649 };
18650 splice(events, contentStart, contentEnd - contentStart + 1, [
18651 [
18652 "enter",
18653 content,
18654 context
18655 ],
18656 [
18657 "enter",
18658 text,
18659 context
18660 ],
18661 [
18662 "exit",
18663 text,
18664 context
18665 ],
18666 [
18667 "exit",
18668 content,
18669 context
18670 ]
18671 ]);
18672 }
18673 return events;
18674 }
18675 /**
18676 * @this {TokenizeContext}
18677 * @type {Tokenizer}
18678 */
18679 function tokenizeHeadingAtx(effects, ok, nok) {
18680 let size = 0;
18681 return start;
18682 /**
18683 * Start of a heading (atx).
18684 *
18685 * ```markdown
18686 * > | ## aa
18687 * ^
18688 * ```
18689 *
18690 * @type {State}
18691 */
18692 function start(code) {
18693 effects.enter("atxHeading");
18694 return before(code);
18695 }
18696 /**
18697 * After optional whitespace, at `#`.
18698 *
18699 * ```markdown
18700 * > | ## aa
18701 * ^
18702 * ```
18703 *
18704 * @type {State}
18705 */
18706 function before(code) {
18707 effects.enter("atxHeadingSequence");
18708 return sequenceOpen(code);
18709 }
18710 /**
18711 * In opening sequence.
18712 *
18713 * ```markdown
18714 * > | ## aa
18715 * ^
18716 * ```
18717 *
18718 * @type {State}
18719 */
18720 function sequenceOpen(code) {
18721 if (code === 35 && size++ < 6) {
18722 effects.consume(code);
18723 return sequenceOpen;
18724 }
18725 if (code === null || markdownLineEndingOrSpace(code)) {
18726 effects.exit("atxHeadingSequence");
18727 return atBreak(code);
18728 }
18729 return nok(code);
18730 }
18731 /**
18732 * After something, before something else.
18733 *
18734 * ```markdown
18735 * > | ## aa
18736 * ^
18737 * ```
18738 *
18739 * @type {State}
18740 */
18741 function atBreak(code) {
18742 if (code === 35) {
18743 effects.enter("atxHeadingSequence");
18744 return sequenceFurther(code);
18745 }
18746 if (code === null || markdownLineEnding(code)) {
18747 effects.exit("atxHeading");
18748 return ok(code);
18749 }
18750 if (markdownSpace(code)) return factorySpace(effects, atBreak, "whitespace")(code);
18751 effects.enter("atxHeadingText");
18752 return data(code);
18753 }
18754 /**
18755 * In further sequence (after whitespace).
18756 *
18757 * Could be normal “visible” hashes in the heading or a final sequence.
18758 *
18759 * ```markdown
18760 * > | ## aa ##
18761 * ^
18762 * ```
18763 *
18764 * @type {State}
18765 */
18766 function sequenceFurther(code) {
18767 if (code === 35) {
18768 effects.consume(code);
18769 return sequenceFurther;
18770 }
18771 effects.exit("atxHeadingSequence");
18772 return atBreak(code);
18773 }
18774 /**
18775 * In text.
18776 *
18777 * ```markdown
18778 * > | ## aa
18779 * ^
18780 * ```
18781 *
18782 * @type {State}
18783 */
18784 function data(code) {
18785 if (code === null || code === 35 || markdownLineEndingOrSpace(code)) {
18786 effects.exit("atxHeadingText");
18787 return atBreak(code);
18788 }
18789 effects.consume(code);
18790 return data;
18791 }
18792 }
18793 var headingAtx;
18794 var init_heading_atx = __esmMin((() => {
18795 init_micromark_factory_space();
18796 init_micromark_util_character();
18797 init_micromark_util_chunked();
18798 headingAtx = {
18799 name: "headingAtx",
18800 tokenize: tokenizeHeadingAtx,
18801 resolve: resolveHeadingAtx
18802 };
18803 }));
18804
18805 //#endregion
18806 //#region node_modules/micromark-util-html-tag-name/index.js
18807 var htmlBlockNames, htmlRawNames;
18808 var init_micromark_util_html_tag_name = __esmMin((() => {
18809 htmlBlockNames = [
18810 "address",
18811 "article",
18812 "aside",
18813 "base",
18814 "basefont",
18815 "blockquote",
18816 "body",
18817 "caption",
18818 "center",
18819 "col",
18820 "colgroup",
18821 "dd",
18822 "details",
18823 "dialog",
18824 "dir",
18825 "div",
18826 "dl",
18827 "dt",
18828 "fieldset",
18829 "figcaption",
18830 "figure",
18831 "footer",
18832 "form",
18833 "frame",
18834 "frameset",
18835 "h1",
18836 "h2",
18837 "h3",
18838 "h4",
18839 "h5",
18840 "h6",
18841 "head",
18842 "header",
18843 "hr",
18844 "html",
18845 "iframe",
18846 "legend",
18847 "li",
18848 "link",
18849 "main",
18850 "menu",
18851 "menuitem",
18852 "nav",
18853 "noframes",
18854 "ol",
18855 "optgroup",
18856 "option",
18857 "p",
18858 "param",
18859 "search",
18860 "section",
18861 "summary",
18862 "table",
18863 "tbody",
18864 "td",
18865 "tfoot",
18866 "th",
18867 "thead",
18868 "title",
18869 "tr",
18870 "track",
18871 "ul"
18872 ];
18873 htmlRawNames = [
18874 "pre",
18875 "script",
18876 "style",
18877 "textarea"
18878 ];
18879 }));
18880
18881 //#endregion
18882 //#region node_modules/micromark-core-commonmark/lib/html-flow.js
18883 /** @type {Resolver} */
18884 function resolveToHtmlFlow(events) {
18885 let index = events.length;
18886 while (index--) if (events[index][0] === "enter" && events[index][1].type === "htmlFlow") break;
18887 if (index > 1 && events[index - 2][1].type === "linePrefix") {
18888 events[index][1].start = events[index - 2][1].start;
18889 events[index + 1][1].start = events[index - 2][1].start;
18890 events.splice(index - 2, 2);
18891 }
18892 return events;
18893 }
18894 /**
18895 * @this {TokenizeContext}
18896 * @type {Tokenizer}
18897 */
18898 function tokenizeHtmlFlow(effects, ok, nok) {
18899 const self = this;
18900 /** @type {number} */
18901 let marker;
18902 /** @type {boolean} */
18903 let closingTag;
18904 /** @type {string} */
18905 let buffer;
18906 /** @type {number} */
18907 let index;
18908 /** @type {Code} */
18909 let markerB;
18910 return start;
18911 /**
18912 * Start of HTML (flow).
18913 *
18914 * ```markdown
18915 * > | <x />
18916 * ^
18917 * ```
18918 *
18919 * @type {State}
18920 */
18921 function start(code) {
18922 return before(code);
18923 }
18924 /**
18925 * At `<`, after optional whitespace.
18926 *
18927 * ```markdown
18928 * > | <x />
18929 * ^
18930 * ```
18931 *
18932 * @type {State}
18933 */
18934 function before(code) {
18935 effects.enter("htmlFlow");
18936 effects.enter("htmlFlowData");
18937 effects.consume(code);
18938 return open;
18939 }
18940 /**
18941 * After `<`, at tag name or other stuff.
18942 *
18943 * ```markdown
18944 * > | <x />
18945 * ^
18946 * > | <!doctype>
18947 * ^
18948 * > | <!--xxx-->
18949 * ^
18950 * ```
18951 *
18952 * @type {State}
18953 */
18954 function open(code) {
18955 if (code === 33) {
18956 effects.consume(code);
18957 return declarationOpen;
18958 }
18959 if (code === 47) {
18960 effects.consume(code);
18961 closingTag = true;
18962 return tagCloseStart;
18963 }
18964 if (code === 63) {
18965 effects.consume(code);
18966 marker = 3;
18967 return self.interrupt ? ok : continuationDeclarationInside;
18968 }
18969 if (asciiAlpha(code)) {
18970 effects.consume(code);
18971 buffer = String.fromCharCode(code);
18972 return tagName;
18973 }
18974 return nok(code);
18975 }
18976 /**
18977 * After `<!`, at declaration, comment, or CDATA.
18978 *
18979 * ```markdown
18980 * > | <!doctype>
18981 * ^
18982 * > | <!--xxx-->
18983 * ^
18984 * > | <![CDATA[>&<]]>
18985 * ^
18986 * ```
18987 *
18988 * @type {State}
18989 */
18990 function declarationOpen(code) {
18991 if (code === 45) {
18992 effects.consume(code);
18993 marker = 2;
18994 return commentOpenInside;
18995 }
18996 if (code === 91) {
18997 effects.consume(code);
18998 marker = 5;
18999 index = 0;
19000 return cdataOpenInside;
19001 }
19002 if (asciiAlpha(code)) {
19003 effects.consume(code);
19004 marker = 4;
19005 return self.interrupt ? ok : continuationDeclarationInside;
19006 }
19007 return nok(code);
19008 }
19009 /**
19010 * After `<!-`, inside a comment, at another `-`.
19011 *
19012 * ```markdown
19013 * > | <!--xxx-->
19014 * ^
19015 * ```
19016 *
19017 * @type {State}
19018 */
19019 function commentOpenInside(code) {
19020 if (code === 45) {
19021 effects.consume(code);
19022 return self.interrupt ? ok : continuationDeclarationInside;
19023 }
19024 return nok(code);
19025 }
19026 /**
19027 * After `<![`, inside CDATA, expecting `CDATA[`.
19028 *
19029 * ```markdown
19030 * > | <![CDATA[>&<]]>
19031 * ^^^^^^
19032 * ```
19033 *
19034 * @type {State}
19035 */
19036 function cdataOpenInside(code) {
19037 if (code === "CDATA[".charCodeAt(index++)) {
19038 effects.consume(code);
19039 if (index === 6) return self.interrupt ? ok : continuation;
19040 return cdataOpenInside;
19041 }
19042 return nok(code);
19043 }
19044 /**
19045 * After `</`, in closing tag, at tag name.
19046 *
19047 * ```markdown
19048 * > | </x>
19049 * ^
19050 * ```
19051 *
19052 * @type {State}
19053 */
19054 function tagCloseStart(code) {
19055 if (asciiAlpha(code)) {
19056 effects.consume(code);
19057 buffer = String.fromCharCode(code);
19058 return tagName;
19059 }
19060 return nok(code);
19061 }
19062 /**
19063 * In tag name.
19064 *
19065 * ```markdown
19066 * > | <ab>
19067 * ^^
19068 * > | </ab>
19069 * ^^
19070 * ```
19071 *
19072 * @type {State}
19073 */
19074 function tagName(code) {
19075 if (code === null || code === 47 || code === 62 || markdownLineEndingOrSpace(code)) {
19076 const slash = code === 47;
19077 const name = buffer.toLowerCase();
19078 if (!slash && !closingTag && htmlRawNames.includes(name)) {
19079 marker = 1;
19080 return self.interrupt ? ok(code) : continuation(code);
19081 }
19082 if (htmlBlockNames.includes(buffer.toLowerCase())) {
19083 marker = 6;
19084 if (slash) {
19085 effects.consume(code);
19086 return basicSelfClosing;
19087 }
19088 return self.interrupt ? ok(code) : continuation(code);
19089 }
19090 marker = 7;
19091 return self.interrupt && !self.parser.lazy[self.now().line] ? nok(code) : closingTag ? completeClosingTagAfter(code) : completeAttributeNameBefore(code);
19092 }
19093 if (code === 45 || asciiAlphanumeric(code)) {
19094 effects.consume(code);
19095 buffer += String.fromCharCode(code);
19096 return tagName;
19097 }
19098 return nok(code);
19099 }
19100 /**
19101 * After closing slash of a basic tag name.
19102 *
19103 * ```markdown
19104 * > | <div/>
19105 * ^
19106 * ```
19107 *
19108 * @type {State}
19109 */
19110 function basicSelfClosing(code) {
19111 if (code === 62) {
19112 effects.consume(code);
19113 return self.interrupt ? ok : continuation;
19114 }
19115 return nok(code);
19116 }
19117 /**
19118 * After closing slash of a complete tag name.
19119 *
19120 * ```markdown
19121 * > | <x/>
19122 * ^
19123 * ```
19124 *
19125 * @type {State}
19126 */
19127 function completeClosingTagAfter(code) {
19128 if (markdownSpace(code)) {
19129 effects.consume(code);
19130 return completeClosingTagAfter;
19131 }
19132 return completeEnd(code);
19133 }
19134 /**
19135 * At an attribute name.
19136 *
19137 * At first, this state is used after a complete tag name, after whitespace,
19138 * where it expects optional attributes or the end of the tag.
19139 * It is also reused after attributes, when expecting more optional
19140 * attributes.
19141 *
19142 * ```markdown
19143 * > | <a />
19144 * ^
19145 * > | <a :b>
19146 * ^
19147 * > | <a _b>
19148 * ^
19149 * > | <a b>
19150 * ^
19151 * > | <a >
19152 * ^
19153 * ```
19154 *
19155 * @type {State}
19156 */
19157 function completeAttributeNameBefore(code) {
19158 if (code === 47) {
19159 effects.consume(code);
19160 return completeEnd;
19161 }
19162 if (code === 58 || code === 95 || asciiAlpha(code)) {
19163 effects.consume(code);
19164 return completeAttributeName;
19165 }
19166 if (markdownSpace(code)) {
19167 effects.consume(code);
19168 return completeAttributeNameBefore;
19169 }
19170 return completeEnd(code);
19171 }
19172 /**
19173 * In attribute name.
19174 *
19175 * ```markdown
19176 * > | <a :b>
19177 * ^
19178 * > | <a _b>
19179 * ^
19180 * > | <a b>
19181 * ^
19182 * ```
19183 *
19184 * @type {State}
19185 */
19186 function completeAttributeName(code) {
19187 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
19188 effects.consume(code);
19189 return completeAttributeName;
19190 }
19191 return completeAttributeNameAfter(code);
19192 }
19193 /**
19194 * After attribute name, at an optional initializer, the end of the tag, or
19195 * whitespace.
19196 *
19197 * ```markdown
19198 * > | <a b>
19199 * ^
19200 * > | <a b=c>
19201 * ^
19202 * ```
19203 *
19204 * @type {State}
19205 */
19206 function completeAttributeNameAfter(code) {
19207 if (code === 61) {
19208 effects.consume(code);
19209 return completeAttributeValueBefore;
19210 }
19211 if (markdownSpace(code)) {
19212 effects.consume(code);
19213 return completeAttributeNameAfter;
19214 }
19215 return completeAttributeNameBefore(code);
19216 }
19217 /**
19218 * Before unquoted, double quoted, or single quoted attribute value, allowing
19219 * whitespace.
19220 *
19221 * ```markdown
19222 * > | <a b=c>
19223 * ^
19224 * > | <a b="c">
19225 * ^
19226 * ```
19227 *
19228 * @type {State}
19229 */
19230 function completeAttributeValueBefore(code) {
19231 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
19232 if (code === 34 || code === 39) {
19233 effects.consume(code);
19234 markerB = code;
19235 return completeAttributeValueQuoted;
19236 }
19237 if (markdownSpace(code)) {
19238 effects.consume(code);
19239 return completeAttributeValueBefore;
19240 }
19241 return completeAttributeValueUnquoted(code);
19242 }
19243 /**
19244 * In double or single quoted attribute value.
19245 *
19246 * ```markdown
19247 * > | <a b="c">
19248 * ^
19249 * > | <a b='c'>
19250 * ^
19251 * ```
19252 *
19253 * @type {State}
19254 */
19255 function completeAttributeValueQuoted(code) {
19256 if (code === markerB) {
19257 effects.consume(code);
19258 markerB = null;
19259 return completeAttributeValueQuotedAfter;
19260 }
19261 if (code === null || markdownLineEnding(code)) return nok(code);
19262 effects.consume(code);
19263 return completeAttributeValueQuoted;
19264 }
19265 /**
19266 * In unquoted attribute value.
19267 *
19268 * ```markdown
19269 * > | <a b=c>
19270 * ^
19271 * ```
19272 *
19273 * @type {State}
19274 */
19275 function completeAttributeValueUnquoted(code) {
19276 if (code === null || code === 34 || code === 39 || code === 47 || code === 60 || code === 61 || code === 62 || code === 96 || markdownLineEndingOrSpace(code)) return completeAttributeNameAfter(code);
19277 effects.consume(code);
19278 return completeAttributeValueUnquoted;
19279 }
19280 /**
19281 * After double or single quoted attribute value, before whitespace or the
19282 * end of the tag.
19283 *
19284 * ```markdown
19285 * > | <a b="c">
19286 * ^
19287 * ```
19288 *
19289 * @type {State}
19290 */
19291 function completeAttributeValueQuotedAfter(code) {
19292 if (code === 47 || code === 62 || markdownSpace(code)) return completeAttributeNameBefore(code);
19293 return nok(code);
19294 }
19295 /**
19296 * In certain circumstances of a complete tag where only an `>` is allowed.
19297 *
19298 * ```markdown
19299 * > | <a b="c">
19300 * ^
19301 * ```
19302 *
19303 * @type {State}
19304 */
19305 function completeEnd(code) {
19306 if (code === 62) {
19307 effects.consume(code);
19308 return completeAfter;
19309 }
19310 return nok(code);
19311 }
19312 /**
19313 * After `>` in a complete tag.
19314 *
19315 * ```markdown
19316 * > | <x>
19317 * ^
19318 * ```
19319 *
19320 * @type {State}
19321 */
19322 function completeAfter(code) {
19323 if (code === null || markdownLineEnding(code)) return continuation(code);
19324 if (markdownSpace(code)) {
19325 effects.consume(code);
19326 return completeAfter;
19327 }
19328 return nok(code);
19329 }
19330 /**
19331 * In continuation of any HTML kind.
19332 *
19333 * ```markdown
19334 * > | <!--xxx-->
19335 * ^
19336 * ```
19337 *
19338 * @type {State}
19339 */
19340 function continuation(code) {
19341 if (code === 45 && marker === 2) {
19342 effects.consume(code);
19343 return continuationCommentInside;
19344 }
19345 if (code === 60 && marker === 1) {
19346 effects.consume(code);
19347 return continuationRawTagOpen;
19348 }
19349 if (code === 62 && marker === 4) {
19350 effects.consume(code);
19351 return continuationClose;
19352 }
19353 if (code === 63 && marker === 3) {
19354 effects.consume(code);
19355 return continuationDeclarationInside;
19356 }
19357 if (code === 93 && marker === 5) {
19358 effects.consume(code);
19359 return continuationCdataInside;
19360 }
19361 if (markdownLineEnding(code) && (marker === 6 || marker === 7)) {
19362 effects.exit("htmlFlowData");
19363 return effects.check(blankLineBefore, continuationAfter, continuationStart)(code);
19364 }
19365 if (code === null || markdownLineEnding(code)) {
19366 effects.exit("htmlFlowData");
19367 return continuationStart(code);
19368 }
19369 effects.consume(code);
19370 return continuation;
19371 }
19372 /**
19373 * In continuation, at eol.
19374 *
19375 * ```markdown
19376 * > | <x>
19377 * ^
19378 * | asd
19379 * ```
19380 *
19381 * @type {State}
19382 */
19383 function continuationStart(code) {
19384 return effects.check(nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
19385 }
19386 /**
19387 * In continuation, at eol, before non-lazy content.
19388 *
19389 * ```markdown
19390 * > | <x>
19391 * ^
19392 * | asd
19393 * ```
19394 *
19395 * @type {State}
19396 */
19397 function continuationStartNonLazy(code) {
19398 effects.enter("lineEnding");
19399 effects.consume(code);
19400 effects.exit("lineEnding");
19401 return continuationBefore;
19402 }
19403 /**
19404 * In continuation, before non-lazy content.
19405 *
19406 * ```markdown
19407 * | <x>
19408 * > | asd
19409 * ^
19410 * ```
19411 *
19412 * @type {State}
19413 */
19414 function continuationBefore(code) {
19415 if (code === null || markdownLineEnding(code)) return continuationStart(code);
19416 effects.enter("htmlFlowData");
19417 return continuation(code);
19418 }
19419 /**
19420 * In comment continuation, after one `-`, expecting another.
19421 *
19422 * ```markdown
19423 * > | <!--xxx-->
19424 * ^
19425 * ```
19426 *
19427 * @type {State}
19428 */
19429 function continuationCommentInside(code) {
19430 if (code === 45) {
19431 effects.consume(code);
19432 return continuationDeclarationInside;
19433 }
19434 return continuation(code);
19435 }
19436 /**
19437 * In raw continuation, after `<`, at `/`.
19438 *
19439 * ```markdown
19440 * > | <script>console.log(1)<\/script>
19441 * ^
19442 * ```
19443 *
19444 * @type {State}
19445 */
19446 function continuationRawTagOpen(code) {
19447 if (code === 47) {
19448 effects.consume(code);
19449 buffer = "";
19450 return continuationRawEndTag;
19451 }
19452 return continuation(code);
19453 }
19454 /**
19455 * In raw continuation, after `</`, in a raw tag name.
19456 *
19457 * ```markdown
19458 * > | <script>console.log(1)<\/script>
19459 * ^^^^^^
19460 * ```
19461 *
19462 * @type {State}
19463 */
19464 function continuationRawEndTag(code) {
19465 if (code === 62) {
19466 const name = buffer.toLowerCase();
19467 if (htmlRawNames.includes(name)) {
19468 effects.consume(code);
19469 return continuationClose;
19470 }
19471 return continuation(code);
19472 }
19473 if (asciiAlpha(code) && buffer.length < 8) {
19474 effects.consume(code);
19475 buffer += String.fromCharCode(code);
19476 return continuationRawEndTag;
19477 }
19478 return continuation(code);
19479 }
19480 /**
19481 * In cdata continuation, after `]`, expecting `]>`.
19482 *
19483 * ```markdown
19484 * > | <![CDATA[>&<]]>
19485 * ^
19486 * ```
19487 *
19488 * @type {State}
19489 */
19490 function continuationCdataInside(code) {
19491 if (code === 93) {
19492 effects.consume(code);
19493 return continuationDeclarationInside;
19494 }
19495 return continuation(code);
19496 }
19497 /**
19498 * In declaration or instruction continuation, at `>`.
19499 *
19500 * ```markdown
19501 * > | <!-->
19502 * ^
19503 * > | <?>
19504 * ^
19505 * > | <!q>
19506 * ^
19507 * > | <!--ab-->
19508 * ^
19509 * > | <![CDATA[>&<]]>
19510 * ^
19511 * ```
19512 *
19513 * @type {State}
19514 */
19515 function continuationDeclarationInside(code) {
19516 if (code === 62) {
19517 effects.consume(code);
19518 return continuationClose;
19519 }
19520 if (code === 45 && marker === 2) {
19521 effects.consume(code);
19522 return continuationDeclarationInside;
19523 }
19524 return continuation(code);
19525 }
19526 /**
19527 * In closed continuation: everything we get until the eol/eof is part of it.
19528 *
19529 * ```markdown
19530 * > | <!doctype>
19531 * ^
19532 * ```
19533 *
19534 * @type {State}
19535 */
19536 function continuationClose(code) {
19537 if (code === null || markdownLineEnding(code)) {
19538 effects.exit("htmlFlowData");
19539 return continuationAfter(code);
19540 }
19541 effects.consume(code);
19542 return continuationClose;
19543 }
19544 /**
19545 * Done.
19546 *
19547 * ```markdown
19548 * > | <!doctype>
19549 * ^
19550 * ```
19551 *
19552 * @type {State}
19553 */
19554 function continuationAfter(code) {
19555 effects.exit("htmlFlow");
19556 return ok(code);
19557 }
19558 }
19559 /**
19560 * @this {TokenizeContext}
19561 * @type {Tokenizer}
19562 */
19563 function tokenizeNonLazyContinuationStart(effects, ok, nok) {
19564 const self = this;
19565 return start;
19566 /**
19567 * At eol, before continuation.
19568 *
19569 * ```markdown
19570 * > | * ```js
19571 * ^
19572 * | b
19573 * ```
19574 *
19575 * @type {State}
19576 */
19577 function start(code) {
19578 if (markdownLineEnding(code)) {
19579 effects.enter("lineEnding");
19580 effects.consume(code);
19581 effects.exit("lineEnding");
19582 return after;
19583 }
19584 return nok(code);
19585 }
19586 /**
19587 * A continuation.
19588 *
19589 * ```markdown
19590 * | * ```js
19591 * > | b
19592 * ^
19593 * ```
19594 *
19595 * @type {State}
19596 */
19597 function after(code) {
19598 return self.parser.lazy[self.now().line] ? nok(code) : ok(code);
19599 }
19600 }
19601 /**
19602 * @this {TokenizeContext}
19603 * @type {Tokenizer}
19604 */
19605 function tokenizeBlankLineBefore(effects, ok, nok) {
19606 return start;
19607 /**
19608 * Before eol, expecting blank line.
19609 *
19610 * ```markdown
19611 * > | <div>
19612 * ^
19613 * |
19614 * ```
19615 *
19616 * @type {State}
19617 */
19618 function start(code) {
19619 effects.enter("lineEnding");
19620 effects.consume(code);
19621 effects.exit("lineEnding");
19622 return effects.attempt(blankLine, ok, nok);
19623 }
19624 }
19625 var htmlFlow, blankLineBefore, nonLazyContinuationStart;
19626 var init_html_flow = __esmMin((() => {
19627 init_micromark_util_character();
19628 init_micromark_util_html_tag_name();
19629 init_blank_line();
19630 htmlFlow = {
19631 name: "htmlFlow",
19632 tokenize: tokenizeHtmlFlow,
19633 resolveTo: resolveToHtmlFlow,
19634 concrete: true
19635 };
19636 blankLineBefore = {
19637 tokenize: tokenizeBlankLineBefore,
19638 partial: true
19639 };
19640 nonLazyContinuationStart = {
19641 tokenize: tokenizeNonLazyContinuationStart,
19642 partial: true
19643 };
19644 }));
19645
19646 //#endregion
19647 //#region node_modules/micromark-core-commonmark/lib/html-text.js
19648 /**
19649 * @this {TokenizeContext}
19650 * @type {Tokenizer}
19651 */
19652 function tokenizeHtmlText(effects, ok, nok) {
19653 const self = this;
19654 /** @type {NonNullable<Code> | undefined} */
19655 let marker;
19656 /** @type {number} */
19657 let index;
19658 /** @type {State} */
19659 let returnState;
19660 return start;
19661 /**
19662 * Start of HTML (text).
19663 *
19664 * ```markdown
19665 * > | a <b> c
19666 * ^
19667 * ```
19668 *
19669 * @type {State}
19670 */
19671 function start(code) {
19672 effects.enter("htmlText");
19673 effects.enter("htmlTextData");
19674 effects.consume(code);
19675 return open;
19676 }
19677 /**
19678 * After `<`, at tag name or other stuff.
19679 *
19680 * ```markdown
19681 * > | a <b> c
19682 * ^
19683 * > | a <!doctype> c
19684 * ^
19685 * > | a <!--b--> c
19686 * ^
19687 * ```
19688 *
19689 * @type {State}
19690 */
19691 function open(code) {
19692 if (code === 33) {
19693 effects.consume(code);
19694 return declarationOpen;
19695 }
19696 if (code === 47) {
19697 effects.consume(code);
19698 return tagCloseStart;
19699 }
19700 if (code === 63) {
19701 effects.consume(code);
19702 return instruction;
19703 }
19704 if (asciiAlpha(code)) {
19705 effects.consume(code);
19706 return tagOpen;
19707 }
19708 return nok(code);
19709 }
19710 /**
19711 * After `<!`, at declaration, comment, or CDATA.
19712 *
19713 * ```markdown
19714 * > | a <!doctype> c
19715 * ^
19716 * > | a <!--b--> c
19717 * ^
19718 * > | a <![CDATA[>&<]]> c
19719 * ^
19720 * ```
19721 *
19722 * @type {State}
19723 */
19724 function declarationOpen(code) {
19725 if (code === 45) {
19726 effects.consume(code);
19727 return commentOpenInside;
19728 }
19729 if (code === 91) {
19730 effects.consume(code);
19731 index = 0;
19732 return cdataOpenInside;
19733 }
19734 if (asciiAlpha(code)) {
19735 effects.consume(code);
19736 return declaration;
19737 }
19738 return nok(code);
19739 }
19740 /**
19741 * In a comment, after `<!-`, at another `-`.
19742 *
19743 * ```markdown
19744 * > | a <!--b--> c
19745 * ^
19746 * ```
19747 *
19748 * @type {State}
19749 */
19750 function commentOpenInside(code) {
19751 if (code === 45) {
19752 effects.consume(code);
19753 return commentEnd;
19754 }
19755 return nok(code);
19756 }
19757 /**
19758 * In comment.
19759 *
19760 * ```markdown
19761 * > | a <!--b--> c
19762 * ^
19763 * ```
19764 *
19765 * @type {State}
19766 */
19767 function comment(code) {
19768 if (code === null) return nok(code);
19769 if (code === 45) {
19770 effects.consume(code);
19771 return commentClose;
19772 }
19773 if (markdownLineEnding(code)) {
19774 returnState = comment;
19775 return lineEndingBefore(code);
19776 }
19777 effects.consume(code);
19778 return comment;
19779 }
19780 /**
19781 * In comment, after `-`.
19782 *
19783 * ```markdown
19784 * > | a <!--b--> c
19785 * ^
19786 * ```
19787 *
19788 * @type {State}
19789 */
19790 function commentClose(code) {
19791 if (code === 45) {
19792 effects.consume(code);
19793 return commentEnd;
19794 }
19795 return comment(code);
19796 }
19797 /**
19798 * In comment, after `--`.
19799 *
19800 * ```markdown
19801 * > | a <!--b--> c
19802 * ^
19803 * ```
19804 *
19805 * @type {State}
19806 */
19807 function commentEnd(code) {
19808 return code === 62 ? end(code) : code === 45 ? commentClose(code) : comment(code);
19809 }
19810 /**
19811 * After `<![`, in CDATA, expecting `CDATA[`.
19812 *
19813 * ```markdown
19814 * > | a <![CDATA[>&<]]> b
19815 * ^^^^^^
19816 * ```
19817 *
19818 * @type {State}
19819 */
19820 function cdataOpenInside(code) {
19821 if (code === "CDATA[".charCodeAt(index++)) {
19822 effects.consume(code);
19823 return index === 6 ? cdata : cdataOpenInside;
19824 }
19825 return nok(code);
19826 }
19827 /**
19828 * In CDATA.
19829 *
19830 * ```markdown
19831 * > | a <![CDATA[>&<]]> b
19832 * ^^^
19833 * ```
19834 *
19835 * @type {State}
19836 */
19837 function cdata(code) {
19838 if (code === null) return nok(code);
19839 if (code === 93) {
19840 effects.consume(code);
19841 return cdataClose;
19842 }
19843 if (markdownLineEnding(code)) {
19844 returnState = cdata;
19845 return lineEndingBefore(code);
19846 }
19847 effects.consume(code);
19848 return cdata;
19849 }
19850 /**
19851 * In CDATA, after `]`, at another `]`.
19852 *
19853 * ```markdown
19854 * > | a <![CDATA[>&<]]> b
19855 * ^
19856 * ```
19857 *
19858 * @type {State}
19859 */
19860 function cdataClose(code) {
19861 if (code === 93) {
19862 effects.consume(code);
19863 return cdataEnd;
19864 }
19865 return cdata(code);
19866 }
19867 /**
19868 * In CDATA, after `]]`, at `>`.
19869 *
19870 * ```markdown
19871 * > | a <![CDATA[>&<]]> b
19872 * ^
19873 * ```
19874 *
19875 * @type {State}
19876 */
19877 function cdataEnd(code) {
19878 if (code === 62) return end(code);
19879 if (code === 93) {
19880 effects.consume(code);
19881 return cdataEnd;
19882 }
19883 return cdata(code);
19884 }
19885 /**
19886 * In declaration.
19887 *
19888 * ```markdown
19889 * > | a <!b> c
19890 * ^
19891 * ```
19892 *
19893 * @type {State}
19894 */
19895 function declaration(code) {
19896 if (code === null || code === 62) return end(code);
19897 if (markdownLineEnding(code)) {
19898 returnState = declaration;
19899 return lineEndingBefore(code);
19900 }
19901 effects.consume(code);
19902 return declaration;
19903 }
19904 /**
19905 * In instruction.
19906 *
19907 * ```markdown
19908 * > | a <?b?> c
19909 * ^
19910 * ```
19911 *
19912 * @type {State}
19913 */
19914 function instruction(code) {
19915 if (code === null) return nok(code);
19916 if (code === 63) {
19917 effects.consume(code);
19918 return instructionClose;
19919 }
19920 if (markdownLineEnding(code)) {
19921 returnState = instruction;
19922 return lineEndingBefore(code);
19923 }
19924 effects.consume(code);
19925 return instruction;
19926 }
19927 /**
19928 * In instruction, after `?`, at `>`.
19929 *
19930 * ```markdown
19931 * > | a <?b?> c
19932 * ^
19933 * ```
19934 *
19935 * @type {State}
19936 */
19937 function instructionClose(code) {
19938 return code === 62 ? end(code) : instruction(code);
19939 }
19940 /**
19941 * After `</`, in closing tag, at tag name.
19942 *
19943 * ```markdown
19944 * > | a </b> c
19945 * ^
19946 * ```
19947 *
19948 * @type {State}
19949 */
19950 function tagCloseStart(code) {
19951 if (asciiAlpha(code)) {
19952 effects.consume(code);
19953 return tagClose;
19954 }
19955 return nok(code);
19956 }
19957 /**
19958 * After `</x`, in a tag name.
19959 *
19960 * ```markdown
19961 * > | a </b> c
19962 * ^
19963 * ```
19964 *
19965 * @type {State}
19966 */
19967 function tagClose(code) {
19968 if (code === 45 || asciiAlphanumeric(code)) {
19969 effects.consume(code);
19970 return tagClose;
19971 }
19972 return tagCloseBetween(code);
19973 }
19974 /**
19975 * In closing tag, after tag name.
19976 *
19977 * ```markdown
19978 * > | a </b> c
19979 * ^
19980 * ```
19981 *
19982 * @type {State}
19983 */
19984 function tagCloseBetween(code) {
19985 if (markdownLineEnding(code)) {
19986 returnState = tagCloseBetween;
19987 return lineEndingBefore(code);
19988 }
19989 if (markdownSpace(code)) {
19990 effects.consume(code);
19991 return tagCloseBetween;
19992 }
19993 return end(code);
19994 }
19995 /**
19996 * After `<x`, in opening tag name.
19997 *
19998 * ```markdown
19999 * > | a <b> c
20000 * ^
20001 * ```
20002 *
20003 * @type {State}
20004 */
20005 function tagOpen(code) {
20006 if (code === 45 || asciiAlphanumeric(code)) {
20007 effects.consume(code);
20008 return tagOpen;
20009 }
20010 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20011 return nok(code);
20012 }
20013 /**
20014 * In opening tag, after tag name.
20015 *
20016 * ```markdown
20017 * > | a <b> c
20018 * ^
20019 * ```
20020 *
20021 * @type {State}
20022 */
20023 function tagOpenBetween(code) {
20024 if (code === 47) {
20025 effects.consume(code);
20026 return end;
20027 }
20028 if (code === 58 || code === 95 || asciiAlpha(code)) {
20029 effects.consume(code);
20030 return tagOpenAttributeName;
20031 }
20032 if (markdownLineEnding(code)) {
20033 returnState = tagOpenBetween;
20034 return lineEndingBefore(code);
20035 }
20036 if (markdownSpace(code)) {
20037 effects.consume(code);
20038 return tagOpenBetween;
20039 }
20040 return end(code);
20041 }
20042 /**
20043 * In attribute name.
20044 *
20045 * ```markdown
20046 * > | a <b c> d
20047 * ^
20048 * ```
20049 *
20050 * @type {State}
20051 */
20052 function tagOpenAttributeName(code) {
20053 if (code === 45 || code === 46 || code === 58 || code === 95 || asciiAlphanumeric(code)) {
20054 effects.consume(code);
20055 return tagOpenAttributeName;
20056 }
20057 return tagOpenAttributeNameAfter(code);
20058 }
20059 /**
20060 * After attribute name, before initializer, the end of the tag, or
20061 * whitespace.
20062 *
20063 * ```markdown
20064 * > | a <b c> d
20065 * ^
20066 * ```
20067 *
20068 * @type {State}
20069 */
20070 function tagOpenAttributeNameAfter(code) {
20071 if (code === 61) {
20072 effects.consume(code);
20073 return tagOpenAttributeValueBefore;
20074 }
20075 if (markdownLineEnding(code)) {
20076 returnState = tagOpenAttributeNameAfter;
20077 return lineEndingBefore(code);
20078 }
20079 if (markdownSpace(code)) {
20080 effects.consume(code);
20081 return tagOpenAttributeNameAfter;
20082 }
20083 return tagOpenBetween(code);
20084 }
20085 /**
20086 * Before unquoted, double quoted, or single quoted attribute value, allowing
20087 * whitespace.
20088 *
20089 * ```markdown
20090 * > | a <b c=d> e
20091 * ^
20092 * ```
20093 *
20094 * @type {State}
20095 */
20096 function tagOpenAttributeValueBefore(code) {
20097 if (code === null || code === 60 || code === 61 || code === 62 || code === 96) return nok(code);
20098 if (code === 34 || code === 39) {
20099 effects.consume(code);
20100 marker = code;
20101 return tagOpenAttributeValueQuoted;
20102 }
20103 if (markdownLineEnding(code)) {
20104 returnState = tagOpenAttributeValueBefore;
20105 return lineEndingBefore(code);
20106 }
20107 if (markdownSpace(code)) {
20108 effects.consume(code);
20109 return tagOpenAttributeValueBefore;
20110 }
20111 effects.consume(code);
20112 return tagOpenAttributeValueUnquoted;
20113 }
20114 /**
20115 * In double or single quoted attribute value.
20116 *
20117 * ```markdown
20118 * > | a <b c="d"> e
20119 * ^
20120 * ```
20121 *
20122 * @type {State}
20123 */
20124 function tagOpenAttributeValueQuoted(code) {
20125 if (code === marker) {
20126 effects.consume(code);
20127 marker = void 0;
20128 return tagOpenAttributeValueQuotedAfter;
20129 }
20130 if (code === null) return nok(code);
20131 if (markdownLineEnding(code)) {
20132 returnState = tagOpenAttributeValueQuoted;
20133 return lineEndingBefore(code);
20134 }
20135 effects.consume(code);
20136 return tagOpenAttributeValueQuoted;
20137 }
20138 /**
20139 * In unquoted attribute value.
20140 *
20141 * ```markdown
20142 * > | a <b c=d> e
20143 * ^
20144 * ```
20145 *
20146 * @type {State}
20147 */
20148 function tagOpenAttributeValueUnquoted(code) {
20149 if (code === null || code === 34 || code === 39 || code === 60 || code === 61 || code === 96) return nok(code);
20150 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20151 effects.consume(code);
20152 return tagOpenAttributeValueUnquoted;
20153 }
20154 /**
20155 * After double or single quoted attribute value, before whitespace or the end
20156 * of the tag.
20157 *
20158 * ```markdown
20159 * > | a <b c="d"> e
20160 * ^
20161 * ```
20162 *
20163 * @type {State}
20164 */
20165 function tagOpenAttributeValueQuotedAfter(code) {
20166 if (code === 47 || code === 62 || markdownLineEndingOrSpace(code)) return tagOpenBetween(code);
20167 return nok(code);
20168 }
20169 /**
20170 * In certain circumstances of a tag where only an `>` is allowed.
20171 *
20172 * ```markdown
20173 * > | a <b c="d"> e
20174 * ^
20175 * ```
20176 *
20177 * @type {State}
20178 */
20179 function end(code) {
20180 if (code === 62) {
20181 effects.consume(code);
20182 effects.exit("htmlTextData");
20183 effects.exit("htmlText");
20184 return ok;
20185 }
20186 return nok(code);
20187 }
20188 /**
20189 * At eol.
20190 *
20191 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20192 * > empty tokens.
20193 *
20194 * ```markdown
20195 * > | a <!--a
20196 * ^
20197 * | b-->
20198 * ```
20199 *
20200 * @type {State}
20201 */
20202 function lineEndingBefore(code) {
20203 effects.exit("htmlTextData");
20204 effects.enter("lineEnding");
20205 effects.consume(code);
20206 effects.exit("lineEnding");
20207 return lineEndingAfter;
20208 }
20209 /**
20210 * After eol, at optional whitespace.
20211 *
20212 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20213 * > empty tokens.
20214 *
20215 * ```markdown
20216 * | a <!--a
20217 * > | b-->
20218 * ^
20219 * ```
20220 *
20221 * @type {State}
20222 */
20223 function lineEndingAfter(code) {
20224 return markdownSpace(code) ? factorySpace(effects, lineEndingAfterPrefix, "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code) : lineEndingAfterPrefix(code);
20225 }
20226 /**
20227 * After eol, after optional whitespace.
20228 *
20229 * > 👉 **Note**: we can’t have blank lines in text, so no need to worry about
20230 * > empty tokens.
20231 *
20232 * ```markdown
20233 * | a <!--a
20234 * > | b-->
20235 * ^
20236 * ```
20237 *
20238 * @type {State}
20239 */
20240 function lineEndingAfterPrefix(code) {
20241 effects.enter("htmlTextData");
20242 return returnState(code);
20243 }
20244 }
20245 var htmlText;
20246 var init_html_text = __esmMin((() => {
20247 init_micromark_factory_space();
20248 init_micromark_util_character();
20249 htmlText = {
20250 name: "htmlText",
20251 tokenize: tokenizeHtmlText
20252 };
20253 }));
20254
20255 //#endregion
20256 //#region node_modules/micromark-core-commonmark/lib/label-end.js
20257 /** @type {Resolver} */
20258 function resolveAllLabelEnd(events) {
20259 let index = -1;
20260 while (++index < events.length) {
20261 const token = events[index][1];
20262 if (token.type === "labelImage" || token.type === "labelLink" || token.type === "labelEnd") {
20263 events.splice(index + 1, token.type === "labelImage" ? 4 : 2);
20264 token.type = "data";
20265 index++;
20266 }
20267 }
20268 return events;
20269 }
20270 /** @type {Resolver} */
20271 function resolveToLabelEnd(events, context) {
20272 let index = events.length;
20273 let offset = 0;
20274 /** @type {Token} */
20275 let token;
20276 /** @type {number | undefined} */
20277 let open;
20278 /** @type {number | undefined} */
20279 let close;
20280 /** @type {Array<Event>} */
20281 let media;
20282 while (index--) {
20283 token = events[index][1];
20284 if (open) {
20285 if (token.type === "link" || token.type === "labelLink" && token._inactive) break;
20286 if (events[index][0] === "enter" && token.type === "labelLink") token._inactive = true;
20287 } else if (close) {
20288 if (events[index][0] === "enter" && (token.type === "labelImage" || token.type === "labelLink") && !token._balanced) {
20289 open = index;
20290 if (token.type !== "labelLink") {
20291 offset = 2;
20292 break;
20293 }
20294 }
20295 } else if (token.type === "labelEnd") close = index;
20296 }
20297 const group = {
20298 type: events[open][1].type === "labelLink" ? "link" : "image",
20299 start: Object.assign({}, events[open][1].start),
20300 end: Object.assign({}, events[events.length - 1][1].end)
20301 };
20302 const label = {
20303 type: "label",
20304 start: Object.assign({}, events[open][1].start),
20305 end: Object.assign({}, events[close][1].end)
20306 };
20307 const text = {
20308 type: "labelText",
20309 start: Object.assign({}, events[open + offset + 2][1].end),
20310 end: Object.assign({}, events[close - 2][1].start)
20311 };
20312 media = [[
20313 "enter",
20314 group,
20315 context
20316 ], [
20317 "enter",
20318 label,
20319 context
20320 ]];
20321 media = push(media, events.slice(open + 1, open + offset + 3));
20322 media = push(media, [[
20323 "enter",
20324 text,
20325 context
20326 ]]);
20327 media = push(media, resolveAll(context.parser.constructs.insideSpan.null, events.slice(open + offset + 4, close - 3), context));
20328 media = push(media, [
20329 [
20330 "exit",
20331 text,
20332 context
20333 ],
20334 events[close - 2],
20335 events[close - 1],
20336 [
20337 "exit",
20338 label,
20339 context
20340 ]
20341 ]);
20342 media = push(media, events.slice(close + 1));
20343 media = push(media, [[
20344 "exit",
20345 group,
20346 context
20347 ]]);
20348 splice(events, open, events.length, media);
20349 return events;
20350 }
20351 /**
20352 * @this {TokenizeContext}
20353 * @type {Tokenizer}
20354 */
20355 function tokenizeLabelEnd(effects, ok, nok) {
20356 const self = this;
20357 let index = self.events.length;
20358 /** @type {Token} */
20359 let labelStart;
20360 /** @type {boolean} */
20361 let defined;
20362 while (index--) if ((self.events[index][1].type === "labelImage" || self.events[index][1].type === "labelLink") && !self.events[index][1]._balanced) {
20363 labelStart = self.events[index][1];
20364 break;
20365 }
20366 return start;
20367 /**
20368 * Start of label end.
20369 *
20370 * ```markdown
20371 * > | [a](b) c
20372 * ^
20373 * > | [a][b] c
20374 * ^
20375 * > | [a][] b
20376 * ^
20377 * > | [a] b
20378 * ```
20379 *
20380 * @type {State}
20381 */
20382 function start(code) {
20383 if (!labelStart) return nok(code);
20384 if (labelStart._inactive) return labelEndNok(code);
20385 defined = self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize({
20386 start: labelStart.end,
20387 end: self.now()
20388 })));
20389 effects.enter("labelEnd");
20390 effects.enter("labelMarker");
20391 effects.consume(code);
20392 effects.exit("labelMarker");
20393 effects.exit("labelEnd");
20394 return after;
20395 }
20396 /**
20397 * After `]`.
20398 *
20399 * ```markdown
20400 * > | [a](b) c
20401 * ^
20402 * > | [a][b] c
20403 * ^
20404 * > | [a][] b
20405 * ^
20406 * > | [a] b
20407 * ^
20408 * ```
20409 *
20410 * @type {State}
20411 */
20412 function after(code) {
20413 if (code === 40) return effects.attempt(resourceConstruct, labelEndOk, defined ? labelEndOk : labelEndNok)(code);
20414 if (code === 91) return effects.attempt(referenceFullConstruct, labelEndOk, defined ? referenceNotFull : labelEndNok)(code);
20415 return defined ? labelEndOk(code) : labelEndNok(code);
20416 }
20417 /**
20418 * After `]`, at `[`, but not at a full reference.
20419 *
20420 * > 👉 **Note**: we only get here if the label is defined.
20421 *
20422 * ```markdown
20423 * > | [a][] b
20424 * ^
20425 * > | [a] b
20426 * ^
20427 * ```
20428 *
20429 * @type {State}
20430 */
20431 function referenceNotFull(code) {
20432 return effects.attempt(referenceCollapsedConstruct, labelEndOk, labelEndNok)(code);
20433 }
20434 /**
20435 * Done, we found something.
20436 *
20437 * ```markdown
20438 * > | [a](b) c
20439 * ^
20440 * > | [a][b] c
20441 * ^
20442 * > | [a][] b
20443 * ^
20444 * > | [a] b
20445 * ^
20446 * ```
20447 *
20448 * @type {State}
20449 */
20450 function labelEndOk(code) {
20451 return ok(code);
20452 }
20453 /**
20454 * Done, it’s nothing.
20455 *
20456 * There was an okay opening, but we didn’t match anything.
20457 *
20458 * ```markdown
20459 * > | [a](b c
20460 * ^
20461 * > | [a][b c
20462 * ^
20463 * > | [a] b
20464 * ^
20465 * ```
20466 *
20467 * @type {State}
20468 */
20469 function labelEndNok(code) {
20470 labelStart._balanced = true;
20471 return nok(code);
20472 }
20473 }
20474 /**
20475 * @this {TokenizeContext}
20476 * @type {Tokenizer}
20477 */
20478 function tokenizeResource(effects, ok, nok) {
20479 return resourceStart;
20480 /**
20481 * At a resource.
20482 *
20483 * ```markdown
20484 * > | [a](b) c
20485 * ^
20486 * ```
20487 *
20488 * @type {State}
20489 */
20490 function resourceStart(code) {
20491 effects.enter("resource");
20492 effects.enter("resourceMarker");
20493 effects.consume(code);
20494 effects.exit("resourceMarker");
20495 return resourceBefore;
20496 }
20497 /**
20498 * In resource, after `(`, at optional whitespace.
20499 *
20500 * ```markdown
20501 * > | [a](b) c
20502 * ^
20503 * ```
20504 *
20505 * @type {State}
20506 */
20507 function resourceBefore(code) {
20508 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceOpen)(code) : resourceOpen(code);
20509 }
20510 /**
20511 * In resource, after optional whitespace, at `)` or a destination.
20512 *
20513 * ```markdown
20514 * > | [a](b) c
20515 * ^
20516 * ```
20517 *
20518 * @type {State}
20519 */
20520 function resourceOpen(code) {
20521 if (code === 41) return resourceEnd(code);
20522 return factoryDestination(effects, resourceDestinationAfter, resourceDestinationMissing, "resourceDestination", "resourceDestinationLiteral", "resourceDestinationLiteralMarker", "resourceDestinationRaw", "resourceDestinationString", 32)(code);
20523 }
20524 /**
20525 * In resource, after destination, at optional whitespace.
20526 *
20527 * ```markdown
20528 * > | [a](b) c
20529 * ^
20530 * ```
20531 *
20532 * @type {State}
20533 */
20534 function resourceDestinationAfter(code) {
20535 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceBetween)(code) : resourceEnd(code);
20536 }
20537 /**
20538 * At invalid destination.
20539 *
20540 * ```markdown
20541 * > | [a](<<) b
20542 * ^
20543 * ```
20544 *
20545 * @type {State}
20546 */
20547 function resourceDestinationMissing(code) {
20548 return nok(code);
20549 }
20550 /**
20551 * In resource, after destination and whitespace, at `(` or title.
20552 *
20553 * ```markdown
20554 * > | [a](b ) c
20555 * ^
20556 * ```
20557 *
20558 * @type {State}
20559 */
20560 function resourceBetween(code) {
20561 if (code === 34 || code === 39 || code === 40) return factoryTitle(effects, resourceTitleAfter, nok, "resourceTitle", "resourceTitleMarker", "resourceTitleString")(code);
20562 return resourceEnd(code);
20563 }
20564 /**
20565 * In resource, after title, at optional whitespace.
20566 *
20567 * ```markdown
20568 * > | [a](b "c") d
20569 * ^
20570 * ```
20571 *
20572 * @type {State}
20573 */
20574 function resourceTitleAfter(code) {
20575 return markdownLineEndingOrSpace(code) ? factoryWhitespace(effects, resourceEnd)(code) : resourceEnd(code);
20576 }
20577 /**
20578 * In resource, at `)`.
20579 *
20580 * ```markdown
20581 * > | [a](b) d
20582 * ^
20583 * ```
20584 *
20585 * @type {State}
20586 */
20587 function resourceEnd(code) {
20588 if (code === 41) {
20589 effects.enter("resourceMarker");
20590 effects.consume(code);
20591 effects.exit("resourceMarker");
20592 effects.exit("resource");
20593 return ok;
20594 }
20595 return nok(code);
20596 }
20597 }
20598 /**
20599 * @this {TokenizeContext}
20600 * @type {Tokenizer}
20601 */
20602 function tokenizeReferenceFull(effects, ok, nok) {
20603 const self = this;
20604 return referenceFull;
20605 /**
20606 * In a reference (full), at the `[`.
20607 *
20608 * ```markdown
20609 * > | [a][b] d
20610 * ^
20611 * ```
20612 *
20613 * @type {State}
20614 */
20615 function referenceFull(code) {
20616 return factoryLabel.call(self, effects, referenceFullAfter, referenceFullMissing, "reference", "referenceMarker", "referenceString")(code);
20617 }
20618 /**
20619 * In a reference (full), after `]`.
20620 *
20621 * ```markdown
20622 * > | [a][b] d
20623 * ^
20624 * ```
20625 *
20626 * @type {State}
20627 */
20628 function referenceFullAfter(code) {
20629 return self.parser.defined.includes(normalizeIdentifier(self.sliceSerialize(self.events[self.events.length - 1][1]).slice(1, -1))) ? ok(code) : nok(code);
20630 }
20631 /**
20632 * In reference (full) that was missing.
20633 *
20634 * ```markdown
20635 * > | [a][b d
20636 * ^
20637 * ```
20638 *
20639 * @type {State}
20640 */
20641 function referenceFullMissing(code) {
20642 return nok(code);
20643 }
20644 }
20645 /**
20646 * @this {TokenizeContext}
20647 * @type {Tokenizer}
20648 */
20649 function tokenizeReferenceCollapsed(effects, ok, nok) {
20650 return referenceCollapsedStart;
20651 /**
20652 * In reference (collapsed), at `[`.
20653 *
20654 * > 👉 **Note**: we only get here if the label is defined.
20655 *
20656 * ```markdown
20657 * > | [a][] d
20658 * ^
20659 * ```
20660 *
20661 * @type {State}
20662 */
20663 function referenceCollapsedStart(code) {
20664 effects.enter("reference");
20665 effects.enter("referenceMarker");
20666 effects.consume(code);
20667 effects.exit("referenceMarker");
20668 return referenceCollapsedOpen;
20669 }
20670 /**
20671 * In reference (collapsed), at `]`.
20672 *
20673 * > 👉 **Note**: we only get here if the label is defined.
20674 *
20675 * ```markdown
20676 * > | [a][] d
20677 * ^
20678 * ```
20679 *
20680 * @type {State}
20681 */
20682 function referenceCollapsedOpen(code) {
20683 if (code === 93) {
20684 effects.enter("referenceMarker");
20685 effects.consume(code);
20686 effects.exit("referenceMarker");
20687 effects.exit("reference");
20688 return ok;
20689 }
20690 return nok(code);
20691 }
20692 }
20693 var labelEnd, resourceConstruct, referenceFullConstruct, referenceCollapsedConstruct;
20694 var init_label_end = __esmMin((() => {
20695 init_micromark_factory_destination();
20696 init_micromark_factory_label();
20697 init_micromark_factory_title();
20698 init_micromark_factory_whitespace();
20699 init_micromark_util_character();
20700 init_micromark_util_chunked();
20701 init_micromark_util_normalize_identifier();
20702 init_micromark_util_resolve_all();
20703 labelEnd = {
20704 name: "labelEnd",
20705 tokenize: tokenizeLabelEnd,
20706 resolveTo: resolveToLabelEnd,
20707 resolveAll: resolveAllLabelEnd
20708 };
20709 resourceConstruct = { tokenize: tokenizeResource };
20710 referenceFullConstruct = { tokenize: tokenizeReferenceFull };
20711 referenceCollapsedConstruct = { tokenize: tokenizeReferenceCollapsed };
20712 }));
20713
20714 //#endregion
20715 //#region node_modules/micromark-core-commonmark/lib/label-start-image.js
20716 /**
20717 * @this {TokenizeContext}
20718 * @type {Tokenizer}
20719 */
20720 function tokenizeLabelStartImage(effects, ok, nok) {
20721 const self = this;
20722 return start;
20723 /**
20724 * Start of label (image) start.
20725 *
20726 * ```markdown
20727 * > | a ![b] c
20728 * ^
20729 * ```
20730 *
20731 * @type {State}
20732 */
20733 function start(code) {
20734 effects.enter("labelImage");
20735 effects.enter("labelImageMarker");
20736 effects.consume(code);
20737 effects.exit("labelImageMarker");
20738 return open;
20739 }
20740 /**
20741 * After `!`, at `[`.
20742 *
20743 * ```markdown
20744 * > | a ![b] c
20745 * ^
20746 * ```
20747 *
20748 * @type {State}
20749 */
20750 function open(code) {
20751 if (code === 91) {
20752 effects.enter("labelMarker");
20753 effects.consume(code);
20754 effects.exit("labelMarker");
20755 effects.exit("labelImage");
20756 return after;
20757 }
20758 return nok(code);
20759 }
20760 /**
20761 * After `![`.
20762 *
20763 * ```markdown
20764 * > | a ![b] c
20765 * ^
20766 * ```
20767 *
20768 * This is needed in because, when GFM footnotes are enabled, images never
20769 * form when started with a `^`.
20770 * Instead, links form:
20771 *
20772 * ```markdown
20773 * ![^a](b)
20774 *
20775 * ![^a][b]
20776 *
20777 * [b]: c
20778 * ```
20779 *
20780 * ```html
20781 * <p>!<a href=\"b\">^a</a></p>
20782 * <p>!<a href=\"c\">^a</a></p>
20783 * ```
20784 *
20785 * @type {State}
20786 */
20787 function after(code) {
20788 /* c8 ignore next 3 */
20789 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20790 }
20791 }
20792 var labelStartImage;
20793 var init_label_start_image = __esmMin((() => {
20794 init_label_end();
20795 labelStartImage = {
20796 name: "labelStartImage",
20797 tokenize: tokenizeLabelStartImage,
20798 resolveAll: labelEnd.resolveAll
20799 };
20800 }));
20801
20802 //#endregion
20803 //#region node_modules/micromark-core-commonmark/lib/label-start-link.js
20804 /**
20805 * @this {TokenizeContext}
20806 * @type {Tokenizer}
20807 */
20808 function tokenizeLabelStartLink(effects, ok, nok) {
20809 const self = this;
20810 return start;
20811 /**
20812 * Start of label (link) start.
20813 *
20814 * ```markdown
20815 * > | a [b] c
20816 * ^
20817 * ```
20818 *
20819 * @type {State}
20820 */
20821 function start(code) {
20822 effects.enter("labelLink");
20823 effects.enter("labelMarker");
20824 effects.consume(code);
20825 effects.exit("labelMarker");
20826 effects.exit("labelLink");
20827 return after;
20828 }
20829 /** @type {State} */
20830 function after(code) {
20831 /* c8 ignore next 3 */
20832 return code === 94 && "_hiddenFootnoteSupport" in self.parser.constructs ? nok(code) : ok(code);
20833 }
20834 }
20835 var labelStartLink;
20836 var init_label_start_link = __esmMin((() => {
20837 init_label_end();
20838 labelStartLink = {
20839 name: "labelStartLink",
20840 tokenize: tokenizeLabelStartLink,
20841 resolveAll: labelEnd.resolveAll
20842 };
20843 }));
20844
20845 //#endregion
20846 //#region node_modules/micromark-core-commonmark/lib/line-ending.js
20847 /**
20848 * @this {TokenizeContext}
20849 * @type {Tokenizer}
20850 */
20851 function tokenizeLineEnding(effects, ok) {
20852 return start;
20853 /** @type {State} */
20854 function start(code) {
20855 effects.enter("lineEnding");
20856 effects.consume(code);
20857 effects.exit("lineEnding");
20858 return factorySpace(effects, ok, "linePrefix");
20859 }
20860 }
20861 var lineEnding;
20862 var init_line_ending = __esmMin((() => {
20863 init_micromark_factory_space();
20864 lineEnding = {
20865 name: "lineEnding",
20866 tokenize: tokenizeLineEnding
20867 };
20868 }));
20869
20870 //#endregion
20871 //#region node_modules/micromark-core-commonmark/lib/thematic-break.js
20872 /**
20873 * @this {TokenizeContext}
20874 * @type {Tokenizer}
20875 */
20876 function tokenizeThematicBreak(effects, ok, nok) {
20877 let size = 0;
20878 /** @type {NonNullable<Code>} */
20879 let marker;
20880 return start;
20881 /**
20882 * Start of thematic break.
20883 *
20884 * ```markdown
20885 * > | ***
20886 * ^
20887 * ```
20888 *
20889 * @type {State}
20890 */
20891 function start(code) {
20892 effects.enter("thematicBreak");
20893 return before(code);
20894 }
20895 /**
20896 * After optional whitespace, at marker.
20897 *
20898 * ```markdown
20899 * > | ***
20900 * ^
20901 * ```
20902 *
20903 * @type {State}
20904 */
20905 function before(code) {
20906 marker = code;
20907 return atBreak(code);
20908 }
20909 /**
20910 * After something, before something else.
20911 *
20912 * ```markdown
20913 * > | ***
20914 * ^
20915 * ```
20916 *
20917 * @type {State}
20918 */
20919 function atBreak(code) {
20920 if (code === marker) {
20921 effects.enter("thematicBreakSequence");
20922 return sequence(code);
20923 }
20924 if (size >= 3 && (code === null || markdownLineEnding(code))) {
20925 effects.exit("thematicBreak");
20926 return ok(code);
20927 }
20928 return nok(code);
20929 }
20930 /**
20931 * In sequence.
20932 *
20933 * ```markdown
20934 * > | ***
20935 * ^
20936 * ```
20937 *
20938 * @type {State}
20939 */
20940 function sequence(code) {
20941 if (code === marker) {
20942 effects.consume(code);
20943 size++;
20944 return sequence;
20945 }
20946 effects.exit("thematicBreakSequence");
20947 return markdownSpace(code) ? factorySpace(effects, atBreak, "whitespace")(code) : atBreak(code);
20948 }
20949 }
20950 var thematicBreak$1;
20951 var init_thematic_break$1 = __esmMin((() => {
20952 init_micromark_factory_space();
20953 init_micromark_util_character();
20954 thematicBreak$1 = {
20955 name: "thematicBreak",
20956 tokenize: tokenizeThematicBreak
20957 };
20958 }));
20959
20960 //#endregion
20961 //#region node_modules/micromark-core-commonmark/lib/list.js
20962 /**
20963 * @type {Tokenizer}
20964 * @this {TokenizeContext}
20965 */
20966 function tokenizeListStart(effects, ok, nok) {
20967 const self = this;
20968 const tail = self.events[self.events.length - 1];
20969 let initialSize = tail && tail[1].type === "linePrefix" ? tail[2].sliceSerialize(tail[1], true).length : 0;
20970 let size = 0;
20971 return start;
20972 /** @type {State} */
20973 function start(code) {
20974 const kind = self.containerState.type || (code === 42 || code === 43 || code === 45 ? "listUnordered" : "listOrdered");
20975 if (kind === "listUnordered" ? !self.containerState.marker || code === self.containerState.marker : asciiDigit(code)) {
20976 if (!self.containerState.type) {
20977 self.containerState.type = kind;
20978 effects.enter(kind, { _container: true });
20979 }
20980 if (kind === "listUnordered") {
20981 effects.enter("listItemPrefix");
20982 return code === 42 || code === 45 ? effects.check(thematicBreak$1, nok, atMarker)(code) : atMarker(code);
20983 }
20984 if (!self.interrupt || code === 49) {
20985 effects.enter("listItemPrefix");
20986 effects.enter("listItemValue");
20987 return inside(code);
20988 }
20989 }
20990 return nok(code);
20991 }
20992 /** @type {State} */
20993 function inside(code) {
20994 if (asciiDigit(code) && ++size < 10) {
20995 effects.consume(code);
20996 return inside;
20997 }
20998 if ((!self.interrupt || size < 2) && (self.containerState.marker ? code === self.containerState.marker : code === 41 || code === 46)) {
20999 effects.exit("listItemValue");
21000 return atMarker(code);
21001 }
21002 return nok(code);
21003 }
21004 /**
21005 * @type {State}
21006 **/
21007 function atMarker(code) {
21008 effects.enter("listItemMarker");
21009 effects.consume(code);
21010 effects.exit("listItemMarker");
21011 self.containerState.marker = self.containerState.marker || code;
21012 return effects.check(blankLine, self.interrupt ? nok : onBlank, effects.attempt(listItemPrefixWhitespaceConstruct, endOfPrefix, otherPrefix));
21013 }
21014 /** @type {State} */
21015 function onBlank(code) {
21016 self.containerState.initialBlankLine = true;
21017 initialSize++;
21018 return endOfPrefix(code);
21019 }
21020 /** @type {State} */
21021 function otherPrefix(code) {
21022 if (markdownSpace(code)) {
21023 effects.enter("listItemPrefixWhitespace");
21024 effects.consume(code);
21025 effects.exit("listItemPrefixWhitespace");
21026 return endOfPrefix;
21027 }
21028 return nok(code);
21029 }
21030 /** @type {State} */
21031 function endOfPrefix(code) {
21032 self.containerState.size = initialSize + self.sliceSerialize(effects.exit("listItemPrefix"), true).length;
21033 return ok(code);
21034 }
21035 }
21036 /**
21037 * @type {Tokenizer}
21038 * @this {TokenizeContext}
21039 */
21040 function tokenizeListContinuation(effects, ok, nok) {
21041 const self = this;
21042 self.containerState._closeFlow = void 0;
21043 return effects.check(blankLine, onBlank, notBlank);
21044 /** @type {State} */
21045 function onBlank(code) {
21046 self.containerState.furtherBlankLines = self.containerState.furtherBlankLines || self.containerState.initialBlankLine;
21047 return factorySpace(effects, ok, "listItemIndent", self.containerState.size + 1)(code);
21048 }
21049 /** @type {State} */
21050 function notBlank(code) {
21051 if (self.containerState.furtherBlankLines || !markdownSpace(code)) {
21052 self.containerState.furtherBlankLines = void 0;
21053 self.containerState.initialBlankLine = void 0;
21054 return notInCurrentItem(code);
21055 }
21056 self.containerState.furtherBlankLines = void 0;
21057 self.containerState.initialBlankLine = void 0;
21058 return effects.attempt(indentConstruct, ok, notInCurrentItem)(code);
21059 }
21060 /** @type {State} */
21061 function notInCurrentItem(code) {
21062 self.containerState._closeFlow = true;
21063 self.interrupt = void 0;
21064 return factorySpace(effects, effects.attempt(list$1, ok, nok), "linePrefix", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 4)(code);
21065 }
21066 }
21067 /**
21068 * @type {Tokenizer}
21069 * @this {TokenizeContext}
21070 */
21071 function tokenizeIndent(effects, ok, nok) {
21072 const self = this;
21073 return factorySpace(effects, afterPrefix, "listItemIndent", self.containerState.size + 1);
21074 /** @type {State} */
21075 function afterPrefix(code) {
21076 const tail = self.events[self.events.length - 1];
21077 return tail && tail[1].type === "listItemIndent" && tail[2].sliceSerialize(tail[1], true).length === self.containerState.size ? ok(code) : nok(code);
21078 }
21079 }
21080 /**
21081 * @type {Exiter}
21082 * @this {TokenizeContext}
21083 */
21084 function tokenizeListEnd(effects) {
21085 effects.exit(this.containerState.type);
21086 }
21087 /**
21088 * @type {Tokenizer}
21089 * @this {TokenizeContext}
21090 */
21091 function tokenizeListItemPrefixWhitespace(effects, ok, nok) {
21092 const self = this;
21093 return factorySpace(effects, afterPrefix, "listItemPrefixWhitespace", self.parser.constructs.disable.null.includes("codeIndented") ? void 0 : 5);
21094 /** @type {State} */
21095 function afterPrefix(code) {
21096 const tail = self.events[self.events.length - 1];
21097 return !markdownSpace(code) && tail && tail[1].type === "listItemPrefixWhitespace" ? ok(code) : nok(code);
21098 }
21099 }
21100 var list$1, listItemPrefixWhitespaceConstruct, indentConstruct;
21101 var init_list$1 = __esmMin((() => {
21102 init_micromark_factory_space();
21103 init_micromark_util_character();
21104 init_blank_line();
21105 init_thematic_break$1();
21106 list$1 = {
21107 name: "list",
21108 tokenize: tokenizeListStart,
21109 continuation: { tokenize: tokenizeListContinuation },
21110 exit: tokenizeListEnd
21111 };
21112 listItemPrefixWhitespaceConstruct = {
21113 tokenize: tokenizeListItemPrefixWhitespace,
21114 partial: true
21115 };
21116 indentConstruct = {
21117 tokenize: tokenizeIndent,
21118 partial: true
21119 };
21120 }));
21121
21122 //#endregion
21123 //#region node_modules/micromark-core-commonmark/lib/setext-underline.js
21124 /** @type {Resolver} */
21125 function resolveToSetextUnderline(events, context) {
21126 let index = events.length;
21127 /** @type {number | undefined} */
21128 let content;
21129 /** @type {number | undefined} */
21130 let text;
21131 /** @type {number | undefined} */
21132 let definition;
21133 while (index--) if (events[index][0] === "enter") {
21134 if (events[index][1].type === "content") {
21135 content = index;
21136 break;
21137 }
21138 if (events[index][1].type === "paragraph") text = index;
21139 } else {
21140 if (events[index][1].type === "content") events.splice(index, 1);
21141 if (!definition && events[index][1].type === "definition") definition = index;
21142 }
21143 const heading = {
21144 type: "setextHeading",
21145 start: Object.assign({}, events[text][1].start),
21146 end: Object.assign({}, events[events.length - 1][1].end)
21147 };
21148 events[text][1].type = "setextHeadingText";
21149 if (definition) {
21150 events.splice(text, 0, [
21151 "enter",
21152 heading,
21153 context
21154 ]);
21155 events.splice(definition + 1, 0, [
21156 "exit",
21157 events[content][1],
21158 context
21159 ]);
21160 events[content][1].end = Object.assign({}, events[definition][1].end);
21161 } else events[content][1] = heading;
21162 events.push([
21163 "exit",
21164 heading,
21165 context
21166 ]);
21167 return events;
21168 }
21169 /**
21170 * @this {TokenizeContext}
21171 * @type {Tokenizer}
21172 */
21173 function tokenizeSetextUnderline(effects, ok, nok) {
21174 const self = this;
21175 /** @type {NonNullable<Code>} */
21176 let marker;
21177 return start;
21178 /**
21179 * At start of heading (setext) underline.
21180 *
21181 * ```markdown
21182 * | aa
21183 * > | ==
21184 * ^
21185 * ```
21186 *
21187 * @type {State}
21188 */
21189 function start(code) {
21190 let index = self.events.length;
21191 /** @type {boolean | undefined} */
21192 let paragraph;
21193 while (index--) if (self.events[index][1].type !== "lineEnding" && self.events[index][1].type !== "linePrefix" && self.events[index][1].type !== "content") {
21194 paragraph = self.events[index][1].type === "paragraph";
21195 break;
21196 }
21197 if (!self.parser.lazy[self.now().line] && (self.interrupt || paragraph)) {
21198 effects.enter("setextHeadingLine");
21199 marker = code;
21200 return before(code);
21201 }
21202 return nok(code);
21203 }
21204 /**
21205 * After optional whitespace, at `-` or `=`.
21206 *
21207 * ```markdown
21208 * | aa
21209 * > | ==
21210 * ^
21211 * ```
21212 *
21213 * @type {State}
21214 */
21215 function before(code) {
21216 effects.enter("setextHeadingLineSequence");
21217 return inside(code);
21218 }
21219 /**
21220 * In sequence.
21221 *
21222 * ```markdown
21223 * | aa
21224 * > | ==
21225 * ^
21226 * ```
21227 *
21228 * @type {State}
21229 */
21230 function inside(code) {
21231 if (code === marker) {
21232 effects.consume(code);
21233 return inside;
21234 }
21235 effects.exit("setextHeadingLineSequence");
21236 return markdownSpace(code) ? factorySpace(effects, after, "lineSuffix")(code) : after(code);
21237 }
21238 /**
21239 * After sequence, after optional whitespace.
21240 *
21241 * ```markdown
21242 * | aa
21243 * > | ==
21244 * ^
21245 * ```
21246 *
21247 * @type {State}
21248 */
21249 function after(code) {
21250 if (code === null || markdownLineEnding(code)) {
21251 effects.exit("setextHeadingLine");
21252 return ok(code);
21253 }
21254 return nok(code);
21255 }
21256 }
21257 var setextUnderline;
21258 var init_setext_underline = __esmMin((() => {
21259 init_micromark_factory_space();
21260 init_micromark_util_character();
21261 setextUnderline = {
21262 name: "setextUnderline",
21263 tokenize: tokenizeSetextUnderline,
21264 resolveTo: resolveToSetextUnderline
21265 };
21266 }));
21267
21268 //#endregion
21269 //#region node_modules/micromark-core-commonmark/index.js
21270 var init_micromark_core_commonmark = __esmMin((() => {
21271 init_attention();
21272 init_autolink();
21273 init_blank_line();
21274 init_block_quote();
21275 init_character_escape();
21276 init_character_reference();
21277 init_code_fenced();
21278 init_code_indented();
21279 init_code_text();
21280 init_content();
21281 init_definition();
21282 init_hard_break_escape();
21283 init_heading_atx();
21284 init_html_flow();
21285 init_html_text();
21286 init_label_end();
21287 init_label_start_image();
21288 init_label_start_link();
21289 init_line_ending();
21290 init_list$1();
21291 init_setext_underline();
21292 init_thematic_break$1();
21293 }));
21294
21295 //#endregion
21296 //#region node_modules/micromark/lib/initialize/flow.js
21297 /**
21298 * @this {TokenizeContext}
21299 * @type {Initializer}
21300 */
21301 function initializeFlow(effects) {
21302 const self = this;
21303 const initial = effects.attempt(blankLine, atBlankEnding, effects.attempt(this.parser.constructs.flowInitial, afterConstruct, factorySpace(effects, effects.attempt(this.parser.constructs.flow, afterConstruct, effects.attempt(content, afterConstruct)), "linePrefix")));
21304 return initial;
21305 /** @type {State} */
21306 function atBlankEnding(code) {
21307 if (code === null) {
21308 effects.consume(code);
21309 return;
21310 }
21311 effects.enter("lineEndingBlank");
21312 effects.consume(code);
21313 effects.exit("lineEndingBlank");
21314 self.currentConstruct = void 0;
21315 return initial;
21316 }
21317 /** @type {State} */
21318 function afterConstruct(code) {
21319 if (code === null) {
21320 effects.consume(code);
21321 return;
21322 }
21323 effects.enter("lineEnding");
21324 effects.consume(code);
21325 effects.exit("lineEnding");
21326 self.currentConstruct = void 0;
21327 return initial;
21328 }
21329 }
21330 var flow$1;
21331 var init_flow = __esmMin((() => {
21332 init_micromark_core_commonmark();
21333 init_micromark_factory_space();
21334 flow$1 = { tokenize: initializeFlow };
21335 }));
21336
21337 //#endregion
21338 //#region node_modules/micromark/lib/initialize/text.js
21339 /**
21340 * @param {'string' | 'text'} field
21341 * @returns {InitialConstruct}
21342 */
21343 function initializeFactory(field) {
21344 return {
21345 tokenize: initializeText,
21346 resolveAll: createResolver(field === "text" ? resolveAllLineSuffixes : void 0)
21347 };
21348 /**
21349 * @this {TokenizeContext}
21350 * @type {Initializer}
21351 */
21352 function initializeText(effects) {
21353 const self = this;
21354 const constructs = this.parser.constructs[field];
21355 const text = effects.attempt(constructs, start, notText);
21356 return start;
21357 /** @type {State} */
21358 function start(code) {
21359 return atBreak(code) ? text(code) : notText(code);
21360 }
21361 /** @type {State} */
21362 function notText(code) {
21363 if (code === null) {
21364 effects.consume(code);
21365 return;
21366 }
21367 effects.enter("data");
21368 effects.consume(code);
21369 return data;
21370 }
21371 /** @type {State} */
21372 function data(code) {
21373 if (atBreak(code)) {
21374 effects.exit("data");
21375 return text(code);
21376 }
21377 effects.consume(code);
21378 return data;
21379 }
21380 /**
21381 * @param {Code} code
21382 * @returns {boolean}
21383 */
21384 function atBreak(code) {
21385 if (code === null) return true;
21386 const list = constructs[code];
21387 let index = -1;
21388 if (list) while (++index < list.length) {
21389 const item = list[index];
21390 if (!item.previous || item.previous.call(self, self.previous)) return true;
21391 }
21392 return false;
21393 }
21394 }
21395 }
21396 /**
21397 * @param {Resolver | undefined} [extraResolver]
21398 * @returns {Resolver}
21399 */
21400 function createResolver(extraResolver) {
21401 return resolveAllText;
21402 /** @type {Resolver} */
21403 function resolveAllText(events, context) {
21404 let index = -1;
21405 /** @type {number | undefined} */
21406 let enter;
21407 while (++index <= events.length) if (enter === void 0) {
21408 if (events[index] && events[index][1].type === "data") {
21409 enter = index;
21410 index++;
21411 }
21412 } else if (!events[index] || events[index][1].type !== "data") {
21413 if (index !== enter + 2) {
21414 events[enter][1].end = events[index - 1][1].end;
21415 events.splice(enter + 2, index - enter - 2);
21416 index = enter + 2;
21417 }
21418 enter = void 0;
21419 }
21420 return extraResolver ? extraResolver(events, context) : events;
21421 }
21422 }
21423 /**
21424 * A rather ugly set of instructions which again looks at chunks in the input
21425 * stream.
21426 * The reason to do this here is that it is *much* faster to parse in reverse.
21427 * And that we can’t hook into `null` to split the line suffix before an EOF.
21428 * To do: figure out if we can make this into a clean utility, or even in core.
21429 * As it will be useful for GFMs literal autolink extension (and maybe even
21430 * tables?)
21431 *
21432 * @type {Resolver}
21433 */
21434 function resolveAllLineSuffixes(events, context) {
21435 let eventIndex = 0;
21436 while (++eventIndex <= events.length) if ((eventIndex === events.length || events[eventIndex][1].type === "lineEnding") && events[eventIndex - 1][1].type === "data") {
21437 const data = events[eventIndex - 1][1];
21438 const chunks = context.sliceStream(data);
21439 let index = chunks.length;
21440 let bufferIndex = -1;
21441 let size = 0;
21442 /** @type {boolean | undefined} */
21443 let tabs;
21444 while (index--) {
21445 const chunk = chunks[index];
21446 if (typeof chunk === "string") {
21447 bufferIndex = chunk.length;
21448 while (chunk.charCodeAt(bufferIndex - 1) === 32) {
21449 size++;
21450 bufferIndex--;
21451 }
21452 if (bufferIndex) break;
21453 bufferIndex = -1;
21454 } else if (chunk === -2) {
21455 tabs = true;
21456 size++;
21457 } else if (chunk === -1) {} else {
21458 index++;
21459 break;
21460 }
21461 }
21462 if (size) {
21463 const token = {
21464 type: eventIndex === events.length || tabs || size < 2 ? "lineSuffix" : "hardBreakTrailing",
21465 start: {
21466 line: data.end.line,
21467 column: data.end.column - size,
21468 offset: data.end.offset - size,
21469 _index: data.start._index + index,
21470 _bufferIndex: index ? bufferIndex : data.start._bufferIndex + bufferIndex
21471 },
21472 end: Object.assign({}, data.end)
21473 };
21474 data.end = Object.assign({}, token.start);
21475 if (data.start.offset === data.end.offset) Object.assign(data, token);
21476 else {
21477 events.splice(eventIndex, 0, [
21478 "enter",
21479 token,
21480 context
21481 ], [
21482 "exit",
21483 token,
21484 context
21485 ]);
21486 eventIndex += 2;
21487 }
21488 }
21489 eventIndex++;
21490 }
21491 return events;
21492 }
21493 var resolver, string$1, text$2;
21494 var init_text$1 = __esmMin((() => {
21495 resolver = { resolveAll: createResolver() };
21496 string$1 = initializeFactory("string");
21497 text$2 = initializeFactory("text");
21498 }));
21499
21500 //#endregion
21501 //#region node_modules/micromark/lib/create-tokenizer.js
21502 /**
21503 * Create a tokenizer.
21504 * Tokenizers deal with one type of data (e.g., containers, flow, text).
21505 * The parser is the object dealing with it all.
21506 * `initialize` works like other constructs, except that only its `tokenize`
21507 * function is used, in which case it doesn’t receive an `ok` or `nok`.
21508 * `from` can be given to set the point before the first character, although
21509 * when further lines are indented, they must be set with `defineSkip`.
21510 *
21511 * @param {ParseContext} parser
21512 * @param {InitialConstruct} initialize
21513 * @param {Omit<Point, '_bufferIndex' | '_index'> | undefined} [from]
21514 * @returns {TokenizeContext}
21515 */
21516 function createTokenizer(parser, initialize, from) {
21517 /** @type {Point} */
21518 let point = Object.assign(from ? Object.assign({}, from) : {
21519 line: 1,
21520 column: 1,
21521 offset: 0
21522 }, {
21523 _index: 0,
21524 _bufferIndex: -1
21525 });
21526 /** @type {Record<string, number>} */
21527 const columnStart = {};
21528 /** @type {Array<Construct>} */
21529 const resolveAllConstructs = [];
21530 /** @type {Array<Chunk>} */
21531 let chunks = [];
21532 /** @type {Array<Token>} */
21533 let stack = [];
21534 /**
21535 * Tools used for tokenizing.
21536 *
21537 * @type {Effects}
21538 */
21539 const effects = {
21540 consume,
21541 enter,
21542 exit,
21543 attempt: constructFactory(onsuccessfulconstruct),
21544 check: constructFactory(onsuccessfulcheck),
21545 interrupt: constructFactory(onsuccessfulcheck, { interrupt: true })
21546 };
21547 /**
21548 * State and tools for resolving and serializing.
21549 *
21550 * @type {TokenizeContext}
21551 */
21552 const context = {
21553 previous: null,
21554 code: null,
21555 containerState: {},
21556 events: [],
21557 parser,
21558 sliceStream,
21559 sliceSerialize,
21560 now,
21561 defineSkip,
21562 write
21563 };
21564 /**
21565 * The state function.
21566 *
21567 * @type {State | void}
21568 */
21569 let state = initialize.tokenize.call(context, effects);
21570 if (initialize.resolveAll) resolveAllConstructs.push(initialize);
21571 return context;
21572 /** @type {TokenizeContext['write']} */
21573 function write(slice) {
21574 chunks = push(chunks, slice);
21575 main();
21576 if (chunks[chunks.length - 1] !== null) return [];
21577 addResult(initialize, 0);
21578 context.events = resolveAll(resolveAllConstructs, context.events, context);
21579 return context.events;
21580 }
21581 /** @type {TokenizeContext['sliceSerialize']} */
21582 function sliceSerialize(token, expandTabs) {
21583 return serializeChunks(sliceStream(token), expandTabs);
21584 }
21585 /** @type {TokenizeContext['sliceStream']} */
21586 function sliceStream(token) {
21587 return sliceChunks(chunks, token);
21588 }
21589 /** @type {TokenizeContext['now']} */
21590 function now() {
21591 const { line, column, offset, _index, _bufferIndex } = point;
21592 return {
21593 line,
21594 column,
21595 offset,
21596 _index,
21597 _bufferIndex
21598 };
21599 }
21600 /** @type {TokenizeContext['defineSkip']} */
21601 function defineSkip(value) {
21602 columnStart[value.line] = value.column;
21603 accountForPotentialSkip();
21604 }
21605 /**
21606 * Main loop (note that `_index` and `_bufferIndex` in `point` are modified by
21607 * `consume`).
21608 * Here is where we walk through the chunks, which either include strings of
21609 * several characters, or numerical character codes.
21610 * The reason to do this in a loop instead of a call is so the stack can
21611 * drain.
21612 *
21613 * @returns {void}
21614 */
21615 function main() {
21616 /** @type {number} */
21617 let chunkIndex;
21618 while (point._index < chunks.length) {
21619 const chunk = chunks[point._index];
21620 if (typeof chunk === "string") {
21621 chunkIndex = point._index;
21622 if (point._bufferIndex < 0) point._bufferIndex = 0;
21623 while (point._index === chunkIndex && point._bufferIndex < chunk.length) go(chunk.charCodeAt(point._bufferIndex));
21624 } else go(chunk);
21625 }
21626 }
21627 /**
21628 * Deal with one code.
21629 *
21630 * @param {Code} code
21631 * @returns {void}
21632 */
21633 function go(code) {
21634 state = state(code);
21635 }
21636 /** @type {Effects['consume']} */
21637 function consume(code) {
21638 if (markdownLineEnding(code)) {
21639 point.line++;
21640 point.column = 1;
21641 point.offset += code === -3 ? 2 : 1;
21642 accountForPotentialSkip();
21643 } else if (code !== -1) {
21644 point.column++;
21645 point.offset++;
21646 }
21647 if (point._bufferIndex < 0) point._index++;
21648 else {
21649 point._bufferIndex++;
21650 if (point._bufferIndex === chunks[point._index].length) {
21651 point._bufferIndex = -1;
21652 point._index++;
21653 }
21654 }
21655 context.previous = code;
21656 }
21657 /** @type {Effects['enter']} */
21658 function enter(type, fields) {
21659 /** @type {Token} */
21660 const token = fields || {};
21661 token.type = type;
21662 token.start = now();
21663 context.events.push([
21664 "enter",
21665 token,
21666 context
21667 ]);
21668 stack.push(token);
21669 return token;
21670 }
21671 /** @type {Effects['exit']} */
21672 function exit(type) {
21673 const token = stack.pop();
21674 token.end = now();
21675 context.events.push([
21676 "exit",
21677 token,
21678 context
21679 ]);
21680 return token;
21681 }
21682 /**
21683 * Use results.
21684 *
21685 * @type {ReturnHandle}
21686 */
21687 function onsuccessfulconstruct(construct, info) {
21688 addResult(construct, info.from);
21689 }
21690 /**
21691 * Discard results.
21692 *
21693 * @type {ReturnHandle}
21694 */
21695 function onsuccessfulcheck(_, info) {
21696 info.restore();
21697 }
21698 /**
21699 * Factory to attempt/check/interrupt.
21700 *
21701 * @param {ReturnHandle} onreturn
21702 * @param {{interrupt?: boolean | undefined} | undefined} [fields]
21703 */
21704 function constructFactory(onreturn, fields) {
21705 return hook;
21706 /**
21707 * Handle either an object mapping codes to constructs, a list of
21708 * constructs, or a single construct.
21709 *
21710 * @param {Array<Construct> | Construct | ConstructRecord} constructs
21711 * @param {State} returnState
21712 * @param {State | undefined} [bogusState]
21713 * @returns {State}
21714 */
21715 function hook(constructs, returnState, bogusState) {
21716 /** @type {Array<Construct>} */
21717 let listOfConstructs;
21718 /** @type {number} */
21719 let constructIndex;
21720 /** @type {Construct} */
21721 let currentConstruct;
21722 /** @type {Info} */
21723 let info;
21724 return Array.isArray(constructs) ? handleListOfConstructs(constructs) : "tokenize" in constructs ? handleListOfConstructs([constructs]) : handleMapOfConstructs(constructs);
21725 /**
21726 * Handle a list of construct.
21727 *
21728 * @param {ConstructRecord} map
21729 * @returns {State}
21730 */
21731 function handleMapOfConstructs(map) {
21732 return start;
21733 /** @type {State} */
21734 function start(code) {
21735 const def = code !== null && map[code];
21736 const all = code !== null && map.null;
21737 return handleListOfConstructs([...Array.isArray(def) ? def : def ? [def] : [], ...Array.isArray(all) ? all : all ? [all] : []])(code);
21738 }
21739 }
21740 /**
21741 * Handle a list of construct.
21742 *
21743 * @param {Array<Construct>} list
21744 * @returns {State}
21745 */
21746 function handleListOfConstructs(list) {
21747 listOfConstructs = list;
21748 constructIndex = 0;
21749 if (list.length === 0) return bogusState;
21750 return handleConstruct(list[constructIndex]);
21751 }
21752 /**
21753 * Handle a single construct.
21754 *
21755 * @param {Construct} construct
21756 * @returns {State}
21757 */
21758 function handleConstruct(construct) {
21759 return start;
21760 /** @type {State} */
21761 function start(code) {
21762 info = store();
21763 currentConstruct = construct;
21764 if (!construct.partial) context.currentConstruct = construct;
21765 if (construct.name && context.parser.constructs.disable.null.includes(construct.name)) return nok(code);
21766 return construct.tokenize.call(fields ? Object.assign(Object.create(context), fields) : context, effects, ok, nok)(code);
21767 }
21768 }
21769 /** @type {State} */
21770 function ok(code) {
21771 onreturn(currentConstruct, info);
21772 return returnState;
21773 }
21774 /** @type {State} */
21775 function nok(code) {
21776 info.restore();
21777 if (++constructIndex < listOfConstructs.length) return handleConstruct(listOfConstructs[constructIndex]);
21778 return bogusState;
21779 }
21780 }
21781 }
21782 /**
21783 * @param {Construct} construct
21784 * @param {number} from
21785 * @returns {void}
21786 */
21787 function addResult(construct, from) {
21788 if (construct.resolveAll && !resolveAllConstructs.includes(construct)) resolveAllConstructs.push(construct);
21789 if (construct.resolve) splice(context.events, from, context.events.length - from, construct.resolve(context.events.slice(from), context));
21790 if (construct.resolveTo) context.events = construct.resolveTo(context.events, context);
21791 }
21792 /**
21793 * Store state.
21794 *
21795 * @returns {Info}
21796 */
21797 function store() {
21798 const startPoint = now();
21799 const startPrevious = context.previous;
21800 const startCurrentConstruct = context.currentConstruct;
21801 const startEventsIndex = context.events.length;
21802 const startStack = Array.from(stack);
21803 return {
21804 restore,
21805 from: startEventsIndex
21806 };
21807 /**
21808 * Restore state.
21809 *
21810 * @returns {void}
21811 */
21812 function restore() {
21813 point = startPoint;
21814 context.previous = startPrevious;
21815 context.currentConstruct = startCurrentConstruct;
21816 context.events.length = startEventsIndex;
21817 stack = startStack;
21818 accountForPotentialSkip();
21819 }
21820 }
21821 /**
21822 * Move the current point a bit forward in the line when it’s on a column
21823 * skip.
21824 *
21825 * @returns {void}
21826 */
21827 function accountForPotentialSkip() {
21828 if (point.line in columnStart && point.column < 2) {
21829 point.column = columnStart[point.line];
21830 point.offset += columnStart[point.line] - 1;
21831 }
21832 }
21833 }
21834 /**
21835 * Get the chunks from a slice of chunks in the range of a token.
21836 *
21837 * @param {Array<Chunk>} chunks
21838 * @param {Pick<Token, 'end' | 'start'>} token
21839 * @returns {Array<Chunk>}
21840 */
21841 function sliceChunks(chunks, token) {
21842 const startIndex = token.start._index;
21843 const startBufferIndex = token.start._bufferIndex;
21844 const endIndex = token.end._index;
21845 const endBufferIndex = token.end._bufferIndex;
21846 /** @type {Array<Chunk>} */
21847 let view;
21848 if (startIndex === endIndex) view = [chunks[startIndex].slice(startBufferIndex, endBufferIndex)];
21849 else {
21850 view = chunks.slice(startIndex, endIndex);
21851 if (startBufferIndex > -1) {
21852 const head = view[0];
21853 if (typeof head === "string") view[0] = head.slice(startBufferIndex);
21854 else view.shift();
21855 }
21856 if (endBufferIndex > 0) view.push(chunks[endIndex].slice(0, endBufferIndex));
21857 }
21858 return view;
21859 }
21860 /**
21861 * Get the string value of a slice of chunks.
21862 *
21863 * @param {Array<Chunk>} chunks
21864 * @param {boolean | undefined} [expandTabs=false]
21865 * @returns {string}
21866 */
21867 function serializeChunks(chunks, expandTabs) {
21868 let index = -1;
21869 /** @type {Array<string>} */
21870 const result = [];
21871 /** @type {boolean | undefined} */
21872 let atTab;
21873 while (++index < chunks.length) {
21874 const chunk = chunks[index];
21875 /** @type {string} */
21876 let value;
21877 if (typeof chunk === "string") value = chunk;
21878 else switch (chunk) {
21879 case -5:
21880 value = "\r";
21881 break;
21882 case -4:
21883 value = "\n";
21884 break;
21885 case -3:
21886 value = "\r\n";
21887 break;
21888 case -2:
21889 value = expandTabs ? " " : " ";
21890 break;
21891 case -1:
21892 if (!expandTabs && atTab) continue;
21893 value = " ";
21894 break;
21895 default: value = String.fromCharCode(chunk);
21896 }
21897 atTab = chunk === -2;
21898 result.push(value);
21899 }
21900 return result.join("");
21901 }
21902 var init_create_tokenizer = __esmMin((() => {
21903 init_micromark_util_character();
21904 init_micromark_util_chunked();
21905 init_micromark_util_resolve_all();
21906 }));
21907
21908 //#endregion
21909 //#region node_modules/micromark/lib/constructs.js
21910 var constructs_exports = /* @__PURE__ */ __exportAll({
21911 attentionMarkers: () => attentionMarkers,
21912 contentInitial: () => contentInitial,
21913 disable: () => disable,
21914 document: () => document$1,
21915 flow: () => flow,
21916 flowInitial: () => flowInitial,
21917 insideSpan: () => insideSpan,
21918 string: () => string,
21919 text: () => text$1
21920 });
21921 var document$1, contentInitial, flowInitial, flow, string, text$1, insideSpan, attentionMarkers, disable;
21922 var init_constructs = __esmMin((() => {
21923 init_micromark_core_commonmark();
21924 init_text$1();
21925 document$1 = {
21926 [42]: list$1,
21927 [43]: list$1,
21928 [45]: list$1,
21929 [48]: list$1,
21930 [49]: list$1,
21931 [50]: list$1,
21932 [51]: list$1,
21933 [52]: list$1,
21934 [53]: list$1,
21935 [54]: list$1,
21936 [55]: list$1,
21937 [56]: list$1,
21938 [57]: list$1,
21939 [62]: blockQuote
21940 };
21941 contentInitial = { [91]: definition };
21942 flowInitial = {
21943 [-2]: codeIndented,
21944 [-1]: codeIndented,
21945 [32]: codeIndented
21946 };
21947 flow = {
21948 [35]: headingAtx,
21949 [42]: thematicBreak$1,
21950 [45]: [setextUnderline, thematicBreak$1],
21951 [60]: htmlFlow,
21952 [61]: setextUnderline,
21953 [95]: thematicBreak$1,
21954 [96]: codeFenced,
21955 [126]: codeFenced
21956 };
21957 string = {
21958 [38]: characterReference,
21959 [92]: characterEscape
21960 };
21961 text$1 = {
21962 [-5]: lineEnding,
21963 [-4]: lineEnding,
21964 [-3]: lineEnding,
21965 [33]: labelStartImage,
21966 [38]: characterReference,
21967 [42]: attention,
21968 [60]: [autolink, htmlText],
21969 [91]: labelStartLink,
21970 [92]: [hardBreakEscape, characterEscape],
21971 [93]: labelEnd,
21972 [95]: attention,
21973 [96]: codeText
21974 };
21975 insideSpan = { null: [attention, resolver] };
21976 attentionMarkers = { null: [42, 95] };
21977 disable = { null: [] };
21978 }));
21979
21980 //#endregion
21981 //#region node_modules/micromark/lib/parse.js
21982 /**
21983 * @param {ParseOptions | null | undefined} [options]
21984 * @returns {ParseContext}
21985 */
21986 function parse(options) {
21987 /** @type {ParseContext} */
21988 const parser = {
21989 defined: [],
21990 lazy: {},
21991 constructs: combineExtensions([constructs_exports, ...(options || {}).extensions || []]),
21992 content: create(content$1),
21993 document: create(document$2),
21994 flow: create(flow$1),
21995 string: create(string$1),
21996 text: create(text$2)
21997 };
21998 return parser;
21999 /**
22000 * @param {InitialConstruct} initial
22001 */
22002 function create(initial) {
22003 return creator;
22004 /** @type {Create} */
22005 function creator(from) {
22006 return createTokenizer(parser, initial, from);
22007 }
22008 }
22009 }
22010 var init_parse = __esmMin((() => {
22011 init_micromark_util_combine_extensions();
22012 init_content$1();
22013 init_document();
22014 init_flow();
22015 init_text$1();
22016 init_create_tokenizer();
22017 init_constructs();
22018 }));
22019
22020 //#endregion
22021 //#region node_modules/micromark/lib/preprocess.js
22022 /**
22023 * @returns {Preprocessor}
22024 */
22025 function preprocess() {
22026 let column = 1;
22027 let buffer = "";
22028 /** @type {boolean | undefined} */
22029 let start = true;
22030 /** @type {boolean | undefined} */
22031 let atCarriageReturn;
22032 return preprocessor;
22033 /** @type {Preprocessor} */
22034 function preprocessor(value, encoding, end) {
22035 /** @type {Array<Chunk>} */
22036 const chunks = [];
22037 /** @type {RegExpMatchArray | null} */
22038 let match;
22039 /** @type {number} */
22040 let next;
22041 /** @type {number} */
22042 let startPosition;
22043 /** @type {number} */
22044 let endPosition;
22045 /** @type {Code} */
22046 let code;
22047 value = buffer + value.toString(encoding);
22048 startPosition = 0;
22049 buffer = "";
22050 if (start) {
22051 if (value.charCodeAt(0) === 65279) startPosition++;
22052 start = void 0;
22053 }
22054 while (startPosition < value.length) {
22055 search.lastIndex = startPosition;
22056 match = search.exec(value);
22057 endPosition = match && match.index !== void 0 ? match.index : value.length;
22058 code = value.charCodeAt(endPosition);
22059 if (!match) {
22060 buffer = value.slice(startPosition);
22061 break;
22062 }
22063 if (code === 10 && startPosition === endPosition && atCarriageReturn) {
22064 chunks.push(-3);
22065 atCarriageReturn = void 0;
22066 } else {
22067 if (atCarriageReturn) {
22068 chunks.push(-5);
22069 atCarriageReturn = void 0;
22070 }
22071 if (startPosition < endPosition) {
22072 chunks.push(value.slice(startPosition, endPosition));
22073 column += endPosition - startPosition;
22074 }
22075 switch (code) {
22076 case 0:
22077 chunks.push(65533);
22078 column++;
22079 break;
22080 case 9:
22081 next = Math.ceil(column / 4) * 4;
22082 chunks.push(-2);
22083 while (column++ < next) chunks.push(-1);
22084 break;
22085 case 10:
22086 chunks.push(-4);
22087 column = 1;
22088 break;
22089 default:
22090 atCarriageReturn = true;
22091 column = 1;
22092 }
22093 }
22094 startPosition = endPosition + 1;
22095 }
22096 if (end) {
22097 if (atCarriageReturn) chunks.push(-5);
22098 if (buffer) chunks.push(buffer);
22099 chunks.push(null);
22100 }
22101 return chunks;
22102 }
22103 }
22104 var search;
22105 var init_preprocess = __esmMin((() => {
22106 search = /[\0\t\n\r]/g;
22107 }));
22108
22109 //#endregion
22110 //#region node_modules/micromark/lib/postprocess.js
22111 /**
22112 * @param {Array<Event>} events
22113 * @returns {Array<Event>}
22114 */
22115 function postprocess(events) {
22116 while (!subtokenize(events));
22117 return events;
22118 }
22119 var init_postprocess = __esmMin((() => {
22120 init_micromark_util_subtokenize();
22121 }));
22122
22123 //#endregion
22124 //#region node_modules/micromark-util-decode-numeric-character-reference/index.js
22125 /**
22126 * Turn the number (in string form as either hexa- or plain decimal) coming from
22127 * a numeric character reference into a character.
22128 *
22129 * Sort of like `String.fromCharCode(Number.parseInt(value, base))`, but makes
22130 * non-characters and control characters safe.
22131 *
22132 * @param {string} value
22133 * Value to decode.
22134 * @param {number} base
22135 * Numeric base.
22136 * @returns {string}
22137 * Character.
22138 */
22139 function decodeNumericCharacterReference(value, base) {
22140 const code = Number.parseInt(value, base);
22141 if (code < 9 || code === 11 || code > 13 && code < 32 || code > 126 && code < 160 || code > 55295 && code < 57344 || code > 64975 && code < 65008 || (code & 65535) === 65535 || (code & 65535) === 65534 || code > 1114111) return "�";
22142 return String.fromCharCode(code);
22143 }
22144 var init_micromark_util_decode_numeric_character_reference = __esmMin((() => {}));
22145
22146 //#endregion
22147 //#region node_modules/micromark-util-decode-string/index.js
22148 /**
22149 * Decode markdown strings (which occur in places such as fenced code info
22150 * strings, destinations, labels, and titles).
22151 *
22152 * The “string” content type allows character escapes and -references.
22153 * This decodes those.
22154 *
22155 * @param {string} value
22156 * Value to decode.
22157 * @returns {string}
22158 * Decoded value.
22159 */
22160 function decodeString(value) {
22161 return value.replace(characterEscapeOrReference, decode);
22162 }
22163 /**
22164 * @param {string} $0
22165 * @param {string} $1
22166 * @param {string} $2
22167 * @returns {string}
22168 */
22169 function decode($0, $1, $2) {
22170 if ($1) return $1;
22171 if ($2.charCodeAt(0) === 35) {
22172 const head = $2.charCodeAt(1);
22173 const hex = head === 120 || head === 88;
22174 return decodeNumericCharacterReference($2.slice(hex ? 2 : 1), hex ? 16 : 10);
22175 }
22176 return decodeNamedCharacterReference($2) || $0;
22177 }
22178 var characterEscapeOrReference;
22179 var init_micromark_util_decode_string = __esmMin((() => {
22180 init_index_dom();
22181 init_micromark_util_decode_numeric_character_reference();
22182 characterEscapeOrReference = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
22183 }));
22184
22185 //#endregion
22186 //#region node_modules/mdast-util-from-markdown/lib/index.js
22187 /**
22188 * Note this compiler only understand complete buffering, not streaming.
22189 *
22190 * @param {Options | null | undefined} [options]
22191 */
22192 function compiler(options) {
22193 /** @type {Config} */
22194 const config = {
22195 transforms: [],
22196 canContainEols: [
22197 "emphasis",
22198 "fragment",
22199 "heading",
22200 "paragraph",
22201 "strong"
22202 ],
22203 enter: {
22204 autolink: opener(link),
22205 autolinkProtocol: onenterdata,
22206 autolinkEmail: onenterdata,
22207 atxHeading: opener(heading),
22208 blockQuote: opener(blockQuote),
22209 characterEscape: onenterdata,
22210 characterReference: onenterdata,
22211 codeFenced: opener(codeFlow),
22212 codeFencedFenceInfo: buffer,
22213 codeFencedFenceMeta: buffer,
22214 codeIndented: opener(codeFlow, buffer),
22215 codeText: opener(codeText, buffer),
22216 codeTextData: onenterdata,
22217 data: onenterdata,
22218 codeFlowValue: onenterdata,
22219 definition: opener(definition),
22220 definitionDestinationString: buffer,
22221 definitionLabelString: buffer,
22222 definitionTitleString: buffer,
22223 emphasis: opener(emphasis),
22224 hardBreakEscape: opener(hardBreak),
22225 hardBreakTrailing: opener(hardBreak),
22226 htmlFlow: opener(html, buffer),
22227 htmlFlowData: onenterdata,
22228 htmlText: opener(html, buffer),
22229 htmlTextData: onenterdata,
22230 image: opener(image),
22231 label: buffer,
22232 link: opener(link),
22233 listItem: opener(listItem),
22234 listItemValue: onenterlistitemvalue,
22235 listOrdered: opener(list, onenterlistordered),
22236 listUnordered: opener(list),
22237 paragraph: opener(paragraph),
22238 reference: onenterreference,
22239 referenceString: buffer,
22240 resourceDestinationString: buffer,
22241 resourceTitleString: buffer,
22242 setextHeading: opener(heading),
22243 strong: opener(strong),
22244 thematicBreak: opener(thematicBreak)
22245 },
22246 exit: {
22247 atxHeading: closer(),
22248 atxHeadingSequence: onexitatxheadingsequence,
22249 autolink: closer(),
22250 autolinkEmail: onexitautolinkemail,
22251 autolinkProtocol: onexitautolinkprotocol,
22252 blockQuote: closer(),
22253 characterEscapeValue: onexitdata,
22254 characterReferenceMarkerHexadecimal: onexitcharacterreferencemarker,
22255 characterReferenceMarkerNumeric: onexitcharacterreferencemarker,
22256 characterReferenceValue: onexitcharacterreferencevalue,
22257 codeFenced: closer(onexitcodefenced),
22258 codeFencedFence: onexitcodefencedfence,
22259 codeFencedFenceInfo: onexitcodefencedfenceinfo,
22260 codeFencedFenceMeta: onexitcodefencedfencemeta,
22261 codeFlowValue: onexitdata,
22262 codeIndented: closer(onexitcodeindented),
22263 codeText: closer(onexitcodetext),
22264 codeTextData: onexitdata,
22265 data: onexitdata,
22266 definition: closer(),
22267 definitionDestinationString: onexitdefinitiondestinationstring,
22268 definitionLabelString: onexitdefinitionlabelstring,
22269 definitionTitleString: onexitdefinitiontitlestring,
22270 emphasis: closer(),
22271 hardBreakEscape: closer(onexithardbreak),
22272 hardBreakTrailing: closer(onexithardbreak),
22273 htmlFlow: closer(onexithtmlflow),
22274 htmlFlowData: onexitdata,
22275 htmlText: closer(onexithtmltext),
22276 htmlTextData: onexitdata,
22277 image: closer(onexitimage),
22278 label: onexitlabel,
22279 labelText: onexitlabeltext,
22280 lineEnding: onexitlineending,
22281 link: closer(onexitlink),
22282 listItem: closer(),
22283 listOrdered: closer(),
22284 listUnordered: closer(),
22285 paragraph: closer(),
22286 referenceString: onexitreferencestring,
22287 resourceDestinationString: onexitresourcedestinationstring,
22288 resourceTitleString: onexitresourcetitlestring,
22289 resource: onexitresource,
22290 setextHeading: closer(onexitsetextheading),
22291 setextHeadingLineSequence: onexitsetextheadinglinesequence,
22292 setextHeadingText: onexitsetextheadingtext,
22293 strong: closer(),
22294 thematicBreak: closer()
22295 }
22296 };
22297 configure(config, (options || {}).mdastExtensions || []);
22298 /** @type {CompileData} */
22299 const data = {};
22300 return compile;
22301 /**
22302 * Turn micromark events into an mdast tree.
22303 *
22304 * @param {Array<Event>} events
22305 * Events.
22306 * @returns {Root}
22307 * mdast tree.
22308 */
22309 function compile(events) {
22310 /** @type {Root} */
22311 let tree = {
22312 type: "root",
22313 children: []
22314 };
22315 /** @type {Omit<CompileContext, 'sliceSerialize'>} */
22316 const context = {
22317 stack: [tree],
22318 tokenStack: [],
22319 config,
22320 enter,
22321 exit,
22322 buffer,
22323 resume,
22324 setData,
22325 getData
22326 };
22327 /** @type {Array<number>} */
22328 const listStack = [];
22329 let index = -1;
22330 while (++index < events.length) if (events[index][1].type === "listOrdered" || events[index][1].type === "listUnordered") if (events[index][0] === "enter") listStack.push(index);
22331 else index = prepareList(events, listStack.pop(), index);
22332 index = -1;
22333 while (++index < events.length) {
22334 const handler = config[events[index][0]];
22335 if (own$5.call(handler, events[index][1].type)) handler[events[index][1].type].call(Object.assign({ sliceSerialize: events[index][2].sliceSerialize }, context), events[index][1]);
22336 }
22337 if (context.tokenStack.length > 0) {
22338 const tail = context.tokenStack[context.tokenStack.length - 1];
22339 (tail[1] || defaultOnError).call(context, void 0, tail[0]);
22340 }
22341 tree.position = {
22342 start: point$1(events.length > 0 ? events[0][1].start : {
22343 line: 1,
22344 column: 1,
22345 offset: 0
22346 }),
22347 end: point$1(events.length > 0 ? events[events.length - 2][1].end : {
22348 line: 1,
22349 column: 1,
22350 offset: 0
22351 })
22352 };
22353 index = -1;
22354 while (++index < config.transforms.length) tree = config.transforms[index](tree) || tree;
22355 return tree;
22356 }
22357 /**
22358 * @param {Array<Event>} events
22359 * @param {number} start
22360 * @param {number} length
22361 * @returns {number}
22362 */
22363 function prepareList(events, start, length) {
22364 let index = start - 1;
22365 let containerBalance = -1;
22366 let listSpread = false;
22367 /** @type {Token | undefined} */
22368 let listItem;
22369 /** @type {number | undefined} */
22370 let lineIndex;
22371 /** @type {number | undefined} */
22372 let firstBlankLineIndex;
22373 /** @type {boolean | undefined} */
22374 let atMarker;
22375 while (++index <= length) {
22376 const event = events[index];
22377 if (event[1].type === "listUnordered" || event[1].type === "listOrdered" || event[1].type === "blockQuote") {
22378 if (event[0] === "enter") containerBalance++;
22379 else containerBalance--;
22380 atMarker = void 0;
22381 } else if (event[1].type === "lineEndingBlank") {
22382 if (event[0] === "enter") {
22383 if (listItem && !atMarker && !containerBalance && !firstBlankLineIndex) firstBlankLineIndex = index;
22384 atMarker = void 0;
22385 }
22386 } else if (event[1].type === "linePrefix" || event[1].type === "listItemValue" || event[1].type === "listItemMarker" || event[1].type === "listItemPrefix" || event[1].type === "listItemPrefixWhitespace") {} else atMarker = void 0;
22387 if (!containerBalance && event[0] === "enter" && event[1].type === "listItemPrefix" || containerBalance === -1 && event[0] === "exit" && (event[1].type === "listUnordered" || event[1].type === "listOrdered")) {
22388 if (listItem) {
22389 let tailIndex = index;
22390 lineIndex = void 0;
22391 while (tailIndex--) {
22392 const tailEvent = events[tailIndex];
22393 if (tailEvent[1].type === "lineEnding" || tailEvent[1].type === "lineEndingBlank") {
22394 if (tailEvent[0] === "exit") continue;
22395 if (lineIndex) {
22396 events[lineIndex][1].type = "lineEndingBlank";
22397 listSpread = true;
22398 }
22399 tailEvent[1].type = "lineEnding";
22400 lineIndex = tailIndex;
22401 } else if (tailEvent[1].type === "linePrefix" || tailEvent[1].type === "blockQuotePrefix" || tailEvent[1].type === "blockQuotePrefixWhitespace" || tailEvent[1].type === "blockQuoteMarker" || tailEvent[1].type === "listItemIndent") {} else break;
22402 }
22403 if (firstBlankLineIndex && (!lineIndex || firstBlankLineIndex < lineIndex)) listItem._spread = true;
22404 listItem.end = Object.assign({}, lineIndex ? events[lineIndex][1].start : event[1].end);
22405 events.splice(lineIndex || index, 0, [
22406 "exit",
22407 listItem,
22408 event[2]
22409 ]);
22410 index++;
22411 length++;
22412 }
22413 if (event[1].type === "listItemPrefix") {
22414 listItem = {
22415 type: "listItem",
22416 _spread: false,
22417 start: Object.assign({}, event[1].start),
22418 end: void 0
22419 };
22420 events.splice(index, 0, [
22421 "enter",
22422 listItem,
22423 event[2]
22424 ]);
22425 index++;
22426 length++;
22427 firstBlankLineIndex = void 0;
22428 atMarker = true;
22429 }
22430 }
22431 }
22432 events[start][1]._spread = listSpread;
22433 return length;
22434 }
22435 /**
22436 * Set data.
22437 *
22438 * @template {keyof CompileData} Key
22439 * Field type.
22440 * @param {Key} key
22441 * Key of field.
22442 * @param {CompileData[Key]} [value]
22443 * New value.
22444 * @returns {void}
22445 * Nothing.
22446 */
22447 function setData(key, value) {
22448 data[key] = value;
22449 }
22450 /**
22451 * Get data.
22452 *
22453 * @template {keyof CompileData} Key
22454 * Field type.
22455 * @param {Key} key
22456 * Key of field.
22457 * @returns {CompileData[Key]}
22458 * Value.
22459 */
22460 function getData(key) {
22461 return data[key];
22462 }
22463 /**
22464 * Create an opener handle.
22465 *
22466 * @param {(token: Token) => Node} create
22467 * Create a node.
22468 * @param {Handle} [and]
22469 * Optional function to also run.
22470 * @returns {Handle}
22471 * Handle.
22472 */
22473 function opener(create, and) {
22474 return open;
22475 /**
22476 * @this {CompileContext}
22477 * @param {Token} token
22478 * @returns {void}
22479 */
22480 function open(token) {
22481 enter.call(this, create(token), token);
22482 if (and) and.call(this, token);
22483 }
22484 }
22485 /**
22486 * @this {CompileContext}
22487 * @returns {void}
22488 */
22489 function buffer() {
22490 this.stack.push({
22491 type: "fragment",
22492 children: []
22493 });
22494 }
22495 /**
22496 * @template {Node} Kind
22497 * Node type.
22498 * @this {CompileContext}
22499 * Context.
22500 * @param {Kind} node
22501 * Node to enter.
22502 * @param {Token} token
22503 * Corresponding token.
22504 * @param {OnEnterError | undefined} [errorHandler]
22505 * Handle the case where this token is open, but it is closed by something else.
22506 * @returns {Kind}
22507 * The given node.
22508 */
22509 function enter(node, token, errorHandler) {
22510 this.stack[this.stack.length - 1].children.push(node);
22511 this.stack.push(node);
22512 this.tokenStack.push([token, errorHandler]);
22513 node.position = { start: point$1(token.start) };
22514 return node;
22515 }
22516 /**
22517 * Create a closer handle.
22518 *
22519 * @param {Handle} [and]
22520 * Optional function to also run.
22521 * @returns {Handle}
22522 * Handle.
22523 */
22524 function closer(and) {
22525 return close;
22526 /**
22527 * @this {CompileContext}
22528 * @param {Token} token
22529 * @returns {void}
22530 */
22531 function close(token) {
22532 if (and) and.call(this, token);
22533 exit.call(this, token);
22534 }
22535 }
22536 /**
22537 * @this {CompileContext}
22538 * Context.
22539 * @param {Token} token
22540 * Corresponding token.
22541 * @param {OnExitError | undefined} [onExitError]
22542 * Handle the case where another token is open.
22543 * @returns {Node}
22544 * The closed node.
22545 */
22546 function exit(token, onExitError) {
22547 const node = this.stack.pop();
22548 const open = this.tokenStack.pop();
22549 if (!open) throw new Error("Cannot close `" + token.type + "` (" + stringifyPosition({
22550 start: token.start,
22551 end: token.end
22552 }) + "): it’s not open");
22553 else if (open[0].type !== token.type) if (onExitError) onExitError.call(this, token, open[0]);
22554 else (open[1] || defaultOnError).call(this, token, open[0]);
22555 node.position.end = point$1(token.end);
22556 return node;
22557 }
22558 /**
22559 * @this {CompileContext}
22560 * @returns {string}
22561 */
22562 function resume() {
22563 return toString(this.stack.pop());
22564 }
22565 /**
22566 * @this {CompileContext}
22567 * @type {Handle}
22568 */
22569 function onenterlistordered() {
22570 setData("expectingFirstListItemValue", true);
22571 }
22572 /**
22573 * @this {CompileContext}
22574 * @type {Handle}
22575 */
22576 function onenterlistitemvalue(token) {
22577 if (getData("expectingFirstListItemValue")) {
22578 const ancestor = this.stack[this.stack.length - 2];
22579 ancestor.start = Number.parseInt(this.sliceSerialize(token), 10);
22580 setData("expectingFirstListItemValue");
22581 }
22582 }
22583 /**
22584 * @this {CompileContext}
22585 * @type {Handle}
22586 */
22587 function onexitcodefencedfenceinfo() {
22588 const data = this.resume();
22589 const node = this.stack[this.stack.length - 1];
22590 node.lang = data;
22591 }
22592 /**
22593 * @this {CompileContext}
22594 * @type {Handle}
22595 */
22596 function onexitcodefencedfencemeta() {
22597 const data = this.resume();
22598 const node = this.stack[this.stack.length - 1];
22599 node.meta = data;
22600 }
22601 /**
22602 * @this {CompileContext}
22603 * @type {Handle}
22604 */
22605 function onexitcodefencedfence() {
22606 if (getData("flowCodeInside")) return;
22607 this.buffer();
22608 setData("flowCodeInside", true);
22609 }
22610 /**
22611 * @this {CompileContext}
22612 * @type {Handle}
22613 */
22614 function onexitcodefenced() {
22615 const data = this.resume();
22616 const node = this.stack[this.stack.length - 1];
22617 node.value = data.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, "");
22618 setData("flowCodeInside");
22619 }
22620 /**
22621 * @this {CompileContext}
22622 * @type {Handle}
22623 */
22624 function onexitcodeindented() {
22625 const data = this.resume();
22626 const node = this.stack[this.stack.length - 1];
22627 node.value = data.replace(/(\r?\n|\r)$/g, "");
22628 }
22629 /**
22630 * @this {CompileContext}
22631 * @type {Handle}
22632 */
22633 function onexitdefinitionlabelstring(token) {
22634 const label = this.resume();
22635 const node = this.stack[this.stack.length - 1];
22636 node.label = label;
22637 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22638 }
22639 /**
22640 * @this {CompileContext}
22641 * @type {Handle}
22642 */
22643 function onexitdefinitiontitlestring() {
22644 const data = this.resume();
22645 const node = this.stack[this.stack.length - 1];
22646 node.title = data;
22647 }
22648 /**
22649 * @this {CompileContext}
22650 * @type {Handle}
22651 */
22652 function onexitdefinitiondestinationstring() {
22653 const data = this.resume();
22654 const node = this.stack[this.stack.length - 1];
22655 node.url = data;
22656 }
22657 /**
22658 * @this {CompileContext}
22659 * @type {Handle}
22660 */
22661 function onexitatxheadingsequence(token) {
22662 const node = this.stack[this.stack.length - 1];
22663 if (!node.depth) node.depth = this.sliceSerialize(token).length;
22664 }
22665 /**
22666 * @this {CompileContext}
22667 * @type {Handle}
22668 */
22669 function onexitsetextheadingtext() {
22670 setData("setextHeadingSlurpLineEnding", true);
22671 }
22672 /**
22673 * @this {CompileContext}
22674 * @type {Handle}
22675 */
22676 function onexitsetextheadinglinesequence(token) {
22677 const node = this.stack[this.stack.length - 1];
22678 node.depth = this.sliceSerialize(token).charCodeAt(0) === 61 ? 1 : 2;
22679 }
22680 /**
22681 * @this {CompileContext}
22682 * @type {Handle}
22683 */
22684 function onexitsetextheading() {
22685 setData("setextHeadingSlurpLineEnding");
22686 }
22687 /**
22688 * @this {CompileContext}
22689 * @type {Handle}
22690 */
22691 function onenterdata(token) {
22692 const node = this.stack[this.stack.length - 1];
22693 let tail = node.children[node.children.length - 1];
22694 if (!tail || tail.type !== "text") {
22695 tail = text();
22696 tail.position = { start: point$1(token.start) };
22697 node.children.push(tail);
22698 }
22699 this.stack.push(tail);
22700 }
22701 /**
22702 * @this {CompileContext}
22703 * @type {Handle}
22704 */
22705 function onexitdata(token) {
22706 const tail = this.stack.pop();
22707 tail.value += this.sliceSerialize(token);
22708 tail.position.end = point$1(token.end);
22709 }
22710 /**
22711 * @this {CompileContext}
22712 * @type {Handle}
22713 */
22714 function onexitlineending(token) {
22715 const context = this.stack[this.stack.length - 1];
22716 if (getData("atHardBreak")) {
22717 const tail = context.children[context.children.length - 1];
22718 tail.position.end = point$1(token.end);
22719 setData("atHardBreak");
22720 return;
22721 }
22722 if (!getData("setextHeadingSlurpLineEnding") && config.canContainEols.includes(context.type)) {
22723 onenterdata.call(this, token);
22724 onexitdata.call(this, token);
22725 }
22726 }
22727 /**
22728 * @this {CompileContext}
22729 * @type {Handle}
22730 */
22731 function onexithardbreak() {
22732 setData("atHardBreak", true);
22733 }
22734 /**
22735 * @this {CompileContext}
22736 * @type {Handle}
22737 */
22738 function onexithtmlflow() {
22739 const data = this.resume();
22740 const node = this.stack[this.stack.length - 1];
22741 node.value = data;
22742 }
22743 /**
22744 * @this {CompileContext}
22745 * @type {Handle}
22746 */
22747 function onexithtmltext() {
22748 const data = this.resume();
22749 const node = this.stack[this.stack.length - 1];
22750 node.value = data;
22751 }
22752 /**
22753 * @this {CompileContext}
22754 * @type {Handle}
22755 */
22756 function onexitcodetext() {
22757 const data = this.resume();
22758 const node = this.stack[this.stack.length - 1];
22759 node.value = data;
22760 }
22761 /**
22762 * @this {CompileContext}
22763 * @type {Handle}
22764 */
22765 function onexitlink() {
22766 const node = this.stack[this.stack.length - 1];
22767 if (getData("inReference")) {
22768 /** @type {ReferenceType} */
22769 const referenceType = getData("referenceType") || "shortcut";
22770 node.type += "Reference";
22771 node.referenceType = referenceType;
22772 delete node.url;
22773 delete node.title;
22774 } else {
22775 delete node.identifier;
22776 delete node.label;
22777 }
22778 setData("referenceType");
22779 }
22780 /**
22781 * @this {CompileContext}
22782 * @type {Handle}
22783 */
22784 function onexitimage() {
22785 const node = this.stack[this.stack.length - 1];
22786 if (getData("inReference")) {
22787 /** @type {ReferenceType} */
22788 const referenceType = getData("referenceType") || "shortcut";
22789 node.type += "Reference";
22790 node.referenceType = referenceType;
22791 delete node.url;
22792 delete node.title;
22793 } else {
22794 delete node.identifier;
22795 delete node.label;
22796 }
22797 setData("referenceType");
22798 }
22799 /**
22800 * @this {CompileContext}
22801 * @type {Handle}
22802 */
22803 function onexitlabeltext(token) {
22804 const string = this.sliceSerialize(token);
22805 const ancestor = this.stack[this.stack.length - 2];
22806 ancestor.label = decodeString(string);
22807 ancestor.identifier = normalizeIdentifier(string).toLowerCase();
22808 }
22809 /**
22810 * @this {CompileContext}
22811 * @type {Handle}
22812 */
22813 function onexitlabel() {
22814 const fragment = this.stack[this.stack.length - 1];
22815 const value = this.resume();
22816 const node = this.stack[this.stack.length - 1];
22817 setData("inReference", true);
22818 if (node.type === "link") node.children = fragment.children;
22819 else node.alt = value;
22820 }
22821 /**
22822 * @this {CompileContext}
22823 * @type {Handle}
22824 */
22825 function onexitresourcedestinationstring() {
22826 const data = this.resume();
22827 const node = this.stack[this.stack.length - 1];
22828 node.url = data;
22829 }
22830 /**
22831 * @this {CompileContext}
22832 * @type {Handle}
22833 */
22834 function onexitresourcetitlestring() {
22835 const data = this.resume();
22836 const node = this.stack[this.stack.length - 1];
22837 node.title = data;
22838 }
22839 /**
22840 * @this {CompileContext}
22841 * @type {Handle}
22842 */
22843 function onexitresource() {
22844 setData("inReference");
22845 }
22846 /**
22847 * @this {CompileContext}
22848 * @type {Handle}
22849 */
22850 function onenterreference() {
22851 setData("referenceType", "collapsed");
22852 }
22853 /**
22854 * @this {CompileContext}
22855 * @type {Handle}
22856 */
22857 function onexitreferencestring(token) {
22858 const label = this.resume();
22859 const node = this.stack[this.stack.length - 1];
22860 node.label = label;
22861 node.identifier = normalizeIdentifier(this.sliceSerialize(token)).toLowerCase();
22862 setData("referenceType", "full");
22863 }
22864 /**
22865 * @this {CompileContext}
22866 * @type {Handle}
22867 */
22868 function onexitcharacterreferencemarker(token) {
22869 setData("characterReferenceType", token.type);
22870 }
22871 /**
22872 * @this {CompileContext}
22873 * @type {Handle}
22874 */
22875 function onexitcharacterreferencevalue(token) {
22876 const data = this.sliceSerialize(token);
22877 const type = getData("characterReferenceType");
22878 /** @type {string} */
22879 let value;
22880 if (type) {
22881 value = decodeNumericCharacterReference(data, type === "characterReferenceMarkerNumeric" ? 10 : 16);
22882 setData("characterReferenceType");
22883 } else value = decodeNamedCharacterReference(data);
22884 const tail = this.stack.pop();
22885 tail.value += value;
22886 tail.position.end = point$1(token.end);
22887 }
22888 /**
22889 * @this {CompileContext}
22890 * @type {Handle}
22891 */
22892 function onexitautolinkprotocol(token) {
22893 onexitdata.call(this, token);
22894 const node = this.stack[this.stack.length - 1];
22895 node.url = this.sliceSerialize(token);
22896 }
22897 /**
22898 * @this {CompileContext}
22899 * @type {Handle}
22900 */
22901 function onexitautolinkemail(token) {
22902 onexitdata.call(this, token);
22903 const node = this.stack[this.stack.length - 1];
22904 node.url = "mailto:" + this.sliceSerialize(token);
22905 }
22906 /** @returns {Blockquote} */
22907 function blockQuote() {
22908 return {
22909 type: "blockquote",
22910 children: []
22911 };
22912 }
22913 /** @returns {Code} */
22914 function codeFlow() {
22915 return {
22916 type: "code",
22917 lang: null,
22918 meta: null,
22919 value: ""
22920 };
22921 }
22922 /** @returns {InlineCode} */
22923 function codeText() {
22924 return {
22925 type: "inlineCode",
22926 value: ""
22927 };
22928 }
22929 /** @returns {Definition} */
22930 function definition() {
22931 return {
22932 type: "definition",
22933 identifier: "",
22934 label: null,
22935 title: null,
22936 url: ""
22937 };
22938 }
22939 /** @returns {Emphasis} */
22940 function emphasis() {
22941 return {
22942 type: "emphasis",
22943 children: []
22944 };
22945 }
22946 /** @returns {Heading} */
22947 function heading() {
22948 return {
22949 type: "heading",
22950 depth: void 0,
22951 children: []
22952 };
22953 }
22954 /** @returns {Break} */
22955 function hardBreak() {
22956 return { type: "break" };
22957 }
22958 /** @returns {HTML} */
22959 function html() {
22960 return {
22961 type: "html",
22962 value: ""
22963 };
22964 }
22965 /** @returns {Image} */
22966 function image() {
22967 return {
22968 type: "image",
22969 title: null,
22970 url: "",
22971 alt: null
22972 };
22973 }
22974 /** @returns {Link} */
22975 function link() {
22976 return {
22977 type: "link",
22978 title: null,
22979 url: "",
22980 children: []
22981 };
22982 }
22983 /**
22984 * @param {Token} token
22985 * @returns {List}
22986 */
22987 function list(token) {
22988 return {
22989 type: "list",
22990 ordered: token.type === "listOrdered",
22991 start: null,
22992 spread: token._spread,
22993 children: []
22994 };
22995 }
22996 /**
22997 * @param {Token} token
22998 * @returns {ListItem}
22999 */
23000 function listItem(token) {
23001 return {
23002 type: "listItem",
23003 spread: token._spread,
23004 checked: null,
23005 children: []
23006 };
23007 }
23008 /** @returns {Paragraph} */
23009 function paragraph() {
23010 return {
23011 type: "paragraph",
23012 children: []
23013 };
23014 }
23015 /** @returns {Strong} */
23016 function strong() {
23017 return {
23018 type: "strong",
23019 children: []
23020 };
23021 }
23022 /** @returns {Text} */
23023 function text() {
23024 return {
23025 type: "text",
23026 value: ""
23027 };
23028 }
23029 /** @returns {ThematicBreak} */
23030 function thematicBreak() {
23031 return { type: "thematicBreak" };
23032 }
23033 }
23034 /**
23035 * Copy a point-like value.
23036 *
23037 * @param {Point} d
23038 * Point-like value.
23039 * @returns {Point}
23040 * unist point.
23041 */
23042 function point$1(d) {
23043 return {
23044 line: d.line,
23045 column: d.column,
23046 offset: d.offset
23047 };
23048 }
23049 /**
23050 * @param {Config} combined
23051 * @param {Array<Extension | Array<Extension>>} extensions
23052 * @returns {void}
23053 */
23054 function configure(combined, extensions) {
23055 let index = -1;
23056 while (++index < extensions.length) {
23057 const value = extensions[index];
23058 if (Array.isArray(value)) configure(combined, value);
23059 else extension(combined, value);
23060 }
23061 }
23062 /**
23063 * @param {Config} combined
23064 * @param {Extension} extension
23065 * @returns {void}
23066 */
23067 function extension(combined, extension) {
23068 /** @type {keyof Extension} */
23069 let key;
23070 for (key in extension) if (own$5.call(extension, key)) {
23071 if (key === "canContainEols") {
23072 const right = extension[key];
23073 if (right) combined[key].push(...right);
23074 } else if (key === "transforms") {
23075 const right = extension[key];
23076 if (right) combined[key].push(...right);
23077 } else if (key === "enter" || key === "exit") {
23078 const right = extension[key];
23079 if (right) Object.assign(combined[key], right);
23080 }
23081 }
23082 }
23083 /** @type {OnEnterError} */
23084 function defaultOnError(left, right) {
23085 if (left) throw new Error("Cannot close `" + left.type + "` (" + stringifyPosition({
23086 start: left.start,
23087 end: left.end
23088 }) + "): a different token (`" + right.type + "`, " + stringifyPosition({
23089 start: right.start,
23090 end: right.end
23091 }) + ") is open");
23092 else throw new Error("Cannot close document, a token (`" + right.type + "`, " + stringifyPosition({
23093 start: right.start,
23094 end: right.end
23095 }) + ") is still open");
23096 }
23097 var own$5, fromMarkdown;
23098 var init_lib$9 = __esmMin((() => {
23099 init_mdast_util_to_string();
23100 init_parse();
23101 init_preprocess();
23102 init_postprocess();
23103 init_micromark_util_decode_numeric_character_reference();
23104 init_micromark_util_decode_string();
23105 init_micromark_util_normalize_identifier();
23106 init_index_dom();
23107 init_unist_util_stringify_position();
23108 own$5 = {}.hasOwnProperty;
23109 fromMarkdown = function(value, encoding, options) {
23110 if (typeof encoding !== "string") {
23111 options = encoding;
23112 encoding = void 0;
23113 }
23114 return compiler(options)(postprocess(parse(options).document().write(preprocess()(value, encoding, true))));
23115 };
23116 __name(point$1, "point");
23117 }));
23118
23119 //#endregion
23120 //#region node_modules/mdast-util-from-markdown/index.js
23121 var init_mdast_util_from_markdown = __esmMin((() => {
23122 init_lib$9();
23123 }));
23124
23125 //#endregion
23126 //#region node_modules/remark-parse/lib/index.js
23127 /**
23128 * @this {import('unified').Processor}
23129 * @type {import('unified').Plugin<[Options?] | void[], string, Root>}
23130 */
23131 function remarkParse(options) {
23132 /** @type {import('unified').ParserFunction<Root>} */
23133 const parser = (doc) => {
23134 const settings = this.data("settings");
23135 return fromMarkdown(doc, Object.assign({}, settings, options, {
23136 extensions: this.data("micromarkExtensions") || [],
23137 mdastExtensions: this.data("fromMarkdownExtensions") || []
23138 }));
23139 };
23140 Object.assign(this, { Parser: parser });
23141 }
23142 var init_lib$8 = __esmMin((() => {
23143 init_mdast_util_from_markdown();
23144 }));
23145
23146 //#endregion
23147 //#region node_modules/remark-parse/index.js
23148 var init_remark_parse = __esmMin((() => {
23149 init_lib$8();
23150 }));
23151
23152 //#endregion
23153 //#region node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
23154 /**
23155 * @typedef {import('hast').Element} Element
23156 * @typedef {import('mdast').Blockquote} Blockquote
23157 * @typedef {import('../state.js').State} State
23158 */
23159 /**
23160 * Turn an mdast `blockquote` node into hast.
23161 *
23162 * @param {State} state
23163 * Info passed around.
23164 * @param {Blockquote} node
23165 * mdast node.
23166 * @returns {Element}
23167 * hast node.
23168 */
23169 function blockquote(state, node) {
23170 /** @type {Element} */
23171 const result = {
23172 type: "element",
23173 tagName: "blockquote",
23174 properties: {},
23175 children: state.wrap(state.all(node), true)
23176 };
23177 state.patch(node, result);
23178 return state.applyData(node, result);
23179 }
23180 var init_blockquote = __esmMin((() => {}));
23181
23182 //#endregion
23183 //#region node_modules/mdast-util-to-hast/lib/handlers/break.js
23184 /**
23185 * @typedef {import('hast').Element} Element
23186 * @typedef {import('hast').Text} Text
23187 * @typedef {import('mdast').Break} Break
23188 * @typedef {import('../state.js').State} State
23189 */
23190 /**
23191 * Turn an mdast `break` node into hast.
23192 *
23193 * @param {State} state
23194 * Info passed around.
23195 * @param {Break} node
23196 * mdast node.
23197 * @returns {Array<Element | Text>}
23198 * hast element content.
23199 */
23200 function hardBreak(state, node) {
23201 /** @type {Element} */
23202 const result = {
23203 type: "element",
23204 tagName: "br",
23205 properties: {},
23206 children: []
23207 };
23208 state.patch(node, result);
23209 return [state.applyData(node, result), {
23210 type: "text",
23211 value: "\n"
23212 }];
23213 }
23214 var init_break = __esmMin((() => {}));
23215
23216 //#endregion
23217 //#region node_modules/mdast-util-to-hast/lib/handlers/code.js
23218 /**
23219 * @typedef {import('hast').Element} Element
23220 * @typedef {import('hast').Properties} Properties
23221 * @typedef {import('mdast').Code} Code
23222 * @typedef {import('../state.js').State} State
23223
23224 */
23225 /**
23226 * Turn an mdast `code` node into hast.
23227 *
23228 * @param {State} state
23229 * Info passed around.
23230 * @param {Code} node
23231 * mdast node.
23232 * @returns {Element}
23233 * hast node.
23234 */
23235 function code(state, node) {
23236 const value = node.value ? node.value + "\n" : "";
23237 const lang = node.lang ? node.lang.match(/^[^ \t]+(?=[ \t]|$)/) : null;
23238 /** @type {Properties} */
23239 const properties = {};
23240 if (lang) properties.className = ["language-" + lang];
23241 /** @type {Element} */
23242 let result = {
23243 type: "element",
23244 tagName: "code",
23245 properties,
23246 children: [{
23247 type: "text",
23248 value
23249 }]
23250 };
23251 if (node.meta) result.data = { meta: node.meta };
23252 state.patch(node, result);
23253 result = state.applyData(node, result);
23254 result = {
23255 type: "element",
23256 tagName: "pre",
23257 properties: {},
23258 children: [result]
23259 };
23260 state.patch(node, result);
23261 return result;
23262 }
23263 var init_code = __esmMin((() => {}));
23264
23265 //#endregion
23266 //#region node_modules/mdast-util-to-hast/lib/handlers/delete.js
23267 /**
23268 * @typedef {import('hast').Element} Element
23269 * @typedef {import('mdast').Delete} Delete
23270 * @typedef {import('../state.js').State} State
23271
23272 */
23273 /**
23274 * Turn an mdast `delete` node into hast.
23275 *
23276 * @param {State} state
23277 * Info passed around.
23278 * @param {Delete} node
23279 * mdast node.
23280 * @returns {Element}
23281 * hast node.
23282 */
23283 function strikethrough(state, node) {
23284 /** @type {Element} */
23285 const result = {
23286 type: "element",
23287 tagName: "del",
23288 properties: {},
23289 children: state.all(node)
23290 };
23291 state.patch(node, result);
23292 return state.applyData(node, result);
23293 }
23294 var init_delete = __esmMin((() => {}));
23295
23296 //#endregion
23297 //#region node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
23298 /**
23299 * @typedef {import('hast').Element} Element
23300 * @typedef {import('mdast').Emphasis} Emphasis
23301 * @typedef {import('../state.js').State} State
23302 */
23303 /**
23304 * Turn an mdast `emphasis` node into hast.
23305 *
23306 * @param {State} state
23307 * Info passed around.
23308 * @param {Emphasis} node
23309 * mdast node.
23310 * @returns {Element}
23311 * hast node.
23312 */
23313 function emphasis(state, node) {
23314 /** @type {Element} */
23315 const result = {
23316 type: "element",
23317 tagName: "em",
23318 properties: {},
23319 children: state.all(node)
23320 };
23321 state.patch(node, result);
23322 return state.applyData(node, result);
23323 }
23324 var init_emphasis = __esmMin((() => {}));
23325
23326 //#endregion
23327 //#region node_modules/micromark-util-sanitize-uri/index.js
23328 /**
23329 * Normalize a URL.
23330 *
23331 * Encode unsafe characters with percent-encoding, skipping already encoded
23332 * sequences.
23333 *
23334 * @param {string} value
23335 * URI to normalize.
23336 * @returns {string}
23337 * Normalized URI.
23338 */
23339 function normalizeUri(value) {
23340 /** @type {Array<string>} */
23341 const result = [];
23342 let index = -1;
23343 let start = 0;
23344 let skip = 0;
23345 while (++index < value.length) {
23346 const code = value.charCodeAt(index);
23347 /** @type {string} */
23348 let replace = "";
23349 if (code === 37 && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) skip = 2;
23350 else if (code < 128) {
23351 if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) replace = String.fromCharCode(code);
23352 } else if (code > 55295 && code < 57344) {
23353 const next = value.charCodeAt(index + 1);
23354 if (code < 56320 && next > 56319 && next < 57344) {
23355 replace = String.fromCharCode(code, next);
23356 skip = 1;
23357 } else replace = "�";
23358 } else replace = String.fromCharCode(code);
23359 if (replace) {
23360 result.push(value.slice(start, index), encodeURIComponent(replace));
23361 start = index + skip + 1;
23362 replace = "";
23363 }
23364 if (skip) {
23365 index += skip;
23366 skip = 0;
23367 }
23368 }
23369 return result.join("") + value.slice(start);
23370 }
23371 var init_micromark_util_sanitize_uri = __esmMin((() => {
23372 init_micromark_util_character();
23373 }));
23374
23375 //#endregion
23376 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
23377 /**
23378 * Turn an mdast `footnoteReference` node into hast.
23379 *
23380 * @param {State} state
23381 * Info passed around.
23382 * @param {FootnoteReference} node
23383 * mdast node.
23384 * @returns {Element}
23385 * hast node.
23386 */
23387 function footnoteReference(state, node) {
23388 const id = String(node.identifier).toUpperCase();
23389 const safeId = normalizeUri(id.toLowerCase());
23390 const index = state.footnoteOrder.indexOf(id);
23391 /** @type {number} */
23392 let counter;
23393 if (index === -1) {
23394 state.footnoteOrder.push(id);
23395 state.footnoteCounts[id] = 1;
23396 counter = state.footnoteOrder.length;
23397 } else {
23398 state.footnoteCounts[id]++;
23399 counter = index + 1;
23400 }
23401 const reuseCounter = state.footnoteCounts[id];
23402 /** @type {Element} */
23403 const link = {
23404 type: "element",
23405 tagName: "a",
23406 properties: {
23407 href: "#" + state.clobberPrefix + "fn-" + safeId,
23408 id: state.clobberPrefix + "fnref-" + safeId + (reuseCounter > 1 ? "-" + reuseCounter : ""),
23409 dataFootnoteRef: true,
23410 ariaDescribedBy: ["footnote-label"]
23411 },
23412 children: [{
23413 type: "text",
23414 value: String(counter)
23415 }]
23416 };
23417 state.patch(node, link);
23418 /** @type {Element} */
23419 const sup = {
23420 type: "element",
23421 tagName: "sup",
23422 properties: {},
23423 children: [link]
23424 };
23425 state.patch(node, sup);
23426 return state.applyData(node, sup);
23427 }
23428 var init_footnote_reference = __esmMin((() => {
23429 init_micromark_util_sanitize_uri();
23430 }));
23431
23432 //#endregion
23433 //#region node_modules/mdast-util-to-hast/lib/handlers/footnote.js
23434 /**
23435 * Turn an mdast `footnote` node into hast.
23436 *
23437 * @param {State} state
23438 * Info passed around.
23439 * @param {Footnote} node
23440 * mdast node.
23441 * @returns {Element}
23442 * hast node.
23443 */
23444 function footnote(state, node) {
23445 const footnoteById = state.footnoteById;
23446 let no = 1;
23447 while (no in footnoteById) no++;
23448 const identifier = String(no);
23449 footnoteById[identifier] = {
23450 type: "footnoteDefinition",
23451 identifier,
23452 children: [{
23453 type: "paragraph",
23454 children: node.children
23455 }],
23456 position: node.position
23457 };
23458 return footnoteReference(state, {
23459 type: "footnoteReference",
23460 identifier,
23461 position: node.position
23462 });
23463 }
23464 var init_footnote = __esmMin((() => {
23465 init_footnote_reference();
23466 }));
23467
23468 //#endregion
23469 //#region node_modules/mdast-util-to-hast/lib/handlers/heading.js
23470 /**
23471 * @typedef {import('hast').Element} Element
23472 * @typedef {import('mdast').Heading} Heading
23473 * @typedef {import('../state.js').State} State
23474 */
23475 /**
23476 * Turn an mdast `heading` node into hast.
23477 *
23478 * @param {State} state
23479 * Info passed around.
23480 * @param {Heading} node
23481 * mdast node.
23482 * @returns {Element}
23483 * hast node.
23484 */
23485 function heading(state, node) {
23486 /** @type {Element} */
23487 const result = {
23488 type: "element",
23489 tagName: "h" + node.depth,
23490 properties: {},
23491 children: state.all(node)
23492 };
23493 state.patch(node, result);
23494 return state.applyData(node, result);
23495 }
23496 var init_heading = __esmMin((() => {}));
23497
23498 //#endregion
23499 //#region node_modules/mdast-util-to-hast/lib/handlers/html.js
23500 /**
23501 * @typedef {import('hast').Element} Element
23502 * @typedef {import('mdast').HTML} Html
23503 * @typedef {import('../state.js').State} State
23504 * @typedef {import('../../index.js').Raw} Raw
23505 */
23506 /**
23507 * Turn an mdast `html` node into hast (`raw` node in dangerous mode, otherwise
23508 * nothing).
23509 *
23510 * @param {State} state
23511 * Info passed around.
23512 * @param {Html} node
23513 * mdast node.
23514 * @returns {Raw | Element | null}
23515 * hast node.
23516 */
23517 function html$2(state, node) {
23518 if (state.dangerous) {
23519 /** @type {Raw} */
23520 const result = {
23521 type: "raw",
23522 value: node.value
23523 };
23524 state.patch(node, result);
23525 return state.applyData(node, result);
23526 }
23527 return null;
23528 }
23529 var init_html$1 = __esmMin((() => {
23530 __name(html$2, "html");
23531 }));
23532
23533 //#endregion
23534 //#region node_modules/mdast-util-to-hast/lib/revert.js
23535 /**
23536 * @typedef {import('hast').ElementContent} ElementContent
23537 *
23538 * @typedef {import('mdast').Content} Content
23539 * @typedef {import('mdast').Reference} Reference
23540 * @typedef {import('mdast').Root} Root
23541 *
23542 * @typedef {import('./state.js').State} State
23543 */
23544 /**
23545 * @typedef {Root | Content} Nodes
23546 * @typedef {Extract<Nodes, Reference>} References
23547 */
23548 /**
23549 * Return the content of a reference without definition as plain text.
23550 *
23551 * @param {State} state
23552 * Info passed around.
23553 * @param {References} node
23554 * Reference node (image, link).
23555 * @returns {ElementContent | Array<ElementContent>}
23556 * hast content.
23557 */
23558 function revert(state, node) {
23559 const subtype = node.referenceType;
23560 let suffix = "]";
23561 if (subtype === "collapsed") suffix += "[]";
23562 else if (subtype === "full") suffix += "[" + (node.label || node.identifier) + "]";
23563 if (node.type === "imageReference") return {
23564 type: "text",
23565 value: "![" + node.alt + suffix
23566 };
23567 const contents = state.all(node);
23568 const head = contents[0];
23569 if (head && head.type === "text") head.value = "[" + head.value;
23570 else contents.unshift({
23571 type: "text",
23572 value: "["
23573 });
23574 const tail = contents[contents.length - 1];
23575 if (tail && tail.type === "text") tail.value += suffix;
23576 else contents.push({
23577 type: "text",
23578 value: suffix
23579 });
23580 return contents;
23581 }
23582 var init_revert = __esmMin((() => {}));
23583
23584 //#endregion
23585 //#region node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
23586 /**
23587 * Turn an mdast `imageReference` node into hast.
23588 *
23589 * @param {State} state
23590 * Info passed around.
23591 * @param {ImageReference} node
23592 * mdast node.
23593 * @returns {ElementContent | Array<ElementContent>}
23594 * hast node.
23595 */
23596 function imageReference(state, node) {
23597 const def = state.definition(node.identifier);
23598 if (!def) return revert(state, node);
23599 /** @type {Properties} */
23600 const properties = {
23601 src: normalizeUri(def.url || ""),
23602 alt: node.alt
23603 };
23604 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23605 /** @type {Element} */
23606 const result = {
23607 type: "element",
23608 tagName: "img",
23609 properties,
23610 children: []
23611 };
23612 state.patch(node, result);
23613 return state.applyData(node, result);
23614 }
23615 var init_image_reference = __esmMin((() => {
23616 init_micromark_util_sanitize_uri();
23617 init_revert();
23618 }));
23619
23620 //#endregion
23621 //#region node_modules/mdast-util-to-hast/lib/handlers/image.js
23622 /**
23623 * Turn an mdast `image` node into hast.
23624 *
23625 * @param {State} state
23626 * Info passed around.
23627 * @param {Image} node
23628 * mdast node.
23629 * @returns {Element}
23630 * hast node.
23631 */
23632 function image(state, node) {
23633 /** @type {Properties} */
23634 const properties = { src: normalizeUri(node.url) };
23635 if (node.alt !== null && node.alt !== void 0) properties.alt = node.alt;
23636 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23637 /** @type {Element} */
23638 const result = {
23639 type: "element",
23640 tagName: "img",
23641 properties,
23642 children: []
23643 };
23644 state.patch(node, result);
23645 return state.applyData(node, result);
23646 }
23647 var init_image = __esmMin((() => {
23648 init_micromark_util_sanitize_uri();
23649 }));
23650
23651 //#endregion
23652 //#region node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
23653 /**
23654 * @typedef {import('hast').Element} Element
23655 * @typedef {import('hast').Text} Text
23656 * @typedef {import('mdast').InlineCode} InlineCode
23657 * @typedef {import('../state.js').State} State
23658 */
23659 /**
23660 * Turn an mdast `inlineCode` node into hast.
23661 *
23662 * @param {State} state
23663 * Info passed around.
23664 * @param {InlineCode} node
23665 * mdast node.
23666 * @returns {Element}
23667 * hast node.
23668 */
23669 function inlineCode(state, node) {
23670 /** @type {Text} */
23671 const text = {
23672 type: "text",
23673 value: node.value.replace(/\r?\n|\r/g, " ")
23674 };
23675 state.patch(node, text);
23676 /** @type {Element} */
23677 const result = {
23678 type: "element",
23679 tagName: "code",
23680 properties: {},
23681 children: [text]
23682 };
23683 state.patch(node, result);
23684 return state.applyData(node, result);
23685 }
23686 var init_inline_code = __esmMin((() => {}));
23687
23688 //#endregion
23689 //#region node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
23690 /**
23691 * Turn an mdast `linkReference` node into hast.
23692 *
23693 * @param {State} state
23694 * Info passed around.
23695 * @param {LinkReference} node
23696 * mdast node.
23697 * @returns {ElementContent | Array<ElementContent>}
23698 * hast node.
23699 */
23700 function linkReference(state, node) {
23701 const def = state.definition(node.identifier);
23702 if (!def) return revert(state, node);
23703 /** @type {Properties} */
23704 const properties = { href: normalizeUri(def.url || "") };
23705 if (def.title !== null && def.title !== void 0) properties.title = def.title;
23706 /** @type {Element} */
23707 const result = {
23708 type: "element",
23709 tagName: "a",
23710 properties,
23711 children: state.all(node)
23712 };
23713 state.patch(node, result);
23714 return state.applyData(node, result);
23715 }
23716 var init_link_reference = __esmMin((() => {
23717 init_micromark_util_sanitize_uri();
23718 init_revert();
23719 }));
23720
23721 //#endregion
23722 //#region node_modules/mdast-util-to-hast/lib/handlers/link.js
23723 /**
23724 * Turn an mdast `link` node into hast.
23725 *
23726 * @param {State} state
23727 * Info passed around.
23728 * @param {Link} node
23729 * mdast node.
23730 * @returns {Element}
23731 * hast node.
23732 */
23733 function link(state, node) {
23734 /** @type {Properties} */
23735 const properties = { href: normalizeUri(node.url) };
23736 if (node.title !== null && node.title !== void 0) properties.title = node.title;
23737 /** @type {Element} */
23738 const result = {
23739 type: "element",
23740 tagName: "a",
23741 properties,
23742 children: state.all(node)
23743 };
23744 state.patch(node, result);
23745 return state.applyData(node, result);
23746 }
23747 var init_link = __esmMin((() => {
23748 init_micromark_util_sanitize_uri();
23749 }));
23750
23751 //#endregion
23752 //#region node_modules/mdast-util-to-hast/lib/handlers/list-item.js
23753 /**
23754 * @typedef {import('hast').Element} Element
23755 * @typedef {import('hast').ElementContent} ElementContent
23756 * @typedef {import('hast').Properties} Properties
23757 * @typedef {import('mdast').Content} Content
23758 * @typedef {import('mdast').ListItem} ListItem
23759 * @typedef {import('mdast').Parent} Parent
23760 * @typedef {import('mdast').Root} Root
23761 * @typedef {import('../state.js').State} State
23762 */
23763 /**
23764 * @typedef {Root | Content} Nodes
23765 * @typedef {Extract<Nodes, Parent>} Parents
23766 */
23767 /**
23768 * Turn an mdast `listItem` node into hast.
23769 *
23770 * @param {State} state
23771 * Info passed around.
23772 * @param {ListItem} node
23773 * mdast node.
23774 * @param {Parents | null | undefined} parent
23775 * Parent of `node`.
23776 * @returns {Element}
23777 * hast node.
23778 */
23779 function listItem(state, node, parent) {
23780 const results = state.all(node);
23781 const loose = parent ? listLoose(parent) : listItemLoose(node);
23782 /** @type {Properties} */
23783 const properties = {};
23784 /** @type {Array<ElementContent>} */
23785 const children = [];
23786 if (typeof node.checked === "boolean") {
23787 const head = results[0];
23788 /** @type {Element} */
23789 let paragraph;
23790 if (head && head.type === "element" && head.tagName === "p") paragraph = head;
23791 else {
23792 paragraph = {
23793 type: "element",
23794 tagName: "p",
23795 properties: {},
23796 children: []
23797 };
23798 results.unshift(paragraph);
23799 }
23800 if (paragraph.children.length > 0) paragraph.children.unshift({
23801 type: "text",
23802 value: " "
23803 });
23804 paragraph.children.unshift({
23805 type: "element",
23806 tagName: "input",
23807 properties: {
23808 type: "checkbox",
23809 checked: node.checked,
23810 disabled: true
23811 },
23812 children: []
23813 });
23814 properties.className = ["task-list-item"];
23815 }
23816 let index = -1;
23817 while (++index < results.length) {
23818 const child = results[index];
23819 if (loose || index !== 0 || child.type !== "element" || child.tagName !== "p") children.push({
23820 type: "text",
23821 value: "\n"
23822 });
23823 if (child.type === "element" && child.tagName === "p" && !loose) children.push(...child.children);
23824 else children.push(child);
23825 }
23826 const tail = results[results.length - 1];
23827 if (tail && (loose || tail.type !== "element" || tail.tagName !== "p")) children.push({
23828 type: "text",
23829 value: "\n"
23830 });
23831 /** @type {Element} */
23832 const result = {
23833 type: "element",
23834 tagName: "li",
23835 properties,
23836 children
23837 };
23838 state.patch(node, result);
23839 return state.applyData(node, result);
23840 }
23841 /**
23842 * @param {Parents} node
23843 * @return {Boolean}
23844 */
23845 function listLoose(node) {
23846 let loose = false;
23847 if (node.type === "list") {
23848 loose = node.spread || false;
23849 const children = node.children;
23850 let index = -1;
23851 while (!loose && ++index < children.length) loose = listItemLoose(children[index]);
23852 }
23853 return loose;
23854 }
23855 /**
23856 * @param {ListItem} node
23857 * @return {Boolean}
23858 */
23859 function listItemLoose(node) {
23860 const spread = node.spread;
23861 return spread === void 0 || spread === null ? node.children.length > 1 : spread;
23862 }
23863 var init_list_item = __esmMin((() => {}));
23864
23865 //#endregion
23866 //#region node_modules/mdast-util-to-hast/lib/handlers/list.js
23867 /**
23868 * @typedef {import('hast').Element} Element
23869 * @typedef {import('hast').Properties} Properties
23870 * @typedef {import('mdast').List} List
23871 * @typedef {import('../state.js').State} State
23872 */
23873 /**
23874 * Turn an mdast `list` node into hast.
23875 *
23876 * @param {State} state
23877 * Info passed around.
23878 * @param {List} node
23879 * mdast node.
23880 * @returns {Element}
23881 * hast node.
23882 */
23883 function list(state, node) {
23884 /** @type {Properties} */
23885 const properties = {};
23886 const results = state.all(node);
23887 let index = -1;
23888 if (typeof node.start === "number" && node.start !== 1) properties.start = node.start;
23889 while (++index < results.length) {
23890 const child = results[index];
23891 if (child.type === "element" && child.tagName === "li" && child.properties && Array.isArray(child.properties.className) && child.properties.className.includes("task-list-item")) {
23892 properties.className = ["contains-task-list"];
23893 break;
23894 }
23895 }
23896 /** @type {Element} */
23897 const result = {
23898 type: "element",
23899 tagName: node.ordered ? "ol" : "ul",
23900 properties,
23901 children: state.wrap(results, true)
23902 };
23903 state.patch(node, result);
23904 return state.applyData(node, result);
23905 }
23906 var init_list = __esmMin((() => {}));
23907
23908 //#endregion
23909 //#region node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
23910 /**
23911 * @typedef {import('hast').Element} Element
23912 * @typedef {import('mdast').Paragraph} Paragraph
23913 * @typedef {import('../state.js').State} State
23914 */
23915 /**
23916 * Turn an mdast `paragraph` node into hast.
23917 *
23918 * @param {State} state
23919 * Info passed around.
23920 * @param {Paragraph} node
23921 * mdast node.
23922 * @returns {Element}
23923 * hast node.
23924 */
23925 function paragraph(state, node) {
23926 /** @type {Element} */
23927 const result = {
23928 type: "element",
23929 tagName: "p",
23930 properties: {},
23931 children: state.all(node)
23932 };
23933 state.patch(node, result);
23934 return state.applyData(node, result);
23935 }
23936 var init_paragraph = __esmMin((() => {}));
23937
23938 //#endregion
23939 //#region node_modules/mdast-util-to-hast/lib/handlers/root.js
23940 /**
23941 * @typedef {import('hast').Root} HastRoot
23942 * @typedef {import('hast').Element} HastElement
23943 * @typedef {import('mdast').Root} MdastRoot
23944 * @typedef {import('../state.js').State} State
23945 */
23946 /**
23947 * Turn an mdast `root` node into hast.
23948 *
23949 * @param {State} state
23950 * Info passed around.
23951 * @param {MdastRoot} node
23952 * mdast node.
23953 * @returns {HastRoot | HastElement}
23954 * hast node.
23955 */
23956 function root(state, node) {
23957 /** @type {HastRoot} */
23958 const result = {
23959 type: "root",
23960 children: state.wrap(state.all(node))
23961 };
23962 state.patch(node, result);
23963 return state.applyData(node, result);
23964 }
23965 var init_root = __esmMin((() => {}));
23966
23967 //#endregion
23968 //#region node_modules/mdast-util-to-hast/lib/handlers/strong.js
23969 /**
23970 * @typedef {import('hast').Element} Element
23971 * @typedef {import('mdast').Strong} Strong
23972 * @typedef {import('../state.js').State} State
23973 */
23974 /**
23975 * Turn an mdast `strong` node into hast.
23976 *
23977 * @param {State} state
23978 * Info passed around.
23979 * @param {Strong} node
23980 * mdast node.
23981 * @returns {Element}
23982 * hast node.
23983 */
23984 function strong(state, node) {
23985 /** @type {Element} */
23986 const result = {
23987 type: "element",
23988 tagName: "strong",
23989 properties: {},
23990 children: state.all(node)
23991 };
23992 state.patch(node, result);
23993 return state.applyData(node, result);
23994 }
23995 var init_strong = __esmMin((() => {}));
23996
23997 //#endregion
23998 //#region node_modules/unist-util-position/lib/index.js
23999 /**
24000 * Get the positional info of `node`.
24001 *
24002 * @param {NodeLike | Node | null | undefined} [node]
24003 * Node.
24004 * @returns {Position}
24005 * Position.
24006 */
24007 function position(node) {
24008 return {
24009 start: pointStart(node),
24010 end: pointEnd(node)
24011 };
24012 }
24013 /**
24014 * Get the positional info of `node`.
24015 *
24016 * @param {'start' | 'end'} type
24017 * Side.
24018 * @returns
24019 * Getter.
24020 */
24021 function point(type) {
24022 return point;
24023 /**
24024 * Get the point info of `node` at a bound side.
24025 *
24026 * @param {NodeLike | Node | null | undefined} [node]
24027 * @returns {Point}
24028 */
24029 function point(node) {
24030 const point = node && node.position && node.position[type] || {};
24031 return {
24032 line: point.line || null,
24033 column: point.column || null,
24034 offset: point.offset > -1 ? point.offset : null
24035 };
24036 }
24037 }
24038 var pointStart, pointEnd;
24039 var init_lib$7 = __esmMin((() => {
24040 pointStart = point("start");
24041 pointEnd = point("end");
24042 }));
24043
24044 //#endregion
24045 //#region node_modules/unist-util-position/index.js
24046 var init_unist_util_position = __esmMin((() => {
24047 init_lib$7();
24048 }));
24049
24050 //#endregion
24051 //#region node_modules/mdast-util-to-hast/lib/handlers/table.js
24052 /**
24053 * Turn an mdast `table` node into hast.
24054 *
24055 * @param {State} state
24056 * Info passed around.
24057 * @param {Table} node
24058 * mdast node.
24059 * @returns {Element}
24060 * hast node.
24061 */
24062 function table(state, node) {
24063 const rows = state.all(node);
24064 const firstRow = rows.shift();
24065 /** @type {Array<Element>} */
24066 const tableContent = [];
24067 if (firstRow) {
24068 /** @type {Element} */
24069 const head = {
24070 type: "element",
24071 tagName: "thead",
24072 properties: {},
24073 children: state.wrap([firstRow], true)
24074 };
24075 state.patch(node.children[0], head);
24076 tableContent.push(head);
24077 }
24078 if (rows.length > 0) {
24079 /** @type {Element} */
24080 const body = {
24081 type: "element",
24082 tagName: "tbody",
24083 properties: {},
24084 children: state.wrap(rows, true)
24085 };
24086 const start = pointStart(node.children[1]);
24087 const end = pointEnd(node.children[node.children.length - 1]);
24088 if (start.line && end.line) body.position = {
24089 start,
24090 end
24091 };
24092 tableContent.push(body);
24093 }
24094 /** @type {Element} */
24095 const result = {
24096 type: "element",
24097 tagName: "table",
24098 properties: {},
24099 children: state.wrap(tableContent, true)
24100 };
24101 state.patch(node, result);
24102 return state.applyData(node, result);
24103 }
24104 var init_table = __esmMin((() => {
24105 init_unist_util_position();
24106 }));
24107
24108 //#endregion
24109 //#region node_modules/mdast-util-to-hast/lib/handlers/table-row.js
24110 /**
24111 * @typedef {import('hast').Properties} Properties
24112 * @typedef {import('hast').Element} Element
24113 * @typedef {import('hast').ElementContent} ElementContent
24114 * @typedef {import('mdast').Content} Content
24115 * @typedef {import('mdast').Parent} Parent
24116 * @typedef {import('mdast').Root} Root
24117 * @typedef {import('mdast').TableRow} TableRow
24118 * @typedef {import('../state.js').State} State
24119 */
24120 /**
24121 * @typedef {Root | Content} Nodes
24122 * @typedef {Extract<Nodes, Parent>} Parents
24123 */
24124 /**
24125 * Turn an mdast `tableRow` node into hast.
24126 *
24127 * @param {State} state
24128 * Info passed around.
24129 * @param {TableRow} node
24130 * mdast node.
24131 * @param {Parents | null | undefined} parent
24132 * Parent of `node`.
24133 * @returns {Element}
24134 * hast node.
24135 */
24136 function tableRow(state, node, parent) {
24137 const siblings = parent ? parent.children : void 0;
24138 const tagName = (siblings ? siblings.indexOf(node) : 1) === 0 ? "th" : "td";
24139 const align = parent && parent.type === "table" ? parent.align : void 0;
24140 const length = align ? align.length : node.children.length;
24141 let cellIndex = -1;
24142 /** @type {Array<ElementContent>} */
24143 const cells = [];
24144 while (++cellIndex < length) {
24145 const cell = node.children[cellIndex];
24146 /** @type {Properties} */
24147 const properties = {};
24148 const alignValue = align ? align[cellIndex] : void 0;
24149 if (alignValue) properties.align = alignValue;
24150 /** @type {Element} */
24151 let result = {
24152 type: "element",
24153 tagName,
24154 properties,
24155 children: []
24156 };
24157 if (cell) {
24158 result.children = state.all(cell);
24159 state.patch(cell, result);
24160 result = state.applyData(node, result);
24161 }
24162 cells.push(result);
24163 }
24164 /** @type {Element} */
24165 const result = {
24166 type: "element",
24167 tagName: "tr",
24168 properties: {},
24169 children: state.wrap(cells, true)
24170 };
24171 state.patch(node, result);
24172 return state.applyData(node, result);
24173 }
24174 var init_table_row = __esmMin((() => {}));
24175
24176 //#endregion
24177 //#region node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
24178 /**
24179 * @typedef {import('hast').Element} Element
24180 * @typedef {import('mdast').TableCell} TableCell
24181 * @typedef {import('../state.js').State} State
24182 */
24183 /**
24184 * Turn an mdast `tableCell` node into hast.
24185 *
24186 * @param {State} state
24187 * Info passed around.
24188 * @param {TableCell} node
24189 * mdast node.
24190 * @returns {Element}
24191 * hast node.
24192 */
24193 function tableCell(state, node) {
24194 /** @type {Element} */
24195 const result = {
24196 type: "element",
24197 tagName: "td",
24198 properties: {},
24199 children: state.all(node)
24200 };
24201 state.patch(node, result);
24202 return state.applyData(node, result);
24203 }
24204 var init_table_cell = __esmMin((() => {}));
24205
24206 //#endregion
24207 //#region node_modules/trim-lines/index.js
24208 /**
24209 * Remove initial and final spaces and tabs at the line breaks in `value`.
24210 * Does not trim initial and final spaces and tabs of the value itself.
24211 *
24212 * @param {string} value
24213 * Value to trim.
24214 * @returns {string}
24215 * Trimmed value.
24216 */
24217 function trimLines(value) {
24218 const source = String(value);
24219 const search = /\r?\n|\r/g;
24220 let match = search.exec(source);
24221 let last = 0;
24222 /** @type {Array<string>} */
24223 const lines = [];
24224 while (match) {
24225 lines.push(trimLine(source.slice(last, match.index), last > 0, true), match[0]);
24226 last = match.index + match[0].length;
24227 match = search.exec(source);
24228 }
24229 lines.push(trimLine(source.slice(last), last > 0, false));
24230 return lines.join("");
24231 }
24232 /**
24233 * @param {string} value
24234 * Line to trim.
24235 * @param {boolean} start
24236 * Whether to trim the start of the line.
24237 * @param {boolean} end
24238 * Whether to trim the end of the line.
24239 * @returns {string}
24240 * Trimmed line.
24241 */
24242 function trimLine(value, start, end) {
24243 let startIndex = 0;
24244 let endIndex = value.length;
24245 if (start) {
24246 let code = value.codePointAt(startIndex);
24247 while (code === tab || code === space) {
24248 startIndex++;
24249 code = value.codePointAt(startIndex);
24250 }
24251 }
24252 if (end) {
24253 let code = value.codePointAt(endIndex - 1);
24254 while (code === tab || code === space) {
24255 endIndex--;
24256 code = value.codePointAt(endIndex - 1);
24257 }
24258 }
24259 return endIndex > startIndex ? value.slice(startIndex, endIndex) : "";
24260 }
24261 var tab, space;
24262 var init_trim_lines = __esmMin((() => {
24263 tab = 9;
24264 space = 32;
24265 }));
24266
24267 //#endregion
24268 //#region node_modules/mdast-util-to-hast/lib/handlers/text.js
24269 /**
24270 * Turn an mdast `text` node into hast.
24271 *
24272 * @param {State} state
24273 * Info passed around.
24274 * @param {MdastText} node
24275 * mdast node.
24276 * @returns {HastText | HastElement}
24277 * hast node.
24278 */
24279 function text(state, node) {
24280 /** @type {HastText} */
24281 const result = {
24282 type: "text",
24283 value: trimLines(String(node.value))
24284 };
24285 state.patch(node, result);
24286 return state.applyData(node, result);
24287 }
24288 var init_text = __esmMin((() => {
24289 init_trim_lines();
24290 }));
24291
24292 //#endregion
24293 //#region node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
24294 /**
24295 * @typedef {import('hast').Element} Element
24296 * @typedef {import('mdast').ThematicBreak} ThematicBreak
24297 * @typedef {import('../state.js').State} State
24298 */
24299 /**
24300 * Turn an mdast `thematicBreak` node into hast.
24301 *
24302 * @param {State} state
24303 * Info passed around.
24304 * @param {ThematicBreak} node
24305 * mdast node.
24306 * @returns {Element}
24307 * hast node.
24308 */
24309 function thematicBreak(state, node) {
24310 /** @type {Element} */
24311 const result = {
24312 type: "element",
24313 tagName: "hr",
24314 properties: {},
24315 children: []
24316 };
24317 state.patch(node, result);
24318 return state.applyData(node, result);
24319 }
24320 var init_thematic_break = __esmMin((() => {}));
24321
24322 //#endregion
24323 //#region node_modules/mdast-util-to-hast/lib/handlers/index.js
24324 function ignore() {
24325 return null;
24326 }
24327 var handlers;
24328 var init_handlers = __esmMin((() => {
24329 init_blockquote();
24330 init_break();
24331 init_code();
24332 init_delete();
24333 init_emphasis();
24334 init_footnote_reference();
24335 init_footnote();
24336 init_heading();
24337 init_html$1();
24338 init_image_reference();
24339 init_image();
24340 init_inline_code();
24341 init_link_reference();
24342 init_link();
24343 init_list_item();
24344 init_list();
24345 init_paragraph();
24346 init_root();
24347 init_strong();
24348 init_table();
24349 init_table_row();
24350 init_table_cell();
24351 init_text();
24352 init_thematic_break();
24353 handlers = {
24354 blockquote,
24355 break: hardBreak,
24356 code,
24357 delete: strikethrough,
24358 emphasis,
24359 footnoteReference,
24360 footnote,
24361 heading,
24362 html: html$2,
24363 imageReference,
24364 image,
24365 inlineCode,
24366 linkReference,
24367 link,
24368 listItem,
24369 list,
24370 paragraph,
24371 root,
24372 strong,
24373 table,
24374 tableCell,
24375 tableRow,
24376 text,
24377 thematicBreak,
24378 toml: ignore,
24379 yaml: ignore,
24380 definition: ignore,
24381 footnoteDefinition: ignore
24382 };
24383 }));
24384
24385 //#endregion
24386 //#region node_modules/unist-util-is/lib/index.js
24387 /**
24388 * @param {Array<string | Props | TestFunctionAnything>} tests
24389 * @returns {AssertAnything}
24390 */
24391 function anyFactory(tests) {
24392 /** @type {Array<AssertAnything>} */
24393 const checks = [];
24394 let index = -1;
24395 while (++index < tests.length) checks[index] = convert(tests[index]);
24396 return castFactory(any);
24397 /**
24398 * @this {unknown}
24399 * @param {Array<unknown>} parameters
24400 * @returns {boolean}
24401 */
24402 function any(...parameters) {
24403 let index = -1;
24404 while (++index < checks.length) if (checks[index].call(this, ...parameters)) return true;
24405 return false;
24406 }
24407 }
24408 /**
24409 * Turn an object into a test for a node with a certain fields.
24410 *
24411 * @param {Props} check
24412 * @returns {AssertAnything}
24413 */
24414 function propsFactory(check) {
24415 return castFactory(all);
24416 /**
24417 * @param {Node} node
24418 * @returns {boolean}
24419 */
24420 function all(node) {
24421 /** @type {string} */
24422 let key;
24423 for (key in check) if (node[key] !== check[key]) return false;
24424 return true;
24425 }
24426 }
24427 /**
24428 * Turn a string into a test for a node with a certain type.
24429 *
24430 * @param {string} check
24431 * @returns {AssertAnything}
24432 */
24433 function typeFactory(check) {
24434 return castFactory(type);
24435 /**
24436 * @param {Node} node
24437 */
24438 function type(node) {
24439 return node && node.type === check;
24440 }
24441 }
24442 /**
24443 * Turn a custom test into a test for a node that passes that test.
24444 *
24445 * @param {TestFunctionAnything} check
24446 * @returns {AssertAnything}
24447 */
24448 function castFactory(check) {
24449 return assertion;
24450 /**
24451 * @this {unknown}
24452 * @param {unknown} node
24453 * @param {Array<unknown>} parameters
24454 * @returns {boolean}
24455 */
24456 function assertion(node, ...parameters) {
24457 return Boolean(node && typeof node === "object" && "type" in node && Boolean(check.call(this, node, ...parameters)));
24458 }
24459 }
24460 function ok() {
24461 return true;
24462 }
24463 var convert;
24464 var init_lib$6 = __esmMin((() => {
24465 convert = (
24466 /**
24467 * @param {Test} [test]
24468 * @returns {AssertAnything}
24469 */
24470 function(test) {
24471 if (test === void 0 || test === null) return ok;
24472 if (typeof test === "string") return typeFactory(test);
24473 if (typeof test === "object") return Array.isArray(test) ? anyFactory(test) : propsFactory(test);
24474 if (typeof test === "function") return castFactory(test);
24475 throw new Error("Expected function, string, or object as test");
24476 });
24477 }));
24478
24479 //#endregion
24480 //#region node_modules/unist-util-is/index.js
24481 var init_unist_util_is = __esmMin((() => {
24482 init_lib$6();
24483 }));
24484
24485 //#endregion
24486 //#region node_modules/unist-util-visit-parents/lib/color.browser.js
24487 /**
24488 * @param {string} d
24489 * @returns {string}
24490 */
24491 function color(d) {
24492 return d;
24493 }
24494 var init_color_browser = __esmMin((() => {}));
24495
24496 //#endregion
24497 //#region node_modules/unist-util-visit-parents/lib/index.js
24498 /**
24499 * Turn a return value into a clean result.
24500 *
24501 * @param {VisitorResult} value
24502 * Valid return values from visitors.
24503 * @returns {ActionTuple}
24504 * Clean result.
24505 */
24506 function toResult(value) {
24507 if (Array.isArray(value)) return value;
24508 if (typeof value === "number") return [true, value];
24509 return [value];
24510 }
24511 var CONTINUE, EXIT, SKIP, visitParents;
24512 var init_lib$5 = __esmMin((() => {
24513 init_unist_util_is();
24514 init_color_browser();
24515 CONTINUE = true;
24516 EXIT = false;
24517 SKIP = "skip";
24518 visitParents = (
24519 /**
24520 * @param {Node} tree
24521 * @param {Test} test
24522 * @param {Visitor<Node>} visitor
24523 * @param {boolean | null | undefined} [reverse]
24524 * @returns {void}
24525 */
24526 function(tree, test, visitor, reverse) {
24527 if (typeof test === "function" && typeof visitor !== "function") {
24528 reverse = visitor;
24529 visitor = test;
24530 test = null;
24531 }
24532 const is = convert(test);
24533 const step = reverse ? -1 : 1;
24534 factory(tree, void 0, [])();
24535 /**
24536 * @param {Node} node
24537 * @param {number | undefined} index
24538 * @param {Array<Parent>} parents
24539 */
24540 function factory(node, index, parents) {
24541 /** @type {Record<string, unknown>} */
24542 const value = node && typeof node === "object" ? node : {};
24543 if (typeof value.type === "string") {
24544 const name = typeof value.tagName === "string" ? value.tagName : typeof value.name === "string" ? value.name : void 0;
24545 Object.defineProperty(visit, "name", { value: "node (" + color(node.type + (name ? "<" + name + ">" : "")) + ")" });
24546 }
24547 return visit;
24548 function visit() {
24549 /** @type {ActionTuple} */
24550 let result = [];
24551 /** @type {ActionTuple} */
24552 let subresult;
24553 /** @type {number} */
24554 let offset;
24555 /** @type {Array<Parent>} */
24556 let grandparents;
24557 if (!test || is(node, index, parents[parents.length - 1] || null)) {
24558 result = toResult(visitor(node, parents));
24559 if (result[0] === false) return result;
24560 }
24561 if (node.children && result[0] !== "skip") {
24562 offset = (reverse ? node.children.length : -1) + step;
24563 grandparents = parents.concat(node);
24564 while (offset > -1 && offset < node.children.length) {
24565 subresult = factory(node.children[offset], offset, grandparents)();
24566 if (subresult[0] === false) return subresult;
24567 offset = typeof subresult[1] === "number" ? subresult[1] : offset + step;
24568 }
24569 }
24570 return result;
24571 }
24572 }
24573 });
24574 }));
24575
24576 //#endregion
24577 //#region node_modules/unist-util-visit-parents/index.js
24578 var init_unist_util_visit_parents = __esmMin((() => {
24579 init_lib$5();
24580 }));
24581
24582 //#endregion
24583 //#region node_modules/unist-util-visit/lib/index.js
24584 var visit;
24585 var init_lib$4 = __esmMin((() => {
24586 init_unist_util_visit_parents();
24587 visit = (
24588 /**
24589 * @param {Node} tree
24590 * @param {Test} test
24591 * @param {Visitor} visitor
24592 * @param {boolean | null | undefined} [reverse]
24593 * @returns {void}
24594 */
24595 function(tree, test, visitor, reverse) {
24596 if (typeof test === "function" && typeof visitor !== "function") {
24597 reverse = visitor;
24598 visitor = test;
24599 test = null;
24600 }
24601 visitParents(tree, test, overload, reverse);
24602 /**
24603 * @param {Node} node
24604 * @param {Array<Parent>} parents
24605 */
24606 function overload(node, parents) {
24607 const parent = parents[parents.length - 1];
24608 return visitor(node, parent ? parent.children.indexOf(node) : null, parent);
24609 }
24610 });
24611 }));
24612
24613 //#endregion
24614 //#region node_modules/unist-util-visit/index.js
24615 var init_unist_util_visit = __esmMin((() => {
24616 init_lib$4();
24617 }));
24618
24619 //#endregion
24620 //#region node_modules/unist-util-generated/lib/index.js
24621 /**
24622 * @typedef PointLike
24623 * @property {number | null | undefined} [line]
24624 * @property {number | null | undefined} [column]
24625 * @property {number | null | undefined} [offset]
24626 *
24627 * @typedef PositionLike
24628 * @property {PointLike | null | undefined} [start]
24629 * @property {PointLike | null | undefined} [end]
24630 *
24631 * @typedef NodeLike
24632 * @property {PositionLike | null | undefined} [position]
24633 */
24634 /**
24635 * Check if `node` is generated.
24636 *
24637 * @param {NodeLike | null | undefined} [node]
24638 * Node to check.
24639 * @returns {boolean}
24640 * Whether `node` is generated (does not have positional info).
24641 */
24642 function generated(node) {
24643 return !node || !node.position || !node.position.start || !node.position.start.line || !node.position.start.column || !node.position.end || !node.position.end.line || !node.position.end.column;
24644 }
24645 var init_lib$3 = __esmMin((() => {}));
24646
24647 //#endregion
24648 //#region node_modules/unist-util-generated/index.js
24649 var init_unist_util_generated = __esmMin((() => {
24650 init_lib$3();
24651 }));
24652
24653 //#endregion
24654 //#region node_modules/mdast-util-definitions/lib/index.js
24655 /**
24656 * Find definitions in `tree`.
24657 *
24658 * Uses CommonMark precedence, which means that earlier definitions are
24659 * preferred over duplicate later definitions.
24660 *
24661 * @param {Node} tree
24662 * Tree to check.
24663 * @returns {GetDefinition}
24664 * Getter.
24665 */
24666 function definitions(tree) {
24667 /** @type {Record<string, Definition>} */
24668 const cache = Object.create(null);
24669 if (!tree || !tree.type) throw new Error("mdast-util-definitions expected node");
24670 visit(tree, "definition", (definition) => {
24671 const id = clean(definition.identifier);
24672 if (id && !own$4.call(cache, id)) cache[id] = definition;
24673 });
24674 return definition;
24675 /** @type {GetDefinition} */
24676 function definition(identifier) {
24677 const id = clean(identifier);
24678 return id && own$4.call(cache, id) ? cache[id] : null;
24679 }
24680 }
24681 /**
24682 * @param {string | null | undefined} [value]
24683 * @returns {string}
24684 */
24685 function clean(value) {
24686 return String(value || "").toUpperCase();
24687 }
24688 var own$4;
24689 var init_lib$2 = __esmMin((() => {
24690 init_unist_util_visit();
24691 own$4 = {}.hasOwnProperty;
24692 }));
24693
24694 //#endregion
24695 //#region node_modules/mdast-util-definitions/index.js
24696 var init_mdast_util_definitions = __esmMin((() => {
24697 init_lib$2();
24698 }));
24699
24700 //#endregion
24701 //#region node_modules/mdast-util-to-hast/lib/state.js
24702 /**
24703 * Create `state` from an mdast tree.
24704 *
24705 * @param {MdastNodes} tree
24706 * mdast node to transform.
24707 * @param {Options | null | undefined} [options]
24708 * Configuration.
24709 * @returns {State}
24710 * `state` function.
24711 */
24712 function createState(tree, options) {
24713 const settings = options || {};
24714 const dangerous = settings.allowDangerousHtml || false;
24715 /** @type {Record<string, MdastFootnoteDefinition>} */
24716 const footnoteById = {};
24717 state.dangerous = dangerous;
24718 state.clobberPrefix = settings.clobberPrefix === void 0 || settings.clobberPrefix === null ? "user-content-" : settings.clobberPrefix;
24719 state.footnoteLabel = settings.footnoteLabel || "Footnotes";
24720 state.footnoteLabelTagName = settings.footnoteLabelTagName || "h2";
24721 state.footnoteLabelProperties = settings.footnoteLabelProperties || { className: ["sr-only"] };
24722 state.footnoteBackLabel = settings.footnoteBackLabel || "Back to content";
24723 state.unknownHandler = settings.unknownHandler;
24724 state.passThrough = settings.passThrough;
24725 state.handlers = _objectSpread2(_objectSpread2({}, handlers), settings.handlers);
24726 state.definition = definitions(tree);
24727 state.footnoteById = footnoteById;
24728 /** @type {Array<string>} */
24729 state.footnoteOrder = [];
24730 /** @type {Record<string, number>} */
24731 state.footnoteCounts = {};
24732 state.patch = patch;
24733 state.applyData = applyData;
24734 state.one = oneBound;
24735 state.all = allBound;
24736 state.wrap = wrap;
24737 state.augment = augment;
24738 visit(tree, "footnoteDefinition", (definition) => {
24739 const id = String(definition.identifier).toUpperCase();
24740 if (!own$3.call(footnoteById, id)) footnoteById[id] = definition;
24741 });
24742 return state;
24743 /**
24744 * Finalise the created `right`, a hast node, from `left`, an mdast node.
24745 *
24746 * @param {MdastNodeWithData | PositionLike | null | undefined} left
24747 * @param {HastElementContent} right
24748 * @returns {HastElementContent}
24749 */
24750 /* c8 ignore start */
24751 function augment(left, right) {
24752 if (left && "data" in left && left.data) {
24753 /** @type {MdastData} */
24754 const data = left.data;
24755 if (data.hName) {
24756 if (right.type !== "element") right = {
24757 type: "element",
24758 tagName: "",
24759 properties: {},
24760 children: []
24761 };
24762 right.tagName = data.hName;
24763 }
24764 if (right.type === "element" && data.hProperties) right.properties = _objectSpread2(_objectSpread2({}, right.properties), data.hProperties);
24765 if ("children" in right && right.children && data.hChildren) right.children = data.hChildren;
24766 }
24767 if (left) {
24768 const ctx = "type" in left ? left : { position: left };
24769 if (!generated(ctx)) right.position = {
24770 start: pointStart(ctx),
24771 end: pointEnd(ctx)
24772 };
24773 }
24774 return right;
24775 }
24776 /* c8 ignore stop */
24777 /**
24778 * Create an element for `node`.
24779 *
24780 * @type {HFunctionProps}
24781 */
24782 /* c8 ignore start */
24783 function state(node, tagName, props, children) {
24784 if (Array.isArray(props)) {
24785 children = props;
24786 props = {};
24787 }
24788 return augment(node, {
24789 type: "element",
24790 tagName,
24791 properties: props || {},
24792 children: children || []
24793 });
24794 }
24795 /* c8 ignore stop */
24796 /**
24797 * Transform an mdast node into a hast node.
24798 *
24799 * @param {MdastNodes} node
24800 * mdast node.
24801 * @param {MdastParents | null | undefined} [parent]
24802 * Parent of `node`.
24803 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24804 * Resulting hast node.
24805 */
24806 function oneBound(node, parent) {
24807 return one(state, node, parent);
24808 }
24809 /**
24810 * Transform the children of an mdast node into hast nodes.
24811 *
24812 * @param {MdastNodes} parent
24813 * mdast node to compile
24814 * @returns {Array<HastElementContent>}
24815 * Resulting hast nodes.
24816 */
24817 function allBound(parent) {
24818 return all(state, parent);
24819 }
24820 }
24821 /**
24822 * Copy a node’s positional info.
24823 *
24824 * @param {MdastNodes} from
24825 * mdast node to copy from.
24826 * @param {HastNodes} to
24827 * hast node to copy into.
24828 * @returns {void}
24829 * Nothing.
24830 */
24831 function patch(from, to) {
24832 if (from.position) to.position = position(from);
24833 }
24834 /**
24835 * Honor the `data` of `from` and maybe generate an element instead of `to`.
24836 *
24837 * @template {HastNodes} Type
24838 * Node type.
24839 * @param {MdastNodes} from
24840 * mdast node to use data from.
24841 * @param {Type} to
24842 * hast node to change.
24843 * @returns {Type | HastElement}
24844 * Nothing.
24845 */
24846 function applyData(from, to) {
24847 /** @type {Type | HastElement} */
24848 let result = to;
24849 if (from && from.data) {
24850 const hName = from.data.hName;
24851 const hChildren = from.data.hChildren;
24852 const hProperties = from.data.hProperties;
24853 if (typeof hName === "string") if (result.type === "element") result.tagName = hName;
24854 else result = {
24855 type: "element",
24856 tagName: hName,
24857 properties: {},
24858 children: []
24859 };
24860 if (result.type === "element" && hProperties) result.properties = _objectSpread2(_objectSpread2({}, result.properties), hProperties);
24861 if ("children" in result && result.children && hChildren !== null && hChildren !== void 0) result.children = hChildren;
24862 }
24863 return result;
24864 }
24865 /**
24866 * Transform an mdast node into a hast node.
24867 *
24868 * @param {State} state
24869 * Info passed around.
24870 * @param {MdastNodes} node
24871 * mdast node.
24872 * @param {MdastParents | null | undefined} [parent]
24873 * Parent of `node`.
24874 * @returns {HastElementContent | Array<HastElementContent> | null | undefined}
24875 * Resulting hast node.
24876 */
24877 function one(state, node, parent) {
24878 const type = node && node.type;
24879 if (!type) throw new Error("Expected node, got `" + node + "`");
24880 if (own$3.call(state.handlers, type)) return state.handlers[type](state, node, parent);
24881 if (state.passThrough && state.passThrough.includes(type)) return "children" in node ? _objectSpread2(_objectSpread2({}, node), {}, { children: all(state, node) }) : node;
24882 if (state.unknownHandler) return state.unknownHandler(state, node, parent);
24883 return defaultUnknownHandler(state, node);
24884 }
24885 /**
24886 * Transform the children of an mdast node into hast nodes.
24887 *
24888 * @param {State} state
24889 * Info passed around.
24890 * @param {MdastNodes} parent
24891 * mdast node to compile
24892 * @returns {Array<HastElementContent>}
24893 * Resulting hast nodes.
24894 */
24895 function all(state, parent) {
24896 /** @type {Array<HastElementContent>} */
24897 const values = [];
24898 if ("children" in parent) {
24899 const nodes = parent.children;
24900 let index = -1;
24901 while (++index < nodes.length) {
24902 const result = one(state, nodes[index], parent);
24903 if (result) {
24904 if (index && nodes[index - 1].type === "break") {
24905 if (!Array.isArray(result) && result.type === "text") result.value = result.value.replace(/^\s+/, "");
24906 if (!Array.isArray(result) && result.type === "element") {
24907 const head = result.children[0];
24908 if (head && head.type === "text") head.value = head.value.replace(/^\s+/, "");
24909 }
24910 }
24911 if (Array.isArray(result)) values.push(...result);
24912 else values.push(result);
24913 }
24914 }
24915 }
24916 return values;
24917 }
24918 /**
24919 * Transform an unknown node.
24920 *
24921 * @param {State} state
24922 * Info passed around.
24923 * @param {MdastNodes} node
24924 * Unknown mdast node.
24925 * @returns {HastText | HastElement}
24926 * Resulting hast node.
24927 */
24928 function defaultUnknownHandler(state, node) {
24929 const data = node.data || {};
24930 /** @type {HastText | HastElement} */
24931 const result = "value" in node && !(own$3.call(data, "hProperties") || own$3.call(data, "hChildren")) ? {
24932 type: "text",
24933 value: node.value
24934 } : {
24935 type: "element",
24936 tagName: "div",
24937 properties: {},
24938 children: all(state, node)
24939 };
24940 state.patch(node, result);
24941 return state.applyData(node, result);
24942 }
24943 /**
24944 * Wrap `nodes` with line endings between each node.
24945 *
24946 * @template {HastContent} Type
24947 * Node type.
24948 * @param {Array<Type>} nodes
24949 * List of nodes to wrap.
24950 * @param {boolean | null | undefined} [loose=false]
24951 * Whether to add line endings at start and end.
24952 * @returns {Array<Type | HastText>}
24953 * Wrapped nodes.
24954 */
24955 function wrap(nodes, loose) {
24956 /** @type {Array<Type | HastText>} */
24957 const result = [];
24958 let index = -1;
24959 if (loose) result.push({
24960 type: "text",
24961 value: "\n"
24962 });
24963 while (++index < nodes.length) {
24964 if (index) result.push({
24965 type: "text",
24966 value: "\n"
24967 });
24968 result.push(nodes[index]);
24969 }
24970 if (loose && nodes.length > 0) result.push({
24971 type: "text",
24972 value: "\n"
24973 });
24974 return result;
24975 }
24976 var own$3;
24977 var init_state = __esmMin((() => {
24978 init_unist_util_visit();
24979 init_unist_util_position();
24980 init_unist_util_generated();
24981 init_mdast_util_definitions();
24982 init_handlers();
24983 init_objectSpread2();
24984 own$3 = {}.hasOwnProperty;
24985 }));
24986
24987 //#endregion
24988 //#region node_modules/mdast-util-to-hast/lib/footer.js
24989 /**
24990 * Generate a hast footer for called footnote definitions.
24991 *
24992 * @param {State} state
24993 * Info passed around.
24994 * @returns {Element | undefined}
24995 * `section` element or `undefined`.
24996 */
24997 function footer(state) {
24998 /** @type {Array<ElementContent>} */
24999 const listItems = [];
25000 let index = -1;
25001 while (++index < state.footnoteOrder.length) {
25002 const def = state.footnoteById[state.footnoteOrder[index]];
25003 if (!def) continue;
25004 const content = state.all(def);
25005 const id = String(def.identifier).toUpperCase();
25006 const safeId = normalizeUri(id.toLowerCase());
25007 let referenceIndex = 0;
25008 /** @type {Array<ElementContent>} */
25009 const backReferences = [];
25010 while (++referenceIndex <= state.footnoteCounts[id]) {
25011 /** @type {Element} */
25012 const backReference = {
25013 type: "element",
25014 tagName: "a",
25015 properties: {
25016 href: "#" + state.clobberPrefix + "fnref-" + safeId + (referenceIndex > 1 ? "-" + referenceIndex : ""),
25017 dataFootnoteBackref: true,
25018 className: ["data-footnote-backref"],
25019 ariaLabel: state.footnoteBackLabel
25020 },
25021 children: [{
25022 type: "text",
25023 value: "↩"
25024 }]
25025 };
25026 if (referenceIndex > 1) backReference.children.push({
25027 type: "element",
25028 tagName: "sup",
25029 children: [{
25030 type: "text",
25031 value: String(referenceIndex)
25032 }]
25033 });
25034 if (backReferences.length > 0) backReferences.push({
25035 type: "text",
25036 value: " "
25037 });
25038 backReferences.push(backReference);
25039 }
25040 const tail = content[content.length - 1];
25041 if (tail && tail.type === "element" && tail.tagName === "p") {
25042 const tailTail = tail.children[tail.children.length - 1];
25043 if (tailTail && tailTail.type === "text") tailTail.value += " ";
25044 else tail.children.push({
25045 type: "text",
25046 value: " "
25047 });
25048 tail.children.push(...backReferences);
25049 } else content.push(...backReferences);
25050 /** @type {Element} */
25051 const listItem = {
25052 type: "element",
25053 tagName: "li",
25054 properties: { id: state.clobberPrefix + "fn-" + safeId },
25055 children: state.wrap(content, true)
25056 };
25057 state.patch(def, listItem);
25058 listItems.push(listItem);
25059 }
25060 if (listItems.length === 0) return;
25061 return {
25062 type: "element",
25063 tagName: "section",
25064 properties: {
25065 dataFootnotes: true,
25066 className: ["footnotes"]
25067 },
25068 children: [
25069 {
25070 type: "element",
25071 tagName: state.footnoteLabelTagName,
25072 properties: _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(state.footnoteLabelProperties))), {}, { id: "footnote-label" }),
25073 children: [{
25074 type: "text",
25075 value: state.footnoteLabel
25076 }]
25077 },
25078 {
25079 type: "text",
25080 value: "\n"
25081 },
25082 {
25083 type: "element",
25084 tagName: "ol",
25085 properties: {},
25086 children: state.wrap(listItems, true)
25087 },
25088 {
25089 type: "text",
25090 value: "\n"
25091 }
25092 ]
25093 };
25094 }
25095 var init_footer = __esmMin((() => {
25096 init_micromark_util_sanitize_uri();
25097 init_objectSpread2();
25098 }));
25099
25100 //#endregion
25101 //#region node_modules/mdast-util-to-hast/lib/index.js
25102 /**
25103 * Transform mdast to hast.
25104 *
25105 * ##### Notes
25106 *
25107 * ###### HTML
25108 *
25109 * Raw HTML is available in mdast as `html` nodes and can be embedded in hast
25110 * as semistandard `raw` nodes.
25111 * Most utilities ignore `raw` nodes but two notable ones don’t:
25112 *
25113 * * `hast-util-to-html` also has an option `allowDangerousHtml` which will
25114 * output the raw HTML.
25115 * This is typically discouraged as noted by the option name but is useful
25116 * if you completely trust authors
25117 * * `hast-util-raw` can handle the raw embedded HTML strings by parsing them
25118 * into standard hast nodes (`element`, `text`, etc).
25119 * This is a heavy task as it needs a full HTML parser, but it is the only
25120 * way to support untrusted content
25121 *
25122 * ###### Footnotes
25123 *
25124 * Many options supported here relate to footnotes.
25125 * Footnotes are not specified by CommonMark, which we follow by default.
25126 * They are supported by GitHub, so footnotes can be enabled in markdown with
25127 * `mdast-util-gfm`.
25128 *
25129 * The options `footnoteBackLabel` and `footnoteLabel` define natural language
25130 * that explains footnotes, which is hidden for sighted users but shown to
25131 * assistive technology.
25132 * When your page is not in English, you must define translated values.
25133 *
25134 * Back references use ARIA attributes, but the section label itself uses a
25135 * heading that is hidden with an `sr-only` class.
25136 * To show it to sighted users, define different attributes in
25137 * `footnoteLabelProperties`.
25138 *
25139 * ###### Clobbering
25140 *
25141 * Footnotes introduces a problem, as it links footnote calls to footnote
25142 * definitions on the page through `id` attributes generated from user content,
25143 * which results in DOM clobbering.
25144 *
25145 * DOM clobbering is this:
25146 *
25147 * ```html
25148 * <p id=x></p>
25149 * <script>alert(x) // `x` now refers to the DOM `p#x` element<\/script>
25150 * ```
25151 *
25152 * Elements by their ID are made available by browsers on the `window` object,
25153 * which is a security risk.
25154 * Using a prefix solves this problem.
25155 *
25156 * More information on how to handle clobbering and the prefix is explained in
25157 * Example: headings (DOM clobbering) in `rehype-sanitize`.
25158 *
25159 * ###### Unknown nodes
25160 *
25161 * Unknown nodes are nodes with a type that isn’t in `handlers` or `passThrough`.
25162 * The default behavior for unknown nodes is:
25163 *
25164 * * when the node has a `value` (and doesn’t have `data.hName`,
25165 * `data.hProperties`, or `data.hChildren`, see later), create a hast `text`
25166 * node
25167 * * otherwise, create a `<div>` element (which could be changed with
25168 * `data.hName`), with its children mapped from mdast to hast as well
25169 *
25170 * This behavior can be changed by passing an `unknownHandler`.
25171 *
25172 * @param {MdastNodes} tree
25173 * mdast tree.
25174 * @param {Options | null | undefined} [options]
25175 * Configuration.
25176 * @returns {HastNodes | null | undefined}
25177 * hast tree.
25178 */
25179 function toHast(tree, options) {
25180 const state = createState(tree, options);
25181 const node = state.one(tree, null);
25182 const foot = footer(state);
25183 if (foot) node.children.push({
25184 type: "text",
25185 value: "\n"
25186 }, foot);
25187 return Array.isArray(node) ? {
25188 type: "root",
25189 children: node
25190 } : node;
25191 }
25192 var init_lib$1 = __esmMin((() => {
25193 init_footer();
25194 init_state();
25195 }));
25196
25197 //#endregion
25198 //#region node_modules/mdast-util-to-hast/index.js
25199 var init_mdast_util_to_hast = __esmMin((() => {
25200 init_handlers();
25201 init_state();
25202 init_lib$1();
25203 }));
25204
25205 //#endregion
25206 //#region node_modules/remark-rehype/lib/index.js
25207 /**
25208 * Bridge-mode.
25209 * Runs the destination with the new hast tree.
25210 *
25211 * @type {import('unified').Plugin<[Processor, Options?], MdastRoot>}
25212 */
25213 function bridge(destination, options) {
25214 return (node, file, next) => {
25215 destination.run(toHast(node, options), file, (error) => {
25216 next(error);
25217 });
25218 };
25219 }
25220 /**
25221 * Mutate-mode.
25222 * Further plugins run on the hast tree.
25223 *
25224 * @type {import('unified').Plugin<[Options?]|void[], MdastRoot, HastRoot>}
25225 */
25226 function mutate(options) {
25227 return (node) => toHast(node, options);
25228 }
25229 var remarkRehype;
25230 var init_lib = __esmMin((() => {
25231 init_mdast_util_to_hast();
25232 remarkRehype = (function(destination, options) {
25233 return destination && "run" in destination ? bridge(destination, options) : mutate(destination || options);
25234 });
25235 }));
25236
25237 //#endregion
25238 //#region node_modules/remark-rehype/index.js
25239 var init_remark_rehype = __esmMin((() => {
25240 init_mdast_util_to_hast();
25241 init_lib();
25242 }));
25243
25244 //#endregion
25245 //#region node_modules/property-information/lib/util/schema.js
25246 var Schema;
25247 var init_schema = __esmMin((() => {
25248 Schema = class {
25249 /**
25250 * @constructor
25251 * @param {Properties} property
25252 * @param {Normal} normal
25253 * @param {string} [space]
25254 */
25255 constructor(property, normal, space) {
25256 this.property = property;
25257 this.normal = normal;
25258 if (space) this.space = space;
25259 }
25260 };
25261 /** @type {Properties} */
25262 Schema.prototype.property = {};
25263 /** @type {Normal} */
25264 Schema.prototype.normal = {};
25265 /** @type {string|null} */
25266 Schema.prototype.space = null;
25267 }));
25268
25269 //#endregion
25270 //#region node_modules/property-information/lib/util/merge.js
25271 /**
25272 * @param {Schema[]} definitions
25273 * @param {string} [space]
25274 * @returns {Schema}
25275 */
25276 function merge(definitions, space) {
25277 /** @type {Properties} */
25278 const property = {};
25279 /** @type {Normal} */
25280 const normal = {};
25281 let index = -1;
25282 while (++index < definitions.length) {
25283 Object.assign(property, definitions[index].property);
25284 Object.assign(normal, definitions[index].normal);
25285 }
25286 return new Schema(property, normal, space);
25287 }
25288 var init_merge = __esmMin((() => {
25289 init_schema();
25290 }));
25291
25292 //#endregion
25293 //#region node_modules/property-information/lib/normalize.js
25294 /**
25295 * @param {string} value
25296 * @returns {string}
25297 */
25298 function normalize(value) {
25299 return value.toLowerCase();
25300 }
25301 var init_normalize = __esmMin((() => {}));
25302
25303 //#endregion
25304 //#region node_modules/property-information/lib/util/info.js
25305 var Info;
25306 var init_info = __esmMin((() => {
25307 Info = class {
25308 /**
25309 * @constructor
25310 * @param {string} property
25311 * @param {string} attribute
25312 */
25313 constructor(property, attribute) {
25314 /** @type {string} */
25315 this.property = property;
25316 /** @type {string} */
25317 this.attribute = attribute;
25318 }
25319 };
25320 /** @type {string|null} */
25321 Info.prototype.space = null;
25322 Info.prototype.boolean = false;
25323 Info.prototype.booleanish = false;
25324 Info.prototype.overloadedBoolean = false;
25325 Info.prototype.number = false;
25326 Info.prototype.commaSeparated = false;
25327 Info.prototype.spaceSeparated = false;
25328 Info.prototype.commaOrSpaceSeparated = false;
25329 Info.prototype.mustUseProperty = false;
25330 Info.prototype.defined = false;
25331 }));
25332
25333 //#endregion
25334 //#region node_modules/property-information/lib/util/types.js
25335 var types_exports = /* @__PURE__ */ __exportAll({
25336 boolean: () => boolean,
25337 booleanish: () => booleanish,
25338 commaOrSpaceSeparated: () => commaOrSpaceSeparated,
25339 commaSeparated: () => commaSeparated,
25340 number: () => number,
25341 overloadedBoolean: () => overloadedBoolean,
25342 spaceSeparated: () => spaceSeparated
25343 });
25344 function increment() {
25345 return Math.pow(2, ++powers);
25346 }
25347 var powers, boolean, booleanish, overloadedBoolean, number, spaceSeparated, commaSeparated, commaOrSpaceSeparated;
25348 var init_types = __esmMin((() => {
25349 powers = 0;
25350 boolean = increment();
25351 booleanish = increment();
25352 overloadedBoolean = increment();
25353 number = increment();
25354 spaceSeparated = increment();
25355 commaSeparated = increment();
25356 commaOrSpaceSeparated = increment();
25357 }));
25358
25359 //#endregion
25360 //#region node_modules/property-information/lib/util/defined-info.js
25361 /**
25362 * @param {DefinedInfo} values
25363 * @param {string} key
25364 * @param {unknown} value
25365 */
25366 function mark(values, key, value) {
25367 if (value) values[key] = value;
25368 }
25369 var checks, DefinedInfo;
25370 var init_defined_info = __esmMin((() => {
25371 init_info();
25372 init_types();
25373 checks = Object.keys(types_exports);
25374 DefinedInfo = class extends Info {
25375 /**
25376 * @constructor
25377 * @param {string} property
25378 * @param {string} attribute
25379 * @param {number|null} [mask]
25380 * @param {string} [space]
25381 */
25382 constructor(property, attribute, mask, space) {
25383 let index = -1;
25384 super(property, attribute);
25385 mark(this, "space", space);
25386 if (typeof mask === "number") while (++index < checks.length) {
25387 const check = checks[index];
25388 mark(this, checks[index], (mask & types_exports[check]) === types_exports[check]);
25389 }
25390 }
25391 };
25392 DefinedInfo.prototype.defined = true;
25393 }));
25394
25395 //#endregion
25396 //#region node_modules/property-information/lib/util/create.js
25397 /**
25398 * @param {Definition} definition
25399 * @returns {Schema}
25400 */
25401 function create(definition) {
25402 /** @type {Properties} */
25403 const property = {};
25404 /** @type {Normal} */
25405 const normal = {};
25406 /** @type {string} */
25407 let prop;
25408 for (prop in definition.properties) if (own$2.call(definition.properties, prop)) {
25409 const value = definition.properties[prop];
25410 const info = new DefinedInfo(prop, definition.transform(definition.attributes || {}, prop), value, definition.space);
25411 if (definition.mustUseProperty && definition.mustUseProperty.includes(prop)) info.mustUseProperty = true;
25412 property[prop] = info;
25413 normal[normalize(prop)] = prop;
25414 normal[normalize(info.attribute)] = prop;
25415 }
25416 return new Schema(property, normal, definition.space);
25417 }
25418 var own$2;
25419 var init_create = __esmMin((() => {
25420 init_normalize();
25421 init_schema();
25422 init_defined_info();
25423 own$2 = {}.hasOwnProperty;
25424 }));
25425
25426 //#endregion
25427 //#region node_modules/property-information/lib/xlink.js
25428 var xlink;
25429 var init_xlink = __esmMin((() => {
25430 init_create();
25431 xlink = create({
25432 space: "xlink",
25433 transform(_, prop) {
25434 return "xlink:" + prop.slice(5).toLowerCase();
25435 },
25436 properties: {
25437 xLinkActuate: null,
25438 xLinkArcRole: null,
25439 xLinkHref: null,
25440 xLinkRole: null,
25441 xLinkShow: null,
25442 xLinkTitle: null,
25443 xLinkType: null
25444 }
25445 });
25446 }));
25447
25448 //#endregion
25449 //#region node_modules/property-information/lib/xml.js
25450 var xml;
25451 var init_xml = __esmMin((() => {
25452 init_create();
25453 xml = create({
25454 space: "xml",
25455 transform(_, prop) {
25456 return "xml:" + prop.slice(3).toLowerCase();
25457 },
25458 properties: {
25459 xmlLang: null,
25460 xmlBase: null,
25461 xmlSpace: null
25462 }
25463 });
25464 }));
25465
25466 //#endregion
25467 //#region node_modules/property-information/lib/util/case-sensitive-transform.js
25468 /**
25469 * @param {Record<string, string>} attributes
25470 * @param {string} attribute
25471 * @returns {string}
25472 */
25473 function caseSensitiveTransform(attributes, attribute) {
25474 return attribute in attributes ? attributes[attribute] : attribute;
25475 }
25476 var init_case_sensitive_transform = __esmMin((() => {}));
25477
25478 //#endregion
25479 //#region node_modules/property-information/lib/util/case-insensitive-transform.js
25480 /**
25481 * @param {Record<string, string>} attributes
25482 * @param {string} property
25483 * @returns {string}
25484 */
25485 function caseInsensitiveTransform(attributes, property) {
25486 return caseSensitiveTransform(attributes, property.toLowerCase());
25487 }
25488 var init_case_insensitive_transform = __esmMin((() => {
25489 init_case_sensitive_transform();
25490 }));
25491
25492 //#endregion
25493 //#region node_modules/property-information/lib/xmlns.js
25494 var xmlns;
25495 var init_xmlns = __esmMin((() => {
25496 init_create();
25497 init_case_insensitive_transform();
25498 xmlns = create({
25499 space: "xmlns",
25500 attributes: { xmlnsxlink: "xmlns:xlink" },
25501 transform: caseInsensitiveTransform,
25502 properties: {
25503 xmlns: null,
25504 xmlnsXLink: null
25505 }
25506 });
25507 }));
25508
25509 //#endregion
25510 //#region node_modules/property-information/lib/aria.js
25511 var aria;
25512 var init_aria = __esmMin((() => {
25513 init_types();
25514 init_create();
25515 aria = create({
25516 transform(_, prop) {
25517 return prop === "role" ? prop : "aria-" + prop.slice(4).toLowerCase();
25518 },
25519 properties: {
25520 ariaActiveDescendant: null,
25521 ariaAtomic: booleanish,
25522 ariaAutoComplete: null,
25523 ariaBusy: booleanish,
25524 ariaChecked: booleanish,
25525 ariaColCount: number,
25526 ariaColIndex: number,
25527 ariaColSpan: number,
25528 ariaControls: spaceSeparated,
25529 ariaCurrent: null,
25530 ariaDescribedBy: spaceSeparated,
25531 ariaDetails: null,
25532 ariaDisabled: booleanish,
25533 ariaDropEffect: spaceSeparated,
25534 ariaErrorMessage: null,
25535 ariaExpanded: booleanish,
25536 ariaFlowTo: spaceSeparated,
25537 ariaGrabbed: booleanish,
25538 ariaHasPopup: null,
25539 ariaHidden: booleanish,
25540 ariaInvalid: null,
25541 ariaKeyShortcuts: null,
25542 ariaLabel: null,
25543 ariaLabelledBy: spaceSeparated,
25544 ariaLevel: number,
25545 ariaLive: null,
25546 ariaModal: booleanish,
25547 ariaMultiLine: booleanish,
25548 ariaMultiSelectable: booleanish,
25549 ariaOrientation: null,
25550 ariaOwns: spaceSeparated,
25551 ariaPlaceholder: null,
25552 ariaPosInSet: number,
25553 ariaPressed: booleanish,
25554 ariaReadOnly: booleanish,
25555 ariaRelevant: null,
25556 ariaRequired: booleanish,
25557 ariaRoleDescription: spaceSeparated,
25558 ariaRowCount: number,
25559 ariaRowIndex: number,
25560 ariaRowSpan: number,
25561 ariaSelected: booleanish,
25562 ariaSetSize: number,
25563 ariaSort: null,
25564 ariaValueMax: number,
25565 ariaValueMin: number,
25566 ariaValueNow: number,
25567 ariaValueText: null,
25568 role: null
25569 }
25570 });
25571 }));
25572
25573 //#endregion
25574 //#region node_modules/property-information/lib/html.js
25575 var html$1;
25576 var init_html = __esmMin((() => {
25577 init_types();
25578 init_create();
25579 init_case_insensitive_transform();
25580 html$1 = create({
25581 space: "html",
25582 attributes: {
25583 acceptcharset: "accept-charset",
25584 classname: "class",
25585 htmlfor: "for",
25586 httpequiv: "http-equiv"
25587 },
25588 transform: caseInsensitiveTransform,
25589 mustUseProperty: [
25590 "checked",
25591 "multiple",
25592 "muted",
25593 "selected"
25594 ],
25595 properties: {
25596 abbr: null,
25597 accept: commaSeparated,
25598 acceptCharset: spaceSeparated,
25599 accessKey: spaceSeparated,
25600 action: null,
25601 allow: null,
25602 allowFullScreen: boolean,
25603 allowPaymentRequest: boolean,
25604 allowUserMedia: boolean,
25605 alt: null,
25606 as: null,
25607 async: boolean,
25608 autoCapitalize: null,
25609 autoComplete: spaceSeparated,
25610 autoFocus: boolean,
25611 autoPlay: boolean,
25612 blocking: spaceSeparated,
25613 capture: null,
25614 charSet: null,
25615 checked: boolean,
25616 cite: null,
25617 className: spaceSeparated,
25618 cols: number,
25619 colSpan: null,
25620 content: null,
25621 contentEditable: booleanish,
25622 controls: boolean,
25623 controlsList: spaceSeparated,
25624 coords: number | commaSeparated,
25625 crossOrigin: null,
25626 data: null,
25627 dateTime: null,
25628 decoding: null,
25629 default: boolean,
25630 defer: boolean,
25631 dir: null,
25632 dirName: null,
25633 disabled: boolean,
25634 download: overloadedBoolean,
25635 draggable: booleanish,
25636 encType: null,
25637 enterKeyHint: null,
25638 fetchPriority: null,
25639 form: null,
25640 formAction: null,
25641 formEncType: null,
25642 formMethod: null,
25643 formNoValidate: boolean,
25644 formTarget: null,
25645 headers: spaceSeparated,
25646 height: number,
25647 hidden: boolean,
25648 high: number,
25649 href: null,
25650 hrefLang: null,
25651 htmlFor: spaceSeparated,
25652 httpEquiv: spaceSeparated,
25653 id: null,
25654 imageSizes: null,
25655 imageSrcSet: null,
25656 inert: boolean,
25657 inputMode: null,
25658 integrity: null,
25659 is: null,
25660 isMap: boolean,
25661 itemId: null,
25662 itemProp: spaceSeparated,
25663 itemRef: spaceSeparated,
25664 itemScope: boolean,
25665 itemType: spaceSeparated,
25666 kind: null,
25667 label: null,
25668 lang: null,
25669 language: null,
25670 list: null,
25671 loading: null,
25672 loop: boolean,
25673 low: number,
25674 manifest: null,
25675 max: null,
25676 maxLength: number,
25677 media: null,
25678 method: null,
25679 min: null,
25680 minLength: number,
25681 multiple: boolean,
25682 muted: boolean,
25683 name: null,
25684 nonce: null,
25685 noModule: boolean,
25686 noValidate: boolean,
25687 onAbort: null,
25688 onAfterPrint: null,
25689 onAuxClick: null,
25690 onBeforeMatch: null,
25691 onBeforePrint: null,
25692 onBeforeToggle: null,
25693 onBeforeUnload: null,
25694 onBlur: null,
25695 onCancel: null,
25696 onCanPlay: null,
25697 onCanPlayThrough: null,
25698 onChange: null,
25699 onClick: null,
25700 onClose: null,
25701 onContextLost: null,
25702 onContextMenu: null,
25703 onContextRestored: null,
25704 onCopy: null,
25705 onCueChange: null,
25706 onCut: null,
25707 onDblClick: null,
25708 onDrag: null,
25709 onDragEnd: null,
25710 onDragEnter: null,
25711 onDragExit: null,
25712 onDragLeave: null,
25713 onDragOver: null,
25714 onDragStart: null,
25715 onDrop: null,
25716 onDurationChange: null,
25717 onEmptied: null,
25718 onEnded: null,
25719 onError: null,
25720 onFocus: null,
25721 onFormData: null,
25722 onHashChange: null,
25723 onInput: null,
25724 onInvalid: null,
25725 onKeyDown: null,
25726 onKeyPress: null,
25727 onKeyUp: null,
25728 onLanguageChange: null,
25729 onLoad: null,
25730 onLoadedData: null,
25731 onLoadedMetadata: null,
25732 onLoadEnd: null,
25733 onLoadStart: null,
25734 onMessage: null,
25735 onMessageError: null,
25736 onMouseDown: null,
25737 onMouseEnter: null,
25738 onMouseLeave: null,
25739 onMouseMove: null,
25740 onMouseOut: null,
25741 onMouseOver: null,
25742 onMouseUp: null,
25743 onOffline: null,
25744 onOnline: null,
25745 onPageHide: null,
25746 onPageShow: null,
25747 onPaste: null,
25748 onPause: null,
25749 onPlay: null,
25750 onPlaying: null,
25751 onPopState: null,
25752 onProgress: null,
25753 onRateChange: null,
25754 onRejectionHandled: null,
25755 onReset: null,
25756 onResize: null,
25757 onScroll: null,
25758 onScrollEnd: null,
25759 onSecurityPolicyViolation: null,
25760 onSeeked: null,
25761 onSeeking: null,
25762 onSelect: null,
25763 onSlotChange: null,
25764 onStalled: null,
25765 onStorage: null,
25766 onSubmit: null,
25767 onSuspend: null,
25768 onTimeUpdate: null,
25769 onToggle: null,
25770 onUnhandledRejection: null,
25771 onUnload: null,
25772 onVolumeChange: null,
25773 onWaiting: null,
25774 onWheel: null,
25775 open: boolean,
25776 optimum: number,
25777 pattern: null,
25778 ping: spaceSeparated,
25779 placeholder: null,
25780 playsInline: boolean,
25781 popover: null,
25782 popoverTarget: null,
25783 popoverTargetAction: null,
25784 poster: null,
25785 preload: null,
25786 readOnly: boolean,
25787 referrerPolicy: null,
25788 rel: spaceSeparated,
25789 required: boolean,
25790 reversed: boolean,
25791 rows: number,
25792 rowSpan: number,
25793 sandbox: spaceSeparated,
25794 scope: null,
25795 scoped: boolean,
25796 seamless: boolean,
25797 selected: boolean,
25798 shadowRootClonable: boolean,
25799 shadowRootDelegatesFocus: boolean,
25800 shadowRootMode: null,
25801 shape: null,
25802 size: number,
25803 sizes: null,
25804 slot: null,
25805 span: number,
25806 spellCheck: booleanish,
25807 src: null,
25808 srcDoc: null,
25809 srcLang: null,
25810 srcSet: null,
25811 start: number,
25812 step: null,
25813 style: null,
25814 tabIndex: number,
25815 target: null,
25816 title: null,
25817 translate: null,
25818 type: null,
25819 typeMustMatch: boolean,
25820 useMap: null,
25821 value: booleanish,
25822 width: number,
25823 wrap: null,
25824 writingSuggestions: null,
25825 align: null,
25826 aLink: null,
25827 archive: spaceSeparated,
25828 axis: null,
25829 background: null,
25830 bgColor: null,
25831 border: number,
25832 borderColor: null,
25833 bottomMargin: number,
25834 cellPadding: null,
25835 cellSpacing: null,
25836 char: null,
25837 charOff: null,
25838 classId: null,
25839 clear: null,
25840 code: null,
25841 codeBase: null,
25842 codeType: null,
25843 color: null,
25844 compact: boolean,
25845 declare: boolean,
25846 event: null,
25847 face: null,
25848 frame: null,
25849 frameBorder: null,
25850 hSpace: number,
25851 leftMargin: number,
25852 link: null,
25853 longDesc: null,
25854 lowSrc: null,
25855 marginHeight: number,
25856 marginWidth: number,
25857 noResize: boolean,
25858 noHref: boolean,
25859 noShade: boolean,
25860 noWrap: boolean,
25861 object: null,
25862 profile: null,
25863 prompt: null,
25864 rev: null,
25865 rightMargin: number,
25866 rules: null,
25867 scheme: null,
25868 scrolling: booleanish,
25869 standby: null,
25870 summary: null,
25871 text: null,
25872 topMargin: number,
25873 valueType: null,
25874 version: null,
25875 vAlign: null,
25876 vLink: null,
25877 vSpace: number,
25878 allowTransparency: null,
25879 autoCorrect: null,
25880 autoSave: null,
25881 disablePictureInPicture: boolean,
25882 disableRemotePlayback: boolean,
25883 prefix: null,
25884 property: null,
25885 results: number,
25886 security: null,
25887 unselectable: null
25888 }
25889 });
25890 }));
25891
25892 //#endregion
25893 //#region node_modules/property-information/lib/svg.js
25894 var svg$1;
25895 var init_svg = __esmMin((() => {
25896 init_types();
25897 init_create();
25898 init_case_sensitive_transform();
25899 svg$1 = create({
25900 space: "svg",
25901 attributes: {
25902 accentHeight: "accent-height",
25903 alignmentBaseline: "alignment-baseline",
25904 arabicForm: "arabic-form",
25905 baselineShift: "baseline-shift",
25906 capHeight: "cap-height",
25907 className: "class",
25908 clipPath: "clip-path",
25909 clipRule: "clip-rule",
25910 colorInterpolation: "color-interpolation",
25911 colorInterpolationFilters: "color-interpolation-filters",
25912 colorProfile: "color-profile",
25913 colorRendering: "color-rendering",
25914 crossOrigin: "crossorigin",
25915 dataType: "datatype",
25916 dominantBaseline: "dominant-baseline",
25917 enableBackground: "enable-background",
25918 fillOpacity: "fill-opacity",
25919 fillRule: "fill-rule",
25920 floodColor: "flood-color",
25921 floodOpacity: "flood-opacity",
25922 fontFamily: "font-family",
25923 fontSize: "font-size",
25924 fontSizeAdjust: "font-size-adjust",
25925 fontStretch: "font-stretch",
25926 fontStyle: "font-style",
25927 fontVariant: "font-variant",
25928 fontWeight: "font-weight",
25929 glyphName: "glyph-name",
25930 glyphOrientationHorizontal: "glyph-orientation-horizontal",
25931 glyphOrientationVertical: "glyph-orientation-vertical",
25932 hrefLang: "hreflang",
25933 horizAdvX: "horiz-adv-x",
25934 horizOriginX: "horiz-origin-x",
25935 horizOriginY: "horiz-origin-y",
25936 imageRendering: "image-rendering",
25937 letterSpacing: "letter-spacing",
25938 lightingColor: "lighting-color",
25939 markerEnd: "marker-end",
25940 markerMid: "marker-mid",
25941 markerStart: "marker-start",
25942 navDown: "nav-down",
25943 navDownLeft: "nav-down-left",
25944 navDownRight: "nav-down-right",
25945 navLeft: "nav-left",
25946 navNext: "nav-next",
25947 navPrev: "nav-prev",
25948 navRight: "nav-right",
25949 navUp: "nav-up",
25950 navUpLeft: "nav-up-left",
25951 navUpRight: "nav-up-right",
25952 onAbort: "onabort",
25953 onActivate: "onactivate",
25954 onAfterPrint: "onafterprint",
25955 onBeforePrint: "onbeforeprint",
25956 onBegin: "onbegin",
25957 onCancel: "oncancel",
25958 onCanPlay: "oncanplay",
25959 onCanPlayThrough: "oncanplaythrough",
25960 onChange: "onchange",
25961 onClick: "onclick",
25962 onClose: "onclose",
25963 onCopy: "oncopy",
25964 onCueChange: "oncuechange",
25965 onCut: "oncut",
25966 onDblClick: "ondblclick",
25967 onDrag: "ondrag",
25968 onDragEnd: "ondragend",
25969 onDragEnter: "ondragenter",
25970 onDragExit: "ondragexit",
25971 onDragLeave: "ondragleave",
25972 onDragOver: "ondragover",
25973 onDragStart: "ondragstart",
25974 onDrop: "ondrop",
25975 onDurationChange: "ondurationchange",
25976 onEmptied: "onemptied",
25977 onEnd: "onend",
25978 onEnded: "onended",
25979 onError: "onerror",
25980 onFocus: "onfocus",
25981 onFocusIn: "onfocusin",
25982 onFocusOut: "onfocusout",
25983 onHashChange: "onhashchange",
25984 onInput: "oninput",
25985 onInvalid: "oninvalid",
25986 onKeyDown: "onkeydown",
25987 onKeyPress: "onkeypress",
25988 onKeyUp: "onkeyup",
25989 onLoad: "onload",
25990 onLoadedData: "onloadeddata",
25991 onLoadedMetadata: "onloadedmetadata",
25992 onLoadStart: "onloadstart",
25993 onMessage: "onmessage",
25994 onMouseDown: "onmousedown",
25995 onMouseEnter: "onmouseenter",
25996 onMouseLeave: "onmouseleave",
25997 onMouseMove: "onmousemove",
25998 onMouseOut: "onmouseout",
25999 onMouseOver: "onmouseover",
26000 onMouseUp: "onmouseup",
26001 onMouseWheel: "onmousewheel",
26002 onOffline: "onoffline",
26003 onOnline: "ononline",
26004 onPageHide: "onpagehide",
26005 onPageShow: "onpageshow",
26006 onPaste: "onpaste",
26007 onPause: "onpause",
26008 onPlay: "onplay",
26009 onPlaying: "onplaying",
26010 onPopState: "onpopstate",
26011 onProgress: "onprogress",
26012 onRateChange: "onratechange",
26013 onRepeat: "onrepeat",
26014 onReset: "onreset",
26015 onResize: "onresize",
26016 onScroll: "onscroll",
26017 onSeeked: "onseeked",
26018 onSeeking: "onseeking",
26019 onSelect: "onselect",
26020 onShow: "onshow",
26021 onStalled: "onstalled",
26022 onStorage: "onstorage",
26023 onSubmit: "onsubmit",
26024 onSuspend: "onsuspend",
26025 onTimeUpdate: "ontimeupdate",
26026 onToggle: "ontoggle",
26027 onUnload: "onunload",
26028 onVolumeChange: "onvolumechange",
26029 onWaiting: "onwaiting",
26030 onZoom: "onzoom",
26031 overlinePosition: "overline-position",
26032 overlineThickness: "overline-thickness",
26033 paintOrder: "paint-order",
26034 panose1: "panose-1",
26035 pointerEvents: "pointer-events",
26036 referrerPolicy: "referrerpolicy",
26037 renderingIntent: "rendering-intent",
26038 shapeRendering: "shape-rendering",
26039 stopColor: "stop-color",
26040 stopOpacity: "stop-opacity",
26041 strikethroughPosition: "strikethrough-position",
26042 strikethroughThickness: "strikethrough-thickness",
26043 strokeDashArray: "stroke-dasharray",
26044 strokeDashOffset: "stroke-dashoffset",
26045 strokeLineCap: "stroke-linecap",
26046 strokeLineJoin: "stroke-linejoin",
26047 strokeMiterLimit: "stroke-miterlimit",
26048 strokeOpacity: "stroke-opacity",
26049 strokeWidth: "stroke-width",
26050 tabIndex: "tabindex",
26051 textAnchor: "text-anchor",
26052 textDecoration: "text-decoration",
26053 textRendering: "text-rendering",
26054 transformOrigin: "transform-origin",
26055 typeOf: "typeof",
26056 underlinePosition: "underline-position",
26057 underlineThickness: "underline-thickness",
26058 unicodeBidi: "unicode-bidi",
26059 unicodeRange: "unicode-range",
26060 unitsPerEm: "units-per-em",
26061 vAlphabetic: "v-alphabetic",
26062 vHanging: "v-hanging",
26063 vIdeographic: "v-ideographic",
26064 vMathematical: "v-mathematical",
26065 vectorEffect: "vector-effect",
26066 vertAdvY: "vert-adv-y",
26067 vertOriginX: "vert-origin-x",
26068 vertOriginY: "vert-origin-y",
26069 wordSpacing: "word-spacing",
26070 writingMode: "writing-mode",
26071 xHeight: "x-height",
26072 playbackOrder: "playbackorder",
26073 timelineBegin: "timelinebegin"
26074 },
26075 transform: caseSensitiveTransform,
26076 properties: {
26077 about: commaOrSpaceSeparated,
26078 accentHeight: number,
26079 accumulate: null,
26080 additive: null,
26081 alignmentBaseline: null,
26082 alphabetic: number,
26083 amplitude: number,
26084 arabicForm: null,
26085 ascent: number,
26086 attributeName: null,
26087 attributeType: null,
26088 azimuth: number,
26089 bandwidth: null,
26090 baselineShift: null,
26091 baseFrequency: null,
26092 baseProfile: null,
26093 bbox: null,
26094 begin: null,
26095 bias: number,
26096 by: null,
26097 calcMode: null,
26098 capHeight: number,
26099 className: spaceSeparated,
26100 clip: null,
26101 clipPath: null,
26102 clipPathUnits: null,
26103 clipRule: null,
26104 color: null,
26105 colorInterpolation: null,
26106 colorInterpolationFilters: null,
26107 colorProfile: null,
26108 colorRendering: null,
26109 content: null,
26110 contentScriptType: null,
26111 contentStyleType: null,
26112 crossOrigin: null,
26113 cursor: null,
26114 cx: null,
26115 cy: null,
26116 d: null,
26117 dataType: null,
26118 defaultAction: null,
26119 descent: number,
26120 diffuseConstant: number,
26121 direction: null,
26122 display: null,
26123 dur: null,
26124 divisor: number,
26125 dominantBaseline: null,
26126 download: boolean,
26127 dx: null,
26128 dy: null,
26129 edgeMode: null,
26130 editable: null,
26131 elevation: number,
26132 enableBackground: null,
26133 end: null,
26134 event: null,
26135 exponent: number,
26136 externalResourcesRequired: null,
26137 fill: null,
26138 fillOpacity: number,
26139 fillRule: null,
26140 filter: null,
26141 filterRes: null,
26142 filterUnits: null,
26143 floodColor: null,
26144 floodOpacity: null,
26145 focusable: null,
26146 focusHighlight: null,
26147 fontFamily: null,
26148 fontSize: null,
26149 fontSizeAdjust: null,
26150 fontStretch: null,
26151 fontStyle: null,
26152 fontVariant: null,
26153 fontWeight: null,
26154 format: null,
26155 fr: null,
26156 from: null,
26157 fx: null,
26158 fy: null,
26159 g1: commaSeparated,
26160 g2: commaSeparated,
26161 glyphName: commaSeparated,
26162 glyphOrientationHorizontal: null,
26163 glyphOrientationVertical: null,
26164 glyphRef: null,
26165 gradientTransform: null,
26166 gradientUnits: null,
26167 handler: null,
26168 hanging: number,
26169 hatchContentUnits: null,
26170 hatchUnits: null,
26171 height: null,
26172 href: null,
26173 hrefLang: null,
26174 horizAdvX: number,
26175 horizOriginX: number,
26176 horizOriginY: number,
26177 id: null,
26178 ideographic: number,
26179 imageRendering: null,
26180 initialVisibility: null,
26181 in: null,
26182 in2: null,
26183 intercept: number,
26184 k: number,
26185 k1: number,
26186 k2: number,
26187 k3: number,
26188 k4: number,
26189 kernelMatrix: commaOrSpaceSeparated,
26190 kernelUnitLength: null,
26191 keyPoints: null,
26192 keySplines: null,
26193 keyTimes: null,
26194 kerning: null,
26195 lang: null,
26196 lengthAdjust: null,
26197 letterSpacing: null,
26198 lightingColor: null,
26199 limitingConeAngle: number,
26200 local: null,
26201 markerEnd: null,
26202 markerMid: null,
26203 markerStart: null,
26204 markerHeight: null,
26205 markerUnits: null,
26206 markerWidth: null,
26207 mask: null,
26208 maskContentUnits: null,
26209 maskUnits: null,
26210 mathematical: null,
26211 max: null,
26212 media: null,
26213 mediaCharacterEncoding: null,
26214 mediaContentEncodings: null,
26215 mediaSize: number,
26216 mediaTime: null,
26217 method: null,
26218 min: null,
26219 mode: null,
26220 name: null,
26221 navDown: null,
26222 navDownLeft: null,
26223 navDownRight: null,
26224 navLeft: null,
26225 navNext: null,
26226 navPrev: null,
26227 navRight: null,
26228 navUp: null,
26229 navUpLeft: null,
26230 navUpRight: null,
26231 numOctaves: null,
26232 observer: null,
26233 offset: null,
26234 onAbort: null,
26235 onActivate: null,
26236 onAfterPrint: null,
26237 onBeforePrint: null,
26238 onBegin: null,
26239 onCancel: null,
26240 onCanPlay: null,
26241 onCanPlayThrough: null,
26242 onChange: null,
26243 onClick: null,
26244 onClose: null,
26245 onCopy: null,
26246 onCueChange: null,
26247 onCut: null,
26248 onDblClick: null,
26249 onDrag: null,
26250 onDragEnd: null,
26251 onDragEnter: null,
26252 onDragExit: null,
26253 onDragLeave: null,
26254 onDragOver: null,
26255 onDragStart: null,
26256 onDrop: null,
26257 onDurationChange: null,
26258 onEmptied: null,
26259 onEnd: null,
26260 onEnded: null,
26261 onError: null,
26262 onFocus: null,
26263 onFocusIn: null,
26264 onFocusOut: null,
26265 onHashChange: null,
26266 onInput: null,
26267 onInvalid: null,
26268 onKeyDown: null,
26269 onKeyPress: null,
26270 onKeyUp: null,
26271 onLoad: null,
26272 onLoadedData: null,
26273 onLoadedMetadata: null,
26274 onLoadStart: null,
26275 onMessage: null,
26276 onMouseDown: null,
26277 onMouseEnter: null,
26278 onMouseLeave: null,
26279 onMouseMove: null,
26280 onMouseOut: null,
26281 onMouseOver: null,
26282 onMouseUp: null,
26283 onMouseWheel: null,
26284 onOffline: null,
26285 onOnline: null,
26286 onPageHide: null,
26287 onPageShow: null,
26288 onPaste: null,
26289 onPause: null,
26290 onPlay: null,
26291 onPlaying: null,
26292 onPopState: null,
26293 onProgress: null,
26294 onRateChange: null,
26295 onRepeat: null,
26296 onReset: null,
26297 onResize: null,
26298 onScroll: null,
26299 onSeeked: null,
26300 onSeeking: null,
26301 onSelect: null,
26302 onShow: null,
26303 onStalled: null,
26304 onStorage: null,
26305 onSubmit: null,
26306 onSuspend: null,
26307 onTimeUpdate: null,
26308 onToggle: null,
26309 onUnload: null,
26310 onVolumeChange: null,
26311 onWaiting: null,
26312 onZoom: null,
26313 opacity: null,
26314 operator: null,
26315 order: null,
26316 orient: null,
26317 orientation: null,
26318 origin: null,
26319 overflow: null,
26320 overlay: null,
26321 overlinePosition: number,
26322 overlineThickness: number,
26323 paintOrder: null,
26324 panose1: null,
26325 path: null,
26326 pathLength: number,
26327 patternContentUnits: null,
26328 patternTransform: null,
26329 patternUnits: null,
26330 phase: null,
26331 ping: spaceSeparated,
26332 pitch: null,
26333 playbackOrder: null,
26334 pointerEvents: null,
26335 points: null,
26336 pointsAtX: number,
26337 pointsAtY: number,
26338 pointsAtZ: number,
26339 preserveAlpha: null,
26340 preserveAspectRatio: null,
26341 primitiveUnits: null,
26342 propagate: null,
26343 property: commaOrSpaceSeparated,
26344 r: null,
26345 radius: null,
26346 referrerPolicy: null,
26347 refX: null,
26348 refY: null,
26349 rel: commaOrSpaceSeparated,
26350 rev: commaOrSpaceSeparated,
26351 renderingIntent: null,
26352 repeatCount: null,
26353 repeatDur: null,
26354 requiredExtensions: commaOrSpaceSeparated,
26355 requiredFeatures: commaOrSpaceSeparated,
26356 requiredFonts: commaOrSpaceSeparated,
26357 requiredFormats: commaOrSpaceSeparated,
26358 resource: null,
26359 restart: null,
26360 result: null,
26361 rotate: null,
26362 rx: null,
26363 ry: null,
26364 scale: null,
26365 seed: null,
26366 shapeRendering: null,
26367 side: null,
26368 slope: null,
26369 snapshotTime: null,
26370 specularConstant: number,
26371 specularExponent: number,
26372 spreadMethod: null,
26373 spacing: null,
26374 startOffset: null,
26375 stdDeviation: null,
26376 stemh: null,
26377 stemv: null,
26378 stitchTiles: null,
26379 stopColor: null,
26380 stopOpacity: null,
26381 strikethroughPosition: number,
26382 strikethroughThickness: number,
26383 string: null,
26384 stroke: null,
26385 strokeDashArray: commaOrSpaceSeparated,
26386 strokeDashOffset: null,
26387 strokeLineCap: null,
26388 strokeLineJoin: null,
26389 strokeMiterLimit: number,
26390 strokeOpacity: number,
26391 strokeWidth: null,
26392 style: null,
26393 surfaceScale: number,
26394 syncBehavior: null,
26395 syncBehaviorDefault: null,
26396 syncMaster: null,
26397 syncTolerance: null,
26398 syncToleranceDefault: null,
26399 systemLanguage: commaOrSpaceSeparated,
26400 tabIndex: number,
26401 tableValues: null,
26402 target: null,
26403 targetX: number,
26404 targetY: number,
26405 textAnchor: null,
26406 textDecoration: null,
26407 textRendering: null,
26408 textLength: null,
26409 timelineBegin: null,
26410 title: null,
26411 transformBehavior: null,
26412 type: null,
26413 typeOf: commaOrSpaceSeparated,
26414 to: null,
26415 transform: null,
26416 transformOrigin: null,
26417 u1: null,
26418 u2: null,
26419 underlinePosition: number,
26420 underlineThickness: number,
26421 unicode: null,
26422 unicodeBidi: null,
26423 unicodeRange: null,
26424 unitsPerEm: number,
26425 values: null,
26426 vAlphabetic: number,
26427 vMathematical: number,
26428 vectorEffect: null,
26429 vHanging: number,
26430 vIdeographic: number,
26431 version: null,
26432 vertAdvY: number,
26433 vertOriginX: number,
26434 vertOriginY: number,
26435 viewBox: null,
26436 viewTarget: null,
26437 visibility: null,
26438 width: null,
26439 widths: null,
26440 wordSpacing: null,
26441 writingMode: null,
26442 x: null,
26443 x1: null,
26444 x2: null,
26445 xChannelSelector: null,
26446 xHeight: number,
26447 y: null,
26448 y1: null,
26449 y2: null,
26450 yChannelSelector: null,
26451 z: null,
26452 zoomAndPan: null
26453 }
26454 });
26455 }));
26456
26457 //#endregion
26458 //#region node_modules/property-information/lib/find.js
26459 /**
26460 * @param {Schema} schema
26461 * @param {string} value
26462 * @returns {Info}
26463 */
26464 function find(schema, value) {
26465 const normal = normalize(value);
26466 let prop = value;
26467 let Type = Info;
26468 if (normal in schema.normal) return schema.property[schema.normal[normal]];
26469 if (normal.length > 4 && normal.slice(0, 4) === "data" && valid.test(value)) {
26470 if (value.charAt(4) === "-") {
26471 const rest = value.slice(5).replace(dash, camelcase);
26472 prop = "data" + rest.charAt(0).toUpperCase() + rest.slice(1);
26473 } else {
26474 const rest = value.slice(4);
26475 if (!dash.test(rest)) {
26476 let dashes = rest.replace(cap, kebab);
26477 if (dashes.charAt(0) !== "-") dashes = "-" + dashes;
26478 value = "data" + dashes;
26479 }
26480 }
26481 Type = DefinedInfo;
26482 }
26483 return new Type(prop, value);
26484 }
26485 /**
26486 * @param {string} $0
26487 * @returns {string}
26488 */
26489 function kebab($0) {
26490 return "-" + $0.toLowerCase();
26491 }
26492 /**
26493 * @param {string} $0
26494 * @returns {string}
26495 */
26496 function camelcase($0) {
26497 return $0.charAt(1).toUpperCase();
26498 }
26499 var valid, dash, cap;
26500 var init_find = __esmMin((() => {
26501 init_normalize();
26502 init_defined_info();
26503 init_info();
26504 valid = /^data[-\w.:]+$/i;
26505 dash = /-[a-z]/g;
26506 cap = /[A-Z]/g;
26507 }));
26508
26509 //#endregion
26510 //#region node_modules/property-information/lib/hast-to-react.js
26511 var hastToReact;
26512 var init_hast_to_react = __esmMin((() => {
26513 hastToReact = {
26514 classId: "classID",
26515 dataType: "datatype",
26516 itemId: "itemID",
26517 strokeDashArray: "strokeDasharray",
26518 strokeDashOffset: "strokeDashoffset",
26519 strokeLineCap: "strokeLinecap",
26520 strokeLineJoin: "strokeLinejoin",
26521 strokeMiterLimit: "strokeMiterlimit",
26522 typeOf: "typeof",
26523 xLinkActuate: "xlinkActuate",
26524 xLinkArcRole: "xlinkArcrole",
26525 xLinkHref: "xlinkHref",
26526 xLinkRole: "xlinkRole",
26527 xLinkShow: "xlinkShow",
26528 xLinkTitle: "xlinkTitle",
26529 xLinkType: "xlinkType",
26530 xmlnsXLink: "xmlnsXlink"
26531 };
26532 }));
26533
26534 //#endregion
26535 //#region node_modules/property-information/index.js
26536 var html, svg;
26537 var init_property_information = __esmMin((() => {
26538 init_merge();
26539 init_xlink();
26540 init_xml();
26541 init_xmlns();
26542 init_aria();
26543 init_html();
26544 init_svg();
26545 init_find();
26546 init_hast_to_react();
26547 init_normalize();
26548 html = merge([
26549 xml,
26550 xlink,
26551 xmlns,
26552 aria,
26553 html$1
26554 ], "html");
26555 svg = merge([
26556 xml,
26557 xlink,
26558 xmlns,
26559 aria,
26560 svg$1
26561 ], "svg");
26562 }));
26563
26564 //#endregion
26565 //#region node_modules/react-markdown/lib/rehype-filter.js
26566 /**
26567 * @typedef {import('unist').Node} Node
26568 * @typedef {import('hast').Root} Root
26569 * @typedef {import('hast').Element} Element
26570 *
26571 * @callback AllowElement
26572 * @param {Element} element
26573 * @param {number} index
26574 * @param {Element|Root} parent
26575 * @returns {boolean|undefined}
26576 *
26577 * @typedef Options
26578 * @property {Array<string>} [allowedElements]
26579 * @property {Array<string>} [disallowedElements=[]]
26580 * @property {AllowElement} [allowElement]
26581 * @property {boolean} [unwrapDisallowed=false]
26582 */
26583 /**
26584 * @type {import('unified').Plugin<[Options], Root>}
26585 */
26586 function rehypeFilter(options) {
26587 if (options.allowedElements && options.disallowedElements) throw new TypeError("Only one of `allowedElements` and `disallowedElements` should be defined");
26588 if (options.allowedElements || options.disallowedElements || options.allowElement) return (tree) => {
26589 visit(tree, "element", (node, index, parent_) => {
26590 const parent = parent_;
26591 /** @type {boolean|undefined} */
26592 let remove;
26593 if (options.allowedElements) remove = !options.allowedElements.includes(node.tagName);
26594 else if (options.disallowedElements) remove = options.disallowedElements.includes(node.tagName);
26595 if (!remove && options.allowElement && typeof index === "number") remove = !options.allowElement(node, index, parent);
26596 if (remove && typeof index === "number") {
26597 if (options.unwrapDisallowed && node.children) parent.children.splice(index, 1, ...node.children);
26598 else parent.children.splice(index, 1);
26599 return index;
26600 }
26601 });
26602 };
26603 }
26604 var init_rehype_filter = __esmMin((() => {
26605 init_unist_util_visit();
26606 }));
26607
26608 //#endregion
26609 //#region node_modules/react-is/cjs/react-is.development.js
26610 /**
26611 * @license React
26612 * react-is.development.js
26613 *
26614 * Copyright (c) Facebook, Inc. and its affiliates.
26615 *
26616 * This source code is licensed under the MIT license found in the
26617 * LICENSE file in the root directory of this source tree.
26618 */
26619 var require_react_is_development = /* @__PURE__ */ __commonJSMin(((exports) => {
26620 (function() {
26621 "use strict";
26622 var REACT_ELEMENT_TYPE = Symbol.for("react.element");
26623 var REACT_PORTAL_TYPE = Symbol.for("react.portal");
26624 var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
26625 var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
26626 var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
26627 var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
26628 var REACT_CONTEXT_TYPE = Symbol.for("react.context");
26629 var REACT_SERVER_CONTEXT_TYPE = Symbol.for("react.server_context");
26630 var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
26631 var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
26632 var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
26633 var REACT_MEMO_TYPE = Symbol.for("react.memo");
26634 var REACT_LAZY_TYPE = Symbol.for("react.lazy");
26635 var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
26636 var enableScopeAPI = false;
26637 var enableCacheElement = false;
26638 var enableTransitionTracing = false;
26639 var enableLegacyHidden = false;
26640 var enableDebugTracing = false;
26641 var REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
26642 function isValidElementType(type) {
26643 if (typeof type === "string" || typeof type === "function") return true;
26644 if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) return true;
26645 if (typeof type === "object" && type !== null) {
26646 if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) return true;
26647 }
26648 return false;
26649 }
26650 function typeOf(object) {
26651 if (typeof object === "object" && object !== null) {
26652 var $$typeof = object.$$typeof;
26653 switch ($$typeof) {
26654 case REACT_ELEMENT_TYPE:
26655 var type = object.type;
26656 switch (type) {
26657 case REACT_FRAGMENT_TYPE:
26658 case REACT_PROFILER_TYPE:
26659 case REACT_STRICT_MODE_TYPE:
26660 case REACT_SUSPENSE_TYPE:
26661 case REACT_SUSPENSE_LIST_TYPE: return type;
26662 default:
26663 var $$typeofType = type && type.$$typeof;
26664 switch ($$typeofType) {
26665 case REACT_SERVER_CONTEXT_TYPE:
26666 case REACT_CONTEXT_TYPE:
26667 case REACT_FORWARD_REF_TYPE:
26668 case REACT_LAZY_TYPE:
26669 case REACT_MEMO_TYPE:
26670 case REACT_PROVIDER_TYPE: return $$typeofType;
26671 default: return $$typeof;
26672 }
26673 }
26674 case REACT_PORTAL_TYPE: return $$typeof;
26675 }
26676 }
26677 }
26678 var ContextConsumer = REACT_CONTEXT_TYPE;
26679 var ContextProvider = REACT_PROVIDER_TYPE;
26680 var Element = REACT_ELEMENT_TYPE;
26681 var ForwardRef = REACT_FORWARD_REF_TYPE;
26682 var Fragment = REACT_FRAGMENT_TYPE;
26683 var Lazy = REACT_LAZY_TYPE;
26684 var Memo = REACT_MEMO_TYPE;
26685 var Portal = REACT_PORTAL_TYPE;
26686 var Profiler = REACT_PROFILER_TYPE;
26687 var StrictMode = REACT_STRICT_MODE_TYPE;
26688 var Suspense = REACT_SUSPENSE_TYPE;
26689 var SuspenseList = REACT_SUSPENSE_LIST_TYPE;
26690 var hasWarnedAboutDeprecatedIsAsyncMode = false;
26691 var hasWarnedAboutDeprecatedIsConcurrentMode = false;
26692 function isAsyncMode(object) {
26693 if (!hasWarnedAboutDeprecatedIsAsyncMode) {
26694 hasWarnedAboutDeprecatedIsAsyncMode = true;
26695 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.");
26696 }
26697 return false;
26698 }
26699 function isConcurrentMode(object) {
26700 if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
26701 hasWarnedAboutDeprecatedIsConcurrentMode = true;
26702 console["warn"]("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.");
26703 }
26704 return false;
26705 }
26706 function isContextConsumer(object) {
26707 return typeOf(object) === REACT_CONTEXT_TYPE;
26708 }
26709 function isContextProvider(object) {
26710 return typeOf(object) === REACT_PROVIDER_TYPE;
26711 }
26712 function isElement(object) {
26713 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
26714 }
26715 function isForwardRef(object) {
26716 return typeOf(object) === REACT_FORWARD_REF_TYPE;
26717 }
26718 function isFragment(object) {
26719 return typeOf(object) === REACT_FRAGMENT_TYPE;
26720 }
26721 function isLazy(object) {
26722 return typeOf(object) === REACT_LAZY_TYPE;
26723 }
26724 function isMemo(object) {
26725 return typeOf(object) === REACT_MEMO_TYPE;
26726 }
26727 function isPortal(object) {
26728 return typeOf(object) === REACT_PORTAL_TYPE;
26729 }
26730 function isProfiler(object) {
26731 return typeOf(object) === REACT_PROFILER_TYPE;
26732 }
26733 function isStrictMode(object) {
26734 return typeOf(object) === REACT_STRICT_MODE_TYPE;
26735 }
26736 function isSuspense(object) {
26737 return typeOf(object) === REACT_SUSPENSE_TYPE;
26738 }
26739 function isSuspenseList(object) {
26740 return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
26741 }
26742 exports.ContextConsumer = ContextConsumer;
26743 exports.ContextProvider = ContextProvider;
26744 exports.Element = Element;
26745 exports.ForwardRef = ForwardRef;
26746 exports.Fragment = Fragment;
26747 exports.Lazy = Lazy;
26748 exports.Memo = Memo;
26749 exports.Portal = Portal;
26750 exports.Profiler = Profiler;
26751 exports.StrictMode = StrictMode;
26752 exports.Suspense = Suspense;
26753 exports.SuspenseList = SuspenseList;
26754 exports.isAsyncMode = isAsyncMode;
26755 exports.isConcurrentMode = isConcurrentMode;
26756 exports.isContextConsumer = isContextConsumer;
26757 exports.isContextProvider = isContextProvider;
26758 exports.isElement = isElement;
26759 exports.isForwardRef = isForwardRef;
26760 exports.isFragment = isFragment;
26761 exports.isLazy = isLazy;
26762 exports.isMemo = isMemo;
26763 exports.isPortal = isPortal;
26764 exports.isProfiler = isProfiler;
26765 exports.isStrictMode = isStrictMode;
26766 exports.isSuspense = isSuspense;
26767 exports.isSuspenseList = isSuspenseList;
26768 exports.isValidElementType = isValidElementType;
26769 exports.typeOf = typeOf;
26770 })();
26771 }));
26772
26773 //#endregion
26774 //#region node_modules/react-is/index.js
26775 var require_react_is = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26776 module.exports = require_react_is_development();
26777 }));
26778
26779 //#endregion
26780 //#region node_modules/hast-util-whitespace/index.js
26781 /**
26782 * Check if the given value is *inter-element whitespace*.
26783 *
26784 * @param {unknown} thing
26785 * Thing to check (typically `Node` or `string`).
26786 * @returns {boolean}
26787 * Whether the `value` is inter-element whitespace (`boolean`): consisting of
26788 * zero or more of space, tab (`\t`), line feed (`\n`), carriage return
26789 * (`\r`), or form feed (`\f`).
26790 * If a node is passed it must be a `Text` node, whose `value` field is
26791 * checked.
26792 */
26793 function whitespace(thing) {
26794 /** @type {string} */
26795 const value = thing && typeof thing === "object" && thing.type === "text" ? thing.value || "" : thing;
26796 return typeof value === "string" && value.replace(/[ \t\n\f\r]/g, "") === "";
26797 }
26798 var init_hast_util_whitespace = __esmMin((() => {}));
26799
26800 //#endregion
26801 //#region node_modules/space-separated-tokens/index.js
26802 /**
26803 * Serialize an array of strings as space separated-tokens.
26804 *
26805 * @param {Array<string|number>} values
26806 * List of tokens.
26807 * @returns {string}
26808 * Space-separated tokens.
26809 */
26810 function stringify$1(values) {
26811 return values.join(" ").trim();
26812 }
26813 var init_space_separated_tokens = __esmMin((() => {
26814 __name(stringify$1, "stringify");
26815 }));
26816
26817 //#endregion
26818 //#region node_modules/comma-separated-tokens/index.js
26819 /**
26820 * Serialize an array of strings or numbers to comma-separated tokens.
26821 *
26822 * @param {Array<string|number>} values
26823 * List of tokens.
26824 * @param {Options} [options]
26825 * Configuration for `stringify` (optional).
26826 * @returns {string}
26827 * Comma-separated tokens.
26828 */
26829 function stringify(values, options) {
26830 const settings = options || {};
26831 return (values[values.length - 1] === "" ? [...values, ""] : values).join((settings.padRight ? " " : "") + "," + (settings.padLeft === false ? "" : " ")).trim();
26832 }
26833 var init_comma_separated_tokens = __esmMin((() => {}));
26834
26835 //#endregion
26836 //#region node_modules/inline-style-parser/index.js
26837 var require_inline_style_parser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
26838 var COMMENT_REGEX = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
26839 var NEWLINE_REGEX = /\n/g;
26840 var WHITESPACE_REGEX = /^\s*/;
26841 var PROPERTY_REGEX = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/;
26842 var COLON_REGEX = /^:\s*/;
26843 var VALUE_REGEX = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/;
26844 var SEMICOLON_REGEX = /^[;\s]*/;
26845 var TRIM_REGEX = /^\s+|\s+$/g;
26846 var NEWLINE = "\n";
26847 var FORWARD_SLASH = "/";
26848 var ASTERISK = "*";
26849 var EMPTY_STRING = "";
26850 var TYPE_COMMENT = "comment";
26851 var TYPE_DECLARATION = "declaration";
26852 /**
26853 * @param {String} style
26854 * @param {Object} [options]
26855 * @return {Object[]}
26856 * @throws {TypeError}
26857 * @throws {Error}
26858 */
26859 module.exports = function(style, options) {
26860 if (typeof style !== "string") throw new TypeError("First argument must be a string");
26861 if (!style) return [];
26862 options = options || {};
26863 /**
26864 * Positional.
26865 */
26866 var lineno = 1;
26867 var column = 1;
26868 /**
26869 * Update lineno and column based on `str`.
26870 *
26871 * @param {String} str
26872 */
26873 function updatePosition(str) {
26874 var lines = str.match(NEWLINE_REGEX);
26875 if (lines) lineno += lines.length;
26876 var i = str.lastIndexOf(NEWLINE);
26877 column = ~i ? str.length - i : column + str.length;
26878 }
26879 /**
26880 * Mark position and patch `node.position`.
26881 *
26882 * @return {Function}
26883 */
26884 function position() {
26885 var start = {
26886 line: lineno,
26887 column
26888 };
26889 return function(node) {
26890 node.position = new Position(start);
26891 whitespace();
26892 return node;
26893 };
26894 }
26895 /**
26896 * Store position information for a node.
26897 *
26898 * @constructor
26899 * @property {Object} start
26900 * @property {Object} end
26901 * @property {undefined|String} source
26902 */
26903 function Position(start) {
26904 this.start = start;
26905 this.end = {
26906 line: lineno,
26907 column
26908 };
26909 this.source = options.source;
26910 }
26911 /**
26912 * Non-enumerable source string.
26913 */
26914 Position.prototype.content = style;
26915 var errorsList = [];
26916 /**
26917 * Error `msg`.
26918 *
26919 * @param {String} msg
26920 * @throws {Error}
26921 */
26922 function error(msg) {
26923 var err = /* @__PURE__ */ new Error(options.source + ":" + lineno + ":" + column + ": " + msg);
26924 err.reason = msg;
26925 err.filename = options.source;
26926 err.line = lineno;
26927 err.column = column;
26928 err.source = style;
26929 if (options.silent) errorsList.push(err);
26930 else throw err;
26931 }
26932 /**
26933 * Match `re` and return captures.
26934 *
26935 * @param {RegExp} re
26936 * @return {undefined|Array}
26937 */
26938 function match(re) {
26939 var m = re.exec(style);
26940 if (!m) return;
26941 var str = m[0];
26942 updatePosition(str);
26943 style = style.slice(str.length);
26944 return m;
26945 }
26946 /**
26947 * Parse whitespace.
26948 */
26949 function whitespace() {
26950 match(WHITESPACE_REGEX);
26951 }
26952 /**
26953 * Parse comments.
26954 *
26955 * @param {Object[]} [rules]
26956 * @return {Object[]}
26957 */
26958 function comments(rules) {
26959 var c;
26960 rules = rules || [];
26961 while (c = comment()) if (c !== false) rules.push(c);
26962 return rules;
26963 }
26964 /**
26965 * Parse comment.
26966 *
26967 * @return {Object}
26968 * @throws {Error}
26969 */
26970 function comment() {
26971 var pos = position();
26972 if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
26973 var i = 2;
26974 while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) ++i;
26975 i += 2;
26976 if (EMPTY_STRING === style.charAt(i - 1)) return error("End of comment missing");
26977 var str = style.slice(2, i - 2);
26978 column += 2;
26979 updatePosition(str);
26980 style = style.slice(i);
26981 column += 2;
26982 return pos({
26983 type: TYPE_COMMENT,
26984 comment: str
26985 });
26986 }
26987 /**
26988 * Parse declaration.
26989 *
26990 * @return {Object}
26991 * @throws {Error}
26992 */
26993 function declaration() {
26994 var pos = position();
26995 var prop = match(PROPERTY_REGEX);
26996 if (!prop) return;
26997 comment();
26998 if (!match(COLON_REGEX)) return error("property missing ':'");
26999 var val = match(VALUE_REGEX);
27000 var ret = pos({
27001 type: TYPE_DECLARATION,
27002 property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
27003 value: val ? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING)) : EMPTY_STRING
27004 });
27005 match(SEMICOLON_REGEX);
27006 return ret;
27007 }
27008 /**
27009 * Parse declarations.
27010 *
27011 * @return {Object[]}
27012 */
27013 function declarations() {
27014 var decls = [];
27015 comments(decls);
27016 var decl;
27017 while (decl = declaration()) if (decl !== false) {
27018 decls.push(decl);
27019 comments(decls);
27020 }
27021 return decls;
27022 }
27023 whitespace();
27024 return declarations();
27025 };
27026 /**
27027 * Trim `str`.
27028 *
27029 * @param {String} str
27030 * @return {String}
27031 */
27032 function trim(str) {
27033 return str ? str.replace(TRIM_REGEX, EMPTY_STRING) : EMPTY_STRING;
27034 }
27035 }));
27036
27037 //#endregion
27038 //#region node_modules/style-to-object/index.js
27039 var require_style_to_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
27040 var parse = require_inline_style_parser();
27041 /**
27042 * Parses inline style to object.
27043 *
27044 * @example
27045 * // returns { 'line-height': '42' }
27046 * StyleToObject('line-height: 42;');
27047 *
27048 * @param {String} style - The inline style.
27049 * @param {Function} [iterator] - The iterator function.
27050 * @return {null|Object}
27051 */
27052 function StyleToObject(style, iterator) {
27053 var output = null;
27054 if (!style || typeof style !== "string") return output;
27055 var declaration;
27056 var declarations = parse(style);
27057 var hasIterator = typeof iterator === "function";
27058 var property;
27059 var value;
27060 for (var i = 0, len = declarations.length; i < len; i++) {
27061 declaration = declarations[i];
27062 property = declaration.property;
27063 value = declaration.value;
27064 if (hasIterator) iterator(property, value, declaration);
27065 else if (value) {
27066 output || (output = {});
27067 output[property] = value;
27068 }
27069 }
27070 return output;
27071 }
27072 module.exports = StyleToObject;
27073 module.exports.default = StyleToObject;
27074 }));
27075
27076 //#endregion
27077 //#region node_modules/style-to-object/index.mjs
27078 var import_style_to_object, style_to_object_default;
27079 var init_style_to_object = __esmMin((() => {
27080 import_style_to_object = /* @__PURE__ */ __toESM(require_style_to_object(), 1);
27081 style_to_object_default = import_style_to_object.default;
27082 }));
27083
27084 //#endregion
27085 //#region node_modules/react-markdown/lib/ast-to-react.js
27086 /**
27087 * @template T
27088 * @typedef {Promise.resolve(React).ComponentType<T>} ComponentType<T>
27089 */
27090 /**
27091 * @template {Promise.resolve(React).ElementType} T
27092 * @typedef {Promise.resolve(React).ComponentPropsWithoutRef<T>} ComponentPropsWithoutRef<T>
27093 */
27094 /**
27095 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27096 * @typedef {import('unist').Position} Position
27097 * @typedef {import('hast').Element} Element
27098 * @typedef {import('hast').ElementContent} ElementContent
27099 * @typedef {import('hast').Root} Root
27100 * @typedef {import('hast').Text} Text
27101 * @typedef {import('hast').Comment} Comment
27102 * @typedef {import('hast').DocType} Doctype
27103 * @typedef {import('property-information').Info} Info
27104 * @typedef {import('property-information').Schema} Schema
27105 * @typedef {import('./complex-types.js').ReactMarkdownProps} ReactMarkdownProps
27106 *
27107 * @typedef Raw
27108 * @property {'raw'} type
27109 * @property {string} value
27110 *
27111 * @typedef Context
27112 * @property {Options} options
27113 * @property {Schema} schema
27114 * @property {number} listDepth
27115 *
27116 * @callback TransformLink
27117 * @param {string} href
27118 * @param {Array<ElementContent>} children
27119 * @param {string?} title
27120 * @returns {string}
27121 *
27122 * @callback TransformImage
27123 * @param {string} src
27124 * @param {string} alt
27125 * @param {string?} title
27126 * @returns {string}
27127 *
27128 * @typedef {Promise.resolve(React).HTMLAttributeAnchorTarget} TransformLinkTargetType
27129 *
27130 * @callback TransformLinkTarget
27131 * @param {string} href
27132 * @param {Array<ElementContent>} children
27133 * @param {string?} title
27134 * @returns {TransformLinkTargetType|undefined}
27135 *
27136 * @typedef {keyof JSX.IntrinsicElements} ReactMarkdownNames
27137 *
27138 * To do: is `data-sourcepos` typeable?
27139 *
27140 * @typedef {ComponentPropsWithoutRef<'code'> & ReactMarkdownProps & {inline?: boolean}} CodeProps
27141 * @typedef {ComponentPropsWithoutRef<'h1'> & ReactMarkdownProps & {level: number}} HeadingProps
27142 * @typedef {ComponentPropsWithoutRef<'li'> & ReactMarkdownProps & {checked: boolean|null, index: number, ordered: boolean}} LiProps
27143 * @typedef {ComponentPropsWithoutRef<'ol'> & ReactMarkdownProps & {depth: number, ordered: true}} OrderedListProps
27144 * @typedef {ComponentPropsWithoutRef<'td'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: false}} TableDataCellProps
27145 * @typedef {ComponentPropsWithoutRef<'th'> & ReactMarkdownProps & {style?: Record<string, unknown>, isHeader: true}} TableHeaderCellProps
27146 * @typedef {ComponentPropsWithoutRef<'tr'> & ReactMarkdownProps & {isHeader: boolean}} TableRowProps
27147 * @typedef {ComponentPropsWithoutRef<'ul'> & ReactMarkdownProps & {depth: number, ordered: false}} UnorderedListProps
27148 *
27149 * @typedef {ComponentType<CodeProps>} CodeComponent
27150 * @typedef {ComponentType<HeadingProps>} HeadingComponent
27151 * @typedef {ComponentType<LiProps>} LiComponent
27152 * @typedef {ComponentType<OrderedListProps>} OrderedListComponent
27153 * @typedef {ComponentType<TableDataCellProps>} TableDataCellComponent
27154 * @typedef {ComponentType<TableHeaderCellProps>} TableHeaderCellComponent
27155 * @typedef {ComponentType<TableRowProps>} TableRowComponent
27156 * @typedef {ComponentType<UnorderedListProps>} UnorderedListComponent
27157 *
27158 * @typedef SpecialComponents
27159 * @property {CodeComponent|ReactMarkdownNames} code
27160 * @property {HeadingComponent|ReactMarkdownNames} h1
27161 * @property {HeadingComponent|ReactMarkdownNames} h2
27162 * @property {HeadingComponent|ReactMarkdownNames} h3
27163 * @property {HeadingComponent|ReactMarkdownNames} h4
27164 * @property {HeadingComponent|ReactMarkdownNames} h5
27165 * @property {HeadingComponent|ReactMarkdownNames} h6
27166 * @property {LiComponent|ReactMarkdownNames} li
27167 * @property {OrderedListComponent|ReactMarkdownNames} ol
27168 * @property {TableDataCellComponent|ReactMarkdownNames} td
27169 * @property {TableHeaderCellComponent|ReactMarkdownNames} th
27170 * @property {TableRowComponent|ReactMarkdownNames} tr
27171 * @property {UnorderedListComponent|ReactMarkdownNames} ul
27172 *
27173 * @typedef {Partial<Omit<import('./complex-types.js').NormalComponents, keyof SpecialComponents> & SpecialComponents>} Components
27174 *
27175 * @typedef Options
27176 * @property {boolean} [sourcePos=false]
27177 * @property {boolean} [rawSourcePos=false]
27178 * @property {boolean} [skipHtml=false]
27179 * @property {boolean} [includeElementIndex=false]
27180 * @property {null|false|TransformLink} [transformLinkUri]
27181 * @property {TransformImage} [transformImageUri]
27182 * @property {TransformLinkTargetType|TransformLinkTarget} [linkTarget]
27183 * @property {Components} [components]
27184 */
27185 /**
27186 * @param {Context} context
27187 * @param {Element|Root} node
27188 */
27189 function childrenToReact(context, node) {
27190 /** @type {Array<ReactNode>} */
27191 const children = [];
27192 let childIndex = -1;
27193 /** @type {Comment|Doctype|Element|Raw|Text} */
27194 let child;
27195 while (++childIndex < node.children.length) {
27196 child = node.children[childIndex];
27197 if (child.type === "element") children.push(toReact(context, child, childIndex, node));
27198 else if (child.type === "text") {
27199 if (node.type !== "element" || !tableElements.has(node.tagName) || !whitespace(child)) children.push(child.value);
27200 } else if (child.type === "raw" && !context.options.skipHtml) children.push(child.value);
27201 }
27202 return children;
27203 }
27204 /**
27205 * @param {Context} context
27206 * @param {Element} node
27207 * @param {number} index
27208 * @param {Element|Root} parent
27209 */
27210 function toReact(context, node, index, parent) {
27211 const options = context.options;
27212 const transform = options.transformLinkUri === void 0 ? uriTransformer : options.transformLinkUri;
27213 const parentSchema = context.schema;
27214 /** @type {ReactMarkdownNames} */
27215 const name = node.tagName;
27216 /** @type {Record<string, unknown>} */
27217 const properties = {};
27218 let schema = parentSchema;
27219 /** @type {string} */
27220 let property;
27221 if (parentSchema.space === "html" && name === "svg") {
27222 schema = svg;
27223 context.schema = schema;
27224 }
27225 if (node.properties) {
27226 for (property in node.properties) if (own$1.call(node.properties, property)) addProperty(properties, property, node.properties[property], context);
27227 }
27228 if (name === "ol" || name === "ul") context.listDepth++;
27229 const children = childrenToReact(context, node);
27230 if (name === "ol" || name === "ul") context.listDepth--;
27231 context.schema = parentSchema;
27232 const position = node.position || {
27233 start: {
27234 line: null,
27235 column: null,
27236 offset: null
27237 },
27238 end: {
27239 line: null,
27240 column: null,
27241 offset: null
27242 }
27243 };
27244 const component = options.components && own$1.call(options.components, name) ? options.components[name] : name;
27245 const basic = typeof component === "string" || component === react$1.default.Fragment;
27246 if (!import_react_is.isValidElementType(component)) throw new TypeError(`Component for name \`${name}\` not defined or is not renderable`);
27247 properties.key = index;
27248 if (name === "a" && options.linkTarget) properties.target = typeof options.linkTarget === "function" ? options.linkTarget(String(properties.href || ""), node.children, typeof properties.title === "string" ? properties.title : null) : options.linkTarget;
27249 if (name === "a" && transform) properties.href = transform(String(properties.href || ""), node.children, typeof properties.title === "string" ? properties.title : null);
27250 if (!basic && name === "code" && parent.type === "element" && parent.tagName !== "pre") properties.inline = true;
27251 if (!basic && (name === "h1" || name === "h2" || name === "h3" || name === "h4" || name === "h5" || name === "h6")) properties.level = Number.parseInt(name.charAt(1), 10);
27252 if (name === "img" && options.transformImageUri) properties.src = options.transformImageUri(String(properties.src || ""), String(properties.alt || ""), typeof properties.title === "string" ? properties.title : null);
27253 if (!basic && name === "li" && parent.type === "element") {
27254 const input = getInputElement(node);
27255 properties.checked = input && input.properties ? Boolean(input.properties.checked) : null;
27256 properties.index = getElementsBeforeCount(parent, node);
27257 properties.ordered = parent.tagName === "ol";
27258 }
27259 if (!basic && (name === "ol" || name === "ul")) {
27260 properties.ordered = name === "ol";
27261 properties.depth = context.listDepth;
27262 }
27263 if (name === "td" || name === "th") {
27264 if (properties.align) {
27265 if (!properties.style) properties.style = {};
27266 properties.style.textAlign = properties.align;
27267 delete properties.align;
27268 }
27269 if (!basic) properties.isHeader = name === "th";
27270 }
27271 if (!basic && name === "tr" && parent.type === "element") properties.isHeader = Boolean(parent.tagName === "thead");
27272 if (options.sourcePos) properties["data-sourcepos"] = flattenPosition(position);
27273 if (!basic && options.rawSourcePos) properties.sourcePosition = node.position;
27274 if (!basic && options.includeElementIndex) {
27275 properties.index = getElementsBeforeCount(parent, node);
27276 properties.siblingCount = getElementsBeforeCount(parent);
27277 }
27278 if (!basic) properties.node = node;
27279 return children.length > 0 ? react$1.default.createElement(component, properties, children) : react$1.default.createElement(component, properties);
27280 }
27281 /**
27282 * @param {Element|Root} node
27283 * @returns {Element?}
27284 */
27285 function getInputElement(node) {
27286 let index = -1;
27287 while (++index < node.children.length) {
27288 const child = node.children[index];
27289 if (child.type === "element" && child.tagName === "input") return child;
27290 }
27291 return null;
27292 }
27293 /**
27294 * @param {Element|Root} parent
27295 * @param {Element} [node]
27296 * @returns {number}
27297 */
27298 function getElementsBeforeCount(parent, node) {
27299 let index = -1;
27300 let count = 0;
27301 while (++index < parent.children.length) {
27302 if (parent.children[index] === node) break;
27303 if (parent.children[index].type === "element") count++;
27304 }
27305 return count;
27306 }
27307 /**
27308 * @param {Record<string, unknown>} props
27309 * @param {string} prop
27310 * @param {unknown} value
27311 * @param {Context} ctx
27312 */
27313 function addProperty(props, prop, value, ctx) {
27314 const info = find(ctx.schema, prop);
27315 let result = value;
27316 if (result === null || result === void 0 || result !== result) return;
27317 if (Array.isArray(result)) result = info.commaSeparated ? stringify(result) : stringify$1(result);
27318 if (info.property === "style" && typeof result === "string") result = parseStyle(result);
27319 if (info.space && info.property) props[own$1.call(hastToReact, info.property) ? hastToReact[info.property] : info.property] = result;
27320 else if (info.attribute) props[info.attribute] = result;
27321 }
27322 /**
27323 * @param {string} value
27324 * @returns {Record<string, string>}
27325 */
27326 function parseStyle(value) {
27327 /** @type {Record<string, string>} */
27328 const result = {};
27329 try {
27330 style_to_object_default(value, iterator);
27331 } catch (_unused) {}
27332 return result;
27333 /**
27334 * @param {string} name
27335 * @param {string} v
27336 */
27337 function iterator(name, v) {
27338 const k = name.slice(0, 4) === "-ms-" ? `ms-${name.slice(4)}` : name;
27339 result[k.replace(/-([a-z])/g, styleReplacer)] = v;
27340 }
27341 }
27342 /**
27343 * @param {unknown} _
27344 * @param {string} $1
27345 */
27346 function styleReplacer(_, $1) {
27347 return $1.toUpperCase();
27348 }
27349 /**
27350 * @param {Position|{start: {line: null, column: null, offset: null}, end: {line: null, column: null, offset: null}}} pos
27351 * @returns {string}
27352 */
27353 function flattenPosition(pos) {
27354 return [
27355 pos.start.line,
27356 ":",
27357 pos.start.column,
27358 "-",
27359 pos.end.line,
27360 ":",
27361 pos.end.column
27362 ].map(String).join("");
27363 }
27364 var import_react_is, own$1, tableElements;
27365 var init_ast_to_react = __esmMin((() => {
27366 import_react_is = /* @__PURE__ */ __toESM(require_react_is(), 1);
27367 init_hast_util_whitespace();
27368 init_property_information();
27369 init_space_separated_tokens();
27370 init_comma_separated_tokens();
27371 init_style_to_object();
27372 init_uri_transformer();
27373 own$1 = {}.hasOwnProperty;
27374 tableElements = /* @__PURE__ */ new Set([
27375 "table",
27376 "thead",
27377 "tbody",
27378 "tfoot",
27379 "tr"
27380 ]);
27381 }));
27382
27383 //#endregion
27384 //#region node_modules/react-markdown/lib/react-markdown.js
27385 /**
27386 * @typedef {Promise.resolve(React).ReactNode} ReactNode
27387 * @typedef {Promise.resolve(React).ReactElement<{}>} ReactElement
27388 * @typedef {import('unified').PluggableList} PluggableList
27389 * @typedef {import('hast').Root} Root
27390 * @typedef {import('./rehype-filter.js').Options} FilterOptions
27391 * @typedef {import('./ast-to-react.js').Options} TransformOptions
27392 *
27393 * @typedef CoreOptions
27394 * @property {string} children
27395 *
27396 * @typedef PluginOptions
27397 * @property {PluggableList} [remarkPlugins=[]]
27398 * @property {PluggableList} [rehypePlugins=[]]
27399 * @property {import('remark-rehype').Options | undefined} [remarkRehypeOptions={}]
27400 *
27401 * @typedef LayoutOptions
27402 * @property {string} [className]
27403 *
27404 * @typedef {CoreOptions & PluginOptions & LayoutOptions & FilterOptions & TransformOptions} ReactMarkdownOptions
27405 *
27406 * @typedef Deprecation
27407 * @property {string} id
27408 * @property {string} [to]
27409 */
27410 /**
27411 * React component to render markdown.
27412 *
27413 * @param {ReactMarkdownOptions} options
27414 * @returns {ReactElement}
27415 */
27416 function ReactMarkdown$1(options) {
27417 for (const key in deprecated) if (own.call(deprecated, key) && own.call(options, key)) {
27418 const deprecation = deprecated[key];
27419 console.warn(`[react-markdown] Warning: please ${deprecation.to ? `use \`${deprecation.to}\` instead of` : "remove"} \`${key}\` (see <${changelog}#${deprecation.id}> for more info)`);
27420 delete deprecated[key];
27421 }
27422 const processor = unified().use(remarkParse).use(options.remarkPlugins || []).use(remarkRehype, _objectSpread2(_objectSpread2({}, options.remarkRehypeOptions), {}, { allowDangerousHtml: true })).use(options.rehypePlugins || []).use(rehypeFilter, options);
27423 const file = new VFile();
27424 if (typeof options.children === "string") file.value = options.children;
27425 else if (options.children !== void 0 && options.children !== null) console.warn(`[react-markdown] Warning: please pass a string as \`children\` (not: \`${options.children}\`)`);
27426 const hastNode = processor.runSync(processor.parse(file), file);
27427 if (hastNode.type !== "root") throw new TypeError("Expected a `root` node");
27428 /** @type {ReactElement} */
27429 let result = react$1.default.createElement(react$1.default.Fragment, {}, childrenToReact({
27430 options,
27431 schema: html,
27432 listDepth: 0
27433 }, hastNode));
27434 if (options.className) result = react$1.default.createElement("div", { className: options.className }, result);
27435 return result;
27436 }
27437 var import_prop_types$1, own, changelog, deprecated;
27438 var init_react_markdown$1 = __esmMin((() => {
27439 init_vfile();
27440 init_unified();
27441 init_remark_parse();
27442 init_remark_rehype();
27443 import_prop_types$1 = /* @__PURE__ */ __toESM(require_prop_types(), 1);
27444 init_property_information();
27445 init_rehype_filter();
27446 init_ast_to_react();
27447 init_objectSpread2();
27448 own = {}.hasOwnProperty;
27449 changelog = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md";
27450 deprecated = {
27451 plugins: {
27452 to: "remarkPlugins",
27453 id: "change-plugins-to-remarkplugins"
27454 },
27455 renderers: {
27456 to: "components",
27457 id: "change-renderers-to-components"
27458 },
27459 astPlugins: { id: "remove-buggy-html-in-markdown-parser" },
27460 allowDangerousHtml: { id: "remove-buggy-html-in-markdown-parser" },
27461 escapeHtml: { id: "remove-buggy-html-in-markdown-parser" },
27462 source: {
27463 to: "children",
27464 id: "change-source-to-children"
27465 },
27466 allowNode: {
27467 to: "allowElement",
27468 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27469 },
27470 allowedTypes: {
27471 to: "allowedElements",
27472 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27473 },
27474 disallowedTypes: {
27475 to: "disallowedElements",
27476 id: "replace-allownode-allowedtypes-and-disallowedtypes"
27477 },
27478 includeNodeIndex: {
27479 to: "includeElementIndex",
27480 id: "change-includenodeindex-to-includeelementindex"
27481 }
27482 };
27483 __name(ReactMarkdown$1, "ReactMarkdown");
27484 ReactMarkdown$1.propTypes = {
27485 children: import_prop_types$1.default.string,
27486 className: import_prop_types$1.default.string,
27487 allowElement: import_prop_types$1.default.func,
27488 allowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27489 disallowedElements: import_prop_types$1.default.arrayOf(import_prop_types$1.default.string),
27490 unwrapDisallowed: import_prop_types$1.default.bool,
27491 remarkPlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27492 import_prop_types$1.default.object,
27493 import_prop_types$1.default.func,
27494 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27495 import_prop_types$1.default.bool,
27496 import_prop_types$1.default.string,
27497 import_prop_types$1.default.object,
27498 import_prop_types$1.default.func,
27499 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27500 ]))
27501 ])),
27502 rehypePlugins: import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27503 import_prop_types$1.default.object,
27504 import_prop_types$1.default.func,
27505 import_prop_types$1.default.arrayOf(import_prop_types$1.default.oneOfType([
27506 import_prop_types$1.default.bool,
27507 import_prop_types$1.default.string,
27508 import_prop_types$1.default.object,
27509 import_prop_types$1.default.func,
27510 import_prop_types$1.default.arrayOf(import_prop_types$1.default.any)
27511 ]))
27512 ])),
27513 sourcePos: import_prop_types$1.default.bool,
27514 rawSourcePos: import_prop_types$1.default.bool,
27515 skipHtml: import_prop_types$1.default.bool,
27516 includeElementIndex: import_prop_types$1.default.bool,
27517 transformLinkUri: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.bool]),
27518 linkTarget: import_prop_types$1.default.oneOfType([import_prop_types$1.default.func, import_prop_types$1.default.string]),
27519 transformImageUri: import_prop_types$1.default.func,
27520 components: import_prop_types$1.default.object
27521 };
27522 }));
27523
27524 //#endregion
27525 //#region node_modules/react-markdown/index.js
27526 var react_markdown_exports = /* @__PURE__ */ __exportAll({
27527 default: () => ReactMarkdown$1,
27528 uriTransformer: () => uriTransformer
27529 });
27530 var init_react_markdown = __esmMin((() => {
27531 init_uri_transformer();
27532 init_react_markdown$1();
27533 }));
27534
27535 //#endregion
27536 //#region modules/ai/assets/js/editor/pages/form-code/index.js
27537 var form_code_exports = /* @__PURE__ */ __exportAll({ default: () => FormCode$1 });
27538 function ownKeys$5(e, r) {
27539 var t = Object.keys(e);
27540 if (Object.getOwnPropertySymbols) {
27541 var o = Object.getOwnPropertySymbols(e);
27542 r && (o = o.filter(function(r) {
27543 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27544 })), t.push.apply(t, o);
27545 }
27546 return t;
27547 }
27548 function _objectSpread$5(e) {
27549 for (var r = 1; r < arguments.length; r++) {
27550 var t = null != arguments[r] ? arguments[r] : {};
27551 r % 2 ? ownKeys$5(Object(t), !0).forEach(function(r) {
27552 _defineProperty$1(e, r, t[r]);
27553 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function(r) {
27554 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27555 });
27556 }
27557 return e;
27558 }
27559 var import_regenerator, import_prop_types, ReactMarkdown, generateUniqueId, CodeDisplayWrapper, FormCode$1;
27560 var init_form_code = __esmMin((() => {
27561 init_extends();
27562 init_asyncToGenerator();
27563 init_slicedToArray();
27564 init_defineProperty$1();
27565 import_regenerator = /* @__PURE__ */ __toESM(require_regenerator());
27566 import_prop_types = /* @__PURE__ */ __toESM(require_prop_types());
27567 init_actions_data();
27568 init_loader();
27569 init_prompt_search();
27570 init_prompt_suggestions();
27571 init_generate_button();
27572 init_prompt_error_message();
27573 init_code_block();
27574 init_use_code_prompt();
27575 init_prompt_history_action_context();
27576 init_prompt_library_link();
27577 init_requests_ids();
27578 init_voice_promotion_alert();
27579 init_splitTextResult();
27580 init_preload_helper();
27581 __name(ownKeys$5, "ownKeys");
27582 __name(_objectSpread$5, "_objectSpread");
27583 ReactMarkdown = (0, react.lazy)(function() {
27584 return __vitePreload(() => Promise.resolve().then(() => (init_react_markdown(), react_markdown_exports)), void 0);
27585 });
27586 generateUniqueId = function generateUniqueId() {
27587 return "custom-css-".concat(Math.random().toString(36).substr(2, 9));
27588 };
27589 CodeDisplayWrapper = (0, _elementor_ui.styled)(_elementor_ui.Box)(function() {
27590 return {
27591 "& p": {
27592 mb: "10px",
27593 fontSize: "13px",
27594 lineHeight: "1.5"
27595 },
27596 "& pre": { position: "relative" },
27597 "& textarea": {
27598 fontSize: "13px",
27599 lineHeight: "1.7"
27600 }
27601 };
27602 });
27603 FormCode$1 = function FormCode(_ref) {
27604 var onClose = _ref.onClose;
27605 var getControlValue = _ref.getControlValue;
27606 var setControlValue = _ref.setControlValue;
27607 var additionalOptions = _ref.additionalOptions;
27608 var credits = _ref.credits;
27609 var children = _ref.children;
27610 var _useCodePrompt = useCodePrompt(_objectSpread$5(_objectSpread$5({}, additionalOptions), {}, { credits }));
27611 var data = _useCodePrompt.data;
27612 var isLoading = _useCodePrompt.isLoading;
27613 var error = _useCodePrompt.error;
27614 var reset = _useCodePrompt.reset;
27615 var send = _useCodePrompt.send;
27616 var sendUsageData = _useCodePrompt.sendUsageData;
27617 var _splitText = splitText(data.result);
27618 var code = _splitText.code;
27619 var details = _splitText.details;
27620 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
27621 var prompt = _useState2[0];
27622 var setPrompt = _useState2[1];
27623 var setGenerate = useRequestIds().setGenerate;
27624 var styleTagId = (0, react.useRef)(generateUniqueId());
27625 useSubscribeOnPromptHistoryAction([{
27626 type: ACTION_TYPES.REUSE,
27627 handler: function handler(action) {
27628 reset();
27629 setPrompt(action.data);
27630 }
27631 }]);
27632 var lastRun = (0, react.useRef)(function() {});
27633 var autocompleteItems = codeHtmlAutocomplete;
27634 var promptLibraryLink = "";
27635 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage)) {
27636 autocompleteItems = codeCssAutocomplete;
27637 promptLibraryLink = "https://go.elementor.com/ai-prompt-library-css/";
27638 } else if (additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.htmlMarkup) promptLibraryLink = "https://go.elementor.com/ai-prompt-library-html/";
27639 else promptLibraryLink = "https://go.elementor.com/ai-prompt-library-custom-code/";
27640 var showSuggestions = !prompt;
27641 var handleSubmit = /*#__PURE__*/ function() {
27642 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator.default.mark(function _callee(event) {
27643 var response;
27644 return import_regenerator.default.wrap(function(_context) {
27645 while (1) switch (_context.prev = _context.next) {
27646 case 0:
27647 event.preventDefault();
27648 setGenerate();
27649 lastRun.current = function() {
27650 return send({ prompt });
27651 };
27652 _context.next = 1;
27653 return lastRun.current();
27654 case 1:
27655 response = _context.sent;
27656 if ("css" === (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.codeLanguage) && response.result) showCssPreview(splitText(response.result).code);
27657 case 2:
27658 case "end": return _context.stop();
27659 }
27660 }, _callee);
27661 }));
27662 return function handleSubmit(_x) {
27663 return _ref2.apply(this, arguments);
27664 };
27665 }();
27666 (0, react.useEffect)(function() {
27667 return function() {
27668 removeStyleTag();
27669 };
27670 }, []);
27671 var showCssPreview = function showCssPreview(cssCode) {
27672 insertStyleTag(parseCSS(cssCode));
27673 };
27674 var parseCSS = function parseCSS(cssCode) {
27675 var elementId = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.elementId;
27676 var selector = "document" === elementId ? elementor.config.document.settings.cssWrapperSelector : ".elementor-element.elementor-element-".concat(elementId);
27677 return cssCode && cssCode.replace(/`/g, "").replace(/^css\s*/i, "").replace(/selector/g, selector);
27678 };
27679 var isElementorEditor = function isElementorEditor() {
27680 return window.elementorFrontend;
27681 };
27682 var insertStyleTag = function insertStyleTag(cssCode) {
27683 if (!isElementorEditor()) return;
27684 var style = document.createElement("style");
27685 style.id = styleTagId.current;
27686 style.appendChild(document.createTextNode(cssCode));
27687 elementorFrontend.elements.$body[0].appendChild(style);
27688 };
27689 var removeStyleTag = function removeStyleTag() {
27690 if (!isElementorEditor()) return;
27691 var styleTag = elementorFrontend.elements.$body[0].querySelector("#".concat(styleTagId.current));
27692 if (styleTag) styleTag.remove();
27693 };
27694 var applyPrompt = function applyPrompt(inputText) {
27695 sendUsageData();
27696 setControlValue(inputText);
27697 onClose();
27698 };
27699 if (isLoading) return /*#__PURE__*/ react.default.createElement(Loader, null);
27700 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, error && /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
27701 error,
27702 onRetry: lastRun.current,
27703 sx: { mb: 2.5 }
27704 }), children, !data.result && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
27705 component: "form",
27706 onSubmit: handleSubmit
27707 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { pb: 1.5 } }, /*#__PURE__*/ react.default.createElement(PromptSearch, {
27708 placeholder: (0, _wordpress_i18n.__)("Describe the code you want to use...", "elementor"),
27709 name: "prompt",
27710 value: prompt,
27711 color: "secondary",
27712 onChange: function onChange(event) {
27713 return setPrompt(event.target.value);
27714 }
27715 })), showSuggestions && /*#__PURE__*/ react.default.createElement(PromptSuggestions, {
27716 suggestions: autocompleteItems,
27717 onSelect: setPrompt
27718 }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink: promptLibraryLink })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27719 direction: "row",
27720 alignItems: "center",
27721 sx: {
27722 py: 1.5,
27723 mt: 4
27724 }
27725 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27726 direction: "row",
27727 justifyContent: "flex-end",
27728 flexGrow: 1
27729 }, /*#__PURE__*/ react.default.createElement(GenerateButton$1, null, (0, _wordpress_i18n.__)("Generate code", "elementor"))))), data.result && /*#__PURE__*/ react.default.createElement(CodeDisplayWrapper, null, /*#__PURE__*/ react.default.createElement(react.Suspense, { fallback: /*#__PURE__*/ react.default.createElement(Loader, null) }, /*#__PURE__*/ react.default.createElement(ReactMarkdown, { components: { code: function code(props) {
27730 return /*#__PURE__*/ react.default.createElement(CodeBlock, _extends$1({}, props, {
27731 defaultValue: getControlValue(),
27732 onInsert: applyPrompt
27733 }));
27734 } } }, code)), details, /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-code-promotion" }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27735 direction: "row",
27736 alignItems: "center",
27737 sx: { mt: 4 }
27738 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
27739 direction: "row",
27740 gap: 1,
27741 justifyContent: "flex-end",
27742 flexGrow: 1
27743 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
27744 size: "small",
27745 color: "secondary",
27746 variant: "text",
27747 onClick: function onClick() {
27748 removeStyleTag();
27749 reset();
27750 }
27751 }, (0, _wordpress_i18n.__)("New prompt", "elementor"))))));
27752 };
27753 FormCode$1.propTypes = {
27754 onClose: import_prop_types.default.func.isRequired,
27755 getControlValue: import_prop_types.default.func.isRequired,
27756 setControlValue: import_prop_types.default.func.isRequired,
27757 additionalOptions: import_prop_types.default.shape({
27758 codeLanguage: import_prop_types.default.string,
27759 htmlMarkup: import_prop_types.default.string,
27760 elementId: import_prop_types.default.string,
27761 initialCredits: import_prop_types.default.number
27762 }),
27763 credits: import_prop_types.default.number,
27764 children: import_prop_types.default.node
27765 };
27766 }));
27767
27768 //#endregion
27769 //#region modules/ai/assets/js/editor/page-content.js
27770 init_extends();
27771 init_defineProperty$1();
27772 init_slicedToArray();
27773 init_history_types();
27774 init_prompt_history_action_context();
27775 init_prompt_history_context();
27776 init_loader();
27777 init_requests_ids();
27778 init_preload_helper();
27779 function ownKeys$4(e, r) {
27780 var t = Object.keys(e);
27781 if (Object.getOwnPropertySymbols) {
27782 var o = Object.getOwnPropertySymbols(e);
27783 r && (o = o.filter(function(r) {
27784 return Object.getOwnPropertyDescriptor(e, r).enumerable;
27785 })), t.push.apply(t, o);
27786 }
27787 return t;
27788 }
27789 __name(ownKeys$4, "ownKeys");
27790 function _objectSpread$4(e) {
27791 for (var r = 1; r < arguments.length; r++) {
27792 var t = null != arguments[r] ? arguments[r] : {};
27793 r % 2 ? ownKeys$4(Object(t), !0).forEach(function(r) {
27794 _defineProperty$1(e, r, t[r]);
27795 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function(r) {
27796 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
27797 });
27798 }
27799 return e;
27800 }
27801 __name(_objectSpread$4, "_objectSpread");
27802 var FormCode = (0, react.lazy)(function() {
27803 return __vitePreload(() => Promise.resolve().then(() => (init_form_code(), form_code_exports)), void 0);
27804 });
27805 var PageContent = function PageContent(_ref) {
27806 var type = _ref.type;
27807 var controlType = _ref.controlType;
27808 var onClose = _ref.onClose;
27809 var onConnect = _ref.onConnect;
27810 var getControlValue = _ref.getControlValue;
27811 var setControlValue = _ref.setControlValue;
27812 var additionalOptions = _ref.additionalOptions;
27813 var _ref2 = function(_additionalOptions$us) {
27814 return (_additionalOptions$us = additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.useCustomInit) !== null && _additionalOptions$us !== void 0 ? _additionalOptions$us : useUserInfo;
27815 }()();
27816 var isLoading = _ref2.isLoading;
27817 var isConnected = _ref2.isConnected;
27818 var isGetStarted = _ref2.isGetStarted;
27819 var connectUrl = _ref2.connectUrl;
27820 var fetchData = _ref2.fetchData;
27821 var hasSubscription = _ref2.hasSubscription;
27822 var credits = _ref2.credits;
27823 var initialUsagePercentage = _ref2.usagePercentage;
27824 var _useRequestIds = useRequestIds();
27825 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
27826 var usagePercentage = _useRequestIds.usagePercentage;
27827 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
27828 var isInitUsageDone = _useState2[0];
27829 var setIsInitUsageDone = _useState2[1];
27830 (0, react.useEffect)(function() {
27831 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
27832 updateUsagePercentage(initialUsagePercentage);
27833 setIsInitUsageDone(true);
27834 }
27835 }, [
27836 isLoading,
27837 initialUsagePercentage,
27838 isInitUsageDone,
27839 updateUsagePercentage
27840 ]);
27841 var showBadge = useUpgradeMessage({
27842 usagePercentage,
27843 hasSubscription
27844 }).showBadge;
27845 var _useState4 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
27846 var sxStyle = _useState4[0];
27847 var setSxStyle = _useState4[1];
27848 var timeoutRef = (0, react.useRef)(null);
27849 var _useState6 = _slicedToArray((0, react.useState)(), 2);
27850 var originalControlValue = _useState6[0];
27851 var setOriginalControlValue = _useState6[1];
27852 var promptDialogStyleProps = {
27853 sx: {
27854 zIndex: 17e4,
27855 "& .MuiDialog-container": {
27856 alignItems: "flex-start",
27857 mt: "media" === type ? "2.5vh" : "18vh"
27858 },
27859 "& .MuiDialogContent-root": {
27860 willChange: "height",
27861 transition: "height 300ms ease-in-out",
27862 position: "relative"
27863 },
27864 "& .MuiBox-root": { boxSizing: "border-box" }
27865 },
27866 PaperProps: { sx: {
27867 m: 0,
27868 maxHeight: "media" === type ? "95vh" : "76vh",
27869 minHeight: "80vh",
27870 height: "auto"
27871 } }
27872 };
27873 var codePromptDialogStyleProps = {
27874 sx: _objectSpread$4(_objectSpread$4({}, promptDialogStyleProps.sx), sxStyle),
27875 PaperProps: {
27876 onMouseEnter: function onMouseEnter() {
27877 clearTimeout(timeoutRef.current);
27878 setSxStyle({ pointerEvents: "all" });
27879 },
27880 onMouseLeave: function onMouseLeave() {
27881 clearTimeout(timeoutRef.current);
27882 timeoutRef.current = setTimeout(function() {
27883 setSxStyle({ pointerEvents: "none" });
27884 }, 200);
27885 },
27886 sx: _objectSpread$4(_objectSpread$4({}, promptDialogStyleProps.PaperProps.sx), {}, { pointerEvents: "auto" })
27887 }
27888 };
27889 var maybeRenderUpgradeChip = function maybeRenderUpgradeChip() {
27890 if (!showBadge) return;
27891 return /*#__PURE__*/ react.default.createElement(UpgradeChip, {
27892 hasSubscription,
27893 usagePercentage
27894 });
27895 };
27896 (0, react.useEffect)(function() {
27897 if (!originalControlValue) setOriginalControlValue(getControlValue());
27898 }, []);
27899 if (isLoading || !isInitUsageDone) return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, promptDialogStyleProps, { maxWidth: "media" === type ? "lg" : "sm" }), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, { dividers: true }, (additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.loadingTitle) && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { style: {
27900 display: "flex",
27901 justifyContent: "center",
27902 alignItems: "center",
27903 width: "100%"
27904 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
27905 variant: "body1",
27906 color: "secondary"
27907 }, additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.loadingTitle)), /*#__PURE__*/ react.default.createElement(Loader, null)));
27908 if (!isConnected) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(WizardDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Connect, {
27909 connectUrl,
27910 onSuccess: function onSuccess(data) {
27911 onConnect(data);
27912 fetchData();
27913 }
27914 })));
27915 if (!isGetStarted) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(WizardDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(GetStarted, { onSuccess: fetchData })));
27916 if ("media" === type) return /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.IMAGE }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(FormMedia, {
27917 onClose,
27918 getControlValue,
27919 setControlValue,
27920 additionalOptions,
27921 credits,
27922 maybeRenderUpgradeChip,
27923 DialogProps: promptDialogStyleProps,
27924 hasSubscription,
27925 usagePercentage
27926 })));
27927 if ("code" === type) return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, codePromptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.CODE }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(PromptDialog.Header, { onClose }, /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27928 className: "e-ai-dialog-content",
27929 dividers: true
27930 }, /*#__PURE__*/ react.default.createElement(react.Suspense, { fallback: /*#__PURE__*/ react.default.createElement(Loader, null) }, /*#__PURE__*/ react.default.createElement(FormCode, {
27931 onClose,
27932 getControlValue,
27933 setControlValue,
27934 additionalOptions,
27935 credits,
27936 usagePercentage
27937 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27938 hasSubscription,
27939 usagePercentage,
27940 sx: { mb: 2 },
27941 feature: FREE_TRIAL_FEATURES_NAMES.CODE
27942 })))))));
27943 if ("animation" === type || "hover_animation" === type) {
27944 var onCloseAnimationDialog = function onCloseAnimationDialog() {
27945 setControlValue(originalControlValue);
27946 elementor.documents.getCurrent().history.setActive(true);
27947 onClose();
27948 };
27949 return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose: onCloseAnimationDialog }, codePromptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
27950 onClose: onCloseAnimationDialog,
27951 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
27952 }, maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27953 className: "e-ai-dialog-content",
27954 dividers: true
27955 }, /*#__PURE__*/ react.default.createElement(FormAnimation, {
27956 onClose,
27957 getControlValue,
27958 setControlValue,
27959 additionalOptions: _objectSpread$4(_objectSpread$4({}, additionalOptions), {}, { animationType: "hover_animation" === type ? "hover" : "other" }),
27960 credits,
27961 usagePercentage
27962 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27963 hasSubscription,
27964 usagePercentage,
27965 sx: { mb: 2 },
27966 feature: FREE_TRIAL_FEATURES_NAMES.ANIMATION
27967 }))));
27968 }
27969 return /*#__PURE__*/ react.default.createElement(PromptDialog, _extends$1({ onClose }, promptDialogStyleProps), /*#__PURE__*/ react.default.createElement(PromptHistoryProvider, { historyType: HISTORY_TYPES.TEXT }, /*#__PURE__*/ react.default.createElement(PromptHistoryActionProvider, null, /*#__PURE__*/ react.default.createElement(PromptDialog.Header, {
27970 onClose,
27971 hideAiBetaLogo: additionalOptions === null || additionalOptions === void 0 ? void 0 : additionalOptions.hideAiBetaLogo
27972 }, !(additionalOptions !== null && additionalOptions !== void 0 && additionalOptions.withoutHistory) && /*#__PURE__*/ react.default.createElement(PromptHistory, null), maybeRenderUpgradeChip()), /*#__PURE__*/ react.default.createElement(PromptDialog.Content, {
27973 className: "e-ai-dialog-content",
27974 dividers: true
27975 }, /*#__PURE__*/ react.default.createElement(FormText, {
27976 type,
27977 controlType,
27978 onClose,
27979 getControlValue,
27980 setControlValue,
27981 additionalOptions,
27982 credits,
27983 usagePercentage
27984 }, /*#__PURE__*/ react.default.createElement(UsageMessages, {
27985 hasSubscription,
27986 usagePercentage,
27987 sx: { mb: 2 },
27988 feature: FREE_TRIAL_FEATURES_NAMES.TEXT
27989 }))))));
27990 };
27991 PageContent.propTypes = {
27992 type: import_prop_types$7.default.string,
27993 controlType: import_prop_types$7.default.string,
27994 onClose: import_prop_types$7.default.func.isRequired,
27995 onConnect: import_prop_types$7.default.func,
27996 getControlValue: import_prop_types$7.default.func.isRequired,
27997 setControlValue: import_prop_types$7.default.func.isRequired,
27998 additionalOptions: import_prop_types$7.default.object
27999 };
28000
28001 //#endregion
28002 //#region node_modules/react-dom/client.js
28003 var require_client = /* @__PURE__ */ __commonJSMin(((exports) => {
28004 var m = (globalThis.ReactDOM);
28005 var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
28006 exports.createRoot = function(c, o) {
28007 i.usingClientEntryPoint = true;
28008 try {
28009 return m.createRoot(c, o);
28010 } finally {
28011 i.usingClientEntryPoint = false;
28012 }
28013 };
28014 }));
28015
28016 //#endregion
28017 //#region assets/dev/js/utils/react.js
28018 var import_client = require_client();
28019
28020 //#endregion
28021 //#region modules/ai/assets/js/editor/utils/preview-container.js
28022 /**
28023 * @typedef {import('elementor/assets/dev/js/editor/container/container')} Container
28024 */
28025 var PREFIX = "e-ai-preview-container";
28026 var CLASS_HIDDEN = PREFIX + "--hidden";
28027 var CLASS_IDLE = PREFIX + "--idle";
28028
28029 //#endregion
28030 //#region modules/ai/assets/js/editor/pages/form-layout/components/unsaved-changes-alert.js
28031 init_extends();
28032 init_objectWithoutProperties$1();
28033 var _excluded$4 = [
28034 "onClose",
28035 "onCancel",
28036 "title",
28037 "text"
28038 ];
28039 var UnsavedChangesAlert = function UnsavedChangesAlert(_ref) {
28040 var onClose = _ref.onClose;
28041 var onCancel = _ref.onCancel;
28042 var title = _ref.title;
28043 var text = _ref.text;
28044 var props = _objectWithoutProperties$1(_ref, _excluded$4);
28045 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, _extends$1({
28046 "aria-labelledby": "unsaved-changes-alert-title",
28047 "aria-describedby": "unsaved-changes-alert-description"
28048 }, props), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogTitle, { id: "unsaved-changes-alert-title" }, title), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContentText, { id: "unsaved-changes-alert-description" }, text)), /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogActions, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28049 onClick: onCancel,
28050 color: "secondary"
28051 }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28052 onClick: onClose,
28053 color: "error",
28054 variant: "contained"
28055 }, (0, _wordpress_i18n.__)("Yes, leave", "elementor"))));
28056 };
28057 UnsavedChangesAlert.propTypes = {
28058 title: import_prop_types$7.default.string,
28059 text: import_prop_types$7.default.string,
28060 onCancel: import_prop_types$7.default.func,
28061 onClose: import_prop_types$7.default.func
28062 };
28063
28064 //#endregion
28065 //#region modules/ai/assets/js/editor/pages/form-layout/components/layout-dialog.js
28066 init_extends();
28067 init_defineProperty$1();
28068 init_slicedToArray();
28069 init_objectWithoutProperties$1();
28070 var _excluded$3 = ["sx", "PaperProps"];
28071 function ownKeys$3(e, r) {
28072 var t = Object.keys(e);
28073 if (Object.getOwnPropertySymbols) {
28074 var o = Object.getOwnPropertySymbols(e);
28075 r && (o = o.filter(function(r) {
28076 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28077 })), t.push.apply(t, o);
28078 }
28079 return t;
28080 }
28081 __name(ownKeys$3, "ownKeys");
28082 function _objectSpread$3(e) {
28083 for (var r = 1; r < arguments.length; r++) {
28084 var t = null != arguments[r] ? arguments[r] : {};
28085 r % 2 ? ownKeys$3(Object(t), !0).forEach(function(r) {
28086 _defineProperty$1(e, r, t[r]);
28087 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function(r) {
28088 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28089 });
28090 }
28091 return e;
28092 }
28093 __name(_objectSpread$3, "_objectSpread");
28094 var StyledDialog = (0, _elementor_ui.styled)(PromptDialog)(function() {
28095 return {
28096 "& .MuiDialog-container": {
28097 marginTop: 0,
28098 alignItems: "flex-end",
28099 paddingBottom: "16vh"
28100 },
28101 "& .MuiPaper-root": {
28102 margin: 0,
28103 maxHeight: "80vh"
28104 }
28105 };
28106 });
28107 var DialogHeader = function DialogHeader(_ref) {
28108 var onClose = _ref.onClose;
28109 var children = _ref.children;
28110 return /*#__PURE__*/ react.default.createElement(_elementor_ui.AppBar, {
28111 sx: { fontWeight: "normal" },
28112 color: "transparent",
28113 position: "relative"
28114 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Toolbar, { variant: "dense" }, /*#__PURE__*/ react.default.createElement(_elementor_icons.AIIcon, { sx: { mr: 1 } }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
28115 component: "span",
28116 variant: "subtitle2",
28117 sx: {
28118 fontWeight: "bold",
28119 textTransform: "uppercase"
28120 }
28121 }, (0, _wordpress_i18n.__)("AI", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
28122 label: (0, _wordpress_i18n.__)("Beta", "elementor"),
28123 color: "default",
28124 size: "small",
28125 sx: { ml: 1 }
28126 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28127 direction: "row",
28128 spacing: 1,
28129 alignItems: "center",
28130 sx: { ml: "auto" }
28131 }, children, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28132 size: "small",
28133 "aria-label": "close",
28134 onClick: onClose,
28135 sx: { "&.MuiButtonBase-root": { mr: -1 } }
28136 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.XIcon, null)))));
28137 };
28138 DialogHeader.propTypes = {
28139 children: import_prop_types$7.default.node,
28140 onClose: import_prop_types$7.default.func.isRequired
28141 };
28142 var StyledDialogContent = (0, _elementor_ui.styled)(PromptDialog.Content)(function() {
28143 return { "&.MuiDialogContent-root": { padding: 0 } };
28144 });
28145 var LayoutDialog = function LayoutDialog(_ref2) {
28146 var _ref2$sx = _ref2.sx;
28147 var sx = _ref2$sx === void 0 ? {} : _ref2$sx;
28148 var _ref2$PaperProps = _ref2.PaperProps;
28149 var PaperProps = _ref2$PaperProps === void 0 ? {} : _ref2$PaperProps;
28150 var props = _objectWithoutProperties$1(_ref2, _excluded$3);
28151 var _useState2 = _slicedToArray((0, react.useState)({ pointerEvents: "none" }), 2);
28152 var sxStyle = _useState2[0];
28153 var setSxStyle = _useState2[1];
28154 var timeoutRef = (0, react.useRef)(null);
28155 /**
28156 * The PromptDialog is using disableScrollLock in order to allow scrolling the page when the Dialog is opened.
28157 * When using the react-draggable library inside the editor, the background page scroll is not working smoothly.
28158 * Therefore, we need to delay the pointerEvents: none, which allowing to scroll the page content.
28159 */
28160 return /*#__PURE__*/ react.default.createElement(StyledDialog, _extends$1({
28161 maxWidth: "md",
28162 PaperProps: _objectSpread$3({
28163 sx: { pointerEvents: "auto" },
28164 onMouseEnter: function onMouseEnter() {
28165 clearTimeout(timeoutRef.current);
28166 setSxStyle({ pointerEvents: "all" });
28167 },
28168 onMouseLeave: function onMouseLeave() {
28169 clearTimeout(timeoutRef.current);
28170 timeoutRef.current = setTimeout(function() {
28171 setSxStyle({ pointerEvents: "none" });
28172 }, 200);
28173 }
28174 }, PaperProps)
28175 }, props, { sx: _objectSpread$3(_objectSpread$3({}, sxStyle), sx) }));
28176 };
28177 LayoutDialog.propTypes = {
28178 sx: import_prop_types$7.default.object,
28179 PaperProps: import_prop_types$7.default.object
28180 };
28181 LayoutDialog.Header = DialogHeader;
28182 LayoutDialog.Content = StyledDialogContent;
28183
28184 //#endregion
28185 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-autocomplete.js
28186 init_slicedToArray();
28187 init_objectWithoutProperties$1();
28188 init_extends();
28189 init_defineProperty$1();
28190 init_prompt_library_link();
28191 var _excluded$2 = ["onSubmit"];
28192 function ownKeys$2(e, r) {
28193 var t = Object.keys(e);
28194 if (Object.getOwnPropertySymbols) {
28195 var o = Object.getOwnPropertySymbols(e);
28196 r && (o = o.filter(function(r) {
28197 return Object.getOwnPropertyDescriptor(e, r).enumerable;
28198 })), t.push.apply(t, o);
28199 }
28200 return t;
28201 }
28202 __name(ownKeys$2, "ownKeys");
28203 function _objectSpread$2(e) {
28204 for (var r = 1; r < arguments.length; r++) {
28205 var t = null != arguments[r] ? arguments[r] : {};
28206 r % 2 ? ownKeys$2(Object(t), !0).forEach(function(r) {
28207 _defineProperty$1(e, r, t[r]);
28208 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function(r) {
28209 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
28210 });
28211 }
28212 return e;
28213 }
28214 __name(_objectSpread$2, "_objectSpread");
28215 var TextInput = (0, react.forwardRef)(function(props, ref) {
28216 return /*#__PURE__*/ react.default.createElement(_elementor_ui.TextField, _extends$1({
28217 autoFocus: true,
28218 multiline: true,
28219 size: "small",
28220 maxRows: 3,
28221 color: "secondary",
28222 variant: "standard"
28223 }, props, {
28224 inputRef: ref,
28225 InputProps: _objectSpread$2(_objectSpread$2({}, props.InputProps), {}, {
28226 type: "search",
28227 sx: { pt: 0 }
28228 })
28229 }));
28230 });
28231 TextInput.propTypes = { InputProps: import_prop_types$7.default.object };
28232 var PaperComponent = function PaperComponent(props) {
28233 var libraryLink = "variation" === useConfig().mode ? "https://go.elementor.com/ai-prompt-library-variations/" : "https://go.elementor.com/ai-prompt-library-containers/";
28234 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Paper, _extends$1({}, props, {
28235 elevation: 8,
28236 sx: { borderRadius: 2 }
28237 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
28238 component: _elementor_ui.Box,
28239 color: function color(theme) {
28240 return theme.palette.text.tertiary;
28241 },
28242 variant: "caption",
28243 paddingX: 2,
28244 paddingY: 1
28245 }, (0, _wordpress_i18n.__)("Suggested Prompts", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), props.children, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { m: 2 } }, /*#__PURE__*/ react.default.createElement(PromptLibraryLink, { libraryLink })));
28246 };
28247 PaperComponent.propTypes = { children: import_prop_types$7.default.node };
28248 var PromptAutocomplete = function PromptAutocomplete(_ref) {
28249 var onSubmit = _ref.onSubmit;
28250 var props = _objectWithoutProperties$1(_ref, _excluded$2);
28251 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28252 var showSuggestions = _useState2[0];
28253 var setShowSuggestions = _useState2[1];
28254 var theme = (0, _elementor_ui.useTheme)();
28255 var itemHeight = parseInt(theme.spacing(4));
28256 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Autocomplete, _extends$1({
28257 PaperComponent,
28258 ListboxProps: { sx: { maxHeight: 5 * itemHeight } },
28259 renderOption: function renderOption(optionProps, option) {
28260 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, _extends$1({}, optionProps, {
28261 title: option.text,
28262 noWrap: true,
28263 variant: "body2",
28264 component: _elementor_ui.Box,
28265 sx: { "&.MuiAutocomplete-option": {
28266 display: "block",
28267 minHeight: itemHeight
28268 } }
28269 }), option.text);
28270 },
28271 freeSolo: true,
28272 fullWidth: true,
28273 disableClearable: true,
28274 open: showSuggestions,
28275 onClose: function onClose(e) {
28276 var _e$relatedTarget;
28277 return setShowSuggestions("A" === ((_e$relatedTarget = e.relatedTarget) === null || _e$relatedTarget === void 0 ? void 0 : _e$relatedTarget.tagName));
28278 },
28279 onKeyDown: function onKeyDown(e) {
28280 if ("Enter" === e.key && !e.shiftKey && !showSuggestions) onSubmit(e);
28281 else if ("/" === e.key && "" === e.target.value) {
28282 e.preventDefault();
28283 setShowSuggestions(true);
28284 }
28285 }
28286 }, props));
28287 };
28288 PromptAutocomplete.propTypes = { onSubmit: import_prop_types$7.default.func.isRequired };
28289 PromptAutocomplete.TextInput = TextInput;
28290
28291 //#endregion
28292 //#region modules/ai/assets/js/editor/icons/arrow-left-icon.js
28293 init_extends();
28294 var ArrowLeftIcon = react.default.forwardRef(function(props, ref) {
28295 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28296 fillRule: "evenodd",
28297 clipRule: "evenodd",
28298 d: "M9.53033 7.46967C9.82322 7.76256 9.82322 8.23744 9.53033 8.53033L6.81066 11.25H19C19.4142 11.25 19.75 11.5858 19.75 12C19.75 12.4142 19.4142 12.75 19 12.75H6.81066L9.53033 15.4697C9.82322 15.7626 9.82322 16.2374 9.53033 16.5303C9.23744 16.8232 8.76256 16.8232 8.46967 16.5303L4.46967 12.5303C4.17678 12.2374 4.17678 11.7626 4.46967 11.4697L8.46967 7.46967C8.76256 7.17678 9.23744 7.17678 9.53033 7.46967Z"
28299 }));
28300 });
28301
28302 //#endregion
28303 //#region modules/ai/assets/js/editor/icons/x-circle-icon.js
28304 init_extends();
28305 var XCircleIcon = react.default.forwardRef(function(props, ref) {
28306 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M12 2.69231C6.8595 2.69231 2.69231 6.8595 2.69231 12C2.69231 17.1405 6.8595 21.3077 12 21.3077C17.1405 21.3077 21.3077 17.1405 21.3077 12C21.3077 6.8595 17.1405 2.69231 12 2.69231ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM9.14527 9.14527C9.47571 8.81483 10.0115 8.81483 10.3419 9.14527L12 10.8034L13.6581 9.14527C13.9885 8.81483 14.5243 8.81483 14.8547 9.14527C15.1852 9.47571 15.1852 10.0115 14.8547 10.3419L13.1966 12L14.8547 13.6581C15.1852 13.9885 15.1852 14.5243 14.8547 14.8547C14.5243 15.1852 13.9885 15.1852 13.6581 14.8547L12 13.1966L10.3419 14.8547C10.0115 15.1852 9.47571 15.1852 9.14527 14.8547C8.81483 14.5243 8.81483 13.9885 9.14527 13.6581L10.8034 12L9.14527 10.3419C8.81483 10.0115 8.81483 9.47571 9.14527 9.14527Z" }));
28307 });
28308
28309 //#endregion
28310 //#region modules/ai/assets/js/editor/icons/plus-circle-icon.js
28311 init_extends();
28312 var PlusCircleIcon = react.default.forwardRef(function(props, ref) {
28313 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", { d: "M12 2.69231C6.8595 2.69231 2.69231 6.8595 2.69231 12C2.69231 17.1405 6.8595 21.3077 12 21.3077C17.1405 21.3077 21.3077 17.1405 21.3077 12C21.3077 6.8595 17.1405 2.69231 12 2.69231ZM1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM12 7.76923C12.4673 7.76923 12.8462 8.14807 12.8462 8.61538V11.1538H15.3846C15.8519 11.1538 16.2308 11.5327 16.2308 12C16.2308 12.4673 15.8519 12.8462 15.3846 12.8462H12.8462V15.3846C12.8462 15.8519 12.4673 16.2308 12 16.2308C11.5327 16.2308 11.1538 15.8519 11.1538 15.3846V12.8462H8.61538C8.14807 12.8462 7.76923 12.4673 7.76923 12C7.76923 11.5327 8.14807 11.1538 8.61538 11.1538H11.1538V8.61538C11.1538 8.14807 11.5327 7.76923 12 7.76923Z" }));
28314 });
28315
28316 //#endregion
28317 //#region modules/ai/assets/js/editor/components/alert-dialog.js
28318 init_slicedToArray();
28319 var AlertDialog = function AlertDialog(props) {
28320 var _useState2 = _slicedToArray((0, react.useState)(true), 2);
28321 var isShown = _useState2[0];
28322 var setIsShown = _useState2[1];
28323 if (!isShown) return null;
28324 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28325 open: true,
28326 maxWidth: "lg"
28327 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.DialogContent, { sx: { padding: 0 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28328 textAlign: "center",
28329 padding: 3
28330 } }, props.message), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28331 alignItems: "center",
28332 spacing: 2,
28333 marginBottom: 2
28334 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
28335 variant: "contained",
28336 type: "button",
28337 color: "primary",
28338 onClick: function onClick() {
28339 var _props$onClose;
28340 setIsShown(false);
28341 (_props$onClose = props.onClose) === null || _props$onClose === void 0 || _props$onClose.call(props);
28342 }
28343 }, (0, _wordpress_i18n.__)("Close", "elementor")))));
28344 };
28345 AlertDialog.propTypes = {
28346 message: import_prop_types$7.default.string.isRequired,
28347 onClose: import_prop_types$7.default.func
28348 };
28349
28350 //#endregion
28351 //#region modules/ai/assets/js/editor/hooks/use-timeout.js
28352 init_slicedToArray();
28353 var useTimeout = function useTimeout(delay) {
28354 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28355 var isTimeout = _useState2[0];
28356 var setIsTimeout = _useState2[1];
28357 var timeoutIdRef = (0, react.useRef)(null);
28358 var turnOffTimeout = function turnOffTimeout() {
28359 clearTimeout(timeoutIdRef.current);
28360 setIsTimeout(false);
28361 };
28362 (0, react.useEffect)(function() {
28363 timeoutIdRef.current = setTimeout(function() {
28364 setIsTimeout(true);
28365 }, delay);
28366 return function() {
28367 clearTimeout(timeoutIdRef.current);
28368 };
28369 }, [delay]);
28370 return [isTimeout, turnOffTimeout];
28371 };
28372
28373 //#endregion
28374 //#region modules/ai/assets/js/editor/pages/form-layout/context/remote-config.js
28375 init_asyncToGenerator();
28376 init_slicedToArray();
28377 init_api();
28378 var RemoteConfigContext = react.default.createContext({});
28379 var useRemoteConfig = function useRemoteConfig() {
28380 return react.default.useContext(RemoteConfigContext);
28381 };
28382 var CONFIG_KEYS = {
28383 WEB_BASED_BUILDER_URL: "webBasedBuilderUrl",
28384 AUTH_TOKEN: "jwt"
28385 };
28386 var RemoteConfigProvider = function RemoteConfigProvider(props) {
28387 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28388 var isLoading = _useState2[0];
28389 var setIsLoading = _useState2[1];
28390 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
28391 var isLoaded = _useState4[0];
28392 var setIsLoaded = _useState4[1];
28393 var _useState6 = _slicedToArray((0, react.useState)(false), 2);
28394 var isError = _useState6[0];
28395 var setIsError = _useState6[1];
28396 var _useState8 = _slicedToArray((0, react.useState)({}), 2);
28397 var remoteConfig = _useState8[0];
28398 var setRemoteConfig = _useState8[1];
28399 var fetchData = /*#__PURE__*/ function() {
28400 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee() {
28401 var result;
28402 return import_regenerator$2.default.wrap(function(_context) {
28403 while (1) switch (_context.prev = _context.next) {
28404 case 0:
28405 setIsLoading(true);
28406 setIsError(false);
28407 _context.prev = 1;
28408 _context.next = 2;
28409 return getRemoteConfig().finally(function() {
28410 setIsLoaded(true);
28411 setIsLoading(false);
28412 });
28413 case 2:
28414 result = _context.sent;
28415 if (result.config) {
28416 _context.next = 3;
28417 break;
28418 }
28419 throw new Error("Invalid remote config");
28420 case 3:
28421 setRemoteConfig(result.config);
28422 _context.next = 5;
28423 break;
28424 case 4:
28425 _context.prev = 4;
28426 _context["catch"](1);
28427 setIsError(true);
28428 setIsLoaded(true);
28429 setIsLoading(false);
28430 case 5:
28431 case "end": return _context.stop();
28432 }
28433 }, _callee, null, [[1, 4]]);
28434 }));
28435 return function fetchData() {
28436 return _ref.apply(this, arguments);
28437 };
28438 }();
28439 (0, react.useEffect)(function() {
28440 window.addEventListener("elementor/connect/success", fetchData);
28441 return function() {
28442 window.removeEventListener("elementor/connect/success", fetchData);
28443 };
28444 }, []);
28445 if (!isLoaded && !isLoading) fetchData();
28446 return /*#__PURE__*/ react.default.createElement(RemoteConfigContext.Provider, { value: {
28447 isLoading,
28448 isLoaded,
28449 isError,
28450 remoteConfig
28451 } }, props.children);
28452 };
28453 RemoteConfigProvider.propTypes = {
28454 children: import_prop_types$7.default.node.isRequired,
28455 onError: import_prop_types$7.default.func.isRequired
28456 };
28457
28458 //#endregion
28459 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/url-dialog.js
28460 init_slicedToArray();
28461 init_requests_ids();
28462 var UrlDialog = function UrlDialog(props) {
28463 var _useTimeout2 = _slicedToArray(useTimeout(1e4), 2);
28464 var isTimeout = _useTimeout2[0];
28465 var turnOffTimeout = _useTimeout2[1];
28466 var _useUserInfo = useUserInfo();
28467 var isLoading = _useUserInfo.isLoading;
28468 var initialUsagePercentage = _useUserInfo.usagePercentage;
28469 var updateUsagePercentage = useRequestIds().updateUsagePercentage;
28470 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28471 var isInitUsageDone = _useState2[0];
28472 var setIsInitUsageDone = _useState2[1];
28473 var builderUrl = useRemoteConfig().remoteConfig[CONFIG_KEYS.WEB_BASED_BUILDER_URL];
28474 var iframeOrigin = (builderUrl ? new URL(builderUrl) : {}).origin;
28475 var isOpen = (0, react.useRef)(false);
28476 (0, react.useEffect)(function() {
28477 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
28478 updateUsagePercentage(initialUsagePercentage);
28479 setIsInitUsageDone(true);
28480 }
28481 }, [
28482 isLoading,
28483 initialUsagePercentage,
28484 isInitUsageDone,
28485 updateUsagePercentage
28486 ]);
28487 (0, react.useEffect)(function() {
28488 if (!isOpen.current) try {
28489 window.$e.run("ai-integration/open-choose-element", { url: props.url });
28490 isOpen.current = true;
28491 } catch (error) {
28492 console.error(error);
28493 }
28494 }, [isOpen.current]);
28495 (0, react.useEffect)(function() {
28496 var onMessage = function onMessage(event) {
28497 if (event.origin !== iframeOrigin) return;
28498 var _event$data = event.data;
28499 var type = _event$data.type;
28500 var html = _event$data.html;
28501 var url = _event$data.url;
28502 switch (type) {
28503 case "element-selector/close":
28504 isOpen.current = false;
28505 props.onClose();
28506 break;
28507 case "element-selector/loaded":
28508 turnOffTimeout();
28509 isOpen.current = true;
28510 break;
28511 case "element-selector/attach":
28512 props.onAttach([{
28513 type: "url",
28514 previewHTML: html,
28515 content: html,
28516 label: url ? new URL(url).href : "",
28517 source: USER_URL_SOURCE
28518 }]);
28519 break;
28520 }
28521 };
28522 window.addEventListener("message", onMessage);
28523 return function() {
28524 window.removeEventListener("message", onMessage);
28525 };
28526 }, [
28527 iframeOrigin,
28528 props,
28529 turnOffTimeout
28530 ]);
28531 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, !isOpen.current && !isTimeout && /*#__PURE__*/ react.default.createElement(_elementor_ui.Dialog, {
28532 open: true,
28533 maxWidth: "lg"
28534 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { sx: {
28535 textAlign: "center",
28536 padding: 3
28537 } }, (0, _wordpress_i18n.__)("Loading...", "elementor"))), isTimeout && /*#__PURE__*/ react.default.createElement(AlertDialog, {
28538 message: (0, _wordpress_i18n.__)("The app is not responding. Please try again later. (#408)", "elementor"),
28539 onClose: props.onClose
28540 }));
28541 };
28542 UrlDialog.propTypes = {
28543 onAttach: import_prop_types$7.default.func.isRequired,
28544 onClose: import_prop_types$7.default.func.isRequired,
28545 url: import_prop_types$7.default.string
28546 };
28547
28548 //#endregion
28549 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/library-dialog.js
28550 var LibraryDialog = function LibraryDialog(props) {
28551 var isApplyingTemplate = (0, react.useRef)(false);
28552 (0, react.useEffect)(function() {
28553 var onLibraryHide = function onLibraryHide() {
28554 if (isApplyingTemplate.current) return;
28555 props.onClose();
28556 };
28557 $e.components.get("library").layout.getModal().on("hide", onLibraryHide);
28558 return function() {
28559 $e.components.get("library").layout.getModal().off("hide", onLibraryHide);
28560 };
28561 }, [props]);
28562 (0, react.useEffect)(function() {
28563 var onMessage = function onMessage(event) {
28564 var _event$data = event.data;
28565 var type = _event$data.type;
28566 var json = _event$data.json;
28567 var html = _event$data.html;
28568 var label = _event$data.label;
28569 var source = _event$data.source;
28570 switch (type) {
28571 case "library/attach:start":
28572 isApplyingTemplate.current = true;
28573 break;
28574 case "library/attach":
28575 props.onAttach([{
28576 type: ATTACHMENT_TYPE_JSON,
28577 previewHTML: html,
28578 content: json,
28579 label,
28580 source
28581 }]);
28582 isApplyingTemplate.current = false;
28583 props.onClose();
28584 break;
28585 }
28586 };
28587 window.addEventListener("message", onMessage);
28588 return function() {
28589 window.removeEventListener("message", onMessage);
28590 };
28591 });
28592 $e.run("library/open", {
28593 toDefault: true,
28594 mode: "ai-attachment"
28595 });
28596 isApplyingTemplate.current = false;
28597 return null;
28598 };
28599 LibraryDialog.propTypes = {
28600 onAttach: import_prop_types$7.default.func.isRequired,
28601 onClose: import_prop_types$7.default.func.isRequired
28602 };
28603
28604 //#endregion
28605 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/attach-dialog.js
28606 var AttachDialog = function AttachDialog(props) {
28607 var type = props.type;
28608 var url = props.url;
28609 switch (type) {
28610 case "url": return /*#__PURE__*/ react.default.createElement(UrlDialog, {
28611 url,
28612 onAttach: props.onAttach,
28613 onClose: props.onClose
28614 });
28615 case MENU_TYPE_LIBRARY: return /*#__PURE__*/ react.default.createElement(LibraryDialog, {
28616 onAttach: props.onAttach,
28617 onClose: props.onClose
28618 });
28619 }
28620 return null;
28621 };
28622 AttachDialog.propTypes = {
28623 type: import_prop_types$7.default.string,
28624 onAttach: import_prop_types$7.default.func,
28625 onClose: import_prop_types$7.default.func,
28626 url: import_prop_types$7.default.string
28627 };
28628
28629 //#endregion
28630 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/menu.js
28631 init_slicedToArray();
28632 init_use_introduction();
28633 var Menu = function Menu(props) {
28634 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
28635 var isOpen = _useState2[0];
28636 var setIsOpen = _useState2[1];
28637 var _useState4 = _slicedToArray((0, react.useState)(null), 2);
28638 var selectedType = _useState4[0];
28639 var setSelectedType = _useState4[1];
28640 var direction = (0, _elementor_ui.useTheme)().direction;
28641 var anchorRef = (0, react.useRef)(null);
28642 var _useIntroduction = useIntroduction("e-ai-attachment-badge");
28643 var isViewed = _useIntroduction.isViewed;
28644 var markAsViewed = _useIntroduction.markAsViewed;
28645 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28646 size: "small",
28647 ref: anchorRef,
28648 disabled: props.disabled,
28649 onClick: function onClick() {
28650 setIsOpen(true);
28651 if (!isViewed) markAsViewed();
28652 },
28653 color: "secondary"
28654 }, function() {
28655 if (isOpen) return /*#__PURE__*/ react.default.createElement(XCircleIcon, { fontSize: "small" });
28656 else if (isViewed) return /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" });
28657 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Badge, {
28658 color: "primary",
28659 badgeContent: " ",
28660 variant: "dot"
28661 }, /*#__PURE__*/ react.default.createElement(PlusCircleIcon, { fontSize: "small" }));
28662 }()), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popover, {
28663 open: isOpen,
28664 anchorEl: anchorRef.current,
28665 onClose: function onClose() {
28666 return setIsOpen(false);
28667 },
28668 anchorOrigin: {
28669 vertical: "bottom",
28670 horizontal: "rtl" === direction ? "right" : "left"
28671 },
28672 transformOrigin: {
28673 vertical: "top",
28674 horizontal: "rtl" === direction ? "right" : "left"
28675 }
28676 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, { sx: { width: 440 } }, props.items.map(function(item) {
28677 var IconComponent = item.icon;
28678 return /*#__PURE__*/ react.default.createElement(_elementor_ui.MenuItem, {
28679 key: item.type,
28680 onClick: function onClick() {
28681 setSelectedType(item.type);
28682 setIsOpen(false);
28683 }
28684 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ListItemIcon, null, /*#__PURE__*/ react.default.createElement(IconComponent, null)), item.title);
28685 }))), /*#__PURE__*/ react.default.createElement(AttachDialog, {
28686 type: selectedType,
28687 onAttach: props.onAttach,
28688 onClose: function onClose() {
28689 setIsOpen(false);
28690 setSelectedType(null);
28691 }
28692 }));
28693 };
28694 Menu.propTypes = {
28695 items: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({
28696 title: import_prop_types$7.default.string.isRequired,
28697 type: import_prop_types$7.default.string.isRequired,
28698 icon: import_prop_types$7.default.elementType
28699 })).isRequired,
28700 onAttach: import_prop_types$7.default.func.isRequired,
28701 disabled: import_prop_types$7.default.bool
28702 };
28703
28704 //#endregion
28705 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail.js
28706 var _templateObject$3;
28707 var THUMBNAIL_SIZE = 64;
28708 var StyledBody = (0, _elementor_ui.styled)("body")(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteral(["\n html, body {\n margin: 0;\n padding: 0;\n overflow: hidden;\n }\n\n body > * {\n width: 100% !important;\n }\n\n body > img {\n height: 100%;\n object-fit: cover;\n }\n\n body:has(> img) {\n height: ", "px\n }\n"])), 64);
28709 var Thumbnail = function Thumbnail(props) {
28710 var _props$html$match;
28711 var _props$html$match2;
28712 var dataWidth = (_props$html$match = props.html.match("data-width=\"(?<width>\\d+)\"")) === null || _props$html$match === void 0 || (_props$html$match = _props$html$match.groups) === null || _props$html$match === void 0 ? void 0 : _props$html$match.width;
28713 var dataHeight = (_props$html$match2 = props.html.match("data-height=\"(?<height>\\d+)\"")) === null || _props$html$match2 === void 0 || (_props$html$match2 = _props$html$match2.groups) === null || _props$html$match2 === void 0 ? void 0 : _props$html$match2.height;
28714 var width = dataWidth ? parseInt(dataWidth) : 64;
28715 var height = dataHeight ? parseInt(dataHeight) : 64;
28716 var scale = 64 / Math.min(height, width);
28717 var top = height > width ? (64 - 64 * (height / width)) / 2 : 0;
28718 var left = width > height ? (64 - 64 * (width / height)) / 2 : 0;
28719 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28720 dir: "ltr",
28721 sx: {
28722 position: "relative",
28723 cursor: "default",
28724 overflow: "hidden",
28725 border: "1px solid",
28726 borderColor: "grey.300",
28727 borderRadius: 1,
28728 boxSizing: "border-box",
28729 width: 64,
28730 height: 64,
28731 opacity: props.disabled ? .5 : 1
28732 }
28733 }, /*#__PURE__*/ react.default.createElement("iframe", {
28734 title: (0, _wordpress_i18n.__)("Preview", "elementor"),
28735 sandbox: "",
28736 srcDoc: "<style>" + StyledBody.componentStyle.rules.join("") + "</style>" + props.html,
28737 style: {
28738 border: "none",
28739 overflow: "hidden",
28740 width,
28741 height,
28742 transform: "scale(".concat(scale, ")"),
28743 transformOrigin: "".concat(left, "px ").concat(top, "px")
28744 }
28745 }));
28746 };
28747 Thumbnail.propTypes = {
28748 html: import_prop_types$7.default.string.isRequired,
28749 disabled: import_prop_types$7.default.bool
28750 };
28751
28752 //#endregion
28753 //#region modules/ai/assets/js/editor/types/attachment.js
28754 var AttachmentPropType = import_prop_types$7.default.shape({
28755 type: import_prop_types$7.default.string,
28756 previewHTML: import_prop_types$7.default.string,
28757 content: import_prop_types$7.default.string,
28758 label: import_prop_types$7.default.string,
28759 source: import_prop_types$7.default.string
28760 });
28761 var AttachmentsTypesPropType = import_prop_types$7.default.shape({ type: import_prop_types$7.default.shape({
28762 promptPlaceholder: import_prop_types$7.default.string,
28763 promptSuggestions: import_prop_types$7.default.arrayOf(import_prop_types$7.default.shape({ text: import_prop_types$7.default.string.isRequired })),
28764 previewGenerator: import_prop_types$7.default.func
28765 }) });
28766
28767 //#endregion
28768 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-json.js
28769 var ThumbnailJson = function ThumbnailJson(props) {
28770 var _props$attachments;
28771 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28772 return "json" === item.type;
28773 });
28774 if (!attachment) return null;
28775 if (!attachment.previewHTML) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
28776 animation: "wave",
28777 variant: "rounded",
28778 width: 60,
28779 height: 60
28780 });
28781 return /*#__PURE__*/ react.default.createElement(Thumbnail, {
28782 html: attachment.previewHTML,
28783 disabled: props.disabled
28784 });
28785 };
28786 ThumbnailJson.propTypes = {
28787 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28788 disabled: import_prop_types$7.default.bool
28789 };
28790
28791 //#endregion
28792 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/thumbnail-url.js
28793 var ThumbnailUrl = function ThumbnailUrl(props) {
28794 var _props$attachments;
28795 var attachment = (_props$attachments = props.attachments) === null || _props$attachments === void 0 ? void 0 : _props$attachments.find(function(item) {
28796 return "url" === item.type;
28797 });
28798 if (!attachment) return null;
28799 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
28800 position: "relative",
28801 "&:hover::before": {
28802 content: "\"\"",
28803 position: "absolute",
28804 userSelect: "none",
28805 inset: 0,
28806 backgroundColor: "rgba(0,0,0,0.6)",
28807 borderRadius: 1,
28808 zIndex: 1
28809 },
28810 "&:hover .remove-attachment": { display: "flex" }
28811 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
28812 className: "remove-attachment",
28813 size: "small",
28814 "aria-label": (0, _wordpress_i18n.__)("Remove", "elementor"),
28815 disabled: props.disabled,
28816 onClick: function onClick(event) {
28817 event.stopPropagation();
28818 props.onDetach();
28819 },
28820 sx: {
28821 display: "none",
28822 position: "absolute",
28823 insetInlineEnd: 4,
28824 insetBlockStart: 4,
28825 backgroundColor: "secondary.main",
28826 zIndex: 1,
28827 borderRadius: 1,
28828 p: "3px",
28829 "&:hover": { backgroundColor: "secondary.dark" }
28830 }
28831 }, /*#__PURE__*/ react.default.createElement(_elementor_icons.TrashIcon, { sx: {
28832 fontSize: "1.125rem",
28833 color: "common.white"
28834 } })), /*#__PURE__*/ react.default.createElement(Thumbnail, {
28835 disabled: props.disabled,
28836 html: attachment.previewHTML
28837 }));
28838 };
28839 ThumbnailUrl.propTypes = {
28840 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28841 disabled: import_prop_types$7.default.bool,
28842 onDetach: import_prop_types$7.default.func
28843 };
28844
28845 //#endregion
28846 //#region modules/ai/assets/js/editor/icons/website-icon.js
28847 init_extends();
28848 var WebsiteIcon = react.default.forwardRef(function(props, ref) {
28849 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28850 fillRule: "evenodd",
28851 clipRule: "evenodd",
28852 d: "M4.16707 3.95837C4.11182 3.95837 4.05883 3.98032 4.01976 4.01939C3.98069 4.05846 3.95874 4.11145 3.95874 4.16671V6.04171H6.04207V3.95837H4.16707ZM4.16707 2.70837C3.7803 2.70837 3.40937 2.86202 3.13588 3.13551C2.86239 3.409 2.70874 3.77993 2.70874 4.16671V15.8334C2.70874 16.2201 2.86239 16.5911 3.13588 16.8646C3.40937 17.1381 3.7803 17.2917 4.16707 17.2917H15.8337C16.2205 17.2917 16.5914 17.1381 16.8649 16.8646C17.1384 16.5911 17.2921 16.2201 17.2921 15.8334V4.16671C17.2921 3.77993 17.1384 3.409 16.8649 3.13551C16.5914 2.86202 16.2205 2.70837 15.8337 2.70837H4.16707ZM7.29207 3.95837V6.04171H16.0421V4.16671C16.0421 4.11145 16.0201 4.05846 15.9811 4.01939C15.942 3.98032 15.889 3.95837 15.8337 3.95837H7.29207ZM16.0421 7.29171H3.95874V15.8334C3.95874 15.8886 3.98069 15.9416 4.01976 15.9807C4.05883 16.0198 4.11182 16.0417 4.16707 16.0417H15.8337C15.889 16.0417 15.942 16.0198 15.9811 15.9807C16.0201 15.9416 16.0421 15.8886 16.0421 15.8334V7.29171Z"
28853 }));
28854 });
28855
28856 //#endregion
28857 //#region modules/ai/assets/js/editor/icons/copy-page-icon.js
28858 init_extends();
28859 var CopyPageIcon = react.default.forwardRef(function(props, ref) {
28860 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
28861 fillRule: "evenodd",
28862 clipRule: "evenodd",
28863 d: "M16.6667 0.208496C17.0534 0.208496 17.4244 0.362142 17.6979 0.635632C17.9714 0.909123 18.125 1.28006 18.125 1.66683V11.6668C18.125 12.0536 17.9714 12.4245 17.6979 12.698C17.4244 12.9715 17.0534 13.1252 16.6667 13.1252H14.7917V16.6668C14.7917 17.0536 14.638 17.4245 14.3645 17.698C14.091 17.9715 13.7201 18.1252 13.3333 18.1252H3.33333C2.94656 18.1252 2.57563 17.9715 2.30214 17.698C2.02865 17.4245 1.875 17.0536 1.875 16.6668V6.66683C1.875 6.28005 2.02865 5.90912 2.30214 5.63563C2.57563 5.36214 2.94656 5.2085 3.33333 5.2085H5.20833V1.66683C5.20833 1.28005 5.36198 0.909122 5.63547 0.635632C5.90896 0.362142 6.27989 0.208496 6.66667 0.208496H16.6667ZM6.66667 1.4585C6.61141 1.4585 6.55842 1.48045 6.51935 1.51952C6.48028 1.55859 6.45833 1.61158 6.45833 1.66683V3.54183H8.54167V1.4585H6.66667ZM3.125 9.79183V16.6668C3.125 16.7221 3.14695 16.7751 3.18602 16.8141C3.22509 16.8532 3.27808 16.8752 3.33333 16.8752H13.3333C13.3886 16.8752 13.4416 16.8532 13.4806 16.8141C13.5197 16.7751 13.5417 16.7221 13.5417 16.6668V13.1252H6.66667C6.27989 13.1252 5.90896 12.9715 5.63547 12.698C5.36198 12.4245 5.20833 12.0536 5.20833 11.6668V9.79183H3.125ZM5.20833 8.54183H3.125V6.66683C3.125 6.61158 3.14695 6.55859 3.18602 6.51952C3.22509 6.48045 3.27808 6.4585 3.33333 6.4585H5.20833V8.54183ZM6.45833 11.6668C6.45833 11.7221 6.48028 11.7751 6.51935 11.8141C6.55842 11.8532 6.61141 11.8752 6.66667 11.8752H16.6667C16.7219 11.8752 16.7749 11.8532 16.814 11.8141C16.853 11.7751 16.875 11.7221 16.875 11.6668V4.79183H6.45833V11.6668ZM9.79167 1.4585V3.54183H16.875V1.66683C16.875 1.61157 16.853 1.55858 16.814 1.51952C16.7749 1.48045 16.7219 1.4585 16.6667 1.4585H9.79167Z"
28864 }));
28865 });
28866
28867 //#endregion
28868 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments.js
28869 init_extends();
28870 var ATTACHMENT_TYPE_JSON = "json";
28871 var ATTACHMENT_TYPE_URL = "url";
28872 var MENU_TYPE_LIBRARY = "library";
28873 var USER_URL_SOURCE = "user-url";
28874 var Attachments = function Attachments(props) {
28875 if (!props.attachments.length) return /*#__PURE__*/ react.default.createElement(Menu, {
28876 disabled: props.disabled,
28877 onAttach: props.onAttach,
28878 items: [{
28879 title: (0, _wordpress_i18n.__)("Reference a website", "elementor"),
28880 icon: WebsiteIcon,
28881 type: "url"
28882 }, {
28883 title: (0, _wordpress_i18n.__)("Create variations from Template Library", "elementor"),
28884 icon: CopyPageIcon,
28885 type: MENU_TYPE_LIBRARY
28886 }]
28887 });
28888 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28889 direction: "row",
28890 spacing: 1
28891 }, props.attachments.map(function(attachment, index) {
28892 switch (attachment.type) {
28893 case ATTACHMENT_TYPE_JSON: return /*#__PURE__*/ react.default.createElement(ThumbnailJson, _extends$1({ key: index }, props));
28894 case "url": return /*#__PURE__*/ react.default.createElement(ThumbnailUrl, _extends$1({ key: index }, props));
28895 default: return null;
28896 }
28897 }));
28898 };
28899 Attachments.propTypes = {
28900 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType).isRequired,
28901 onAttach: import_prop_types$7.default.func.isRequired,
28902 onDetach: import_prop_types$7.default.func,
28903 disabled: import_prop_types$7.default.bool
28904 };
28905
28906 //#endregion
28907 //#region modules/ai/assets/js/editor/pages/form-layout/components/prompt-form.js
28908 init_slicedToArray();
28909 init_extends();
28910 init_objectWithoutProperties$1();
28911 var _excluded$1 = ["tooltip"];
28912 var PROMPT_SUGGESTIONS = Object.freeze([
28913 { text: (0, _wordpress_i18n.__)("Hero section on [topic] with heading, text, buttons on the right, and an image on the left", "elementor.com") },
28914 { text: (0, _wordpress_i18n.__)("About Us section on [topic] with heading, text, and big image below", "elementor.com") },
28915 { text: (0, _wordpress_i18n.__)("Team section with four image boxes showcasing team members", "elementor.com") },
28916 { text: (0, _wordpress_i18n.__)("FAQ section with a toggle widget showcasing FAQs about [topic]", "elementor.com") },
28917 { text: (0, _wordpress_i18n.__)("Gallery section with a carousel displaying three images at once", "elementor.com") },
28918 { text: (0, _wordpress_i18n.__)("Contact section with a form for [topic]", "elementor.com") },
28919 { text: (0, _wordpress_i18n.__)("Client section featuring companies' logos", "elementor.com") },
28920 { text: (0, _wordpress_i18n.__)("Testimonial section with testimonials, each featuring a star rating and an image", "elementor.com") },
28921 { text: (0, _wordpress_i18n.__)("Service section about [topic], showcasing four services with buttons", "elementor.com") },
28922 { text: (0, _wordpress_i18n.__)("Stats section with counters displaying data about [topic]", "elementor.com") },
28923 { text: (0, _wordpress_i18n.__)("Quote section with colored background, featuring a centered quote", "elementor.com") },
28924 { text: (0, _wordpress_i18n.__)("Pricing section for [topic] with a pricing list", "elementor.com") },
28925 { text: (0, _wordpress_i18n.__)("Subscribe section featuring a simple email form, inviting users to stay informed on [topic]", "elementor.com") }
28926 ]);
28927 var IconButtonWithTooltip = function IconButtonWithTooltip(_ref) {
28928 var tooltip = _ref.tooltip;
28929 var props = _objectWithoutProperties$1(_ref, _excluded$1);
28930 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: tooltip }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
28931 component: "span",
28932 sx: { cursor: props.disabled ? "default" : "pointer" }
28933 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, props)));
28934 };
28935 IconButtonWithTooltip.propTypes = {
28936 tooltip: import_prop_types$7.default.string,
28937 disabled: import_prop_types$7.default.bool
28938 };
28939 var BackButton = function BackButton(props) {
28940 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28941 size: "small",
28942 color: "secondary",
28943 tooltip: (0, _wordpress_i18n.__)("Back to results", "elementor")
28944 }, props), /*#__PURE__*/ react.default.createElement(ArrowLeftIcon, null));
28945 };
28946 var EditButton = function EditButton(props) {
28947 return /*#__PURE__*/ react.default.createElement(IconButtonWithTooltip, _extends$1({
28948 size: "small",
28949 color: "primary",
28950 tooltip: (0, _wordpress_i18n.__)("Edit prompt", "elementor")
28951 }, props), /*#__PURE__*/ react.default.createElement(EditIcon$1, null));
28952 };
28953 var GenerateButton = function GenerateButton(props) {
28954 return /*#__PURE__*/ react.default.createElement(GenerateSubmit, _extends$1({
28955 size: "small",
28956 fullWidth: false
28957 }, props), (0, _wordpress_i18n.__)("Generate", "elementor"));
28958 };
28959 var PromptForm = (0, react.forwardRef)(function(_ref2, ref) {
28960 var _attachments$;
28961 var attachments = _ref2.attachments;
28962 var isActive = _ref2.isActive;
28963 var isLoading = _ref2.isLoading;
28964 var _ref2$showActions = _ref2.showActions;
28965 var showActions = _ref2$showActions === void 0 ? false : _ref2$showActions;
28966 var onAttach = _ref2.onAttach;
28967 var onDetach = _ref2.onDetach;
28968 var _onSubmit = _ref2.onSubmit;
28969 var onBack = _ref2.onBack;
28970 var onEdit = _ref2.onEdit;
28971 var _ref2$shouldResetProm = _ref2.shouldResetPrompt;
28972 var shouldResetPrompt = _ref2$shouldResetProm === void 0 ? false : _ref2$shouldResetProm;
28973 var _useState2 = _slicedToArray((0, react.useState)(""), 2);
28974 var prompt = _useState2[0];
28975 var setPrompt = _useState2[1];
28976 (0, react.useEffect)(function() {
28977 if (shouldResetPrompt) setPrompt("");
28978 }, [shouldResetPrompt]);
28979 var _usePromptEnhancer = usePromptEnhancer(prompt, "layout");
28980 var isEnhancing = _usePromptEnhancer.isEnhancing;
28981 var enhance = _usePromptEnhancer.enhance;
28982 var previousPrompt = (0, react.useRef)("");
28983 var attachmentsTypes = useConfig().attachmentsTypes;
28984 var isInputDisabled = isLoading || isEnhancing || !isActive;
28985 var isInputEmpty = "" === prompt && !attachments.length;
28986 var isGenerateDisabled = isInputDisabled || isInputEmpty;
28987 var attachmentsConfig = attachmentsTypes[((_attachments$ = attachments[0]) === null || _attachments$ === void 0 ? void 0 : _attachments$.type) || ""];
28988 var promptSuggestions = (attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.promptSuggestions) || PROMPT_SUGGESTIONS;
28989 var promptPlaceholder = (attachmentsConfig === null || attachmentsConfig === void 0 ? void 0 : attachmentsConfig.promptPlaceholder) || (0, _wordpress_i18n.__)("Press '/' for suggested prompts or describe the layout you want to create", "elementor");
28990 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
28991 component: "form",
28992 onSubmit: function onSubmit(e) {
28993 return _onSubmit(e, prompt);
28994 },
28995 direction: "row",
28996 sx: { p: 3 },
28997 alignItems: "start",
28998 gap: 1
28999 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29000 direction: "row",
29001 alignItems: "start",
29002 flexGrow: 1,
29003 spacing: 2
29004 }, showActions && (isActive ? /*#__PURE__*/ react.default.createElement(BackButton, {
29005 disabled: isLoading || isEnhancing,
29006 onClick: function handleBack() {
29007 setPrompt(previousPrompt.current);
29008 onBack();
29009 }
29010 }) : /*#__PURE__*/ react.default.createElement(EditButton, {
29011 disabled: isLoading,
29012 onClick: function handleEdit() {
29013 previousPrompt.current = prompt;
29014 onEdit();
29015 }
29016 })), /*#__PURE__*/ react.default.createElement(Attachments, {
29017 attachments,
29018 onAttach,
29019 onDetach,
29020 disabled: isInputDisabled
29021 }), /*#__PURE__*/ react.default.createElement(PromptAutocomplete, {
29022 value: prompt,
29023 disabled: isInputDisabled,
29024 onSubmit: function onSubmit(e) {
29025 return _onSubmit(e, prompt);
29026 },
29027 options: promptSuggestions,
29028 onChange: function onChange(_, selectedValue) {
29029 return setPrompt(selectedValue.text + " ");
29030 },
29031 renderInput: function renderInput(params) {
29032 return /*#__PURE__*/ react.default.createElement(PromptAutocomplete.TextInput, _extends$1({}, params, {
29033 ref,
29034 onChange: function onChange(e) {
29035 return setPrompt(e.target.value);
29036 },
29037 placeholder: promptPlaceholder
29038 }));
29039 }
29040 })), /*#__PURE__*/ react.default.createElement(EnhanceButton, {
29041 size: "small",
29042 disabled: isGenerateDisabled || "" === prompt,
29043 isLoading: isEnhancing,
29044 onClick: function onClick() {
29045 return enhance().then(function(_ref3) {
29046 var result = _ref3.result;
29047 return setPrompt(result);
29048 });
29049 }
29050 }), /*#__PURE__*/ react.default.createElement(GenerateButton, { disabled: isGenerateDisabled }));
29051 });
29052 PromptForm.propTypes = {
29053 isActive: import_prop_types$7.default.bool,
29054 onAttach: import_prop_types$7.default.func,
29055 onDetach: import_prop_types$7.default.func,
29056 isLoading: import_prop_types$7.default.bool,
29057 showActions: import_prop_types$7.default.bool,
29058 onSubmit: import_prop_types$7.default.func.isRequired,
29059 onBack: import_prop_types$7.default.func.isRequired,
29060 onEdit: import_prop_types$7.default.func.isRequired,
29061 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType),
29062 shouldResetPrompt: import_prop_types$7.default.bool
29063 };
29064
29065 //#endregion
29066 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-container.js
29067 var ScreenshotContainer = (0, _elementor_ui.styled)(_elementor_ui.Box, { shouldForwardProp: function shouldForwardProp(prop) {
29068 return prop !== "outlineOffset";
29069 } })(function(_ref) {
29070 var theme = _ref.theme;
29071 var selected = _ref.selected;
29072 var height = _ref.height;
29073 var disabled = _ref.disabled;
29074 var _ref$outlineOffset = _ref.outlineOffset;
29075 var outlineOffset = _ref$outlineOffset === void 0 ? "0px" : _ref$outlineOffset;
29076 var outlineColor = selected ? theme.palette.text.primary : theme.palette.text.disabled;
29077 var outline = "2px solid ".concat(outlineColor);
29078 return {
29079 height,
29080 cursor: disabled ? "default" : "pointer",
29081 overflow: "hidden",
29082 boxSizing: "border-box",
29083 backgroundPosition: "top center",
29084 backgroundSize: "100% auto",
29085 backgroundRepeat: "no-repeat",
29086 backgroundColor: theme.palette.common.white,
29087 borderRadius: theme.shape.borderRadius * .5,
29088 outlineOffset,
29089 outline,
29090 opacity: disabled ? "0.4" : "1",
29091 transition: "all 50ms linear",
29092 "&:hover": disabled ? {} : { outlineColor: theme.palette.text.primary }
29093 };
29094 });
29095
29096 //#endregion
29097 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot-unavailable.js
29098 init_extends();
29099 init_defineProperty$1();
29100 function ownKeys$1(e, r) {
29101 var t = Object.keys(e);
29102 if (Object.getOwnPropertySymbols) {
29103 var o = Object.getOwnPropertySymbols(e);
29104 r && (o = o.filter(function(r) {
29105 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29106 })), t.push.apply(t, o);
29107 }
29108 return t;
29109 }
29110 __name(ownKeys$1, "ownKeys");
29111 function _objectSpread$1(e) {
29112 for (var r = 1; r < arguments.length; r++) {
29113 var t = null != arguments[r] ? arguments[r] : {};
29114 r % 2 ? ownKeys$1(Object(t), !0).forEach(function(r) {
29115 _defineProperty$1(e, r, t[r]);
29116 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r) {
29117 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29118 });
29119 }
29120 return e;
29121 }
29122 __name(_objectSpread$1, "_objectSpread");
29123 function ScreenshotUnavailable(props) {
29124 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, _extends$1({}, props, { sx: _objectSpread$1(_objectSpread$1({}, props.sx || {}), {}, {
29125 display: "flex",
29126 alignItems: "center",
29127 justifyContent: "center",
29128 backgroundColor: "background.paper",
29129 color: "text.tertiary",
29130 fontStyle: "italic",
29131 fontSize: "12px",
29132 paddingInline: 12,
29133 textAlign: "center",
29134 lineHeight: 1.5
29135 }) }), (0, _wordpress_i18n.__)("Preview unavailable", "elementor"));
29136 }
29137 ScreenshotUnavailable.propTypes = { sx: import_prop_types$7.default.object };
29138
29139 //#endregion
29140 //#region modules/ai/assets/js/editor/icons/lock-icon.js
29141 init_extends();
29142 var LockIcon = react.default.forwardRef(function(props, ref) {
29143 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29144 fillRule: "evenodd",
29145 clipRule: "evenodd",
29146 d: "M7.8125 11.9996C7.29473 11.9996 6.875 12.4473 6.875 12.9996V18.9996C6.875 19.5519 7.29473 19.9996 7.8125 19.9996H17.1875C17.7053 19.9996 18.125 19.5519 18.125 18.9996V12.9996C18.125 12.4473 17.7053 11.9996 17.1875 11.9996H7.8125ZM5 12.9996C5 11.3428 6.2592 9.99963 7.8125 9.99963H17.1875C18.7408 9.99963 20 11.3428 20 12.9996V18.9996C20 20.6565 18.7408 21.9996 17.1875 21.9996H7.8125C6.2592 21.9996 5 20.6565 5 18.9996V12.9996Z"
29147 }), /*#__PURE__*/ react.default.createElement("path", {
29148 fillRule: "evenodd",
29149 clipRule: "evenodd",
29150 d: "M12.5 3.90527C11.7044 3.90527 10.9413 4.22134 10.3787 4.78395C9.81607 5.34656 9.5 6.10962 9.5 6.90527V10.9053C9.5 11.4576 9.05228 11.9053 8.5 11.9053C7.94772 11.9053 7.5 11.4576 7.5 10.9053V6.90527C7.5 5.57919 8.02678 4.30742 8.96447 3.36974C9.90215 2.43206 11.1739 1.90527 12.5 1.90527C13.8261 1.90527 15.0979 2.43206 16.0355 3.36974C16.9732 4.30742 17.5 5.57919 17.5 6.90527V10.9053C17.5 11.4576 17.0523 11.9053 16.5 11.9053C15.9477 11.9053 15.5 11.4576 15.5 10.9053V6.90527C15.5 6.10962 15.1839 5.34656 14.6213 4.78395C14.0587 4.22134 13.2956 3.90527 12.5 3.90527Z"
29151 }), /*#__PURE__*/ react.default.createElement("path", { d: "M6 12H19V20H6V12Z" }));
29152 });
29153
29154 //#endregion
29155 //#region modules/ai/assets/js/editor/pages/form-layout/components/pro-template-indicator.js
29156 init_slicedToArray();
29157 var popoverId = "e-pro-upgrade-popover";
29158 var StyledContent = (0, _elementor_ui.styled)(_elementor_ui.Paper)(function(_ref) {
29159 var theme = _ref.theme;
29160 return {
29161 position: "relative",
29162 padding: theme.spacing(3),
29163 boxShadow: theme.shadows[4],
29164 zIndex: "9999"
29165 };
29166 });
29167 var StyledArrow = (0, _elementor_ui.styled)(_elementor_ui.Box)(function(_ref2) {
29168 var theme = _ref2.theme;
29169 return {
29170 position: "absolute",
29171 width: theme.spacing(5),
29172 height: theme.spacing(5),
29173 overflow: "hidden",
29174 left: "100% !important",
29175 transform: "translateX(-50%) translateY(-50%) rotate(var(--rotate, 0deg)) !important",
29176 "&::after": {
29177 backgroundColor: theme.palette.background.paper,
29178 content: "\"\"",
29179 display: "block",
29180 position: "absolute",
29181 width: theme.spacing(2.5),
29182 height: theme.spacing(2.5),
29183 top: "50%",
29184 left: "50%",
29185 transform: "translateX(-50%) translateY(-50%) rotate(45deg)",
29186 boxShadow: "5px -5px 5px 0px rgba(0, 0, 0, 0.2)",
29187 backgroundImage: "linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05))"
29188 }
29189 };
29190 });
29191 var ProTemplateIndicator = function ProTemplateIndicator() {
29192 var actionUrl = "https://go.elementor.com/go-pro-ai/";
29193 var actionLabel = (0, _wordpress_i18n.__)("Go Pro", "elementor");
29194 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
29195 var isPopoverOpen = _useState2[0];
29196 var setIsPopoverOpen = _useState2[1];
29197 var anchorEl = (0, react.useRef)(null);
29198 var arrowEl = (0, react.useRef)(null);
29199 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
29200 flexDirection: "row-reverse",
29201 component: "span",
29202 display: "flex",
29203 onMouseLeave: function hidePopover() {
29204 return setIsPopoverOpen(false);
29205 },
29206 alignItems: "center"
29207 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
29208 ref: anchorEl,
29209 onMouseEnter: function showPopover() {
29210 return setIsPopoverOpen(true);
29211 },
29212 onClick: function onClick(e) {
29213 return e.stopPropagation();
29214 },
29215 "aria-owns": isPopoverOpen ? popoverId : void 0,
29216 "aria-haspopup": "true",
29217 sx: {
29218 m: 1,
29219 "&:hover": { backgroundColor: "action.selected" }
29220 }
29221 }, /*#__PURE__*/ react.default.createElement(LockIcon, { sx: { color: "text.primary" } })), /*#__PURE__*/ react.default.createElement(_elementor_ui.Popper, {
29222 open: isPopoverOpen,
29223 popperOptions: {
29224 placement: "left-start",
29225 modifiers: [{
29226 name: "arrow",
29227 enabled: true,
29228 options: {
29229 element: arrowEl.current,
29230 padding: 5
29231 }
29232 }, {
29233 name: "offset",
29234 options: { offset: [0, 10] }
29235 }]
29236 },
29237 anchorEl: anchorEl.current,
29238 sx: {
29239 zIndex: "9999",
29240 maxWidth: 300
29241 }
29242 }, /*#__PURE__*/ react.default.createElement(StyledContent, null, /*#__PURE__*/ react.default.createElement(StyledArrow, { ref: arrowEl }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Stack, {
29243 alignItems: "start",
29244 spacing: 2
29245 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Chip, {
29246 color: "promotion",
29247 variant: "outlined",
29248 size: "small",
29249 label: (0, _wordpress_i18n.__)("Pro", "elementor"),
29250 icon: /*#__PURE__*/ react.default.createElement(LockIcon, null)
29251 }), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("This result includes an Elementor Pro widget that's not available with your current plan. Upgrade to use all the widgets in this result.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, {
29252 variant: "contained",
29253 color: "promotion",
29254 size: "small",
29255 href: actionUrl,
29256 target: "_blank",
29257 sx: { alignSelf: "flex-end" }
29258 }, actionLabel)))));
29259 };
29260
29261 //#endregion
29262 //#region modules/ai/assets/js/editor/pages/form-layout/components/template-badge.js
29263 var TemplateBadge = function TemplateBadge(props) {
29264 var hasPro = useConfig().hasPro;
29265 if ("Pro" === props.type && !hasPro) return /*#__PURE__*/ react.default.createElement(ProTemplateIndicator, null);
29266 return null;
29267 };
29268 TemplateBadge.propTypes = { type: import_prop_types$7.default.string };
29269
29270 //#endregion
29271 //#region modules/ai/assets/js/editor/pages/form-layout/components/screenshot.js
29272 init_defineProperty$1();
29273 function ownKeys(e, r) {
29274 var t = Object.keys(e);
29275 if (Object.getOwnPropertySymbols) {
29276 var o = Object.getOwnPropertySymbols(e);
29277 r && (o = o.filter(function(r) {
29278 return Object.getOwnPropertyDescriptor(e, r).enumerable;
29279 })), t.push.apply(t, o);
29280 }
29281 return t;
29282 }
29283 function _objectSpread(e) {
29284 for (var r = 1; r < arguments.length; r++) {
29285 var t = null != arguments[r] ? arguments[r] : {};
29286 r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
29287 _defineProperty$1(e, r, t[r]);
29288 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
29289 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
29290 });
29291 }
29292 return e;
29293 }
29294 var SCREENSHOT_HEIGHT = "138px";
29295 var Screenshot = function Screenshot(_ref) {
29296 var url = _ref.url;
29297 var type = _ref.type;
29298 var _ref$isLoading = _ref.isLoading;
29299 var isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading;
29300 var _ref$isSelected = _ref.isSelected;
29301 var isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected;
29302 var isPlaceholder = _ref.isPlaceholder;
29303 var disabled = _ref.disabled;
29304 var onClick = _ref.onClick;
29305 var _ref$sx = _ref.sx;
29306 var sx = _ref$sx === void 0 ? {} : _ref$sx;
29307 var outlineOffset = _ref.outlineOffset;
29308 if (isPlaceholder) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: _objectSpread({ height: SCREENSHOT_HEIGHT }, sx) });
29309 if (isLoading) return /*#__PURE__*/ react.default.createElement(_elementor_ui.Skeleton, {
29310 width: "100%",
29311 animation: "wave",
29312 variant: "rounded",
29313 height: SCREENSHOT_HEIGHT,
29314 sx
29315 });
29316 if (!url) return /*#__PURE__*/ react.default.createElement(ScreenshotUnavailable, {
29317 selected: isSelected,
29318 disabled,
29319 sx,
29320 onClick,
29321 height: SCREENSHOT_HEIGHT,
29322 outlineOffset
29323 });
29324 return /*#__PURE__*/ react.default.createElement(ScreenshotContainer, {
29325 selected: isSelected,
29326 disabled,
29327 sx: _objectSpread({ backgroundImage: "url('".concat(url, "')") }, sx),
29328 onClick,
29329 height: SCREENSHOT_HEIGHT,
29330 outlineOffset
29331 }, /*#__PURE__*/ react.default.createElement(TemplateBadge, { type }));
29332 };
29333 Screenshot.propTypes = {
29334 isSelected: import_prop_types$7.default.bool,
29335 isLoading: import_prop_types$7.default.bool,
29336 isPlaceholder: import_prop_types$7.default.bool,
29337 disabled: import_prop_types$7.default.bool,
29338 onClick: import_prop_types$7.default.func.isRequired,
29339 url: import_prop_types$7.default.string,
29340 type: import_prop_types$7.default.string,
29341 sx: import_prop_types$7.default.object,
29342 outlineOffset: import_prop_types$7.default.string
29343 };
29344
29345 //#endregion
29346 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-layout-prompt.js
29347 init_api();
29348 init_use_prompt();
29349 var useLayoutPrompt = function useLayoutPrompt(type, initialValue) {
29350 return usePrompt(function(requestBody, signal) {
29351 requestBody.variationType = type;
29352 return generateLayout(requestBody, signal);
29353 }, initialValue);
29354 };
29355
29356 //#endregion
29357 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshot.js
29358 init_asyncToGenerator();
29359 init_slicedToArray();
29360 var ERROR_INITIAL_VALUE = "";
29361 var useScreenshot = function useScreenshot(type, onData) {
29362 var _useState2 = _slicedToArray((0, react.useState)(ERROR_INITIAL_VALUE), 2);
29363 var error = _useState2[0];
29364 var setError = _useState2[1];
29365 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
29366 var isLoading = _useState4[0];
29367 var setIsLoading = _useState4[1];
29368 var layoutData = useLayoutPrompt(type, null);
29369 return {
29370 generate: function generate(requestBody, signal) {
29371 setIsLoading(true);
29372 setError(ERROR_INITIAL_VALUE);
29373 return layoutData.send(requestBody, signal).then(/*#__PURE__*/ function() {
29374 var _ref = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(data) {
29375 var createdScreenshot;
29376 return import_regenerator$2.default.wrap(function(_context) {
29377 while (1) switch (_context.prev = _context.next) {
29378 case 0:
29379 _context.next = 1;
29380 return onData(data.result);
29381 case 1:
29382 createdScreenshot = _context.sent;
29383 createdScreenshot.sendUsageData = function() {
29384 return layoutData.sendUsageData(data);
29385 };
29386 createdScreenshot.baseTemplateId = data.baseTemplateId;
29387 createdScreenshot.type = data.type;
29388 return _context.abrupt("return", createdScreenshot);
29389 case 2:
29390 case "end": return _context.stop();
29391 }
29392 }, _callee);
29393 }));
29394 return function(_x) {
29395 return _ref.apply(this, arguments);
29396 };
29397 }()).catch(function(err) {
29398 setError(err.extra_data ? err : err.message || err);
29399 throw err;
29400 }).finally(function() {
29401 return setIsLoading(false);
29402 });
29403 },
29404 error,
29405 isLoading
29406 };
29407 };
29408
29409 //#endregion
29410 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-screenshots.js
29411 init_asyncToGenerator();
29412 init_slicedToArray();
29413 init_requests_ids();
29414 var PENDING_VALUE = { isPending: true };
29415 var useScreenshots = function useScreenshots(_ref) {
29416 var onData = _ref.onData;
29417 var _useState2 = _slicedToArray((0, react.useState)([]), 2);
29418 var screenshots = _useState2[0];
29419 var setScreenshots = _useState2[1];
29420 /**
29421 * The ids for each request are:
29422 * - editorSessionId: a unique id for each editor opening
29423 * - sessionId: a unique id for each session. (open the AI builder)
29424 * - generateId: a unique id for each generate request. (prompt change)
29425 * - batchId: a unique id for each batch of generate requests. (generate, regenerate)
29426 * - requestId: a unique id for each generate request.
29427 */
29428 var currentContext = useConfig().currentContext;
29429 var _useRequestIds = useRequestIds();
29430 var editorSessionId = _useRequestIds.editorSessionId;
29431 var sessionId = _useRequestIds.sessionId;
29432 var setRequest = _useRequestIds.setRequest;
29433 var setBatch = _useRequestIds.setBatch;
29434 var setGenerate = _useRequestIds.setGenerate;
29435 var generateIdRef = (0, react.useRef)("");
29436 var batchId = setBatch();
29437 var screenshotsData = [
29438 useScreenshot(0, onData),
29439 useScreenshot(1, onData),
29440 useScreenshot(2, onData)
29441 ];
29442 var screenshotsGroupCount = screenshotsData.length;
29443 var error = screenshotsData.every(function(s) {
29444 return s === null || s === void 0 ? void 0 : s.error;
29445 }) ? screenshotsData[0].error : "";
29446 var isLoading = screenshotsData.some(function(s) {
29447 return s === null || s === void 0 ? void 0 : s.isLoading;
29448 });
29449 var abortController = (0, react.useRef)(null);
29450 var abort = function abort() {
29451 var _abortController$curr;
29452 return (_abortController$curr = abortController.current) === null || _abortController$curr === void 0 ? void 0 : _abortController$curr.abort();
29453 };
29454 var createScreenshots = /*#__PURE__*/ function() {
29455 var _ref2 = _asyncToGenerator$1(/*#__PURE__*/ import_regenerator$2.default.mark(function _callee(prompt, attachments) {
29456 var onGenerate;
29457 var onError;
29458 var promises;
29459 var results;
29460 var isAllFailed;
29461 return import_regenerator$2.default.wrap(function(_context) {
29462 while (1) switch (_context.prev = _context.next) {
29463 case 0:
29464 abortController.current = new AbortController();
29465 onGenerate = function onGenerate(screenshot) {
29466 setScreenshots(function(prev) {
29467 var updatedData = _toConsumableArray(prev);
29468 var pendingIndex = updatedData.indexOf(PENDING_VALUE);
29469 updatedData[pendingIndex] = screenshot;
29470 return updatedData;
29471 });
29472 return true;
29473 };
29474 onError = function onError() {
29475 setScreenshots(function(prev) {
29476 var updatedData = _toConsumableArray(prev);
29477 var pendingIndex = updatedData.lastIndexOf(PENDING_VALUE);
29478 updatedData[pendingIndex] = { isError: true };
29479 return updatedData;
29480 });
29481 return false;
29482 };
29483 promises = screenshotsData.map(function(_ref3) {
29484 var generate = _ref3.generate;
29485 return generate({
29486 prompt,
29487 prevGeneratedIds: screenshots.map(function(screenshot) {
29488 return screenshot.baseTemplateId || "";
29489 }),
29490 currentContext,
29491 ids: {
29492 editorSessionId: editorSessionId.current,
29493 sessionId: sessionId.current,
29494 generateId: generateIdRef.current,
29495 batchId: batchId.current,
29496 requestId: setRequest().current
29497 },
29498 attachments: attachments.map(function(_ref4) {
29499 return {
29500 type: _ref4.type,
29501 content: _ref4.content,
29502 label: _ref4.label,
29503 source: _ref4.source
29504 };
29505 })
29506 }, abortController.current.signal).then(onGenerate).catch(onError);
29507 });
29508 _context.next = 1;
29509 return Promise.all(promises);
29510 case 1:
29511 results = _context.sent;
29512 isAllFailed = results.every(function(value) {
29513 return false === value;
29514 });
29515 if (isAllFailed) setScreenshots(function(prev) {
29516 var updatedData = _toConsumableArray(prev);
29517 updatedData.splice(screenshotsGroupCount * -1);
29518 return updatedData;
29519 });
29520 case 2:
29521 case "end": return _context.stop();
29522 }
29523 }, _callee);
29524 }));
29525 return function createScreenshots(_x, _x2) {
29526 return _ref2.apply(this, arguments);
29527 };
29528 }();
29529 return {
29530 generate: function generate(prompt, attachments) {
29531 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29532 generateIdRef.current = setGenerate().current;
29533 setScreenshots(placeholders);
29534 createScreenshots(prompt, attachments);
29535 },
29536 regenerate: function regenerate(prompt, attachments) {
29537 var placeholders = Array(screenshotsGroupCount).fill(PENDING_VALUE);
29538 setScreenshots(function(prev) {
29539 return [].concat(_toConsumableArray(prev), _toConsumableArray(placeholders));
29540 });
29541 createScreenshots(prompt, attachments);
29542 },
29543 screenshots,
29544 isLoading,
29545 error,
29546 abort
29547 };
29548 };
29549
29550 //#endregion
29551 //#region modules/ai/assets/js/editor/pages/form-layout/hooks/use-slider.js
29552 init_slicedToArray();
29553 var SCREENSHOTS_PER_PAGE = 3;
29554 var useSlider = function useSlider() {
29555 var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29556 var _ref$slidesCount = _ref.slidesCount;
29557 var slidesCount = _ref$slidesCount === void 0 ? 0 : _ref$slidesCount;
29558 var _ref$slidesPerPage = _ref.slidesPerPage;
29559 var slidesPerPage = _ref$slidesPerPage === void 0 ? 3 : _ref$slidesPerPage;
29560 var _ref$gapPercentage = _ref.gapPercentage;
29561 var gapPercentage = _ref$gapPercentage === void 0 ? 2 : _ref$gapPercentage;
29562 var _useState2 = _slicedToArray((0, react.useState)(1), 2);
29563 var currentPage = _useState2[0];
29564 var setCurrentPage = _useState2[1];
29565 var slideWidthPercentage = (100 - gapPercentage * (slidesPerPage - 1)) / slidesPerPage;
29566 var offsetXPercentage = (slideWidthPercentage + gapPercentage) * slidesPerPage * (currentPage - 1) * -1;
29567 var pagesCount = Math.ceil(slidesCount / slidesPerPage);
29568 (0, react.useEffect)(function() {
29569 if (currentPage > 1 && currentPage > pagesCount) setCurrentPage(pagesCount);
29570 }, [pagesCount]);
29571 return {
29572 currentPage,
29573 setCurrentPage,
29574 pagesCount,
29575 slidesPerPage,
29576 gapPercentage,
29577 offsetXPercentage,
29578 slideWidthPercentage
29579 };
29580 };
29581
29582 //#endregion
29583 //#region modules/ai/assets/js/editor/icons/minimize-diagonal-icon.js
29584 init_extends();
29585 var MinimizeDiagonalIcon = react.default.forwardRef(function(props, ref) {
29586 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29587 fillRule: "evenodd",
29588 clipRule: "evenodd",
29589 d: "M3.46967 3.46967C3.76256 3.17678 4.23744 3.17678 4.53033 3.46967L9.25 8.18934V6C9.25 5.58579 9.58579 5.25 10 5.25C10.4142 5.25 10.75 5.58579 10.75 6V10C10.75 10.4142 10.4142 10.75 10 10.75H6C5.58579 10.75 5.25 10.4142 5.25 10C5.25 9.58579 5.58579 9.25 6 9.25H8.18934L3.46967 4.53033C3.17678 4.23744 3.17678 3.76256 3.46967 3.46967ZM14 13.25H18C18.4142 13.25 18.75 13.5858 18.75 14C18.75 14.4142 18.4142 14.75 18 14.75H15.8107L20.5303 19.4697C20.8232 19.7626 20.8232 20.2374 20.5303 20.5303C20.2374 20.8232 19.7626 20.8232 19.4697 20.5303L14.75 15.8107V18C14.75 18.4142 14.4142 18.75 14 18.75C13.5858 18.75 13.25 18.4142 13.25 18V14C13.25 13.5858 13.5858 13.25 14 13.25Z"
29590 }));
29591 });
29592
29593 //#endregion
29594 //#region modules/ai/assets/js/editor/icons/expand-diagonal-icon.js
29595 init_extends();
29596 var ExpandDiagonalIcon = react.default.forwardRef(function(props, ref) {
29597 return /*#__PURE__*/ react.default.createElement(_elementor_ui.SvgIcon, _extends$1({ viewBox: "0 0 24 24" }, props, { ref }), /*#__PURE__*/ react.default.createElement("path", {
29598 fillRule: "evenodd",
29599 clipRule: "evenodd",
29600 d: "M4 3.25H8C8.41421 3.25 8.75 3.58579 8.75 4C8.75 4.41421 8.41421 4.75 8 4.75H5.81066L10.5303 9.46967C10.8232 9.76256 10.8232 10.2374 10.5303 10.5303C10.2374 10.8232 9.76256 10.8232 9.46967 10.5303L4.75 5.81066V8C4.75 8.41421 4.41421 8.75 4 8.75C3.58579 8.75 3.25 8.41421 3.25 8V4C3.25 3.58579 3.58579 3.25 4 3.25ZM13.4697 13.4697C13.7626 13.1768 14.2374 13.1768 14.5303 13.4697L19.25 18.1893V16C19.25 15.5858 19.5858 15.25 20 15.25C20.4142 15.25 20.75 15.5858 20.75 16V20C20.75 20.4142 20.4142 20.75 20 20.75H16C15.5858 20.75 15.25 20.4142 15.25 20C15.25 19.5858 15.5858 19.25 16 19.25H18.1893L13.4697 14.5303C13.1768 14.2374 13.1768 13.7626 13.4697 13.4697Z"
29601 }));
29602 });
29603
29604 //#endregion
29605 //#region modules/ai/assets/js/editor/pages/form-layout/components/attachments/prompt-power-notice.js
29606 init_use_introduction();
29607 var PromptPowerNotice = function PromptPowerNotice() {
29608 var _useIntroduction = useIntroduction("e-ai-builder-attachments-power");
29609 var isViewed = _useIntroduction.isViewed;
29610 var markAsViewed = _useIntroduction.markAsViewed;
29611 if (isViewed) return null;
29612 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
29613 pt: 2,
29614 px: 2,
29615 pb: 0
29616 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Alert, {
29617 severity: "info",
29618 onClose: function onClose() {
29619 return markAsViewed();
29620 }
29621 }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29622 variant: "body2",
29623 display: "inline-block",
29624 sx: { paddingInlineEnd: 1 }
29625 }, (0, _wordpress_i18n.__)("You’ve got the power.", "elementor")), /*#__PURE__*/ react.default.createElement(_elementor_ui.Typography, {
29626 variant: "body2",
29627 display: "inline-block"
29628 }, (0, _wordpress_i18n.__)("Craft your prompt to affect content, images and/or colors - whichever you decide.", "elementor"))));
29629 };
29630
29631 //#endregion
29632 //#region node_modules/validator/lib/util/assertString.js
29633 var require_assertString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29634 Object.defineProperty(exports, "__esModule", { value: true });
29635 exports.default = assertString;
29636 function assertString(input) {
29637 if (input === void 0 || input === null) throw new TypeError("Expected a string but received a ".concat(input));
29638 if (input.constructor.name !== "String") throw new TypeError("Expected a string but received a ".concat(input.constructor.name));
29639 }
29640 module.exports = exports.default;
29641 module.exports.default = exports.default;
29642 }));
29643
29644 //#endregion
29645 //#region node_modules/validator/lib/util/checkHost.js
29646 var require_checkHost = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29647 Object.defineProperty(exports, "__esModule", { value: true });
29648 exports.default = checkHost;
29649 function isRegExp(obj) {
29650 return Object.prototype.toString.call(obj) === "[object RegExp]";
29651 }
29652 function checkHost(host, matches) {
29653 for (var i = 0; i < matches.length; i++) {
29654 var match = matches[i];
29655 if (host === match || isRegExp(match) && match.test(host)) return true;
29656 }
29657 return false;
29658 }
29659 module.exports = exports.default;
29660 module.exports.default = exports.default;
29661 }));
29662
29663 //#endregion
29664 //#region node_modules/validator/lib/util/includesString.js
29665 var require_includesString = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29666 Object.defineProperty(exports, "__esModule", { value: true });
29667 exports.default = void 0;
29668 var includes = function includes(str, val) {
29669 return str.indexOf(val) !== -1;
29670 };
29671 exports.default = includes;
29672 module.exports = exports.default;
29673 module.exports.default = exports.default;
29674 }));
29675
29676 //#endregion
29677 //#region node_modules/validator/lib/util/merge.js
29678 var require_merge = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29679 Object.defineProperty(exports, "__esModule", { value: true });
29680 exports.default = merge;
29681 function merge() {
29682 var obj = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
29683 var defaults = arguments.length > 1 ? arguments[1] : void 0;
29684 for (var key in defaults) if (typeof obj[key] === "undefined") obj[key] = defaults[key];
29685 return obj;
29686 }
29687 module.exports = exports.default;
29688 module.exports.default = exports.default;
29689 }));
29690
29691 //#endregion
29692 //#region node_modules/validator/lib/isFQDN.js
29693 var require_isFQDN = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29694 Object.defineProperty(exports, "__esModule", { value: true });
29695 exports.default = isFQDN;
29696 var _assertString = _interopRequireDefault(require_assertString());
29697 var _merge = _interopRequireDefault(require_merge());
29698 function _interopRequireDefault(e) {
29699 return e && e.__esModule ? e : { default: e };
29700 }
29701 var default_fqdn_options = {
29702 require_tld: true,
29703 allow_underscores: false,
29704 allow_trailing_dot: false,
29705 allow_numeric_tld: false,
29706 allow_wildcard: false,
29707 ignore_max_length: false
29708 };
29709 function isFQDN(str, options) {
29710 (0, _assertString.default)(str);
29711 options = (0, _merge.default)(options, default_fqdn_options);
29712 if (options.allow_trailing_dot && str[str.length - 1] === ".") str = str.substring(0, str.length - 1);
29713 if (options.allow_wildcard === true && str.indexOf("*.") === 0) str = str.substring(2);
29714 var parts = str.split(".");
29715 var tld = parts[parts.length - 1];
29716 if (options.require_tld) {
29717 if (parts.length < 2) return false;
29718 if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) return false;
29719 if (/\s/.test(tld)) return false;
29720 }
29721 if (!options.allow_numeric_tld && /^\d+$/.test(tld)) return false;
29722 return parts.every(function(part) {
29723 if (part.length > 63 && !options.ignore_max_length) return false;
29724 if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) return false;
29725 if (/[\uff01-\uff5e]/.test(part)) return false;
29726 if (/^-|-$/.test(part)) return false;
29727 if (!options.allow_underscores && /_/.test(part)) return false;
29728 return true;
29729 });
29730 }
29731 module.exports = exports.default;
29732 module.exports.default = exports.default;
29733 }));
29734
29735 //#endregion
29736 //#region node_modules/validator/lib/isIP.js
29737 var require_isIP = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29738 Object.defineProperty(exports, "__esModule", { value: true });
29739 exports.default = isIP;
29740 var _assertString = _interopRequireDefault(require_assertString());
29741 function _interopRequireDefault(e) {
29742 return e && e.__esModule ? e : { default: e };
29743 }
29744 function _typeof(o) {
29745 "@babel/helpers - typeof";
29746 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
29747 return typeof o;
29748 } : function(o) {
29749 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
29750 }, _typeof(o);
29751 }
29752 /**
29753 11.3. Examples
29754
29755 The following addresses
29756
29757 fe80::1234 (on the 1st link of the node)
29758 ff02::5678 (on the 5th link of the node)
29759 ff08::9abc (on the 10th organization of the node)
29760
29761 would be represented as follows:
29762
29763 fe80::1234%1
29764 ff02::5678%5
29765 ff08::9abc%10
29766
29767 (Here we assume a natural translation from a zone index to the
29768 <zone_id> part, where the Nth zone of any scope is translated into
29769 "N".)
29770
29771 If we use interface names as <zone_id>, those addresses could also be
29772 represented as follows:
29773
29774 fe80::1234%ne0
29775 ff02::5678%pvc1.3
29776 ff08::9abc%interface10
29777
29778 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs
29779 to the 5th link, and "interface10" belongs to the 10th organization.
29780 * * */
29781 var IPv4SegmentFormat = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
29782 var IPv4AddressFormat = "(".concat(IPv4SegmentFormat, "[.]){3}").concat(IPv4SegmentFormat);
29783 var IPv4AddressRegExp = new RegExp("^".concat(IPv4AddressFormat, "$"));
29784 var IPv6SegmentFormat = "(?:[0-9a-fA-F]{1,4})";
29785 var IPv6AddressRegExp = new RegExp("^(" + "(?:".concat(IPv6SegmentFormat, ":){7}(?:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){6}(?:").concat(IPv4AddressFormat, "|:").concat(IPv6SegmentFormat, "|:)|") + "(?:".concat(IPv6SegmentFormat, ":){5}(?::").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,2}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){4}(?:(:").concat(IPv6SegmentFormat, "){0,1}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,3}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){3}(?:(:").concat(IPv6SegmentFormat, "){0,2}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,4}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){2}(?:(:").concat(IPv6SegmentFormat, "){0,3}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,5}|:)|") + "(?:".concat(IPv6SegmentFormat, ":){1}(?:(:").concat(IPv6SegmentFormat, "){0,4}:").concat(IPv4AddressFormat, "|(:").concat(IPv6SegmentFormat, "){1,6}|:)|") + "(?::((?::".concat(IPv6SegmentFormat, "){0,5}:").concat(IPv4AddressFormat, "|(?::").concat(IPv6SegmentFormat, "){1,7}|:))") + ")(%[0-9a-zA-Z.]{1,})?$");
29786 function isIP(ipAddress) {
29787 var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
29788 (0, _assertString.default)(ipAddress);
29789 var version = (_typeof(options) === "object" ? options.version : arguments[1]) || "";
29790 if (!version) return isIP(ipAddress, { version: 4 }) || isIP(ipAddress, { version: 6 });
29791 if (version.toString() === "4") return IPv4AddressRegExp.test(ipAddress);
29792 if (version.toString() === "6") return IPv6AddressRegExp.test(ipAddress);
29793 return false;
29794 }
29795 module.exports = exports.default;
29796 module.exports.default = exports.default;
29797 }));
29798
29799 //#endregion
29800 //#region node_modules/validator/lib/isURL.js
29801 var require_isURL = /* @__PURE__ */ __commonJSMin(((exports, module) => {
29802 Object.defineProperty(exports, "__esModule", { value: true });
29803 exports.default = isURL;
29804 var _assertString = _interopRequireDefault(require_assertString());
29805 var _checkHost = _interopRequireDefault(require_checkHost());
29806 var _includesString = _interopRequireDefault(require_includesString());
29807 var _isFQDN = _interopRequireDefault(require_isFQDN());
29808 var _isIP = _interopRequireDefault(require_isIP());
29809 var _merge = _interopRequireDefault(require_merge());
29810 function _interopRequireDefault(e) {
29811 return e && e.__esModule ? e : { default: e };
29812 }
29813 function _slicedToArray(r, e) {
29814 return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
29815 }
29816 function _nonIterableRest() {
29817 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
29818 }
29819 function _unsupportedIterableToArray(r, a) {
29820 if (r) {
29821 if ("string" == typeof r) return _arrayLikeToArray(r, a);
29822 var t = {}.toString.call(r).slice(8, -1);
29823 return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
29824 }
29825 }
29826 function _arrayLikeToArray(r, a) {
29827 (null == a || a > r.length) && (a = r.length);
29828 for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
29829 return n;
29830 }
29831 function _iterableToArrayLimit(r, l) {
29832 var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
29833 if (null != t) {
29834 var e;
29835 var n;
29836 var i;
29837 var u;
29838 var a = [];
29839 var f = !0;
29840 var o = !1;
29841 try {
29842 if (i = (t = t.call(r)).next, 0 === l) {
29843 if (Object(t) !== t) return;
29844 f = !1;
29845 } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
29846 } catch (r) {
29847 o = !0, n = r;
29848 } finally {
29849 try {
29850 if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
29851 } finally {
29852 if (o) throw n;
29853 }
29854 }
29855 return a;
29856 }
29857 }
29858 function _arrayWithHoles(r) {
29859 if (Array.isArray(r)) return r;
29860 }
29861 var default_url_options = {
29862 protocols: [
29863 "http",
29864 "https",
29865 "ftp"
29866 ],
29867 require_tld: true,
29868 require_protocol: false,
29869 require_host: true,
29870 require_port: false,
29871 require_valid_protocol: true,
29872 allow_underscores: false,
29873 allow_trailing_dot: false,
29874 allow_protocol_relative_urls: false,
29875 allow_fragments: true,
29876 allow_query_components: true,
29877 validate_length: true,
29878 max_allowed_length: 2084
29879 };
29880 var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/;
29881 function isURL(url, options) {
29882 (0, _assertString.default)(url);
29883 if (!url || /[\s<>]/.test(url)) return false;
29884 if (url.indexOf("mailto:") === 0) return false;
29885 options = (0, _merge.default)(options, default_url_options);
29886 if (options.validate_length && url.length > options.max_allowed_length) return false;
29887 if (!options.allow_fragments && (0, _includesString.default)(url, "#")) return false;
29888 if (!options.allow_query_components && ((0, _includesString.default)(url, "?") || (0, _includesString.default)(url, "&"))) return false;
29889 var protocol;
29890 var auth;
29891 var host;
29892 var hostname;
29893 var port;
29894 var port_str;
29895 var split = url.split("#");
29896 var ipv6;
29897 url = split.shift();
29898 split = url.split("?");
29899 url = split.shift();
29900 var protocol_match = url.match(/^([a-z][a-z0-9+\-.]*):/i);
29901 var had_explicit_protocol = false;
29902 var cleanUpProtocol = function cleanUpProtocol(potential_protocol) {
29903 had_explicit_protocol = true;
29904 protocol = potential_protocol.toLowerCase();
29905 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) return false;
29906 return url.substring(protocol_match[0].length);
29907 };
29908 if (protocol_match) {
29909 var potential_protocol = protocol_match[1];
29910 var after_colon = url.substring(protocol_match[0].length);
29911 if (!(after_colon.slice(0, 2) === "//")) {
29912 var first_slash_position = after_colon.indexOf("/");
29913 var before_slash = first_slash_position === -1 ? after_colon : after_colon.substring(0, first_slash_position);
29914 var at_position = before_slash.indexOf("@");
29915 if (at_position !== -1) {
29916 var before_at = before_slash.substring(0, at_position);
29917 if (/^[a-zA-Z0-9\-_.%:]*$/.test(before_at)) {
29918 if (options.require_protocol) return false;
29919 } else {
29920 url = cleanUpProtocol(potential_protocol);
29921 if (url === false) return false;
29922 }
29923 } else if (/^[0-9]/.test(after_colon)) {
29924 if (options.require_protocol) return false;
29925 } else {
29926 url = cleanUpProtocol(potential_protocol);
29927 if (url === false) return false;
29928 }
29929 } else {
29930 url = cleanUpProtocol(potential_protocol);
29931 if (url === false) return false;
29932 }
29933 } else if (options.require_protocol) return false;
29934 if (url.slice(0, 2) === "//") {
29935 if (!had_explicit_protocol && !options.allow_protocol_relative_urls) return false;
29936 url = url.slice(2);
29937 }
29938 if (url === "") return false;
29939 split = url.split("/");
29940 url = split.shift();
29941 if (url === "" && !options.require_host) return true;
29942 split = url.split("@");
29943 if (split.length > 1) {
29944 if (options.disallow_auth) return false;
29945 if (split[0] === "") return false;
29946 auth = split.shift();
29947 if (auth.indexOf(":") >= 0 && auth.split(":").length > 2) return false;
29948 var _auth$split2 = _slicedToArray(auth.split(":"), 2);
29949 var user = _auth$split2[0];
29950 var password = _auth$split2[1];
29951 if (user === "" && password === "") return false;
29952 }
29953 hostname = split.join("@");
29954 port_str = null;
29955 ipv6 = null;
29956 var ipv6_match = hostname.match(wrapped_ipv6);
29957 if (ipv6_match) {
29958 host = "";
29959 ipv6 = ipv6_match[1];
29960 port_str = ipv6_match[2] || null;
29961 } else {
29962 split = hostname.split(":");
29963 host = split.shift();
29964 if (split.length) port_str = split.join(":");
29965 }
29966 if (port_str !== null && port_str.length > 0) {
29967 port = parseInt(port_str, 10);
29968 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) return false;
29969 } else if (options.require_port) return false;
29970 if (options.host_whitelist) return (0, _checkHost.default)(host, options.host_whitelist);
29971 if (host === "" && !options.require_host) return true;
29972 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) return false;
29973 host = host || ipv6;
29974 if (options.host_blacklist && (0, _checkHost.default)(host, options.host_blacklist)) return false;
29975 return true;
29976 }
29977 module.exports = exports.default;
29978 module.exports.default = exports.default;
29979 }));
29980
29981 //#endregion
29982 //#region modules/ai/assets/js/editor/pages/form-layout/index.js
29983 init_objectWithoutProperties$1();
29984 init_slicedToArray();
29985 init_extends();
29986 init_prompt_error_message();
29987 var import_isURL = /* @__PURE__ */ __toESM(require_isURL());
29988 init_voice_promotion_alert();
29989 var _excluded = ["children"];
29990 var DirectionalMinimizeDiagonalIcon = (0, _elementor_ui.withDirection)(MinimizeDiagonalIcon);
29991 var DirectionalExpandDiagonalIcon = (0, _elementor_ui.withDirection)(ExpandDiagonalIcon);
29992 /**
29993 * @typedef {Object} Attachment
29994 * @property {('json')} type - The type of the attachment, currently only `json` is supported.
29995 * @property {string} previewHTML - HTML content as a string, representing a preview.
29996 * @property {string} content - Actual content of the attachment as a string.
29997 * @property {string} label - Label for the attachment.
29998 */
29999 var RegenerateButton = function RegenerateButton(props) {
30000 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30001 size: "small",
30002 color: "secondary",
30003 startIcon: /*#__PURE__*/ react.default.createElement(RefreshIcon, null)
30004 }, props), (0, _wordpress_i18n.__)("Regenerate", "elementor"));
30005 };
30006 var UseLayoutButton = function UseLayoutButton(props) {
30007 return /*#__PURE__*/ react.default.createElement(_elementor_ui.Button, _extends$1({
30008 size: "small",
30009 variant: "contained"
30010 }, props), (0, _wordpress_i18n.__)("Use Layout", "elementor"));
30011 };
30012 UseLayoutButton.propTypes = { sx: import_prop_types$7.default.object };
30013 var isRegenerateButtonDisabled = function isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive) {
30014 if (isLoading || isPromptFormActive) return true;
30015 return screenshots.length >= 3 * 5;
30016 };
30017 var FormLayout = function FormLayout(_ref) {
30018 var _screenshots$selected;
30019 var _screenshots$2;
30020 var _ref$DialogHeaderProp = _ref.DialogHeaderProps;
30021 var DialogHeaderProps = _ref$DialogHeaderProp === void 0 ? {} : _ref$DialogHeaderProp;
30022 var _ref$DialogContentPro = _ref.DialogContentProps;
30023 var DialogContentProps = _ref$DialogContentPro === void 0 ? {} : _ref$DialogContentPro;
30024 var initialAttachments = _ref.attachments;
30025 var _useConfig = useConfig();
30026 var attachmentsTypes = _useConfig.attachmentsTypes;
30027 var onData = _useConfig.onData;
30028 var onInsert = _useConfig.onInsert;
30029 var onSelect = _useConfig.onSelect;
30030 var onClose = _useConfig.onClose;
30031 var onGenerate = _useConfig.onGenerate;
30032 var _useScreenshots = useScreenshots({ onData });
30033 var screenshots = _useScreenshots.screenshots;
30034 var generate = _useScreenshots.generate;
30035 var regenerate = _useScreenshots.regenerate;
30036 var isLoading = _useScreenshots.isLoading;
30037 var error = _useScreenshots.error;
30038 var abort = _useScreenshots.abort;
30039 var screenshotOutlineOffset = "2px";
30040 var _useSlider = useSlider({ slidesCount: screenshots.length });
30041 var currentPage = _useSlider.currentPage;
30042 var setCurrentPage = _useSlider.setCurrentPage;
30043 var pagesCount = _useSlider.pagesCount;
30044 var gapPercentage = _useSlider.gapPercentage;
30045 var slidesPerPage = _useSlider.slidesPerPage;
30046 var offsetXPercentage = _useSlider.offsetXPercentage;
30047 var slideWidthPercentage = _useSlider.slideWidthPercentage;
30048 var _useState2 = _slicedToArray((0, react.useState)(-1), 2);
30049 var selectedScreenshotIndex = _useState2[0];
30050 var setSelectedScreenshotIndex = _useState2[1];
30051 var _useState4 = _slicedToArray((0, react.useState)(false), 2);
30052 var showUnsavedChangesAlert = _useState4[0];
30053 var setShowUnsavedChangesAlert = _useState4[1];
30054 var _useState6 = _slicedToArray((0, react.useState)(true), 2);
30055 var isPromptEditable = _useState6[0];
30056 var setIsPromptEditable = _useState6[1];
30057 var _useState8 = _slicedToArray((0, react.useState)([]), 2);
30058 var attachments = _useState8[0];
30059 var setAttachments = _useState8[1];
30060 var _useState0 = _slicedToArray((0, react.useState)(false), 2);
30061 var shouldRenderWebApp = _useState0[0];
30062 var setShouldRenderWebApp = _useState0[1];
30063 var _useState10 = _slicedToArray((0, react.useState)(false), 2);
30064 var isMinimized = _useState10[0];
30065 var setIsMinimized = _useState10[1];
30066 var lastRun = (0, react.useRef)(function() {});
30067 var promptInputRef = (0, react.useRef)(null);
30068 var selectedTemplate = (_screenshots$selected = screenshots[selectedScreenshotIndex]) === null || _screenshots$selected === void 0 ? void 0 : _screenshots$selected.template;
30069 var dialogContentChildren = DialogContentProps.children;
30070 var dialogContentProps = _objectWithoutProperties$1(DialogContentProps, _excluded);
30071 var shouldFallbackToEditPrompt = !!(error && 0 === screenshots.length);
30072 var isPromptFormActive = isPromptEditable || shouldFallbackToEditPrompt;
30073 var abortAndClose = function abortAndClose() {
30074 abort();
30075 onClose();
30076 };
30077 var onCloseIntent = function onCloseIntent() {
30078 if (promptInputRef.current.value.trim() !== "" || screenshots.length > 0) return setShowUnsavedChangesAlert(true);
30079 abortAndClose();
30080 };
30081 var handleGenerate = function handleGenerate(event, prompt) {
30082 event.preventDefault();
30083 if ("" === prompt.trim() && 0 === attachments.length) return;
30084 if ((0, import_isURL.default)(prompt)) {
30085 setShouldRenderWebApp(true);
30086 return;
30087 }
30088 onGenerate();
30089 lastRun.current = function() {
30090 setSelectedScreenshotIndex(-1);
30091 generate(prompt, attachments);
30092 };
30093 lastRun.current();
30094 setIsPromptEditable(false);
30095 setCurrentPage(1);
30096 };
30097 var handleRegenerate = function handleRegenerate() {
30098 lastRun.current = function() {
30099 regenerate(promptInputRef.current.value, attachments);
30100 setCurrentPage(pagesCount + 1);
30101 };
30102 lastRun.current();
30103 };
30104 var applyTemplate = function applyTemplate() {
30105 onInsert(selectedTemplate);
30106 screenshots[selectedScreenshotIndex].sendUsageData();
30107 abortAndClose();
30108 };
30109 var handleScreenshotClick = function handleScreenshotClick(index, template) {
30110 return function() {
30111 if (isPromptFormActive) return;
30112 setSelectedScreenshotIndex(index);
30113 onSelect(template);
30114 };
30115 };
30116 /**
30117 * @param {Attachment[]} items
30118 */
30119 var onAttach = function onAttach(items) {
30120 items.forEach(function(item) {
30121 if (!attachmentsTypes[item.type]) throw new Error("Invalid attachment type: ".concat(item.type));
30122 var typeConfig = attachmentsTypes[item.type];
30123 if (!item.previewHTML && typeConfig.previewGenerator) typeConfig.previewGenerator(item.content).then(function(html) {
30124 item.previewHTML = html;
30125 setAttachments(function(prev) {
30126 return prev.map(function(attachment) {
30127 if (attachment.content === item.content) return item;
30128 return attachment;
30129 });
30130 });
30131 });
30132 });
30133 setAttachments(items);
30134 setShouldRenderWebApp(false);
30135 setIsPromptEditable(true);
30136 };
30137 (0, react.useEffect)(function() {
30138 var _screenshots$;
30139 if ((_screenshots$ = screenshots[0]) === null || _screenshots$ === void 0 ? void 0 : _screenshots$.template) {
30140 onSelect(screenshots[0].template);
30141 setSelectedScreenshotIndex(0);
30142 }
30143 }, [(_screenshots$2 = screenshots[0]) === null || _screenshots$2 === void 0 ? void 0 : _screenshots$2.template]);
30144 (0, react.useEffect)(function() {
30145 if (initialAttachments !== null && initialAttachments !== void 0 && initialAttachments.length) onAttach(initialAttachments);
30146 }, []);
30147 return /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose: onCloseIntent }, /*#__PURE__*/ react.default.createElement(LayoutDialog.Header, _extends$1({ onClose: onCloseIntent }, DialogHeaderProps), DialogHeaderProps.children, /*#__PURE__*/ react.default.createElement(_elementor_ui.Tooltip, { title: isMinimized ? (0, _wordpress_i18n.__)("Expand", "elementor") : (0, _wordpress_i18n.__)("Minimize", "elementor") }, /*#__PURE__*/ react.default.createElement(_elementor_ui.IconButton, {
30148 size: "small",
30149 "aria-label": "minimize",
30150 onClick: function onClick() {
30151 return setIsMinimized(function(prev) {
30152 return !prev;
30153 });
30154 }
30155 }, isMinimized ? /*#__PURE__*/ react.default.createElement(DirectionalExpandDiagonalIcon, null) : /*#__PURE__*/ react.default.createElement(DirectionalMinimizeDiagonalIcon, null)))), /*#__PURE__*/ react.default.createElement(LayoutDialog.Content, _extends$1({ dividers: true }, dialogContentProps), /*#__PURE__*/ react.default.createElement(_elementor_ui.Collapse, { in: !isMinimized }, dialogContentChildren && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30156 pt: 2,
30157 px: 2,
30158 pb: 0
30159 } }, dialogContentChildren), attachments.length > 0 && /*#__PURE__*/ react.default.createElement(PromptPowerNotice, null), error && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30160 pt: 2,
30161 px: 2,
30162 pb: 0
30163 } }, /*#__PURE__*/ react.default.createElement(PromptErrorMessage, {
30164 error,
30165 onRetry: lastRun.current
30166 })), showUnsavedChangesAlert && /*#__PURE__*/ react.default.createElement(UnsavedChangesAlert, {
30167 open: showUnsavedChangesAlert,
30168 title: (0, _wordpress_i18n.__)("Leave Elementor AI?", "elementor"),
30169 text: (0, _wordpress_i18n.__)("Your progress will be deleted, and can't be recovered.", "elementor"),
30170 onClose: abortAndClose,
30171 onCancel: function onCancel() {
30172 return setShowUnsavedChangesAlert(false);
30173 }
30174 }), shouldRenderWebApp && /*#__PURE__*/ react.default.createElement(AttachDialog, {
30175 type: "url",
30176 url: promptInputRef.current.value,
30177 onAttach,
30178 onClose: function onClose() {
30179 setShouldRenderWebApp(false);
30180 }
30181 }), /*#__PURE__*/ react.default.createElement(PromptForm, {
30182 shouldResetPrompt: shouldRenderWebApp,
30183 ref: promptInputRef,
30184 isActive: isPromptFormActive,
30185 isLoading,
30186 showActions: screenshots.length > 0 || isLoading,
30187 attachmentsTypes,
30188 attachments,
30189 onAttach,
30190 onDetach: function onDetach(index) {
30191 setAttachments(function(prev) {
30192 var newAttachments = _toConsumableArray(prev);
30193 newAttachments.splice(index, 1);
30194 return newAttachments;
30195 });
30196 setIsPromptEditable(true);
30197 },
30198 onSubmit: handleGenerate,
30199 onBack: function onBack() {
30200 return setIsPromptEditable(false);
30201 },
30202 onEdit: function onEdit() {
30203 return setIsPromptEditable(true);
30204 }
30205 }), (screenshots.length > 0 || isLoading) && /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(_elementor_ui.Divider, null), /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: { p: 1.5 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30206 overflow: "hidden",
30207 p: .5
30208 } }, /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, { sx: {
30209 display: "flex",
30210 transition: "all 0.4s ease",
30211 gap: "".concat(gapPercentage, "%"),
30212 transform: "translateX(".concat(offsetXPercentage, "%)")
30213 } }, screenshots.map(function(_ref2, index) {
30214 var screenshot = _ref2.screenshot;
30215 var type = _ref2.type;
30216 var template = _ref2.template;
30217 var isError = _ref2.isError;
30218 var isPending = _ref2.isPending;
30219 return /*#__PURE__*/ react.default.createElement(Screenshot, {
30220 key: index,
30221 url: screenshot,
30222 type,
30223 disabled: isPromptFormActive,
30224 isPlaceholder: isError,
30225 isLoading: isPending,
30226 isSelected: selectedScreenshotIndex === index,
30227 onClick: handleScreenshotClick(index, template),
30228 outlineOffset: screenshotOutlineOffset,
30229 sx: { flex: "0 0 ".concat(slideWidthPercentage, "%") }
30230 });
30231 }))), /*#__PURE__*/ react.default.createElement(VoicePromotionAlert, { introductionKey: "ai-context-layout-promotion" })), screenshots.length > 0 && /*#__PURE__*/ react.default.createElement(_elementor_ui.Box, {
30232 sx: {
30233 pt: 0,
30234 px: 2,
30235 pb: 2
30236 },
30237 display: "grid",
30238 gridTemplateColumns: "repeat(3, 1fr)",
30239 justifyItems: "center"
30240 }, /*#__PURE__*/ react.default.createElement(RegenerateButton, {
30241 onClick: handleRegenerate,
30242 disabled: isRegenerateButtonDisabled(screenshots, isLoading, isPromptFormActive),
30243 sx: { justifySelf: "start" }
30244 }), screenshots.length > slidesPerPage && /*#__PURE__*/ react.default.createElement(_elementor_ui.Pagination, {
30245 page: currentPage,
30246 count: pagesCount,
30247 disabled: isPromptFormActive,
30248 onChange: function onChange(_, page) {
30249 return setCurrentPage(page);
30250 }
30251 }), /*#__PURE__*/ react.default.createElement(UseLayoutButton, {
30252 onClick: applyTemplate,
30253 disabled: isPromptFormActive || -1 === selectedScreenshotIndex,
30254 sx: {
30255 justifySelf: "end",
30256 gridColumn: 3
30257 }
30258 }))))));
30259 };
30260 FormLayout.propTypes = {
30261 DialogHeaderProps: import_prop_types$7.default.object,
30262 DialogContentProps: import_prop_types$7.default.object,
30263 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType)
30264 };
30265
30266 //#endregion
30267 //#region modules/ai/assets/js/editor/layout-content.js
30268 init_slicedToArray();
30269 init_loader();
30270 init_requests_ids();
30271 var LayoutContent = function LayoutContent(props) {
30272 var _useUserInfo = useUserInfo();
30273 var isLoading = _useUserInfo.isLoading;
30274 var isConnected = _useUserInfo.isConnected;
30275 var isGetStarted = _useUserInfo.isGetStarted;
30276 var connectUrl = _useUserInfo.connectUrl;
30277 var fetchData = _useUserInfo.fetchData;
30278 var hasSubscription = _useUserInfo.hasSubscription;
30279 var initialUsagePercentage = _useUserInfo.usagePercentage;
30280 var _useConfig = useConfig();
30281 var onClose = _useConfig.onClose;
30282 var onConnect = _useConfig.onConnect;
30283 var _useRequestIds = useRequestIds();
30284 var updateUsagePercentage = _useRequestIds.updateUsagePercentage;
30285 var usagePercentage = _useRequestIds.usagePercentage;
30286 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30287 var isInitUsageDone = _useState2[0];
30288 var setIsInitUsageDone = _useState2[1];
30289 (0, react.useEffect)(function() {
30290 if (!isInitUsageDone && !isLoading && (initialUsagePercentage || 0 === initialUsagePercentage)) {
30291 updateUsagePercentage(initialUsagePercentage);
30292 setIsInitUsageDone(true);
30293 }
30294 }, [
30295 isLoading,
30296 initialUsagePercentage,
30297 isInitUsageDone,
30298 updateUsagePercentage
30299 ]);
30300 if (isLoading || !isInitUsageDone) return /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog.Header, { onClose }), /*#__PURE__*/ react.default.createElement(LayoutDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Loader, { BoxProps: { sx: { px: 3 } } })));
30301 if (!isConnected) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(Connect, {
30302 connectUrl,
30303 onSuccess: function onSuccess(data) {
30304 onConnect(data);
30305 fetchData();
30306 }
30307 })));
30308 if (!isGetStarted) return /*#__PURE__*/ react.default.createElement(WizardDialog, { onClose }, /*#__PURE__*/ react.default.createElement(LayoutDialog, { onClose }), /*#__PURE__*/ react.default.createElement(WizardDialog.Content, { dividers: true }, /*#__PURE__*/ react.default.createElement(GetStarted, { onSuccess: fetchData })));
30309 var showUpgradeChip = !hasSubscription || 80 <= usagePercentage;
30310 return /*#__PURE__*/ react.default.createElement(FormLayout, {
30311 attachments: props.attachments,
30312 DialogHeaderProps: { children: showUpgradeChip && /*#__PURE__*/ react.default.createElement(UpgradeChip, {
30313 hasSubscription,
30314 usagePercentage
30315 }) }
30316 });
30317 };
30318 LayoutContent.propTypes = { attachments: import_prop_types$7.default.arrayOf(AttachmentPropType) };
30319
30320 //#endregion
30321 //#region modules/ai/assets/js/editor/layout-app.js
30322 init_requests_ids();
30323 var LayoutApp = function LayoutApp(props) {
30324 return /*#__PURE__*/ react.default.createElement(RemoteConfigProvider, { onError: props.onClose }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(ConfigProvider, {
30325 mode: props.mode,
30326 attachmentsTypes: props.attachmentsTypes,
30327 onClose: props.onClose,
30328 onConnect: props.onConnect,
30329 onData: props.onData,
30330 onInsert: props.onInsert,
30331 onSelect: props.onSelect,
30332 onGenerate: props.onGenerate,
30333 currentContext: props.currentContext,
30334 hasPro: props.hasPro
30335 }, /*#__PURE__*/ react.default.createElement(LayoutContent, { attachments: props.attachments }))));
30336 };
30337 LayoutApp.propTypes = {
30338 mode: import_prop_types$7.default.oneOf(LAYOUT_APP_MODES).isRequired,
30339 attachmentsTypes: AttachmentsTypesPropType,
30340 attachments: import_prop_types$7.default.arrayOf(AttachmentPropType),
30341 onClose: import_prop_types$7.default.func.isRequired,
30342 onConnect: import_prop_types$7.default.func.isRequired,
30343 onData: import_prop_types$7.default.func.isRequired,
30344 onInsert: import_prop_types$7.default.func.isRequired,
30345 onSelect: import_prop_types$7.default.func.isRequired,
30346 onGenerate: import_prop_types$7.default.func.isRequired,
30347 currentContext: import_prop_types$7.default.object,
30348 hasPro: import_prop_types$7.default.bool
30349 };
30350
30351 //#endregion
30352 //#region modules/ai/assets/js/editor/utils/screenshot.js
30353 init_requests_ids();
30354
30355 //#endregion
30356 //#region modules/ai/assets/js/editor/layout-app-wrapper.js
30357 var LayoutAppWrapper = function LayoutAppWrapper(props) {
30358 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DirectionProvider, { rtl: props.isRTL }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ThemeProvider, { colorScheme: props.colorScheme }, props.children));
30359 };
30360 LayoutAppWrapper.propTypes = {
30361 children: import_prop_types$7.default.node,
30362 isRTL: import_prop_types$7.default.bool,
30363 colorScheme: import_prop_types$7.default.oneOf([
30364 "auto",
30365 "light",
30366 "dark"
30367 ])
30368 };
30369
30370 //#endregion
30371 //#region modules/ai/assets/js/editor/utils/editor-integration.js
30372 init_requests_ids();
30373 var onConnect = function onConnect(data) {
30374 elementorCommon.config.library_connect.is_connected = true;
30375 elementorCommon.config.library_connect.current_access_level = data.kits_access_level || data.access_level || 0;
30376 elementorCommon.config.library_connect.current_access_tier = data.access_tier;
30377 elementorCommon.config.library_connect.plan_type = data.plan_type;
30378 };
30379 var VARIATIONS_PROMPTS = [
30380 { text: (0, _wordpress_i18n.__)("Minimalist design with bold typography about", "elementor") },
30381 { text: (0, _wordpress_i18n.__)("Elegant style with serif fonts discussing", "elementor") },
30382 { text: (0, _wordpress_i18n.__)("Retro vibe with muted colors and classic fonts about", "elementor") },
30383 { text: (0, _wordpress_i18n.__)("Futuristic design with neon accents about", "elementor") },
30384 { text: (0, _wordpress_i18n.__)("Professional look with clean lines for", "elementor") },
30385 { text: (0, _wordpress_i18n.__)("Earthy tones and organic shapes featuring", "elementor") },
30386 { text: (0, _wordpress_i18n.__)("Luxurious theme with rich colors discussing", "elementor") },
30387 { text: (0, _wordpress_i18n.__)("Tech-inspired style with modern fonts about", "elementor") },
30388 { text: (0, _wordpress_i18n.__)("Warm hues with comforting visuals about", "elementor") }
30389 ];
30390 var WEB_BASED_PROMPTS = [
30391 { text: (0, _wordpress_i18n.__)("Change the content to be about [topic]", "elementor") },
30392 { text: (0, _wordpress_i18n.__)("Generate lorem ipsum placeholder text for all paragraphs", "elementor") },
30393 { text: (0, _wordpress_i18n.__)("Revise the content to focus on [topic] and then translate it into Spanish", "elementor") },
30394 { text: (0, _wordpress_i18n.__)("Shift the focus of the content to [topic] in order to showcase our company's mission and values", "elementor") },
30395 { text: (0, _wordpress_i18n.__)("Alter the content to provide helpful tips related to [topic]", "elementor") },
30396 { text: (0, _wordpress_i18n.__)("Adjust the content to include FAQs and answers for common inquiries about [topic]", "elementor") }
30397 ];
30398 var PROMPT_PLACEHOLDER = (0, _wordpress_i18n.__)("Press '/' for suggestions or describe the changes you want to apply (optional)...", "elementor");
30399
30400 //#endregion
30401 //#region modules/ai/assets/js/editor/app.js
30402 init_requests_ids();
30403 var App = function App(props) {
30404 return /*#__PURE__*/ react.default.createElement(_elementor_ui.DirectionProvider, { rtl: props.isRTL }, /*#__PURE__*/ react.default.createElement(_elementor_ui.ThemeProvider, { colorScheme: props.colorScheme }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(PageContent, {
30405 type: props.type,
30406 controlType: props.controlType,
30407 onClose: props.onClose,
30408 onConnect,
30409 getControlValue: props.getControlValue,
30410 setControlValue: props.setControlValue,
30411 additionalOptions: props.additionalOptions
30412 }))));
30413 };
30414 App.propTypes = {
30415 colorScheme: import_prop_types$7.default.oneOf([
30416 "auto",
30417 "light",
30418 "dark"
30419 ]),
30420 type: import_prop_types$7.default.string,
30421 controlType: import_prop_types$7.default.string,
30422 onClose: import_prop_types$7.default.func,
30423 getControlValue: import_prop_types$7.default.func,
30424 setControlValue: import_prop_types$7.default.func,
30425 additionalOptions: import_prop_types$7.default.object,
30426 isRTL: import_prop_types$7.default.bool
30427 };
30428
30429 //#endregion
30430 //#region modules/ai/assets/js/media-library/components.js
30431 var AIMediaGenerateApp = function AIMediaGenerateApp(_ref) {
30432 var onClose = _ref.onClose;
30433 var setControlValue = _ref.setControlValue;
30434 var _ref$predefinedPrompt = _ref.predefinedPrompt;
30435 var predefinedPrompt = _ref$predefinedPrompt === void 0 ? "" : _ref$predefinedPrompt;
30436 var _ref$textToImageHook = _ref.textToImageHook;
30437 var textToImageHook = _ref$textToImageHook === void 0 ? null : _ref$textToImageHook;
30438 var _ref$initialSettings = _ref.initialSettings;
30439 var initialSettings = _ref$initialSettings === void 0 ? {} : _ref$initialSettings;
30440 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30441 type: "media",
30442 getControlValue: function getControlValue() {},
30443 setControlValue,
30444 onClose,
30445 isRTL: elementorCommon.config.isRTL,
30446 additionalOptions: {
30447 defaultImageType: Object.keys(IMAGE_PROMPT_CATEGORIES)[1],
30448 textToImageHook,
30449 predefinedPrompt,
30450 initialSettings
30451 }
30452 }));
30453 };
30454 AIMediaGenerateApp.propTypes = {
30455 onClose: import_prop_types$7.default.func.isRequired,
30456 predefinedPrompt: import_prop_types$7.default.string,
30457 textToImageHook: import_prop_types$7.default.func,
30458 setControlValue: import_prop_types$7.default.func.isRequired,
30459 initialSettings: import_prop_types$7.default.object
30460 };
30461 var AIMediaEditApp = function AIMediaEditApp(_ref2) {
30462 var onClose = _ref2.onClose;
30463 var imageId = _ref2.imageId;
30464 var image = wp.media.attachment(imageId);
30465 return /*#__PURE__*/ react.default.createElement(react.default.Fragment, null, /*#__PURE__*/ react.default.createElement(App, {
30466 type: "media",
30467 getControlValue: function getControlValue() {
30468 return image.attributes;
30469 },
30470 setControlValue: function setControlValue() {},
30471 onClose,
30472 isRTL: elementorCommon.config.isRTL,
30473 additionalOptions: { location: LOCATIONS.IMAGE_TOOLS }
30474 }));
30475 };
30476 AIMediaEditApp.propTypes = {
30477 onClose: import_prop_types$7.default.func.isRequired,
30478 imageId: import_prop_types$7.default.string
30479 };
30480
30481 //#endregion
30482 //#region modules/ai/assets/js/media-library/generate.js
30483 init_slicedToArray();
30484 init_requests_ids();
30485 var _templateObject$2;
30486 var _templateObject2$1;
30487 var Icon$1 = (0, _elementor_ui.styled)("i")(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteral(["\n padding-right: 0.5em;\n cursor: pointer;\n"])));
30488 var StyledButton$1 = (0, _elementor_ui.styled)("a")(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteral(["\n color: var(--e-a-color-primary-bold);\n cursor: pointer;\n font: inherit;\n display: inline-block;\n position: relative;\n top: -3px;\n margin-left: 4px;\n border: 1px solid var(--e-a-color-primary-bold);\n border-radius: 3px;\n line-height: 2.15384615;\n padding: 0 10px;\n background: #f6f7f7;\n\n &:hover {\n color: var(--e-a-color-primary-bold);\n background: #eeefef;\n }\n"])));
30489 var AIMediaGenerateAppWrapper = function AIMediaGenerateAppWrapper() {
30490 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30491 var isOpen = _useState2[0];
30492 var setIsOpen = _useState2[1];
30493 return /*#__PURE__*/ react.default.createElement("div", { style: { padding: "0.5em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(StyledButton$1, { onClick: function handleClick() {
30494 setIsOpen(true);
30495 } }, /*#__PURE__*/ react.default.createElement(Icon$1, { className: "eicon-ai" }), (0, _wordpress_i18n.__)("Generate with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AIMediaGenerateApp, {
30496 onClose: function handleClose() {
30497 var _wp$media$frame;
30498 (_wp$media$frame = wp.media.frame) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.content) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.get()) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.collection) === null || _wp$media$frame === void 0 || _wp$media$frame._requery(true);
30499 setIsOpen(false);
30500 },
30501 setControlValue: function setControlValue() {}
30502 })));
30503 };
30504
30505 //#endregion
30506 //#region node_modules/@wordpress/element/build-module/react-platform.js
30507 /**
30508 * External dependencies
30509 */
30510
30511 //#endregion
30512 //#region modules/ai/assets/js/media-library/utils.js
30513 var getImageId = function getImageId() {
30514 var _wp$media;
30515 var imageId = (_wp$media = wp.media) === null || _wp$media === void 0 || (_wp$media = _wp$media.frames) === null || _wp$media === void 0 || (_wp$media = _wp$media.edit) === null || _wp$media === void 0 || (_wp$media = _wp$media.model) === null || _wp$media === void 0 || (_wp$media = _wp$media.id) === null || _wp$media === void 0 ? void 0 : _wp$media.toString();
30516 if (imageId) return imageId;
30517 return getImageIdByUrl();
30518 };
30519 var getImageIdByUrl = function getImageIdByUrl() {
30520 var _document$getElementB;
30521 var _wp$media$frame;
30522 var imageUrl = (_document$getElementB = document.getElementById("attachment-details-copy-link")) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.value;
30523 var images = (_wp$media$frame = wp.media.frame) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.content) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.get()) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.collection) === null || _wp$media$frame === void 0 ? void 0 : _wp$media$frame.models;
30524 var image = Array.isArray(images) && images.find(function(img) {
30525 return img.attributes.url === imageUrl;
30526 });
30527 return image ? image.attributes.id.toString() : null;
30528 };
30529 var isImageFile = function isImageFile() {
30530 var _wp$media2;
30531 var _filename$split$pop;
30532 var filename = (_wp$media2 = wp.media) === null || _wp$media2 === void 0 || (_wp$media2 = _wp$media2.frames) === null || _wp$media2 === void 0 || (_wp$media2 = _wp$media2.edit) === null || _wp$media2 === void 0 || (_wp$media2 = _wp$media2.model) === null || _wp$media2 === void 0 || (_wp$media2 = _wp$media2.attributes) === null || _wp$media2 === void 0 ? void 0 : _wp$media2.filename;
30533 var imageExtensions = [
30534 "jpg",
30535 "jpeg",
30536 "png",
30537 "gif",
30538 "bmp",
30539 "webp",
30540 "tiff",
30541 "svg",
30542 "ico",
30543 "heic",
30544 "heif"
30545 ];
30546 var fileExtension = (_filename$split$pop = filename.split(".").pop()) === null || _filename$split$pop === void 0 ? void 0 : _filename$split$pop.toLowerCase();
30547 return imageExtensions.includes(fileExtension || "");
30548 };
30549
30550 //#endregion
30551 //#region modules/ai/assets/js/media-library/edit-button.js
30552 init_slicedToArray();
30553 init_requests_ids();
30554 var _templateObject$1;
30555 var _templateObject2;
30556 var Icon = (0, _elementor_ui.styled)("i")(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteral(["\n color: var(--e-a-color-primary-bold);\n padding-inline-end: 0.5em;\n cursor: pointer;\n"])));
30557 var StyledButton = (0, _elementor_ui.styled)("a")(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font: inherit;\n display: inline-block;\n font-size: 13px;\n line-height: 2.15384615;\n padding: 0 10px;\n cursor: pointer;\n border-width: 1px;\n border-style: solid;\n border-radius: 3px;\n background: #f6f7f7;\n color: var(--e-a-color-primary-bold);\n\n &:hover {\n color: var(--e-a-color-primary-bold);\n background: #eeefef;\n }\n"])));
30558 var AIMediaEditAppButtonWrapper = function AIMediaEditAppButtonWrapper() {
30559 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30560 var isOpen = _useState2[0];
30561 var setIsOpen = _useState2[1];
30562 var _useState4 = _slicedToArray((0, react.useState)(getImageId), 2);
30563 var imageId = _useState4[0];
30564 var setImageId = _useState4[1];
30565 return isImageFile() && /*#__PURE__*/ react.default.createElement("div", { style: { marginLeft: "0.5em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(StyledButton, { onClick: function handleClick() {
30566 setImageId(getImageId());
30567 setIsOpen(true);
30568 } }, /*#__PURE__*/ react.default.createElement(Icon, { className: "eicon-ai" }), (0, _wordpress_i18n.__)("Edit with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AIMediaEditApp, {
30569 onClose: function handleClose() {
30570 var _wp$media$frame;
30571 (_wp$media$frame = wp.media.frame) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.controller) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.content) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.get().collection) === null || _wp$media$frame === void 0 || _wp$media$frame._requery(true);
30572 setIsOpen(false);
30573 },
30574 imageId
30575 })));
30576 };
30577
30578 //#endregion
30579 //#region modules/ai/assets/js/media-library/edit-link.js
30580 init_slicedToArray();
30581 init_requests_ids();
30582 var _templateObject;
30583 var ImageLink = (0, _elementor_ui.styled)("a")(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n && {\n color: var(--e-a-color-primary-bold);\n cursor: pointer;\n font-size: inherit;\n display: inline-block;\n\n &:hover {\n color: var(--e-a-color-primary-bold);\n }\n }\n"])));
30584 var AIMediaEditAppLinkWrapper = function AIMediaEditAppLinkWrapper() {
30585 var _useState2 = _slicedToArray((0, react.useState)(false), 2);
30586 var isOpen = _useState2[0];
30587 var setIsOpen = _useState2[1];
30588 var _useState4 = _slicedToArray((0, react.useState)(getImageId), 2);
30589 var imageId = _useState4[0];
30590 var setImageId = _useState4[1];
30591 return /*#__PURE__*/ react.default.createElement("div", { style: { paddingTop: "0.2em" } }, /*#__PURE__*/ react.default.createElement(RequestIdsProvider, null, /*#__PURE__*/ react.default.createElement(ImageLink, { onClick: function handleClick() {
30592 setImageId(getImageId());
30593 setIsOpen(true);
30594 } }, (0, _wordpress_i18n.__)("Edit with Elementor AI", "elementor")), isOpen && /*#__PURE__*/ react.default.createElement(AIMediaEditApp, {
30595 onClose: function handleClose() {
30596 var _wp$media$frame;
30597 (_wp$media$frame = wp.media.frame) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.content) === null || _wp$media$frame === void 0 || (_wp$media$frame = _wp$media$frame.get().collection) === null || _wp$media$frame === void 0 || _wp$media$frame._requery(true);
30598 setIsOpen(false);
30599 },
30600 imageId
30601 })));
30602 };
30603
30604 //#endregion
30605 //#region modules/ai/assets/js/media-library/index.js
30606 init_requests_ids();
30607 var isMediaLibrary = function isMediaLibrary() {
30608 return window.location.href.includes("/upload.php");
30609 };
30610 var insertStyleTag = function insertStyleTag() {
30611 var style = document.createElement("style");
30612 style.appendChild(document.createTextNode("\n #e-image-ai-attachment-details,\n #e-image-ai-media-library {\n display: inline-block;\n }\n #e-form-media * {\n box-sizing: border-box;\n }\n #menu- {\n z-index: 180000;\n }\n "));
30613 document.head.appendChild(style);
30614 };
30615 var renderComponent = function renderComponent(containerId, Component) {
30616 var container = document.getElementById(containerId);
30617 if (container) (0, import_client.createRoot)(container).render(/*#__PURE__*/ react.default.createElement(Component, null));
30618 };
30619 var addEventListener = function addEventListener(eventName, containerId, Component) {
30620 window.addEventListener(eventName, function() {
30621 setTimeout(function() {
30622 return renderComponent(containerId, Component);
30623 }, 1);
30624 });
30625 };
30626 var addEditorPostIdRequestConstant = function addEditorPostIdRequestConstant() {
30627 var _elementorCommon;
30628 if (!((_elementorCommon = elementorCommon) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.ajax) !== null && _elementorCommon !== void 0 && (_elementorCommon = _elementorCommon.requestConstants) !== null && _elementorCommon !== void 0 && _elementorCommon.editor_post_id)) {
30629 var _elementorCommon2;
30630 var _window$document$quer;
30631 (_elementorCommon2 = elementorCommon) === null || _elementorCommon2 === void 0 || (_elementorCommon2 = _elementorCommon2.ajax) === null || _elementorCommon2 === void 0 || _elementorCommon2.addRequestConstant("editor_post_id", (_window$document$quer = window.document.querySelector("#post_ID")) === null || _window$document$quer === void 0 ? void 0 : _window$document$quer.value);
30632 }
30633 };
30634 (function(_wp, _wp2) {
30635 if (isMediaLibrary()) {
30636 window.EDITOR_SESSION_ID = getUniqueId("wp-media-lib-session");
30637 var mediaLibrary = document.querySelector(".page-title-action");
30638 if (mediaLibrary) {
30639 var container = document.createElement("div");
30640 container.id = "e-image-ai-media-library";
30641 mediaLibrary.insertAdjacentElement("afterend", container);
30642 renderComponent("e-image-ai-media-library", AIMediaGenerateAppWrapper);
30643 }
30644 }
30645 if ((_wp = wp) !== null && _wp !== void 0 && (_wp = _wp.media) !== null && _wp !== void 0 && (_wp = _wp.view) !== null && _wp !== void 0 && (_wp = _wp.Attachment) !== null && _wp !== void 0 && _wp.Details) wp.media.view.Attachment.Details = wp.media.view.Attachment.Details.extend({ template: function template(view) {
30646 var html = wp.media.template("attachment-details")(view);
30647 var content = document.createElement("div");
30648 content.innerHTML = html;
30649 var compatMeta = content.querySelector(".dimensions");
30650 if (!compatMeta) return content.innerHTML;
30651 var container = document.createElement("div");
30652 container.id = "e-image-ai-insert-media";
30653 compatMeta.insertAdjacentElement("beforeend", container);
30654 addEditorPostIdRequestConstant();
30655 window.dispatchEvent(new CustomEvent("renderInsertMediaEvent"));
30656 return content.innerHTML;
30657 } });
30658 if ((_wp2 = wp) !== null && _wp2 !== void 0 && (_wp2 = _wp2.media) !== null && _wp2 !== void 0 && (_wp2 = _wp2.view) !== null && _wp2 !== void 0 && (_wp2 = _wp2.Attachment) !== null && _wp2 !== void 0 && (_wp2 = _wp2.Details) !== null && _wp2 !== void 0 && _wp2.TwoColumn) wp.media.view.Attachment.Details.TwoColumn = wp.media.view.Attachment.Details.TwoColumn.extend({ template: function template(view) {
30659 var html = wp.media.template("attachment-details-two-column")(view);
30660 var content = document.createElement("div");
30661 content.innerHTML = html;
30662 var details = content.querySelector(".attachment-actions");
30663 if (!details) return content.innerHTML;
30664 var container = document.createElement("div");
30665 container.id = "e-image-ai-attachment-details";
30666 details.appendChild(container);
30667 addEditorPostIdRequestConstant();
30668 window.dispatchEvent(new CustomEvent("renderAttachmentsDetailsEvent"));
30669 return content.innerHTML;
30670 } });
30671 addEventListener("renderInsertMediaEvent", "e-image-ai-insert-media", AIMediaEditAppLinkWrapper);
30672 addEventListener("renderAttachmentsDetailsEvent", "e-image-ai-attachment-details", AIMediaEditAppButtonWrapper);
30673 insertStyleTag();
30674 })();
30675
30676 //#endregion
30677 })(React, wp.i18n, elementorV2.ui, elementorV2.icons, elementorV2.ui['TextField']);
30678 //# sourceMappingURL=ai-media-library.js.map