[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/js/dist/ -> list-reusable-blocks.js (source)

   1  /******/ (() => { // webpackBootstrap
   2  /******/     "use strict";
   3  /******/     // The require scope
   4  /******/     var __webpack_require__ = {};
   5  /******/     
   6  /************************************************************************/
   7  /******/     /* webpack/runtime/compat get default export */
   8  /******/     (() => {
   9  /******/         // getDefaultExport function for compatibility with non-harmony modules
  10  /******/         __webpack_require__.n = (module) => {
  11  /******/             var getter = module && module.__esModule ?
  12  /******/                 () => (module['default']) :
  13  /******/                 () => (module);
  14  /******/             __webpack_require__.d(getter, { a: getter });
  15  /******/             return getter;
  16  /******/         };
  17  /******/     })();
  18  /******/     
  19  /******/     /* webpack/runtime/define property getters */
  20  /******/     (() => {
  21  /******/         // define getter functions for harmony exports
  22  /******/         __webpack_require__.d = (exports, definition) => {
  23  /******/             for(var key in definition) {
  24  /******/                 if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  25  /******/                     Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  26  /******/                 }
  27  /******/             }
  28  /******/         };
  29  /******/     })();
  30  /******/     
  31  /******/     /* webpack/runtime/hasOwnProperty shorthand */
  32  /******/     (() => {
  33  /******/         __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  34  /******/     })();
  35  /******/     
  36  /************************************************************************/
  37  var __webpack_exports__ = {};
  38  
  39  ;// external ["wp","element"]
  40  const external_wp_element_namespaceObject = window["wp"]["element"];
  41  ;// external ["wp","i18n"]
  42  const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
  43  ;// ./node_modules/tslib/tslib.es6.mjs
  44  /******************************************************************************
  45  Copyright (c) Microsoft Corporation.
  46  
  47  Permission to use, copy, modify, and/or distribute this software for any
  48  purpose with or without fee is hereby granted.
  49  
  50  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  51  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  52  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  53  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  54  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  55  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  56  PERFORMANCE OF THIS SOFTWARE.
  57  ***************************************************************************** */
  58  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
  59  
  60  var extendStatics = function(d, b) {
  61    extendStatics = Object.setPrototypeOf ||
  62        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  63        function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  64    return extendStatics(d, b);
  65  };
  66  
  67  function __extends(d, b) {
  68    if (typeof b !== "function" && b !== null)
  69        throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  70    extendStatics(d, b);
  71    function __() { this.constructor = d; }
  72    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  73  }
  74  
  75  var __assign = function() {
  76    __assign = Object.assign || function __assign(t) {
  77        for (var s, i = 1, n = arguments.length; i < n; i++) {
  78            s = arguments[i];
  79            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  80        }
  81        return t;
  82    }
  83    return __assign.apply(this, arguments);
  84  }
  85  
  86  function __rest(s, e) {
  87    var t = {};
  88    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  89        t[p] = s[p];
  90    if (s != null && typeof Object.getOwnPropertySymbols === "function")
  91        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  92            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  93                t[p[i]] = s[p[i]];
  94        }
  95    return t;
  96  }
  97  
  98  function __decorate(decorators, target, key, desc) {
  99    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
 100    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
 101    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;
 102    return c > 3 && r && Object.defineProperty(target, key, r), r;
 103  }
 104  
 105  function __param(paramIndex, decorator) {
 106    return function (target, key) { decorator(target, key, paramIndex); }
 107  }
 108  
 109  function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
 110    function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
 111    var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
 112    var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
 113    var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
 114    var _, done = false;
 115    for (var i = decorators.length - 1; i >= 0; i--) {
 116        var context = {};
 117        for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
 118        for (var p in contextIn.access) context.access[p] = contextIn.access[p];
 119        context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
 120        var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
 121        if (kind === "accessor") {
 122            if (result === void 0) continue;
 123            if (result === null || typeof result !== "object") throw new TypeError("Object expected");
 124            if (_ = accept(result.get)) descriptor.get = _;
 125            if (_ = accept(result.set)) descriptor.set = _;
 126            if (_ = accept(result.init)) initializers.unshift(_);
 127        }
 128        else if (_ = accept(result)) {
 129            if (kind === "field") initializers.unshift(_);
 130            else descriptor[key] = _;
 131        }
 132    }
 133    if (target) Object.defineProperty(target, contextIn.name, descriptor);
 134    done = true;
 135  };
 136  
 137  function __runInitializers(thisArg, initializers, value) {
 138    var useValue = arguments.length > 2;
 139    for (var i = 0; i < initializers.length; i++) {
 140        value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
 141    }
 142    return useValue ? value : void 0;
 143  };
 144  
 145  function __propKey(x) {
 146    return typeof x === "symbol" ? x : "".concat(x);
 147  };
 148  
 149  function __setFunctionName(f, name, prefix) {
 150    if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
 151    return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
 152  };
 153  
 154  function __metadata(metadataKey, metadataValue) {
 155    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
 156  }
 157  
 158  function __awaiter(thisArg, _arguments, P, generator) {
 159    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
 160    return new (P || (P = Promise))(function (resolve, reject) {
 161        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
 162        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
 163        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
 164        step((generator = generator.apply(thisArg, _arguments || [])).next());
 165    });
 166  }
 167  
 168  function __generator(thisArg, body) {
 169    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);
 170    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
 171    function verb(n) { return function (v) { return step([n, v]); }; }
 172    function step(op) {
 173        if (f) throw new TypeError("Generator is already executing.");
 174        while (g && (g = 0, op[0] && (_ = 0)), _) try {
 175            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;
 176            if (y = 0, t) op = [op[0] & 2, t.value];
 177            switch (op[0]) {
 178                case 0: case 1: t = op; break;
 179                case 4: _.label++; return { value: op[1], done: false };
 180                case 5: _.label++; y = op[1]; op = [0]; continue;
 181                case 7: op = _.ops.pop(); _.trys.pop(); continue;
 182                default:
 183                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
 184                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
 185                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
 186                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
 187                    if (t[2]) _.ops.pop();
 188                    _.trys.pop(); continue;
 189            }
 190            op = body.call(thisArg, _);
 191        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
 192        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
 193    }
 194  }
 195  
 196  var __createBinding = Object.create ? (function(o, m, k, k2) {
 197    if (k2 === undefined) k2 = k;
 198    var desc = Object.getOwnPropertyDescriptor(m, k);
 199    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
 200        desc = { enumerable: true, get: function() { return m[k]; } };
 201    }
 202    Object.defineProperty(o, k2, desc);
 203  }) : (function(o, m, k, k2) {
 204    if (k2 === undefined) k2 = k;
 205    o[k2] = m[k];
 206  });
 207  
 208  function __exportStar(m, o) {
 209    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
 210  }
 211  
 212  function __values(o) {
 213    var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
 214    if (m) return m.call(o);
 215    if (o && typeof o.length === "number") return {
 216        next: function () {
 217            if (o && i >= o.length) o = void 0;
 218            return { value: o && o[i++], done: !o };
 219        }
 220    };
 221    throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
 222  }
 223  
 224  function __read(o, n) {
 225    var m = typeof Symbol === "function" && o[Symbol.iterator];
 226    if (!m) return o;
 227    var i = m.call(o), r, ar = [], e;
 228    try {
 229        while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
 230    }
 231    catch (error) { e = { error: error }; }
 232    finally {
 233        try {
 234            if (r && !r.done && (m = i["return"])) m.call(i);
 235        }
 236        finally { if (e) throw e.error; }
 237    }
 238    return ar;
 239  }
 240  
 241  /** @deprecated */
 242  function __spread() {
 243    for (var ar = [], i = 0; i < arguments.length; i++)
 244        ar = ar.concat(__read(arguments[i]));
 245    return ar;
 246  }
 247  
 248  /** @deprecated */
 249  function __spreadArrays() {
 250    for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
 251    for (var r = Array(s), k = 0, i = 0; i < il; i++)
 252        for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
 253            r[k] = a[j];
 254    return r;
 255  }
 256  
 257  function __spreadArray(to, from, pack) {
 258    if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
 259        if (ar || !(i in from)) {
 260            if (!ar) ar = Array.prototype.slice.call(from, 0, i);
 261            ar[i] = from[i];
 262        }
 263    }
 264    return to.concat(ar || Array.prototype.slice.call(from));
 265  }
 266  
 267  function __await(v) {
 268    return this instanceof __await ? (this.v = v, this) : new __await(v);
 269  }
 270  
 271  function __asyncGenerator(thisArg, _arguments, generator) {
 272    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
 273    var g = generator.apply(thisArg, _arguments || []), i, q = [];
 274    return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
 275    function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
 276    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]); } }
 277    function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
 278    function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
 279    function fulfill(value) { resume("next", value); }
 280    function reject(value) { resume("throw", value); }
 281    function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
 282  }
 283  
 284  function __asyncDelegator(o) {
 285    var i, p;
 286    return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
 287    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; }
 288  }
 289  
 290  function __asyncValues(o) {
 291    if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
 292    var m = o[Symbol.asyncIterator], i;
 293    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);
 294    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); }); }; }
 295    function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
 296  }
 297  
 298  function __makeTemplateObject(cooked, raw) {
 299    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
 300    return cooked;
 301  };
 302  
 303  var __setModuleDefault = Object.create ? (function(o, v) {
 304    Object.defineProperty(o, "default", { enumerable: true, value: v });
 305  }) : function(o, v) {
 306    o["default"] = v;
 307  };
 308  
 309  function __importStar(mod) {
 310    if (mod && mod.__esModule) return mod;
 311    var result = {};
 312    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
 313    __setModuleDefault(result, mod);
 314    return result;
 315  }
 316  
 317  function __importDefault(mod) {
 318    return (mod && mod.__esModule) ? mod : { default: mod };
 319  }
 320  
 321  function __classPrivateFieldGet(receiver, state, kind, f) {
 322    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
 323    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");
 324    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
 325  }
 326  
 327  function __classPrivateFieldSet(receiver, state, value, kind, f) {
 328    if (kind === "m") throw new TypeError("Private method is not writable");
 329    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
 330    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");
 331    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
 332  }
 333  
 334  function __classPrivateFieldIn(state, receiver) {
 335    if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
 336    return typeof state === "function" ? receiver === state : state.has(receiver);
 337  }
 338  
 339  function __addDisposableResource(env, value, async) {
 340    if (value !== null && value !== void 0) {
 341      if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
 342      var dispose, inner;
 343      if (async) {
 344        if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
 345        dispose = value[Symbol.asyncDispose];
 346      }
 347      if (dispose === void 0) {
 348        if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
 349        dispose = value[Symbol.dispose];
 350        if (async) inner = dispose;
 351      }
 352      if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
 353      if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
 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  
 362  var _SuppressedError = typeof 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  
 367  function __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    var r, s = 0;
 373    function next() {
 374      while (r = env.stack.pop()) {
 375        try {
 376          if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
 377          if (r.dispose) {
 378            var result = r.dispose.call(r.value);
 379            if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
 380          }
 381          else s |= 1;
 382        }
 383        catch (e) {
 384          fail(e);
 385        }
 386      }
 387      if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
 388      if (env.hasError) throw env.error;
 389    }
 390    return next();
 391  }
 392  
 393  /* harmony default export */ const tslib_es6 = ({
 394    __extends,
 395    __assign,
 396    __rest,
 397    __decorate,
 398    __param,
 399    __metadata,
 400    __awaiter,
 401    __generator,
 402    __createBinding,
 403    __exportStar,
 404    __values,
 405    __read,
 406    __spread,
 407    __spreadArrays,
 408    __spreadArray,
 409    __await,
 410    __asyncGenerator,
 411    __asyncDelegator,
 412    __asyncValues,
 413    __makeTemplateObject,
 414    __importStar,
 415    __importDefault,
 416    __classPrivateFieldGet,
 417    __classPrivateFieldSet,
 418    __classPrivateFieldIn,
 419    __addDisposableResource,
 420    __disposeResources,
 421  });
 422  
 423  ;// ./node_modules/lower-case/dist.es2015/index.js
 424  /**
 425   * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
 426   */
 427  var SUPPORTED_LOCALE = {
 428      tr: {
 429          regexp: /\u0130|\u0049|\u0049\u0307/g,
 430          map: {
 431              İ: "\u0069",
 432              I: "\u0131",
 433              İ: "\u0069",
 434          },
 435      },
 436      az: {
 437          regexp: /\u0130/g,
 438          map: {
 439              İ: "\u0069",
 440              I: "\u0131",
 441              İ: "\u0069",
 442          },
 443      },
 444      lt: {
 445          regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
 446          map: {
 447              I: "\u0069\u0307",
 448              J: "\u006A\u0307",
 449              Į: "\u012F\u0307",
 450              Ì: "\u0069\u0307\u0300",
 451              Í: "\u0069\u0307\u0301",
 452              Ĩ: "\u0069\u0307\u0303",
 453          },
 454      },
 455  };
 456  /**
 457   * Localized lower case.
 458   */
 459  function localeLowerCase(str, locale) {
 460      var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
 461      if (lang)
 462          return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
 463      return lowerCase(str);
 464  }
 465  /**
 466   * Lower case as a function.
 467   */
 468  function lowerCase(str) {
 469      return str.toLowerCase();
 470  }
 471  
 472  ;// ./node_modules/no-case/dist.es2015/index.js
 473  
 474  // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
 475  var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
 476  // Remove all non-word characters.
 477  var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
 478  /**
 479   * Normalize the string into something other libraries can manipulate easier.
 480   */
 481  function noCase(input, options) {
 482      if (options === void 0) { options = {}; }
 483      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;
 484      var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
 485      var start = 0;
 486      var end = result.length;
 487      // Trim the delimiter from around the output string.
 488      while (result.charAt(start) === "\0")
 489          start++;
 490      while (result.charAt(end - 1) === "\0")
 491          end--;
 492      // Transform each token independently.
 493      return result.slice(start, end).split("\0").map(transform).join(delimiter);
 494  }
 495  /**
 496   * Replace `re` in the input string with the replacement value.
 497   */
 498  function replace(input, re, value) {
 499      if (re instanceof RegExp)
 500          return input.replace(re, value);
 501      return re.reduce(function (input, re) { return input.replace(re, value); }, input);
 502  }
 503  
 504  ;// ./node_modules/dot-case/dist.es2015/index.js
 505  
 506  
 507  function dotCase(input, options) {
 508      if (options === void 0) { options = {}; }
 509      return noCase(input, __assign({ delimiter: "." }, options));
 510  }
 511  
 512  ;// ./node_modules/param-case/dist.es2015/index.js
 513  
 514  
 515  function paramCase(input, options) {
 516      if (options === void 0) { options = {}; }
 517      return dotCase(input, __assign({ delimiter: "-" }, options));
 518  }
 519  
 520  ;// external ["wp","apiFetch"]
 521  const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
 522  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
 523  ;// external ["wp","blob"]
 524  const external_wp_blob_namespaceObject = window["wp"]["blob"];
 525  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
 526  /**
 527   * External dependencies
 528   */
 529  
 530  
 531  /**
 532   * WordPress dependencies
 533   */
 534  
 535  
 536  /**
 537   * Internal dependencies
 538   */
 539  
 540  
 541  /**
 542   * Export a reusable block as a JSON file.
 543   *
 544   * @param {number} id
 545   */
 546  async function exportReusableBlock(id) {
 547    const postType = await external_wp_apiFetch_default()({
 548      path: `/wp/v2/types/wp_block`
 549    });
 550    const post = await external_wp_apiFetch_default()({
 551      path: `/wp/v2/$postType.rest_base}/$id}?context=edit`
 552    });
 553    const title = post.title.raw;
 554    const content = post.content.raw;
 555    const syncStatus = post.wp_pattern_sync_status;
 556    const fileContent = JSON.stringify({
 557      __file: 'wp_block',
 558      title,
 559      content,
 560      syncStatus
 561    }, null, 2);
 562    const fileName = paramCase(title) + '.json';
 563    (0,external_wp_blob_namespaceObject.downloadBlob)(fileName, fileContent, 'application/json');
 564  }
 565  /* harmony default export */ const utils_export = (exportReusableBlock);
 566  
 567  ;// external ["wp","compose"]
 568  const external_wp_compose_namespaceObject = window["wp"]["compose"];
 569  ;// external ["wp","components"]
 570  const external_wp_components_namespaceObject = window["wp"]["components"];
 571  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
 572  /**
 573   * Reads the textual content of the given file.
 574   *
 575   * @param {File} file File.
 576   * @return {Promise<string>}  Content of the file.
 577   */
 578  function readTextFile(file) {
 579    const reader = new window.FileReader();
 580    return new Promise(resolve => {
 581      reader.onload = () => {
 582        resolve(reader.result);
 583      };
 584      reader.readAsText(file);
 585    });
 586  }
 587  
 588  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
 589  /**
 590   * WordPress dependencies
 591   */
 592  
 593  
 594  /**
 595   * Internal dependencies
 596   */
 597  
 598  
 599  /**
 600   * Import a reusable block from a JSON file.
 601   *
 602   * @param {File} file File.
 603   * @return {Promise} Promise returning the imported reusable block.
 604   */
 605  async function importReusableBlock(file) {
 606    const fileContent = await readTextFile(file);
 607    let parsedContent;
 608    try {
 609      parsedContent = JSON.parse(fileContent);
 610    } catch (e) {
 611      throw new Error('Invalid JSON file');
 612    }
 613    if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
 614      throw new Error('Invalid pattern JSON file');
 615    }
 616    const postType = await external_wp_apiFetch_default()({
 617      path: `/wp/v2/types/wp_block`
 618    });
 619    const reusableBlock = await external_wp_apiFetch_default()({
 620      path: `/wp/v2/$postType.rest_base}`,
 621      data: {
 622        title: parsedContent.title,
 623        content: parsedContent.content,
 624        status: 'publish',
 625        meta: parsedContent.syncStatus === 'unsynced' ? {
 626          wp_pattern_sync_status: parsedContent.syncStatus
 627        } : undefined
 628      },
 629      method: 'POST'
 630    });
 631    return reusableBlock;
 632  }
 633  /* harmony default export */ const utils_import = (importReusableBlock);
 634  
 635  ;// external "ReactJSXRuntime"
 636  const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
 637  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
 638  /**
 639   * WordPress dependencies
 640   */
 641  
 642  
 643  
 644  
 645  
 646  /**
 647   * Internal dependencies
 648   */
 649  
 650  
 651  
 652  function ImportForm({
 653    instanceId,
 654    onUpload
 655  }) {
 656    const inputId = 'list-reusable-blocks-import-form-' + instanceId;
 657    const formRef = (0,external_wp_element_namespaceObject.useRef)();
 658    const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
 659    const [error, setError] = (0,external_wp_element_namespaceObject.useState)(null);
 660    const [file, setFile] = (0,external_wp_element_namespaceObject.useState)(null);
 661    const onChangeFile = event => {
 662      setFile(event.target.files[0]);
 663      setError(null);
 664    };
 665    const onSubmit = event => {
 666      event.preventDefault();
 667      if (!file) {
 668        return;
 669      }
 670      setIsLoading({
 671        isLoading: true
 672      });
 673      utils_import(file).then(reusableBlock => {
 674        if (!formRef) {
 675          return;
 676        }
 677        setIsLoading(false);
 678        onUpload(reusableBlock);
 679      }).catch(errors => {
 680        if (!formRef) {
 681          return;
 682        }
 683        let uiMessage;
 684        switch (errors.message) {
 685          case 'Invalid JSON file':
 686            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid JSON file');
 687            break;
 688          case 'Invalid pattern JSON file':
 689            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid pattern JSON file');
 690            break;
 691          default:
 692            uiMessage = (0,external_wp_i18n_namespaceObject.__)('Unknown error');
 693        }
 694        setIsLoading(false);
 695        setError(uiMessage);
 696      });
 697    };
 698    const onDismissError = () => {
 699      setError(null);
 700    };
 701    return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("form", {
 702      className: "list-reusable-blocks-import-form",
 703      onSubmit: onSubmit,
 704      ref: formRef,
 705      children: [error && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
 706        status: "error",
 707        onRemove: () => onDismissError(),
 708        children: error
 709      }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
 710        htmlFor: inputId,
 711        className: "list-reusable-blocks-import-form__label",
 712        children: (0,external_wp_i18n_namespaceObject.__)('File')
 713      }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
 714        id: inputId,
 715        type: "file",
 716        onChange: onChangeFile
 717      }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
 718        __next40pxDefaultSize: true,
 719        type: "submit",
 720        isBusy: isLoading,
 721        accessibleWhenDisabled: true,
 722        disabled: !file || isLoading,
 723        variant: "secondary",
 724        className: "list-reusable-blocks-import-form__button",
 725        children: (0,external_wp_i18n_namespaceObject._x)('Import', 'button label')
 726      })]
 727    });
 728  }
 729  /* harmony default export */ const import_form = ((0,external_wp_compose_namespaceObject.withInstanceId)(ImportForm));
 730  
 731  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
 732  /**
 733   * WordPress dependencies
 734   */
 735  
 736  
 737  
 738  
 739  /**
 740   * Internal dependencies
 741   */
 742  
 743  
 744  function ImportDropdown({
 745    onUpload
 746  }) {
 747    return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
 748      popoverProps: {
 749        placement: 'bottom-start'
 750      },
 751      contentClassName: "list-reusable-blocks-import-dropdown__content",
 752      renderToggle: ({
 753        isOpen,
 754        onToggle
 755      }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
 756        size: "compact",
 757        className: "list-reusable-blocks-import-dropdown__button",
 758        "aria-expanded": isOpen,
 759        onClick: onToggle,
 760        variant: "primary",
 761        children: (0,external_wp_i18n_namespaceObject.__)('Import from JSON')
 762      }),
 763      renderContent: ({
 764        onClose
 765      }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_form, {
 766        onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload)
 767      })
 768    });
 769  }
 770  /* harmony default export */ const import_dropdown = (ImportDropdown);
 771  
 772  ;// ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
 773  /**
 774   * WordPress dependencies
 775   */
 776  
 777  
 778  
 779  /**
 780   * Internal dependencies
 781   */
 782  
 783  
 784  
 785  // Setup Export Links.
 786  
 787  document.body.addEventListener('click', event => {
 788    if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
 789      return;
 790    }
 791    event.preventDefault();
 792    utils_export(event.target.dataset.id);
 793  });
 794  
 795  // Setup Import Form.
 796  document.addEventListener('DOMContentLoaded', () => {
 797    const button = document.querySelector('.page-title-action');
 798    if (!button) {
 799      return;
 800    }
 801    const showNotice = () => {
 802      const notice = document.createElement('div');
 803      notice.className = 'notice notice-success is-dismissible';
 804      notice.innerHTML = `<p>${(0,external_wp_i18n_namespaceObject.__)('Pattern imported successfully!')}</p>`;
 805      const headerEnd = document.querySelector('.wp-header-end');
 806      if (!headerEnd) {
 807        return;
 808      }
 809      headerEnd.parentNode.insertBefore(notice, headerEnd);
 810    };
 811    const container = document.createElement('div');
 812    container.className = 'list-reusable-blocks__container';
 813    button.parentNode.insertBefore(container, button);
 814    (0,external_wp_element_namespaceObject.createRoot)(container).render( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.StrictMode, {
 815      children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_dropdown, {
 816        onUpload: showNotice
 817      })
 818    }));
 819  });
 820  
 821  (window.wp = window.wp || {}).listReusableBlocks = __webpack_exports__;
 822  /******/ })()
 823  ;


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref