text:
module('lively.ide.codeeditor.Commands').requires().toRun(function() {

var JavaScriptCommandHelper = {

  withIdentifierAtPointOrSelection: function(codeEditorMorph) {
      var ast = codeEditorMorph.withASTDo(function(ast) { return ast; })
             || lively.ast.parse(codeEditorMorph.textString, {}),
          token = codeEditorMorph.tokenAfterPoint();

      var identfierTypes = ["identifier", "entity.name.function", "variable.parameter", "variable.language"];
      if (token && !identfierTypes.include(token.type)) token = codeEditorMorph.tokenAtPoint();
      if (token && !identfierTypes.include(token.type)) token = null;

      var refName = codeEditorMorph.getSelection().isEmpty() ?
        token && token.value : codeEditorMorph.getTextRange();
      return {ast: ast, name: refName}
  }

}

var JavaScriptCommands = {

  selectDefinition: {
    readOnly: true,
    bindKey: {win: "Alt-.", mac: "Alt-."},
    exec: function(ed, options) {
      var args = (options && options.args) || null,
          codeEditor = ed.$morph,
          idInfo = JavaScriptCommandHelper.withIdentifierAtPointOrSelection(codeEditor);

      if (!idInfo.name) { show("No symbol identifier selected"); return; }

      var pos = codeEditor.getCursorPositionAce(),
          cursorIndex = codeEditor.positionToIndex(pos),
          declIdNode = lively.ast.query.findDeclarationClosestToIndex(idInfo.ast, idInfo.name, cursorIndex);

      if (!declIdNode) return;

      ed.pushEmacsMark && ed.pushEmacsMark(pos, false);
      declIdNode && codeEditor.setSelectionRange(declIdNode.start, declIdNode.end);
    }
  },

  selectSymbolReferenceOrDeclarationNext: {
    readOnly: true, exec: function(ed) { ed.execCommand('selectSymbolReferenceOrDeclaration', {args: 'next'}); }
  },

  selectSymbolReferenceOrDeclarationPrev: {
    readOnly: true, exec: function(ed) { ed.execCommand('selectSymbolReferenceOrDeclaration', {args: 'prev'}); }
  },

  selectSymbolReferenceOrDeclaration: {
    readOnly: true,
    exec: function(ed, options) {
      // finds the name of the currently selected symbol and will use the JS
      // ast to select references and declarations whose name matches the symbol
      // in the current scope
      // 1. get the token / identifier info of what is currently selected
      var args = (options && options.args) || null,
          codeEditor = ed.$morph,
          idInfo = JavaScriptCommandHelper.withIdentifierAtPointOrSelection(codeEditor);

      if (!idInfo.name) { show("No symbol identifier selected"); return; }

      // 2. find reference and declaration nodes of the selected token / identifier
      var cursorPos = codeEditor.getCursorPositionAce(),
          cursorindex = codeEditor.positionToIndex(cursorPos),
          scope = lively.ast.query.scopeAtIndex(idInfo.ast, cursorindex),
          refs = lively.ast.query.findReferencesAndDeclsInScope(scope, idInfo.name);

      // 3. map the AST ref / decl nodes to actual text ranges
      var Range = lively.ide.ace.require('ace/range').Range,
          sel = codeEditor.getSelection(),
          // selectionRanges = sel.getAllRanges(),
          ranges = refs
          .map(function(ref) {
            return Range.fromPoints(
              codeEditor.indexToPosition(ref.start),
              codeEditor.indexToPosition(ref.end)); })
          // .filter(function(range) { // only those ranges currently NOT selected
          //   return selectionRanges.every(function(selRange) {
          //     return !selRange.isEqual(range); }); });

      if (!ranges.length) return;

      // do we want to select all ranges or jsut the next/prev one?
      if (args === 'next' || args === 'prev') {
        var currentRangeIdx = ranges.map(String).indexOf(String(sel.getRange()));
        if (currentRangeIdx === -1 && ranges.length) ranges = [ranges[0]];
        else {
          var nextIdx = currentRangeIdx + (args === 'next' ? 1 : -1);
          if (nextIdx < 0) nextIdx = ranges.length-1;
          else if (nextIdx >= ranges.length) nextIdx = 0;
          ranges = [ranges[nextIdx]];
        }
      } /*else: select all ranges*/

      // do the actual selection
      ranges.forEach(sel.addRange.bind(sel));

    }
  },

  prettyPrintJS: {
    readOnly: false,
    exec: function(ed, options) {
      var selectedCode = ed.$morph.getSelectionOrLineString(),
          range = ed.$morph.getSelectionRangeAce(),
          startIndent = ed.$morph.getLine(ed.$morph.getCursorPositionAce().row, true).match(/^\s*/)[0].length,
          opts = {
            "indent_size": 2,
            "indent_char": " ",
            "eol": "\n",
            "indent_level": startIndent,
            "indent_with_tabs": false,
            "preserve_newlines": true,
            "max_preserve_newlines": 100,
            "jslint_happy": false,
            "space_after_anon_function": false,
            "brace_style": "collapse",
            "keep_array_indentation": false,
            "keep_function_indentation": false,
            "space_before_conditional": true,
            "break_chained_methods": false,
            "eval_code": false,
            "unescape_strings": false,
            "wrap_line_length": 0,
            "wrap_attributes": "auto",
            "wrap_attributes_indent_size": 2,
            "end_with_newline": false
        };

      Promise.resolve()
        .then(() => typeof js_beautify !== "undefined" ?
                     js_beautify : new Promise((resolve, reject) => {
                      JSLoader.loadJs(URL.root.withFilename("node_modules/js-beautify/js/lib/beautify.js").toString())
                      lively.lang.fun.waitFor(3000, () => typeof js_beautify !== "undefined",
                        (err) => err ? reject(err) : resolve(js_beautify)); }))
        .then(beautifier => js_beautify(selectedCode, opts))
        .then(prettyPrinted => ed.$morph.replace(range, prettyPrinted))
        .catch(err => ed.$morph.showError(err));
    }
  }

};

Object.extend(lively.ide.codeeditor.Commands, {

  allCommands: function() {
    return lively.lang.obj.merge({}, JavaScriptCommands);
  },

  attach: function(codeEditorMorph) {
    var cmds = lively.ide.codeeditor.Commands.allCommands();
    codeEditorMorph.withAceDo(function(ed) {
      ed.commands.addCommands(cmds); });
  },

  updateAll: function() {
    // lively.ide.codeeditor.Commands.updateAll();
    lively.ide.allCodeEditors().forEach(ea =>
      lively.ide.codeeditor.Commands.attach(ea));
  }

});

}) // end of module


text:
// ReSharper disable RedundantUsingDirective
using System;
using System.Collections.Generic;
using Microsoft.Isam.Esent.Interop;
using Microsoft.Isam.Esent.Interop.Vista;
using Microsoft.Isam.Esent.Interop.Windows10;
using System.Runtime.CompilerServices;
using System.Text;
// ReSharper enable RedundantUsingDirective

// ReSharper disable RedundantNameQualifier
// ReSharper disable once CheckNamespace
namespace Imageboard10.Core.ModelStorage.Blobs
{
	internal sealed class BlobsTable : IDisposable
	{
        public readonly Session Session;
        public readonly JET_TABLEID Table;

		public BlobsTable(Session session, JET_TABLEID table)
        {
            Session = session;
            Table = table;
			_columnDic = null;
			Columns = new DefaultView(this);
        }

	    public BlobsTable(Session session, JET_DBID dbid, string tableName, OpenTableGrbit grbit)
	    {
	        Session = session;
	        JET_TABLEID tableid;
	        Api.OpenTable(session, dbid, tableName, grbit, out tableid);
	        Table = tableid;
	        _columnDic = null;
	        Columns = new DefaultView(this);
	    }

        public void Dispose()
        {
            Api.JetCloseTable(Session, Table);
        }

        public static implicit operator JET_TABLEID(BlobsTable src)
        {
            return src.Table;
        }

		public enum Column
		{
			Id,
			Name,
			Category,
			Length,
			CreatedDate,
			Data,
			ReferenceId,
			IsCompleted,
			IsFilestream,
		}

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        public JET_COLUMNID GetColumnid(Column columnName)
        {
			switch (columnName)
			{
				case Column.Id:
					return Api.GetTableColumnid(Session, Table, "Id");
				case Column.Name:
					return Api.GetTableColumnid(Session, Table, "Name");
				case Column.Category:
					return Api.GetTableColumnid(Session, Table, "Category");
				case Column.Length:
					return Api.GetTableColumnid(Session, Table, "Length");
				case Column.CreatedDate:
					return Api.GetTableColumnid(Session, Table, "CreatedDate");
				case Column.Data:
					return Api.GetTableColumnid(Session, Table, "Data");
				case Column.ReferenceId:
					return Api.GetTableColumnid(Session, Table, "ReferenceId");
				case Column.IsCompleted:
					return Api.GetTableColumnid(Session, Table, "IsCompleted");
				case Column.IsFilestream:
					return Api.GetTableColumnid(Session, Table, "IsFilestream");
				default:
					throw new ArgumentOutOfRangeException();
			}
        }

		private IDictionary<Column, JET_COLUMNID> _columnDic;

        public IDictionary<Column, JET_COLUMNID> ColumnDictionary
        {
			[MethodImpl(MethodImplOptions.AggressiveInlining)]
			get {
				if (_columnDic == null) {
					_columnDic = new Dictionary<Column, JET_COLUMNID>()
					{
						{ Column.Id, Api.GetTableColumnid(Session, Table, "Id") },
						{ Column.Name, Api.GetTableColumnid(Session, Table, "Name") },
						{ Column.Category, Api.GetTableColumnid(Session, Table, "Category") },
						{ Column.Length, Api.GetTableColumnid(Session, Table, "Length") },
						{ Column.CreatedDate, Api.GetTableColumnid(Session, Table, "CreatedDate") },
						{ Column.Data, Api.GetTableColumnid(Session, Table, "Data") },
						{ Column.ReferenceId, Api.GetTableColumnid(Session, Table, "ReferenceId") },
						{ Column.IsCompleted, Api.GetTableColumnid(Session, Table, "IsCompleted") },
						{ Column.IsFilestream, Api.GetTableColumnid(Session, Table, "IsFilestream") },
					};
				}
				return _columnDic;
			}
        }

