/** * @name string-left-right * @fileoverview Looks up the first non-whitespace character to the left/right of a given index * @version 4.1.0 * @author Roy Revelt, Codsen Ltd * @license MIT * {@link https://codsen.com/os/string-left-right/} */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).stringLeftRight={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r,n,o=Object.prototype,i=Function.prototype.toString,u=o.hasOwnProperty,c=i.call(Object),f=o.toString,s=(r=Object.getPrototypeOf,n=Object,function(t){return r(n(t))});var l=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=f.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=s(t);if(null===e)return!0;var r=u.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&i.call(r)==c},a={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",u="[object Boolean]",c="[object Date]",f="[object Function]",s="[object GeneratorFunction]",l="[object Map]",a="[object Number]",p="[object Object]",h="[object Promise]",d="[object RegExp]",g="[object Set]",y="[object String]",v="[object Symbol]",b="[object WeakMap]",_="[object ArrayBuffer]",m="[object DataView]",w="[object Float32Array]",j="[object Float64Array]",A="[object Int8Array]",O="[object Int16Array]",x="[object Int32Array]",N="[object Uint8Array]",S="[object Uint8ClampedArray]",R="[object Uint16Array]",I="[object Uint32Array]",$=/\w*$/,E=/^\[object .+?Constructor\]$/,L=/^(?:0|[1-9]\d*)$/,C={};C[i]=C["[object Array]"]=C[_]=C[m]=C[u]=C[c]=C[w]=C[j]=C[A]=C[O]=C[x]=C[l]=C[a]=C[p]=C[d]=C[g]=C[y]=C[v]=C[N]=C[S]=C[R]=C[I]=!0,C["[object Error]"]=C[f]=C[b]=!1;var P="object"==typeof self&&self&&self.Object===Object&&self,T="object"==typeof e&&e&&e.Object===Object&&e||P||Function("return this")(),W=r&&!r.nodeType&&r,D=W&&t&&!t.nodeType&&t,F=D&&D.exports===W;function k(t,e){return t.set(e[0],e[1]),t}function B(t,e){return t.add(e),t}function M(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o-1},Nt.prototype.set=function(t,e){var r=this.__data__,n=Et(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},St.prototype.clear=function(){this.__data__={hash:new xt,map:new(ht||Nt),string:new xt}},St.prototype.delete=function(t){return Wt(this,t).delete(t)},St.prototype.get=function(t){return Wt(this,t).get(t)},St.prototype.has=function(t){return Wt(this,t).has(t)},St.prototype.set=function(t,e){return Wt(this,t).set(t,e),this},Rt.prototype.clear=function(){this.__data__=new Nt},Rt.prototype.delete=function(t){return this.__data__.delete(t)},Rt.prototype.get=function(t){return this.__data__.get(t)},Rt.prototype.has=function(t){return this.__data__.has(t)},Rt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Nt){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new St(n)}return r.set(t,e),this};var Ft=st?z(st,Object):function(){return[]},kt=function(t){return tt.call(t)};function Bt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||L.test(t))&&t>-1&&t%1==0&&t-1&&t%1==0&&t<=o}(t.length)&&!Gt(t)}var Vt=lt||function(){return!1};function Gt(t){var e=Jt(t)?tt.call(t):"";return e==f||e==s}function Jt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Kt(t){return Ht(t)?It(t):function(t){if(!Mt(t))return at(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Lt(t,!0,!0)}}(a,a.exports);var p=a.exports;const h=" ";function d(t){const e={value:t,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function g(t){return"number"==typeof t}function y(t){return"string"==typeof t}function v({str:t,idx:e=0,stopAtNewlines:r=!1,stopAtRawNbsp:n=!1}){if("string"!=typeof t||!t.length)return null;if(e&&"number"==typeof e||(e=0),!t[e+1])return null;if(t[e+1]&&(t[e+1].trim()||r&&"\n\r".includes(t[e+1])||n&&t[e+1]===h))return e+1;if(t[e+2]&&(t[e+2].trim()||r&&"\n\r".includes(t[e+2])||n&&t[e+2]===h))return e+2;for(let o=e+1,i=t.length;oi+1?u.push([i+1,h]):"left"===t&&"number"==typeof h&&h<~-i&&u.unshift([h+1,i]),i=h,"right"===t?(void 0===c&&(c=h),f=h):(void 0===f&&(f=h),c=h)}}return void 0===c||void 0===f?null:{gaps:u,leftmostChar:c,rightmostChar:f}}const j={i:!1};function A(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("left",t,e,n,Array.from(r).reverse())}function O(t,e,...r){if(!r||!r.length)throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let n;return n=l(r[0])?{...j,...r.shift()}:j,w("right",t,e,n,r)}function x(t,e,r,n,o=[]){if("string"!=typeof e||!e.length)return null;if(r&&"number"==typeof r||(r=0),"right"===t&&!e[r+1]||"left"===t&&0==+r)return null;let i=null,u=null;do{i="right"===t?O(e,"number"==typeof u?u:r,...o):A(e,"number"==typeof u?u:r,...o),null!==i&&(u="right"===t?i.rightmostChar:i.leftmostChar)}while(i);if(null!=u&&"right"===t&&(u+=1),null===u)return null;if("right"===t){if(e[u]&&e[u].trim())return u;const t=b(e,u);if(n&&0!==n.mode){if(1===n.mode)return u;if(2===n.mode){const t=e.slice(u);if(t.trim()||t.includes("\n")||t.includes("\r"))for(let t=u,r=e.length;t