PageSourceSearch

https://servas.org/modules/contrib/gutenberg/js/vendor/gutenberg/style-engine/index.js?tm9b27

js servas.org collected 2026-10-02 06:21:15 UTC 37,469 bytes, 1,095 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.