		public static void CreateColumnsAndIndexes(Session sid, JET_TABLEID tableid)
		{
			JET_COLUMNID tempcolid;
            Api.JetAddColumn(sid, tableid, "Id", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.Long,
				grbit = ColumndefGrbit.ColumnNotNULL | ColumndefGrbit.ColumnAutoincrement,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "Name", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.LongText,
				grbit = ColumndefGrbit.ColumnNotNULL,
				cp = JET_CP.Unicode,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "Category", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.LongText,
				grbit = ColumndefGrbit.None,
				cp = JET_CP.Unicode,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "Length", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.Currency,
				grbit = ColumndefGrbit.ColumnNotNULL,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "CreatedDate", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.DateTime,
				grbit = ColumndefGrbit.ColumnNotNULL,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "Data", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.LongBinary,
				grbit = ColumndefGrbit.ColumnTagged,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "ReferenceId", new JET_COLUMNDEF()
            {
				coltyp = VistaColtyp.GUID,
				grbit = ColumndefGrbit.ColumnTagged,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "IsCompleted", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.Bit,
				grbit = ColumndefGrbit.ColumnNotNULL,
            }, null, 0, out tempcolid);
            Api.JetAddColumn(sid, tableid, "IsFilestream", new JET_COLUMNDEF()
            {
				coltyp = JET_coltyp.Bit,
				grbit = ColumndefGrbit.ColumnNotNULL,
            }, null, 0, out tempcolid);
			var idxDef1 = "+Id\0\0";
			Api.JetCreateIndex(sid, tableid, "PrimaryIndex", CreateIndexGrbit.IndexUnique | CreateIndexGrbit.IndexPrimary, idxDef1, idxDef1.Length, 100);
			var idxDef2 = "+Name\0\0";
			Api.JetCreateIndex(sid, tableid, "NameIndex", CreateIndexGrbit.IndexUnique, idxDef2, idxDef2.Length, 100);
			var idxDef3 = "+Category\0+IsCompleted\0\0";
			Api.JetCreateIndex(sid, tableid, "CategoryIndex", CreateIndexGrbit.None, idxDef3, idxDef3.Length, 100);
			var idxDef4 = "+ReferenceId\0+IsCompleted\0\0";
			Api.JetCreateIndex(sid, tableid, "ReferenceIdIndex", CreateIndexGrbit.None, idxDef4, idxDef4.Length, 100);
			var idxDef5 = "+IsCompleted\0\0";
			Api.JetCreateIndex(sid, tableid, "IsCompletedIndex", CreateIndexGrbit.None, idxDef5, idxDef5.Length, 100);
		}

		public struct Multivalue<T> where T : ColumnValue, new()
        {
            private readonly BlobsTable _table;
            private readonly JET_RETRIEVECOLUMN[] _r;
            private readonly T[] _c;
            private readonly JET_COLUMNID _columnid;

            public Multivalue(BlobsTable table, JET_COLUMNID columnid)
            {
                _table = table;
                _r = new [] { new JET_RETRIEVECOLUMN() { columnid = columnid } };
                _c = new T[1];
                _columnid = columnid;
            }

            public void Clear()
            {
                var si = new JET_SETINFO() { itagSequence = 1 };
                for (var i = 0; i < Count; i++)
                {
                    Api.JetSetColumn(_table.Session, _table.Table, _columnid, null, 0, SetColumnGrbit.None, si);
                }
            }

            public int Count
            {
                get
                {
                    _r[0].itagSequence = 0;
                    Api.JetRetrieveColumns(_table.Session, _table, _r, 1);
                    return _r[0].itagSequence;
                }
            }

            public T this[int i]
            {
                get
                {
                    var col = new T
                    {
                        ItagSequence = i + 1,
                        Columnid = _columnid,
                        RetrieveGrbit = RetrieveColumnGrbit.None
                    };
                    _c[0] = col;
				    // ReSharper disable once CoVariantArrayConversion
                    Api.RetrieveColumns(_table.Session, _table.Table, _c);
                    return _c[0];
                }
				set
				{
                    _c[0] = value ?? throw new ArgumentNullException();
					_c[0].ItagSequence = i + 1;
					_c[0].Columnid = _columnid;
				    // ReSharper disable once CoVariantArrayConversion
                    Api.SetColumns(_table.Session, _table.Table, _c);
				}
            }

			public void Add(T value)
			{
                _c[0] = value ?? throw new ArgumentNullException();
				_c[0].ItagSequence = 0;
				_c[0].Columnid = _columnid;
				// ReSharper disable once CoVariantArrayConversion
                Api.SetColumns(_table.Session, _table.Table, _c);
			}

			public IEnumerable<T> Enumerate()
			{
                var cnt = Count;
				if (cnt == 0)
				{
					yield break;
				}
                for (var i = 0; i < cnt; i++)
                {
                    var col = new T
                    {
                        ItagSequence = i + 1,
                        Columnid = _columnid,
                        RetrieveGrbit = RetrieveColumnGrbit.None
                    };
                    _c[0] = col;
				    // ReSharper disable once CoVariantArrayConversion
                    Api.RetrieveColumns(_table.Session, _table.Table, _c);
					yield return _c[0];
                }
			}

            public T[] Values
            {
                get
                {
                    var cnt = Count;
					if (cnt == 0)
					{
						return new T[0];
					}
                    var r = new T[cnt];
                    for (var i = 0; i < cnt; i++)
                    {
                        var col = new T
                        {
                            ItagSequence = i + 1,
                            Columnid = _columnid,
                            RetrieveGrbit = RetrieveColumnGrbit.None
                        };
                        r[i] = col;
                    }
                    // ReSharper disable once CoVariantArrayConversion
                    Api.RetrieveColumns(_table.Session, _table.Table, r);
                    return r;
                }
				set => SetValues(value, false);
			}

			public void SetValues(T[] value, bool isInsert)
			{
				if (value == null)
				{
					throw new ArgumentNullException();
				}
				if (!isInsert)
				{
					Clear();
				}
				if (value.Length == 0)
				{
					return;
				}
                for (var i = 0; i < value.Length; i++)
                {
					value[i].ItagSequence = i + 1;
					value[i].Columnid = _columnid;
				}
				// ReSharper disable once CoVariantArrayConversion
                Api.SetColumns(_table.Session, _table.Table, value);
			}
        }

		public struct DefaultView
		{
			private readonly BlobsTable _table;

