/**
 * @name string-collapse-leading-whitespace
 * @fileoverview Collapse the leading and trailing whitespace of a string
 * @version 7.1.3
 * @author Roy Revelt
 * @license MIT
 * {@link https://codsen.com/os/string-collapse-leading-whitespace/}
 */

"use strict";var stringCollapseLeadingWhitespace=(()=>{var m=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var D=(l,r)=>{for(var o in r)m(l,o,{get:r[o],enumerable:!0})},V=(l,r,o,c)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of y(r))!E.call(l,s)&&s!==o&&m(l,s,{get:()=>r[s],enumerable:!(c=b(r,s))||c.enumerable});return l};var N=l=>V(m({},"__esModule",{value:!0}),l);var J={};D(J,{collWhitespace:()=>h,version:()=>v});var a="7.1.3";var v=a;function h(l,r=1){let o="\xA0";function c(e){return Array.from(e).reverse().join("")}function s(e,i,g){let t=g?"\n":"\r",$=g?"\r":"\n";if(!e)return e;let f=0,p=0,u="";for(let n=0,d=e.length;n<d;n++)(e[n]===t||e[n]===$&&e[n-1]!==t)&&p++,"\r\n".includes(e[n])||e[n]===o?(f=0,e[n]===o?u+=e[n]:e[n]===t?p<=i&&(u+=e[n],e[n+1]===$&&(u+=e[n+1],n++)):e[n]===$&&(e==null?void 0:e[n-1])!==t&&p<=i&&(u+=e[n])):(f++,!e[n+1]&&!p&&(u+=" "));return u}if(typeof l=="string"&&l.length){let e=1;typeof+r=="number"&&Number.isInteger(+r)&&+r>=0&&(e=+r);let i="",g="";if(!l.trim())i=l;else if(!l[0].trim()){for(let t=0,$=l.length;t<$;t++)if(l[t].trim()){i=l.slice(0,t);break}}if(l.trim()&&(l.slice(-1).trim()===""||l.slice(-1)===o)){for(let t=l.length;t--;)if(l[t].trim()){g=l.slice(t+1);break}}return"".concat(s(i,e,!1)).concat(l.trim()).concat(c(s(c(g),e,!0)))}return l}return N(J);})();
