//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// UserRTX.NET satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;
using System.Text;

#if !WASM
namespace user_rtx { using u = user_rtx;
#else
namespace user_rtx.wasm { using u = user_rtx.wasm;
#endif

static partial class str {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public static bool StartsWithWhiteSpace( string str ) =>
   str.Length > 0 && char.IsWhiteSpace( str[0] );

public static bool EndsWithWhiteSpace( string str ) =>
   str.Length > 0 && char.IsWhiteSpace( StrictLastChar( str ) );

public static bool HasBoundaryWhiteSpace( string str ) =>
   StartsWithWhiteSpace( str ) || EndsWithWhiteSpace( str );

public static bool ContainsWhiteSpace( string str )
{
   foreach ( char ch in str )
      if ( char.IsWhiteSpace( ch ) )
         return true;
   return false;
}
public static bool ContainsDoubleWhiteSpace( string str )
{
   if ( str.Length == 0 )
      return false;
   bool isPrevCharWhiteSpace = char.IsWhiteSpace( str[0] );
   for ( int i=1; i<str.Length; i++ ) {
      bool isWhiteSpace = char.IsWhiteSpace( str[i] );
      if ( isWhiteSpace && isPrevCharWhiteSpace )
         return true;
      isPrevCharWhiteSpace = isWhiteSpace;
   }
   return false;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // str

} // user_rtx (.wasm)