			public DefaultView(BlobsTable table)
			{
				_table = table;
			}
			public int Id
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsInt32(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Id]).Value;
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Id], value);

			}

		    // ReSharper disable once InconsistentNaming
			public int Id_AutoincrementValue
			{
				// ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsInt32(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Id], RetrieveColumnGrbit.RetrieveCopy).Value;
			}
			public string Name
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsString(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Name]);
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Name], value, Encoding.Unicode);

			}

			public string Category
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsString(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Category]);
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Category], value, Encoding.Unicode);

			}

			public long Length
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsInt64(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Length]).Value;
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Length], value);

			}

			public DateTime CreatedDate
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsDateTime(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.CreatedDate]).Value;
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.CreatedDate], value);

			}

			public byte[] Data
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Data]);
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.Data], value);

			}

			public Guid? ReferenceId
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsGuid(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.ReferenceId]);
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set {
					if (value != null)
					{
						Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.ReferenceId], value.Value);
					} else
					{
						Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.ReferenceId], null);
					}
				}
			}

			public bool IsCompleted
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsBoolean(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.IsCompleted]).Value;
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.IsCompleted], value);

			}

			public bool IsFilestream
			{
			    // ReSharper disable once PossibleInvalidOperationException
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				get => Api.RetrieveColumnAsBoolean(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.IsFilestream]).Value;
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
				set => Api.SetColumn(_table.Session, _table, _table.ColumnDictionary[BlobsTable.Column.IsFilestream], value);

			}

		}

		public DefaultView Columns { get; }

	    public IEnumerable<object> EnumerateToEnd()
	    {
			do {
	            yield return this;
			} while (Api.TryMoveNext(Session, Table));
	    }

	    public IEnumerable<object> EnumerateToEnd(int skip, int? maxCount)
	    {
			if (skip > 0)
			{
				if (!TryMove(skip))
				{
					yield break;
				}
			}
			do {
	            yield return this;
				if (maxCount != null)
				{
					maxCount--;
					if (maxCount <= 0)
					{
						break;
					}
				}
			} while (Api.TryMoveNext(Session, Table));
	    }

	    public IEnumerable<object> EnumerateToEnd(int? maxCount)
	    {
			do {
	            yield return this;
				if (maxCount != null)
				{
					maxCount--;
					if (maxCount <= 0)
					{
						break;
					}
				}
			} while (Api.TryMoveNext(Session, Table));
	    }

	    public IEnumerable<object> Enumerate()
	    {
			if (Api.TryMoveFirst(Session, Table))
			{
				do {
					yield return this;
				} while (Api.TryMoveNext(Session, Table));
			}
	    }

	    public IEnumerable<object> EnumerateUnique()
	    {
			if (Api.TryMoveFirst(Session, Table))
			{
				do {
					yield return this;
				} while (Api.TryMove(Session, Table, JET_Move.Next, MoveGrbit.MoveKeyNE));
			}
	    }

	    [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public void MoveBeforeFirst()
	    {
	        Api.MoveBeforeFirst(Session, Table);
	    }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public bool TryMoveFirst()
	    {
	        return Api.TryMoveFirst(Session, Table);
	    }

	    [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public bool TryMoveNext()
	    {
	        return Api.TryMoveNext(Session, Table);
	    }

	    [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public bool TryMoveNextUniqueKey()
	    {
	        return Api.TryMove(Session, Table, JET_Move.Next, MoveGrbit.MoveKeyNE);
	    }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public bool TryMovePrevious()
	    {
	        return Api.TryMovePrevious(Session, Table);
	    }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public bool TryMove(int delta)
	    {
	        return Api.TryMove(Session, Table, (JET_Move)delta, MoveGrbit.None);
	    }

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool TryGotoBookmark(byte[] bookmark)
		{
			if (bookmark == null)
			{
				throw new ArgumentNullException(nameof(bookmark));
			}
			return Api.TryGotoBookmark(Session, Table, bookmark, bookmark.Length);
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool TryGotoBookmark(byte[] bookmark, int bookmarkSize)
		{
			if (bookmark == null)
			{
				throw new ArgumentNullException(nameof(bookmark));
			}
			return Api.TryGotoBookmark(Session, Table, bookmark, bookmarkSize);
		}

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
	    public void DeleteCurrentRow()
	    {
	        Api.JetDelete(Session, Table);
	    }

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public byte[] GetBookmark()
		{
			return Api.GetBookmark(Session, Table);
		}

		public static class ViewValues
		{

			// ReSharper disable once InconsistentNaming
			public struct FullRowUpdate
			{
				public string Name;
				public string Category;
				public DateTime CreatedDate;
				public byte[] Data;
				public long Length;
				public Guid? ReferenceId;
				public bool IsCompleted;
				public bool IsFilestream;
			}

			// ReSharper disable once InconsistentNaming
			public struct CompletedUpdate
			{
				public long Length;
				public bool IsCompleted;
			}

			// ReSharper disable once InconsistentNaming
			public struct IdFromIndexView
			{
				public int Id;
			}
		}

		public static class FetchViews {

			// ReSharper disable once InconsistentNaming
			public struct FullRowUpdate
			{
				private readonly BlobsTable _table;
				private readonly ColumnValue[] _c;

				public FullRowUpdate(BlobsTable table)
				{
					_table = table;

					_c = new ColumnValue[8];
					_c[0] = new StringColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Name],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[1] = new StringColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Category],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[2] = new DateTimeColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.CreatedDate],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[3] = new BytesColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Data],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[4] = new Int64ColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Length],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[5] = new GuidColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.ReferenceId],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[6] = new BoolColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.IsCompleted],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
					_c[7] = new BoolColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.IsFilestream],
						RetrieveGrbit = RetrieveColumnGrbit.None
					};
				}

				public ViewValues.FullRowUpdate Fetch()
				{
					var r = new ViewValues.FullRowUpdate();
					Api.RetrieveColumns(_table.Session, _table, _c);
					r.Name = ((StringColumnValue)_c[0]).Value;
					r.Category = ((StringColumnValue)_c[1]).Value;
				    // ReSharper disable once PossibleInvalidOperationException
					r.CreatedDate = ((DateTimeColumnValue)_c[2]).Value.Value;
					r.Data = ((BytesColumnValue)_c[3]).Value;
				    // ReSharper disable once PossibleInvalidOperationException
					r.Length = ((Int64ColumnValue)_c[4]).Value.Value;
					r.ReferenceId = ((GuidColumnValue)_c[5]).Value;
				    // ReSharper disable once PossibleInvalidOperationException
					r.IsCompleted = ((BoolColumnValue)_c[6]).Value.Value;
				    // ReSharper disable once PossibleInvalidOperationException
					r.IsFilestream = ((BoolColumnValue)_c[7]).Value.Value;
					return r;
				}
			}

			// ReSharper disable once InconsistentNaming
			public struct IdFromIndexView
			{
				private readonly BlobsTable _table;
				private readonly ColumnValue[] _c;

				public IdFromIndexView(BlobsTable table)
				{
					_table = table;

					_c = new ColumnValue[1];
					_c[0] = new Int32ColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Id],
						RetrieveGrbit = RetrieveColumnGrbit.RetrieveFromPrimaryBookmark
					};
				}

				public ViewValues.IdFromIndexView Fetch()
				{
					var r = new ViewValues.IdFromIndexView();
					Api.RetrieveColumns(_table.Session, _table, _c);
				    // ReSharper disable once PossibleInvalidOperationException
					r.Id = ((Int32ColumnValue)_c[0]).Value.Value;
					return r;
				}
			}

		}

		public class TableFetchViews
		{
			private readonly BlobsTable _table;

			public TableFetchViews(BlobsTable table)
			{
				_table = table;
			}

		    // ReSharper disable once InconsistentNaming
			private FetchViews.FullRowUpdate? __fv_FullRowUpdate;
			public FetchViews.FullRowUpdate FullRowUpdate
			{
				get
				{
					if (__fv_FullRowUpdate == null)
					{
						__fv_FullRowUpdate = new FetchViews.FullRowUpdate(_table);
					}
					return __fv_FullRowUpdate.Value;
				}
			}

		    // ReSharper disable once InconsistentNaming
			private FetchViews.IdFromIndexView? __fv_IdFromIndexView;
			public FetchViews.IdFromIndexView IdFromIndexView
			{
				get
				{
					if (__fv_IdFromIndexView == null)
					{
						__fv_IdFromIndexView = new FetchViews.IdFromIndexView(_table);
					}
					return __fv_IdFromIndexView.Value;
				}
			}
		}

		// ReSharper disable once InconsistentNaming
		private TableFetchViews __views;

		public TableFetchViews Views
		{
			get
			{
				if (__views == null)
				{
					__views = new TableFetchViews(this);
				}
				return __views;
			}
		}

		public static class InsertOrUpdateViews
		{
			public struct FullRowUpdate
			{
				private readonly BlobsTable _table;
				private readonly ColumnValue[] _c;

				public FullRowUpdate(BlobsTable table)
				{
					_table = table;

					_c = new ColumnValue[8];
					_c[0] = new StringColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Name],
						SetGrbit = SetColumnGrbit.None
					};
					_c[1] = new StringColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Category],
						SetGrbit = SetColumnGrbit.None
					};
					_c[2] = new DateTimeColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.CreatedDate],
						SetGrbit = SetColumnGrbit.None
					};
					_c[3] = new BytesColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Data],
						SetGrbit = SetColumnGrbit.None
					};
					_c[4] = new Int64ColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Length],
						SetGrbit = SetColumnGrbit.None
					};
					_c[5] = new GuidColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.ReferenceId],
						SetGrbit = SetColumnGrbit.None
					};
					_c[6] = new BoolColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.IsCompleted],
						SetGrbit = SetColumnGrbit.None
					};
					_c[7] = new BoolColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.IsFilestream],
						SetGrbit = SetColumnGrbit.None
					};
				}

				public void Set(ViewValues.FullRowUpdate value, bool isInsert = false)
				{
					((StringColumnValue)_c[0]).Value = value.Name;
					((StringColumnValue)_c[1]).Value = value.Category;
					((DateTimeColumnValue)_c[2]).Value = value.CreatedDate;
					((BytesColumnValue)_c[3]).Value = value.Data;
					((Int64ColumnValue)_c[4]).Value = value.Length;
					((GuidColumnValue)_c[5]).Value = value.ReferenceId;
					((BoolColumnValue)_c[6]).Value = value.IsCompleted;
					((BoolColumnValue)_c[7]).Value = value.IsFilestream;
					Api.SetColumns(_table.Session, _table, _c);
				}

				public void Set(ref ViewValues.FullRowUpdate value, bool isInsert = false)
				{
					((StringColumnValue)_c[0]).Value = value.Name;
					((StringColumnValue)_c[1]).Value = value.Category;
					((DateTimeColumnValue)_c[2]).Value = value.CreatedDate;
					((BytesColumnValue)_c[3]).Value = value.Data;
					((Int64ColumnValue)_c[4]).Value = value.Length;
					((GuidColumnValue)_c[5]).Value = value.ReferenceId;
					((BoolColumnValue)_c[6]).Value = value.IsCompleted;
					((BoolColumnValue)_c[7]).Value = value.IsFilestream;
					Api.SetColumns(_table.Session, _table, _c);
				}
			}
			public struct CompletedUpdate
			{
				private readonly BlobsTable _table;
				private readonly ColumnValue[] _c;

				public CompletedUpdate(BlobsTable table)
				{
					_table = table;

					_c = new ColumnValue[2];
					_c[0] = new Int64ColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.Length],
						SetGrbit = SetColumnGrbit.None
					};
					_c[1] = new BoolColumnValue() {
						Columnid = _table.ColumnDictionary[BlobsTable.Column.IsCompleted],
						SetGrbit = SetColumnGrbit.None
					};
				}

				public void Set(ViewValues.CompletedUpdate value, bool isInsert = false)
				{
					((Int64ColumnValue)_c[0]).Value = value.Length;
					((BoolColumnValue)_c[1]).Value = value.IsCompleted;
					Api.SetColumns(_table.Session, _table, _c);
				}

				public void Set(ref ViewValues.CompletedUpdate value, bool isInsert = false)
				{
					((Int64ColumnValue)_c[0]).Value = value.Length;
					((BoolColumnValue)_c[1]).Value = value.IsCompleted;
					Api.SetColumns(_table.Session, _table, _c);
				}
			}
		}

		public class TableInsertViews
		{
			private readonly BlobsTable _table;

			public TableInsertViews(BlobsTable table)
			{
				_table = table;
			}

			public Update CreateUpdate() => new Update(_table.Session, _table, JET_prep.Insert);

			private byte[] _bookmarkBuffer;

			private void EnsureBookmarkBuffer()
			{
				if (_bookmarkBuffer == null)
				{
					_bookmarkBuffer = new byte[SystemParameters.BookmarkMost];
				}
			}

			public void SaveUpdateWithBookmark(Update update, out byte[] bookmark)
			{
				EnsureBookmarkBuffer();
				int bsize;
				update.Save(_bookmarkBuffer, _bookmarkBuffer.Length, out bsize);
				bookmark = new byte[bsize];
				Array.Copy(_bookmarkBuffer, bookmark, bsize);
			}

		    // ReSharper disable once InconsistentNaming
			private InsertOrUpdateViews.FullRowUpdate? __iuv_FullRowUpdate;

			public InsertOrUpdateViews.FullRowUpdate FullRowUpdate
			{
				get
				{
					if (__iuv_FullRowUpdate == null)
					{
						__iuv_FullRowUpdate = new InsertOrUpdateViews.FullRowUpdate(_table);
					}
					return __iuv_FullRowUpdate.Value;
				}
			}

			public void InsertAsFullRowUpdate(ViewValues.FullRowUpdate value)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(value, true);
					update.Save();
				}
			}

			public void InsertAsFullRowUpdate(ref ViewValues.FullRowUpdate value)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(ref value, true);
					update.Save();
				}
			}

			public void InsertAsFullRowUpdate(ViewValues.FullRowUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(value, true);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}

			public void InsertAsFullRowUpdate(ref ViewValues.FullRowUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(ref value, true);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}
		}

		// ReSharper disable once InconsistentNaming
		private TableInsertViews __insert;

		public TableInsertViews Insert
		{
			get
			{
				if (__insert == null)
				{
					__insert = new TableInsertViews(this);
				}
				return __insert;
			}
		}

		public class TableUpdateViews
		{
			private readonly BlobsTable _table;

			public TableUpdateViews(BlobsTable table)
			{
				_table = table;
			}

			public Update CreateUpdate() => new Update(_table.Session, _table, JET_prep.Replace);

			private byte[] _bookmarkBuffer;

			private void EnsureBookmarkBuffer()
			{
				if (_bookmarkBuffer == null)
				{
					_bookmarkBuffer = new byte[SystemParameters.BookmarkMost];
				}
			}

			public void SaveUpdateWithBookmark(Update update, out byte[] bookmark)
			{
				EnsureBookmarkBuffer();
				int bsize;
				update.Save(_bookmarkBuffer, _bookmarkBuffer.Length, out bsize);
				bookmark = new byte[bsize];
				Array.Copy(_bookmarkBuffer, bookmark, bsize);
			}

		    // ReSharper disable once InconsistentNaming
			private InsertOrUpdateViews.FullRowUpdate? __iuv_FullRowUpdate;

			public InsertOrUpdateViews.FullRowUpdate FullRowUpdate
			{
				get
				{
					if (__iuv_FullRowUpdate == null)
					{
						__iuv_FullRowUpdate = new InsertOrUpdateViews.FullRowUpdate(_table);
					}
					return __iuv_FullRowUpdate.Value;
				}
			}

			public void UpdateAsFullRowUpdate(ViewValues.FullRowUpdate value)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(value);
					update.Save();
				}
			}

			public void UpdateAsFullRowUpdate(ref ViewValues.FullRowUpdate value)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(ref value);
					update.Save();
				}
			}

			public void UpdateAsFullRowUpdate(ViewValues.FullRowUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(value);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}

			public void UpdateAsFullRowUpdate(ref ViewValues.FullRowUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					FullRowUpdate.Set(ref value);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}

		    // ReSharper disable once InconsistentNaming
			private InsertOrUpdateViews.CompletedUpdate? __iuv_CompletedUpdate;

			public InsertOrUpdateViews.CompletedUpdate CompletedUpdate
			{
				get
				{
					if (__iuv_CompletedUpdate == null)
					{
						__iuv_CompletedUpdate = new InsertOrUpdateViews.CompletedUpdate(_table);
					}
					return __iuv_CompletedUpdate.Value;
				}
			}

			public void UpdateAsCompletedUpdate(ViewValues.CompletedUpdate value)
			{
				using (var update = CreateUpdate())
				{
					CompletedUpdate.Set(value);
					update.Save();
				}
			}

			public void UpdateAsCompletedUpdate(ref ViewValues.CompletedUpdate value)
			{
				using (var update = CreateUpdate())
				{
					CompletedUpdate.Set(ref value);
					update.Save();
				}
			}

			public void UpdateAsCompletedUpdate(ViewValues.CompletedUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					CompletedUpdate.Set(value);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}

			public void UpdateAsCompletedUpdate(ref ViewValues.CompletedUpdate value, out byte[] bookmark)
			{
				using (var update = CreateUpdate())
				{
					CompletedUpdate.Set(ref value);
					SaveUpdateWithBookmark(update, out bookmark);
				}
			}
		}

		// ReSharper disable once InconsistentNaming
		private TableUpdateViews __update;

		public TableUpdateViews Update
		{
			get
			{
				if (__update == null)
				{
					__update = new TableUpdateViews(this);
				}
				return __update;
			}
		}

		public static class IndexDefinitions
		{

			public struct PrimaryIndex
			{
				private readonly BlobsTable _table;

				public PrimaryIndex(BlobsTable table)
				{
					_table = table;
				}

				public void SetAsCurrentIndex()
				{
					Api.JetSetCurrentIndex(_table.Session, _table, "PrimaryIndex");
				}

				public struct PrimaryIndexKey
				{
					public int Id;
				}

			    // ReSharper disable InconsistentNaming
				public PrimaryIndexKey CreateKey(
						int Id
				)
			    // ReSharper enable InconsistentNaming
				{
					return new PrimaryIndexKey() {
						Id = Id,

					};
				}

				public void SetKey(PrimaryIndexKey key)
				{
					Api.MakeKey(_table.Session, _table, key.Id,  MakeKeyGrbit.NewKey);
				}

				public bool Find(PrimaryIndexKey key)
				{
					SetKey(key);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange);
				}

				public IEnumerable<object> Enumerate(PrimaryIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMoveNext(_table.Session, _table));
					}
				}

				public IEnumerable<object> EnumerateUnique(PrimaryIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMove(_table.Session, _table, JET_Move.Next, MoveGrbit.MoveKeyNE));
					}
				}

			    public int GetIndexRecordCount()
			    {
			        int r;
			        Api.JetIndexRecordCount(_table.Session, _table, out r, int.MaxValue);
			        return r;
			    }

			    public int GetIndexRecordCount(PrimaryIndexKey key)
			    {
			        if (!Find(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

			}

			public struct NameIndex
			{
				private readonly BlobsTable _table;

				public NameIndex(BlobsTable table)
				{
					_table = table;
				}

				public void SetAsCurrentIndex()
				{
					Api.JetSetCurrentIndex(_table.Session, _table, "NameIndex");
				}

				public struct NameIndexKey
				{
					public string Name;
				}

			    // ReSharper disable InconsistentNaming
				public NameIndexKey CreateKey(
						string Name
				)
			    // ReSharper enable InconsistentNaming
				{
					return new NameIndexKey() {
						Name = Name,

					};
				}

				public void SetKey(NameIndexKey key)
				{
					Api.MakeKey(_table.Session, _table, key.Name, Encoding.Unicode, MakeKeyGrbit.NewKey);
				}

				public bool Find(NameIndexKey key)
				{
					SetKey(key);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange);
				}

				public IEnumerable<object> Enumerate(NameIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMoveNext(_table.Session, _table));
					}
				}

				public IEnumerable<object> EnumerateUnique(NameIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMove(_table.Session, _table, JET_Move.Next, MoveGrbit.MoveKeyNE));
					}
				}

			    public int GetIndexRecordCount()
			    {
			        int r;
			        Api.JetIndexRecordCount(_table.Session, _table, out r, int.MaxValue);
			        return r;
			    }

			    public int GetIndexRecordCount(NameIndexKey key)
			    {
			        if (!Find(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

			}

			public struct CategoryIndex
			{
				private readonly BlobsTable _table;

				public CategoryIndex(BlobsTable table)
				{
					_table = table;
				}

				public void SetAsCurrentIndex()
				{
					Api.JetSetCurrentIndex(_table.Session, _table, "CategoryIndex");
				}

				public struct CategoryIndexKey
				{
					public string Category;
					public bool IsCompleted;
				}

			    // ReSharper disable InconsistentNaming
				public CategoryIndexKey CreateKey(
						string Category
						,bool IsCompleted
				)
			    // ReSharper enable InconsistentNaming
				{
					return new CategoryIndexKey() {
						Category = Category,
						IsCompleted = IsCompleted,

					};
				}

				public void SetKey(CategoryIndexKey key)
				{
					Api.MakeKey(_table.Session, _table, key.Category, Encoding.Unicode, MakeKeyGrbit.NewKey);
					Api.MakeKey(_table.Session, _table, key.IsCompleted,  MakeKeyGrbit.None);
				}

				public bool Find(CategoryIndexKey key)
				{
					SetKey(key);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange);
				}

				public IEnumerable<object> Enumerate(CategoryIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMoveNext(_table.Session, _table));
					}
				}

				public IEnumerable<object> EnumerateUnique(CategoryIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMove(_table.Session, _table, JET_Move.Next, MoveGrbit.MoveKeyNE));
					}
				}

			    public int GetIndexRecordCount()
			    {
			        int r;
			        Api.JetIndexRecordCount(_table.Session, _table, out r, int.MaxValue);
			        return r;
			    }

			    public int GetIndexRecordCount(CategoryIndexKey key)
			    {
			        if (!Find(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

				public struct CategoryIndexPartialKey1
				{
					public string Category;
				}

			    // ReSharper disable InconsistentNaming
				public CategoryIndexPartialKey1 CreateKey(
						string Category
				)
			    // ReSharper enable InconsistentNaming
				{
					return new CategoryIndexPartialKey1() {
						Category = Category,

					};
				}

				public void SetKey(CategoryIndexPartialKey1 key, bool startRange)
				{
					var rangeFlag = startRange ? MakeKeyGrbit.FullColumnStartLimit : MakeKeyGrbit.FullColumnEndLimit;
					Api.MakeKey(_table.Session, _table, key.Category, Encoding.Unicode, MakeKeyGrbit.NewKey | rangeFlag);
				}

				public bool Find(CategoryIndexPartialKey1 key)
				{
					SetKey(key, true);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekGE);
				}

				public bool SetPartialUpperRange(CategoryIndexPartialKey1 key)
				{
					SetKey(key, false);
					return Api.TrySetIndexRange(_table.Session, _table, SetIndexRangeGrbit.RangeUpperLimit);
				}

				public bool SeekPartial(CategoryIndexPartialKey1 key)
				{
					if (Find(key))
					{
						if (SetPartialUpperRange(key))
						{
							return true;
						}
					}
					return false;
				}

				public IEnumerable<object> Enumerate(CategoryIndexPartialKey1 key)
				{
					SetKey(key, true);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekGE))
					{
						SetKey(key, false);
						if (Api.TrySetIndexRange(_table.Session, _table, SetIndexRangeGrbit.RangeUpperLimit))
						{
							do {
								yield return _table;
							} while (Api.TryMoveNext(_table.Session, _table));
						}
					}
				}

				public int GetIndexRecordCount(CategoryIndexPartialKey1 key)
			    {
					if (!SeekPartial(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

			}

			public struct ReferenceIdIndex
			{
				private readonly BlobsTable _table;

				public ReferenceIdIndex(BlobsTable table)
				{
					_table = table;
				}

				public void SetAsCurrentIndex()
				{
					Api.JetSetCurrentIndex(_table.Session, _table, "ReferenceIdIndex");
				}

				public struct ReferenceIdIndexKey
				{
					public Guid? ReferenceId;
					public bool IsCompleted;
				}

			    // ReSharper disable InconsistentNaming
				public ReferenceIdIndexKey CreateKey(
						Guid? ReferenceId
						,bool IsCompleted
				)
			    // ReSharper enable InconsistentNaming
				{
					return new ReferenceIdIndexKey() {
						ReferenceId = ReferenceId,
						IsCompleted = IsCompleted,

					};
				}

				public void SetKey(ReferenceIdIndexKey key)
				{
					if (key.ReferenceId == null)
					{
						Api.MakeKey(_table.Session, _table, null, MakeKeyGrbit.NewKey);
					} else
					{
						Api.MakeKey(_table.Session, _table, key.ReferenceId.Value, MakeKeyGrbit.NewKey);
					}
					Api.MakeKey(_table.Session, _table, key.IsCompleted,  MakeKeyGrbit.None);
				}

				public bool Find(ReferenceIdIndexKey key)
				{
					SetKey(key);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange);
				}

				public IEnumerable<object> Enumerate(ReferenceIdIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMoveNext(_table.Session, _table));
					}
				}

				public IEnumerable<object> EnumerateUnique(ReferenceIdIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMove(_table.Session, _table, JET_Move.Next, MoveGrbit.MoveKeyNE));
					}
				}

			    public int GetIndexRecordCount()
			    {
			        int r;
			        Api.JetIndexRecordCount(_table.Session, _table, out r, int.MaxValue);
			        return r;
			    }

			    public int GetIndexRecordCount(ReferenceIdIndexKey key)
			    {
			        if (!Find(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

				public struct ReferenceIdIndexPartialKey1
				{
					public Guid? ReferenceId;
				}

			    // ReSharper disable InconsistentNaming
				public ReferenceIdIndexPartialKey1 CreateKey(
						Guid? ReferenceId
				)
			    // ReSharper enable InconsistentNaming
				{
					return new ReferenceIdIndexPartialKey1() {
						ReferenceId = ReferenceId,

					};
				}

				public void SetKey(ReferenceIdIndexPartialKey1 key, bool startRange)
				{
					var rangeFlag = startRange ? MakeKeyGrbit.FullColumnStartLimit : MakeKeyGrbit.FullColumnEndLimit;
					if (key.ReferenceId == null)
					{
						Api.MakeKey(_table.Session, _table, null, MakeKeyGrbit.NewKey | rangeFlag);
					} else
					{
						Api.MakeKey(_table.Session, _table, key.ReferenceId.Value, MakeKeyGrbit.NewKey | rangeFlag);
					}
				}

				public bool Find(ReferenceIdIndexPartialKey1 key)
				{
					SetKey(key, true);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekGE);
				}

				public bool SetPartialUpperRange(ReferenceIdIndexPartialKey1 key)
				{
					SetKey(key, false);
					return Api.TrySetIndexRange(_table.Session, _table, SetIndexRangeGrbit.RangeUpperLimit);
				}

				public bool SeekPartial(ReferenceIdIndexPartialKey1 key)
				{
					if (Find(key))
					{
						if (SetPartialUpperRange(key))
						{
							return true;
						}
					}
					return false;
				}

				public IEnumerable<object> Enumerate(ReferenceIdIndexPartialKey1 key)
				{
					SetKey(key, true);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekGE))
					{
						SetKey(key, false);
						if (Api.TrySetIndexRange(_table.Session, _table, SetIndexRangeGrbit.RangeUpperLimit))
						{
							do {
								yield return _table;
							} while (Api.TryMoveNext(_table.Session, _table));
						}
					}
				}

				public int GetIndexRecordCount(ReferenceIdIndexPartialKey1 key)
			    {
					if (!SeekPartial(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

			}

			public struct IsCompletedIndex
			{
				private readonly BlobsTable _table;

				public IsCompletedIndex(BlobsTable table)
				{
					_table = table;
				}

				public void SetAsCurrentIndex()
				{
					Api.JetSetCurrentIndex(_table.Session, _table, "IsCompletedIndex");
				}

				public struct IsCompletedIndexKey
				{
					public bool IsCompleted;
				}

			    // ReSharper disable InconsistentNaming
				public IsCompletedIndexKey CreateKey(
						bool IsCompleted
				)
			    // ReSharper enable InconsistentNaming
				{
					return new IsCompletedIndexKey() {
						IsCompleted = IsCompleted,

					};
				}

				public void SetKey(IsCompletedIndexKey key)
				{
					Api.MakeKey(_table.Session, _table, key.IsCompleted,  MakeKeyGrbit.NewKey);
				}

				public bool Find(IsCompletedIndexKey key)
				{
					SetKey(key);
					return Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange);
				}

				public IEnumerable<object> Enumerate(IsCompletedIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMoveNext(_table.Session, _table));
					}
				}

				public IEnumerable<object> EnumerateUnique(IsCompletedIndexKey key)
				{
					SetKey(key);
					if (Api.TrySeek(_table.Session, _table, SeekGrbit.SeekEQ | SeekGrbit.SetIndexRange))
					{
						do {
							yield return _table;
						} while (Api.TryMove(_table.Session, _table, JET_Move.Next, MoveGrbit.MoveKeyNE));
					}
				}

			    public int GetIndexRecordCount()
			    {
			        int r;
			        Api.JetIndexRecordCount(_table.Session, _table, out r, int.MaxValue);
			        return r;
			    }

			    public int GetIndexRecordCount(IsCompletedIndexKey key)
			    {
			        if (!Find(key))
					{
						return 0;
					}
			        return GetIndexRecordCount();
			    }

			}
		}

		public class TableIndexes
		{
			private readonly BlobsTable _table;

			public TableIndexes(BlobsTable table)
			{
				_table = table;
			}

		    // ReSharper disable once InconsistentNaming
			private IndexDefinitions.PrimaryIndex? __ti_PrimaryIndex;

			public IndexDefinitions.PrimaryIndex PrimaryIndex
			{
				get
				{
					if (__ti_PrimaryIndex == null)
					{
						__ti_PrimaryIndex = new IndexDefinitions.PrimaryIndex(_table);
					}
					return __ti_PrimaryIndex.Value;
				}
			}

		    // ReSharper disable once InconsistentNaming
			private IndexDefinitions.NameIndex? __ti_NameIndex;

			public IndexDefinitions.NameIndex NameIndex
			{
				get
				{
					if (__ti_NameIndex == null)
					{
						__ti_NameIndex = new IndexDefinitions.NameIndex(_table);
					}
					return __ti_NameIndex.Value;
				}
			}

		    // ReSharper disable once InconsistentNaming
			private IndexDefinitions.CategoryIndex? __ti_CategoryIndex;

			public IndexDefinitions.CategoryIndex CategoryIndex
			{
				get
				{
					if (__ti_CategoryIndex == null)
					{
						__ti_CategoryIndex = new IndexDefinitions.CategoryIndex(_table);
					}
					return __ti_CategoryIndex.Value;
				}
			}

		    // ReSharper disable once InconsistentNaming
			private IndexDefinitions.ReferenceIdIndex? __ti_ReferenceIdIndex;

			public IndexDefinitions.ReferenceIdIndex ReferenceIdIndex
			{
				get
				{
					if (__ti_ReferenceIdIndex == null)
					{
						__ti_ReferenceIdIndex = new IndexDefinitions.ReferenceIdIndex(_table);
					}
					return __ti_ReferenceIdIndex.Value;
				}
			}

		    // ReSharper disable once InconsistentNaming
			private IndexDefinitions.IsCompletedIndex? __ti_IsCompletedIndex;

			public IndexDefinitions.IsCompletedIndex IsCompletedIndex
			{
				get
				{
					if (__ti_IsCompletedIndex == null)
					{
						__ti_IsCompletedIndex = new IndexDefinitions.IsCompletedIndex(_table);
					}
					return __ti_IsCompletedIndex.Value;
				}
			}
		}

		// ReSharper disable once InconsistentNaming
		private TableIndexes __indexes;

		public TableIndexes Indexes
		{
			get
			{
				if (__indexes == null)
				{
					__indexes = new TableIndexes(this);
				}
				return __indexes;
			}
		}
	}
}
// ReSharper enable RedundantNameQualifier

