!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("decap-cms-lib-util"),require("decap-cms-lib-auth"),require("react"),require("@emotion/react"),require("prop-types"),require("decap-cms-ui-default")):"function"==typeof define&&define.amd?define("DecapCmsBackendBitbucket",["decap-cms-lib-util","decap-cms-lib-auth","react","@emotion/react","prop-types","decap-cms-ui-default"],t):"object"==typeof exports?exports.DecapCmsBackendBitbucket=t(require("decap-cms-lib-util"),require("decap-cms-lib-auth"),require("react"),require("@emotion/react"),require("prop-types"),require("decap-cms-ui-default")):e.DecapCmsBackendBitbucket=t(e.DecapCmsLibUtil,e.DecapCmsLibAuth,e.React,e.DecapCmsDefaultExports.EmotionCore,e.DecapCmsDefaultExports.PropTypes,e.DecapCmsUiDefault)}(window,((e,t,r,n,i,s)=>(()=>{var o={2294:e=>{"use strict";function t(e,t,i){e instanceof RegExp&&(e=r(e,i)),t instanceof RegExp&&(t=r(t,i));var s=n(e,t,i);return s&&{start:s[0],end:s[1],pre:i.slice(0,s[0]),body:i.slice(s[0]+e.length,s[1]),post:i.slice(s[1]+t.length)}}function r(e,t){var r=t.match(e);return r?r[0]:null}function n(e,t,r){var n,i,s,o,a,u=r.indexOf(e),c=r.indexOf(t,u+1),l=u;if(u>=0&&c>0){if(e===t)return[u,c];for(n=[],s=r.length;l>=0&&!a;)l==u?(n.push(l),u=r.indexOf(e,l+1)):1==n.length?a=[n.pop(),c]:((i=n.pop())=0?u:c;n.length&&(a=[s,o])}return a}e.exports=t,t.range=n},4114:e=>{e.exports=function(e,r){for(var n=[],i=0;i{var n=r(2118),i=r(6909),s=r(8138),o=r(4174),a=r(7942);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t{var n=r(9413),i=r(3620);function s(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}s.prototype=n(i.prototype),s.prototype.constructor=s,e.exports=s},235:(e,t,r)=>{var n=r(3945),i=r(1846),s=r(8028),o=r(2344),a=r(4769);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t{var n=r(9413),i=r(3620);function s(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}s.prototype=n(i.prototype),s.prototype.constructor=s,e.exports=s},326:(e,t,r)=>{var n=r(8761)(r(7772),"Map");e.exports=n},6738:(e,t,r)=>{var n=r(2411),i=r(6417),s=r(6928),o=r(9493),a=r(4150);function u(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t{var n=r(7772).Symbol;e.exports=n},3215:(e,t,r)=>{var n=r(8761)(r(7772),"WeakMap");e.exports=n},9432:e=>{e.exports=function(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}},343:e=>{e.exports=function(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r{e.exports=function(e,t){for(var r=-1,n=t.length,i=e.length;++r{e.exports=function(e){return e.split("")}},2218:(e,t,r)=>{var n=r(1225);e.exports=function(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}},9413:(e,t,r)=>{var n=r(9259),i=Object.create,s=function(){function e(){}return function(t){if(!n(t))return{};if(i)return i(t);e.prototype=t;var r=new e;return e.prototype=void 0,r}}();e.exports=s},1359:e=>{e.exports=function(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s{var n=r(5067),i=r(5882);e.exports=function e(t,r,s,o,a){var u=-1,c=t.length;for(s||(s=i),a||(a=[]);++u0&&s(l)?r>1?e(l,r-1,s,o,a):n(a,l):o||(a[a.length]=l)}return a}},3324:(e,t,r)=>{var n=r(7297),i=r(3812);e.exports=function(e,t){for(var r=0,s=(t=n(t,e)).length;null!=e&&r{var n=r(857),i=r(2107),s=r(7157),o=n?n.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":o&&o in Object(e)?i(e):s(e)}},7832:(e,t,r)=>{var n=r(1359),i=r(2195),s=r(6024);e.exports=function(e,t,r){return t==t?s(e,t,r):n(e,i,r)}},5183:(e,t,r)=>{var n=r(3366),i=r(5125);e.exports=function(e){return i(e)&&"[object Arguments]"==n(e)}},2195:e=>{e.exports=function(e){return e!=e}},6840:(e,t,r)=>{var n=r(1049),i=r(7394),s=r(9259),o=r(7035),a=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,l=u.toString,h=c.hasOwnProperty,p=RegExp("^"+l.call(h).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=function(e){return!(!s(e)||i(e))&&(n(e)?p:a).test(o(e))}},3620:e=>{e.exports=function(){}},6532:(e,t,r)=>{var n=r(6874),i=r(3043),s=r(3059),o=i?function(e,t){return i(e,"toString",{configurable:!0,enumerable:!1,value:n(t),writable:!0})}:s;e.exports=o},9872:e=>{e.exports=function(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=Array(i);++n{var n=r(857),i=r(343),s=r(6152),o=r(4795),a=n?n.prototype:void 0,u=a?a.toString:void 0;e.exports=function e(t){if("string"==typeof t)return t;if(s(t))return i(t,e)+"";if(o(t))return u?u.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}},7297:(e,t,r)=>{var n=r(6152),i=r(1401),s=r(4452),o=r(6188);e.exports=function(e,t){return n(e)?e:i(e,t)?[e]:s(o(e))}},3895:(e,t,r)=>{var n=r(9872);e.exports=function(e,t,r){var i=e.length;return r=void 0===r?i:r,!t&&r>=i?e:n(e,t,r)}},1821:(e,t,r)=>{var n=r(7832);e.exports=function(e,t){for(var r=-1,i=e.length;++r-1;);return r}},1522:e=>{e.exports=function(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r{var n=r(7772)["__core-js_shared__"];e.exports=n},7541:(e,t,r)=>{var n=r(5859),i=r(9097),s=r(8203),o=r(9350),a=r(6152),u=r(3735);e.exports=function(e){return i((function(t){var r=t.length,i=r,c=n.prototype.thru;for(e&&t.reverse();i--;){var l=t[i];if("function"!=typeof l)throw new TypeError("Expected a function");if(c&&!h&&"wrapper"==o(l))var h=new n([],!0)}for(i=h?i:r;++i{var n=r(8761),i=function(){try{var e=n(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();e.exports=i},9097:(e,t,r)=>{var n=r(5676),i=r(3114),s=r(5251);e.exports=function(e){return s(i(e,void 0,n),e+"")}},1242:(e,t,r)=>{var n="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g;e.exports=n},8203:(e,t,r)=>{var n=r(529),i=r(4291),s=n?function(e){return n.get(e)}:i;e.exports=s},9350:(e,t,r)=>{var n=r(9212),i=Object.prototype.hasOwnProperty;e.exports=function(e){for(var t=e.name+"",r=n[t],s=i.call(n,t)?r.length:0;s--;){var o=r[s],a=o.func;if(null==a||a==e)return o.name}return t}},7937:(e,t,r)=>{var n=r(8304);e.exports=function(e,t){var r=e.__data__;return n(t)?r["string"==typeof t?"string":"hash"]:r.map}},8761:(e,t,r)=>{var n=r(6840),i=r(8109);e.exports=function(e,t){var r=i(e,t);return n(r)?r:void 0}},2107:(e,t,r)=>{var n=r(857),i=Object.prototype,s=i.hasOwnProperty,o=i.toString,a=n?n.toStringTag:void 0;e.exports=function(e){var t=s.call(e,a),r=e[a];try{e[a]=void 0;var n=!0}catch(e){}var i=o.call(e);return n&&(t?e[a]=r:delete e[a]),i}},8109:e=>{e.exports=function(e,t){return null==e?void 0:e[t]}},3880:e=>{var t=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");e.exports=function(e){return t.test(e)}},2118:(e,t,r)=>{var n=r(9191);e.exports=function(){this.__data__=n?n(null):{},this.size=0}},6909:e=>{e.exports=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}},8138:(e,t,r)=>{var n=r(9191),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;if(n){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return i.call(t,e)?t[e]:void 0}},4174:(e,t,r)=>{var n=r(9191),i=Object.prototype.hasOwnProperty;e.exports=function(e){var t=this.__data__;return n?void 0!==t[e]:i.call(t,e)}},7942:(e,t,r)=>{var n=r(9191);e.exports=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=n&&void 0===t?"__lodash_hash_undefined__":t,this}},5882:(e,t,r)=>{var n=r(857),i=r(9631),s=r(6152),o=n?n.isConcatSpreadable:void 0;e.exports=function(e){return s(e)||i(e)||!!(o&&e&&e[o])}},1401:(e,t,r)=>{var n=r(6152),i=r(4795),s=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/;e.exports=function(e,t){if(n(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!i(e))||o.test(e)||!s.test(e)||null!=t&&e in Object(t)}},8304:e=>{e.exports=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}},3735:(e,t,r)=>{var n=r(6504),i=r(8203),s=r(9350),o=r(8674);e.exports=function(e){var t=s(e),r=o[t];if("function"!=typeof r||!(t in n.prototype))return!1;if(e===r)return!0;var a=i(r);return!!a&&e===a[0]}},7394:(e,t,r)=>{var n,i=r(4019),s=(n=/[^.]+$/.exec(i&&i.keys&&i.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"";e.exports=function(e){return!!s&&s in e}},3945:e=>{e.exports=function(){this.__data__=[],this.size=0}},1846:(e,t,r)=>{var n=r(2218),i=Array.prototype.splice;e.exports=function(e){var t=this.__data__,r=n(t,e);return!(r<0||(r==t.length-1?t.pop():i.call(t,r,1),--this.size,0))}},8028:(e,t,r)=>{var n=r(2218);e.exports=function(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}},2344:(e,t,r)=>{var n=r(2218);e.exports=function(e){return n(this.__data__,e)>-1}},4769:(e,t,r)=>{var n=r(2218);e.exports=function(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}},2411:(e,t,r)=>{var n=r(9612),i=r(235),s=r(326);e.exports=function(){this.size=0,this.__data__={hash:new n,map:new(s||i),string:new n}}},6417:(e,t,r)=>{var n=r(7937);e.exports=function(e){var t=n(this,e).delete(e);return this.size-=t?1:0,t}},6928:(e,t,r)=>{var n=r(7937);e.exports=function(e){return n(this,e).get(e)}},9493:(e,t,r)=>{var n=r(7937);e.exports=function(e){return n(this,e).has(e)}},4150:(e,t,r)=>{var n=r(7937);e.exports=function(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}},7777:(e,t,r)=>{var n=r(733);e.exports=function(e){var t=n(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}},529:(e,t,r)=>{var n=r(3215),i=n&&new n;e.exports=i},9191:(e,t,r)=>{var n=r(8761)(Object,"create");e.exports=n},7157:e=>{var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},3114:(e,t,r)=>{var n=r(9432),i=Math.max;e.exports=function(e,t,r){return t=i(void 0===t?e.length-1:t,0),function(){for(var s=arguments,o=-1,a=i(s.length-t,0),u=Array(a);++o{e.exports={}},7772:(e,t,r)=>{var n=r(1242),i="object"==typeof self&&self&&self.Object===Object&&self,s=n||i||Function("return this")();e.exports=s},5251:(e,t,r)=>{var n=r(6532),i=r(7787)(n);e.exports=i},7787:e=>{var t=Date.now;e.exports=function(e){var r=0,n=0;return function(){var i=t(),s=16-(i-n);if(n=i,s>0){if(++r>=800)return arguments[0]}else r=0;return e.apply(void 0,arguments)}}},6024:e=>{e.exports=function(e,t,r){for(var n=r-1,i=e.length;++n{var n=r(217),i=r(3880),s=r(3344);e.exports=function(e){return i(e)?s(e):n(e)}},4452:(e,t,r)=>{var n=r(7777),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,o=n((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(i,(function(e,r,n,i){t.push(n?i.replace(s,"$1"):r||e)})),t}));e.exports=o},3812:(e,t,r)=>{var n=r(4795);e.exports=function(e){if("string"==typeof e||n(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}},7035:e=>{var t=Function.prototype.toString;e.exports=function(e){if(null!=e){try{return t.call(e)}catch(e){}try{return e+""}catch(e){}}return""}},3344:e=>{var t="\\ud800-\\udfff",r="["+t+"]",n="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",i="\\ud83c[\\udffb-\\udfff]",s="[^"+t+"]",o="(?:\\ud83c[\\udde6-\\uddff]){2}",a="[\\ud800-\\udbff][\\udc00-\\udfff]",u="(?:"+n+"|"+i+")?",c="[\\ufe0e\\ufe0f]?",l=c+u+"(?:\\u200d(?:"+[s,o,a].join("|")+")"+c+u+")*",h="(?:"+[s+n+"?",n,o,a,r].join("|")+")",p=RegExp(i+"(?="+i+")|"+h+l,"g");e.exports=function(e){return e.match(p)||[]}},7366:(e,t,r)=>{var n=r(6504),i=r(5859),s=r(1522);e.exports=function(e){if(e instanceof n)return e.clone();var t=new i(e.__wrapped__,e.__chain__);return t.__actions__=s(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}},6874:e=>{e.exports=function(e){return function(){return e}}},1225:e=>{e.exports=function(e,t){return e===t||e!=e&&t!=t}},5676:(e,t,r)=>{var n=r(2034);e.exports=function(e){return null!=e&&e.length?n(e,1):[]}},5395:(e,t,r)=>{var n=r(7541)();e.exports=n},2579:(e,t,r)=>{var n=r(3324);e.exports=function(e,t,r){var i=null==e?void 0:n(e,t);return void 0===i?r:i}},3059:e=>{e.exports=function(e){return e}},9631:(e,t,r)=>{var n=r(5183),i=r(5125),s=Object.prototype,o=s.hasOwnProperty,a=s.propertyIsEnumerable,u=n(function(){return arguments}())?n:function(e){return i(e)&&o.call(e,"callee")&&!a.call(e,"callee")};e.exports=u},6152:e=>{var t=Array.isArray;e.exports=t},1049:(e,t,r)=>{var n=r(3366),i=r(9259);e.exports=function(e){if(!i(e))return!1;var t=n(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}},9259:e=>{e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5125:e=>{e.exports=function(e){return null!=e&&"object"==typeof e}},4795:(e,t,r)=>{var n=r(3366),i=r(5125);e.exports=function(e){return"symbol"==typeof e||i(e)&&"[object Symbol]"==n(e)}},733:(e,t,r)=>{var n=r(6738);function i(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(i.Cache||n),r}i.Cache=n,e.exports=i},4291:e=>{e.exports=function(){}},6188:(e,t,r)=>{var n=r(1054);e.exports=function(e){return null==e?"":n(e)}},3433:(e,t,r)=>{var n=r(1054),i=r(3895),s=r(1821),o=r(8435),a=r(6188),u=/^\s+/;e.exports=function(e,t,r){if((e=a(e))&&(r||void 0===t))return e.replace(u,"");if(!e||!(t=n(t)))return e;var c=o(e),l=s(c,o(t));return i(c,l).join("")}},8674:(e,t,r)=>{var n=r(6504),i=r(5859),s=r(3620),o=r(6152),a=r(5125),u=r(7366),c=Object.prototype.hasOwnProperty;function l(e){if(a(e)&&!o(e)&&!(e instanceof n)){if(e instanceof i)return e;if(c.call(e,"__wrapped__"))return u(e)}return new i(e)}l.prototype=s.prototype,l.prototype.constructor=l,e.exports=l},7339:(e,t,r)=>{e.exports=p,p.Minimatch=f;var n=function(){try{return r(1023)}catch(e){}}()||{sep:"/"};p.sep=n.sep;var i=p.GLOBSTAR=f.GLOBSTAR={},s=r(9766),o={"!":{open:"(?:(?!(?:",close:"))[^/]*?)"},"?":{open:"(?:",close:")?"},"+":{open:"(?:",close:")+"},"*":{open:"(?:",close:")*"},"@":{open:"(?:",close:")"}},a="[^/]",u=a+"*?",c="().*{}+?[]^$\\!".split("").reduce((function(e,t){return e[t]=!0,e}),{}),l=/\/+/;function h(e,t){t=t||{};var r={};return Object.keys(e).forEach((function(t){r[t]=e[t]})),Object.keys(t).forEach((function(e){r[e]=t[e]})),r}function p(e,t,r){return g(t),r||(r={}),!(!r.nocomment&&"#"===t.charAt(0))&&new f(t,r).match(e)}function f(e,t){if(!(this instanceof f))return new f(e,t);g(e),t||(t={}),e=e.trim(),t.allowWindowsEscape||"/"===n.sep||(e=e.split(n.sep).join("/")),this.options=t,this.set=[],this.pattern=e,this.regexp=null,this.negate=!1,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.make()}function d(e,t){return t||(t=this instanceof f?this.options:{}),e=void 0===e?this.pattern:e,g(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:s(e)}p.filter=function(e,t){return t=t||{},function(r,n,i){return p(r,e,t)}},p.defaults=function(e){if(!e||"object"!=typeof e||!Object.keys(e).length)return p;var t=p,r=function(r,n,i){return t(r,n,h(e,i))};return(r.Minimatch=function(r,n){return new t.Minimatch(r,h(e,n))}).defaults=function(r){return t.defaults(h(e,r)).Minimatch},r.filter=function(r,n){return t.filter(r,h(e,n))},r.defaults=function(r){return t.defaults(h(e,r))},r.makeRe=function(r,n){return t.makeRe(r,h(e,n))},r.braceExpand=function(r,n){return t.braceExpand(r,h(e,n))},r.match=function(r,n,i){return t.match(r,n,h(e,i))},r},f.defaults=function(e){return p.defaults(e).Minimatch},f.prototype.debug=function(){},f.prototype.make=function(){var e=this.pattern,t=this.options;if(t.nocomment||"#"!==e.charAt(0))if(e){this.parseNegate();var r=this.globSet=this.braceExpand();t.debug&&(this.debug=function(){console.error.apply(console,arguments)}),this.debug(this.pattern,r),r=this.globParts=r.map((function(e){return e.split(l)})),this.debug(this.pattern,r),r=r.map((function(e,t,r){return e.map(this.parse,this)}),this),this.debug(this.pattern,r),r=r.filter((function(e){return-1===e.indexOf(!1)})),this.debug(this.pattern,r),this.set=r}else this.empty=!0;else this.comment=!0},f.prototype.parseNegate=function(){var e=this.pattern,t=!1,r=0;if(!this.options.nonegate){for(var n=0,i=e.length;n65536)throw new TypeError("pattern is too long")};f.prototype.parse=function(e,t){g(e);var r=this.options;if("**"===e){if(!r.noglobstar)return i;e="*"}if(""===e)return"";var n,s="",l=!!r.nocase,h=!1,p=[],f=[],d=!1,v=-1,y=-1,b="."===e.charAt(0)?"":r.dot?"(?!(?:^|\\/)\\.{1,2}(?:$|\\/))":"(?!\\.)",x=this;function w(){if(n){switch(n){case"*":s+=u,l=!0;break;case"?":s+=a,l=!0;break;default:s+="\\"+n}x.debug("clearStateChar %j %j",n,s),n=!1}}for(var _,P=0,k=e.length;P-1;E--){var F=f[E],q=s.slice(0,F.reStart),T=s.slice(F.reStart,F.reEnd-8),L=s.slice(F.reEnd-8,F.reEnd),M=s.slice(F.reEnd);L+=M;var U=q.split("(").length-1,B=M;for(P=0;P=0&&!(i=e[s]);s--);for(s=0;s>> no match, partial?",e,p,t,f),p!==a))}if("string"==typeof l?(c=h===l,this.debug("string match",l,h,c)):(c=h.match(l),this.debug("pattern match",l,h,c)),!c)return!1}if(s===a&&o===u)return!0;if(s===a)return r;if(o===u)return s===a-1&&""===e[s];throw new Error("wtf?")}},9766:(e,t,r)=>{var n=r(4114),i=r(2294);e.exports=function(e){return e?("{}"===e.substr(0,2)&&(e="\\{\\}"+e.substr(2)),v(function(e){return e.split("\\\\").join(s).split("\\{").join(o).split("\\}").join(a).split("\\,").join(u).split("\\.").join(c)}(e),!0).map(h)):[]};var s="\0SLASH"+Math.random()+"\0",o="\0OPEN"+Math.random()+"\0",a="\0CLOSE"+Math.random()+"\0",u="\0COMMA"+Math.random()+"\0",c="\0PERIOD"+Math.random()+"\0";function l(e){return parseInt(e,10)==e?parseInt(e,10):e.charCodeAt(0)}function h(e){return e.split(s).join("\\").split(o).join("{").split(a).join("}").split(u).join(",").split(c).join(".")}function p(e){if(!e)return[""];var t=[],r=i("{","}",e);if(!r)return e.split(",");var n=r.pre,s=r.body,o=r.post,a=n.split(",");a[a.length-1]+="{"+s+"}";var u=p(o);return o.length&&(a[a.length-1]+=u.shift(),a.push.apply(a,u)),t.push.apply(t,a),t}function f(e){return"{"+e+"}"}function d(e){return/^-?0\d/.test(e)}function g(e,t){return e<=t}function m(e,t){return e>=t}function v(e,t){var r=[],s=i("{","}",e);if(!s||/\$$/.test(s.pre))return[e];var o,u=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),h=u||c,y=s.body.indexOf(",")>=0;if(!h&&!y)return s.post.match(/,.*\}/)?v(e=s.pre+"{"+s.body+a+s.post):[e];if(h)o=s.body.split(/\.\./);else if(1===(o=p(s.body)).length&&1===(o=v(o[0],!1).map(f)).length)return(w=s.post.length?v(s.post,!1):[""]).map((function(e){return s.pre+o[0]+e}));var b,x=s.pre,w=s.post.length?v(s.post,!1):[""];if(h){var _=l(o[0]),P=l(o[1]),k=Math.max(o[0].length,o[1].length),S=3==o.length?Math.abs(l(o[2])):1,O=g;P<_&&(S*=-1,O=m);var C=o.some(d);b=[];for(var A=_;O(A,P);A+=S){var R;if(c)"\\"===(R=String.fromCharCode(A))&&(R="");else if(R=String(A),C){var j=k-R.length;if(j>0){var E=new Array(j+1).join("0");R=A<0?"-"+E+R.slice(1):E+R}}b.push(R)}}else b=n(o,(function(e){return v(e,!1)}));for(var F=0;F{"use strict";function t(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}function r(e,t){for(var r,n="",i=0,s=-1,o=0,a=0;a<=e.length;++a){if(a2){var u=n.lastIndexOf("/");if(u!==n.length-1){-1===u?(n="",i=0):i=(n=n.slice(0,u)).length-1-n.lastIndexOf("/"),s=a,o=0;continue}}else if(2===n.length||1===n.length){n="",i=0,s=a,o=0;continue}t&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+e.slice(s+1,a):n=e.slice(s+1,a),i=a-s-1;s=a,o=0}else 46===r&&-1!==o?++o:o=-1}return n}var n={resolve:function(){for(var e,n="",i=!1,s=arguments.length-1;s>=-1&&!i;s--){var o;s>=0?o=arguments[s]:(void 0===e&&(e=process.cwd()),o=e),t(o),0!==o.length&&(n=o+"/"+n,i=47===o.charCodeAt(0))}return n=r(n,!i),i?n.length>0?"/"+n:"/":n.length>0?n:"."},normalize:function(e){if(t(e),0===e.length)return".";var n=47===e.charCodeAt(0),i=47===e.charCodeAt(e.length-1);return 0!==(e=r(e,!n)).length||n||(e="."),e.length>0&&i&&(e+="/"),n?"/"+e:e},isAbsolute:function(e){return t(e),e.length>0&&47===e.charCodeAt(0)},join:function(){if(0===arguments.length)return".";for(var e,r=0;r0&&(void 0===e?e=i:e+="/"+i)}return void 0===e?".":n.normalize(e)},relative:function(e,r){if(t(e),t(r),e===r)return"";if((e=n.resolve(e))===(r=n.resolve(r)))return"";for(var i=1;ic){if(47===r.charCodeAt(a+h))return r.slice(a+h+1);if(0===h)return r.slice(a+h)}else o>c&&(47===e.charCodeAt(i+h)?l=h:0===h&&(l=0));break}var p=e.charCodeAt(i+h);if(p!==r.charCodeAt(a+h))break;47===p&&(l=h)}var f="";for(h=i+l+1;h<=s;++h)h!==s&&47!==e.charCodeAt(h)||(0===f.length?f+="..":f+="/..");return f.length>0?f+r.slice(a+l):(a+=l,47===r.charCodeAt(a)&&++a,r.slice(a))},_makeLong:function(e){return e},dirname:function(e){if(t(e),0===e.length)return".";for(var r=e.charCodeAt(0),n=47===r,i=-1,s=!0,o=e.length-1;o>=1;--o)if(47===(r=e.charCodeAt(o))){if(!s){i=o;break}}else s=!1;return-1===i?n?"/":".":n&&1===i?"//":e.slice(0,i)},basename:function(e,r){if(void 0!==r&&"string"!=typeof r)throw new TypeError('"ext" argument must be a string');t(e);var n,i=0,s=-1,o=!0;if(void 0!==r&&r.length>0&&r.length<=e.length){if(r.length===e.length&&r===e)return"";var a=r.length-1,u=-1;for(n=e.length-1;n>=0;--n){var c=e.charCodeAt(n);if(47===c){if(!o){i=n+1;break}}else-1===u&&(o=!1,u=n+1),a>=0&&(c===r.charCodeAt(a)?-1==--a&&(s=n):(a=-1,s=u))}return i===s?s=u:-1===s&&(s=e.length),e.slice(i,s)}for(n=e.length-1;n>=0;--n)if(47===e.charCodeAt(n)){if(!o){i=n+1;break}}else-1===s&&(o=!1,s=n+1);return-1===s?"":e.slice(i,s)},extname:function(e){t(e);for(var r=-1,n=0,i=-1,s=!0,o=0,a=e.length-1;a>=0;--a){var u=e.charCodeAt(a);if(47!==u)-1===i&&(s=!1,i=a+1),46===u?-1===r?r=a:1!==o&&(o=1):-1!==r&&(o=-1);else if(!s){n=a+1;break}}return-1===r||-1===i||0===o||1===o&&r===i-1&&r===n+1?"":e.slice(r,i)},format:function(e){if(null===e||"object"!=typeof e)throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return function(e,t){var r=t.dir||t.root,n=t.base||(t.name||"")+(t.ext||"");return r?r===t.root?r+n:r+"/"+n:n}(0,e)},parse:function(e){t(e);var r={root:"",dir:"",base:"",ext:"",name:""};if(0===e.length)return r;var n,i=e.charCodeAt(0),s=47===i;s?(r.root="/",n=1):n=0;for(var o=-1,a=0,u=-1,c=!0,l=e.length-1,h=0;l>=n;--l)if(47!==(i=e.charCodeAt(l)))-1===u&&(c=!1,u=l+1),46===i?-1===o?o=l:1!==h&&(h=1):-1!==o&&(h=-1);else if(!c){a=l+1;break}return-1===o||-1===u||0===h||1===h&&o===u-1&&o===a+1?-1!==u&&(r.base=r.name=0===a&&s?e.slice(1,u):e.slice(a,u)):(0===a&&s?(r.name=e.slice(1,o),r.base=e.slice(1,u)):(r.name=e.slice(a,o),r.base=e.slice(a,u)),r.ext=e.slice(o,u)),a>0?r.dir=e.slice(0,a-1):s&&(r.dir="/"),r},sep:"/",delimiter:":",win32:null,posix:null};n.posix=n,e.exports=n},3252:function(e){!function(t){"use strict";var r=function(e){setTimeout(e,0)};"undefined"!=typeof process&&process&&"function"==typeof process.nextTick&&(r=process.nextTick),e.exports=function(e){var t={capacity:e||1,current:0,queue:[],firstHere:!1,take:function(){if(!1===t.firstHere){t.current++,t.firstHere=!0;var e=1}else e=0;var r={n:1};"function"==typeof arguments[0]?r.task=arguments[0]:r.n=arguments[0],arguments.length>=2&&("function"==typeof arguments[1]?r.task=arguments[1]:r.n=arguments[1]);var n=r.task;if(r.task=function(){n(t.leave)},t.current+r.n-e>t.capacity)return 1===e&&(t.current--,t.firstHere=!1),t.queue.push(r);t.current+=r.n-e,r.task(t.leave),1===e&&(t.firstHere=!1)},leave:function(e){if(e=e||1,t.current-=e,t.queue.length){var n=t.queue[0];n.n+t.current>t.capacity||(t.queue.shift(),t.current+=n.n,r(n.task))}else if(t.current<0)throw new Error("leave called too many times.")},available:function(e){return e=e||1,t.current+e<=t.capacity}};return t}}()},9776:(e,t,r)=>{var n=r(7186);e.exports={parse:function(e){return n.parse(e.toString())}}},7186:e=>{"use strict";function t(e,r,n,i){this.message=e,this.expected=r,this.found=n,this.location=i,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,t)}!function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(t,Error),t.buildMessage=function(e,t){var r={literal:function(e){return'"'+i(e.text)+'"'},class:function(e){var t,r="";for(t=0;t0){for(t=1,n=1;tZe&&(Ze=Ve,Qe=[]),Qe.push(e))}function at(){var e,t,r,n=35*Ve+0,i=tt[n];if(i)return Ve=i.nextPos,i.result;for(e=Ve,t=[],r=ut();r!==a;)t.push(r),r=ut();return t!==a&&(t=l(t)),e=t,tt[n]={nextPos:Ve,result:e},e}function ut(){var t,r=35*Ve+1,n=tt[r];return n?(Ve=n.nextPos,n.result):(t=function(){var e,t,r=35*Ve+5,n=tt[r];return n?(Ve=n.nextPos,n.result):(e=Ve,(t=lt())!==a&&bt()!==a&&ct()!==a?e=t=g(t):(Ve=e,e=a),tt[r]={nextPos:Ve,result:e},e)}(),t===a&&(t=function(){var t,r,n,i,s,o,u,c,l=35*Ve+6,h=tt[l];return h?(Ve=h.nextPos,h.result):(t=Ve,r=function(){var t,r,n,i,s,o,u=35*Ve+19,c=tt[u];return c?(Ve=c.nextPos,c.result):(t=Ve,e.substr(Ve,5)===ie?(r=ie,Ve+=5):(r=a,0===et&&ot(se)),r!==a&&(n=_t())!==a?(32===e.charCodeAt(Ve)?(i=Q,Ve++):(i=a,0===et&&ot(ee)),i!==a&&(s=wt())!==a&&(o=xt())!==a?t=r=[r,n,i,s,o]:(Ve=t,t=a)):(Ve=t,t=a),tt[u]={nextPos:Ve,result:t},t)}(),r!==a?((n=yt())===a&&(n=null),n!==a?(i=function(){var t,r,n,i,s=35*Ve+21,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,e.substr(Ve,17)===ue?(r=ue,Ve+=17):(r=a,0===et&&ot(ce)),r!==a&&(n=Pt())!==a?(37===e.charCodeAt(Ve)?(i=le,Ve++):(i=a,0===et&&ot(he)),i!==a&&xt()!==a?t=r=pe(n):(Ve=t,t=a)):(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}(),i!==a?(s=function(){var t,r,n,i,s=35*Ve+25,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,e.substr(Ve,6)===Oe?(r=Oe,Ve+=6):(r=a,0===et&&ot(Ce)),r===a&&(e.substr(Ve,4)===Ae?(r=Ae,Ve+=4):(r=a,0===et&&ot(Re))),r!==a?(e.substr(Ve,6)===je?(n=je,Ve+=6):(n=a,0===et&&ot(Ee)),n!==a&&(i=wt())!==a&&xt()!==a?t=r=Fe(r,i):(Ve=t,t=a)):(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}(),s!==a?(o=function(){var t,r,n,i,s=35*Ve+26,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,e.substr(Ve,6)===Oe?(r=Oe,Ve+=6):(r=a,0===et&&ot(Ce)),r===a&&(e.substr(Ve,4)===Ae?(r=Ae,Ve+=4):(r=a,0===et&&ot(Re))),r!==a?(e.substr(Ve,4)===qe?(n=qe,Ve+=4):(n=a,0===et&&ot(Te)),n!==a&&(i=wt())!==a&&xt()!==a?t=r=Fe(r,i):(Ve=t,t=a)):(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}(),o!==a?((u=bt())===a&&(u=null),u!==a?((c=ct())===a&&(c=ht()),c===a&&(c=null),c!==a?t=r=m(n,i,s,o,u,c):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a),tt[l]={nextPos:Ve,result:t},t)}(),t===a&&(t=function(){var e,t,r,n=35*Ve+7,i=tt[n];return i?(Ve=i.nextPos,i.result):(e=Ve,(t=lt())!==a&&bt()!==a?((r=ht())===a&&(r=null),r!==a?e=t=v(t,r):(Ve=e,e=a)):(Ve=e,e=a),tt[n]={nextPos:Ve,result:e},e)}(),t===a&&(t=function(){var t,r,n,i=35*Ve+9,s=tt[i];return s?(Ve=s.nextPos,s.result):(t=Ve,e.substr(Ve,16)===w?(r=w,Ve+=16):(r=a,0===et&&ot(_)),r!==a&&(n=wt())!==a&&xt()!==a?t=r=P(n):(Ve=t,t=a),tt[i]={nextPos:Ve,result:t},t)}(),t===a&&(t=function(){var e,t,r,n,i=35*Ve+2,s=tt[i];return s?(Ve=s.nextPos,s.result):(e=Ve,(t=mt())!==a?((r=vt())===a&&(r=null),r!==a?((n=pt())===a&&(n=null),n!==a&&ct()!==a?e=t=h(t,r):(Ve=e,e=a)):(Ve=e,e=a)):(Ve=e,e=a),tt[i]={nextPos:Ve,result:e},e)}(),t===a&&(t=function(){var e,t,r,n,i=35*Ve+4,s=tt[i];return s?(Ve=s.nextPos,s.result):(e=Ve,(t=mt())!==a?((r=vt())===a&&(r=null),r!==a?((n=ht())===a&&(n=null),n!==a?e=t=d(t,r,n):(Ve=e,e=a)):(Ve=e,e=a)):(Ve=e,e=a),tt[i]={nextPos:Ve,result:e},e)}()))))),tt[r]={nextPos:Ve,result:t},t)}function ct(){var t,r,n,i,s=35*Ve+3,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,e.substr(Ve,13)===p?(r=p,Ve+=13):(r=a,0===et&&ot(f)),r!==a&&(n=wt())!==a&&(i=xt())!==a?t=r=[r,n,i]:(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}function lt(){var t,r,n,i=35*Ve+8,s=tt[i];return s?(Ve=s.nextPos,s.result):(t=Ve,e.substr(Ve,10)===y?(r=y,Ve+=10):(r=a,0===et&&ot(b)),r!==a&&(n=wt())!==a&&xt()!==a?t=r=x(n):(Ve=t,t=a),tt[i]={nextPos:Ve,result:t},t)}function ht(){var e,t,r,n,i=35*Ve+10,s=tt[i];if(s)return Ve=s.nextPos,s.result;if(e=Ve,(t=pt())!==a){for(r=[],n=ft();n!==a;)r.push(n),n=ft();r!==a?e=t=k(t,r):(Ve=e,e=a)}else Ve=e,e=a;return tt[i]={nextPos:Ve,result:e},e}function pt(){var t,r,n,i,s,o=35*Ve+11,u=tt[o];return u?(Ve=u.nextPos,u.result):(t=Ve,e.substr(Ve,4)===S?(r=S,Ve+=4):(r=a,0===et&&ot(O)),r!==a&&(n=wt())!==a&&xt()!==a?(e.substr(Ve,4)===C?(i=C,Ve+=4):(i=a,0===et&&ot(A)),i!==a&&(s=wt())!==a&&xt()!==a?t=r=R(n,s):(Ve=t,t=a)):(Ve=t,t=a),tt[o]={nextPos:Ve,result:t},t)}function ft(){var t,r,n,i,s=35*Ve+12,o=tt[s];if(o)return Ve=o.nextPos,o.result;if(t=Ve,r=function(){var t,r=35*Ve+13,n=tt[r];return n?(Ve=n.nextPos,n.result):(t=function(){var t,r,n,i,s,o,u,c,l,h=35*Ve+14,p=tt[h];return p?(Ve=p.nextPos,p.result):(t=Ve,e.substr(Ve,5)===E?(r=E,Ve+=5):(r=a,0===et&&ot(F)),r!==a&&(n=dt())!==a?(e.substr(Ve,2)===q?(i=q,Ve+=2):(i=a,0===et&&ot(T)),i!==a&&(s=dt())!==a?(e.substr(Ve,2)===L?(o=L,Ve+=2):(o=a,0===et&&ot(M)),o!==a&&(u=dt())!==a?(e.substr(Ve,4)===U?(c=U,Ve+=4):(c=a,0===et&&ot(B)),c!==a?((l=wt())===a&&(l=null),l!==a&&xt()!==a?t=r=$(n,s,u,l):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a),tt[h]={nextPos:Ve,result:t},t)}(),t===a&&(t=function(){var t,r,n,i,s,o,u,c=35*Ve+15,l=tt[c];return l?(Ve=l.nextPos,l.result):(t=Ve,e.substr(Ve,4)===D?(r=D,Ve+=4):(r=a,0===et&&ot(I)),r!==a&&(n=dt())!==a?(e.substr(Ve,2)===L?(i=L,Ve+=2):(i=a,0===et&&ot(M)),i!==a&&(s=dt())!==a?(e.substr(Ve,3)===N?(o=N,Ve+=3):(o=a,0===et&&ot(z)),o!==a?((u=wt())===a&&(u=null),u!==a&&xt()!==a?t=r=W(n,s,u):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a),tt[c]={nextPos:Ve,result:t},t)}()),tt[r]={nextPos:Ve,result:t},t)}(),r!==a){if(n=[],(i=gt())!==a)for(;i!==a;)n.push(i),i=gt();else n=a;n!==a?t=r=j(r,n):(Ve=t,t=a)}else Ve=t,t=a;return tt[s]={nextPos:Ve,result:t},t}function dt(){var t,r,n,i,s=35*Ve+16,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,(r=Pt())!==a?(44===e.charCodeAt(Ve)?(n=H,Ve++):(n=a,0===et&&ot(G)),n!==a&&(i=Pt())!==a?t=r=J(r,i):(Ve=t,t=a)):(Ve=t,t=a),t===a&&(t=Ve,(r=Pt())!==a&&(r=K(r)),t=r),tt[s]={nextPos:Ve,result:t},t)}function gt(){var t,r,n,i,s=35*Ve+17,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,r=Ve,43===e.charCodeAt(Ve)?(n=Y,Ve++):(n=a,0===et&&ot(V)),n===a&&(45===e.charCodeAt(Ve)?(n=X,Ve++):(n=a,0===et&&ot(Z)),n===a&&(32===e.charCodeAt(Ve)?(n=Q,Ve++):(n=a,0===et&&ot(ee)),n===a&&(92===e.charCodeAt(Ve)?(n=te,Ve++):(n=a,0===et&&ot(re))))),n!==a?((i=wt())===a&&(i=null),i!==a?r=n=[n,i]:(Ve=r,r=a)):(Ve=r,r=a),r!==a&&(n=xt())!==a?t=r=ne(r):(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}function mt(){var t,r,n,i,s,o=35*Ve+18,u=tt[o];return u?(Ve=u.nextPos,u.result):(t=Ve,e.substr(Ve,5)===ie?(r=ie,Ve+=5):(r=a,0===et&&ot(se)),r!==a&&(n=_t())!==a?(32===e.charCodeAt(Ve)?(i=Q,Ve++):(i=a,0===et&&ot(ee)),i!==a?(s=function(){var e,t,r=35*Ve+20,n=tt[r];return n?(Ve=n.nextPos,n.result):(e=Ve,(t=wt())!==a&&(t=ae(t)),e=t,tt[r]={nextPos:Ve,result:e},e)}(),s!==a&&xt()!==a?t=r=oe(n,s):(Ve=t,t=a)):(Ve=t,t=a)):(Ve=t,t=a),tt[o]={nextPos:Ve,result:t},t)}function vt(){var t,r,n,i=35*Ve+22,s=tt[i];return s?(Ve=s.nextPos,s.result):(t=Ve,r=function(){var t,r,n,i,s=35*Ve+23,o=tt[s];return o?(Ve=o.nextPos,o.result):(t=Ve,e.substr(Ve,3)===de?(r=de,Ve+=3):(r=a,0===et&&ot(ge)),r===a&&(e.substr(Ve,7)===me?(r=me,Ve+=7):(r=a,0===et&&ot(ve))),r!==a?(e.substr(Ve,11)===ye?(n=ye,Ve+=11):(n=a,0===et&&ot(be)),n!==a&&(i=wt())!==a&&xt()!==a?t=r=xe(r,i):(Ve=t,t=a)):(Ve=t,t=a),tt[s]={nextPos:Ve,result:t},t)}(),r===a&&(r=yt()),r===a&&(r=null),r!==a?((n=bt())===a&&(n=null),n!==a?t=r=fe(r,n):(Ve=t,t=a)):(Ve=t,t=a),tt[i]={nextPos:Ve,result:t},t)}function yt(){var t,r,n,i,s,o=35*Ve+24,u=tt[o];return u?(Ve=u.nextPos,u.result):(t=Ve,e.substr(Ve,9)===we?(r=we,Ve+=9):(r=a,0===et&&ot(_e)),r!==a&&(n=wt())!==a&&xt()!==a?(e.substr(Ve,9)===Pe?(i=Pe,Ve+=9):(i=a,0===et&&ot(ke)),i!==a&&(s=wt())!==a&&xt()!==a?t=r=Se(n,s):(Ve=t,t=a)):(Ve=t,t=a),tt[o]={nextPos:Ve,result:t},t)}function bt(){var t,r,n,i,s,o=35*Ve+27,u=tt[o];return u?(Ve=u.nextPos,u.result):(t=Ve,e.substr(Ve,6)===Le?(r=Le,Ve+=6):(r=a,0===et&&ot(Me)),r!==a&&(n=_t())!==a?(32===e.charCodeAt(Ve)?(i=Q,Ve++):(i=a,0===et&&ot(ee)),i!==a&&(s=wt())!==a&&xt()!==a?t=r=Ue(s):(Ve=t,t=a)):(Ve=t,t=a),t===a&&(t=Ve,e.substr(Ve,6)===Le?(r=Le,Ve+=6):(r=a,0===et&&ot(Me)),r!==a&&(n=_t())!==a&&(i=xt())!==a?t=r=[r,n,i]:(Ve=t,t=a)),tt[o]={nextPos:Ve,result:t},t)}function xt(){var t,r=35*Ve+29,n=tt[r];return n?(Ve=n.nextPos,n.result):(10===e.charCodeAt(Ve)?(t=Be,Ve++):(t=a,0===et&&ot($e)),t===a&&(e.substr(Ve,2)===De?(t=De,Ve+=2):(t=a,0===et&&ot(Ie))),t===a&&(t=function(){var t,r,n=35*Ve+31,i=tt[n];return i?(Ve=i.nextPos,i.result):(t=Ve,et++,e.length>Ve?(r=e.charAt(Ve),Ve++):(r=a,0===et&&ot(Ne)),et--,r===a?t=void 0:(Ve=t,t=a),tt[n]={nextPos:Ve,result:t},t)}()),tt[r]={nextPos:Ve,result:t},t)}function wt(){var t,r,n,i=35*Ve+32,s=tt[i];if(s)return Ve=s.nextPos,s.result;if(t=Ve,r=[],ze.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(We)),n!==a)for(;n!==a;)r.push(n),ze.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(We));else r=a;return r!==a&&(r=ne(r)),t=r,tt[i]={nextPos:Ve,result:t},t}function _t(){var t,r,n,i=35*Ve+33,s=tt[i];if(s)return Ve=s.nextPos,s.result;if(t=Ve,r=[],He.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(Ge)),n!==a)for(;n!==a;)r.push(n),He.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(Ge));else r=a;return r!==a&&(r=ne(r)),t=r,tt[i]={nextPos:Ve,result:t},t}function Pt(){var t,r,n,i=35*Ve+34,s=tt[i];if(s)return Ve=s.nextPos,s.result;if(t=Ve,r=[],Je.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(Ke)),n!==a)for(;n!==a;)r.push(n),Je.test(e.charAt(Ve))?(n=e.charAt(Ve),Ve++):(n=a,0===et&&ot(Ke));else r=a;return r!==a&&(r=Ye(r)),t=r,tt[i]={nextPos:Ve,result:t},t}function kt(e,t,r,n){if(t.old_mode&&!t.new_mode)return{newPath:null,oldPath:e.file_name,newMode:null,oldMode:t.old_mode,hunks:r?r.hunks:[],status:"deleted",binary:!!n};if(!t.old_mode&&t.new_mode)return{oldPath:null,newPath:e.file_name,oldMode:null,newMode:t.new_mode,hunks:r?r.hunks:[],status:"added",binary:!!n};if(t.old_mode&&t.new_mode)return{newPath:e.file_name,oldPath:e.file_name,oldMode:t.old_mode,newMode:t.new_mode,hunks:r?r.hunks:[],status:"modified",binary:!!n};throw new Error("file modes missing")}function St(e,t,r){return(t=t||{}).filePath=e,t.status="unmerged",t.binary=!!r,t}if((n=c())!==a&&Ve===e.length)return n;throw n!==a&&Ve{"use strict";e.exports=r},1756:e=>{"use strict";e.exports=n},2673:e=>{"use strict";e.exports=i},82:e=>{"use strict";e.exports=t},4688:t=>{"use strict";t.exports=e},3327:e=>{"use strict";e.exports=s}},a={};function u(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e].call(r.exports,r,r.exports,u),r.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var c={};return(()=>{"use strict";u.d(c,{DecapCmsBackendBitbucket:()=>je});var e,t,r=u(3433),n=u.n(r),i=u(3252),s=u.n(i),o=function(){function e(e,t){for(var r=0;r1?r-1:0),i=1;i0&&Array.isArray(n[0])&&(n=n[0]),this.transformers=n.map((function(e){return"function"==typeof e?e():e})),this.tag}return o(e,[{key:"interimTag",value:function(e,t){for(var r=arguments.length,n=Array(r>2?r-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:p;return{onSubstitution:function(t,r){if(Array.isArray(t)){var n=t.length,i=e.separator,s=e.conjunction,o=e.serial,a=r.match(/(\n?[^\S\n]+)$/);if(t=a?t.join(i+a[1]):t.join(i+" "),s&&n>1){var u=t.lastIndexOf(i);t=t.slice(0,u)+(o?i:"")+" "+s+t.slice(u+1)}}return t}}},d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"initial";return{onEndResult:function(t){if("initial"===e){var r=t.match(/^[^\S\n]*(?=\S)/gm),n=r&&Math.min.apply(Math,function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:"";return{onEndResult:function(t){if(""===e)return t.trim();if("start"===(e=e.toLowerCase())||"left"===e)return t.replace(/^\s*/,"");if("end"===e||"right"===e)return t.replace(/\s*$/,"");throw new Error("Side not supported: "+e)}}};new h(f({separator:","}),d,g),new h(f({separator:",",conjunction:"and"}),d,g),new h(f({separator:",",conjunction:"or"}),d,g);const m=function(e){return{onSubstitution:function(t,r){if(null==e||"string"!=typeof e)throw new Error("You need to specify a string character to split by.");return"string"==typeof t&&t.includes(e)&&(t=t.split(e)),t}}};var v=function(e){return null!=e&&!Number.isNaN(e)&&"boolean"!=typeof e};new h(m("\n"),(function(){return{onSubstitution:function(e){return Array.isArray(e)?e.filter(v):v(e)?e:""}}}),f,d,g);const y=function(e,t){return{onSubstitution:function(r,n){if(null==e||null==t)throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");return null==r?r:r.toString().replace(e,t)}}};new h(m("\n"),f,d,g,y(/&/g,"&"),y(//g,">"),y(/"/g,"""),y(/'/g,"'"),y(/`/g,"`"));const b=function(e,t){return{onEndResult:function(r){if(null==e||null==t)throw new Error("replaceResultTransformer requires at least 2 arguments.");return r.replace(e,t)}}},x=new h(b(/(?:\n(?:\s*))+/g," "),g);new h(b(/(?:\n\s*)/g,""),g),new h(f({separator:","}),b(/(?:\s+)/g," "),g),new h(f({separator:",",conjunction:"or"}),b(/(?:\s+)/g," "),g),new h(f({separator:",",conjunction:"and"}),b(/(?:\s+)/g," "),g),new h(f,d,g),new h(f,b(/(?:\s+)/g," "),g);const w=new h(d,g);new h(d("all"),g);var _=u(4688),P=u(82);function k(){return k=Object.assign?Object.assign.bind():function(e){for(var t=1;t96?W:H},J=function(e,t,r){var n;if(t){var i=t.shouldForwardProp;n=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!=typeof n&&r&&(n=e.__emotion_forwardProp),n},K=function(e){var t=e.cache,r=e.serialized,n=e.isStringTag;return E(t,r,n),z((function(){return function(e,t,r){E(e,t,r);var n=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var i=t;do{e.insert(t===i?"."+n:"",i,e.sheet,!0),i=i.next}while(void 0!==i)}}(t,r,n)})),null},Y=function e(t,r){var n,i,s=t.__emotion_real===t,o=s&&t.__emotion_base||t;void 0!==r&&(n=r.label,i=r.target);var a=J(t,r,s),u=a||G(o),c=!u("as");return function(){var l=arguments,h=s&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==n&&h.push("label:"+n+";"),null==l[0]||void 0===l[0].raw)h.push.apply(h,l);else{h.push(l[0][0]);for(var p=l.length,f=1;f=4;++n,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(n)|(255&e.charCodeAt(++n))<<8|(255&e.charCodeAt(++n))<<16|(255&e.charCodeAt(++n))<<24))+(59797*(t>>>16)<<16),r=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&r)+(59797*(r>>>16)<<16);switch(i){case 3:r^=(255&e.charCodeAt(n+2))<<16;case 2:r^=(255&e.charCodeAt(n+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(n)))+(59797*(r>>>16)<<16)}return(((r=1540483477*(65535&(r^=r>>>13))+(59797*(r>>>16)<<16))^r>>>15)>>>0).toString(36)}(i)+u;return{name:c,styles:i,next:D}}(h.concat(g),t.registered,m);d+=t.key+"-"+y.name,void 0!==i&&(d+=" "+i);var b=c&&void 0===a?G(f):u,x={};for(var w in e)c&&"as"===w||b(w)&&(x[w]=e[w]);return x.className=d,x.ref=r,S.createElement(S.Fragment,null,S.createElement(K,{cache:t,serialized:y,isStringTag:"string"==typeof f}),S.createElement(f,x))}));return d.displayName=void 0!==n?n:"Styled("+("string"==typeof o?o:o.displayName||o.name||"Component")+")",d.defaultProps=t.defaultProps,d.__emotion_real=d,d.__emotion_base=o,d.__emotion_styles=h,d.__emotion_forwardProp=a,Object.defineProperty(d,"toString",{value:function(){return"."+i}}),d.withComponent=function(t,n){return e(t,k({},r,n,{shouldForwardProp:J(d,n,!0)})).apply(void 0,h)},d}},V=u(2673),X=u.n(V),Z=u(3327);function Q(e,t,r){var n;return(t="symbol"==typeof(n=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?n:String(n))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ee=Y(Z.Icon,{target:"e15sc0jo0",label:"LoginButtonIcon"})({name:"1gnqu05",styles:"margin-right:18px"});class te extends O().Component{constructor(...e){super(...e),Q(this,"state",{}),Q(this,"handleLogin",(e=>{e.preventDefault(),this.auth.authenticate(this.authSettings,((e,t)=>{e?this.setState({loginError:e.toString()}):this.props.onLogin(t)}))}))}componentDidMount(){const{auth_type:e=""}=this.props.config.backend;if("implicit"===e){const{base_url:e="https://bitbucket.org",auth_endpoint:t="site/oauth2/authorize",app_id:r=""}=this.props.config.backend;this.auth=new P.ImplicitAuthenticator({base_url:e,auth_endpoint:t,app_id:r,clearHash:this.props.clearHash}),this.auth.completeAuth(((e,t)=>{e?this.setState({loginError:e.toString()}):this.props.onLogin(t)})),this.authSettings={scope:"repository:write"}}else this.auth=new P.NetlifyAuthenticator({base_url:this.props.base_url,site_id:"localhost"===document.location.host.split(":")[0]?"demo.decapcms.org":this.props.siteId,auth_endpoint:this.props.authEndpoint}),this.authSettings={provider:"bitbucket",scope:"repo"}}render(){const{inProgress:e,config:t,t:r}=this.props;return(0,j.jsx)(Z.AuthenticationPage,{onLogin:this.handleLogin,loginDisabled:e,loginErrorMessage:this.state.loginError,logoUrl:t.logo_url,siteUrl:t.site_url,renderButtonContent:()=>(0,j.jsx)(O().Fragment,null,(0,j.jsx)(ee,{type:"bitbucket"}),r(e?"auth.loggingIn":"auth.loginWithBitbucket")),t:r})}}Q(te,"propTypes",{onLogin:X().func.isRequired,inProgress:X().bool,base_url:X().string,siteId:X().string,authEndpoint:X().string,config:X().object.isRequired,clearHash:X().func,t:X().func.isRequired});var re=u(2579),ne=u.n(re),ie=u(5395),se=u.n(ie),oe=u(1023),ae=u(9776);function ue(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ce(e,t,r){var n;return(t="symbol"==typeof(n=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(t))?n:String(n))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var le=function(e){return e.MERGED="MERGED",e.SUPERSEDED="SUPERSEDED",e.OPEN="OPEN",e.DECLINED="DECLINED",e}(le||{}),he=function(e){return e.Successful="SUCCESSFUL",e.Failed="FAILED",e.InProgress="INPROGRESS",e.Stopped="STOPPED",e}(he||{});const pe="Bitbucket",fe="application/json; charset=utf-8";function de(e){return e&&404===e.status?(console.log("This 404 was expected and handled appropriately."),{size:0,values:[]}):Promise.reject(e)}class ge{constructor(e){ce(this,"apiRoot",void 0),ce(this,"branch",void 0),ce(this,"repo",void 0),ce(this,"requestFunction",void 0),ce(this,"repoURL",void 0),ce(this,"commitAuthor",void 0),ce(this,"mergeStrategy",void 0),ce(this,"initialWorkflowStatus",void 0),ce(this,"cmsLabelPrefix",void 0),ce(this,"buildRequest",(e=>{const t=_.unsentRequest.withRoot(this.apiRoot)(e);return t.has("cache")?t:_.unsentRequest.withNoCache(t)})),ce(this,"request",(e=>{try{return(0,_.requestWithBackoff)(this,e)}catch(e){throw new _.APIError(e.message,null,pe)}})),ce(this,"responseToJSON",(0,_.responseParser)({format:"json",apiName:pe})),ce(this,"responseToBlob",(0,_.responseParser)({format:"blob",apiName:pe})),ce(this,"responseToText",(0,_.responseParser)({format:"text",apiName:pe})),ce(this,"requestJSON",(e=>this.request(e).then(this.responseToJSON))),ce(this,"requestText",(e=>this.request(e).then(this.responseToText))),ce(this,"user",(()=>this.requestJSON("/user"))),ce(this,"hasWriteAccess",(async()=>{const e=await this.request(this.repoURL);if(404===e.status)throw Error("Repo not found");return e.ok})),ce(this,"getBranch",(async e=>await this.requestJSON(`${this.repoURL}/refs/branches/${e}`))),ce(this,"branchCommitSha",(async e=>{const{target:{hash:t}}=await this.getBranch(e);return t})),ce(this,"defaultBranchCommitSha",(()=>this.branchCommitSha(this.branch))),ce(this,"isFile",(({type:e})=>"commit_file"===e)),ce(this,"getFileId",((e,t)=>`${e}/${t}`)),ce(this,"processFile",(e=>function(e){for(var t=1;te.filter(this.isFile).map(this.processFile))),ce(this,"readFile",(async(e,t,{parseText:r=!0,branch:n=this.branch,head:i=""}={})=>await(0,_.readFile)(t,(async()=>{const t=i||await this.branchCommitSha(n);return await this.request({url:`${this.repoURL}/src/${t}/${e}`,cache:"no-store"}).then(r?this.responseToText:this.responseToBlob)}),_.localForage,r))),ce(this,"getEntriesAndCursor",(e=>{const{size:t,page:r,pagelen:n,next:i,previous:s,values:o}=e,a=n&&t?Math.ceil(t/n):void 0;return{entries:o,cursor:_.Cursor.create({actions:[...i?["next"]:[],...s?["prev"]:[]],meta:{page:r,count:t,pageSize:n,pageCount:a},data:{links:{next:i,prev:s}}})}})),ce(this,"listFiles",(async(e,t=1,r,n)=>{const i=await this.branchCommitSha(n),s=await this.requestJSON({url:`${this.repoURL}/src/${i}/${e}`,params:{max_depth:t,pagelen:r}}).catch(de),{entries:o,cursor:a}=this.getEntriesAndCursor(s);return{entries:this.processFiles(o),cursor:a}})),ce(this,"traverseCursor",(async(e,t)=>se()([this.requestJSON,(0,_.then)(this.getEntriesAndCursor),(0,_.then)((({cursor:e,entries:t})=>({cursor:e,entries:this.processFiles(t)})))])(e.data.getIn(["links",t])))),ce(this,"listAllFiles",(async(e,t,r)=>{const{cursor:n,entries:i}=await this.listFiles(e,t,100,r),s=[...i];let o=n;for(;o&&o.actions.has("next");){const{cursor:e,entries:t}=await this.traverseCursor(o,"next");s.push(...t),o=e}return this.processFiles(s)})),ce(this,"deleteFiles",((e,t)=>{const r=new FormData;if(e.forEach((e=>{r.append("files",e)})),r.append("branch",this.branch),t&&r.append("message",t),this.commitAuthor){const{name:e,email:t}=this.commitAuthor;r.append("author",`${e} <${t}>`)}return se()([_.unsentRequest.withMethod("POST"),_.unsentRequest.withBody(r),this.request])(`${this.repoURL}/src`)})),this.apiRoot=e.apiRoot||"https://api.bitbucket.org/2.0",this.branch=e.branch||"master",this.repo=e.repo||"",this.requestFunction=e.requestFunction||_.unsentRequest.performRequest,this.hasWriteAccess=e.hasWriteAccess||this.hasWriteAccess,this.repoURL=this.repo?`/repositories/${this.repo}`:"",this.mergeStrategy=e.squashMerges?"squash":"merge_commit",this.initialWorkflowStatus=e.initialWorkflowStatus,this.cmsLabelPrefix=e.cmsLabelPrefix}async readFileMetadata(e,t){return await(0,_.readFileMetadata)(t,(async()=>{try{const{values:t}=await this.requestJSON({url:`${this.repoURL}/commits`,params:{path:e,include:this.branch}}),r=t[0];return{author:r.author.user?r.author.user.display_name||r.author.user.nickname:r.author.raw,updatedOn:r.date}}catch(e){return{author:"",updatedOn:""}}}),_.localForage)}async isShaExistsInBranch(e,t){const{values:r}=await this.requestJSON({url:`${this.repoURL}/commits`,params:{include:e,pagelen:100}}).catch((t=>(console.log(`Failed getting commits for branch '${e}'`,t),[])));return r.some((e=>e.hash===t))}async uploadFiles(e,{commitMessage:t,branch:r,parentSha:n}){const i=new FormData,s=[];e.forEach((e=>{if(e.delete)i.append("files",e.path);else if(e.newPath){const t=ne()(e,"fileObj",new Blob([e.raw]));s.push({from:e.path,to:e.newPath,contentBlob:t})}else{const t=ne()(e,"fileObj",new Blob([e.raw]));i.append(e.path,t,(0,_.basename)(e.path))}}));for(const{from:e,to:t,contentBlob:o}of s){const s=(0,oe.dirname)(e),a=(0,oe.dirname)(t),u=n?this.branch:r,c=await this.listAllFiles(s,100,u);for(const t of c){i.append("files",t.path);const r=t.path===e?o:await this.readFile(t.path,null,{branch:u,parseText:!1});i.append(t.path.replace(s,a),r,(0,_.basename)(t.path))}}if(t&&i.append("message",t),this.commitAuthor){const{name:e,email:t}=this.commitAuthor;i.append("author",`${e} <${t}>`)}i.append("branch",r),n&&i.append("parents",n);try{await this.requestText({url:`${this.repoURL}/src`,method:"POST",body:i})}catch(e){const t=e.message||"";throw n&&t.includes("Something went wrong")&&await(0,_.throwOnConflictingBranches)(r,(e=>this.getBranch(e)),pe),e}return e}async persistFiles(e,t,r){const n=[...e,...t];if(r.useWorkflow){const t=e[0].slug;return this.editorialWorkflowGit(n,t,r)}return this.uploadFiles(n,{commitMessage:r.commitMessage,branch:this.branch})}async addPullRequestComment(e,t){await this.requestJSON({method:"POST",url:`${this.repoURL}/pullrequests/${e.id}/comments`,headers:{"Content-Type":fe},body:JSON.stringify({content:{raw:t}})})}async getPullRequestLabel(e){const t=await this.requestJSON({url:`${this.repoURL}/pullrequests/${e}/comments`,params:{pagelen:100}});return t.values.map((e=>e.content.raw))[t.values.length-1]}async createPullRequest(e,t,r){const n=await this.requestJSON({method:"POST",url:`${this.repoURL}/pullrequests`,headers:{"Content-Type":fe},body:JSON.stringify({title:t,source:{branch:{name:e}},destination:{branch:{name:this.branch}},description:_.DEFAULT_PR_BODY,close_source_branch:!0})});await this.addPullRequestComment(n,(0,_.statusToLabel)(r,this.cmsLabelPrefix))}async getDifferences(e,t=this.branch){if(e===t)return[];const r=await this.requestText({url:`${this.repoURL}/diff/${e}..${t}`,params:{binary:!1}});return(0,ae.parse)(r).map((e=>{var t,r;const n=(null===(t=e.oldPath)||void 0===t?void 0:t.replace(/b\//,""))||"",i=(null===(r=e.newPath)||void 0===r?void 0:r.replace(/b\//,""))||"",s=i||n;return{oldPath:n,newPath:i,status:e.status,newFile:"added"===e.status,path:s,binary:e.binary||/.svg$/.test(s)}}))}async editorialWorkflowGit(e,t,r){const n=(0,_.generateContentKey)(r.collectionName,t),i=(0,_.branchFromContentKey)(n);if(r.unpublished){const t=await this.getDifferences(i),n=[];for(const r of t.filter((e=>e.binary&&"deleted"!==e.status)))e.some((e=>e.path===r.path))||n.push({path:r.path,delete:!0});await this.uploadFiles([...e,...n],{commitMessage:r.commitMessage,branch:i})}else{const t=await this.branchCommitSha(this.branch);await this.uploadFiles(e,{commitMessage:r.commitMessage,branch:i,parentSha:t}),await this.createPullRequest(i,r.commitMessage,r.status||this.initialWorkflowStatus)}}async getPullRequests(e){const t=e?`source.branch.name = "${e}"`:`source.branch.name ~ "${_.CMS_BRANCH_PREFIX}/"`,r=await this.requestJSON({url:`${this.repoURL}/pullrequests`,params:{pagelen:50,q:x` source.repository.full_name = "${this.repo}" AND state = "${le.OPEN}" AND destination.branch.name = "${this.branch}" AND comment_count > 0 AND ${t} `}}),n=await Promise.all(r.values.map((e=>this.getPullRequestLabel(e.id))));return r.values.filter(((e,t)=>(0,_.isCMSLabel)(n[t],this.cmsLabelPrefix)))}async getBranchPullRequest(e){const t=await this.getPullRequests(e);if(t.length<=0)throw new _.EditorialWorkflowError("content is not under editorial workflow",!0);return t[0]}async listUnpublishedBranches(){return console.log("%c Checking for Unpublished entries","line-height: 30px;text-align: center;font-weight: bold"),(await this.getPullRequests()).map((e=>e.source.branch.name))}async retrieveUnpublishedEntryData(e){const{collection:t,slug:r}=(0,_.parseContentKey)(e),n=(0,_.branchFromContentKey)(e),i=await this.getBranchPullRequest(n),s=await this.getDifferences(n),o=await this.getPullRequestLabel(i.id),a=(0,_.labelToStatus)(o,this.cmsLabelPrefix),u=i.updated_on,c=i.author.display_name;return{collection:t,slug:r,status:a,diffs:s.filter((e=>"deleted"!==e.status)).map((e=>({path:e.path,newFile:e.newFile,id:""}))),updatedAt:u,pullRequestAuthor:c}}async updateUnpublishedEntryStatus(e,t,r){const n=(0,_.generateContentKey)(e,t),i=(0,_.branchFromContentKey)(n),s=await this.getBranchPullRequest(i);await this.addPullRequestComment(s,(0,_.statusToLabel)(r,this.cmsLabelPrefix))}async mergePullRequest(e){await this.requestJSON({method:"POST",url:`${this.repoURL}/pullrequests/${e.id}/merge`,headers:{"Content-Type":fe},body:JSON.stringify({message:_.MERGE_COMMIT_MESSAGE,close_source_branch:!0,merge_strategy:this.mergeStrategy})})}async publishUnpublishedEntry(e,t){const r=(0,_.generateContentKey)(e,t),n=(0,_.branchFromContentKey)(r),i=await this.getBranchPullRequest(n);await this.mergePullRequest(i)}async declinePullRequest(e){await this.requestJSON({method:"POST",url:`${this.repoURL}/pullrequests/${e.id}/decline`})}async deleteBranch(e){await this.request({method:"DELETE",url:`${this.repoURL}/refs/branches/${e}`})}async deleteUnpublishedEntry(e,t){const r=(0,_.generateContentKey)(e,t),n=(0,_.branchFromContentKey)(r),i=await this.getBranchPullRequest(n);await this.declinePullRequest(i),await this.deleteBranch(n)}async getPullRequestStatuses(e){return(await this.requestJSON({url:`${this.repoURL}/pullrequests/${e.id}/statuses`,params:{pagelen:100}})).values}async getStatuses(e,t){const r=(0,_.generateContentKey)(e,t),n=(0,_.branchFromContentKey)(r),i=await this.getBranchPullRequest(n);return(await this.getPullRequestStatuses(i)).map((({key:e,state:t,url:r})=>({context:e,state:t===he.Successful?_.PreviewState.Success:_.PreviewState.Other,target_url:r})))}async getUnpublishedEntrySha(e,t){const r=(0,_.generateContentKey)(e,t),n=(0,_.branchFromContentKey)(r);return(await this.getBranchPullRequest(n)).destination.commit.hash}}var me=u(7339),ve=u.n(me);const ye=["sha"];function be(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function xe(e){for(var t=1;tve()(e,t,{matchBase:!0})))}async uploadResource(e,t){const r=await this.getResourceUploadRequests([e]);for(const e of r)await this.doUpload(e.actions.upload,t),e.actions.verify&&await this.doVerify(e.actions.verify,e);return e.sha}async doUpload(e,t){await _.unsentRequest.fetchWithTimeout(decodeURI(e.href),{method:"PUT",body:t,headers:e.header})}async doVerify(e,t){this.makeAuthorizedRequest({url:decodeURI(e.href),method:"POST",headers:xe(xe({},_e.defaultContentHeaders),e.header),body:JSON.stringify({oid:t.oid,size:t.size})})}async getResourceUploadRequests(e){const t=await this.makeAuthorizedRequest({url:`${this.rootURL}/objects/batch`,method:"POST",headers:_e.defaultContentHeaders,body:JSON.stringify({operation:"upload",transfers:["basic"],objects:e.map((e=>{let{sha:t}=e;return xe(xe({},function(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},s=Object.keys(e);for(n=0;n=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(e,ye)),{},{oid:t})}))})});return(await t.json()).objects.filter((e=>"error"in e?(console.error(e.error),!1):e.actions))}}function Pe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ke(e){for(var t=1;t{const t=await this.getToken(),r=_.unsentRequest.withHeaders({Authorization:`Bearer ${t}`},e);return _.unsentRequest.performRequest(r)})),Se(this,"apiRequestFunction",(async e=>{const t=this.refreshedTokenPromise?await this.refreshedTokenPromise:this.token,r=_.unsentRequest.withHeaders({Authorization:`Bearer ${t}`},e),n=await _.unsentRequest.performRequest(r);if(401===n.status){const t=await n.json().catch((()=>null));if(t&&"error"===t.type&&/^access token expired/i.test(t.error.message)){const t=await this.getRefreshedAccessToken(),r=_.unsentRequest.withHeaders({Authorization:`Bearer ${t}`},e);return _.unsentRequest.performRequest(r)}}return n})),this.options=ke({proxied:!1,API:null,updateUserCredentials:async()=>null,initialWorkflowStatus:""},t),!this.options.proxied&&(null===e.backend.repo||void 0===e.backend.repo))throw new Error('The BitBucket backend needs a "repo" in the backend configuration.');this.api=this.options.API||null,this.updateUserCredentials=this.options.updateUserCredentials,this.repo=e.backend.repo||"",this.branch=e.backend.branch||"master",this.isBranchConfigured=!!e.backend.branch,this.apiRoot=e.backend.api_root||"https://api.bitbucket.org/2.0",this.baseUrl=e.base_url||"",this.siteId=e.site_id||"",this.largeMediaURL=e.backend.large_media_url||`https://bitbucket.org/${e.backend.repo}/info/lfs`,this.token="",this.mediaFolder=e.media_folder,this.squashMerges=e.backend.squash_merges||!1,this.cmsLabelPrefix=e.backend.cms_label_prefix||"",this.previewContext=e.backend.preview_context||"",this.lock=(0,_.asyncLock)(),this.authType=e.backend.auth_type||""}isGitBackend(){return!0}async status(){const e=await Re(Ce).then((e=>e.json())).then((e=>e.components.filter((e=>Ae.includes(e.name))).every((e=>"operational"===e.status)))).catch((e=>(console.warn("Failed getting BitBucket status",e),!0)));let t=!1;var r;return e&&(t=await(null===(r=this.api)||void 0===r?void 0:r.user().then((e=>!!e)).catch((e=>(console.warn("Failed getting Bitbucket user",e),!1))))||!1),{auth:{status:t},api:{status:e,statusPage:Oe}}}authComponent(){return te}setUser(e){this.token=e.token,this.api=new ge({requestFunction:this.apiRequestFunction,branch:this.branch,repo:this.repo,squashMerges:this.squashMerges,cmsLabelPrefix:this.cmsLabelPrefix,initialWorkflowStatus:this.options.initialWorkflowStatus})}restoreUser(e){return this.authenticate(e)}async authenticate(e){if(this.token=e.token,!this.isBranchConfigured){const e=await Re(`${this.apiRoot}/repositories/${this.repo}`,{headers:{Authorization:`token ${this.token}`}}).then((e=>e.json())).catch((()=>null));e&&(this.branch=e.mainbranch.name)}if(this.refreshToken=e.refresh_token,this.api=new ge({requestFunction:this.apiRequestFunction,branch:this.branch,repo:this.repo,apiRoot:this.apiRoot,squashMerges:this.squashMerges,cmsLabelPrefix:this.cmsLabelPrefix,initialWorkflowStatus:this.options.initialWorkflowStatus}),!await this.api.hasWriteAccess().catch((e=>{throw e.message=w` Repo "${this.repo}" not found. Please ensure the repo information is spelled correctly. If the repo is private, make sure you're logged into a Bitbucket account with access. `,e})))throw new Error("Your BitBucket user account does not have access to this repo.");const t=await this.api.user();return ke(ke({},t),{},{name:t.display_name,login:t.username,token:e.token,avatar_url:t.links.avatar.href,refresh_token:e.refresh_token})}getRefreshedAccessToken(){if("implicit"===this.authType)throw new _.AccessTokenError("Can't refresh access token when using implicit auth");if(this.refreshedTokenPromise)return this.refreshedTokenPromise;if(!this.authenticator){const e={base_url:this.baseUrl,site_id:this.siteId};this.authenticator=new P.NetlifyAuthenticator(e)}return this.refreshedTokenPromise=this.authenticator.refresh({provider:"bitbucket",refresh_token:this.refreshToken}).then((({token:e,refresh_token:t})=>(this.token=e,this.refreshToken=t,this.refreshedTokenPromise=void 0,this.updateUserCredentials({token:e,refresh_token:t}),e))),this.refreshedTokenPromise}logout(){this.token=null}getToken(){return this.refreshedTokenPromise?this.refreshedTokenPromise:Promise.resolve(this.token)}async entriesByFolder(e,t,r){let n;const i=await this.api.defaultBranchCommitSha(),s=await(0,_.entriesByFolder)((()=>this.api.listFiles(e,r,20,this.branch).then((({entries:e,cursor:r})=>(n=r.mergeMeta({extension:t}),e.filter((e=>(0,_.filterByExtension)(e,t))))))),((e,t)=>this.api.readFile(e,t,{head:i})),this.api.readFileMetadata.bind(this.api),pe);return s[_.CURSOR_COMPATIBILITY_SYMBOL]=n,s}async listAllFiles(e,t,r){return(await this.api.listAllFiles(e,r,this.branch)).filter((e=>(0,_.filterByExtension)(e,t)))}async allEntriesByFolder(e,t,r){const n=await this.api.defaultBranchCommitSha();return await(0,_.allEntriesByFolder)({listAllFiles:()=>this.listAllFiles(e,t,r),readFile:(e,t)=>this.api.readFile(e,t,{head:n}),readFileMetadata:this.api.readFileMetadata.bind(this.api),apiName:pe,branch:this.branch,localForage:_.localForage,folder:e,extension:t,depth:r,getDefaultBranch:()=>Promise.resolve({name:this.branch,sha:n}),isShaExistsInBranch:this.api.isShaExistsInBranch.bind(this.api),getDifferences:(e,t)=>this.api.getDifferences(e,t),getFileId:e=>Promise.resolve(this.api.getFileId(n,e)),filterFile:e=>(0,_.filterByExtension)(e,t)})}async entriesByFiles(e){const t=await this.api.defaultBranchCommitSha();return(0,_.entriesByFiles)(e,((e,r)=>this.api.readFile(e,r,{head:t})),this.api.readFileMetadata.bind(this.api),pe)}getEntry(e){return this.api.readFile(e).then((t=>({file:{path:e,id:null},data:t})))}getMedia(e=this.mediaFolder){return this.api.listAllFiles(e,1,this.branch).then((e=>e.map((({id:e,name:t,path:r})=>({id:e,name:t,path:r,displayURL:{id:e,path:r}})))))}getLargeMediaClient(){return this._largeMediaClientPromise||(this._largeMediaClientPromise=(async()=>{const e=await this.api.readFile(".gitattributes").then((e=>(0,_.getLargeMediaPatternsFromGitAttributesFile)(e))).catch((e=>(404===e.status?console.log("This 404 was expected and handled appropriately."):console.error(e),[])));return new _e(!!(this.largeMediaURL&&e.length>0),this.largeMediaURL,e,this.requestFunction)})()),this._largeMediaClientPromise}getMediaDisplayURL(e){return this._mediaDisplayURLSem=this._mediaDisplayURLSem||s()(10),(0,_.getMediaDisplayURL)(e,this.api.readFile.bind(this.api),this._mediaDisplayURLSem)}async getMediaFile(e){const t=(0,_.basename)(e),r=await(0,_.getMediaAsBlob)(e,null,this.api.readFile.bind(this.api)),n=(0,_.blobToFileObj)(t,r),i=URL.createObjectURL(n);return{id:await(0,_.getBlobSHA)(n),displayURL:i,path:e,name:t,size:n.size,file:n,url:i}}async persistEntry(e,t){const r=await this.getLargeMediaClient();return(0,_.runWithLock)(this.lock,(async()=>this.api.persistFiles(e.dataFiles,r.enabled?await(0,_.getLargeMediaFilteredMediaFiles)(r,e.assets):e.assets,t)),"Failed to acquire persist entry lock")}async persistMedia(e,t){const{fileObj:r,path:n}=e,i=r?URL.createObjectURL(r):"",s=await this.getLargeMediaClient(),o=n.startsWith("/")?n.slice(1):n;if(!s.enabled||!s.matchPath(o))return this._persistMedia(e,t);const a=await(0,_.getPointerFileForMediaFileObj)(s,r,n);return ke(ke({},await this._persistMedia(a,t)),{},{displayURL:i})}async _persistMedia(e,t){const r=e.fileObj,[i]=await Promise.all([(0,_.getBlobSHA)(r),this.api.persistFiles([],[e],t)]),s=URL.createObjectURL(r);return{displayURL:s,path:n()(e.path,"/k"),name:r.name,size:r.size,id:i,file:r,url:s}}deleteFiles(e,t){return this.api.deleteFiles(e,t)}traverseCursor(e,t){return this.api.traverseCursor(e,t).then((async({entries:t,cursor:r})=>{var n;const i=null===(n=e.meta)||void 0===n?void 0:n.get("extension");i&&(t=t.filter((e=>(0,_.filterByExtension)(e,i))),r=r.mergeMeta({extension:i}));const s=await this.api.defaultBranchCommitSha();return{entries:await(0,_.entriesByFiles)(t,((e,t)=>this.api.readFile(e,t,{head:s})),this.api.readFileMetadata.bind(this.api),pe),cursor:r}}))}async loadMediaFile(e,t,{branch:r}){const n=await(0,_.getMediaAsBlob)(e,t,(async(e,t,{parseText:n})=>await this.api.readFile(e,t,{branch:r,parseText:n}))),i=(0,_.basename)(e),s=(0,_.blobToFileObj)(i,n);return{id:e,displayURL:URL.createObjectURL(s),path:e,name:i,size:s.size,file:s}}async unpublishedEntries(){return await(0,_.unpublishedEntries)((()=>this.api.listUnpublishedBranches().then((e=>e.map((e=>(0,_.contentKeyFromBranch)(e)))))))}async unpublishedEntry({id:e,collection:t,slug:r}){if(e)return await this.api.retrieveUnpublishedEntryData(e);if(t&&r){const e=(0,_.generateContentKey)(t,r);return await this.api.retrieveUnpublishedEntryData(e)}throw new Error("Missing unpublished entry id or collection and slug")}getBranch(e,t){const r=(0,_.generateContentKey)(e,t);return(0,_.branchFromContentKey)(r)}async unpublishedEntryDataFile(e,t,r,n){const i=this.getBranch(e,t);return await this.api.readFile(r,n,{branch:i})}async unpublishedEntryMediaFile(e,t,r,n){const i=this.getBranch(e,t);return await this.loadMediaFile(r,n,{branch:i})}async updateUnpublishedEntryStatus(e,t,r){return(0,_.runWithLock)(this.lock,(()=>this.api.updateUnpublishedEntryStatus(e,t,r)),"Failed to acquire update entry status lock")}async deleteUnpublishedEntry(e,t){return(0,_.runWithLock)(this.lock,(()=>this.api.deleteUnpublishedEntry(e,t)),"Failed to acquire delete entry lock")}async publishUnpublishedEntry(e,t){return(0,_.runWithLock)(this.lock,(()=>this.api.publishUnpublishedEntry(e,t)),"Failed to acquire publish entry lock")}async getDeployPreview(e,t){try{const r=await this.api.getStatuses(e,t),n=(0,_.getPreviewStatus)(r,this.previewContext);if(n){const{target_url:e,state:t}=n;return{url:e,status:t}}return null}catch(e){return null}}},API:ge,AuthenticationPage:te}})(),c.DecapCmsBackendBitbucket})())); //# sourceMappingURL=decap-cms-backend-bitbucket.js.map