PluginProbe
Gutenberg / 19.6.1
Gutenberg v19.6.1
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / style-engine / index.js

index.js in Gutenberg 19.6.1, at build/style-engine/index.js

1,151 lines 38.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ // The require scope
4 /******/ var __webpack_require__ = {};
5 /******/
6 /************************************************************************/
7 /******/ /* webpack/runtime/define property getters */
8 /******/ (() => {
9 /******/ // define getter functions for harmony exports
10 /******/ __webpack_require__.d = (exports, definition) => {
11 /******/ for(var key in definition) {
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14 /******/ }
15 /******/ }
16 /******/ };
17 /******/ })();
18 /******/
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */
20 /******/ (() => {
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22 /******/ })();
23 /******/
24 /******/ /* webpack/runtime/make namespace object */
25 /******/ (() => {
26 /******/ // define __esModule on exports
27 /******/ __webpack_require__.r = (exports) => {
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30 /******/ }
31 /******/ Object.defineProperty(exports, '__esModule', { value: true });
32 /******/ };
33 /******/ })();
34 /******/
35 /************************************************************************/
36 var __webpack_exports__ = {};
37 // ESM COMPAT FLAG
38 __webpack_require__.r(__webpack_exports__);
39
40 // EXPORTS
41 __webpack_require__.d(__webpack_exports__, {
42 compileCSS: () => (/* binding */ compileCSS),
43 getCSSRules: () => (/* binding */ getCSSRules),
44 getCSSValueFromRawStyle: () => (/* reexport */ getCSSValueFromRawStyle)
45 });
46
47 ;// ./node_modules/tslib/tslib.es6.mjs
48 /******************************************************************************
49 Copyright (c) Microsoft Corporation.
50
51 Permission to use, copy, modify, and/or distribute this software for any
52 purpose with or without fee is hereby granted.
53
54 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
55 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
56 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
57 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
58 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
59 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
60 PERFORMANCE OF THIS SOFTWARE.
61 ***************************************************************************** */
62 /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
63
64 var extendStatics = function(d, b) {
65 extendStatics = Object.setPrototypeOf ||
66 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
67 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
68 return extendStatics(d, b);
69 };
70
71 function __extends(d, b) {
72 if (typeof b !== "function" && b !== null)
73 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
74 extendStatics(d, b);
75 function __() { this.constructor = d; }
76 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
77 }
78
79 var __assign = function() {
80 __assign = Object.assign || function __assign(t) {
81 for (var s, i = 1, n = arguments.length; i < n; i++) {
82 s = arguments[i];
83 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
84 }
85 return t;
86 }
87 return __assign.apply(this, arguments);
88 }
89
90 function __rest(s, e) {
91 var t = {};
92 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
93 t[p] = s[p];
94 if (s != null && typeof Object.getOwnPropertySymbols === "function")
95 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
96 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
97 t[p[i]] = s[p[i]];
98 }
99 return t;
100 }
101
102 function __decorate(decorators, target, key, desc) {
103 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
104 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
105 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
106 return c > 3 && r && Object.defineProperty(target, key, r), r;
107 }
108
109 function __param(paramIndex, decorator) {
110 return function (target, key) { decorator(target, key, paramIndex); }
111 }
112
113 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
114 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
115 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
116 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
117 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
118 var _, done = false;
119 for (var i = decorators.length - 1; i >= 0; i--) {
120 var context = {};
121 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
122 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
123 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
124 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
125 if (kind === "accessor") {
126 if (result === void 0) continue;
127 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
128 if (_ = accept(result.get)) descriptor.get = _;
129 if (_ = accept(result.set)) descriptor.set = _;
130 if (_ = accept(result.init)) initializers.unshift(_);
131 }
132 else if (_ = accept(result)) {
133 if (kind === "field") initializers.unshift(_);
134 else descriptor[key] = _;
135 }
136 }
137 if (target) Object.defineProperty(target, contextIn.name, descriptor);
138 done = true;
139 };
140
141 function __runInitializers(thisArg, initializers, value) {
142 var useValue = arguments.length > 2;
143 for (var i = 0; i < initializers.length; i++) {
144 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
145 }
146 return useValue ? value : void 0;
147 };
148
149 function __propKey(x) {
150 return typeof x === "symbol" ? x : "".concat(x);
151 };
152
153 function __setFunctionName(f, name, prefix) {
154 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
155 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
156 };
157
158 function __metadata(metadataKey, metadataValue) {
159 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
160 }
161
162 function __awaiter(thisArg, _arguments, P, generator) {
163 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
164 return new (P || (P = Promise))(function (resolve, reject) {
165 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
166 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
167 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
168 step((generator = generator.apply(thisArg, _arguments || [])).next());
169 });
170 }
171
172 function __generator(thisArg, body) {
173 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
174 return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
175 function verb(n) { return function (v) { return step([n, v]); }; }
176 function step(op) {
177 if (f) throw new TypeError("Generator is already executing.");
178 while (g && (g = 0, op[0] && (_ = 0)), _) try {
179 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
180 if (y = 0, t) op = [op[0] & 2, t.value];
181 switch (op[0]) {
182 case 0: case 1: t = op; break;
183 case 4: _.label++; return { value: op[1], done: false };
184 case 5: _.label++; y = op[1]; op = [0]; continue;
185 case 7: op = _.ops.pop(); _.trys.pop(); continue;
186 default:
187 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
188 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
189 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
190 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
191 if (t[2]) _.ops.pop();
192 _.trys.pop(); continue;
193 }
194 op = body.call(thisArg, _);
195 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
196 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
197 }
198 }
199
200 var __createBinding = Object.create ? (function(o, m, k, k2) {
201 if (k2 === undefined) k2 = k;
202 var desc = Object.getOwnPropertyDescriptor(m, k);
203 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
204 desc = { enumerable: true, get: function() { return m[k]; } };
205 }
206 Object.defineProperty(o, k2, desc);
207 }) : (function(o, m, k, k2) {
208 if (k2 === undefined) k2 = k;
209 o[k2] = m[k];
210 });
211
212 function __exportStar(m, o) {
213 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
214 }
215
216 function __values(o) {
217 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
218 if (m) return m.call(o);
219 if (o && typeof o.length === "number") return {
220 next: function () {
221 if (o && i >= o.length) o = void 0;
222 return { value: o && o[i++], done: !o };
223 }
224 };
225 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
226 }
227
228 function __read(o, n) {
229 var m = typeof Symbol === "function" && o[Symbol.iterator];
230 if (!m) return o;
231 var i = m.call(o), r, ar = [], e;
232 try {
233 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
234 }
235 catch (error) { e = { error: error }; }
236 finally {
237 try {
238 if (r && !r.done && (m = i["return"])) m.call(i);
239 }
240 finally { if (e) throw e.error; }
241 }
242 return ar;
243 }
244
245 /** @deprecated */
246 function __spread() {
247 for (var ar = [], i = 0; i < arguments.length; i++)
248 ar = ar.concat(__read(arguments[i]));
249 return ar;
250 }
251
252 /** @deprecated */
253 function __spreadArrays() {
254 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
255 for (var r = Array(s), k = 0, i = 0; i < il; i++)
256 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
257 r[k] = a[j];
258 return r;
259 }
260
261 function __spreadArray(to, from, pack) {
262 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
263 if (ar || !(i in from)) {
264 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
265 ar[i] = from[i];
266 }
267 }
268 return to.concat(ar || Array.prototype.slice.call(from));
269 }
270
271 function __await(v) {
272 return this instanceof __await ? (this.v = v, this) : new __await(v);
273 }
274
275 function __asyncGenerator(thisArg, _arguments, generator) {
276 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
277 var g = generator.apply(thisArg, _arguments || []), i, q = [];
278 return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
279 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
280 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
281 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
282 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
283 function fulfill(value) { resume("next", value); }
284 function reject(value) { resume("throw", value); }
285 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
286 }
287
288 function __asyncDelegator(o) {
289 var i, p;
290 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
291 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
292 }
293
294 function __asyncValues(o) {
295 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
296 var m = o[Symbol.asyncIterator], i;
297 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
298 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
299 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
300 }
301
302 function __makeTemplateObject(cooked, raw) {
303 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
304 return cooked;
305 };
306
307 var __setModuleDefault = Object.create ? (function(o, v) {
308 Object.defineProperty(o, "default", { enumerable: true, value: v });
309 }) : function(o, v) {
310 o["default"] = v;
311 };
312
313 function __importStar(mod) {
314 if (mod && mod.__esModule) return mod;
315 var result = {};
316 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
317 __setModuleDefault(result, mod);
318 return result;
319 }
320
321 function __importDefault(mod) {
322 return (mod && mod.__esModule) ? mod : { default: mod };
323 }
324
325 function __classPrivateFieldGet(receiver, state, kind, f) {
326 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
327 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
328 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
329 }
330
331 function __classPrivateFieldSet(receiver, state, value, kind, f) {
332 if (kind === "m") throw new TypeError("Private method is not writable");
333 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
334 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
335 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
336 }
337
338 function __classPrivateFieldIn(state, receiver) {
339 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
340 return typeof state === "function" ? receiver === state : state.has(receiver);
341 }
342
343 function __addDisposableResource(env, value, async) {
344 if (value !== null && value !== void 0) {
345 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
346 var dispose, inner;
347 if (async) {
348 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
349 dispose = value[Symbol.asyncDispose];
350 }
351 if (dispose === void 0) {
352 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
353 dispose = value[Symbol.dispose];
354 if (async) inner = dispose;
355 }
356 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
357 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
358 env.stack.push({ value: value, dispose: dispose, async: async });
359 }
360 else if (async) {
361 env.stack.push({ async: true });
362 }
363 return value;
364 }
365
366 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
367 var e = new Error(message);
368 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
369 };
370
371 function __disposeResources(env) {
372 function fail(e) {
373 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
374 env.hasError = true;
375 }
376 var r, s = 0;
377 function next() {
378 while (r = env.stack.pop()) {
379 try {
380 if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
381 if (r.dispose) {
382 var result = r.dispose.call(r.value);
383 if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
384 }
385 else s |= 1;
386 }
387 catch (e) {
388 fail(e);
389 }
390 }
391 if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
392 if (env.hasError) throw env.error;
393 }
394 return next();
395 }
396
397 function __rewriteRelativeImportExtension(path, preserveJsx) {
398 if (typeof path === "string" && /^\.\.?\//.test(path)) {
399 return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
400 return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
401 });
402 }
403 return path;
404 }
405
406 /* harmony default export */ const tslib_es6 = ({
407 __extends,
408 __assign,
409 __rest,
410 __decorate,
411 __param,
412 __esDecorate,
413 __runInitializers,
414 __propKey,
415 __setFunctionName,
416 __metadata,
417 __awaiter,
418 __generator,
419 __createBinding,
420 __exportStar,
421 __values,
422 __read,
423 __spread,
424 __spreadArrays,
425 __spreadArray,
426 __await,
427 __asyncGenerator,
428 __asyncDelegator,
429 __asyncValues,
430 __makeTemplateObject,
431 __importStar,
432 __importDefault,
433 __classPrivateFieldGet,
434 __classPrivateFieldSet,
435 __classPrivateFieldIn,
436 __addDisposableResource,
437 __disposeResources,
438 __rewriteRelativeImportExtension,
439 });
440
441 ;// ./node_modules/lower-case/dist.es2015/index.js
442 /**
443 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
444 */
445 var SUPPORTED_LOCALE = {
446 tr: {
447 regexp: /\u0130|\u0049|\u0049\u0307/g,
448 map: {
449 İ: "\u0069",
450 I: "\u0131",
451 : "\u0069",
452 },
453 },
454 az: {
455 regexp: /\u0130/g,
456 map: {
457 İ: "\u0069",
458 I: "\u0131",
459 : "\u0069",
460 },
461 },
462 lt: {
463 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
464 map: {
465 I: "\u0069\u0307",
466 J: "\u006A\u0307",
467 Į: "\u012F\u0307",
468 Ì: "\u0069\u0307\u0300",
469 Í: "\u0069\u0307\u0301",
470 Ĩ: "\u0069\u0307\u0303",
471 },
472 },
473 };
474 /**
475 * Localized lower case.
476 */
477 function localeLowerCase(str, locale) {
478 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
479 if (lang)
480 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
481 return lowerCase(str);
482 }
483 /**
484 * Lower case as a function.
485 */
486 function lowerCase(str) {
487 return str.toLowerCase();
488 }
489
490 ;// ./node_modules/no-case/dist.es2015/index.js
491
492 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
493 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
494 // Remove all non-word characters.
495 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
496 /**
497 * Normalize the string into something other libraries can manipulate easier.
498 */
499 function noCase(input, options) {
500 if (options === void 0) { options = {}; }
501 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
502 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
503 var start = 0;
504 var end = result.length;
505 // Trim the delimiter from around the output string.
506 while (result.charAt(start) === "\0")
507 start++;
508 while (result.charAt(end - 1) === "\0")
509 end--;
510 // Transform each token independently.
511 return result.slice(start, end).split("\0").map(transform).join(delimiter);
512 }
513 /**
514 * Replace `re` in the input string with the replacement value.
515 */
516 function replace(input, re, value) {
517 if (re instanceof RegExp)
518 return input.replace(re, value);
519 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
520 }
521
522 ;// ./node_modules/dot-case/dist.es2015/index.js
523
524
525 function dotCase(input, options) {
526 if (options === void 0) { options = {}; }
527 return noCase(input, __assign({ delimiter: "." }, options));
528 }
529
530 ;// ./node_modules/param-case/dist.es2015/index.js
531
532
533 function paramCase(input, options) {
534 if (options === void 0) { options = {}; }
535 return dotCase(input, __assign({ delimiter: "-" }, options));
536 }
537
538 ;// ./packages/style-engine/build-module/styles/constants.js
539 const VARIABLE_REFERENCE_PREFIX = 'var:';
540 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
541 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
542
543 ;// ./packages/style-engine/build-module/styles/utils.js
544 /**
545 * External dependencies
546 */
547
548
549 /**
550 * Internal dependencies
551 */
552
553
554
555 /**
556 * Helper util to return a value from a certain path of the object.
557 * Path is specified as an array of properties, like `[ 'x', 'y' ]`.
558 *
559 * @param object Input object.
560 * @param path Path to the object property.
561 * @return Value of the object property at the specified path.
562 */
563 const getStyleValueByPath = (object, path) => {
564 let value = object;
565 path.forEach(fieldName => {
566 value = value?.[fieldName];
567 });
568 return value;
569 };
570
571 /**
572 * Returns a JSON representation of the generated CSS rules.
573 *
574 * @param style Style object.
575 * @param options Options object with settings to adjust how the styles are generated.
576 * @param path An array of strings representing the path to the style value in the style object.
577 * @param ruleKey A CSS property key.
578 *
579 * @return GeneratedCSSRule[] CSS rules.
580 */
581 function generateRule(style, options, path, ruleKey) {
582 const styleValue = getStyleValueByPath(style, path);
583 return styleValue ? [{
584 selector: options?.selector,
585 key: ruleKey,
586 value: getCSSValueFromRawStyle(styleValue)
587 }] : [];
588 }
589
590 /**
591 * Returns a JSON representation of the generated CSS rules taking into account box model properties, top, right, bottom, left.
592 *
593 * @param style Style object.
594 * @param options Options object with settings to adjust how the styles are generated.
595 * @param path An array of strings representing the path to the style value in the style object.
596 * @param ruleKeys An array of CSS property keys and patterns.
597 * @param individualProperties The "sides" or individual properties for which to generate rules.
598 *
599 * @return GeneratedCSSRule[] CSS rules.
600 */
601 function generateBoxRules(style, options, path, ruleKeys, individualProperties = ['top', 'right', 'bottom', 'left']) {
602 const boxStyle = getStyleValueByPath(style, path);
603 if (!boxStyle) {
604 return [];
605 }
606 const rules = [];
607 if (typeof boxStyle === 'string') {
608 rules.push({
609 selector: options?.selector,
610 key: ruleKeys.default,
611 value: boxStyle
612 });
613 } else {
614 const sideRules = individualProperties.reduce((acc, side) => {
615 const value = getCSSValueFromRawStyle(getStyleValueByPath(boxStyle, [side]));
616 if (value) {
617 acc.push({
618 selector: options?.selector,
619 key: ruleKeys?.individual.replace('%s', upperFirst(side)),
620 value
621 });
622 }
623 return acc;
624 }, []);
625 rules.push(...sideRules);
626 }
627 return rules;
628 }
629
630 /**
631 * Returns a WordPress CSS custom var value from incoming style preset value,
632 * if one is detected.
633 *
634 * The preset value is a string and follows the pattern `var:description|context|slug`.
635 *
636 * Example:
637 *
638 * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)'
639 *
640 * @param styleValue A string representing a raw CSS value. Non-strings won't be processed.
641 *
642 * @return A CSS custom var value if the incoming style value is a preset value.
643 */
644
645 function getCSSValueFromRawStyle(styleValue) {
646 if (typeof styleValue === 'string' && styleValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
647 const variable = styleValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(presetVariable => paramCase(presetVariable, {
648 splitRegexp: [/([a-z0-9])([A-Z])/g,
649 // fooBar => foo-bar, 3Bar => 3-bar
650 /([0-9])([a-z])/g,
651 // 3bar => 3-bar
652 /([A-Za-z])([0-9])/g,
653 // Foo3 => foo-3, foo3 => foo-3
654 /([A-Z])([A-Z][a-z])/g // FOOBar => foo-bar
655 ]
656 })).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
657 return `var(--wp--${variable})`;
658 }
659 return styleValue;
660 }
661
662 /**
663 * Capitalizes the first letter in a string.
664 *
665 * @param string The string whose first letter the function will capitalize.
666 *
667 * @return String with the first letter capitalized.
668 */
669 function upperFirst(string) {
670 const [firstLetter, ...rest] = string;
671 return firstLetter.toUpperCase() + rest.join('');
672 }
673
674 /**
675 * Converts an array of strings into a camelCase string.
676 *
677 * @param strings The strings to join into a camelCase string.
678 *
679 * @return camelCase string.
680 */
681 function camelCaseJoin(strings) {
682 const [firstItem, ...rest] = strings;
683 return firstItem.toLowerCase() + rest.map(upperFirst).join('');
684 }
685
686 /**
687 * Safely decodes a URI with `decodeURI`. Returns the URI unmodified if
688 * `decodeURI` throws an error.
689 *
690 * @param {string} uri URI to decode.
691 *
692 * @example
693 * ```js
694 * const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z'
695 * ```
696 *
697 * @return {string} Decoded URI if possible.
698 */
699 function safeDecodeURI(uri) {
700 try {
701 return decodeURI(uri);
702 } catch (uriError) {
703 return uri;
704 }
705 }
706
707 ;// ./packages/style-engine/build-module/styles/border/index.js
708 /**
709 * Internal dependencies
710 */
711
712
713
714 /**
715 * Creates a function for generating CSS rules when the style path is the same as the camelCase CSS property used in React.
716 *
717 * @param path An array of strings representing the path to the style value in the style object.
718 *
719 * @return A function that generates CSS rules.
720 */
721 function createBorderGenerateFunction(path) {
722 return (style, options) => generateRule(style, options, path, camelCaseJoin(path));
723 }
724
725 /**
726 * Creates a function for generating border-{top,bottom,left,right}-{color,style,width} CSS rules.
727 *
728 * @param edge The edge to create CSS rules for.
729 *
730 * @return A function that generates CSS rules.
731 */
732 function createBorderEdgeGenerateFunction(edge) {
733 return (style, options) => {
734 return ['color', 'style', 'width'].flatMap(key => {
735 const path = ['border', edge, key];
736 return createBorderGenerateFunction(path)(style, options);
737 });
738 };
739 }
740 const color = {
741 name: 'color',
742 generate: createBorderGenerateFunction(['border', 'color'])
743 };
744 const radius = {
745 name: 'radius',
746 generate: (style, options) => {
747 return generateBoxRules(style, options, ['border', 'radius'], {
748 default: 'borderRadius',
749 individual: 'border%sRadius'
750 }, ['topLeft', 'topRight', 'bottomLeft', 'bottomRight']);
751 }
752 };
753 const borderStyle = {
754 name: 'style',
755 generate: createBorderGenerateFunction(['border', 'style'])
756 };
757 const width = {
758 name: 'width',
759 generate: createBorderGenerateFunction(['border', 'width'])
760 };
761 const borderTop = {
762 name: 'borderTop',
763 generate: createBorderEdgeGenerateFunction('top')
764 };
765 const borderRight = {
766 name: 'borderRight',
767 generate: createBorderEdgeGenerateFunction('right')
768 };
769 const borderBottom = {
770 name: 'borderBottom',
771 generate: createBorderEdgeGenerateFunction('bottom')
772 };
773 const borderLeft = {
774 name: 'borderLeft',
775 generate: createBorderEdgeGenerateFunction('left')
776 };
777 /* harmony default export */ const border = ([color, borderStyle, width, radius, borderTop, borderRight, borderBottom, borderLeft]);
778
779 ;// ./packages/style-engine/build-module/styles/color/background.js
780 /**
781 * Internal dependencies
782 */
783
784
785 const background = {
786 name: 'background',
787 generate: (style, options) => {
788 return generateRule(style, options, ['color', 'background'], 'backgroundColor');
789 }
790 };
791 /* harmony default export */ const color_background = (background);
792
793 ;// ./packages/style-engine/build-module/styles/color/gradient.js
794 /**
795 * Internal dependencies
796 */
797
798
799 const gradient = {
800 name: 'gradient',
801 generate: (style, options) => {
802 return generateRule(style, options, ['color', 'gradient'], 'background');
803 }
804 };
805 /* harmony default export */ const color_gradient = (gradient);
806
807 ;// ./packages/style-engine/build-module/styles/color/text.js
808 /**
809 * Internal dependencies
810 */
811
812
813 const text_text = {
814 name: 'text',
815 generate: (style, options) => {
816 return generateRule(style, options, ['color', 'text'], 'color');
817 }
818 };
819 /* harmony default export */ const color_text = (text_text);
820
821 ;// ./packages/style-engine/build-module/styles/color/index.js
822 /**
823 * Internal dependencies
824 */
825
826
827
828 /* harmony default export */ const styles_color = ([color_text, color_gradient, color_background]);
829
830 ;// ./packages/style-engine/build-module/styles/dimensions/index.js
831 /**
832 * Internal dependencies
833 */
834
835
836 const minHeight = {
837 name: 'minHeight',
838 generate: (style, options) => {
839 return generateRule(style, options, ['dimensions', 'minHeight'], 'minHeight');
840 }
841 };
842 const aspectRatio = {
843 name: 'aspectRatio',
844 generate: (style, options) => {
845 return generateRule(style, options, ['dimensions', 'aspectRatio'], 'aspectRatio');
846 }
847 };
848 /* harmony default export */ const dimensions = ([minHeight, aspectRatio]);
849
850 ;// ./packages/style-engine/build-module/styles/background/index.js
851 /**
852 * Internal dependencies
853 */
854
855
856 const backgroundImage = {
857 name: 'backgroundImage',
858 generate: (style, options) => {
859 const _backgroundImage = style?.background?.backgroundImage;
860
861 /*
862 * The background image can be a string or an object.
863 * If the background image is a string, it could already contain a url() function,
864 * or have a linear-gradient value.
865 */
866 if (typeof _backgroundImage === 'object' && _backgroundImage?.url) {
867 return [{
868 selector: options.selector,
869 key: 'backgroundImage',
870 // Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.
871 value: `url( '${encodeURI(safeDecodeURI(_backgroundImage.url))}' )`
872 }];
873 }
874 return generateRule(style, options, ['background', 'backgroundImage'], 'backgroundImage');
875 }
876 };
877 const backgroundPosition = {
878 name: 'backgroundPosition',
879 generate: (style, options) => {
880 return generateRule(style, options, ['background', 'backgroundPosition'], 'backgroundPosition');
881 }
882 };
883 const backgroundRepeat = {
884 name: 'backgroundRepeat',
885 generate: (style, options) => {
886 return generateRule(style, options, ['background', 'backgroundRepeat'], 'backgroundRepeat');
887 }
888 };
889 const backgroundSize = {
890 name: 'backgroundSize',
891 generate: (style, options) => {
892 return generateRule(style, options, ['background', 'backgroundSize'], 'backgroundSize');
893 }
894 };
895 const backgroundAttachment = {
896 name: 'backgroundAttachment',
897 generate: (style, options) => {
898 return generateRule(style, options, ['background', 'backgroundAttachment'], 'backgroundAttachment');
899 }
900 };
901 /* harmony default export */ const styles_background = ([backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize, backgroundAttachment]);
902
903 ;// ./packages/style-engine/build-module/styles/shadow/index.js
904 /**
905 * Internal dependencies
906 */
907
908
909 const shadow = {
910 name: 'shadow',
911 generate: (style, options) => {
912 return generateRule(style, options, ['shadow'], 'boxShadow');
913 }
914 };
915 /* harmony default export */ const styles_shadow = ([shadow]);
916
917 ;// ./packages/style-engine/build-module/styles/outline/index.js
918 /**
919 * Internal dependencies
920 */
921
922
923 const outline_color = {
924 name: 'color',
925 generate: (style, options, path = ['outline', 'color'], ruleKey = 'outlineColor') => {
926 return generateRule(style, options, path, ruleKey);
927 }
928 };
929 const offset = {
930 name: 'offset',
931 generate: (style, options, path = ['outline', 'offset'], ruleKey = 'outlineOffset') => {
932 return generateRule(style, options, path, ruleKey);
933 }
934 };
935 const outlineStyle = {
936 name: 'style',
937 generate: (style, options, path = ['outline', 'style'], ruleKey = 'outlineStyle') => {
938 return generateRule(style, options, path, ruleKey);
939 }
940 };
941 const outline_width = {
942 name: 'width',
943 generate: (style, options, path = ['outline', 'width'], ruleKey = 'outlineWidth') => {
944 return generateRule(style, options, path, ruleKey);
945 }
946 };
947 /* harmony default export */ const outline = ([outline_color, outlineStyle, offset, outline_width]);
948
949 ;// ./packages/style-engine/build-module/styles/spacing/padding.js
950 /**
951 * Internal dependencies
952 */
953
954
955 const padding = {
956 name: 'padding',
957 generate: (style, options) => {
958 return generateBoxRules(style, options, ['spacing', 'padding'], {
959 default: 'padding',
960 individual: 'padding%s'
961 });
962 }
963 };
964 /* harmony default export */ const spacing_padding = (padding);
965
966 ;// ./packages/style-engine/build-module/styles/spacing/margin.js
967 /**
968 * Internal dependencies
969 */
970
971
972 const margin = {
973 name: 'margin',
974 generate: (style, options) => {
975 return generateBoxRules(style, options, ['spacing', 'margin'], {
976 default: 'margin',
977 individual: 'margin%s'
978 });
979 }
980 };
981 /* harmony default export */ const spacing_margin = (margin);
982
983 ;// ./packages/style-engine/build-module/styles/spacing/index.js
984 /**
985 * Internal dependencies
986 */
987
988
989 /* harmony default export */ const spacing = ([spacing_margin, spacing_padding]);
990
991 ;// ./packages/style-engine/build-module/styles/typography/index.js
992 /**
993 * Internal dependencies
994 */
995
996
997 const fontSize = {
998 name: 'fontSize',
999 generate: (style, options) => {
1000 return generateRule(style, options, ['typography', 'fontSize'], 'fontSize');
1001 }
1002 };
1003 const fontStyle = {
1004 name: 'fontStyle',
1005 generate: (style, options) => {
1006 return generateRule(style, options, ['typography', 'fontStyle'], 'fontStyle');
1007 }
1008 };
1009 const fontWeight = {
1010 name: 'fontWeight',
1011 generate: (style, options) => {
1012 return generateRule(style, options, ['typography', 'fontWeight'], 'fontWeight');
1013 }
1014 };
1015 const fontFamily = {
1016 name: 'fontFamily',
1017 generate: (style, options) => {
1018 return generateRule(style, options, ['typography', 'fontFamily'], 'fontFamily');
1019 }
1020 };
1021 const letterSpacing = {
1022 name: 'letterSpacing',
1023 generate: (style, options) => {
1024 return generateRule(style, options, ['typography', 'letterSpacing'], 'letterSpacing');
1025 }
1026 };
1027 const lineHeight = {
1028 name: 'lineHeight',
1029 generate: (style, options) => {
1030 return generateRule(style, options, ['typography', 'lineHeight'], 'lineHeight');
1031 }
1032 };
1033 const textColumns = {
1034 name: 'textColumns',
1035 generate: (style, options) => {
1036 return generateRule(style, options, ['typography', 'textColumns'], 'columnCount');
1037 }
1038 };
1039 const textDecoration = {
1040 name: 'textDecoration',
1041 generate: (style, options) => {
1042 return generateRule(style, options, ['typography', 'textDecoration'], 'textDecoration');
1043 }
1044 };
1045 const textTransform = {
1046 name: 'textTransform',
1047 generate: (style, options) => {
1048 return generateRule(style, options, ['typography', 'textTransform'], 'textTransform');
1049 }
1050 };
1051 const writingMode = {
1052 name: 'writingMode',
1053 generate: (style, options) => {
1054 return generateRule(style, options, ['typography', 'writingMode'], 'writingMode');
1055 }
1056 };
1057 /* harmony default export */ const typography = ([fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textColumns, textDecoration, textTransform, writingMode]);
1058
1059 ;// ./packages/style-engine/build-module/styles/index.js
1060 /**
1061 * Internal dependencies
1062 */
1063
1064
1065
1066
1067
1068
1069
1070
1071 const styleDefinitions = [...border, ...styles_color, ...dimensions, ...outline, ...spacing, ...typography, ...styles_shadow, ...styles_background];
1072
1073 ;// ./packages/style-engine/build-module/index.js
1074 /**
1075 * External dependencies
1076 */
1077
1078
1079 /**
1080 * Internal dependencies
1081 */
1082
1083
1084
1085 /**
1086 * Generates a stylesheet for a given style object and selector.
1087 *
1088 * @since 6.1.0 Introduced in WordPress core.
1089 *
1090 * @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json
1091 * @param options Options object with settings to adjust how the styles are generated.
1092 *
1093 * @return A generated stylesheet or inline style declarations.
1094 */
1095 function compileCSS(style, options = {}) {
1096 const rules = getCSSRules(style, options);
1097
1098 // If no selector is provided, treat generated rules as inline styles to be returned as a single string.
1099 if (!options?.selector) {
1100 const inlineRules = [];
1101 rules.forEach(rule => {
1102 inlineRules.push(`${paramCase(rule.key)}: ${rule.value};`);
1103 });
1104 return inlineRules.join(' ');
1105 }
1106 const groupedRules = rules.reduce((acc, rule) => {
1107 const {
1108 selector
1109 } = rule;
1110 if (!selector) {
1111 return acc;
1112 }
1113 if (!acc[selector]) {
1114 acc[selector] = [];
1115 }
1116 acc[selector].push(rule);
1117 return acc;
1118 }, {});
1119 const selectorRules = Object.keys(groupedRules).reduce((acc, subSelector) => {
1120 acc.push(`${subSelector} { ${groupedRules[subSelector].map(rule => `${paramCase(rule.key)}: ${rule.value};`).join(' ')} }`);
1121 return acc;
1122 }, []);
1123 return selectorRules.join('\n');
1124 }
1125
1126 /**
1127 * Returns a JSON representation of the generated CSS rules.
1128 *
1129 * @since 6.1.0 Introduced in WordPress core.
1130 *
1131 * @param style Style object, for example, the value of a block's attributes.style object or the top level styles in theme.json
1132 * @param options Options object with settings to adjust how the styles are generated.
1133 *
1134 * @return A collection of objects containing the selector, if any, the CSS property key (camelcase) and parsed CSS value.
1135 */
1136 function getCSSRules(style, options = {}) {
1137 const rules = [];
1138 styleDefinitions.forEach(definition => {
1139 if (typeof definition.generate === 'function') {
1140 rules.push(...definition.generate(style, options));
1141 }
1142 });
1143 return rules;
1144 }
1145
1146 // Export style utils.
1147
1148
1149 (window.wp = window.wp || {}).styleEngine = __webpack_exports__;
1150 /******/ })()
1151 ;