redpajama_set_name: RedPajamaGithub


text:
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

/**
 * @fileoverview IE specific atoms.
 */

goog.provide('webdriver.ie');

goog.require('bot.dom');
goog.require('bot.Error');
goog.require('bot.ErrorCode');
goog.require('bot.locators');
goog.require('bot.userAgent');
goog.require('goog.dom.TagName');
goog.require('goog.style');

/**
 * Find the first element in the DOM matching the mechanism and critera.
 *
 * @param {!string} mechanism The mechanism to search by.
 * @param {!string} criteria The criteria to search for.
 * @param {(Document|Element)=} opt_root The node from which to start the
 *     search. If not specified, will use {@code document} as the root.
 * @return {Element} The first matching element found in the DOM, or null if no
 *     such element could be found.
 */
webdriver.ie.findElement = function(mechanism, criteria, opt_root) {
  var locator = {};
  locator[mechanism] = criteria;
  return bot.locators.findElement(locator, opt_root);
};

/**
 * Find all elements in the DOM matching the mechanism and critera.
 *
 * @param {!string} mechanism The mechanism to search by.
 * @param {!string} criteria The criteria to search for.
 * @param {(Document|Element)=} opt_root The node from which to start the
 *     search. If not specified, will use {@code document} as the root.
 * @return {!goog.array.ArrayLike.<Element>} All matching elements found in the
 *     DOM.
 */
