From 2c4bef2befd7be1e015c97617c6cc4e00d81ffc3 Mon Sep 17 00:00:00 2001 From: molenzwiebel Date: Wed, 3 Feb 2021 23:44:15 +0100 Subject: [PATCH] Proof of concept of suggested removal reasons. Major spaghetti. --- extension/data/libs/yaml.js | 8 + extension/data/modules/config.js | 162 +++++ extension/data/modules/newremovalreasons.js | 741 ++++++++++++++++++++ extension/data/modules/oldreddit.js | 8 + extension/data/styles/toolbox.css | 44 +- extension/data/tbhelpers.js | 137 ++++ extension/manifest.json | 4 +- 7 files changed, 1101 insertions(+), 3 deletions(-) create mode 100644 extension/data/libs/yaml.js create mode 100644 extension/data/modules/newremovalreasons.js diff --git a/extension/data/libs/yaml.js b/extension/data/libs/yaml.js new file mode 100644 index 000000000..3ba59a203 --- /dev/null +++ b/extension/data/libs/yaml.js @@ -0,0 +1,8 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).yaml=e()}}((function(){return function e(t,r,n){function a(s,o){if(!r[s]){if(!t[s]){var l="function"==typeof require&&require;if(!o&&l)return l(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};t[s][0].call(f.exports,(function(e){return a(t[s][1][e]||e)}),f,f.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s0?s-4:s;for(r=0;r>16&255,l[f++]=t>>8&255,l[f++]=255&t;2===o&&(t=a[e.charCodeAt(r)]<<2|a[e.charCodeAt(r+1)]>>4,l[f++]=255&t);1===o&&(t=a[e.charCodeAt(r)]<<10|a[e.charCodeAt(r+1)]<<4|a[e.charCodeAt(r+2)]>>2,l[f++]=t>>8&255,l[f++]=255&t);return l},r.fromByteArray=function(e){for(var t,r=e.length,a=r%3,i=[],s=0,o=r-a;so?o:s+16383));1===a?(t=e[r-1],i.push(n[t>>2]+n[t<<4&63]+"==")):2===a&&(t=(e[r-2]<<8)+e[r-1],i.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return i.join("")};for(var n=[],a=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,l=s.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function f(e,t,r){for(var a,i,s=[],o=t;o>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63},{}],2:[function(e,t,r){(function(t){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +"use strict";var n=e("base64-js"),a=e("ieee754"),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;r.Buffer=t,r.SlowBuffer=function(e){+e!=e&&(e=0);return t.alloc(+e)},r.INSPECT_MAX_BYTES=50;var s=2147483647;function o(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');var r=new Uint8Array(e);return Object.setPrototypeOf(r,t.prototype),r}function t(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return f(e)}return l(e,t,r)}function l(e,r,n){if("string"==typeof e)return function(e,r){"string"==typeof r&&""!==r||(r="utf8");if(!t.isEncoding(r))throw new TypeError("Unknown encoding: "+r);var n=0|p(e,r),a=o(n),i=a.write(e,r);i!==n&&(a=a.slice(0,i));return a}(e,r);if(ArrayBuffer.isView(e))return c(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return function(e,r,n){if(r<0||e.byteLength=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|e}function p(e,r){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var n=e.length,a=arguments.length>2&&!0===arguments[2];if(!a&&0===n)return 0;for(var i=!1;;)switch(r){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return j(e).length;default:if(i)return a?-1:B(e).length;r=(""+r).toLowerCase(),i=!0}}function d(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return T(this,t,r);case"utf8":case"utf-8":return S(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return L(this,t,r);case"base64":return k(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function v(e,r,n,a,i){if(0===e.length)return-1;if("string"==typeof n?(a=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),U(n=+n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof r&&(r=t.from(r,a)),t.isBuffer(r))return 0===r.length?-1:b(e,r,n,a,i);if("number"==typeof r)return r&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,r,n):Uint8Array.prototype.lastIndexOf.call(e,r,n):b(e,[r],n,a,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,a){var i,s=1,o=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,o/=2,l/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var f=-1;for(i=r;io&&(r=o-l),i=r;i>=0;i--){for(var c=!0,h=0;ha&&(n=a):n=a;var i=t.length;n>i/2&&(n=i/2);for(var s=0;s>8,a=r%256,i.push(a),i.push(n);return i}(t,e.length-r),e,r,n)}function k(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function S(e,t,r){r=Math.min(e.length,r);for(var n=[],a=t;a239?4:u>223?3:u>191?2:1;if(a+c<=r)switch(c){case 1:u<128&&(f=u);break;case 2:128==(192&(i=e[a+1]))&&(l=(31&u)<<6|63&i)>127&&(f=l);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(l=(15&u)<<12|(63&i)<<6|63&s)>2047&&(l<55296||l>57343)&&(f=l);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(l=(15&u)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&l<1114112&&(f=l)}null===f?(f=65533,c=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),a+=c}return function(e){var t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);var r="",n=0;for(;nt&&(e+=" ... "),""},i&&(t.prototype[i]=t.prototype.inspect),t.prototype.compare=function(e,r,n,a,i){if(Y(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===r&&(r=0),void 0===n&&(n=e?e.length:0),void 0===a&&(a=0),void 0===i&&(i=this.length),r<0||n>e.length||a<0||i>this.length)throw new RangeError("out of range index");if(a>=i&&r>=n)return 0;if(a>=i)return-1;if(r>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(a>>>=0),o=(n>>>=0)-(r>>>=0),l=Math.min(s,o),u=this.slice(a,i),f=e.slice(r,n),c=0;c>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var a=this.length-t;if((void 0===r||r>a)&&(r=a),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return y(this,e,t,r);case"utf8":case"utf-8":return g(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return O(this,e,t,r);case"base64":return C(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;function M(e,t,r){var n="";r=Math.min(e.length,r);for(var a=t;an)&&(r=n);for(var a="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function P(e,r,n,a,i,s){if(!t.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>i||re.length)throw new RangeError("Index out of range")}function x(e,t,r,n,a,i){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function _(e,t,r,n,i){return t=+t,r>>>=0,i||x(e,0,r,4),a.write(e,t,r,n,23,4),r+4}function I(e,t,r,n,i){return t=+t,r>>>=0,i||x(e,0,r,8),a.write(e,t,r,n,52,8),r+8}t.prototype.slice=function(e,r){var n=this.length;(e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e],a=1,i=0;++i>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e+--t],a=1;t>0&&(a*=256);)n+=this[e+--t]*a;return n},t.prototype.readUInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||N(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=this[e],a=1,i=0;++i=(a*=128)&&(n-=Math.pow(2,8*t)),n},t.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||N(e,t,this.length);for(var n=t,a=1,i=this[e+--n];n>0&&(a*=256);)i+=this[e+--n]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},t.prototype.readInt8=function(e,t){return e>>>=0,t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt16BE=function(e,t){e>>>=0,t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||N(e,4,this.length),a.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||N(e,4,this.length),a.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||N(e,8,this.length),a.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||N(e,8,this.length),a.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t>>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var a=1,i=0;for(this[t]=255&e;++i>>=0,r>>>=0,n)||P(this,e,t,r,Math.pow(2,8*r)-1,0);var a=r-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+r},t.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},t.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var a=Math.pow(2,8*r-1);P(this,e,t,r,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i>0)-o&255;return t+r},t.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t>>>=0,!n){var a=Math.pow(2,8*r-1);P(this,e,t,r,a-1,-a)}var i=r-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+r},t.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},t.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||P(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},t.prototype.writeFloatLE=function(e,t,r){return _(this,e,t,!0,r)},t.prototype.writeFloatBE=function(e,t,r){return _(this,e,t,!1,r)},t.prototype.writeDoubleLE=function(e,t,r){return I(this,e,t,!0,r)},t.prototype.writeDoubleBE=function(e,t,r){return I(this,e,t,!1,r)},t.prototype.copy=function(e,r,n,a){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),a||0===a||(a=this.length),r>=e.length&&(r=e.length),r||(r=0),a>0&&a=this.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-r=0;--s)e[s+r]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,a),r);return i},t.prototype.fill=function(e,r,n,a){if("string"==typeof e){if("string"==typeof r?(a=r,r=0,n=this.length):"string"==typeof n&&(a=n,n=this.length),void 0!==a&&"string"!=typeof a)throw new TypeError("encoding must be a string");if("string"==typeof a&&!t.isEncoding(a))throw new TypeError("Unknown encoding: "+a);if(1===e.length){var i=e.charCodeAt(0);("utf8"===a&&i<128||"latin1"===a)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(r<0||this.length>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=r;s55295&&r<57344){if(!a){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&i.push(239,191,189);continue}a=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),a=r;continue}r=65536+(a-55296<<10|r-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function j(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(D,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,n){for(var a=0;a=t.length||a>=e.length);++a)t[a+r]=e[a];return a}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function U(e){return e!=e}var F=function(){for(var e=new Array(256),t=0;t<16;++t)for(var r=16*t,n=0;n<16;++n)e[r+n]="0123456789abcdef"[t]+"0123456789abcdef"[n];return e}()}).call(this,e("buffer").Buffer)},{"base64-js":1,buffer:2,ieee754:3}],3:[function(e,t,r){r.read=function(e,t,r,n,a){var i,s,o=8*a-n-1,l=(1<>1,f=-7,c=r?a-1:0,h=r?-1:1,p=e[t+c];for(c+=h,i=p&(1<<-f)-1,p>>=-f,f+=o;f>0;i=256*i+e[t+c],c+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=n;f>0;s=256*s+e[t+c],c+=h,f-=8);if(0===i)i=1-u;else{if(i===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),i-=u}return(p?-1:1)*s*Math.pow(2,i-n)},r.write=function(e,t,r,n,a,i){var s,o,l,u=8*i-a-1,f=(1<>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,d=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+c>=1?h/l:h*Math.pow(2,1-c))*l>=2&&(s++,l/=2),s+c>=f?(o=0,s=f):s+c>=1?(o=(t*l-1)*Math.pow(2,a),s+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,a),s=0));a>=8;e[r+p]=255&o,p+=d,o/=256,a-=8);for(s=s<0;e[r+p]=255&s,p+=d,s/=256,u-=8);e[r+p-d]|=128*m}},{}],4:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/defineProperty")),o=n(e("./schema/Alias")),l=n(e("./schema/Map")),u=n(e("./schema/Merge")),f=n(e("./schema/Scalar")),c=n(e("./schema/Seq")),h=function(){function e(t){(0,a.default)(this,e),(0,s.default)(this,"map",{}),this.prefix=t}return(0,i.default)(e,null,[{key:"validAnchorNode",value:function(e){return e instanceof f.default||e instanceof c.default||e instanceof l.default}}]),(0,i.default)(e,[{key:"createAlias",value:function(e,t){return this.setAnchor(e,t),new o.default(e)}},{key:"createMergePair",value:function(){for(var e=this,t=new u.default,r=arguments.length,n=new Array(r),a=0;a0&&!t.commentBefore&&(t.commentBefore=r.before.join("\n"),r.before=[]))})),n.length){case 0:this.contents=null,r.after=r.before;break;case 1:if(this.contents=n[0],this.contents){var i=r.before.join("\n")||null;if(i){var s=this.contents instanceof v.default&&this.contents.items[0]?this.contents.items[0]:this.contents;s.commentBefore=s.commentBefore?"".concat(i,"\n").concat(s.commentBefore):i}}else r.after=r.before.concat(r.after);break;default:this.contents=n,this.contents[0]?this.contents[0].commentBefore=r.before.join("\n")||null:r.after=r.before.concat(r.after)}this.comment=r.after.join("\n")||null}},{key:"resolveTagDirective",value:function(e){var t=(0,i.default)(e.parameters,2),r=t[0],n=t[1];if(r&&n)if(this.tagPrefixes.every((function(e){return e.handle!==r})))this.tagPrefixes.push({handle:r,prefix:n});else{this.errors.push(new h.YAMLSemanticError(e,"The %TAG directive must only be given at most once per handle in the same document."))}else{this.errors.push(new h.YAMLSemanticError(e,"Insufficient parameters given for %TAG directive"))}}},{key:"resolveYamlDirective",value:function(t){var r=(0,i.default)(t.parameters,1)[0];if("YAML:1.0"===t.name&&(r="1.0"),this.version){this.errors.push(new h.YAMLSemanticError(t,"The %YAML directive must only be given at most once per document."))}if(r){if(!e.defaults[r]){var n=this.version||this.options.version,a="Document will be parsed as YAML ".concat(n," rather than YAML ").concat(r);this.warnings.push(new h.YAMLWarning(t,a))}this.version=r}else{this.errors.push(new h.YAMLSemanticError(t,"Insufficient parameters given for %YAML directive"))}}},{key:"resolveTagName",value:function(e){var t=e.tag,r=e.type,n=!1;if(t){var a=t.handle,i=t.suffix,s=t.verbatim;if(s){if("!"!==s&&"!!"!==s)return s;var o="Verbatim tags aren't resolved, so ".concat(s," is invalid.");this.errors.push(new h.YAMLSemanticError(e,o))}else if("!"!==a||i){var l=this.tagPrefixes.find((function(e){return e.handle===a}));if(!l){var u=this.getDefaults().tagPrefixes;u&&(l=u.find((function(e){return e.handle===a})))}if(l){if(i){if("!"===a&&"1.0"===(this.version||this.options.version)){if("^"===i[0])return i;if(/[:/]/.test(i)){var f=i.match(/^([a-z0-9-]+)\/(.*)/i);return f?"tag:".concat(f[1],".yaml.org,2002:").concat(f[2]):"tag:".concat(i)}}return l.prefix+decodeURIComponent(i)}this.errors.push(new h.YAMLSemanticError(e,"The ".concat(a," tag has no suffix.")))}else{var p="The ".concat(a," tag handle is non-default and was not declared.");this.errors.push(new h.YAMLSemanticError(e,p))}}else n=!0}switch(r){case c.Type.BLOCK_FOLDED:case c.Type.BLOCK_LITERAL:case c.Type.QUOTE_DOUBLE:case c.Type.QUOTE_SINGLE:return d.default.defaultTags.STR;case c.Type.FLOW_MAP:case c.Type.MAP:return d.default.defaultTags.MAP;case c.Type.FLOW_SEQ:case c.Type.SEQ:return d.default.defaultTags.SEQ;case c.Type.PLAIN:return n?d.default.defaultTags.STR:null;default:return null}}},{key:"resolveNode",value:function(e){if(!e)return null;var t,r=this.anchors,n=this.errors,a=this.schema,i=!1,s=!1,o={before:[],after:[]},l=function(e){return e&&[c.Type.MAP_KEY,c.Type.MAP_VALUE,c.Type.SEQ_ITEM].includes(e.type)}(e.context.parent)?e.context.parent.props.concat(e.props):e.props,u=!0,f=!1,p=void 0;try{for(var d,v=l[Symbol.iterator]();!(u=(d=v.next()).done);u=!0){var b=d.value,y=b.start,g=b.end;switch(e.context.src[y]){case c.Char.COMMENT:if(!e.commentHasRequiredWhitespace(y)){n.push(new h.YAMLSemanticError(e,"Comments must be separated from other tokens by white space characters"))}var w=e.context.src.slice(y+1,g),O=e.header,C=e.valueRange;C&&(y>C.start||O&&y>O.start)?o.after.push(w):o.before.push(w);break;case c.Char.ANCHOR:if(i){n.push(new h.YAMLSemanticError(e,"A node can have at most one anchor"))}i=!0;break;case c.Char.TAG:if(s){n.push(new h.YAMLSemanticError(e,"A node can have at most one tag"))}s=!0}}}catch(e){f=!0,p=e}finally{try{u||null==v.return||v.return()}finally{if(f)throw p}}if(i){var E=e.anchor,k=r.getNode(E);k&&(r.map[r.newName(E)]=k),r.map[E]=e}if(e.type===c.Type.ALIAS){if(i||s){n.push(new h.YAMLSemanticError(e,"An alias node must not specify any properties"))}var S=e.rawValue,A=r.getNode(S);if(!A){var M="Aliased anchor not found: ".concat(S);return n.push(new h.YAMLReferenceError(e,M)),null}t=new m.default(A),r._cstAliases.push(t)}else{var L=this.resolveTagName(e);if(L)t=a.resolveNodeWithFallback(this,e,L);else{if(e.type!==c.Type.PLAIN){var T="Failed to resolve ".concat(e.type," node here");return n.push(new h.YAMLSyntaxError(e,T)),null}try{t=a.resolveScalar(e.strValue||"")}catch(t){return t.source||(t.source=e),n.push(t),null}}}if(t){t.range=[e.range.start,e.range.end],this.options.keepCstNodes&&(t.cstNode=e),this.options.keepNodeTypes&&(t.type=e.type);var R=o.before.join("\n");R&&(t.commentBefore=t.commentBefore?"".concat(t.commentBefore,"\n").concat(R):R);var N=o.after.join("\n");N&&(t.comment=t.comment?"".concat(t.comment,"\n").concat(N):N)}return e.resolved=t}},{key:"listNonDefaultTags",value:function(){return(0,p.default)(this.contents).filter((function(e){return 0!==e.indexOf(d.default.defaultPrefix)}))}},{key:"setTagPrefix",value:function(e,t){if("!"!==e[0]||"!"!==e[e.length-1])throw new Error("Handle must start and end with !");if(t){var r=this.tagPrefixes.find((function(t){return t.handle===e}));r?r.prefix=t:this.tagPrefixes.push({handle:e,prefix:t})}else this.tagPrefixes=this.tagPrefixes.filter((function(t){return t.handle!==e}))}},{key:"stringifyTag",value:function(e){if("1.0"===(this.version||this.options.version)){var t=e.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);if(t)return"!"+t[1];var r=e.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);return r?"!".concat(r[1],"/").concat(r[2]):"!".concat(e.replace(/^tag:/,""))}var n=this.tagPrefixes.find((function(t){return 0===e.indexOf(t.prefix)}));if(!n){var a=this.getDefaults().tagPrefixes;n=a&&a.find((function(t){return 0===e.indexOf(t.prefix)}))}if(!n)return"!"===e[0]?e:"!<".concat(e,">");var i=e.substr(n.prefix.length).replace(/[!,[\]{}]/g,(function(e){return{"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"}[e]}));return n.handle+i}},{key:"toJSON",value:function(e){var t=this,r=this.options,n=r.keepBlobsInJSON,a=r.mapAsMap,i=r.maxAliasCount,s=n&&("string"!=typeof e||!(this.contents instanceof y.default)),o={doc:this,keep:s,mapAsMap:s&&!!a,maxAliasCount:i},l=Object.keys(this.anchors.map);return l.length>0&&(o.anchors=l.map((function(e){return{alias:[],aliasCount:0,count:1,node:t.anchors.map[e]}}))),(0,g.default)(this.contents,e,o)}},{key:"toString",value:function(){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");this.setSchema();var e=[],t=!1;if(this.version){var r="%YAML 1.2";"yaml-1.1"===this.schema.name&&("1.0"===this.version?r="%YAML:1.0":"1.1"===this.version&&(r="%YAML 1.1")),e.push(r),t=!0}var n=this.listNonDefaultTags();this.tagPrefixes.forEach((function(r){var a=r.handle,i=r.prefix;n.some((function(e){return 0===e.indexOf(i)}))&&(e.push("%TAG ".concat(a," ").concat(i)),t=!0)})),(t||this.directivesEndMarker)&&e.push("---"),this.commentBefore&&(!t&&this.directivesEndMarker||e.unshift(""),e.unshift(this.commentBefore.replace(/^/gm,"#")));var a={anchors:{},doc:this,indent:""},i=!1,s=null;if(this.contents){this.contents instanceof b.default&&(this.contents.spaceBefore&&(t||this.directivesEndMarker)&&e.push(""),this.contents.commentBefore&&e.push(this.contents.commentBefore.replace(/^/gm,"#")),a.forceBlockIndent=!!this.comment,s=this.contents.comment);var o=s?null:function(){return i=!0},l=this.schema.stringify(this.contents,a,(function(){return s=null}),o);e.push((0,u.default)(l,"",s))}else void 0!==this.contents&&e.push(this.schema.stringify(this.contents,a));return this.comment&&(i&&!s||""===e[e.length-1]||e.push(""),e.push(this.comment.replace(/^/gm,"#"))),e.join("\n")+"\n"}}]),e}();r.default=w,(0,l.default)(w,"defaults",{"1.0":{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:d.default.defaultPrefix},{handle:"!!",prefix:"tag:private.yaml.org,2002:"}]},1.1:{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:d.default.defaultPrefix}]},1.2:{schema:"core",merge:!1,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:d.default.defaultPrefix}]}})},{"./Anchors":4,"./addComment":6,"./constants":7,"./errors":25,"./listTagNames":28,"./schema":37,"./schema/Alias":29,"./schema/Collection":30,"./schema/Node":33,"./schema/Scalar":35,"./toJSON":56,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/interopRequireWildcard":69,"@babel/runtime/helpers/slicedToArray":76}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.addCommentBefore=function(e,t,r){if(!r)return e;var n=r.replace(/[\s\S]^/gm,"$&".concat(t,"#"));return"#".concat(n,"\n").concat(t).concat(e)},r.default=function(e,t,r){return r?-1===r.indexOf("\n")?"".concat(e," #").concat(r):"".concat(e,"\n")+r.replace(/^/gm,"".concat(t||"","#")):e}},{}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.Type=r.Char=void 0;r.Char={ANCHOR:"&",COMMENT:"#",TAG:"!",DIRECTIVES_END:"-",DOCUMENT_END:"."};r.Type={ALIAS:"ALIAS",BLANK_LINE:"BLANK_LINE",BLOCK_FOLDED:"BLOCK_FOLDED",BLOCK_LITERAL:"BLOCK_LITERAL",COMMENT:"COMMENT",DIRECTIVE:"DIRECTIVE",DOCUMENT:"DOCUMENT",FLOW_MAP:"FLOW_MAP",FLOW_SEQ:"FLOW_SEQ",MAP:"MAP",MAP_KEY:"MAP_KEY",MAP_VALUE:"MAP_VALUE",PLAIN:"PLAIN",QUOTE_DOUBLE:"QUOTE_DOUBLE",QUOTE_SINGLE:"QUOTE_SINGLE",SEQ:"SEQ",SEQ_ITEM:"SEQ_ITEM"}},{}],8:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("./Node")),f=n(e("./Range")),c=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parse",value:function(e,t){this.context=e;var r=e.src,n=u.default.endOfIdentifier(r,t+1);return this.valueRange=new f.default(t+1,n),n=u.default.endOfWhiteSpace(r,n),n=this.parseComment(n)}}]),t}(u.default);r.default=c},{"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],9:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=e("../constants"),f=n(e("./Node")),c=n(e("./Range")),h=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,u.Type.BLANK_LINE))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parse",value:function(e,t){this.context=e;for(var r=e.src,n=t+1;f.default.atBlank(r,n);){var a=f.default.endOfWhiteSpace(r,n);if("\n"!==a)break;n=a+1}return this.range=new c.default(t,n),n}},{key:"includesTrailingLines",get:function(){return!0}}]),t}(f.default);r.default=h},{"../constants":7,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],10:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.Chomp=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/get")),u=n(e("@babel/runtime/helpers/inherits")),f=e("../constants"),c=n(e("./Node")),h=n(e("./Range")),p={CLIP:"CLIP",KEEP:"KEEP",STRIP:"STRIP"};r.Chomp=p;var d=function(e){function t(e,r){var n;return(0,a.default)(this,t),(n=(0,s.default)(this,(0,o.default)(t).call(this,e,r))).blockIndent=null,n.chomping=p.CLIP,n.header=null,n}return(0,u.default)(t,e),(0,i.default)(t,[{key:"parseBlockHeader",value:function(e){for(var t=this.context.src,r=e+1,n="";;){var a=t[r];switch(a){case"-":this.chomping=p.STRIP;break;case"+":this.chomping=p.KEEP;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n+=a;break;default:return this.blockIndent=Number(n)||null,this.header=new h.default(e,r),r}r+=1}}},{key:"parseBlockValue",value:function(e){for(var t=this.context,r=t.indent,n=t.src,a=e,i=e,s=this.blockIndent?r+this.blockIndent-1:r,o=1,l=n[a];"\n"===l&&(a+=1,!c.default.atDocumentBoundary(n,a));l=n[a]){var u=c.default.endOfBlockIndent(n,s,a);if(null===u)break;if(!this.blockIndent){var f=u-(a+r);if("\n"!==n[u]){if(fo&&(o=f)}a="\n"===n[u]?u:i=c.default.endOfLine(n,u)}return this.chomping!==p.KEEP&&(a=n[i]?i+1:i),this.valueRange=new h.default(e+1,a),a}},{key:"parse",value:function(e,t){this.context=e;var r=e.src,n=this.parseBlockHeader(t);return n=c.default.endOfWhiteSpace(r,n),n=this.parseComment(n),n=this.parseBlockValue(n)}},{key:"setOrigRanges",value:function(e,r){return r=(0,l.default)((0,o.default)(t.prototype),"setOrigRanges",this).call(this,e,r),this.header?this.header.setOrigRange(e,r):r}},{key:"includesTrailingLines",get:function(){return this.chomping===p.KEEP}},{key:"strValue",get:function(){if(!this.valueRange||!this.context)return null;var e=this.valueRange,t=e.start,r=e.end,n=this.context,a=n.indent,i=n.src;if(this.valueRange.isEmpty())return"";for(var s=null,o=i[r-1];"\n"===o||"\t"===o||" "===o;){if((r-=1)<=t){if(this.chomping===p.KEEP)break;return""}"\n"===o&&(s=r),o=i[r-1]}var l=r+1;s&&(this.chomping===p.KEEP?(l=s,r=this.valueRange.end):r=s);for(var u=a+this.blockIndent,h=this.type===f.Type.BLOCK_FOLDED,d=!0,m="",v="",b=!1,y=t;y=0;--a){var i=t.items[a];if(i.type===f.Type.COMMENT){var s=i.context,o=s.indent,l=s.lineStart;if(o>0&&i.range.start>=l+o)break;n=a}else{if(i.type!==f.Type.BLANK_LINE)break;n=a}}if(-1===n)return null;for(var u=t.items.splice(n,r-n),c=u[0].range.start;t.range.end=c,t.valueRange&&t.valueRange.end>c&&(t.valueRange.end=c),t!==e;)t=t.context.parent;return u}var b=function(e){function t(e){var r;(0,a.default)(this,t),r=(0,i.default)(this,(0,s.default)(t).call(this,e.type===f.Type.SEQ_ITEM?f.Type.SEQ:f.Type.MAP));for(var n=e.props.length-1;n>=0;--n)if(e.props[n].start=a+n||("#"===i||"\n"===i)&&t.nextContentHasIndent(e,r,n))}}]),(0,l.default)(t,[{key:"parse",value:function(e,r){this.context=e;var n=e.parseNode,a=e.src,i=d.default.startOfLine(a,r),s=this.items[0];s.context.parent=this,this.valueRange=m.default.copy(s.valueRange);for(var o=s.range.start-s.context.lineStart,l=r,u=a[l=d.default.normalizeOffset(a,l)],h=d.default.endOfWhiteSpace(a,i)===l,b=!1;u;){for(;"\n"===u||"#"===u;){if(h&&"\n"===u&&!b){var y=new c.default;if(l=y.parse({src:a},l),this.valueRange.end=l,l>=a.length){u=null;break}this.items.push(y),l-=1}else if("#"===u){if(l=a.length){u=null;break}}if(i=l+1,l=d.default.endOfIndent(a,i),d.default.atBlank(a,l)){var w=d.default.endOfWhiteSpace(a,l),O=a[w];O&&"\n"!==O&&"#"!==O||(l=w)}u=a[l],h=!0}if(!u)break;if(l!==i+o&&(h||":"!==u)){i>r&&(l=i);break}if(s.type===f.Type.SEQ_ITEM!=("-"===u)){var C=!0;if("-"===u){var E=a[l+1];C=!E||"\n"===E||"\t"===E||" "===E}if(C){i>r&&(l=i);break}}var k=n({atLineStart:h,inCollection:!0,indent:o,lineStart:i,parent:this},l);if(!k)return l;if(this.items.push(k),this.valueRange.end=k.valueRange.end,u=a[l=d.default.normalizeOffset(a,k.range.end)],h=!1,b=k.includesTrailingLines,u){for(var S=l-1,A=a[S];" "===A||"\t"===A;)A=a[--S];"\n"===A&&(i=S+1,h=!0)}var M=v(k);M&&Array.prototype.push.apply(this.items,M)}return l}},{key:"setOrigRanges",value:function(e,r){return r=(0,o.default)((0,s.default)(t.prototype),"setOrigRanges",this).call(this,e,r),this.items.forEach((function(t){r=t.setOrigRanges(e,r)})),r}},{key:"toString",value:function(){var e=this.context.src,t=this.items,r=this.range,n=this.value;if(null!=n)return n;for(var a=e.slice(r.start,t[0].range.start)+String(t[0]),i=1;i0}}]),t}(d.default);r.default=b},{"../constants":7,"./BlankLine":9,"./CollectionItem":12,"./Comment":13,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],12:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/get")),u=n(e("@babel/runtime/helpers/inherits")),f=e("../constants"),c=e("../errors"),h=n(e("./BlankLine")),p=n(e("./Node")),d=n(e("./Range")),m=function(e){function t(e,r){var n;return(0,a.default)(this,t),(n=(0,s.default)(this,(0,o.default)(t).call(this,e,r))).node=null,n}return(0,u.default)(t,e),(0,i.default)(t,[{key:"parse",value:function(e,t){this.context=e;var r=e.parseNode,n=e.src,a=e.atLineStart,i=e.lineStart;a||this.type!==f.Type.SEQ_ITEM||(this.error=new c.YAMLSemanticError(this,"Sequence items must not have preceding content on the same line"));for(var s=a?t-i:e.indent,o=p.default.endOfWhiteSpace(n,t+1),l=n[o],u="#"===l,m=[],v=null;"\n"===l||"#"===l;){if("#"===l){var b=p.default.endOfLine(n,o+1);m.push(new d.default(o,b)),o=b}else{a=!0,i=o+1,"\n"===n[p.default.endOfWhiteSpace(n,i)]&&0===m.length&&(i=(v=new h.default).parse({src:n},i)),o=p.default.endOfIndent(n,i)}l=n[o]}if(p.default.nextNodeIsIndented(l,o-(i+s),this.type!==f.Type.SEQ_ITEM)?this.node=r({atLineStart:a,inCollection:!1,indent:s,lineStart:i,parent:this},o):l&&i>t+1&&(o=i-1),this.node){if(v){var y=e.parent.items||e.parent.contents;y&&y.push(v)}m.length&&Array.prototype.push.apply(this.props,m),o=this.node.range.end}else if(u){var g=m[0];this.props.push(g),o=g.end}else o=p.default.endOfLine(n,t+1);var w=this.node?this.node.valueRange.end:o;return this.valueRange=new d.default(t,w),o}},{key:"setOrigRanges",value:function(e,r){return r=(0,l.default)((0,o.default)(t.prototype),"setOrigRanges",this).call(this,e,r),this.node?this.node.setOrigRanges(e,r):r}},{key:"toString",value:function(){var e=this.context.src,t=this.node,r=this.range,n=this.value;if(null!=n)return n;var a=t?e.slice(r.start,t.range.start)+String(t):e.slice(r.start,r.end);return p.default.addStringTerminator(e,r.end,a)}},{key:"includesTrailingLines",get:function(){return!!this.node&&this.node.includesTrailingLines}}]),t}(p.default);r.default=m},{"../constants":7,"../errors":25,"./BlankLine":9,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],13:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=e("../constants"),f=n(e("./Node")),c=n(e("./Range")),h=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,u.Type.COMMENT))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parse",value:function(e,t){this.context=e;var r=this.parseComment(t);return this.range=new c.default(t,r),r}}]),t}(f.default);r.default=h},{"../constants":7,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],14:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/possibleConstructorReturn")),s=n(e("@babel/runtime/helpers/getPrototypeOf")),o=n(e("@babel/runtime/helpers/createClass")),l=n(e("@babel/runtime/helpers/inherits")),u=e("../constants"),f=n(e("./Node")),c=n(e("./Range")),h=function(e){function t(){var e;return(0,a.default)(this,t),(e=(0,i.default)(this,(0,s.default)(t).call(this,u.Type.DIRECTIVE))).name=null,e}return(0,l.default)(t,e),(0,o.default)(t,null,[{key:"endOfDirective",value:function(e,t){for(var r=e[t];r&&"\n"!==r&&"#"!==r;)r=e[t+=1];for(r=e[t-1];" "===r||"\t"===r;)r=e[(t-=1)-1];return t}}]),(0,o.default)(t,[{key:"parseName",value:function(e){for(var t=this.context.src,r=e,n=t[r];n&&"\n"!==n&&"\t"!==n&&" "!==n;)n=t[r+=1];return this.name=t.slice(e,r),r}},{key:"parseParameters",value:function(e){for(var t=this.context.src,r=e,n=t[r];n&&"\n"!==n&&"#"!==n;)n=t[r+=1];return this.valueRange=new c.default(e,r),r}},{key:"parse",value:function(e,t){this.context=e;var r=this.parseName(t+1);return r=this.parseParameters(r),r=this.parseComment(r),this.range=new c.default(t,r),r}},{key:"parameters",get:function(){var e=this.rawValue;return e?e.trim().split(/[ \t]+/):[]}}]),t}(f.default);r.default=h},{"../constants":7,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],15:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/possibleConstructorReturn")),s=n(e("@babel/runtime/helpers/getPrototypeOf")),o=n(e("@babel/runtime/helpers/get")),l=n(e("@babel/runtime/helpers/createClass")),u=n(e("@babel/runtime/helpers/inherits")),f=e("../constants"),c=e("../errors"),h=n(e("./BlankLine")),p=e("./Collection"),d=n(e("./Comment")),m=n(e("./Directive")),v=n(e("./Node")),b=n(e("./Range")),y=function(e){function t(){var e;return(0,a.default)(this,t),(e=(0,i.default)(this,(0,s.default)(t).call(this,f.Type.DOCUMENT))).directives=null,e.contents=null,e.directivesEndMarker=null,e.documentEndMarker=null,e}return(0,u.default)(t,e),(0,l.default)(t,null,[{key:"startCommentOrEndBlankLine",value:function(e,t){var r=v.default.endOfWhiteSpace(e,t),n=e[r];return"#"===n||"\n"===n?r:t}}]),(0,l.default)(t,[{key:"parseDirectives",value:function(e){var r=this.context.src;this.directives=[];for(var n=!0,a=!1,i=e;!v.default.atDocumentBoundary(r,i,f.Char.DIRECTIVES_END);)switch(r[i=t.startCommentOrEndBlankLine(r,i)]){case"\n":if(n){var s=new h.default;(i=s.parse({src:r},i))0&&(this.contents=this.directives,this.directives=[]),i}return r[i]?(this.directivesEndMarker=new b.default(i,i+3),i+3):(a?this.error=new c.YAMLSemanticError(this,"Missing directives-end indicator line"):this.directives.length>0&&(this.contents=this.directives,this.directives=[]),i)}},{key:"parseContents",value:function(e){var r=this.context,n=r.parseNode,a=r.src;this.contents||(this.contents=[]);for(var i=e;"-"===a[i-1];)i-=1;var s=v.default.endOfWhiteSpace(a,e),o=i===e;for(this.valueRange=new b.default(s);!v.default.atDocumentBoundary(a,s,f.Char.DOCUMENT_END);){switch(a[s]){case"\n":if(o){var l=new h.default;(s=l.parse({src:a},s))0&&((t.length>0||e[0].type===f.Type.COMMENT)&&(n+="---\n"),n+=e.join("")),"\n"!==n[n.length-1]&&(n+="\n"),n}}]),t}(v.default);r.default=y},{"../constants":7,"../errors":25,"./BlankLine":9,"./Collection":11,"./Comment":13,"./Directive":14,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],16:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/get")),u=n(e("@babel/runtime/helpers/inherits")),f=e("../constants"),c=e("../errors"),h=n(e("./BlankLine")),p=n(e("./Comment")),d=n(e("./Node")),m=n(e("./Range")),v=function(e){function t(e,r){var n;return(0,a.default)(this,t),(n=(0,s.default)(this,(0,o.default)(t).call(this,e,r))).items=null,n}return(0,u.default)(t,e),(0,i.default)(t,[{key:"prevNodeIsJsonLike",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.items.length,t=this.items[e-1];return!!t&&(t.jsonLike||t.type===f.Type.COMMENT&&this.nodeIsJsonLike(e-1))}},{key:"parse",value:function(e,t){this.context=e;var r=e.parseNode,n=e.src,a=e.indent,i=e.lineStart,s=n[t];this.items=[{char:s,offset:t}];var o=d.default.endOfWhiteSpace(n,t+1);for(s=n[o];s&&"]"!==s&&"}"!==s;){switch(s){case"\n":if(i=o+1,"\n"===n[d.default.endOfWhiteSpace(n,i)]){var l=new h.default;i=l.parse({src:n},i),this.items.push(l)}if((o=d.default.endOfIndent(n,i))<=i+a&&(s=n[o],ot.offset);)++n;t.origOffset=t.offset+n,r=n}})),r}},{key:"toString",value:function(){var e=this.context.src,t=this.items,r=this.range,n=this.value;if(null!=n)return n;var a=t.filter((function(e){return e instanceof d.default})),i="",s=r.start;return a.forEach((function(t){var r=e.slice(s,t.range.start);s=t.range.end,"\n"===(i+=r+String(t))[i.length-1]&&"\n"!==e[s-1]&&"\n"===e[s]&&(s+=1)})),i+=e.slice(s,r.end),d.default.addStringTerminator(e,r.end,i)}}]),t}(d.default);r.default=v},{"../constants":7,"../errors":25,"./BlankLine":9,"./Comment":13,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],17:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/slicedToArray")),i=n(e("@babel/runtime/helpers/classCallCheck")),s=n(e("@babel/runtime/helpers/createClass")),o=e("../constants"),l=e("./source-utils"),u=n(e("./Range")),f=function(){function e(t,r,n){(0,i.default)(this,e),Object.defineProperty(this,"context",{value:n||null,writable:!0}),this.error=null,this.range=null,this.valueRange=null,this.props=r||[],this.type=t,this.value=null}return(0,s.default)(e,null,[{key:"addStringTerminator",value:function(t,r,n){if("\n"===n[n.length-1])return n;var a=e.endOfWhiteSpace(t,r);return a>=t.length||"\n"===t[a]?n+"\n":n}},{key:"atDocumentBoundary",value:function(e,t,r){var n=e[t];if(!n)return!0;var a=e[t-1];if(a&&"\n"!==a)return!1;if(r){if(n!==r)return!1}else if(n!==o.Char.DIRECTIVES_END&&n!==o.Char.DOCUMENT_END)return!1;var i=e[t+1],s=e[t+2];if(i!==n||s!==n)return!1;var l=e[t+3];return!l||"\n"===l||"\t"===l||" "===l}},{key:"endOfIdentifier",value:function(e,t){for(var r=e[t],n="<"===r,a=n?["\n","\t"," ",">"]:["\n","\t"," ","[","]","{","}",","];r&&-1===a.indexOf(r);)r=e[t+=1];return n&&">"===r&&(t+=1),t}},{key:"endOfIndent",value:function(e,t){for(var r=e[t];" "===r;)r=e[t+=1];return t}},{key:"endOfLine",value:function(e,t){for(var r=e[t];r&&"\n"!==r;)r=e[t+=1];return t}},{key:"endOfWhiteSpace",value:function(e,t){for(var r=e[t];"\t"===r||" "===r;)r=e[t+=1];return t}},{key:"startOfLine",value:function(e,t){var r=e[t-1];if("\n"===r)return t;for(;r&&"\n"!==r;)r=e[t-=1];return t+1}},{key:"endOfBlockIndent",value:function(t,r,n){var a=e.endOfIndent(t,n);if(a>n+r)return a;var i=e.endOfWhiteSpace(t,a),s=t[i];return s&&"\n"!==s?null:i}},{key:"atBlank",value:function(e,t,r){var n=e[t];return"\n"===n||"\t"===n||" "===n||r&&!n}},{key:"atCollectionItem",value:function(t,r){var n=t[r];return("?"===n||":"===n||"-"===n)&&e.atBlank(t,r+1,!0)}},{key:"nextNodeIsIndented",value:function(e,t,r){return!(!e||t<0)&&(t>0||r&&"-"===e)}},{key:"normalizeOffset",value:function(t,r){var n=t[r];return n?"\n"!==n&&"\n"===t[r-1]?r-1:e.endOfWhiteSpace(t,r):r}},{key:"foldNewline",value:function(t,r,n){for(var a=0,i=!1,s="",o=t[r+1];" "===o||"\t"===o||"\n"===o;){switch(o){case"\n":a=0,r+=1,s+="\n";break;case"\t":a<=n&&(i=!0),r=e.endOfWhiteSpace(t,r+2)-1;break;case" ":a+=1,r+=1}o=t[r+1]}return s||(s=" "),o&&a<=n&&(i=!0),{fold:s,offset:r,error:i}}}]),(0,s.default)(e,[{key:"getPropValue",value:function(e,t,r){if(!this.context)return null;var n=this.context.src,a=this.props[e];return a&&n[a.start]===t?n.slice(a.start+(r?1:0),a.end):null}},{key:"commentHasRequiredWhitespace",value:function(t){var r=this.context.src;if(this.header&&t===this.header.end)return!1;if(!this.valueRange)return!1;var n=this.valueRange.end;return t!==n||e.atBlank(r,n-1)}},{key:"parseComment",value:function(t){var r=this.context.src;if(r[t]===o.Char.COMMENT){var n=e.endOfLine(r,t+1),a=new u.default(t,n);return this.props.push(a),n}return t}},{key:"setOrigRanges",value:function(e,t){return this.range&&(t=this.range.setOrigRange(e,t)),this.valueRange&&this.valueRange.setOrigRange(e,t),this.props.forEach((function(r){return r.setOrigRange(e,t)})),t}},{key:"toString",value:function(){var t=this.context.src,r=this.range,n=this.value;if(null!=n)return n;var a=t.slice(r.start,r.end);return e.addStringTerminator(t,r.end,a)}},{key:"anchor",get:function(){for(var e=0;e0?e.join("\n"):null}},{key:"hasComment",get:function(){if(this.context)for(var e=this.context.src,t=0;t0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.atLineStart,g=n.inCollection,w=n.inFlow,O=n.indent,C=n.lineStart,E=n.parent;(0,a.default)(this,e),(0,s.default)(this,"parseNode",(function(r,n){if(d.default.atDocumentBoundary(t.src,n))return null;var a,i=new e(t,r),s=i.parseProps(n),g=s.props,w=s.type,O=s.valueStart;switch(w){case o.Type.ALIAS:a=new u.default(w,g);break;case o.Type.BLOCK_FOLDED:case o.Type.BLOCK_LITERAL:a=new f.default(w,g);break;case o.Type.FLOW_MAP:case o.Type.FLOW_SEQ:a=new p.default(w,g);break;case o.Type.MAP_KEY:case o.Type.MAP_VALUE:case o.Type.SEQ_ITEM:a=new h.default(w,g);break;case o.Type.COMMENT:case o.Type.PLAIN:a=new m.default(w,g);break;case o.Type.QUOTE_DOUBLE:a=new v.default(w,g);break;case o.Type.QUOTE_SINGLE:a=new b.default(w,g);break;default:return a.error=new l.YAMLSyntaxError(a,"Unknown node type: ".concat(JSON.stringify(w))),a.range=new y.default(n,n+1),a}var C=a.parse(i,O);if(a.range=new y.default(n,C),C<=n&&(a.error=new Error("Node#parse consumed no characters"),a.error.parseEnd=C,a.error.source=a,a.range.end=n+1),i.nodeStartsCollection(a)){a.error||i.atLineStart||i.parent.type!==o.Type.DOCUMENT||(a.error=new l.YAMLSyntaxError(a,"Block collection must not have preceding content here (e.g. directives-end indicator)"));var E=new c.default(a);return C=E.parse(new e(i),C),E.range=new y.default(n,C),E}return a})),this.atLineStart=null!=i?i:r.atLineStart||!1,this.inCollection=null!=g?g:r.inCollection||!1,this.inFlow=null!=w?w:r.inFlow||!1,this.indent=null!=O?O:r.indent,this.lineStart=null!=C?C:r.lineStart,this.parent=null!=E?E:r.parent||{},this.root=r.root,this.src=r.src}return(0,i.default)(e,null,[{key:"parseType",value:function(e,t,r){switch(e[t]){case"*":return o.Type.ALIAS;case">":return o.Type.BLOCK_FOLDED;case"|":return o.Type.BLOCK_LITERAL;case"{":return o.Type.FLOW_MAP;case"[":return o.Type.FLOW_SEQ;case"?":return!r&&d.default.atBlank(e,t+1,!0)?o.Type.MAP_KEY:o.Type.PLAIN;case":":return!r&&d.default.atBlank(e,t+1,!0)?o.Type.MAP_VALUE:o.Type.PLAIN;case"-":return!r&&d.default.atBlank(e,t+1,!0)?o.Type.SEQ_ITEM:o.Type.PLAIN;case'"':return o.Type.QUOTE_DOUBLE;case"'":return o.Type.QUOTE_SINGLE;default:return o.Type.PLAIN}}}]),(0,i.default)(e,[{key:"nodeStartsCollection",value:function(e){var t=this.inCollection,r=this.inFlow,n=this.src;if(t||r)return!1;if(e instanceof h.default)return!0;var a=e.range.end;return"\n"!==n[a]&&"\n"!==n[a-1]&&":"===n[a=d.default.endOfWhiteSpace(n,a)]}},{key:"parseProps",value:function(t){for(var r=this.inFlow,n=this.parent,a=this.src,i=[],s=!1,l=a[t=d.default.endOfWhiteSpace(a,t)];l===o.Char.ANCHOR||l===o.Char.COMMENT||l===o.Char.TAG||"\n"===l;){if("\n"===l){var u=t+1,f=d.default.endOfIndent(a,u),c=f-(u+this.indent),h=n.type===o.Type.SEQ_ITEM&&n.context.atLineStart;if(!d.default.nextNodeIsIndented(a[f],c,!h))break;this.atLineStart=!0,this.lineStart=u,s=!1,t=f}else if(l===o.Char.COMMENT){var p=d.default.endOfLine(a,t+1);i.push(new y.default(t,p)),t=p}else{var m=d.default.endOfIdentifier(a,t+1);l===o.Char.TAG&&","===a[m]&&/^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(a.slice(t+1,m+13))&&(m=d.default.endOfIdentifier(a,m+5)),i.push(new y.default(t,m)),s=!0,t=d.default.endOfWhiteSpace(a,m)}l=a[t]}return s&&":"===l&&d.default.atBlank(a,t+1,!0)&&(t-=1),{props:i,type:e.parseType(a,t,r),valueStart:t}}},{key:"pretty",get:function(){var e={start:"".concat(this.lineStart," + ").concat(this.indent),in:[],parent:this.parent.type};return this.atLineStart||(e.start+=" + N"),this.inCollection&&e.in.push("collection"),this.inFlow&&e.in.push("flow"),e}}]),e}();r.default=g},{"../constants":7,"../errors":25,"./Alias":8,"./BlockValue":10,"./Collection":11,"./CollectionItem":12,"./FlowCollection":16,"./Node":17,"./PlainValue":19,"./QuoteDouble":20,"./QuoteSingle":21,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/interopRequireDefault":68}],19:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("./Node")),f=n(e("./Range")),c=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parseBlockValue",value:function(e){for(var r=this.context,n=r.indent,a=r.inFlow,i=r.src,s=e,o=e,l=i[s];"\n"===l&&!u.default.atDocumentBoundary(i,s+1);l=i[s]){var f=u.default.endOfBlockIndent(i,n,s+1);if(null===f||"#"===i[f])break;s="\n"===i[f]?f:o=t.endOfLine(i,f,a)}return this.valueRange.isEmpty()&&(this.valueRange.start=e),this.valueRange.end=o,o}},{key:"parse",value:function(e,r){this.context=e;var n=e.inFlow,a=e.src,i=r,s=a[i];return s&&"#"!==s&&"\n"!==s&&(i=t.endOfLine(a,r,n)),this.valueRange=new f.default(r,i),i=u.default.endOfWhiteSpace(a,i),i=this.parseComment(i),this.hasComment&&!this.valueRange.isEmpty()||(i=this.parseBlockValue(i)),i}},{key:"strValue",get:function(){if(!this.valueRange||!this.context)return null;for(var e=this.valueRange,t=e.start,r=e.end,n=this.context.src,a=n[r-1];tf?n.slice(f,s+1):o)}else i+=o}return i}}],[{key:"endOfLine",value:function(e,t,r){for(var n=e[t],a=t;n&&"\n"!==n&&(!r||"["!==n&&"]"!==n&&"{"!==n&&"}"!==n&&","!==n);){var i=e[a+1];if(":"===n&&(!i||"\n"===i||"\t"===i||" "===i||r&&","===i))break;if((" "===n||"\t"===n)&&"#"===i)break;a+=1,n=i}return a}}]),t}(u.default);r.default=c},{"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],20:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=e("../errors"),f=n(e("./Node")),c=n(e("./Range")),h=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parseCharCode",value:function(e,t,r){var n=this.context.src,a=n.substr(e,t),i=a.length===t&&/^[0-9a-fA-F]+$/.test(a)?parseInt(a,16):NaN;return isNaN(i)?(r.push(new u.YAMLSyntaxError(this,"Invalid escape sequence ".concat(n.substr(e-2,t+2)))),n.substr(e-2,t+2)):String.fromCodePoint(i)}},{key:"parse",value:function(e,r){this.context=e;var n=e.src,a=t.endOfQuote(n,r+1);return this.valueRange=new c.default(r,a),a=f.default.endOfWhiteSpace(n,a),a=this.parseComment(a)}},{key:"strValue",get:function(){if(!this.valueRange||!this.context)return null;var e=[],t=this.valueRange,r=t.start,n=t.end,a=this.context,i=a.indent,s=a.src;'"'!==s[n-1]&&e.push(new u.YAMLSyntaxError(this,'Missing closing "quote'));for(var o="",l=r+1;lp?s.slice(p,l+1):c)}else o+=c}return e.length>0?{errors:e,str:o}:o}}],[{key:"endOfQuote",value:function(e,t){for(var r=e[t];r&&'"'!==r;)r=e[t+="\\"===r?2:1];return t+1}}]),t}(f.default);r.default=h},{"../errors":25,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],21:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=e("../errors"),f=n(e("./Node")),c=n(e("./Range")),h=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,l.default)(t,e),(0,i.default)(t,[{key:"parse",value:function(e,r){this.context=e;var n=e.src,a=t.endOfQuote(n,r+1);return this.valueRange=new c.default(r,a),a=f.default.endOfWhiteSpace(n,a),a=this.parseComment(a)}},{key:"strValue",get:function(){if(!this.valueRange||!this.context)return null;var e=[],t=this.valueRange,r=t.start,n=t.end,a=this.context,i=a.indent,s=a.src;"'"!==s[n-1]&&e.push(new u.YAMLSyntaxError(this,"Missing closing 'quote"));for(var o="",l=r+1;lp?s.slice(p,l+1):c)}else o+=c}return e.length>0?{errors:e,str:o}:o}}],[{key:"endOfQuote",value:function(e,t){for(var r=e[t];r;)if("'"===r){if("'"!==e[t+1])break;r=e[t+=2]}else r=e[t+=1];return t+1}}]),t}(f.default);r.default=h},{"../errors":25,"./Node":17,"./Range":22,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],22:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=function(){function e(t,r){(0,a.default)(this,e),this.start=t,this.end=r||t}return(0,i.default)(e,null,[{key:"copy",value:function(t){return new e(t.start,t.end)}}]),(0,i.default)(e,[{key:"isEmpty",value:function(){return"number"!=typeof this.start||!this.end||this.end<=this.start}},{key:"setOrigRange",value:function(e,t){var r=this.start,n=this.end;if(0===e.length||n<=e[0])return this.origStart=r,this.origEnd=n,t;for(var a=t;ar);)++a;this.origStart=r+a;for(var i=a;a=n);)++a;return this.origEnd=n+a,i}}]),e}();r.default=s},{"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/interopRequireDefault":68}],23:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){var t=[];-1!==e.indexOf("\r")&&(e=e.replace(/\r\n?/g,(function(e,r){return e.length>1&&t.push(r),"\n"})));var r=[],n=0;do{var s=new a.default,o=new i.default({src:e});n=s.parse(o,n),r.push(s)}while(n=1)||e>n.length)return null;for(var s=n[e-1],o=n[e];o&&o>s&&"\n"===i[o-1];)--o;return i.slice(s,o)}Object.defineProperty(r,"__esModule",{value:!0}),r.getLinePos=function(e,t){if("number"!=typeof e||e<0)return null;var r=a(t),n=r.lineStarts,i=r.src;if(!n||!i||e>i.length)return null;for(var s=0;s2&&void 0!==arguments[2]?arguments[2]:80,s=i(r.line,t);if(!s)return null;var o=r.col;if(s.length>a)if(o<=a-10)s=s.substr(0,a-1)+"…";else{var l=Math.round(a/2);s.length>o+l&&(s=s.substr(0,o+l-1)+"…"),o-=s.length-a,s="…"+s.substr(1-a)}var u=1,f="";n&&(n.line===r.line&&o+(n.col-r.col)<=a+1?u=n.col-r.col:(u=Math.min(s.length+1,a)-o,f="…"));var c=o>1?" ".repeat(o-1):"",h="^".repeat(u);return"".concat(s,"\n").concat(c).concat(h).concat(f)}},{}],25:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.YAMLWarning=r.YAMLSyntaxError=r.YAMLSemanticError=r.YAMLReferenceError=r.YAMLError=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("@babel/runtime/helpers/wrapNativeSuper")),f=n(e("./cst/Node")),c=e("./cst/source-utils"),h=n(e("./cst/Range")),p=function(e){function t(e,r,n){var i;if((0,a.default)(this,t),!(n&&r instanceof f.default))throw new Error("Invalid arguments for new ".concat(e));return(i=(0,s.default)(this,(0,o.default)(t).call(this))).name=e,i.message=n,i.source=r,i}return(0,l.default)(t,e),(0,i.default)(t,[{key:"makePretty",value:function(){if(this.source){this.nodeType=this.source.type;var e=this.source.context&&this.source.context.root;if("number"==typeof this.offset){this.range=new h.default(this.offset,this.offset+1);var t=e&&(0,c.getLinePos)(this.offset,e);if(t){var r={line:t.line,col:t.col+1};this.linePos={start:t,end:r}}delete this.offset}else this.range=this.source.range,this.linePos=this.source.rangeAsLinePos;if(this.linePos){var n=this.linePos.start,a=n.line,i=n.col;this.message+=" at line ".concat(a,", column ").concat(i);var s=e&&(0,c.getPrettyContext)(this.linePos,e);s&&(this.message+=":\n\n".concat(s,"\n"))}delete this.source}}}]),t}((0,u.default)(Error));r.YAMLError=p;var d=function(e){function t(e,r){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,"YAMLReferenceError",e,r))}return(0,l.default)(t,e),t}(p);r.YAMLReferenceError=d;var m=function(e){function t(e,r){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,"YAMLSemanticError",e,r))}return(0,l.default)(t,e),t}(p);r.YAMLSemanticError=m;var v=function(e){function t(e,r){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,"YAMLSyntaxError",e,r))}return(0,l.default)(t,e),t}(p);r.YAMLSyntaxError=v;var b=function(e){function t(e,r){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).call(this,"YAMLWarning",e,r))}return(0,l.default)(t,e),t}(p);r.YAMLWarning=b},{"./cst/Node":17,"./cst/Range":22,"./cst/source-utils":24,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74,"@babel/runtime/helpers/wrapNativeSuper":80}],26:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t,r,s){var o=s.indentAtStart,l=s.lineWidth,u=void 0===l?80:l,f=s.minContentWidth,c=void 0===f?20:f,h=s.onFold,p=s.onOverflow;if(!u||u<0)return e;var d=Math.max(1+c,1+u-t.length);if(e.length<=d)return e;var m,v=[],b={},y=u-("number"==typeof o?o:t.length),g=void 0,w=void 0,O=!1,C=-1;r===n&&-1!==(C=i(e,C))&&(y=C+d);for(;m=e[C+=1];){if(r===a&&"\\"===m)switch(e[C+1]){case"x":C+=3;break;case"u":C+=5;break;case"U":C+=9;break;default:C+=1}if("\n"===m)r===n&&(C=i(e,C)),y=C+d,g=void 0;else{if(" "===m&&w&&" "!==w&&"\n"!==w&&"\t"!==w){var E=e[C+1];E&&" "!==E&&"\n"!==E&&"\t"!==E&&(g=C)}if(C>=y)if(g)v.push(g),y=g+d,g=void 0;else if(r===a){for(;" "===w||"\t"===w;)w=m,m=e[C+=1],O=!0;v.push(C-2),b[C-2]=!0,y=C-2+d,g=void 0}else O=!0}w=m}O&&p&&p();if(0===v.length)return e;h&&h();for(var k=e.slice(0,v[0]),S=0;S1){n.errors.unshift(new f.YAMLSemanticError(r[1],"Source contains multiple documents; please use YAML.parseAllDocuments()"))}return n}var v={createNode:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0;void 0===r&&"string"==typeof t&&(r=t,t=!0);var n=Object.assign({},u.default.defaults[p.version],p);return new c.default(n).createNode(e,t,r)},defaultOptions:p,Document:d,parse:function(e,t){var r=m(e,t);if(r.warnings.forEach((function(e){return(0,h.warn)(e)})),r.errors.length>0)throw r.errors[0];return r.toJSON()},parseAllDocuments:function(e,t){var r,n=[],a=!0,i=!1,s=void 0;try{for(var o,u=(0,l.default)(e)[Symbol.iterator]();!(a=(o=u.next()).done);a=!0){var f=o.value,c=new d(t);c.parse(f,r),n.push(c),r=c}}catch(e){i=!0,s=e}finally{try{a||null==u.return||u.return()}finally{if(i)throw s}}return n},parseCST:l.default,parseDocument:m,stringify:function(e,t){var r=new d(t);return r.contents=e,String(r)}};r.default=v},{"./Document":5,"./cst/parse":23,"./errors":25,"./schema":37,"./warnings":57,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],28:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/typeof")),i=n(e("./schema/Collection")),s=n(e("./schema/Pair")),o=n(e("./schema/Scalar"));r.default=function(e){return Object.keys(function e(t,r){if(t&&"object"===(0,a.default)(t)){var n=t.tag;t instanceof i.default?(n&&(r[n]=!0),t.items.forEach((function(t){return e(t,r)}))):t instanceof s.default?(e(t.key,r),e(t.value,r)):t instanceof o.default&&n&&(r[n]=!0)}return r}(e,{}))}},{"./schema/Collection":30,"./schema/Pair":34,"./schema/Scalar":35,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/typeof":79}],29:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/possibleConstructorReturn")),s=n(e("@babel/runtime/helpers/getPrototypeOf")),o=n(e("@babel/runtime/helpers/createClass")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("@babel/runtime/helpers/defineProperty")),f=e("../constants"),c=e("../errors"),h=n(e("../toJSON")),p=n(e("./Collection")),d=n(e("./Node")),m=n(e("./Pair")),v=function e(t,r){if(t instanceof b){var n=r.find((function(e){return e.node===t.source}));return n.count*n.aliasCount}if(t instanceof p.default){var a=0,i=!0,s=!1,o=void 0;try{for(var l,u=t.items[Symbol.iterator]();!(i=(l=u.next()).done);i=!0){var f=e(l.value,r);f>a&&(a=f)}}catch(e){s=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(s)throw o}}return a}if(t instanceof m.default){var c=e(t.key,r),h=e(t.value,r);return Math.max(c,h)}return 1},b=function(e){function t(e){var r;return(0,a.default)(this,t),(r=(0,i.default)(this,(0,s.default)(t).call(this))).source=e,r.type=f.Type.ALIAS,r}return(0,l.default)(t,e),(0,o.default)(t,null,[{key:"stringify",value:function(e,t){var r=e.range,n=e.source,a=t.anchors,i=t.doc,s=t.implicitKey,o=t.inStringifyKey,l=Object.keys(a).find((function(e){return a[e]===n}));if(!l&&o&&(l=i.anchors.getName(n)||i.anchors.newName()),l)return"*".concat(l).concat(s?" ":"");var u=i.anchors.getName(n)?"Alias node must be after source node":"Source node not found for alias node";throw new Error("".concat(u," [").concat(r,"]"))}}]),(0,o.default)(t,[{key:"toJSON",value:function(e,t){var r=this;if(!t)return(0,h.default)(this.source,e,t);var n=t.anchors,a=t.maxAliasCount,i=n.find((function(e){return e.node===r.source}));if(!i||void 0===i.res){var s="This should not happen: Alias anchor was not resolved?";throw this.cstNode?new c.YAMLReferenceError(this.cstNode,s):new ReferenceError(s)}if(a>=0&&(i.count+=1,0===i.aliasCount&&(i.aliasCount=v(this.source,n)),i.count*i.aliasCount>a)){var o="Excessive alias count indicates a resource exhaustion attack";throw this.cstNode?new c.YAMLReferenceError(this.cstNode,o):new ReferenceError(o)}return i.res}},{key:"toString",value:function(e){return t.stringify(this,e)}},{key:"tag",set:function(e){throw new Error("Alias nodes cannot have tags")}}]),t}(d.default);r.default=b,(0,u.default)(b,"default",!0)},{"../constants":7,"../errors":25,"../toJSON":56,"./Collection":30,"./Node":33,"./Pair":34,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],30:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.isEmptyPath=void 0;var a=n(e("@babel/runtime/helpers/toArray")),i=n(e("@babel/runtime/helpers/classCallCheck")),s=n(e("@babel/runtime/helpers/createClass")),o=n(e("@babel/runtime/helpers/possibleConstructorReturn")),l=n(e("@babel/runtime/helpers/getPrototypeOf")),u=n(e("@babel/runtime/helpers/assertThisInitialized")),f=n(e("@babel/runtime/helpers/inherits")),c=n(e("@babel/runtime/helpers/defineProperty")),h=n(e("@babel/runtime/helpers/typeof")),p=n(e("../addComment")),d=n(e("./Node")),m=n(e("./Pair")),v=n(e("./Scalar")),b=function(e){return null==e||"object"===(0,h.default)(e)&&e[Symbol.iterator]().next().done};r.isEmptyPath=b;var y=function(e){function t(){var e,r;(0,i.default)(this,t);for(var n=arguments.length,a=new Array(n),s=0;st.maxFlowStringSingleLineLength){v=w;var E=!0,k=!1,S=void 0;try{for(var A,M=C[Symbol.iterator]();!(E=(A=M.next()).done);E=!0){var L=A.value;v+=L?"\n ".concat(h).concat(L):"\n"}}catch(e){k=!0,S=e}finally{try{E||null==M.return||M.return()}finally{if(k)throw S}}v+="\n".concat(h).concat(O)}else v="".concat(w," ").concat(C.join(" ")," ").concat(O)}else{var T=g.map(s);v=T.shift();var R=!0,N=!1,P=void 0;try{for(var x,_=T[Symbol.iterator]();!(R=(x=_.next()).done);R=!0){var I=x.value;v+=I?"\n".concat(h).concat(I):"\n"}}catch(e){N=!0,P=e}finally{try{R||null==_.return||_.return()}finally{if(N)throw P}}}return this.comment?(v+="\n"+this.comment.replace(/^/gm,"".concat(h,"#")),n&&n()):b&&a&&a(),v}}]),t}(d.default);r.default=y,(0,c.default)(y,"maxFlowStringSingleLineLength",60)},{"../addComment":6,"./Node":33,"./Pair":34,"./Scalar":35,"@babel/runtime/helpers/assertThisInitialized":60,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74,"@babel/runtime/helpers/toArray":78,"@babel/runtime/helpers/typeof":79}],31:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.findPair=p,r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/get")),u=n(e("@babel/runtime/helpers/inherits")),f=n(e("./Collection")),c=n(e("./Pair")),h=n(e("./Scalar"));function p(e,t){var r=t instanceof h.default?t.value:t,n=!0,a=!1,i=void 0;try{for(var s,o=e[Symbol.iterator]();!(n=(s=o.next()).done);n=!0){var l=s.value;if(l instanceof c.default){if(l.key===t||l.key===r)return l;if(l.key&&l.key.value===r)return l}}}catch(e){a=!0,i=e}finally{try{n||null==o.return||o.return()}finally{if(a)throw i}}}var d=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,u.default)(t,e),(0,i.default)(t,[{key:"add",value:function(e){if(e?e instanceof c.default||(e=new c.default(e.key||e,e.value)):e=new c.default(e),p(this.items,e.key))throw new Error("Key ".concat(e.key," already set"));this.items.push(e)}},{key:"delete",value:function(e){var t=p(this.items,e);return!!t&&this.items.splice(this.items.indexOf(t),1).length>0}},{key:"get",value:function(e,t){var r=p(this.items,e),n=r&&r.value;return!t&&n instanceof h.default?n.value:n}},{key:"has",value:function(e){return!!p(this.items,e)}},{key:"set",value:function(e,t){var r=p(this.items,e);r?r.value=t:this.items.push(new c.default(e,t))}},{key:"toJSON",value:function(e,t,r){var n=r?new r:t&&t.mapAsMap?new Map:{};t&&t.onCreate&&t.onCreate(n);var a=!0,i=!1,s=void 0;try{for(var o,l=this.items[Symbol.iterator]();!(a=(o=l.next()).done);a=!0){o.value.addToJSMap(t,n)}}catch(e){i=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw s}}return n}},{key:"toString",value:function(e,r,n){if(!e)return JSON.stringify(this);var a=!0,i=!1,s=void 0;try{for(var u,f=this.items[Symbol.iterator]();!(a=(u=f.next()).done);a=!0){var h=u.value;if(!(h instanceof c.default))throw new Error("Map items must all be pairs; found ".concat(JSON.stringify(h)," instead"))}}catch(e){i=!0,s=e}finally{try{a||null==f.return||f.return()}finally{if(i)throw s}}return(0,l.default)((0,o.default)(t.prototype),"toString",this).call(this,e,{blockItem:function(e){return e.str},flowChars:{start:"{",end:"}"},isMap:!0,itemIndent:e.indent||""},r,n)}}]),t}(f.default);r.default=d},{"./Collection":30,"./Pair":34,"./Scalar":35,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],32:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.MERGE_KEY=void 0;var a=n(e("@babel/runtime/helpers/slicedToArray")),i=n(e("@babel/runtime/helpers/classCallCheck")),s=n(e("@babel/runtime/helpers/createClass")),o=n(e("@babel/runtime/helpers/possibleConstructorReturn")),l=n(e("@babel/runtime/helpers/getPrototypeOf")),u=n(e("@babel/runtime/helpers/get")),f=n(e("@babel/runtime/helpers/inherits")),c=n(e("./Map")),h=n(e("./Pair")),p=n(e("./Scalar")),d=n(e("./Seq")),m="<<";r.MERGE_KEY=m;var v=function(e){function t(e){var r;if((0,i.default)(this,t),e instanceof h.default){var n=e.value;n instanceof d.default||((n=new d.default).items.push(e.value),n.range=e.value.range),(r=(0,o.default)(this,(0,l.default)(t).call(this,e.key,n))).range=e.range}else r=(0,o.default)(this,(0,l.default)(t).call(this,new p.default(m),new d.default));return r.type="MERGE_PAIR",(0,o.default)(r)}return(0,f.default)(t,e),(0,s.default)(t,[{key:"addToJSMap",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var s,o=this.value.items[Symbol.iterator]();!(r=(s=o.next()).done);r=!0){var l=s.value.source;if(!(l instanceof c.default))throw new Error("Merge sources must be maps");var u=l.toJSON(null,e,Map),f=!0,h=!1,p=void 0;try{for(var d,m=u[Symbol.iterator]();!(f=(d=m.next()).done);f=!0){var v=(0,a.default)(d.value,2),b=v[0],y=v[1];t instanceof Map?t.has(b)||t.set(b,y):t instanceof Set?t.add(b):Object.prototype.hasOwnProperty.call(t,b)||(t[b]=y)}}catch(e){h=!0,p=e}finally{try{f||null==m.return||m.return()}finally{if(h)throw p}}}}catch(e){n=!0,i=e}finally{try{r||null==o.return||o.return()}finally{if(n)throw i}}return t}},{key:"toString",value:function(e,r){var n=this.value;if(n.items.length>1)return(0,u.default)((0,l.default)(t.prototype),"toString",this).call(this,e,r);this.value=n.items[0];var a=(0,u.default)((0,l.default)(t.prototype),"toString",this).call(this,e,r);return this.value=n,a}}]),t}(h.default);r.default=v},{"./Map":31,"./Pair":34,"./Scalar":35,"./Seq":36,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74,"@babel/runtime/helpers/slicedToArray":76}],33:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck"));r.default=function e(){(0,a.default)(this,e)}},{"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/interopRequireDefault":68}],34:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("@babel/runtime/helpers/typeof")),f=n(e("../addComment")),c=e("../constants"),h=n(e("../toJSON")),p=n(e("./Collection")),d=n(e("./Node")),m=n(e("./Scalar")),v=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,a.default)(this,t),(r=(0,s.default)(this,(0,o.default)(t).call(this))).key=e,r.value=n,r.type="PAIR",r}return(0,l.default)(t,e),(0,i.default)(t,[{key:"addToJSMap",value:function(e,t){var r=(0,h.default)(this.key,"",e);if(t instanceof Map){var n=(0,h.default)(this.value,r,e);t.set(r,n)}else if(t instanceof Set)t.add(r);else{var a=function(e,t,r){return null===t?"":"object"!==(0,u.default)(t)?String(t):e instanceof d.default&&r&&r.doc?e.toString({anchors:{},doc:r.doc,indent:"",inFlow:!0,inStringifyKey:!0}):JSON.stringify(t)}(this.key,r,e);t[a]=(0,h.default)(this.value,a,e)}return t}},{key:"toJSON",value:function(e,t){var r=t&&t.mapAsMap?new Map:{};return this.addToJSMap(t,r)}},{key:"toString",value:function(e,t,r){if(!e||!e.doc)return JSON.stringify(this);var n=e.doc.options.simpleKeys,a=this.key,i=this.value,s=a instanceof d.default&&a.comment;if(n){if(s)throw new Error("With simple keys, key nodes cannot have comments");if(a instanceof p.default){throw new Error("With simple keys, collection cannot be used as a key value")}}var o=!n&&(!a||s||a instanceof p.default||a.type===c.Type.BLOCK_FOLDED||a.type===c.Type.BLOCK_LITERAL),l=e,h=l.doc,m=l.indent;e=Object.assign({},e,{implicitKey:!o,indent:m+" "});var v=!1,b=h.schema.stringify(a,e,(function(){return s=null}),(function(){return v=!0}));if(b=(0,f.default)(b,e.indent,s),e.allNullValues&&!n)return this.comment?(b=(0,f.default)(b,e.indent,this.comment),t&&t()):v&&!s&&r&&r(),e.inFlow?b:"? ".concat(b);b=o?"? ".concat(b,"\n").concat(m,":"):"".concat(b,":"),this.comment&&(b=(0,f.default)(b,e.indent,this.comment),t&&t());var y="",g=null;if(i instanceof d.default){if(i.spaceBefore&&(y="\n"),i.commentBefore){var w=i.commentBefore.replace(/^/gm,"".concat(e.indent,"#"));y+="\n".concat(w)}g=i.comment}else i&&"object"===(0,u.default)(i)&&(i=h.schema.createNode(i,!0));e.implicitKey=!1,v=!1;var O=h.schema.stringify(i,e,(function(){return g=null}),(function(){return v=!0})),C=" ";if(y||this.comment)C="".concat(y,"\n").concat(e.indent);else if(!o&&i instanceof p.default){("["===O[0]||"{"===O[0])&&!O.includes("\n")||(C="\n".concat(e.indent))}return v&&!g&&r&&r(),(0,f.default)(b+C+O,e.indent,g)}},{key:"commentBefore",get:function(){return this.key&&this.key.commentBefore},set:function(e){null==this.key&&(this.key=new m.default(null)),this.key.commentBefore=e}}]),t}(d.default);r.default=v},{"../addComment":6,"../constants":7,"../toJSON":56,"./Collection":30,"./Node":33,"./Scalar":35,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74,"@babel/runtime/helpers/typeof":79}],35:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/inherits")),u=n(e("../toJSON")),f=function(e){function t(e){var r;return(0,a.default)(this,t),(r=(0,s.default)(this,(0,o.default)(t).call(this))).value=e,r}return(0,l.default)(t,e),(0,i.default)(t,[{key:"toJSON",value:function(e,t){return t&&t.keep?this.value:(0,u.default)(this.value,e,t)}},{key:"toString",value:function(){return String(this.value)}}]),t}(n(e("./Node")).default);r.default=f},{"../toJSON":56,"./Node":33,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/possibleConstructorReturn":74}],36:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/classCallCheck")),i=n(e("@babel/runtime/helpers/createClass")),s=n(e("@babel/runtime/helpers/possibleConstructorReturn")),o=n(e("@babel/runtime/helpers/getPrototypeOf")),l=n(e("@babel/runtime/helpers/get")),u=n(e("@babel/runtime/helpers/inherits")),f=n(e("../toJSON")),c=n(e("./Collection")),h=n(e("./Scalar"));function p(e){var t=e instanceof h.default?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),Number.isInteger(t)&&t>=0?t:null}var d=function(e){function t(){return(0,a.default)(this,t),(0,s.default)(this,(0,o.default)(t).apply(this,arguments))}return(0,u.default)(t,e),(0,i.default)(t,[{key:"add",value:function(e){this.items.push(e)}},{key:"delete",value:function(e){var t=p(e);return"number"==typeof t&&this.items.splice(t,1).length>0}},{key:"get",value:function(e,t){var r=p(e);if("number"==typeof r){var n=this.items[r];return!t&&n instanceof h.default?n.value:n}}},{key:"has",value:function(e){var t=p(e);return"number"==typeof t&&t0&&(t.resolved=this.resolveScalar(s,n))}}catch(r){r.source||(r.source=t),e.errors.push(r),t.resolved=null}return t.resolved?(r&&t.tag&&(t.resolved.tag=r),t.resolved):null}},{key:"resolveNodeWithFallback",value:function(t,r,n){var a=this.resolveNode(t,r,n);if(Object.prototype.hasOwnProperty.call(r,"resolved"))return a;var i,s=(i=r.type)===u.Type.FLOW_MAP||i===u.Type.MAP?e.defaultTags.MAP:function(e){var t=e.type;return t===u.Type.FLOW_SEQ||t===u.Type.SEQ}(r)?e.defaultTags.SEQ:e.defaultTags.STR;if(s){t.warnings.push(new f.YAMLWarning(r,"The tag ".concat(n," is unavailable, falling back to ").concat(s)));var o=this.resolveNode(t,r,s);return o.tag=n,o}return t.errors.push(new f.YAMLReferenceError(r,"The tag ".concat(n," is unavailable"))),null}},{key:"getTagObject",value:function(e){if(e instanceof d.default)return d.default;if(e.tag){var t=this.tags.filter((function(t){return t.tag===e.tag}));if(t.length>0)return t.find((function(t){return t.format===e.format}))||t[0]}var r,n;if(e instanceof y.default){n=e.value;var i=this.tags.filter((function(e){return e.identify&&e.identify(n)||e.class&&n instanceof e.class}));r=i.find((function(t){return t.format===e.format}))||i.find((function(e){return!e.format}))}else n=e,r=this.tags.find((function(e){return e.nodeClass&&n instanceof e.nodeClass}));if(!r){var s=n&&n.constructor?n.constructor.name:(0,a.default)(n);throw new Error("Tag not resolved for ".concat(s," value"))}return r}},{key:"stringifyProps",value:function(e,t,r){var n=r.anchors,a=r.doc,i=[],s=a.anchors.getName(e);return s&&(n[s]=e,i.push("&".concat(s))),e.tag?i.push(a.stringifyTag(e.tag)):t.default||i.push(a.stringifyTag(t.tag)),i.join(" ")}},{key:"stringify",value:function(e,t,r,n){var a;if(!(e instanceof v.default)){var i={aliasNodes:[],onTagObj:function(e){return a=e},prevObjects:[]};e=this.createNode(e,!0,null,i);var s=t.doc.anchors,o=!0,l=!1,u=void 0;try{for(var f,h=i.aliasNodes[Symbol.iterator]();!(o=(f=h.next()).done);o=!0){var p=f.value;p.source=p.source.node;var d=s.getName(p.source);d||(d=s.newName(),s.map[d]=p.source)}}catch(e){l=!0,u=e}finally{try{o||null==h.return||h.return()}finally{if(l)throw u}}}if(t.tags=this,e instanceof b.default)return e.toString(t,r,n);a||(a=this.getTagObject(e));var y=this.stringifyProps(e,a,t),g="function"==typeof a.stringify?a.stringify(e,t,r,n):e instanceof m.default?e.toString(t,r,n):(0,c.stringifyString)(e,t,r,n);return y?e instanceof m.default&&"{"!==g[0]&&"["!==g[0]?"".concat(y,"\n").concat(t.indent).concat(g):"".concat(y," ").concat(g):g}}]),e}();r.default=g,(0,o.default)(g,"defaultPrefix","tag:yaml.org,2002:"),(0,o.default)(g,"defaultTags",{MAP:"tag:yaml.org,2002:map",SEQ:"tag:yaml.org,2002:seq",STR:"tag:yaml.org,2002:str"})},{"../constants":7,"../errors":25,"../stringify":41,"../tags":47,"../tags/failsafe/string":46,"../warnings":57,"./Alias":29,"./Collection":30,"./Node":33,"./Pair":34,"./Scalar":35,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/typeof":79}],38:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireWildcard"),a=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){if(t.type!==i.Type.MAP&&t.type!==i.Type.FLOW_MAP){var r="A ".concat(t.type," node cannot be resolved as a mapping");return e.errors.push(new o.YAMLSyntaxError(t,r)),null}var n=t.type===i.Type.FLOW_MAP?function(e,t){for(var r=[],n=[],a=void 0,s=null,l=!1,u="{",h=0;h0){(p=new s.default(i.Type.PLAIN,[])).context={parent:h,src:h.context.src};var d=h.range.start+1;if(p.range={start:d,end:d},p.valueRange={start:d,end:d},"number"==typeof h.range.origStart){var v=h.range.origStart+1;p.range.origStart=p.range.origEnd=v,p.valueRange.origStart=p.valueRange.origEnd=v}}var b=new f.default(a,e.resolveNode(p));m(h,b),n.push(b),(0,c.checkKeyLength)(e.errors,t,u,a,l),a=void 0,l=null;break;default:void 0!==a&&n.push(new f.default(a)),a=e.resolveNode(h),l=h.range.start,h.error&&e.errors.push(h.error);e:for(var y=u+1;;++y){var g=t.items[y];switch(g&&g.type){case i.Type.BLANK_LINE:case i.Type.COMMENT:continue e;case i.Type.MAP_VALUE:break e;default:e.errors.push(new o.YAMLSemanticError(h,"Implicit map keys need to be followed by map values"));break e}}if(h.valueRangeContainsNewline){e.errors.push(new o.YAMLSemanticError(h,"Implicit map keys need to be on a single line"))}}}void 0!==a&&n.push(new f.default(a));return{comments:r,items:n}}(e,t),a=n.comments,d=n.items,v=new l.default;v.items=d,(0,c.resolveComments)(v,a);for(var b=!1,y=0;yn.valueRange.start)return!1;if(a[o]!==i.Char.COMMENT)return!1;for(var l=r;l=0;--o){var l=t.items[o];if(!l||l.type!==a.Type.COMMENT){s=l;break}}if(s&&s.char!==r){var u,f="Expected ".concat(i," to end with ").concat(r);"number"==typeof s.offset?(u=new n.YAMLSemanticError(t,f)).offset=s.offset+1:(u=new n.YAMLSemanticError(s,f),s.range&&s.range.end&&(u.offset=s.range.end-s.range.start)),e.push(u)}},r.checkKeyLength=function(e,t,r,a,i){if(!a||"number"!=typeof i)return;var s=t.items[r],o=s&&s.range&&s.range.start;if(!o)for(var l=r-1;l>=0;--l){var u=t.items[l];if(u&&u.range){o=u.range.end+2*(r-l);break}}if(o>i+1024){var f=String(a).substr(0,8)+"..."+String(a).substr(-8);e.push(new n.YAMLSemanticError(t,'The "'.concat(f,'" key is too long')))}},r.resolveComments=function(e,t){var r=!0,n=!1,a=void 0;try{for(var i,s=t[Symbol.iterator]();!(r=(i=s.next()).done);r=!0){var o=i.value,l=o.afterKey,u=o.before,f=o.comment,c=e.items[u];c?(l&&c.value&&(c=c.value),void 0===f?!l&&c.commentBefore||(c.spaceBefore=!0):c.commentBefore?c.commentBefore+="\n"+f:c.commentBefore=f):void 0!==f&&(e.comment?e.comment+="\n"+f:e.comment=f)}}catch(e){n=!0,a=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw a}}};var n=e("../errors"),a=e("../constants")},{"../constants":7,"../errors":25}],41:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireWildcard");Object.defineProperty(r,"__esModule",{value:!0}),r.stringifyNumber=function(e){var t=e.format,r=e.minFractionDigits,n=e.tag,a=e.value;if(!isFinite(a))return isNaN(a)?".nan":a<0?"-.inf":".inf";var i=JSON.stringify(a);if(!t&&r&&(!n||"tag:yaml.org,2002:float"===n)&&/^\d/.test(i)){var s=i.indexOf(".");s<0&&(s=i.length,i+=".");for(var o=r-(i.length-s-1);o-- >0;)i+="0"}return i},r.stringifyString=function(e,t,r,n){var c=o.strOptions.defaultType,h=t.implicitKey,p=t.inFlow,d=e,m=d.type,v=d.value;"string"!=typeof v&&(v=String(v),e=Object.assign({},e,{value:v}));var b=function(c){switch(c){case i.Type.BLOCK_FOLDED:case i.Type.BLOCK_LITERAL:return f(e,t,r,n);case i.Type.QUOTE_DOUBLE:return l(v,t);case i.Type.QUOTE_SINGLE:return u(v,t);case i.Type.PLAIN:return function(e,t,r,n){var c=e.comment,h=e.type,p=e.value,d=t.actualString,m=t.implicitKey,v=t.indent,b=t.inFlow,y=t.tags;if(m&&/[\n[\]{},]/.test(p)||b&&/[[\]{},]/.test(p))return l(p,t);if(!p||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(p))return m||b||-1===p.indexOf("\n")?-1!==p.indexOf('"')&&-1===p.indexOf("'")?u(p,t):l(p,t):f(e,t,r,n);if(!m&&!b&&h!==i.Type.PLAIN&&-1!==p.indexOf("\n"))return f(e,t,r,n);var g=p.replace(/\n+/g,"$&\n".concat(v));if(d&&"string"!=typeof y.resolveScalar(g).value)return l(p,t);var w=m?g:(0,s.default)(g,v,s.FOLD_FLOW,o.strOptions.fold);if(c&&!b&&(-1!==w.indexOf("\n")||-1!==c.indexOf("\n")))return r&&r(),(0,a.addCommentBefore)(w,v,c);return w}(e,t,r,n);default:return null}};m!==i.Type.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(v)?m=i.Type.QUOTE_DOUBLE:!h&&!p||m!==i.Type.BLOCK_FOLDED&&m!==i.Type.BLOCK_LITERAL||(m=i.Type.QUOTE_DOUBLE);var y=b(m);if(null===y&&null===(y=b(c)))throw new Error("Unsupported default string type ".concat(c));return y};var a=e("./addComment"),i=e("./constants"),s=n(e("./foldFlowLines")),o=e("./tags/options");function l(e,t){var r=t.implicitKey,n=t.indent,a=o.strOptions.doubleQuoted,i=a.jsonEncoding,l=a.minMultiLineLength,u=JSON.stringify(e);if(i)return u;for(var f="",c=0,h=0,p=u[h];p;p=u[++h])if(" "===p&&"\\"===u[h+1]&&"n"===u[h+2]&&(f+=u.slice(c,h)+"\\ ",c=h+=1,p="\\"),"\\"===p)switch(u[h+1]){case"u":f+=u.slice(c,h);var d=u.substr(h+2,4);switch(d){case"0000":f+="\\0";break;case"0007":f+="\\a";break;case"000b":f+="\\v";break;case"001b":f+="\\e";break;case"0085":f+="\\N";break;case"00a0":f+="\\_";break;case"2028":f+="\\L";break;case"2029":f+="\\P";break;default:"00"===d.substr(0,2)?f+="\\x"+d.substr(2):f+=u.substr(h,6)}c=(h+=5)+1;break;case"n":if(r||'"'===u[h+2]||u.lengtht)return!0;if(r-(a=n+1)<=t)return!1}return!0}(f,o.strOptions.fold.lineWidth-c.length)),d=p?"|":">";if(!f)return d+"\n";var m="",v="";if(f=f.replace(/[\n\t ]*$/,(function(e){var t=e.indexOf("\n");return-1===t?d+="-":f!==e&&t===e.length-1||(d+="+",n&&n()),v=e.replace(/\n$/,""),""})).replace(/^[\n ]*/,(function(e){-1!==e.indexOf(" ")&&(d+=h);var t=e.match(/ +$/);return t?(m=e.slice(0,-t[0].length),t[0]):(m=e,"")})),v&&(v=v.replace(/\n+(?!\n|$)/g,"$&".concat(c))),m&&(m=m.replace(/\n+/g,"$&".concat(c))),a&&(d+=" #"+a.replace(/ ?[\r\n]+/g," "),r&&r()),!f)return"".concat(d).concat(h,"\n").concat(c).concat(v);if(p)return f=f.replace(/\n+/g,"$&".concat(c)),"".concat(d,"\n").concat(c).concat(m).concat(f).concat(v);f=f.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,"$&".concat(c));var b=(0,s.default)("".concat(m).concat(f).concat(v),c,s.FOLD_BLOCK,o.strOptions.fold);return"".concat(d,"\n").concat(c).concat(b)}},{"./addComment":6,"./constants":7,"./foldFlowLines":26,"./tags/options":49,"@babel/runtime/helpers/interopRequireWildcard":69}],42:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("../schema/Scalar")),i=e("../stringify"),s=n(e("./failsafe")),o=e("./options"),l=s.default.concat([{identify:function(e){return null==e},createNode:function(e,t,r){return r.wrapScalars?new a.default(null):null},default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:function(){return null},options:o.nullOptions,stringify:function(){return o.nullOptions.nullStr}},{identify:function(e){return"boolean"==typeof e},default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:function(e){return"t"===e[0]||"T"===e[0]},options:o.boolOptions,stringify:function(e){return e.value?o.boolOptions.trueStr:o.boolOptions.falseStr}},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o([0-7]+)$/,resolve:function(e,t){return parseInt(t,8)},stringify:function(e){return"0o"+e.value.toString(8)}},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:function(e){return parseInt(e,10)},stringify:i.stringifyNumber},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x([0-9a-fA-F]+)$/,resolve:function(e,t){return parseInt(t,16)},stringify:function(e){return"0x"+e.value.toString(16)}},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.inf|(\.nan))$/i,resolve:function(e,t){return t?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY},stringify:i.stringifyNumber},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:0|[1-9][0-9]*)(\.[0-9]*)?[eE][-+]?[0-9]+$/,resolve:function(e){return parseFloat(e)},stringify:function(e){var t=e.value;return Number(t).toExponential()}},{identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:0|[1-9][0-9]*)\.([0-9]*)$/,resolve:function(e,t){var r=new a.default(parseFloat(e));return t&&"0"===t[t.length-1]&&(r.minFractionDigits=t.length),r},stringify:i.stringifyNumber}]);r.default=l},{"../schema/Scalar":35,"../stringify":41,"./failsafe":43,"./options":49,"@babel/runtime/helpers/interopRequireDefault":68}],43:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("./map")),i=n(e("./seq")),s=n(e("./string")),o=[a.default,i.default,s.default];r.default=o},{"./map":44,"./seq":45,"./string":46,"@babel/runtime/helpers/interopRequireDefault":68}],44:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var a=n(e("@babel/runtime/helpers/typeof")),i=n(e("@babel/runtime/helpers/slicedToArray")),s=n(e("../../schema/Map")),o=n(e("../../schema/parseMap"));var l={createNode:function(e,t,r){var n=new s.default;if(t instanceof Map){var o=!0,l=!1,u=void 0;try{for(var f,c=t[Symbol.iterator]();!(o=(f=c.next()).done);o=!0){var h=(0,i.default)(f.value,2),p=h[0],d=h[1];n.items.push(e.createPair(p,d,r))}}catch(e){l=!0,u=e}finally{try{o||null==c.return||c.return()}finally{if(l)throw u}}}else if(t&&"object"===(0,a.default)(t))for(var m=0,v=Object.keys(t);m1){throw new a.YAMLSemanticError(t,"Each pair must have its own sequence indicator")}var u=l.items[0]||new s.default;l.commentBefore&&(u.commentBefore=u.commentBefore?"".concat(l.commentBefore,"\n").concat(u.commentBefore):l.commentBefore),l.comment&&(u.comment=u.comment?"".concat(l.comment,"\n").concat(u.comment):l.comment),l=u}r.items[n]=l instanceof s.default?l:new s.default(l)}}return r}function f(e,t,r){var n=new l.default;n.tag="tag:yaml.org,2002:pairs";var a=!0,i=!1,s=void 0;try{for(var o,u=t[Symbol.iterator]();!(a=(o=u.next()).done);a=!0){var f=o.value,c=void 0,h=void 0;if(Array.isArray(f)){if(2!==f.length)throw new TypeError("Expected [key, value] tuple: ".concat(f));c=f[0],h=f[1]}else if(f&&f instanceof Object){var p=Object.keys(f);if(1!==p.length)throw new TypeError("Expected { key: value } tuple: ".concat(f));h=f[c=p[0]]}else c=f;var d=e.createPair(c,h,r);n.items.push(d)}}catch(e){i=!0,s=e}finally{try{a||null==u.return||u.return()}finally{if(i)throw s}}return n}var c={default:!1,tag:"tag:yaml.org,2002:pairs",resolve:u,createNode:f};r.default=c},{"../../errors":25,"../../schema/Map":31,"../../schema/Pair":34,"../../schema/Seq":36,"../../schema/parseSeq":39,"@babel/runtime/helpers/interopRequireDefault":68}],54:[function(e,t,r){"use strict";var n=e("@babel/runtime/helpers/interopRequireWildcard"),a=e("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.YAMLSet=void 0;var i=a(e("@babel/runtime/helpers/typeof")),s=a(e("@babel/runtime/helpers/classCallCheck")),o=a(e("@babel/runtime/helpers/createClass")),l=a(e("@babel/runtime/helpers/possibleConstructorReturn")),u=a(e("@babel/runtime/helpers/getPrototypeOf")),f=a(e("@babel/runtime/helpers/get")),c=a(e("@babel/runtime/helpers/inherits")),h=a(e("@babel/runtime/helpers/defineProperty")),p=e("../../errors"),d=n(e("../../schema/Map")),m=a(e("../../schema/Pair")),v=a(e("../../schema/parseMap")),b=a(e("../../schema/Scalar")),y=function(e){function t(){var e;return(0,s.default)(this,t),(e=(0,l.default)(this,(0,u.default)(t).call(this))).tag=t.tag,e}return(0,c.default)(t,e),(0,o.default)(t,[{key:"add",value:function(e){var t=e instanceof m.default?e:new m.default(e);(0,d.findPair)(this.items,t.key)||this.items.push(t)}},{key:"get",value:function(e,t){var r=(0,d.findPair)(this.items,e);return!t&&r instanceof m.default?r.key instanceof b.default?r.key.value:r.key:r}},{key:"set",value:function(e,t){if("boolean"!=typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat((0,i.default)(t)));var r=(0,d.findPair)(this.items,e);r&&!t?this.items.splice(this.items.indexOf(r),1):!r&&t&&this.items.push(new m.default(e))}},{key:"toJSON",value:function(e,r){return(0,f.default)((0,u.default)(t.prototype),"toJSON",this).call(this,e,r,Set)}},{key:"toString",value:function(e,r,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues())return(0,f.default)((0,u.default)(t.prototype),"toString",this).call(this,e,r,n);throw new Error("Set items must all have null values")}}]),t}(d.default);r.YAMLSet=y,(0,h.default)(y,"tag","tag:yaml.org,2002:set");var g={identify:function(e){return e instanceof Set},nodeClass:y,default:!1,tag:"tag:yaml.org,2002:set",resolve:function(e,t){var r=(0,v.default)(e,t);if(!r.hasAllNullValues())throw new p.YAMLSemanticError(t,"Set items must all have null values");return Object.assign(new y,r)},createNode:function(e,t,r){var n=new y,a=!0,i=!1,s=void 0;try{for(var o,l=t[Symbol.iterator]();!(a=(o=l.next()).done);a=!0){var u=o.value;n.items.push(e.createPair(u,null,r))}}catch(e){i=!0,s=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw s}}return n}};r.default=g},{"../../errors":25,"../../schema/Map":31,"../../schema/Pair":34,"../../schema/Scalar":35,"../../schema/parseMap":38,"@babel/runtime/helpers/classCallCheck":61,"@babel/runtime/helpers/createClass":63,"@babel/runtime/helpers/defineProperty":64,"@babel/runtime/helpers/get":65,"@babel/runtime/helpers/getPrototypeOf":66,"@babel/runtime/helpers/inherits":67,"@babel/runtime/helpers/interopRequireDefault":68,"@babel/runtime/helpers/interopRequireWildcard":69,"@babel/runtime/helpers/possibleConstructorReturn":74,"@babel/runtime/helpers/typeof":79}],55:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.timestamp=r.floatTime=r.intTime=void 0;var n=e("../../stringify"),a=function(e,t){var r=t.split(":").reduce((function(e,t){return 60*e+Number(t)}),0);return"-"===e?-r:r},i=function(e){var t=e.value;if(isNaN(t)||!isFinite(t))return(0,n.stringifyNumber)(t);var r="";t<0&&(r="-",t=Math.abs(t));var a=[t%60];return t<60?a.unshift(0):(t=Math.round((t-a[0])/60),a.unshift(t%60),t>=60&&(t=Math.round((t-a[0])/60),a.unshift(t))),r+a.map((function(e){return e<10?"0"+String(e):String(e)})).join(":").replace(/000000\d*$/,"")},s={identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/,resolve:function(e,t,r){return a(t,r.replace(/_/g,""))},stringify:i};r.intTime=s;var o={identify:function(e){return"number"==typeof e},default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/,resolve:function(e,t,r){return a(t,r.replace(/_/g,""))},stringify:i};r.floatTime=o;var l={identify:function(e){return e instanceof Date},default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^(?:([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?)$"),resolve:function(e,t,r,n,i,s,o,l,u){l&&(l=(l+"00").substr(1,3));var f=Date.UTC(t,r-1,n,i||0,s||0,o||0,l||0);if(u&&"Z"!==u){var c=a(u[0],u.slice(1));Math.abs(c)<30&&(c*=60),f-=6e4*c}return new Date(f)},stringify:function(e){return e.value.toISOString().replace(/((T00:00)?:00)?\.000Z$/,"")}};r.timestamp=l},{"../../stringify":41}],56:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.default=function e(t,r,n){if(Array.isArray(t))return t.map((function(t,r){return e(t,String(r),n)}));if(t&&"function"==typeof t.toJSON){var a=n&&n.anchors&&n.anchors.find((function(e){return e.node===t}));a&&(n.onCreate=function(e){a.res=e,delete n.onCreate});var i=t.toJSON(r,n);return a&&n.onCreate&&n.onCreate(i),i}return t}},{}],57:[function(e,t,r){(function(e){"use strict";function t(t,r){if(!e||!e._YAML_SILENCE_WARNINGS){var n=(e&&e.process).emitWarning;n?n(t,r):console.warn(r?"".concat(r,": ").concat(t):t)}}Object.defineProperty(r,"__esModule",{value:!0}),r.warn=t,r.warnFileDeprecation=function(r){if(e&&e._YAML_SILENCE_DEPRECATION_WARNINGS)return;var n=r.replace(/.*yaml[/\\]/i,"").replace(/\.js$/,"").replace(/\\/g,"/");t("The endpoint 'yaml/".concat(n,"' will be removed in a future release."),"DeprecationWarning")},r.warnOptionDeprecation=function(r,a){if(e&&e._YAML_SILENCE_DEPRECATION_WARNINGS)return;if(n[r])return;n[r]=!0;var i="The option '".concat(r,"' will be removed in a future release");t(i+=a?", use '".concat(a,"' instead."):".","DeprecationWarning")};var n={}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],58:[function(e,t,r){t.exports=e("./dist").default},{"./dist":27}],59:[function(e,t,r){t.exports=function(e){if(Array.isArray(e))return e}},{}],60:[function(e,t,r){t.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}},{}],61:[function(e,t,r){t.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}},{}],62:[function(e,t,r){var n=e("./setPrototypeOf");function a(e,r,i){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}()?t.exports=a=function(e,t,r){var a=[null];a.push.apply(a,t);var i=new(Function.bind.apply(e,a));return r&&n(i,r.prototype),i}:t.exports=a=Reflect.construct,a.apply(null,arguments)}t.exports=a},{"./setPrototypeOf":75}],63:[function(e,t,r){function n(e,t){for(var r=0;r', }, + { + title: 'edit suggested removal reasons', + tooltip: 'Set up automatically suggested removal reasons for specific automoderator rules.', + content: ` +

+ Toolbox can suggest a removal reason based on your configured automoderator rules. It will attempt to extract all the valid report reasons + from your automoderator config, then add a button to instantly confirm the removal for posts that have a matching report attached. +

+
+
+ ` + }, { title: 'edit mod macros', tooltip: 'Edit and add your mod macros here.', @@ -736,6 +748,126 @@ function tbconfig () { } } + // magic suggested removal reasons, neat + function magicRemovalReasonsEditContent (automodReasons, configuredRemovalReasons) { + const currentReasons = config.suggestedRemovalReasons || {}; + config.suggestedRemovalReasons = currentReasons; + const $removalReasonsList = $body.find("#tb-magic-removal-reasons-list"); + + $removalReasonsList.empty(); + + for (const reason of automodReasons) { + const $el = $(/* html */` +
+ +
+
+ Items reported with "${reason.reason}" +
+ + +
+ + + +
+ +
+ +
+ `); + + const $toggleButton = $el.find("#tb-toggle-automod-source"); + const $toggleContent = $el.find(".automod-source"); + const $content = $el.find(".magic-removal-reason-content"); + + function renderContent() { + const removal = currentReasons[reason.reasonRegex]; + + if (!removal) { + $content.html(/* html */` +

No suggested removal reason configured.

+ + `); + } else { + let actions = []; + if (removal.comment) actions.push("leave a removal comment"); + if (removal.dm) actions.push("send a removal DM"); + if (removal.logSubmission) actions.push("log the removed submission to /r/" + removal.logSubmission.subreddit); + + $content.html(/* html */` +

A suggested removal reason is configured to ${actions.join(", ")}.

+ + + + `); + } + } + + $el.on("click", ".set-magic-removal-reason", async () => { + // TODO + try { + const selected = await window.promptRemovalReason( + configuredRemovalReasons, + "Removal reasons for /r/" + subreddit + ":", + `Select the removal reason to be suggested for posts reported with ${reason.reason}:`, + "all" + ); + + if (!selected) return; + + currentReasons[reason.reasonRegex] = selected; + + postToWiki('toolbox', config, 'added suggested removal reason', true); + + renderContent(); + } catch { + // nothing selected + return; + } + }); + + $el.on("click", ".view-magic-removal-reason", async () => { + const removal = currentReasons[reason.reasonRegex]; + const message = removal.comment ? removal.comment.content : removal.dm.content; + + // todo: ui? + prompt("Suggested Removal Reason Content", message); + }); + + $el.on("click", ".remove-magic-removal-reason", async () => { + delete currentReasons[reason.reasonRegex]; + + postToWiki('toolbox', config, 'removed suggested removal reason', true); + + renderContent(); + }); + + renderContent(); + + $toggleButton.on("click", e => { + e.preventDefault(); + + if ($toggleContent.is(":visible")) { + $toggleContent.hide(); + $toggleButton.html(`${TBui.icons.dotMenu} Show AutoModerator rule`); + } else { + $toggleContent.show(); + $toggleButton.html(`${TBui.icons.close} Hide AutoModerator rule`); + } + }); + + $removalReasonsList.append($el); + } + } + // Mod macros are also nice to have! function modMacrosContent () { if (config.modMacros && config.modMacros.length > 0) { @@ -1388,6 +1520,36 @@ function tbconfig () { $body.find('.tb-window-tabs .edit_removal_reasons').removeClass('content-populated'); }); + // magic removal reasons clicked + $body.on('click', '.tb-window-tabs .edit_suggested_removal_reasons', async function () { + const $this = $(this); + $body.find('#tb-magic-removal-reasons-list').empty().text("Loading..."); + + // load the automoderator contents so we can determine removal reasons + let automodContents = await TBApi.readFromWiki(subreddit, "config/automoderator"); + if (automodContents === TBCore.WIKI_PAGE_UNKNOWN || automodContents === TBCore.NO_WIKI_PAGE) { + automodContents = ""; + } + + // update config if needed + if ($body.hasClass('toolbox-wiki-edited')) { + await TBApi.readFromWiki(subreddit, 'toolbox', true).then(resp => { + if (!resp || resp === TBCore.WIKI_PAGE_UNKNOWN || resp === TBCore.NO_WIKI_PAGE) { + return; + } + + config = resp; + }); + } + + // load removal reasons + const reasons = await TBHelpers.getRemovalReasonsSettings(subreddit); + + magicRemovalReasonsEditContent(TBHelpers.parseAutomodReasons(automodContents), reasons); + + $this.addClass('content-populated'); + }); + // Mod macros tab is clicked. $body.on('click', '.tb-window-tabs .edit_mod_macros', function () { const $this = $(this); diff --git a/extension/data/modules/newremovalreasons.js b/extension/data/modules/newremovalreasons.js new file mode 100644 index 000000000..c79a04283 --- /dev/null +++ b/extension/data/modules/newremovalreasons.js @@ -0,0 +1,741 @@ +'use strict'; + +function newremovalreasons() { + const self = new TB.Module('New Removal Reasons'); + self.shortname = 'new_removal_reasons'; + + self.settings['enabled']['default'] = true; + + self.register_setting('commentReasons', { + type: 'boolean', + default: false, + title: 'Enable removal reasons for comments.', + }); + + self.register_setting('alwaysShow', { + type: 'boolean', + default: false, + title: 'Show an empty removal reason box for subreddits that don\'t have removal reasons.', + }); + + // Storage settings. + self.register_setting('reasonType', { + type: 'selector', + values: ['Reply with a comment to the item that is removed', 'Send as PM (personal message)', 'Send as both PM and reply', 'None (This only works when a logsub has been set)'], + default: 'reply', + title: 'Method of sending removal reasons.', + }); + + self.register_setting('reasonAsSub', { + type: 'boolean', + default: false, + advanced: false, + title: 'Send removal reasons as a subreddit. Note: these will appear in modmail and potentially clutter it up.', + }); + + self.register_setting('reasonAutoArchive', { + type: 'boolean', + default: false, + advanced: false, + title: 'Auto-archive sent modmail pm. Note: Only works on new modmail.', + }); + + self.register_setting('reasonSticky', { + type: 'boolean', + default: false, + title: 'Leave removal reasons as a sticky comment.', + }); + + self.register_setting('actionLock', { + type: 'boolean', + default: false, + title: 'Lock threads after leaving a removal reason.', + }); + + self.register_setting('actionLockComment', { + type: 'boolean', + default: false, + title: 'Lock removal reasons when replying as a comment.', + }); + + // Default is escape()'d: + // May make this a user setting, one day. + self.register_setting('customRemovalReason', { + type: 'string', + default: '%3Ctextarea%20id%3D%22customTextarea%22%20%20class%3D%22tb-input%22%20placeholder%3D%22Enter%20Custom%20reason%22%3E%3C/textarea%3E', + hidden: true, + }); + + // Error texts + const STATUS_DEFAULT_TEXT = 'saving...', + APPROVE_ERROR = 'error, failed to approve post', + FLAIR_ERROR = 'error, failed to flair post', + NO_REASON_ERROR = 'error, no reason selected', + NO_REPLY_TYPE_ERROR = 'error, no reply type selected', + REPLY_ERROR = 'error, failed to post reply', + PM_ERROR = 'error, failed to send PM', + MODMAIL_ERROR = 'error, failed to send Modmail', + MODMAIL_ARCHIVE_ERROR = 'error, failed to archive sent Modmail', + DISTINGUISH_ERROR = 'error, failed to distinguish reply', + LOCK_POST_ERROR = 'error, failed to lock post', + LOCK_COMMENT_ERROR = 'error, failed to lock reply', + LOG_REASON_MISSING_ERROR = 'error, public log reason missing', + LOG_POST_ERROR = 'error, failed to create log post'; + + // Set up markdown renderer + SnuOwnd.DEFAULT_HTML_ELEMENT_WHITELIST.push('select', 'option', 'textarea', 'input'); + SnuOwnd.DEFAULT_HTML_ATTR_WHITELIST.push('id', 'placeholder', 'label', 'value'); + const MARKDOWN_PARSER = SnuOwnd.getParser(SnuOwnd.getRedditRenderer(SnuOwnd.DEFAULT_BODY_FLAGS | SnuOwnd.HTML_ALLOW_ELEMENT_WHITELIST)); + + // helper function that converts the specified element constructed + // of markdown and possible inline html into the equivalent markdown + // with the inputs replaced by their legitimate values. + function reasonElementToMarkdown(entry) { + let markdown = ""; + + let $inputs = entry.$element.find(".styled-reason").find("select, input, textarea"); + let indexCounter = 0; + + console.log(`
${entry.reason.text}
`); + $(`
${entry.reason.text}
`).contents().each((_, el) => { + // If an element, check for conversions + if (el.nodeType === Node.ELEMENT_NODE) { + switch (el.tagName.toLowerCase()) { + // Convert breaks to lots of newlines + case 'br': + markdown += '\n\n'; + break; + + // Convert input elements to custom input (stored in order) + case 'select': + case 'input': + case 'textarea': + markdown += $inputs[indexCounter++].value || ""; + break; + } + } else if (el.nodeType === Node.TEXT_NODE) { + // If a text node, get content + markdown += el.textContent; + } + }); + + return markdown; + } + + // settings: settings of removal reasons as returned from getRemovalReasonsSettings + // title: title of the modal + // context: string shown at the top providing context for the removal reason popup + // show: either "submission", "comment" or "all" to determine which options to list + // returns a promise that resolves with the chosen options, or a promise that resolves + // with null if the user selected nothing, or a promise that rejects if the user cancelled + async function promptRemovalReason(settings, title, context, show = "all") { + // Render header and footer. Note that the strings will be empty if no header/footer is + // set, so this will always succeed as long as the input was valid. + const headerText = MARKDOWN_PARSER.render(settings.header); + const footerText = MARKDOWN_PARSER.render(settings.footer); + + // whether to show various parts + const headerDisplay = settings.header ? "" : "none"; + const footerDisplay = settings.footer ? "" : "none"; + const hasCustomLogReason = settings.logSub && settings.logTitle.includes("{reason}"); + const logReasonDisplay = hasCustomLogReason ? "" : "none"; + const isThread = show === "submission" || show === "all"; + + // defaults for reply options + const replyType = settings.forceSettings ? settings.replyType : ({ + "reply_with_a_comment_to_the_item_that_is_removed": "reply", + "send_as_pm_(personal_message)": "pm", + "send_as_both_pm_and_reply": "both", + "none_(this_only_works_when_a_logsub_has_been_set)": "none" + } [self.setting("reasonType")] || "reply"); + + // Construct popup. + const $popup = $( /* html */ ` +
+
+
${title}
+ +
+ ${context} + + +
+

+ + + ${headerText} +

+
+ + + + + + + + + + + + +
reasonflair textflair css
+ + + + + +
+
    + +
  • + + +
      +
    • + + +
    • + +
    • + + +
    • +
    +
  • + + +
  • + + +
      +
    • + + +
    • + +
    • + + +
    • +
    +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + + +
  • +
+
+ + +
+

+ Log Reason(s): + +

+ +

+ (Used for posting a log to /r/${settings.logSub}. Will only be used when "send" is clicked.) +

+
+
+ + +
+
+ `); + + // Fill values. + if (settings.forceSettings) { + // disable all sending options if we force settings + $popup.find("#buttons input").prop("disabled", true); + } + + // Disable certain options if we're not removing a thread. + if (!isThread) { + $popup.find("#type-stickied").prop("disabled", true); + $popup.find("#type-action-lock-thread").prop("disabled", true); + } + + // populate inputs + $popup.find("input[name=reply-type]").val([replyType]); // set reply type + $popup.find("#type-stickied").prop("checked", settings.forceSettings ? settings.stickyComment : self.setting('reasonSticky')); + $popup.find("#type-action-lock-comment").prop("checked", settings.forceSettings ? settings.lockComment : self.setting('actionLockComment')); + $popup.find("#type-as-sub").prop("checked", settings.forceSettings ? settings.sendPMAsSub : self.setting('reasonAsSub')); + $popup.find("#type-auto-archive").prop("checked", settings.forceSettings ? settings.autoArchivePM : self.setting('reasonAutoArchive')); + $popup.find("#type-action-lock-thread").prop("checked", settings.forceSettings ? settings.lockThread : self.setting("actionLock")); + $popup.find("#log-reason-input").val(settings.logReason); + + const reasonInputs = []; + + // populate reasons and set up listeners for them + for (let i = 0; i < settings.reasons.length; i++) { + const reason = settings.reasons[i]; + if ((show === "submission" && !reason.appliesToPosts) || (show === "comment" && !reason.appliesToComments)) { + continue; + } + + const reasonMarkdown = `${reason.text}\n\n`; + const reasonHtml = MARKDOWN_PARSER.render(reasonMarkdown); + + const $tr = $( /* html */ ` + + + +
${i + 1}
+ + + +
${reason.title || ""}
+
${reasonHtml}
+ + + + ${reason.flairText || ""} + + + + ${reason.flairCSS || ""} + + + `); + + // if we have a title, hide details until checked. + // else, remove the title. + if (reason.title) { + $tr.find(".styled-reason, .flair-text-span, .flair-css-span").hide(); + } else { + $tr.find(".removal-reason-title").remove(); + } + + $popup.find("#reason-table").append($tr); + + // setup element in the list, attach listeners for toggling select + const reasonInputEntry = { + $element: $tr, + reason, + selected: false + }; + + $tr.on("click", (e) => { + const clickedOnCheckbox = $(e.target).is(".reason-check"); + + // if not selected, clicking anywhere will select it. + if (!reasonInputEntry.selected) { + reasonInputEntry.selected = true; + $tr.addClass("reason-selected"); + $tr.find(".reason-check").prop("checked", true); + + // show contents if we're only showing the title + if (reason.title) { + $tr.find(".styled-reason, .flair-text-span, .flair-css-span").show(); + } + } else if (clickedOnCheckbox) { + // only deselect if we explicitly clicked on the checkbox + reasonInputEntry.selected = false; + $tr.removeClass("reason-selected"); + $tr.find(".reason-check").prop("checked", false); + + // only hide the contents if we have a title to show + if (reason.title) { + $tr.find(".styled-reason, .flair-text-span, .flair-css-span").hide(); + } + } + }); + + reasonInputs.push(reasonInputEntry); + } + + // pre-fill input elements in the custom reasons (inputs, textareas) + $popup.find('.reason-content input[id], .reason-content textarea[id]').each(async (i, el) => { + el.id = `reason-input-${settings.subreddit}-${el.id}`; + el.value = await TB.storage.getCache('RReasons', el.id, el.value); + }); + + // listen to changes to these input elements and persist them to cache + $popup.on("change", ".reason-content input[id], .reason-content textarea[id]", function () { + TB.storage.setCache('RReasons', this.id, this.selectedIndex || this.value); + }); + + $popup.appendTo('body'); + + // return a promise that resolves/rejects based on the button pressed + return new Promise((resolve, reject) => { + // no reason, resolve with null + $popup.find(".no-reason").on("click", () => { + $popup.remove(); + resolve(null); + }); + + // cancel, reject + $popup.find(".cancel").on("click", () => { + $popup.remove(); + reject(); + }); + + // save, compute values and resolve with them + $popup.find(".save").on("click", () => { + const result = {}; + const $status = $popup.find(".status"); + const replyType = $popup.find("input[name=reply-type]:checked").val(); + + // Step 1: compute removal message + const selected = reasonInputs.filter(x => x.selected); + if (!selected.length && replyType !== "none") { + // none selected + $status.text(NO_REASON_ERROR); + return; + } + + let message = ""; + let flairText = ""; + let flairCSS = ""; + let flairTemplateID = ""; + for (const selectedReason of selected) { + // convert reason to markdown with inputs filled + message += "\n\n" + reasonElementToMarkdown(selectedReason); + flairText += " " + selectedReason.reason.flairText; + flairCSS += " " + selectedReason.reason.flairCSS; + flairTemplateID = selectedReason.reason.flairTemplateID; + } + + if ($popup.find("#include-header").is(":checked")) { + message = `${settings.header}${message}`; // message is already prefixed with double newline + } + + if ($popup.find("#include-footer").is(":checked")) { + message += `\n\n${settings.footer}`; + } + + message = message.trim(); + + // step 2: assign data + + // assign flair settings + if (isThread) { + flairText = flairText.trim(); + flairCSS = flairCSS.trim(); + + result.submission = { + lock: $popup.find("#type-action-lock-thread").is(":checked"), + flair: (flairText.length || flairCSS.length || flairTemplateID) ? { + text: flairText, + css: flairCSS, + templateID: flairTemplateID.trim() || null + } : null + }; + } + + // comment reply + if ((replyType === "reply" || replyType === "both") && message.length) { + result.comment = { + content: message, + lock: $popup.find("#type-action-lock-comment").is(":checked"), + sticky: $popup.find("#type-stickied").is(":checked"), + }; + } + + // dm reply + if ((replyType === "dm" || replyType === "both") && message.length) { + result.dm = { + subject: settings.pmSubject, + content: message, + asSub: $popup.find("#type-as-sub").is(":checked"), + archive: $popup.find("#type-auto-archive").is(":checked") + }; + } + + // log sub + if (settings.logSub) { + const removeReason = $popup.find('#log-reason-input').val().trim(); + + if (hasCustomLogReason && !removeReason.length) { + $status.text(LOG_REASON_MISSING_ERROR); + return; + } + + result.logSubmission = { + subreddit: settings.logSub, + title: TBHelpers.removeQuotes(settings.logTitle.replace("{reason}", removeReason)) + }; + } + + console.log(JSON.stringify(result, null, 4)); + + // step 3: remove and return + $popup.remove(); + resolve(result); + }); + }); + } + window.promptRemovalReason = promptRemovalReason; // hack + + // Returns { id, subreddit } of the given element, where the given element is something + // inside the comment/submission (will extract closest parent) + function findThingID($el) { + if (TBCore.isOldReddit) { + const $thing = $el.closest('.thing, .tb-thing'); + const isComment = $thing.hasClass('comment') || $thing.hasClass('was-comment') || $thing.hasClass('tb-comment'); + + return { + id: $thing.attr('data-fullname'), + subreddit: $thing.attr('data-subreddit'), + isComment + }; + } else { + const $button = $el.find(".tb-add-removal-reason"); + + if ($button) { + return { + id: $button.attr('data-id'), + subreddit: $button.attr('data-subreddit'), + isComment: $button.closest('.tb-frontend-container').data('tb-type') === 'comment' + }; + } else { + const $parent = $el.closest('.Post'); + const postDetails = $parent.find('.tb-frontend-container[data-tb-type="post"]').data('tb-details'); + + return { + id: postDetails.data.id, + subreddit: postDetails.data.subreddit.name, + isComment: false + }; + } + } + } + + /** + * Applies the result of `result` to the element to the given thingInfo, where + * thingInfo is the result of calling `getAPIThingInfo` on the data. + */ + async function applyRemovalResult(thingInfo, result) { + // Step 1: figure out the data of the object we're removing + const data = { + subreddit: thingInfo.subreddit, + fullname: thingInfo.id, + author: thingInfo.user, + title: thingInfo.title, + kind: thingInfo.kind, + mod: thingInfo.mod, + url: thingInfo.permalink, + link: thingInfo.postlink, + domain: thingInfo.domain, + logSub: result.logSubmission ? result.logSubmission.subreddit : "", + body: thingInfo.body, + raw_body: thingInfo.raw_body, + uri_body: thingInfo.uri_body || encodeURIComponent(thingInfo.body), + uri_title: thingInfo.uri_title || encodeURIComponent(thingInfo.title), + }; + + // Step 2: remove the actual object, if it wasn't already + // we do this async + TBCore.getApiThingInfo(data.fullname, data.subreddit, false, ({ ham }) => { + if (!ham) { + TBApi.removeThing(data.fullname); + } + }); + + // Step 3: flair if needed + if (result.submission && result.submission.flair) { + const flair = result.submission.flair; + await TBApi.flairPost(data.fullname, data.subreddit, flair.text, flair.css, flair.templateID); + } + + // Step 4: post to log sub if needed + if (result.logSubmission) { + await TBApi.postLink(data.url || data.link, result.logSubmission.title, result.logSubmission.subreddit).then(response => { + // approve immediately, set the log link + data.loglink = response.json.data.url; + + return TBApi.approveThing(response.json.data.name); + }); + } + + // Step 5: post the removal message, if needed + if (result.comment) { + // substitute data + const content = TBHelpers.replaceTokens(data, result.comment.content); + + const comment = await TBApi.postComment(data.fullname, content).then(x => x.json.data.things[0]); + + // distinguish (and sticky if needed) + await TBApi.distinguishThing(comment.data.id, result.comment.sticky); + + // lock if needed + if (result.comment.lock) { + await TBApi.lock(comment.data.id); + } + } + + // Step 6: lock submission if needed + if (result.submission && result.submission.lock) { + await TBApi.lock(data.fullname); + } + + // Step 7: send dm if needed + if (result.dm) { + // we need to find out if this sub uses old or new modmail + // load mod sub info + await new Promise(r => TBCore.getModSubs(r)); + + const subredditData = TBCore.mySubsData.find(s => s.subreddit === data.subreddit); + const useNewModmail = result.dm.asSub && result.dm.archive && subredditData && subredditData.is_enrolled_in_new_modmail; + + const subject = TBHelpers.replaceTokens(data, result.dm.subject); + const message = `${TBHelpers.replaceTokens(data, result.dm.content)}\n\n---\n[[Link to your ${data.kind}](${data.url})]`; + + if (useNewModmail) { + const conversation = await TBApi.apiOauthPOST("/api/mod/conversations", { + to: data.author, + isAuthorHidden: true, + subject, + body: message, + srName: data.subreddit + }).then(x => x.json()).then(x => x.conversation); + + if (result.dm.archive && !conversation.isInternal) { + await TBApi.apiOauthPOST(`/api/mod/conversations/${conversation.id}/archive`); + } + } else { + await TBApi.sendMessage(data.author, subject, message, result.dm.asSub ? data.subreddit : undefined); + } + } + + // Done! + } + + async function possiblyAddSuggestedRemovalButton($target, data) { + const automodReport = data.modReports.find(x => x.startsWith("AutoModerator: ")); + if (!automodReport) return; + + const suggestions = await TBHelpers.getSuggestedReasonsForSubreddit(data.subreddit.name); + + // find matching suggestion + let match = null; + for (const [k, v] of Object.entries(suggestions)) { + const regex = new RegExp("^AutoModerator: " + k + "$"); + if (!regex.test(automodReport)) continue; + + match = v; + } + + if (!match) return; + + // add button if we have one that matches + $target.append(`Remove with suggested reason`); + + // handle clicks + $target.on("click", ".tb-remove-using-suggested-reason", async () => { + // get info on the thing + const thingData = await new Promise(r => TBCore.getApiThingInfo(data.id, data.subreddit.name, false, r)); + + // apply removal + await applyRemovalResult(thingData, match); + + // signify ok + TB.ui.textFeedback("Removed!", TB.ui.FEEDBACK_POSITIVE); + }); + } + + self.init = function () { + console.log("Inite"); + + // Check if removal reasons are runnable + if (TBCore.isModmail) { + self.log('Disabled because modmail'); + return; + } + + // set up listeners + TB.listener.on('post', e => { + const $target = $(e.target); + possiblyAddSuggestedRemovalButton($target, e.detail.data); + + if (e.detail.data.isRemoved && TBCore.pageDetails.pageType !== 'queueListing') { + $target.append(`Add removal reason (new)`); + } + }); + + if (self.setting('commentReasons')) { + TB.listener.on('comment', e => { + const $target = $(e.target); + possiblyAddSuggestedRemovalButton($target, e.detail.data); + + if (e.detail.data.isRemoved && TBCore.pageDetails.pageType !== 'queueListing') { + $target.append(`Add removal reason (new)`); + } + }); + } + + // Open reason drop-down when we remove something as ham. + $('body').on('click', 'button:contains("remove"), button:contains("Confirm removal"), .tb-add-removal-reason, .big-mod-buttons > span > .pretty-button.neutral, .remove-button, .tb-submission-button-remove, .tb-comment-button-remove', async function (event) { + const $button = $(this); + const { id, subreddit, isComment } = findThingID($button); + + // load data and removal reasons + const data = await new Promise(r => TBCore.getApiThingInfo(id, subreddit, false, r)); + const reasons = await TBHelpers.getRemovalReasonsSettings(subreddit); + + // todo: confirm remove here immediately + + // ask user for the removal reason + const result = await promptRemovalReason( + reasons, + `Removal reasons for /r/${subreddit}:`, + `Removing: ${TBHelpers.htmlEncode(data.title)}`, + isComment ? "comment" : "submission" + ); + + if (!result) return; // selected none + + // perform result + await applyRemovalResult(data, result); + }); + }; + + TB.register_module(self); +} // end newremovalreasons() + +window.addEventListener('TBModuleLoaded', () => { + newremovalreasons(); +}); diff --git a/extension/data/modules/oldreddit.js b/extension/data/modules/oldreddit.js index dc981b362..187fcec18 100644 --- a/extension/data/modules/oldreddit.js +++ b/extension/data/modules/oldreddit.js @@ -50,6 +50,12 @@ function oldReddit () { const info = TBCore.getThingInfo($thing); + let modReports = []; + const $reportsEl = $thing.find("ul.report-reasons"); + if ($reportsEl.length) { + modReports = $reportsEl.find("li.mod-report").map((_, x) => x.textContent.trim()).toArray(); + } + requestAnimationFrame(() => { const $jsApiThingPlaceholder = $('
').appendTo($thing.find('.entry:first')); $jsApiThingPlaceholder.append(''); @@ -76,6 +82,7 @@ function oldReddit () { name: info.subreddit, type: info.subredditType, }, + modReports, }, }; @@ -116,6 +123,7 @@ function oldReddit () { name: info.subreddit, type: info.subredditType, }, + modReports }, }; diff --git a/extension/data/styles/toolbox.css b/extension/data/styles/toolbox.css index fe891fd27..c72f6347b 100644 --- a/extension/data/styles/toolbox.css +++ b/extension/data/styles/toolbox.css @@ -1776,7 +1776,8 @@ TODO: Find out what this is supposed to fix and put that in the comment instead. } .mod-toolbox-rd #tb-removal-reasons-list, -.mod-toolbox-rd #tb-mod-macros-list { +.mod-toolbox-rd #tb-mod-macros-list, +.mod-toolbox-rd #tb-magic-removal-reasons-list { border-top: solid 2px gray; margin-top: 5px; width: 99%; @@ -1801,7 +1802,8 @@ TODO: Find out what this is supposed to fix and put that in the comment instead. } .mod-toolbox-rd .edit_removal_reasons tr.removal-reason, -.mod-toolbox-rd .edit_mod_macros tr.mod-macro { +.mod-toolbox-rd .edit_mod_macros tr.mod-macro, +.mod-toolbox-rd div.magic-removal-reason { border-bottom: solid 5px #F0F0F0; } @@ -1855,6 +1857,44 @@ TODO: Find out what this is supposed to fix and put that in the comment instead. display: none; } +.mod-toolbox-rd #tb-magic-removal-reasons-list { + max-height: 600px; + overflow-x: hidden; + overflow-y: scroll; + display: block; + padding-right: 5px; +} + +.mod-toolbox-rd .magic-removal-reason .magic-removal-reason-title { + display: flex; + flex-direction: row; + justify-content: center; + border-bottom: 1px dashed black; + padding: 5px 0; +} + +.mod-toolbox-rd .magic-removal-reason .magic-removal-reason-content { + padding: 5px 0; +} + +.mod-toolbox-rd .magic-removal-reason .magic-removal-reason-title .left { + flex: 1; + font-weight: bold; +} + +.mod-toolbox-rd .magic-removal-reason .automod-source b { + padding: 5px 0; + display: block; +} + +.mod-toolbox-rd .magic-removal-reason .automod-source pre { + overflow-y: hidden; + overflow-x: auto; + border: 1px dashed #e6e6de; + background-color: #fcfcfb; + border-radius: 2px; + padding: 5px 10px; +} /* Icons in the sidebar diff --git a/extension/data/tbhelpers.js b/extension/data/tbhelpers.js index cdfc79624..267a87ea5 100644 --- a/extension/data/tbhelpers.js +++ b/extension/data/tbhelpers.js @@ -717,4 +717,141 @@ // Collapse to base64 return btoa(objThing); }; + + /** + * Parses the given automoderator yaml and returns a list of objects + * containing { reason: string, reasonRegex: string, snippet: string }. + * Only returns automod entries that are set to report or filter and have + * a set reason. May include entries for which the reason or reason_regex + * are the same, depending on the configured result. + * @param {string} content + * @returns {array} + */ + TBHelpers.parseAutomodReasons = function (content) { + const documents = yaml.parseAllDocuments(content, { keepCstNodes: true }); + const ret = []; + + for (const doc of documents) { + if (!doc.has("action")) continue; + if (!doc.has("action_reason")) continue; + + const action = doc.get("action"); + const reason = doc.get("action_reason"); + + if (action !== "report" && action !== "filter") continue; + + const regex = reason.replace(/\{\{[\w-]+\}\}/g, ".*?"); + + // bunch of spaghetti to get exactly the relevant snippet and dedent it + const firstNode = doc.contents.items[0].key; + const fullSnippet = doc.cstNode.context.src.slice(doc.range[0], doc.contents.range[1]); + const startOfSectionToFirstKey = firstNode.range[0] - doc.range[0]; + const indentationLevel = startOfSectionToFirstKey - fullSnippet.slice(0, startOfSectionToFirstKey).lastIndexOf("\n") - 1; + const actualSnippet = fullSnippet.trim().split("\n").map((x, i) => i === 0 ? x : x.slice(indentationLevel)).filter(x => x).join("\n").trim(); + + ret.push({ + reason, + reasonRegex: regex, + snippet: actualSnippet + }); + } + + return ret; + }; + + // Default texts + const DEFAULT_SUBJECT = 'Your {kind} was removed from /r/{subreddit}', + DEFAULT_LOG_TITLE = 'Removed: {kind} by /u/{author} to /r/{subreddit}'; + + // retrieves the (possibly cached) settings for the given subreddit, or null + // if no such settings exist + TBHelpers.getSubredditConfig = async function getSubredditConfig(subreddit) { + // if we have no toolbox config for this subreddit, no point in looking up + if (TBCore.noConfig.includes(subreddit)) { + return null; + } + + // check cache first + if (TBCore.configCache[subreddit]) { + return TBCore.configCache[subreddit]; + } + + // not cached, query the wiki + const wikiResp = await TBApi.readFromWiki(subreddit, "toolbox", true); + if (!wikiResp || wikiResp === TBCore.WIKI_PAGE_UNKNOWN || wikiResp === TBCore.NO_WIKI_PAGE || !wikiResp.removalReasons) { + return null; + } + + // config is valid, update cache + TBCore.updateCache("configCache", wikiResp, subreddit); + + return wikiResp; + }; + + // retrieves raw removal reasons settings from cache or toolbox wiki page, + // returns null if no removal reason settings. + TBHelpers.getRemovalReasonsStorage = async function getRemovalReasonsStorage(subreddit) { + const config = await TBHelpers.getSubredditConfig(subreddit); + if (!config) return null; + + const rr = config.removalReasons; + if (rr.getfrom) { + return getRemovalReasonsStorage(rr.getfrom); + } + + return rr; + }; + + // returns the removalreasons settings for the given subreddit, merged with + // the options set by the local user + // returns an empty promise if the subreddit has no removal reasons set + TBHelpers.getRemovalReasonsSettings = async function getRemovalReasonsSettings(subreddit) { + const data = await TBHelpers.getRemovalReasonsStorage(subreddit); + if (!data) return null; + + return { + subreddit, + + header: unescape(data.header || ""), + footer: unescape(data.footer || ""), + + // whether or not the sending options should be forcibly taken + // from the settings or be configurable by the user + forceSettings: data.removalOption === "force", + + // reply options + replyType: data.typeReply, + stickyComment: !!data.typeStickied, + lockComment: !!data.typeLockComment, + sendPMAsSub: !!data.typeAsSub, + autoArchivePM: !!data.autoArchive, + lockThread: !!data.typeLockThread, + pmSubject: data.pmsubject || DEFAULT_SUBJECT, + + // information for when logging removals to a sub is enabled + logSub: data.logsub || "", + logReason: data.logreason || "", + logTitle: data.logTitle || DEFAULT_LOG_TITLE, + + reasons: data.reasons.map(reason => ({ + text: unescape(reason.text), + title: reason.title, + appliesToPosts: reason.removePosts === undefined ? true : !!reason.removePosts, + appliesToComments: reason.removeComments === undefined ? true : !!reason.removeComments, + flairText: reason.flairText, + flairCSS: reason.flairCSS, + flairTemplateID: reason.flairTemplateID || "" + })) + }; + } + + // retrieve the set of suggested removal reasons for the given subreddit + // will consult cache first. Returns an object with keys set to a regex + // and values set to a return value of `promptRemovalReason`. + TBHelpers.getSuggestedReasonsForSubreddit = async function getSuggestedReasonsForSubreddit(subreddit) { + const config = await TBHelpers.getSubredditConfig(subreddit); + if (!config) return {}; + + return config.suggestedRemovalReasons || {}; + }; })(window.TBHelpers = window.TBHelpers || {}); diff --git a/extension/manifest.json b/extension/manifest.json index 4d356ce1a..3daafa7b9 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -87,7 +87,8 @@ "data/libs/codemirror/mode/yaml.js", "data/libs/codemirror/mode/javascript.js", "data/libs/pako.js", - "data/libs/tinycolor.js" + "data/libs/tinycolor.js", + "data/libs/yaml.js" ] }, { @@ -164,6 +165,7 @@ "data/modules/personalnotes.js", "data/modules/historybutton.js", "data/modules/removalreasons.js", + "data/modules/newremovalreasons.js", "data/modules/nukecomments.js", "data/modules/trouble.js", "data/modules/profile.js",