WordPress/wp-includes/js/dist/api-fetch.min.js

2 lines
12 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.apiFetch=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s="jqrR")}({Ff2n:function(e,r,t){"use strict";function n(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t,n,o={},c=Object.keys(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||(o[t]=e[t]);return o}(e,r);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(n=0;n<c.length;n++)t=c[n],r.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}t.d(r,"a",(function(){return n}))},"HaE+":function(e,r,t){"use strict";function n(e,r,t,n,o,c,i){try{var a=e[c](i),u=a.value}catch(e){return void t(e)}a.done?r(u):Promise.resolve(u).then(n,o)}function o(e){return function(){var r=this,t=arguments;return new Promise((function(o,c){var i=e.apply(r,t);function a(e){n(i,o,c,a,u,"next",e)}function u(e){n(i,o,c,a,u,"throw",e)}a(void 0)}))}}t.d(r,"a",(function(){return o}))},Mmq9:function(e,r){e.exports=window.wp.url},dvlR:function(e,r){e.exports=window.regeneratorRuntime},jqrR:function(e,r,t){"use strict";t.r(r);var n=t("rePB"),o=t("Ff2n"),c=t("l3Sj");function i(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?i(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):i(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var u=function(e){function r(e,t){var n=e.headers,o=void 0===n?{}:n;for(var c in o)if("x-wp-nonce"===c.toLowerCase()&&o[c]===r.nonce)return t(e);return t(a(a({},e),{},{headers:a(a({},o),{},{"X-WP-Nonce":r.nonce})}))}return r.nonce=e,r};function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?s(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):s(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var f=function(e,r){var t,n,o=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(t=e.namespace.replace(/^\/|\/$/g,""),o=(n=e.endpoint.replace(/^\//,""))?t+"/"+n:t),delete e.namespace,delete e.endpoint,r(p(p({},e),{},{path:o}))};function l(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function O(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?l(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):l(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var b=function(e){return function(r,t){return f(r,(function(r){var n,o=r.url,c=r.path;return"string"==typeof c&&(n=e,-1!==e.indexOf("?")&&(c=c.replace("?","&")),c=c.replace(/^\//,""),"string"==typeof n&&-1!==n.indexOf("?")&&(c=c.replace("?","&")),o=n+c),t(O(O({},r),{},{url:o}))}))}};function d(e){var r=e.split("?"),t=r[1],n=r[0];return t?n+"?"+t.split("&").map((function(e){return e.split("=")})).sort((function(e,r){return e[0].localeCompare(r[0])})).map((function(e){return e.join("=")})).join("&"):n}var j=function(e){var r=Object.keys(e).reduce((function(r,t){return r[d(t)]=e[t],r}),{});return function(e,t){var n=e.parse,o=void 0===n||n;if("string"==typeof e.path){var c=e.method||"GET",i=d(e.path);if("GET"===c&&r[i]){var a=r[i];return delete r[i],Promise.resolve(o?a.body:new window.Response(JSON.stringify(a.body),{status:200,statusText:"OK",headers:a.headers}))}if("OPTIONS"===c&&r[c]&&r[c][i])return Promise.resolve(r[c][i])}return t(e)}},y=t("dvlR"),h=t.n(y),v=t("HaE+"),g=t("Mmq9");function w(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function P(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?w(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):w(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var m=function(e){return e.json?e.json():Promise.reject(e)},x=function(e){return function(e){if(!e)return{};var r=e.match(/<([^>]+)>; rel="next"/);return r?{next:r[1]}:{}}(e.headers.get("link")).next},D=function(e){var r=e.path&&-1!==e.path.indexOf("per_page=-1"),t=e.url&&-1!==e.url.indexOf("per_page=-1");return r||t},S=function(){var e=Object(v.a)(h.a.mark((function e(r,t){var n,c,i,a,u,s;return h.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==r.parse){e.next=2;break}return e.abrupt("return",t(r));case 2:if(D(r)){e.next=4;break}return e.abrupt("return",t(r));case 4:return e.next=6,B(P(P({},(f={per_page:100},l=void 0,O=void 0,l=(p=r).path,O=p.url,P(P({},Object(o.a)(p,["path","url"])),{},{url:O&&Object(g.addQueryArgs)(O,f),path:l&&Object(g.addQueryArgs)(l,f)}))),{},{parse:!1}));case 6:return n=e.sent,e.next=9,m(n);case 9:if(c=e.sent,Array.isArray(c)){e.next=12;break}return e.abrupt("return",c);case 12:if(i=x(n)){e.next=15;break}return e.abrupt("return",c);case 15:a=[].concat(c);case 16:if(!i){e.next=27;break}return e.next=19,B(P(P({},r),{},{path:void 0,url:i,parse:!1}));case 19:return u=e.sent,e.next=22,m(u);case 22:s=e.sent,a=a.concat(s),i=x(u),e.next=16;break;case 27:return e.abrupt("return",a);case 28:case"end":return e.stop()}var p,f,l,O}),e)})));return function(r,t){return e.apply(this,arguments)}}();function _(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function E(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?_(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):_(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var k=new Set(["PATCH","PUT","DELETE"]);var T=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return r?204===e.status?null:e.json?e.json():Promise.reject(e):e},M=function(e){var r={code:"invalid_json",message:Object(c.__)("The response is not a valid JSON response.")};if(!e||!e.json)throw r;return e.json().catch((function(){throw r}))},A=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Promise.resolve(T(e,r)).catch((function(e){return R(e,r)}))};function R(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!r)throw e;return M(e).then((function(e){var r={code:"unknown_error",message:Object(c.__)("An unknown error occurred.")};throw e||r}))}function C(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function N(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?C(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):C(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var Q=function(e,r){if(!(e.path&&-1!==e.path.indexOf("/wp/v2/media")||e.url&&-1!==e.url.indexOf("/wp/v2/media")))return r(e,r);var t=0;return r(N(N({},e),{},{parse:!1})).catch((function(n){var o=n.headers.get("x-wp-upload-attachment-id");return n.status>=500&&n.status<600&&o?function e(n){return t++,r({path:"/wp/v2/media/".concat(n,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return t<5?e(n):(r({path:"/wp/v2/media/".concat(n,"?force=true"),method:"DELETE"}),Promise.reject())}))}(o).catch((function(){return!1!==e.parse?Promise.reject({code:"post_process",message:Object(c.__)("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(n)})):R(n,e.parse)})).then((function(r){return A(r,e.parse)}))};function q(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function H(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?q(Object(t),!0).forEach((function(r){Object(n.a)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):q(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var F={Accept:"application/json, */*;q=0.1"},L={credentials:"include"},U=[function(e,r){return"string"!=typeof e.url||Object(g.hasQueryArg)(e.url,"_locale")||(e.url=Object(g.addQueryArgs)(e.url,{_locale:"user"})),"string"!=typeof e.path||Object(g.hasQueryArg)(e.path,"_locale")||(e.path=Object(g.addQueryArgs)(e.path,{_locale:"user"})),r(e)},f,function(e,r){var t=e.method,n=void 0===t?"GET":t;return k.has(n.toUpperCase())&&(e=E(E({},e),{},{headers:E(E({},e.headers),{},{"X-HTTP-Method-Override":n,"Content-Type":"application/json"}),method:"POST"})),r(e)},S];var G=function(e){if(e.status>=200&&e.status<300)return e;throw e},I=function(e){var r=e.url,t=e.path,n=e.data,i=e.parse,a=void 0===i||i,u=Object(o.a)(e,["url","path","data","parse"]),s=e.body,p=e.headers;return p=H(H({},F),p),n&&(s=JSON.stringify(n),p["Content-Type"]="application/json"),window.fetch(r||t,H(H(H({},L),u),{},{body:s,headers:p})).then((function(e){return Promise.resolve(e).then(G).catch((function(e){return R(e,a)})).then((function(e){return A(e,a)}))}),(function(){throw{code:"fetch_error",message:Object(c.__)("You are probably offline.")}}))};function J(e){return U.reduceRight((function(e,r){return function(t){return r(t,e)}}),I)(e).catch((function(r){return"rest_cookie_invalid_nonce"!==r.code?Promise.reject(r):window.fetch(J.nonceEndpoint).then(G).then((function(e){return e.text()})).then((function(r){return J.nonceMiddleware.nonce=r,J(e)}))}))}J.use=function(e){U.unshift(e)},J.setFetchHandler=function(e){I=e},J.createNonceMiddleware=u,J.createPreloadingMiddleware=j,J.createRootURLMiddleware=b,J.fetchAllMiddleware=S,J.mediaUploadMiddleware=Q;var B=r.default=J},l3Sj:function(e,r){e.exports=window.wp.i18n},rePB:function(e,r,t){"use strict";function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}t.d(r,"a",(function(){return n}))}}).default;