webdriver.ie.findElements = function(mechanism, criteria, opt_root) {
  // For finding multiple elements by class name in IE, if the document
  // mode is below 8 (which includes quirks mode), the findElements atom
  // drops into a branch of the Closure library that doesn't validate
  // that the class name is valid, and therefore just returns an empty
  // array. Thus, we pre-screen the class name in this special case.
  // Note: the regex used herein may not be entirely correct; judging
  // this to be an acceptable risk due to the (hopefully) limited nature
  // of the bug.
  if (mechanism == 'className' && bot.userAgent.IE_DOC_PRE8) {
    var invalidTokenRegex = /[~!@\$%\^&\*\(\)_\+=,\.\/';:"\?><\[\]\\\{\}\|`#]+/;
    if (invalidTokenRegex.test(criteria)) {
      throw new bot.Error(bot.ErrorCode.INVALID_SELECTOR_ERROR,
                          'Invalid character in class name.');
    }
  }
  var locator = {};
  locator[mechanism] = criteria;
  return bot.locators.findElements(locator, opt_root);
};

/**
 * Checks whether the element is currently scrolled into the parent's overflow
 * region, such that the offset given, relative to the top-left corner of the
 * element, is currently in the overflow region.
 *
 * @param {!Element} element The element to check.
 * @return {bot.dom.OverflowState} Whether the coordinates specified, relative to the element,
 *     are scrolled in the parent overflow.
 */
webdriver.ie.isInParentOverflow = function(element) {
  var rect = bot.dom.getClientRect(element);
  var x = Math.round(rect.width / 2);
  var y = Math.round(rect.height / 2);
  var center = new goog.math.Coordinate(x, y);
  return bot.dom.getOverflowState(element, center);
};


text:
package S71200URLCommunicator.Enums;

public enum BlackoutCommand{
    Disable,
    Enable
}


text:
@layout('layouts.default')

@section('content')
	@if($errors->has())

				<?php $messages = $errors->all('
:message
') ?>
				@foreach($messages as $message)
					{{ $message }}
				@endforeach

	@endif
	{{ Form::open('add_comment_reply', 'POST') }}

	{{ Form:: token() }}

		    {{ Form::label('body', 'Comment') }}
		    {{ Form::textarea('body', Input::old('body')) }}

			My comment is
			{{ Form::select('endorsing', array('1' => 'Endorsing', '0' => 'Protesting'), 'Endorsing'); }}
			this stance.

			{{ Form::hidden('parent_comment_id', $parent_comment_id) }}

		    {{ Form::submit('Add Comment') }}

	{{ Form::close() }}

@endsection


text:
#timeline-overview-panel {
    flex: none;
    position: relative;
    border-bottom: 1px solid rgb(140, 140, 140);
}

#timeline-overview-panel .timeline-graph-bar {
    pointer-events: none;
}

.timeline-records-title, .timeline-records-list {
    background-color: #eee;
}

.timeline-records-title {
    padding: 3px 3px 3px 5px;
    flex: 0 0 19px;
    color: rgb(92, 110, 129); text-shadow: rgba(255, 255, 255, 0.75) 0 1px 0;
}

.timeline-records-list {
    flex: auto;
}

#timeline-overview-grid {
    background-color: rgb(255, 255, 255);
}

.timeline-overview-frames-mode #timeline-overview-grid {
    display: none;
}

#timeline-overview-grid .resources-dividers-label-bar {
    pointer-events: auto;
}

.timeline-overview-frames-mode .overview-grid-window,
.timeline-overview-frames-mode .overview-grid-dividers-background {
    height: 100%;
}

#timeline-container {
    border-right: 0 none transparent;
    overflow-y: scroll;
    overflow-x: hidden;
}

.timeline-details-split {
    flex: auto;
}

.timeline-view {
    flex: auto;
    overflow: auto;
}

.timeline-view-stack {
    flex: auto;
    display: flex;
}

#timeline-container .webkit-html-external-link,
#timeline-container .webkit-html-resource-link {
    color: inherit;
}

.timeline-tree-item {
    height: 18px;
    line-height: 15px;
    padding-right: 5px;
    padding-left: 5px;
    padding-top: 2px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.timeline-tree-item.selected {
    background-color: rgb(56, 121, 217) !important;
    color: white;
}

.timeline-tree-item.hovered:not(.selected),
.timeline-graph-side.hovered {
    background-color: rgba(0, 0, 0, 0.05) !important;
}

.timeline-expandable {
    position: absolute;
    border-left: 1px solid rgb(163, 163, 163);
    pointer-events: none;
}

.timeline-expandable-left {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 3px;
    border-top: 1px solid rgb(163, 163, 163);
    border-bottom: 1px solid rgb(163, 163, 163);
}

.timeline-tree-item-expand-arrow {
    display: inline-block;
    -webkit-user-select: none;
    -webkit-mask-image: url(Images/statusbarButtonGlyphs.png);
    -webkit-mask-size: 320px 144px;
    width: 10px;
    height: 10px;
    content: "";
    background-color: rgb(110, 110, 110);
    position: relative;
    top: -1px;
    left: -1px;
}

@media (-webkit-min-device-pixel-ratio: 1.5) {
.timeline-tree-item-expand-arrow {
    -webkit-mask-image: url(Images/statusbarButtonGlyphs_2x.png);
}
} /* media */

.timeline-tree-item-expand-arrow.parent {
    -webkit-mask-position: -4px -96px;
}

.timeline-tree-item-expand-arrow.parent.expanded {
    -webkit-mask-position: -20px -96px;
}

.timeline-expandable-arrow {
    background-image: url(Images/statusbarButtonGlyphs.png);
    background-size: 320px 144px;
    opacity: 0.5;
    width: 10px;
    height: 10px;
    position: relative;
    top: 3px;
    left: 2px;
}

@media (-webkit-min-device-pixel-ratio: 1.5) {
.timeline-expandable-arrow {
    background-image: url(Images/statusbarButtonGlyphs_2x.png);
}
} /* media */

.timeline-expandable-collapsed .timeline-expandable-arrow {
    background-position: -4px -96px;
}

.timeline-expandable-expanded .timeline-expandable-arrow {
    background-position: -20px -96px;
}

.timeline-tree-item .type {
    padding-left: 5px;
}

.timeline-tree-item .count {
    font-weight: bold;
}

.timeline-tree-item .timeline-tree-icon {
    position: relative;
    top: -1px;
    left: 1px;
    width: 7px;
    height: 7px;
    border-radius: 1px;
    border-style: solid;
    border-width: 1px;
    display: inline-block;
}

.timeline-tree-item.background .timeline-tree-icon {
    background: none !important;
}

.timeline-tree-item-warning {
    display: block;
    background-image: url(Images/statusbarButtonGlyphs.png);
    background-size: 320px 144px;
    width: 10px;
    height: 10px;
    float: right;
    background-position: -202px -107px;
    position: relative;
    top: 2px;
}

.timeline-tree-item-child-warning {
    opacity: 0.6;
}

@media (-webkit-min-device-pixel-ratio: 1.5) {
.timeline-tree-item-warning {
    background-image: url(Images/statusbarButtonGlyphs_2x.png);
}
} /* media */

.timeline-tree-item .data.dimmed {
    color: rgba(0, 0, 0, 0.7);
    pointer-events: none;
    padding-left: 4px;
}

.timeline-tree-item.selected .data.dimmed {
    color: rgba(255, 255, 255, 0.8);
    pointer-events: auto;
}

.timeline-tree-item.selected .timeline-tree-item-expand-arrow {
    background-color: white;
}

#timeline-overview-events,
#timeline-overview-memory,
#timeline-overview-power {
    flex: 0 0 60px;
    z-index: 160;
    width: 100%;
}

#timeline-overview-memory {
    flex-basis: 20px;
}

#timeline-overview-frames {
    flex-basis: 79px;
}

#timeline-overview-pane {
    flex: auto;
    position: relative;
    overflow: hidden;
}

#timeline-overview-container {
    display: flex;
    flex-direction: column;
    flex: none;
    position: relative;
    overflow: hidden;
}

#timeline-overview-container canvas {
    width: 100%;
    height: 100%;
}

#timeline-overview-frames canvas {
    z-index: 200;
    background-color: rgba(255, 255, 255, 0.8);
}

#timeline-graphs {
    position: absolute;
    left: 0;
    right: 0;
    max-height: 100%;
    top: 20px;
}

.timeline-graph-side {
    position: relative;
    height: 18px;
    padding: 0 5px;
    white-space: nowrap;
    margin-top: 0;
    border-top: 1px solid transparent;
    overflow: hidden;
}

.timeline-graph-side.selected {
    background-color: rgba(56, 121, 217, 0.1) !important;
}

.timeline-graph-bar-area {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 3px;
    pointer-events: none;
}

.timeline-graph-bar {
    position: absolute;
    top: -1px;
    bottom: 0;
    margin: auto -2px;
    height: 10px;
    min-width: 5px;
    z-index: 180;
    pointer-events: visibleFill;
    border-radius: 1px;
    border: 1px solid;
}

.timeline-graph-bar.cpu {
    opacity: 0.7;
}

.timeline-graph-side.background .timeline-graph-bar {
    background: transparent !important;
    border-width: 2px;
}

.timeline-aggregated-category {
    display: inline-block;
    height: 11px;
    margin-right: 5px;
    position: relative;
    top: 2px;
    width: 10px;
    border: solid 1px;
}

.popover ul {
    margin: 0;
    padding: 0;
    list-style-type: none;
}

#resources-container-content {
    overflow: hidden;
    min-height: 100%;
}

.memory-graph-label {
    position: absolute;
    left: 5px;
    font-size: 9px;
    color: rgb(50%, 50%, 50%);
    white-space: nowrap;
}

#memory-graphs-canvas-container {
    overflow: hidden;
    flex: auto;
    position: relative;
}

#memory-counters-graph {
    flex: auto;
}

#memory-graphs-canvas-container .memory-counter-marker {
    position: absolute;
    border-radius: 3px;
    width: 5px;
    height: 5px;
    margin-left: -3px;
    margin-top: -2px;
}

#memory-graphs-container > div:last-child {
    background-color: #eee;
    overflow-y: hidden;
}

#memory-graphs-container .sidebar-tree-section {
    flex: 0 0 24px;
    padding: 5px 0 0 5px;
}

.memory-counter-sidebar-info {
    flex: 0 0 18px;
    margin-left: 5px;
    white-space: nowrap;
}

.memory-counter-sidebar-info .swatch {
    background-image: none;
    border: 1px solid rgba(0,0,0,0.3);
    opacity: 0.5;
}

.memory-counter-sidebar-info .title {
    margin: 4px;
}

.memory-counter-value {
    margin: 4px;
}

#counter-values-bar {
    flex: 0 0 18px;
    border-bottom: solid 1px lightgray;
    width: 100%;
    overflow: hidden;
    line-height: 18px;
}

.timeline .resources-event-divider {
    height: 19px;
    width: 6px;
    pointer-events: auto;
    margin-left: -2px;
}

.timeline .resources-event-divider::before {
    height: 19px;
    width: 2px;
    margin: 0 2px;
    background-color: rgb(163, 109, 0);
    bottom: auto;
    content: "";
    display: block;
}

.timeline .resources-event-divider:hover::before {
    width: 4px;
    margin: 0 1px;
}

.timeline .resources-event-divider.timeline-frame-divider::before {
    display: none;
}

.timeline .resources-event-divider.resources-red-divider::before {
    background-color: rgb(255, 0, 0);
}

.timeline .resources-event-divider.resources-blue-divider::before {
    background-color: rgb(0, 0, 255);
}

.timeline .resources-event-divider.resources-orange-divider::before {
    background-color: rgb(255, 178, 23);
}

.timeline .resources-event-divider.resources-green-divider::before {
    background-color: rgb(0, 130, 0);
}

.resources-divider:last-child {
    border-color: transparent;
}

.timeline .resources-event-divider.timeline-frame-divider {
    background-color: rgba(180, 180, 180, 0.8);
    border-style: none;
    width: 1px;
    height: 100%;
    pointer-events: none;
}

.timeline-frame-container {
    height: 19px;
    overflow: hidden;
    background-color: rgb(220, 220, 220);
    opacity: 0.8;
    color: black;
    text-align: center;
    z-index: 220;
    pointer-events: auto;
}

.timeline-frame-strip {
    position: absolute;
    height: 19px;
    padding-top: 3px;
}

.timeline-frame-strip.selected {
    background-color: rgb(56, 121, 217);
    color: white;
}

#timeline-grid-header {
    pointer-events: none;
    height: 19px;
}

#timeline-graph-records-header {
    pointer-events: none;
    height: 19px;
    padding: 1px 0;
    justify-content: center;
}

.timeline-utilization-strip {
    z-index: 250;
    overflow: hidden;
    flex: 0 1 12px;
    position: relative;
    height: 9px;
}

.timeline-utilization-strip .timeline-graph-bar {
    border-color: rgb(192, 192, 192);
    background-color: rgba(0, 0, 0, 0.1);
    margin: 1.5px auto;
    height: auto;
}

.timeline-utilization-strip.gpu .timeline-graph-bar {
    background-color: #00a;
    border: none;
    opacity: 0.3;
    min-width: 0;
}

.timeline-utilization-strip.gpu .timeline-graph-bar.gpu-task-foreign {
    background-color: #aaa;
}

.timeline-cpu-curtain-left, .timeline-cpu-curtain-right {
    background-color: rgba(210, 210, 210, 0.5);
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 300;
}

.timeline-cpu-curtain-left {
    left: 0;
}

.timeline-cpu-curtain-right {
    right: 0;
}

.image-preview-container {
    background: transparent;
    text-align: left;
    border-spacing: 0;
}

.image-preview-container img {
    max-width: 100px;
    max-height: 100px;
    background-image: url(Images/checker.png);
    -webkit-user-select: text;
    -webkit-user-drag: auto;
}

.image-container {
    padding: 0;
}

.timeline-filters-header {
    flex: 0 0 23px;
    overflow: hidden;
}

.timeline-details {
    vertical-align: top;
}

.timeline-details-title {
    border-bottom: 1px solid #B8B8B8;
    font-weight: bold;
    padding-bottom: 5px;
    padding-top: 0;
    white-space: nowrap;
}

.timeline-details-row-title {
    font-weight: bold;
    text-align: right;
    white-space: nowrap;
}

.timeline-details-row-data {
    white-space: nowrap;
}

.timeline-details-view {
    color: #333;
    overflow: hidden;
}

.timeline-details-view-body {
    flex: auto;
    overflow: auto;
    position: relative;
    background-color: #eee;
}

.timeline-details-view-block {
    flex: none;
    display: flex;
    flex-direction: column;
}

.timeline-details-view-row {
    display: flex;
    border-bottom: 1px solid #e1e1e1;
}

.timeline-details-view-row-title {
    font-weight: bold;
    color: rgb(48, 57, 66);
    width: 170px;
    line-height: 24px;
    padding-left: 10px;
    flex: none;
}

.timeline-details-view-row-value {
    padding-left: 10px;
    border-left: 1px solid #e1e1e1;
    min-height: 24px;
    line-height: 24px;
    -webkit-user-select: text;
}

.timeline-details-view-row-details {
    padding-left: 10px;
}

.timeline-details-view-pie-chart-wrapper {
    margin: 8px 10px 8px 0;
}

.timeline-details-view-pie-chart {
    margin-right: 8px;
}

.timeline-details-view-row-details .image-preview-container {
    padding: 10px;
}

.timeline-details-view-row-details table {
    padding-left: 10px;
}

.timeline-details-view-row-details table td {
    text-align: left;
    vertical-align: top;
}

.timeline-details-view-row-details table td .section {
    margin-top: -1px;
}

.timeline-details-view-row-details table td .section  > .header .title {
    white-space: nowrap;
}

.timeline-details-view-row-stack-trace {
    padding: 4px 0 4px 20px;
}

.timeline-details-view-row-stack-trace div {
    white-space: nowrap;
    text-overflow: ellipsis;
    line-height: 12px;
}

.timeline-details-view-row-stack-trace .webkit-html-external-link,
.timeline-details-view-row-stack-trace .webkit-html-resource-link {
    color: #333 !important;
}

.timeline-aggregated-info {
    flex: none;
    position: relative;
    margin-left:  5px;
}

.timeline-aggregated-info-legend > div {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.timeline-flamechart {
    overflow: hidden;
}

.timeline-progress-pane {
    color: #777;
    background-color: rgba(255, 255, 255, 0.8);
    font-size: 30px;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.layer-tree.outline-disclosure {
    z-index: 10;
}

.layer-tree.outline-disclosure > ol,
.profiler-log-view > ol {
    margin-left: -12px
    overflow: auto;
}

.layer-tree.outline-disclosure ol.children,
.profiler-log-view ol.children {
    margin-left: -14px;
    padding-left: 22px;
}

.layer-tree.outline-disclosure li,
.profiler-log-view li {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height: 16px;
    line-height: 16px;
    margin-top: 0;
}

.layer-tree.outline-disclosure .dimmed {
    opacity: 0.6;
}

.layers-3d-view {
    overflow: hidden;
    -webkit-user-select: none;
}

.layers-3d-view canvas {
    flex: 1 1;
}

.transform-control-panel {
    white-space: nowrap;
    flex: none;
}

.layer-details-view .empty-view {
    font-size: 16px;
}

.layer-details-view table td {
    padding-left: 8px;
}

.layer-details-view table td:first-child {
    font-weight: bold;
}

.layer-details-view .scroll-rect.active {
    background-color: rgba(100, 100, 100, 0.2);
}

.paint-profiler-overview .progress-banner {
    color: #777;
    background-color: rgba(255, 255, 255, 0.8);
    font-size: 20px;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.paint-profiler-canvas-container {
    flex: auto;
    position: relative;
}

.paint-profiler-overview {
    background-color: #eee;
}

.paint-profiler-pie-chart {
    width: 60px !important;
    height: 60px !important;
    padding: 2px;
    overflow: hidden;
    font-size: 10px;
}

.profiler-log-view.outline-disclosure,
.layer-tree.outline-disclosure {
    font-size: 12px;
    line-height: 14px;
}

.profiler-log-view.outline-disclosure li.parent::before,
.layer-tree.outline-disclosure li.parent::before  {
    top: 1px;
}

.paint-profiler-canvas-container canvas {
    z-index: 200;
    background-color: white;
    opacity: 0.95;
    height: 100%;
    width: 100%;
}

.paint-profiler-canvas-container .overview-grid-dividers-background,
.paint-profiler-canvas-container .overview-grid-window {
    bottom: 0;
    height: auto;
}

.paint-profiler-canvas-container .overview-grid-window-resizer {
    z-index: 2000;
}

.profiler-log-view .console-formatted-string {
    white-space: nowrap;
}

.profiler-log-view.section .properties {
    display: block;
    padding-right: 0 !important;
}

.paint-profiler-image-view {
    overflow: hidden;
}

.paint-profiler-image-view .paint-profiler-image-container {
    -webkit-transform-origin: 0 0;
}

.paint-profiler-image-view .paint-profiler-image-container div {
    border-color: rgba(100, 100, 100, 0.4);
    border-style: solid;
    z-index: 100;
    position: absolute;
    top: 0;
    left: 0;
}

.paint-profiler-image-view img {
    border: solid 1px black;
}

.layer-details-view ul {
    list-style: none;
    -webkit-padding-start: 0;
    -webkit-margin-before: 0;
    -webkit-margin-after: 0;
}

.layer-details-view a {
    padding: 8px;
    display: block;
}

.timeline-layers-view > div:last-child,
.timeline-layers-view-properties > div:last-child {
    background-color: #eee;
}

.timeline-layers-view-properties table {
    width: 100%;
    border-collapse: collapse;
}

.timeline-layers-view-properties td {
    border: 1px solid #e1e1e1;
    line-height: 22px;
}

.timeline-paint-profiler-log-split > div:last-child {
    background-color: #eee;
    z-index: 0;
}

.timeline-gap {
    flex: none;
}

.invalidations-group {
    margin-top: 4px;
    line-height: normal;
}

.invalidations-group > .header {
    padding-left: 0;
}

.invalidations-group > .content {
    margin-left: 25px;
}

.invalidations-group > .content > .node-list {
    border-left: 1px solid #e1e1e1;
}


text:
var Arrow = require('arrow'),
	fs = require('fs'),
	path = require('path');

exports.generateModels = function generateModels(schema, next) {
	var generator = require('../generator'),
		self = this,
		modelDir = this.getModelDir();

	// Set models to an empty object, in case we get an error, so versions of Arrow<1.4.9 don't choke.
	self.models = {};

	generator.generateModels(self.name, modelDir, schema, !!this.config.modelAutogen, function (err) {
		if (err) {
			return next && next(self.parseError(err));
		}

		self.logger.debug('loading connector/' + self.name + ' models from', modelDir);
		self.models = Arrow.loadModelsForConnector(self.name, module, modelDir);

		if (next) {
			next();
		}
	});
};


text:
from .lims_autosamplerMethod_postgresql_models import *

from SBaaS_base.sbaas_base_query_update import sbaas_base_query_update
from SBaaS_base.sbaas_base_query_drop import sbaas_base_query_drop
from SBaaS_base.sbaas_base_query_initialize import sbaas_base_query_initialize
from SBaaS_base.sbaas_base_query_insert import sbaas_base_query_insert
from SBaaS_base.sbaas_base_query_select import sbaas_base_query_select
from SBaaS_base.sbaas_base_query_delete import sbaas_base_query_delete

from SBaaS_base.sbaas_template_query import sbaas_template_query

class lims_autosamplerMethod_query(sbaas_template_query):
    def initialize_supportedTables(self):
        '''Set the supported tables dict for
        '''
        tables_supported = {'autosampler_parameters':autosampler_parameters,
                            'autosampler_information':autosampler_information,
                            'autosampler_method':autosampler_method,
                        };
        self.set_supportedTables(tables_supported);

    #table initializations:
    def drop_lims_autosamplerMethod(self):
        try:
            autosampler_parameters.__table__.drop(self.engine,True);
            autosampler_information.__table__.drop(self.engine,True);
            autosampler_method.__table__.drop(self.engine,True);

        except SQLAlchemyError as e:
            print(e);
    def reset_lims_autosamplerMethod(self):
        try:
            reset = self.session.query(autosampler_parameters).delete(synchronize_session=False);
            reset = self.session.query(autosampler_information).delete(synchronize_session=False);
            reset = self.session.query(autosampler_method).delete(synchronize_session=False);

            self.session.commit();
        except SQLAlchemyError as e:
            print(e);
    def initialize_lims_autosamplerMethod(self):
        try:
            autosampler_parameters.__table__.create(self.engine,True);
            autosampler_information.__table__.create(self.engine,True);
            autosampler_method.__table__.create(self.engine,True);

        except SQLAlchemyError as e:
            print(e);


text:
export { DateRangeHandler } from './DateRangeHandler/DateRangeHandler';
export { DateTimeRangeHandler } from './DateTimeRangeHandler/DateTimeRangeHandler';
export { TimeRangeHandler } from './TimeRangeHandler/TimeRangeHandler';
export { NumberRangeHandler } from './NumberRangeHandler/NumberRangeHandler';
export { IntegerRangeHandler } from './IntegerRangeHandler/IntegerRangeHandler';


text:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Threading;
using System.Xml.Linq;

using feal.PantryGuide.AmznClient.Data;
using feal.PantryGuide.AmznClient.Logic;
using log4net;

namespace feal.PantryGuide.AmznClient
{
  public class Amzn
  {

    #region log

    private static readonly ILog log = LogManager.GetLogger(typeof(Amzn));

    #endregion

    #region aws credentials

    private static string AWS_ACCESS_KEY_ID = "xxx";
    private static string AWS_SECRET_KEY = "xx";
    private static string ENDPOINT = "webservices.amazon.com";
    private static string ASSOCIATE_TAG = "pantryguide-20";

    private static int AWS_CONNECTION_TRIES = 3;

    #endregion

    #region private members

    //alike singleton
    private static readonly SignedRequestHelper signedHelper =
      new SignedRequestHelper(AWS_ACCESS_KEY_ID, AWS_SECRET_KEY, ENDPOINT);

    #endregion

    public static List<AItem> GetProducts(string keywords,
      string sortBy = "",
      int startPage = 1,
      int endPage = 1)
    {
      var result = new List<AItem>();
      for (var itemPage = startPage; itemPage <= endPage; itemPage++)
      {
        //build params
        var parameters = new Dictionary<string, string>()
        {
          {"Service", "AWSECommerceService"},
          {"Operation", "ItemSearch"},
          {"AWSAccessKeyId", AWS_ACCESS_KEY_ID},
          {"AssociateTag", ASSOCIATE_TAG},
          {"SearchIndex", "Pantry"},
          {"Keywords", keywords},
          {"ResponseGroup", "ItemAttributes,Large"},
          {"ItemPage", itemPage.ToString()}
        };

        if (!string.IsNullOrEmpty(sortBy))
        {
          parameters.Add("Sort", sortBy);
        }

        bool success;
        var xmlResponse = GetAwsResponse(parameters, out success);
        if (!success)
        {
          return result;
        }
        try
        {
          //using a very small amount of linq to parse the xml ;)
          result.AddRange
          (
            from item in xmlResponse.SingleDescendentsByName("Items")
              ?.DescendentsByName("Item")

            let itemAttributes = item.SingleDescendentsByName("ItemAttributes")
            let listPrice = itemAttributes?.SingleDescendentsByName("ListPrice")
            let packageDimensions = item.SingleDescendentsByName("PackageDimensions")
            let smallImage = item.SingleDescendentsByName("SmallImage")
            let mediumImage = item.SingleDescendentsByName("MediumImage")
            let largeImage = item.SingleDescendentsByName("LargeImage")

            select new AItem()
            {
              Asin = item.ElementValueByName<string>("ASIN"),
              Url = item.ElementValueByName<string>("DetailPageURL"),
              SalesRank = item.ElementValueByName<int>("SalesRank"),
              ImageSet = new AImageSet()
              {
                SmallImage = new AImage()
                {
                  Dimensions = new Rectangle()
                  {
                    Height = smallImage?.ElementValueByName<int>("Height") ?? 0,
                    Width = smallImage?.ElementValueByName<int>("Width") ?? 0
                  },
                  Url = smallImage?.ElementValueByName<string>("URL")
                },
                MediumImage = new AImage()
                {
                  Dimensions = new Rectangle()
                  {
                    Height = mediumImage?.ElementValueByName<int>("Height") ?? 0,
                    Width = mediumImage?.ElementValueByName<int>("Width") ?? 0
                  },
                  Url = mediumImage?.ElementValueByName<string>("URL")
                },
                LargeImage = new AImage()
                {
                  Dimensions = new Rectangle()
                  {
                    Height = largeImage?.ElementValueByName<int>("Height") ?? 0,
                    Width = largeImage?.ElementValueByName<int>("Width") ?? 0
                  },
                  Url = largeImage?.ElementValueByName<string>("URL")
                }
              },
              Brand = itemAttributes?.ElementValueByName<string>("Brand"),
              Price = listPrice?.ElementValueByName<int>("Amount") ?? 0,
              Currency = listPrice?.ElementValueByName<string>("CurrencyCode"),
              FormattedPrice = listPrice?.ElementValueByName<string>("FormattedPrice"),
              Quantity = itemAttributes?.ElementValueByName<int>("NumberOfItems") ?? 0,
              PackageDimensions = new APackageDimensions()
              {
                Height = packageDimensions?.ElementValueByName<int>("Height") ?? 0,
                Length = packageDimensions?.ElementValueByName<int>("Length") ?? 0,
                Width = packageDimensions?.ElementValueByName<int>("Width") ?? 0,
                Weight = packageDimensions?.ElementValueByName<int>("Weight") ?? 0,
                Unit = packageDimensions?.Elements()?.FirstOrDefault()?.Attributes()?.FirstOrDefault()?.Value
              },
              Category = itemAttributes?.ElementValueByName<string>("ProductGroup"),
              Title = itemAttributes?.ElementValueByName<string>("Title"),
              Description =
                itemAttributes?.DescendentsByName("Feature")?.Select(des => des?.Value)?.Aggregate((a, b) => $"{a}\n{b}")
            }
          );
        }
        catch (Exception ex)
        {
          log.Error(ex);
        }
      }
      return result;
    }

    public static List<AItem> GetTopSeller(string nodeId,
                                           int startPage = 1,
                                           int endPage = 1)
    {
      var result = new List<AItem>();
      for (var itemPage = startPage; itemPage <= endPage; itemPage++)
      {
        //build params
        var parameters = new Dictionary<string, string>()
        {
          {"Service", "AWSECommerceService"},
          {"Operation", "BrowseNodeLookup"},
          {"AWSAccessKeyId", AWS_ACCESS_KEY_ID},
          {"AssociateTag", ASSOCIATE_TAG},
          {"SearchIndex", "Pantry"},
          {"BrowseNodeId", nodeId},
          {"ResponseGroup", "TopSellers"},
          {"ItemPage", itemPage.ToString() }
        };

        bool success;
        //due to problems with heavy amazon querying -> wait
        Thread.Sleep(200);
        var xmlResponse = GetAwsResponse(parameters, out success);

        if (!success) return result;

        //get all top seller asins from node
        var asins =
          xmlResponse.SingleDescendentsByName("BrowseNodes")
            ?.DescendentsByName("BrowseNode")
            ?.SelectMany(node => node.DescendentsByName("TopItemSet"))
            ?.SelectMany(node => node.DescendentsByName("TopItem"))
            ?.Select(node => node.ElementValueByName<string>("ASIN"));

        if (asins == null) return result;

        //get product info
        foreach (var asin in asins)
        {
          //amazon api is very sensitive in case of high speed so lets sleep
          Thread.Sleep(200);
          var item = GetProducts(asin).FirstOrDefault();
          if (item != null)
          {
            result.Add(item);
          }
        }
      }
      return result;
    }

    public static List<ACategory> GetChildCategories(string nodeId,
      int startPage = 1,
      int endPage = 1)
    {
      var result = new List<ACategory>();
      for (var itemPage = startPage; itemPage <= endPage; itemPage++)
      {
        //build params
        var parameters = new Dictionary<string, string>()
        {
          {"Service", "AWSECommerceService"},
          {"Operation", "BrowseNodeLookup"},
          {"AWSAccessKeyId", AWS_ACCESS_KEY_ID},
          {"AssociateTag", ASSOCIATE_TAG},
          {"SearchIndex", "Pantry"},
          {"BrowseNodeId", nodeId},
          {"ResponseGroup", "BrowseNodeInfo"},
          {"ItemPage", itemPage.ToString() }
        };

        bool success;
        var xmlResponse = GetAwsResponse(parameters, out success);

        if(!success) return result;

        result.AddRange
        (
          from child in xmlResponse.SingleDescendentsByName("BrowseNodes")
            ?.DescendentsByName("BrowseNode")
            ?.SelectMany(node => node.DescendentsByName("Children"))
            ?.SelectMany(node => node.DescendentsByName("BrowseNode"))
          select new ACategory()
          {
            Node = child.ElementValueByName<string>("BrowseNodeId"),
            Name = child.ElementValueByName<string>("Name")
          }
        );

      }
      return result;

    }

    public static void CreateCart(IDictionary<AItem, int> items)
    {
      var parameters = new Dictionary<string, string>()
        {
          {"Service", "AWSECommerceService"},
          {"Operation", "CartCreate"},
          {"AWSAccessKeyId", AWS_ACCESS_KEY_ID},
          {"AssociateTag", ASSOCIATE_TAG},
        };

      var cntr = 1;
      foreach (var item in items)
      {
        parameters.Add($"Item.{cntr}.OfferListingId", item.Key.Asin);
        parameters.Add($"Item.{cntr}.Quantity", item.Key.ToString());
        cntr++;
      }

      bool success;
      var result = GetAwsResponse(parameters, out success);
      if (!success)
      {
        return;
      }

      //todo parse
    }

    private static XElement GetAwsResponse(IDictionary<string, string> parameters, out bool success)
    {
      success = false;
      //build url
      string response = null;

      using (var wc = new WebClient())
      {
        //try several times
        for (var i = 0; i < AWS_CONNECTION_TRIES; i++)
        {
          var url = signedHelper.Sign(parameters);
          //get response
          try
          {
            response = wc.DownloadString(url);
            success = true;
          }
          catch(Exception ex)
          {
            //Error -> return
            success = false;
            Thread.Sleep(500 * (i + 1));
          }
          if (success)
          {
            //found result -> exit for
            break;
          }
        }
      }

      //nothing found...
      if (!success)
      {
        return null;
      }

      //parse xml using (heavy) linq
      try
      {
        success = true;
        return XElement.Parse(response);
      }
      catch
      {
        success = false;
        return null;
      }
    }

  }
}


text:
  <button type="button" class="close" ng-click="cancel()">

  </button>

�Estas seguro de realizar esta operacion?

  <fieldset class="border-top">
    <legend>Cuenta personal</legend>

TIPO CUENTA:

SOCIO:

DOCUMENTO:

ESTADO CUENTA:

  </fieldset>
  <fieldset class="border-top">
    <legend>Datos de capitalizacion</legend>

DESDE:

HASTA:

MONTO A CAPITALIZAR:

  </fieldset>

  <button class="btn btn-primary" data-ng-click="ok()">Guardar</button>
  <button class="btn btn-default" data-ng-click="cancel()">Cancelar</button>


text:
package com.google.auth;

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;

import com.google.api.client.json.GenericJson;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Utilities for test code under com.google.auth.
 */
public class TestUtils {

  private static final String UTF_8 = "UTF-8";

  private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();

  public static void assertContainsBearerToken(Map<String, List<String>> metadata, String token) {
    assertNotNull(metadata);
    assertNotNull(token);
    String expectedValue = "Bearer " + token;
    List<String> authorizations = metadata.get("Authorization");
    assertNotNull("Authorization headers not found", authorizations);
    boolean found = false;
    for (String authorization : authorizations) {
      if (expectedValue.equals(authorization)) {
        found = true;
        break;
      }
    }
    assertTrue("Bearer token not found", found);
  }

  public static InputStream jsonToInputStream(GenericJson json) throws IOException {
    json.setFactory(JSON_FACTORY);
    String text = json.toPrettyString();
    InputStream stream = new ByteArrayInputStream(text.getBytes(UTF_8));
    return stream;
  }

  public static Map<String, String> parseQuery(String query) throws IOException {
    Map<String, String> map = new HashMap<String, String>();
    Iterable<String> entries = Splitter.on('&').split(query);
    for (String entry : entries) {
      List<String> sides = Lists.newArrayList(Splitter.on('=').split(entry));
      if (sides.size() != 2) {
        throw new IOException("Invalid Query String");
      }
      String key = URLDecoder.decode(sides.get(0), UTF_8);
      String value = URLDecoder.decode(sides.get(1), UTF_8);
      map.put(key, value);
    }
    return map;
  }

  private TestUtils() {
  }
}


text:
'use strict';

var expect = require('chai').expect;
var express = require('express');
var request = require('supertest');
var bodyParser = require('body-parser')
var cookieParser = require('cookie-parser');
var expressSession = require('express-session');
var Passwordless = require('../../').Passwordless;
var TokenStoreMock = require('../mock/tokenstoremock');
var Mocks = require('../mock/mocks');

describe('passwordless', function() {
	describe('requestToken', function() {

		describe('several strategies', function() {
			var mocks = new Mocks();
			var app = express();
			var passwordless = new Passwordless();
			passwordless.init(new TokenStoreMock());

			app.use(bodyParser.json());
			app.use(bodyParser.urlencoded({extended: false}));

			passwordless.addDelivery('email', mocks.deliveryMockSend('email'));
			passwordless.addDelivery('sms', mocks.deliveryMockSend('sms'));

			app.post('/login', passwordless.requestToken(mocks.getUserId()),
				function(req, res){
					res.status(200).send();
			});

			var agent1 = request.agent(app);
			var agent2 = request.agent(app);

			it('should return 400 if the field "delivery" is not provided', function (done) {
				agent1
					.post('/login')
					.send( { user: mocks.alice().email } )
					.expect(400, done);
			})

			it('should not have sent or stored any tokens so far', function () {
				expect(mocks.delivered.length).to.equal(0);
			})

			it('should return 400 if the field "delivery" contains an invalid value', function (done) {
				agent1
					.post('/login')
					.send( { user: mocks.alice().email, delivery: 'snailmail' } )
					.expect(400, done);
			})

			it('should not have sent or stored any tokens so far', function () {
				expect(mocks.delivered.length).to.equal(0);
			})

			it('should deliver token for a valid delivery method', function (done) {
				agent1
					.post('/login')
					.send( { user: mocks.alice().phone, delivery: 'sms' } )
					.expect(200, done);
			})

			it('should have sent and stored token', function () {
				expect(mocks.delivered.length).to.equal(1);
				expect(mocks.delivered[0].delivery).to.equal('sms');
			})

			it('should deliver token for a valid delivery method (2)', function (done) {
				agent2
					.post('/login')
					.send( { user: mocks.alice().email, delivery: 'email' } )
					.expect(200, done);
			})

			it('should have sent and stored token', function () {
				expect(mocks.delivered.length).to.equal(2);
				expect(mocks.delivered[1].delivery).to.equal('email');
			})
		})

		describe('option(deliveryField)', function() {
			var mocks = new Mocks();
			var app = express();
			var passwordless = new Passwordless();
			passwordless.init(new TokenStoreMock());

			app.use(bodyParser.json());
			app.use(bodyParser.urlencoded({extended: false}));

			passwordless.addDelivery('email', mocks.deliveryMockSend('email'));
			passwordless.addDelivery('sms', mocks.deliveryMockSend('sms'));

			app.post('/login', passwordless.requestToken(mocks.getUserId(), {deliveryField: 'method'}),
				function(req, res){
					res.status(200).send();
			});

			var agent = request.agent(app);

			it('should deliver token for a valid delivery strategy', function (done) {
				mocks.delivered = [];
				agent
					.post('/login')
					.send( { user: mocks.alice().phone, method: 'sms' } )
					.expect(200, done);
			})

			it('should have sent and stored token', function () {
				expect(mocks.delivered.length).to.equal(1);
				expect(mocks.delivered[0].delivery).to.equal('sms');
			})
		})
	})
})


text:
pinion.backend.input.Button = (function($) {

    var constr;

    constr = function(settings) {
        this.$element = $("

");

        this._counter = 0;
    };

    constr.prototype = {
        constructor: pinion.backend.input.Button,
        defaultSettings: {
            label: "send",
            click: null,
            translate: true
        },
        init: function() {
            var _this = this,
                label = this.settings.translate ? pinion.translate(this.settings.label) : this.settings.label;

            // JAVASCRIPT SETTINGS
            if(this.settings.click) {
                this.click(this.settings.click);
            }

            this.$button = $("<input type='submit' value='"+label+"' />")
                .click(function() {
                    _this.fire("click");
                    return false;
                })
                .appendTo(this.$element);
        },
        click: function(callback) {
            if(callback === undefined) {
                this.$button.click();
                return this;
            } else {
                return this.on("click", callback);
            }
        },
        reset: function() {
            this._counter = 0;
        }
    };

    return constr;

}(jQuery));